| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933156934156935156936156937156938156939156940156941156942156943156944156945156946156947156948156949156950156951156952156953156954156955156956156957156958156959156960156961156962156963156964156965156966156967156968156969156970156971156972156973156974156975156976156977156978156979156980156981156982156983156984156985156986156987156988156989156990156991156992156993156994156995156996156997156998156999157000157001157002157003157004157005157006157007157008157009157010157011157012157013157014157015157016157017157018157019157020157021157022157023157024157025157026157027157028157029157030157031157032157033157034157035157036157037157038157039157040157041157042157043157044157045157046157047157048157049157050157051157052157053157054157055157056157057157058157059157060157061157062157063157064157065157066157067157068157069157070157071157072157073157074157075157076157077157078157079157080157081157082157083157084157085157086157087157088157089157090157091157092157093157094157095157096157097157098157099157100157101157102157103157104157105157106157107157108157109157110157111157112157113157114157115157116157117157118157119157120157121157122157123157124157125157126157127157128157129157130157131157132157133157134157135157136157137157138157139157140157141157142157143157144157145157146157147157148157149157150157151157152157153157154157155157156157157157158157159157160157161157162157163157164157165157166157167157168157169157170157171157172157173157174157175157176157177157178157179157180157181157182157183157184157185157186157187157188157189157190157191157192157193157194157195157196157197157198157199157200157201157202157203157204157205157206157207157208157209157210157211157212157213157214157215157216157217157218157219157220157221157222157223157224157225157226157227157228157229157230157231157232157233157234157235157236157237157238157239157240157241157242157243157244157245157246157247157248157249157250157251157252157253157254157255157256157257157258157259157260157261157262157263157264157265157266157267157268157269157270157271157272157273157274157275157276157277157278157279157280157281157282157283157284157285157286157287157288157289157290157291157292157293157294157295157296157297157298157299157300157301157302157303157304157305157306157307157308157309157310157311157312157313157314157315157316157317157318157319157320157321157322157323157324157325157326157327157328157329157330157331157332157333157334157335157336157337157338157339157340157341157342157343157344157345157346157347157348157349157350157351157352157353157354157355157356157357157358157359157360157361157362157363157364157365157366157367157368157369157370157371157372157373157374157375157376157377157378157379157380157381157382157383157384157385157386157387157388157389157390157391157392157393157394157395157396157397157398157399157400157401157402157403157404157405157406157407157408157409157410157411157412157413157414157415157416157417157418157419157420157421157422157423157424157425157426157427157428157429157430157431157432157433157434157435157436157437157438157439157440157441157442157443157444157445157446157447157448157449157450157451157452157453157454157455157456157457157458157459157460157461157462157463157464157465157466157467157468157469157470157471157472157473157474157475157476157477157478157479157480157481157482157483157484157485157486157487157488157489157490157491157492157493157494157495157496157497157498157499157500157501157502157503157504157505157506157507157508157509157510157511157512157513157514157515157516157517157518157519157520157521157522157523157524157525157526157527157528157529157530157531157532157533157534157535157536157537157538157539157540157541157542157543157544157545157546157547157548157549157550157551157552157553157554157555157556157557157558157559157560157561157562157563157564157565157566157567157568157569157570157571157572157573157574157575157576157577157578157579157580157581157582157583157584157585157586157587157588157589157590157591157592157593157594157595157596157597157598157599157600157601157602157603157604157605157606157607157608157609157610157611157612157613157614157615157616157617157618157619157620157621157622157623157624157625157626157627157628157629157630157631157632157633157634157635157636157637157638157639157640157641157642157643157644157645157646157647157648157649157650157651157652157653157654157655157656157657157658157659157660157661157662157663157664157665157666157667157668157669157670157671157672157673157674157675157676157677157678157679157680157681157682157683157684157685157686157687157688157689157690157691157692157693157694157695157696157697157698157699157700157701157702157703157704157705157706157707157708157709157710157711157712157713157714157715157716157717157718157719157720157721157722157723157724157725157726157727157728157729157730157731157732157733157734157735157736157737157738157739157740157741157742157743157744157745157746157747157748157749157750157751157752157753157754157755157756157757157758157759157760157761157762157763157764157765157766157767157768157769157770157771157772157773157774157775157776157777157778157779157780157781157782157783157784157785157786157787157788157789157790157791157792157793157794157795157796157797157798157799157800157801157802157803157804157805157806157807157808157809157810157811157812157813157814157815157816157817157818157819157820157821157822157823157824157825157826157827157828157829157830157831157832157833157834157835157836157837157838157839157840157841157842157843157844157845157846157847157848157849157850157851157852157853157854157855157856157857157858157859157860157861157862157863157864157865157866157867157868157869157870157871157872157873157874157875157876157877157878157879157880157881157882157883157884157885157886157887157888157889157890157891157892157893157894157895157896157897157898157899157900157901157902157903157904157905157906157907157908157909157910157911157912157913157914157915157916157917157918157919157920157921157922157923157924157925157926157927157928157929157930157931157932157933157934157935157936157937157938157939157940157941157942157943157944157945157946157947157948157949157950157951157952157953157954157955157956157957157958157959157960157961157962157963157964157965157966157967157968157969157970157971157972157973157974157975157976157977157978157979157980157981157982157983157984157985157986157987157988157989157990157991157992157993157994157995157996157997157998157999158000158001158002158003158004158005158006158007158008158009158010158011158012158013158014158015158016158017158018158019158020158021158022158023158024158025158026158027158028158029158030158031158032158033158034158035158036158037158038158039158040158041158042158043158044158045158046158047158048158049158050158051158052158053158054158055158056158057158058158059158060158061158062158063158064158065158066158067158068158069158070158071158072158073158074158075158076158077158078158079158080158081158082158083158084158085158086158087158088158089158090158091158092158093158094158095158096158097158098158099158100158101158102158103158104158105158106158107158108158109158110158111158112158113158114158115158116158117158118158119158120158121158122158123158124158125158126158127158128158129158130158131158132158133158134158135158136158137158138158139158140158141158142158143158144158145158146158147158148158149158150158151158152158153158154158155158156158157158158158159158160158161158162158163158164158165158166158167158168158169158170158171158172158173158174158175158176158177158178158179158180158181158182158183158184158185158186158187158188158189158190158191158192158193158194158195158196158197158198158199158200158201158202158203158204158205158206158207158208158209158210158211158212158213158214158215158216158217158218158219158220158221158222158223158224158225158226158227158228158229158230158231158232158233158234158235158236158237158238158239158240158241158242158243158244158245158246158247158248158249158250158251158252158253158254158255158256158257158258158259158260158261158262158263158264158265158266158267158268158269158270158271158272158273158274158275158276158277158278158279158280158281158282158283158284158285158286158287158288158289158290158291158292158293158294158295158296158297158298158299158300158301158302158303158304158305158306158307158308158309158310158311158312158313158314158315158316158317158318158319158320158321158322158323158324158325158326158327158328158329158330158331158332158333158334158335158336158337158338158339158340158341158342158343158344158345158346158347158348158349158350158351158352158353158354158355158356158357158358158359158360158361158362158363158364158365158366158367158368158369158370158371158372158373158374158375158376158377158378158379158380158381158382158383158384158385158386158387158388158389158390158391158392158393158394158395158396158397158398158399158400158401158402158403158404158405158406158407158408158409158410158411158412158413158414158415158416158417158418158419158420158421158422158423158424158425158426158427158428158429158430158431158432158433158434158435158436158437158438158439158440158441158442158443158444158445158446158447158448158449158450158451158452158453158454158455158456158457158458158459158460158461158462158463158464158465158466158467158468158469158470158471158472158473158474158475158476158477158478158479158480158481158482158483158484158485158486158487158488158489158490158491158492158493158494158495158496158497158498158499158500158501158502158503158504158505158506158507158508158509158510158511158512158513158514158515158516158517158518158519158520158521158522158523158524158525158526158527158528158529158530158531158532158533158534158535158536158537158538158539158540158541158542158543158544158545158546158547158548158549158550158551158552158553158554158555158556158557158558158559158560158561158562158563158564158565158566158567158568158569158570158571158572158573158574158575158576158577158578158579158580158581158582158583158584158585158586158587158588158589158590158591158592158593158594158595158596158597158598158599158600158601158602158603158604158605158606158607158608158609158610158611158612158613158614158615158616158617158618158619158620158621158622158623158624158625158626158627158628158629158630158631158632158633158634158635158636158637158638158639158640158641158642158643158644158645158646158647158648158649158650158651158652158653158654158655158656158657158658158659158660158661158662158663158664158665158666158667158668158669158670158671158672158673158674158675158676158677158678158679158680158681158682158683158684158685158686158687158688158689158690158691158692158693158694158695158696158697158698158699158700158701158702158703158704158705158706158707158708158709158710158711158712158713158714158715158716158717158718158719158720158721158722158723158724158725158726158727158728158729158730158731158732158733158734158735158736158737158738158739158740158741158742158743158744158745158746158747158748158749158750158751158752158753158754158755158756158757158758158759158760158761158762158763158764158765158766158767158768158769158770158771158772158773158774158775158776158777158778158779158780158781158782158783158784158785158786158787158788158789158790158791158792158793158794158795158796158797158798158799158800158801158802158803158804158805158806158807158808158809158810158811158812158813158814158815158816158817158818158819158820158821158822158823158824158825158826158827158828158829158830158831158832158833158834158835158836158837158838158839158840158841158842158843158844158845158846158847158848158849158850158851158852158853158854158855158856158857158858158859158860158861158862158863158864158865158866158867158868158869158870158871158872158873158874158875158876158877158878158879158880158881158882158883158884158885158886158887158888158889158890158891158892158893158894158895158896158897158898158899158900158901158902158903158904158905158906158907158908158909158910158911158912158913158914158915158916158917158918158919158920158921158922158923158924158925158926158927158928158929158930158931158932158933158934158935158936158937158938158939158940158941158942158943158944158945158946158947158948158949158950158951158952158953158954158955158956158957158958158959158960158961158962158963158964158965158966158967158968158969158970158971158972158973158974158975158976158977158978158979158980158981158982158983158984158985158986158987158988158989158990158991158992158993158994158995158996158997158998158999159000159001159002159003159004159005159006159007159008159009159010159011159012159013159014159015159016159017159018159019159020159021159022159023159024159025159026159027159028159029159030159031159032159033159034159035159036159037159038159039159040159041159042159043159044159045159046159047159048159049159050159051159052159053159054159055159056159057159058159059159060159061159062159063159064159065159066159067159068159069159070159071159072159073159074159075159076159077159078159079159080159081159082159083159084159085159086159087159088159089159090159091159092159093159094159095159096159097159098159099159100159101159102159103159104159105159106159107159108159109159110159111159112159113159114159115159116159117159118159119159120159121159122159123159124159125159126159127159128159129159130159131159132159133159134159135159136159137159138159139159140159141159142159143159144159145159146159147159148159149159150159151159152159153159154159155159156159157159158159159159160159161159162159163159164159165159166159167159168159169159170159171159172159173159174159175159176159177159178159179159180159181159182159183159184159185159186159187159188159189159190159191159192159193159194159195159196159197159198159199159200159201159202159203159204159205159206159207159208159209159210159211159212159213159214159215159216159217159218159219159220159221159222159223159224159225159226159227159228159229159230159231159232159233159234159235159236159237159238159239159240159241159242159243159244159245159246159247159248159249159250159251159252159253159254159255159256159257159258159259159260159261159262159263159264159265159266159267159268159269159270159271159272159273159274159275159276159277159278159279159280159281159282159283159284159285159286159287159288159289159290159291159292159293159294159295159296159297159298159299159300159301159302159303159304159305159306159307159308159309159310159311159312159313159314159315159316159317159318159319159320159321159322159323159324159325159326159327159328159329159330159331159332159333159334159335159336159337159338159339159340159341159342159343159344159345159346159347159348159349159350159351159352159353159354159355159356159357159358159359159360159361159362159363159364159365159366159367159368159369159370159371159372159373159374159375159376159377159378159379159380159381159382159383159384159385159386159387159388159389159390159391159392159393159394159395159396159397159398159399159400159401159402159403159404159405159406159407159408159409159410159411159412159413159414159415159416159417159418159419159420159421159422159423159424159425159426159427159428159429159430159431159432159433159434159435159436159437159438159439159440159441159442159443159444159445159446159447159448159449159450159451159452159453159454159455159456159457159458159459159460159461159462159463159464159465159466159467159468159469159470159471159472159473159474159475159476159477159478159479159480159481159482159483159484159485159486159487159488159489159490159491159492159493159494159495159496159497159498159499159500159501159502159503159504159505159506159507159508159509159510159511159512159513159514159515159516159517159518159519159520159521159522159523159524159525159526159527159528159529159530159531159532159533159534159535159536159537159538159539159540159541159542159543159544159545159546159547159548159549159550159551159552159553159554159555159556159557159558159559159560159561159562159563159564159565159566159567159568159569159570159571159572159573159574159575159576159577159578159579159580159581159582159583159584159585159586159587159588159589159590159591159592159593159594159595159596159597159598159599159600159601159602159603159604159605159606159607159608159609159610159611159612159613159614159615159616159617159618159619159620159621159622159623159624159625159626159627159628159629159630159631159632159633159634159635159636159637159638159639159640159641159642159643159644159645159646159647159648159649159650159651159652159653159654159655159656159657159658159659159660159661159662159663159664159665159666159667159668159669159670159671159672159673159674159675159676159677159678159679159680159681159682159683159684159685159686159687159688159689159690159691159692159693159694159695159696159697159698159699159700159701159702159703159704159705159706159707159708159709159710159711159712159713159714159715159716159717159718159719159720159721159722159723159724159725159726159727159728159729159730159731159732159733159734159735159736159737159738159739159740159741159742159743159744159745159746159747159748159749159750159751159752159753159754159755159756159757159758159759159760159761159762159763159764159765159766159767159768159769159770159771159772159773159774159775159776159777159778159779159780159781159782159783159784159785159786159787159788159789159790159791159792159793159794159795159796159797159798159799159800159801159802159803159804159805159806159807159808159809159810159811159812159813159814159815159816159817159818159819159820159821159822159823159824159825159826159827159828159829159830159831159832159833159834159835159836159837159838159839159840159841159842159843159844159845159846159847159848159849159850159851159852159853159854159855159856159857159858159859159860159861159862159863159864159865159866159867159868159869159870159871159872159873159874159875159876159877159878159879159880159881159882159883159884159885159886159887159888159889159890159891159892159893159894159895159896159897159898159899159900159901159902159903159904159905159906159907159908159909159910159911159912159913159914159915159916159917159918159919159920159921159922159923159924159925159926159927159928159929159930159931159932159933159934159935159936159937159938159939159940159941159942159943159944159945159946159947159948159949159950159951159952159953159954159955159956159957159958159959159960159961159962159963159964159965159966159967159968159969159970159971159972159973159974159975159976159977159978159979159980159981159982159983159984159985159986159987159988159989159990159991159992159993159994159995159996159997159998159999160000160001160002160003160004160005160006160007160008160009160010160011160012160013160014160015160016160017160018160019160020160021160022160023160024160025160026160027160028160029160030160031160032160033160034160035160036160037160038160039160040160041160042160043160044160045160046160047160048160049160050160051160052160053160054160055160056160057160058160059160060160061160062160063160064160065160066160067160068160069160070160071160072160073160074160075160076160077160078160079160080160081160082160083160084160085160086160087160088160089160090160091160092160093160094160095160096160097160098160099160100160101160102160103160104160105160106160107160108160109160110160111160112160113160114160115160116160117160118160119160120160121160122160123160124160125160126160127160128160129160130160131160132160133160134160135160136160137160138160139160140160141160142160143160144160145160146160147160148160149160150160151160152160153160154160155160156160157160158160159160160160161160162160163160164160165160166160167160168160169160170160171160172160173160174160175160176160177160178160179160180160181160182160183160184160185160186160187160188160189160190160191160192160193160194160195160196160197160198160199160200160201160202160203160204160205160206160207160208160209160210160211160212160213160214160215160216160217160218160219160220160221160222160223160224160225160226160227160228160229160230160231160232160233160234160235160236160237160238160239160240160241160242160243160244160245160246160247160248160249160250160251160252160253160254160255160256160257160258160259160260160261160262160263160264160265160266160267160268160269160270160271160272160273160274160275160276160277160278160279160280160281160282160283160284160285160286160287160288160289160290160291160292160293160294160295160296160297160298160299160300160301160302160303160304160305160306160307160308160309160310160311160312160313160314160315160316160317160318160319160320160321160322160323160324160325160326160327160328160329160330160331160332160333160334160335160336160337160338160339160340160341160342160343160344160345160346160347160348160349160350160351160352160353160354160355160356160357160358160359160360160361160362160363160364160365160366160367160368160369160370160371160372160373160374160375160376160377160378160379160380160381160382160383160384160385160386160387160388160389160390160391160392160393160394160395160396160397160398160399160400160401160402160403160404160405160406160407160408160409160410160411160412160413160414160415160416160417160418160419160420160421160422160423160424160425160426160427160428160429160430160431160432160433160434160435160436160437160438160439160440160441160442160443160444160445160446160447160448160449160450160451160452160453160454160455160456160457160458160459160460160461160462160463160464160465160466160467160468160469160470160471160472160473160474160475160476160477160478160479160480160481160482160483160484160485160486160487160488160489160490160491160492160493160494160495160496160497160498160499160500160501160502160503160504160505160506160507160508160509160510160511160512160513160514160515160516160517160518160519160520160521160522160523160524160525160526160527160528160529160530160531160532160533160534160535160536160537160538160539160540160541160542160543160544160545160546160547160548160549160550160551160552160553160554160555160556160557160558160559160560160561160562160563160564160565160566160567160568160569160570160571160572160573160574160575160576160577160578160579160580160581160582160583160584160585160586160587160588160589160590160591160592160593160594160595160596160597160598160599160600160601160602160603160604160605160606160607160608160609160610160611160612160613160614160615160616160617160618160619160620160621160622160623160624160625160626160627160628160629160630160631160632160633160634160635160636160637160638160639160640160641160642160643160644160645160646160647160648160649160650160651160652160653160654160655160656160657160658160659160660160661160662160663160664160665160666160667160668160669160670160671160672160673160674160675160676160677160678160679160680160681160682160683160684160685160686160687160688160689160690160691160692160693160694160695160696160697160698160699160700160701160702160703160704160705160706160707160708160709160710160711160712160713160714160715160716160717160718160719160720160721160722160723160724160725160726160727160728160729160730160731160732160733160734160735160736160737160738160739160740160741160742160743160744160745160746160747160748160749160750160751160752160753160754160755160756160757160758160759160760160761160762160763160764160765160766160767160768160769160770160771160772160773160774160775160776160777160778160779160780160781160782160783160784160785160786160787160788160789160790160791160792160793160794160795160796160797160798160799160800160801160802160803160804160805160806160807160808160809160810160811160812160813160814160815160816160817160818160819160820160821160822160823160824160825160826160827160828160829160830160831160832160833160834160835160836160837160838160839160840160841160842160843160844160845160846160847160848160849160850160851160852160853160854160855160856160857160858160859160860160861160862160863160864160865160866160867160868160869160870160871160872160873160874160875160876160877160878160879160880160881160882160883160884160885160886160887160888160889160890160891160892160893160894160895160896160897160898160899160900160901160902160903160904160905160906160907160908160909160910160911160912160913160914160915160916160917160918160919160920160921160922160923160924160925160926160927160928160929160930160931160932160933160934160935160936160937160938160939160940160941160942160943160944160945160946160947160948160949160950160951160952160953160954160955160956160957160958160959160960160961160962160963160964160965160966160967160968160969160970160971160972160973160974160975160976160977160978160979160980160981160982160983160984160985160986160987160988160989160990160991160992160993160994160995160996160997160998160999161000161001161002161003161004161005161006161007161008161009161010161011161012161013161014161015161016161017161018161019161020161021161022161023161024161025161026161027161028161029161030161031161032161033161034161035161036161037161038161039161040161041161042161043161044161045161046161047161048161049161050161051161052161053161054161055161056161057161058161059161060161061161062161063161064161065161066161067161068161069161070161071161072161073161074161075161076161077161078161079161080161081161082161083161084161085161086161087161088161089161090161091161092161093161094161095161096161097161098161099161100161101161102161103161104161105161106161107161108161109161110161111161112161113161114161115161116161117161118161119161120161121161122161123161124161125161126161127161128161129161130161131161132161133161134161135161136161137161138161139161140161141161142161143161144161145161146161147161148161149161150161151161152161153161154161155161156161157161158161159161160161161161162161163161164161165161166161167161168161169161170161171161172161173161174161175161176161177161178161179161180161181161182161183161184161185161186161187161188161189161190161191161192161193161194161195161196161197161198161199161200161201161202161203161204161205161206161207161208161209161210161211161212161213161214161215161216161217161218161219161220161221161222161223161224161225161226161227161228161229161230161231161232161233161234161235161236161237161238161239161240161241161242161243161244161245161246161247161248161249161250161251161252161253161254161255161256161257161258161259161260161261161262161263161264161265161266161267161268161269161270161271161272161273161274161275161276161277161278161279161280161281161282161283161284161285161286161287161288161289161290161291161292161293161294161295161296161297161298161299161300161301161302161303161304161305161306161307161308161309161310161311161312161313161314161315161316161317161318161319161320161321161322161323161324161325161326161327161328161329161330161331161332161333161334161335161336161337161338161339161340161341161342161343161344161345161346161347161348161349161350161351161352161353161354161355161356161357161358161359161360161361161362161363161364161365161366161367161368161369161370161371161372161373161374161375161376161377161378161379161380161381161382161383161384161385161386161387161388161389161390161391161392161393161394161395161396161397161398161399161400161401161402161403161404161405161406161407161408161409161410161411161412161413161414161415161416161417161418161419161420161421161422161423161424161425161426161427161428161429161430161431161432161433161434161435161436161437161438161439161440161441161442161443161444161445161446161447161448161449161450161451161452161453161454161455161456161457161458161459161460161461161462161463161464161465161466161467161468161469161470161471161472161473161474161475161476161477161478161479161480161481161482161483161484161485161486161487161488161489161490161491161492161493161494161495161496161497161498161499161500161501161502161503161504161505161506161507161508161509161510161511161512161513161514161515161516161517161518161519161520161521161522161523161524161525161526161527161528161529161530161531161532161533161534161535161536161537161538161539161540161541161542161543161544161545161546161547161548161549161550161551161552161553161554161555161556161557161558161559161560161561161562161563161564161565161566161567161568161569161570161571161572161573161574161575161576161577161578161579161580161581161582161583161584161585161586161587161588161589161590161591161592161593161594161595161596161597161598161599161600161601161602161603161604161605161606161607161608161609161610161611161612161613161614161615161616161617161618161619161620161621161622161623161624161625161626161627161628161629161630161631161632161633161634161635161636161637161638161639161640161641161642161643161644161645161646161647161648161649161650161651161652161653161654161655161656161657161658161659161660161661161662161663161664161665161666161667161668161669161670161671161672161673161674161675161676161677161678161679161680161681161682161683161684161685161686161687161688161689161690161691161692161693161694161695161696161697161698161699161700161701161702161703161704161705161706161707161708161709161710161711161712161713161714161715161716161717161718161719161720161721161722161723161724161725161726161727161728161729161730161731161732161733161734161735161736161737161738161739161740161741161742161743161744161745161746161747161748161749161750161751161752161753161754161755161756161757161758161759161760161761161762161763161764161765161766161767161768161769161770161771161772161773161774161775161776161777161778161779161780161781161782161783161784161785161786161787161788161789161790161791161792161793161794161795161796161797161798161799161800161801161802161803161804161805161806161807161808161809161810161811161812161813161814161815161816161817161818161819161820161821161822161823161824161825161826161827161828161829161830161831161832161833161834161835161836161837161838161839161840161841161842161843161844161845161846161847161848161849161850161851161852161853161854161855161856161857161858161859161860161861161862161863161864161865161866161867161868161869161870161871161872161873161874161875161876161877161878161879161880161881161882161883161884161885161886161887161888161889161890161891161892161893161894161895161896161897161898161899161900161901161902161903161904161905161906161907161908161909161910161911161912161913161914161915161916161917161918161919161920161921161922161923161924161925161926161927161928161929161930161931161932161933161934161935161936161937161938161939161940161941161942161943161944161945161946161947161948161949161950161951161952161953161954161955161956161957161958161959161960161961161962161963161964161965161966161967161968161969161970161971161972161973161974161975161976161977161978161979161980161981161982161983161984161985161986161987161988161989161990161991161992161993161994161995161996161997161998161999162000162001162002162003162004162005162006162007162008162009162010162011162012162013162014162015162016162017162018162019162020162021162022162023162024162025162026162027162028162029162030162031162032162033162034162035162036162037162038162039162040162041162042162043162044162045162046162047162048162049162050162051162052162053162054162055162056162057162058162059162060162061162062162063162064162065162066162067162068162069162070162071162072162073162074162075162076162077162078162079162080162081162082162083162084162085162086162087162088162089162090162091162092162093162094162095162096162097162098162099162100162101162102162103162104162105162106162107162108162109162110162111162112162113162114162115162116162117162118162119162120162121162122162123162124162125162126162127162128162129162130162131162132162133162134162135162136162137162138162139162140162141162142162143162144162145162146162147162148162149162150162151162152162153162154162155162156162157162158162159162160162161162162162163162164162165162166162167162168162169162170162171162172162173162174162175162176162177162178162179162180162181162182162183162184162185162186162187162188162189162190162191162192162193162194162195162196162197162198162199162200162201162202162203162204162205162206162207162208162209162210162211162212162213162214162215162216162217162218162219162220162221162222162223162224162225162226162227162228162229162230162231162232162233162234162235162236162237162238162239162240162241162242162243162244162245162246162247162248162249162250162251162252162253162254162255162256162257162258162259162260162261162262162263162264162265162266162267162268162269162270162271162272162273162274162275162276162277162278162279162280162281162282162283162284162285162286162287162288162289162290162291162292162293162294162295162296162297162298162299162300162301162302162303162304162305162306162307162308162309162310162311162312162313162314162315162316162317162318162319162320162321162322162323162324162325162326162327162328162329162330162331162332162333162334162335162336162337162338162339162340162341162342162343162344162345162346162347162348162349162350162351162352162353162354162355162356162357162358162359162360162361162362162363162364162365162366162367162368162369162370162371162372162373162374162375162376162377162378162379162380162381162382162383162384162385162386162387162388162389162390162391162392162393162394162395162396162397162398162399162400162401162402162403162404162405162406162407162408162409162410162411162412162413162414162415162416162417162418162419162420162421162422162423162424162425162426162427162428162429162430162431162432162433162434162435162436162437162438162439162440162441162442162443162444162445162446162447162448162449162450162451162452162453162454162455162456162457162458162459162460162461162462162463162464162465162466162467162468162469162470162471162472162473162474162475162476162477162478162479162480162481162482162483162484162485162486162487162488162489162490162491162492162493162494162495162496162497162498162499162500162501162502162503162504162505162506162507162508162509162510162511162512162513162514162515162516162517162518162519162520162521162522162523162524162525162526162527162528162529162530162531162532162533162534162535162536162537162538162539162540162541162542162543162544162545162546162547162548162549162550162551162552162553162554162555162556162557162558162559162560162561162562162563162564162565162566162567162568162569162570162571162572162573162574162575162576162577162578162579162580162581162582162583162584162585162586162587162588162589162590162591162592162593162594162595162596162597162598162599162600162601162602162603162604162605162606162607162608162609162610162611162612162613162614162615162616162617162618162619162620162621162622162623162624162625162626162627162628162629162630162631162632162633162634162635162636162637162638162639162640162641162642162643162644162645162646162647162648162649162650162651162652162653162654162655162656162657162658162659162660162661162662162663162664162665162666162667162668162669162670162671162672162673162674162675162676162677162678162679162680162681162682162683162684162685162686162687162688162689162690162691162692162693162694162695162696162697162698162699162700162701162702162703162704162705162706162707162708162709162710162711162712162713162714162715162716162717162718162719162720162721162722162723162724162725162726162727162728162729162730162731162732162733162734162735162736162737162738162739162740162741162742162743162744162745162746162747162748162749162750162751162752162753162754162755162756162757162758162759162760162761162762162763162764162765162766162767162768162769162770162771162772162773162774162775162776162777162778162779162780162781162782162783162784162785162786162787162788162789162790162791162792162793162794162795162796162797162798162799162800162801162802162803162804162805162806162807162808162809162810162811162812162813162814162815162816162817162818162819162820162821162822162823162824162825162826162827162828162829162830162831162832162833162834162835162836162837162838162839162840162841162842162843162844162845162846162847162848162849162850162851162852162853162854162855162856162857162858162859162860162861162862162863162864162865162866162867162868162869162870162871162872162873162874162875162876162877162878162879162880162881162882162883162884162885162886162887162888162889162890162891162892162893162894162895162896162897162898162899162900162901162902162903162904162905162906162907162908162909162910162911162912162913162914162915162916162917162918162919162920162921162922162923162924162925162926162927162928162929162930162931162932162933162934162935162936162937162938162939162940162941162942162943162944162945162946162947162948162949162950162951162952162953162954162955162956162957162958162959162960162961162962162963162964162965162966162967162968162969162970162971162972162973162974162975162976162977162978162979162980162981162982162983162984162985162986162987162988162989162990162991162992162993162994162995162996162997162998162999163000163001163002163003163004163005163006163007163008163009163010163011163012163013163014163015163016163017163018163019163020163021163022163023163024163025163026163027163028163029163030163031163032163033163034163035163036163037163038163039163040163041163042163043163044163045163046163047163048163049163050163051163052163053163054163055163056163057163058163059163060163061163062163063163064163065163066163067163068163069163070163071163072163073163074163075163076163077163078163079163080163081163082163083163084163085163086163087163088163089163090163091163092163093163094163095163096163097163098163099163100163101163102163103163104163105163106163107163108163109163110163111163112163113163114163115163116163117163118163119163120163121163122163123163124163125163126163127163128163129163130163131163132163133163134163135163136163137163138163139163140163141163142163143163144163145163146163147163148163149163150163151163152163153163154163155163156163157163158163159163160163161163162163163163164163165163166163167163168163169163170163171163172163173163174163175163176163177163178163179163180163181163182163183163184163185163186163187163188163189163190163191163192163193163194163195163196163197163198163199163200163201163202163203163204163205163206163207163208163209163210163211163212163213163214163215163216163217163218163219163220163221163222163223163224163225163226163227163228163229163230163231163232163233163234163235163236163237163238163239163240163241163242163243163244163245163246163247163248163249163250163251163252163253163254163255163256163257163258163259163260163261163262163263163264163265163266163267163268163269163270163271163272163273163274163275163276163277163278163279163280163281163282163283163284163285163286163287163288163289163290163291163292163293163294163295163296163297163298163299163300163301163302163303163304163305163306163307163308163309163310163311163312163313163314163315163316163317163318163319163320163321163322163323163324163325163326163327163328163329163330163331163332163333163334163335163336163337163338163339163340163341163342163343163344163345163346163347163348163349163350163351163352163353163354163355163356163357163358163359163360163361163362163363163364163365163366163367163368163369163370163371163372163373163374163375163376163377163378163379163380163381163382163383163384163385163386163387163388163389163390163391163392163393163394163395163396163397163398163399163400163401163402163403163404163405163406163407163408163409163410163411163412163413163414163415163416163417163418163419163420163421163422163423163424163425163426163427163428163429163430163431163432163433163434163435163436163437163438163439163440163441163442163443163444163445163446163447163448163449163450163451163452163453163454163455163456163457163458163459163460163461163462163463163464163465163466163467163468163469163470163471163472163473163474163475163476163477163478163479163480163481163482163483163484163485163486163487163488163489163490163491163492163493163494163495163496163497163498163499163500163501163502163503163504163505163506163507163508163509163510163511163512163513163514163515163516163517163518163519163520163521163522163523163524163525163526163527163528163529163530163531163532163533163534163535163536163537163538163539163540163541163542163543163544163545163546163547163548163549163550163551163552163553163554163555163556163557163558163559163560163561163562163563163564163565163566163567163568163569163570163571163572163573163574163575163576163577163578163579163580163581163582163583163584163585163586163587163588163589163590163591163592163593163594163595163596163597163598163599163600163601163602163603163604163605163606163607163608163609163610163611163612163613163614163615163616163617163618163619163620163621163622163623163624163625163626163627163628163629163630163631163632163633163634163635163636163637163638163639163640163641163642163643163644163645163646163647163648163649163650163651163652163653163654163655163656163657163658163659163660163661163662163663163664163665163666163667163668163669163670163671163672163673163674163675163676163677163678163679163680163681163682163683163684163685163686163687163688163689163690163691163692163693163694163695163696163697163698163699163700163701163702163703163704163705163706163707163708163709163710163711163712163713163714163715163716163717163718163719163720163721163722163723163724163725163726163727163728163729163730163731163732163733163734163735163736163737163738163739163740163741163742163743163744163745163746163747163748163749163750163751163752163753163754163755163756163757163758163759163760163761163762163763163764163765163766163767163768163769163770163771163772163773163774163775163776163777163778163779163780163781163782163783163784163785163786163787163788163789163790163791163792163793163794163795163796163797163798163799163800163801163802163803163804163805163806163807163808163809163810163811163812163813163814163815163816163817163818163819163820163821163822163823163824163825163826163827163828163829163830163831163832163833163834163835163836163837163838163839163840163841163842163843163844163845163846163847163848163849163850163851163852163853163854163855163856163857163858163859163860163861163862163863163864163865163866163867163868163869163870163871163872163873163874163875163876163877163878163879163880163881163882163883163884163885163886163887163888163889163890163891163892163893163894163895163896163897163898163899163900163901163902163903163904163905163906163907163908163909163910163911163912163913163914163915163916163917163918163919163920163921163922163923163924163925163926163927163928163929163930163931163932163933163934163935163936163937163938163939163940163941163942163943163944163945163946163947163948163949163950163951163952163953163954163955163956163957163958163959163960163961163962163963163964163965163966163967163968163969163970163971163972163973163974163975163976163977163978163979163980163981163982163983163984163985163986163987163988163989163990163991163992163993163994163995163996163997163998163999164000164001164002164003164004164005164006164007164008164009164010164011164012164013164014164015164016164017164018164019164020164021164022164023164024164025164026164027164028164029164030164031164032164033164034164035164036164037164038164039164040164041164042164043164044164045164046164047164048164049164050164051164052164053164054164055164056164057164058164059164060164061164062164063164064164065164066164067164068164069164070164071164072164073164074164075164076164077164078164079164080164081164082164083164084164085164086164087164088164089164090164091164092164093164094164095164096164097164098164099164100164101164102164103164104164105164106164107164108164109164110164111164112164113164114164115164116164117164118164119164120164121164122164123164124164125164126164127164128164129164130164131164132164133164134164135164136164137164138164139164140164141164142164143164144164145164146164147164148164149164150164151164152164153164154164155164156164157164158164159164160164161164162164163164164164165164166164167164168164169164170164171164172164173164174164175164176164177164178164179164180164181164182164183164184164185164186164187164188164189164190164191164192164193164194164195164196164197164198164199164200164201164202164203164204164205164206164207164208164209164210164211164212164213164214164215164216164217164218164219164220164221164222164223164224164225164226164227164228164229164230164231164232164233164234164235164236164237164238164239164240164241164242164243164244164245164246164247164248164249164250164251164252164253164254164255164256164257164258164259164260164261164262164263164264164265164266164267164268164269164270164271164272164273164274164275164276164277164278164279164280164281164282164283164284164285164286164287164288164289164290164291164292164293164294164295164296164297164298164299164300164301164302164303164304164305164306164307164308164309164310164311164312164313164314164315164316164317164318164319164320164321164322164323164324164325164326164327164328164329164330164331164332164333164334164335164336164337164338164339164340164341164342164343164344164345164346164347164348164349164350164351164352164353164354164355164356164357164358164359164360164361164362164363164364164365164366164367164368164369164370164371164372164373164374164375164376164377164378164379164380164381164382164383164384164385164386164387164388164389164390164391164392164393164394164395164396164397164398164399164400164401164402164403164404164405164406164407164408164409164410164411164412164413164414164415164416164417164418164419164420164421164422164423164424164425164426164427164428164429164430164431164432164433164434164435164436164437164438164439164440164441164442164443164444164445164446164447164448164449164450164451164452164453164454164455164456164457164458164459164460164461164462164463164464164465164466164467164468164469164470164471164472164473164474164475164476164477164478164479164480164481164482164483164484164485164486164487164488164489164490164491164492164493164494164495164496164497164498164499164500164501164502164503164504164505164506164507164508164509164510164511164512164513164514164515164516164517164518164519164520164521164522164523164524164525164526164527164528164529164530164531164532164533164534164535164536164537164538164539164540164541164542164543164544164545164546164547164548164549164550164551164552164553164554164555164556164557164558164559164560164561164562164563164564164565164566164567164568164569164570164571164572164573164574164575164576164577164578164579164580164581164582164583164584164585164586164587164588164589164590164591164592164593164594164595164596164597164598164599164600164601164602164603164604164605164606164607164608164609164610164611164612164613164614164615164616164617164618164619164620164621164622164623164624164625164626164627164628164629164630164631164632164633164634164635164636164637164638164639164640164641164642164643164644164645164646164647164648164649164650164651164652164653164654164655164656164657164658164659164660164661164662164663164664164665164666164667164668164669164670164671164672164673164674164675164676164677164678164679164680164681164682164683164684164685164686164687164688164689164690164691164692164693164694164695164696164697164698164699164700164701164702164703164704164705164706164707164708164709164710164711164712164713164714164715164716164717164718164719164720164721164722164723164724164725164726164727164728164729164730164731164732164733164734164735164736164737164738164739164740164741164742164743164744164745164746164747164748164749164750164751164752164753164754164755164756164757164758164759164760164761164762164763164764164765164766164767164768164769164770164771164772164773164774164775164776164777164778164779164780164781164782164783164784164785164786164787164788164789164790164791164792164793164794164795164796164797164798164799164800164801164802164803164804164805164806164807164808164809164810164811164812164813164814164815164816164817164818164819164820164821164822164823164824164825164826164827164828164829164830164831164832164833164834164835164836164837164838164839164840164841164842164843164844164845164846164847164848164849164850164851164852164853164854164855164856164857164858164859164860164861164862164863164864164865164866164867164868164869164870164871164872164873164874164875164876164877164878164879164880164881164882164883164884164885164886164887164888164889164890164891164892164893164894164895164896164897164898164899164900164901164902164903164904164905164906164907164908164909164910164911164912164913164914164915164916164917164918164919164920164921164922164923164924164925164926164927164928164929164930164931164932164933164934164935164936164937164938164939164940164941164942164943164944164945164946164947164948164949164950164951164952164953164954164955164956164957164958164959164960164961164962164963164964164965164966164967164968164969164970164971164972164973164974164975164976164977164978164979164980164981164982164983164984164985164986164987164988164989164990164991164992164993164994164995164996164997164998164999165000165001165002165003165004165005165006165007165008165009165010165011165012165013165014165015165016165017165018165019165020165021165022165023165024165025165026165027165028165029165030165031165032165033165034165035165036165037165038165039165040165041165042165043165044165045165046165047165048165049165050165051165052165053165054165055165056165057165058165059165060165061165062165063165064165065165066165067165068165069165070165071165072165073165074165075165076165077165078165079165080165081165082165083165084165085165086165087165088165089165090165091165092165093165094165095165096165097165098165099165100165101165102165103165104165105165106165107165108165109165110165111165112165113165114165115165116165117165118165119165120165121165122165123165124165125165126165127165128165129165130165131165132165133165134165135165136165137165138165139165140165141165142165143165144165145165146165147165148165149165150165151165152165153165154165155165156165157165158165159165160165161165162165163165164165165165166165167165168165169165170165171165172165173165174165175165176165177165178165179165180165181165182165183165184165185165186165187165188165189165190165191165192165193165194165195165196165197165198165199165200165201165202165203165204165205165206165207165208165209165210165211165212165213165214165215165216165217165218165219165220165221165222165223165224165225165226165227165228165229165230165231165232165233165234165235165236165237165238165239165240165241165242165243165244165245165246165247165248165249165250165251165252165253165254165255165256165257165258165259165260165261165262165263165264165265165266165267165268165269165270165271165272165273165274165275165276165277165278165279165280165281165282165283165284165285165286165287165288165289165290165291165292165293165294165295165296165297165298165299165300165301165302165303165304165305165306165307165308165309165310165311165312165313165314165315165316165317165318165319165320165321165322165323165324165325165326165327165328165329165330165331165332165333165334165335165336165337165338165339165340165341165342165343165344165345165346165347165348165349165350165351165352165353165354165355165356165357165358165359165360165361165362165363165364165365165366165367165368165369165370165371165372165373165374165375165376165377165378165379165380165381165382165383165384165385165386165387165388165389165390165391165392165393165394165395165396165397165398165399165400165401165402165403165404165405165406165407165408165409165410165411165412165413165414165415165416165417165418165419165420165421165422165423165424165425165426165427165428165429165430165431165432165433165434165435165436165437165438165439165440165441165442165443165444165445165446165447165448165449165450165451165452165453165454165455165456165457165458165459165460165461165462165463165464165465165466165467165468165469165470165471165472165473165474165475165476165477165478165479165480165481165482165483165484165485165486165487165488165489165490165491165492165493165494165495165496165497165498165499165500165501165502165503165504165505165506165507165508165509165510165511165512165513165514165515165516165517165518165519165520165521165522165523165524165525165526165527165528165529165530165531165532165533165534165535165536165537165538165539165540165541165542165543165544165545165546165547165548165549165550165551165552165553165554165555165556165557165558165559165560165561165562165563165564165565165566165567165568165569165570165571165572165573165574165575165576165577165578165579165580165581165582165583165584165585165586165587165588165589165590165591165592165593165594165595165596165597165598165599165600165601165602165603165604165605165606165607165608165609165610165611165612165613165614165615165616165617165618165619165620165621165622165623165624165625165626165627165628165629165630165631165632165633165634165635165636165637165638165639165640165641165642165643165644165645165646165647165648165649165650165651165652165653165654165655165656165657165658165659165660165661165662165663165664165665165666165667165668165669165670165671165672165673165674165675165676165677165678165679165680165681165682165683165684165685165686165687165688165689165690165691165692165693165694165695165696165697165698165699165700165701165702165703165704165705165706165707165708165709165710165711165712165713165714165715165716165717165718165719165720165721165722165723165724165725165726165727165728165729165730165731165732165733165734165735165736165737165738165739165740165741165742165743165744165745165746165747165748165749165750165751165752165753165754165755165756165757165758165759165760165761165762165763165764165765165766165767165768165769165770165771165772165773165774165775165776165777165778165779165780165781165782165783165784165785165786165787165788165789165790165791165792165793165794165795165796165797165798165799165800165801165802165803165804165805165806165807165808165809165810165811165812165813165814165815165816165817165818165819165820165821165822165823165824165825165826165827165828165829165830165831165832165833165834165835165836165837165838165839165840165841165842165843165844165845165846165847165848165849165850165851165852165853165854165855165856165857165858165859165860165861165862165863165864165865165866165867165868165869165870165871165872165873165874165875165876165877165878165879165880165881165882165883165884165885165886165887165888165889165890165891165892165893165894165895165896165897165898165899165900165901165902165903165904165905165906165907165908165909165910165911165912165913165914165915165916165917165918165919165920165921165922165923165924165925165926165927165928165929165930165931165932165933165934165935165936165937165938165939165940165941165942165943165944165945165946165947165948165949165950165951165952165953165954165955165956165957165958165959165960165961165962165963165964165965165966165967165968165969165970165971165972165973165974165975165976165977165978165979165980165981165982165983165984165985165986165987165988165989165990165991165992165993165994165995165996165997165998165999166000166001166002166003166004166005166006166007166008166009166010166011166012166013166014166015166016166017166018166019166020166021166022166023166024166025166026166027166028166029166030166031166032166033166034166035166036166037166038166039166040166041166042166043166044166045166046166047166048166049166050166051166052166053166054166055166056166057166058166059166060166061166062166063166064166065166066166067166068166069166070166071166072166073166074166075166076166077166078166079166080166081166082166083166084166085166086166087166088166089166090166091166092166093166094166095166096166097166098166099166100166101166102166103166104166105166106166107166108166109166110166111166112166113166114166115166116166117166118166119166120166121166122166123166124166125166126166127166128166129166130166131166132166133166134166135166136166137166138166139166140166141166142166143166144166145166146166147166148166149166150166151166152166153166154166155166156166157166158166159166160166161166162166163166164166165166166166167166168166169166170166171166172166173166174166175166176166177166178166179166180166181166182166183166184166185166186166187166188166189166190166191166192166193166194166195166196166197166198166199166200166201166202166203166204166205166206166207166208166209166210166211166212166213166214166215166216166217166218166219166220166221166222166223166224166225166226166227166228166229166230166231166232166233166234166235166236166237166238166239166240166241166242166243166244166245166246166247166248166249166250166251166252166253166254166255166256166257166258166259166260166261166262166263166264166265166266166267166268166269166270166271166272166273166274166275166276166277166278166279166280166281166282166283166284166285166286166287166288166289166290166291166292166293166294166295166296166297166298166299166300166301166302166303166304166305166306166307166308166309166310166311166312166313166314166315166316166317166318166319166320166321166322166323166324166325166326166327166328166329166330166331166332166333166334166335166336166337166338166339166340166341166342166343166344166345166346166347166348166349166350166351166352166353166354166355166356166357166358166359166360166361166362166363166364166365166366166367166368166369166370166371166372166373166374166375166376166377166378166379166380166381166382166383166384166385166386166387166388166389166390166391166392166393166394166395166396166397166398166399166400166401166402166403166404166405166406166407166408166409166410166411166412166413166414166415166416166417166418166419166420166421166422166423166424166425166426166427166428166429166430166431166432166433166434166435166436166437166438166439166440166441166442166443166444166445166446166447166448166449166450166451166452166453166454166455166456166457166458166459166460166461166462166463166464166465166466166467166468166469166470166471166472166473166474166475166476166477166478166479166480166481166482166483166484166485166486166487166488166489166490166491166492166493166494166495166496166497166498166499166500166501166502166503166504166505166506166507166508166509166510166511166512166513166514166515166516166517166518166519166520166521166522166523166524166525166526166527166528166529166530166531166532166533166534166535166536166537166538166539166540166541166542166543166544166545166546166547166548166549166550166551166552166553166554166555166556166557166558166559166560166561166562166563166564166565166566166567166568166569166570166571166572166573166574166575166576166577166578166579166580166581166582166583166584166585166586166587166588166589166590166591166592166593166594166595166596166597166598166599166600166601166602166603166604166605166606166607166608166609166610166611166612166613166614166615166616166617166618166619166620166621166622166623166624166625166626166627166628166629166630166631166632166633166634166635166636166637166638166639166640166641166642166643166644166645166646166647166648166649166650166651166652166653166654166655166656166657166658166659166660166661166662166663166664166665166666166667166668166669166670166671166672166673166674166675166676166677166678166679166680166681166682166683166684166685166686166687166688166689166690166691166692166693166694166695166696166697166698166699166700166701166702166703166704166705166706166707166708166709166710166711166712166713166714166715166716166717166718166719166720166721166722166723166724166725166726166727166728166729166730166731166732166733166734166735166736166737166738166739166740166741166742166743166744166745166746166747166748166749166750166751166752166753166754166755166756166757166758166759166760166761166762166763166764166765166766166767166768166769166770166771166772166773166774166775166776166777166778166779166780166781166782166783166784166785166786166787166788166789166790166791166792166793166794166795166796166797166798166799166800166801166802166803166804166805166806166807166808166809166810166811166812166813166814166815166816166817166818166819166820166821166822166823166824166825166826166827166828166829166830166831166832166833166834166835166836166837166838166839166840166841166842166843166844166845166846166847166848166849166850166851166852166853166854166855166856166857166858166859166860166861166862166863166864166865166866166867166868166869166870166871166872166873166874166875166876166877166878166879166880166881166882166883166884166885166886166887166888166889166890166891166892166893166894166895166896166897166898166899166900166901166902166903166904166905166906166907166908166909166910166911166912166913166914166915166916166917166918166919166920166921166922166923166924166925166926166927166928166929166930166931166932166933166934166935166936166937166938166939166940166941166942166943166944166945166946166947166948166949166950166951166952166953166954166955166956166957166958166959166960166961166962166963166964166965166966166967166968166969166970166971166972166973166974166975166976166977166978166979166980166981166982166983166984166985166986166987166988166989166990166991166992166993166994166995166996166997166998166999167000167001167002167003167004167005167006167007167008167009167010167011167012167013167014167015167016167017167018167019167020167021167022167023167024167025167026167027167028167029167030167031167032167033167034167035167036167037167038167039167040167041167042167043167044167045167046167047167048167049167050167051167052167053167054167055167056167057167058167059167060167061167062167063167064167065167066167067167068167069167070167071167072167073167074167075167076167077167078167079167080167081167082167083167084167085167086167087167088167089167090167091167092167093167094167095167096167097167098167099167100167101167102167103167104167105167106167107167108167109167110167111167112167113167114167115167116167117167118167119167120167121167122167123167124167125167126167127167128167129167130167131167132167133167134167135167136167137167138167139167140167141167142167143167144167145167146167147167148167149167150167151167152167153167154167155167156167157167158167159167160167161167162167163167164167165167166167167167168167169167170167171167172167173167174167175167176167177167178167179167180167181167182167183167184167185167186167187167188167189167190167191167192167193167194167195167196167197167198167199167200167201167202167203167204167205167206167207167208167209167210167211167212167213167214167215167216167217167218167219167220167221167222167223167224167225167226167227167228167229167230167231167232167233167234167235167236167237167238167239167240167241167242167243167244167245167246167247167248167249167250167251167252167253167254167255167256167257167258167259167260167261167262167263167264167265167266167267167268167269167270167271167272167273167274167275167276167277167278167279167280167281167282167283167284167285167286167287167288167289167290167291167292167293167294167295167296167297167298167299167300167301167302167303167304167305167306167307167308167309167310167311167312167313167314167315167316167317167318167319167320167321167322167323167324167325167326167327167328167329167330167331167332167333167334167335167336167337167338167339167340167341167342167343167344167345167346167347167348167349167350167351167352167353167354167355167356167357167358167359167360167361167362167363167364167365167366167367167368167369167370167371167372167373167374167375167376167377167378167379167380167381167382167383167384167385167386167387167388167389167390167391167392167393167394167395167396167397167398167399167400167401167402167403167404167405167406167407167408167409167410167411167412167413167414167415167416167417167418167419167420167421167422167423167424167425167426167427167428167429167430167431167432167433167434167435167436167437167438167439167440167441167442167443167444167445167446167447167448167449167450167451167452167453167454167455167456167457167458167459167460167461167462167463167464167465167466167467167468167469167470167471167472167473167474167475167476167477167478167479167480167481167482167483167484167485167486167487167488167489167490167491167492167493167494167495167496167497167498167499167500167501167502167503167504167505167506167507167508167509167510167511167512167513167514167515167516167517167518167519167520167521167522167523167524167525167526167527167528167529167530167531167532167533167534167535167536167537167538167539167540167541167542167543167544167545167546167547167548167549167550167551167552167553167554167555167556167557167558167559167560167561167562167563167564167565167566167567167568167569167570167571167572167573167574167575167576167577167578167579167580167581167582167583167584167585167586167587167588167589167590167591167592167593167594167595167596167597167598167599167600167601167602167603167604167605167606167607167608167609167610167611167612167613167614167615167616167617167618167619167620167621167622167623167624167625167626167627167628167629167630167631167632167633167634167635167636167637167638167639167640167641167642167643167644167645167646167647167648167649167650167651167652167653167654167655167656167657167658167659167660167661167662167663167664167665167666167667167668167669167670167671167672167673167674167675167676167677167678167679167680167681167682167683167684167685167686167687167688167689167690167691167692167693167694167695167696167697167698167699167700167701167702167703167704167705167706167707167708167709167710167711167712167713167714167715167716167717167718167719167720167721167722167723167724167725167726167727167728167729167730167731167732167733167734167735167736167737167738167739167740167741167742167743167744167745167746167747167748167749167750167751167752167753167754167755167756167757167758167759167760167761167762167763167764167765167766167767167768167769167770167771167772167773167774167775167776167777167778167779167780167781167782167783167784167785167786167787167788167789167790167791167792167793167794167795167796167797167798167799167800167801167802167803167804167805167806167807167808167809167810167811167812167813167814167815167816167817167818167819167820167821167822167823167824167825167826167827167828167829167830167831167832167833167834167835167836167837167838167839167840167841167842167843167844167845167846167847167848167849167850167851167852167853167854167855167856167857167858167859167860167861167862167863167864167865167866167867167868167869167870167871167872167873167874167875167876167877167878167879167880167881167882167883167884167885167886167887167888167889167890167891167892167893167894167895167896167897167898167899167900167901167902167903167904167905167906167907167908167909167910167911167912167913167914167915167916167917167918167919167920167921167922167923167924167925167926167927167928167929167930167931167932167933167934167935167936167937167938167939167940167941167942167943167944167945167946167947167948167949167950167951167952167953167954167955167956167957167958167959167960167961167962167963167964167965167966167967167968167969167970167971167972167973167974167975167976167977167978167979167980167981167982167983167984167985167986167987167988167989167990167991167992167993167994167995167996167997167998167999168000168001168002168003168004168005168006168007168008168009168010168011168012168013168014168015168016168017168018168019168020168021168022168023168024168025168026168027168028168029168030168031168032168033168034168035168036168037168038168039168040168041168042168043168044168045168046168047168048168049168050168051168052168053168054168055168056168057168058168059168060168061168062168063168064168065168066168067168068168069168070168071168072168073168074168075168076168077168078168079168080168081168082168083168084168085168086168087168088168089168090168091168092168093168094168095168096168097168098168099168100168101168102168103168104168105168106168107168108168109168110168111168112168113168114168115168116168117168118168119168120168121168122168123168124168125168126168127168128168129168130168131168132168133168134168135168136168137168138168139168140168141168142168143168144168145168146168147168148168149168150168151168152168153168154168155168156168157168158168159168160168161168162168163168164168165168166168167168168168169168170168171168172168173168174168175168176168177168178168179168180168181168182168183168184168185168186168187168188168189168190168191168192168193168194168195168196168197168198168199168200168201168202168203168204168205168206168207168208168209168210168211168212168213168214168215168216168217168218168219168220168221168222168223168224168225168226168227168228168229168230168231168232168233168234168235168236168237168238168239168240168241168242168243168244168245168246168247168248168249168250168251168252168253168254168255168256168257168258168259168260168261168262168263168264168265168266168267168268168269168270168271168272168273168274168275168276168277168278168279168280168281168282168283168284168285168286168287168288168289168290168291168292168293168294168295168296168297168298168299168300168301168302168303168304168305168306168307168308168309168310168311168312168313168314168315168316168317168318168319168320168321168322168323168324168325168326168327168328168329168330168331168332168333168334168335168336168337168338168339168340168341168342168343168344168345168346168347168348168349168350168351168352168353168354168355168356168357168358168359168360168361168362168363168364168365168366168367168368168369168370168371168372168373168374168375168376168377168378168379168380168381168382168383168384168385168386168387168388168389168390168391168392168393168394168395168396168397168398168399168400168401168402168403168404168405168406168407168408168409168410168411168412168413168414168415168416168417168418168419168420168421168422168423168424168425168426168427168428168429168430168431168432168433168434168435168436168437168438168439168440168441168442168443168444168445168446168447168448168449168450168451168452168453168454168455168456168457168458168459168460168461168462168463168464168465168466168467168468168469168470168471168472168473168474168475168476168477168478168479168480168481168482168483168484168485168486168487168488168489168490168491168492168493168494168495168496168497168498168499168500168501168502168503168504168505168506168507168508168509168510168511168512168513168514168515168516168517168518168519168520168521168522168523168524168525168526168527168528168529168530168531168532168533168534168535168536168537168538168539168540168541168542168543168544168545168546168547168548168549168550168551168552168553168554168555168556168557168558168559168560168561168562168563168564168565168566168567168568168569168570168571168572168573168574168575168576168577168578168579168580168581168582168583168584168585168586168587168588168589168590168591168592168593168594168595168596168597168598168599168600168601168602168603168604168605168606168607168608168609168610168611168612168613168614168615168616168617168618168619168620168621168622168623168624168625168626168627168628168629168630168631168632168633168634168635168636168637168638168639168640168641168642168643168644168645168646168647168648168649168650168651168652168653168654168655168656168657168658168659168660168661168662168663168664168665168666168667168668168669168670168671168672168673168674168675168676168677168678168679168680168681168682168683168684168685168686168687168688168689168690168691168692168693168694168695168696168697168698168699168700168701168702168703168704168705168706168707168708168709168710168711168712168713168714168715168716168717168718168719168720168721168722168723168724168725168726168727168728168729168730168731168732168733168734168735168736168737168738168739168740168741168742168743168744168745168746168747168748168749168750168751168752168753168754168755168756168757168758168759168760168761168762168763168764168765168766168767168768168769168770168771168772168773168774168775168776168777168778168779168780168781168782168783168784168785168786168787168788168789168790168791168792168793168794168795168796168797168798168799168800168801168802168803168804168805168806168807168808168809168810168811168812168813168814168815168816168817168818168819168820168821168822168823168824168825168826168827168828168829168830168831168832168833168834168835168836168837168838 |
- var vr = Object.defineProperty
- , yr = Object.defineProperties;
- var Tr = Object.getOwnPropertyDescriptors;
- var or = Object.getOwnPropertySymbols;
- var _r = Object.prototype.hasOwnProperty
- , mr = Object.prototype.propertyIsEnumerable;
- var sr = (a,e,i)=>e in a ? vr(a, e, {
- enumerable: !0,
- configurable: !0,
- writable: !0,
- value: i
- }) : a[e] = i
- , $t = (a,e)=>{
- for (var i in e || (e = {}))
- _r.call(e, i) && sr(a, i, e[i]);
- if (or)
- for (var i of or(e))
- mr.call(e, i) && sr(a, i, e[i]);
- return a
- }
- , Zt = (a,e)=>yr(a, Tr(e));
- var gr = (a,e)=>{
- var i = {};
- for (var o in a)
- _r.call(a, o) && e.indexOf(o) < 0 && (i[o] = a[o]);
- if (a != null && or)
- for (var o of or(a))
- e.indexOf(o) < 0 && mr.call(a, o) && (i[o] = a[o]);
- return i
- }
- ;
- var Tt = (a,e,i)=>(sr(a, typeof e != "symbol" ? e + "" : e, i),
- i);
- function _mergeNamespaces(a, e) {
- return e.forEach(function(i) {
- i && typeof i != "string" && !Array.isArray(i) && Object.keys(i).forEach(function(o) {
- if (o !== "default" && !(o in a)) {
- var s = Object.getOwnPropertyDescriptor(i, o);
- Object.defineProperty(a, o, s.get ? s : {
- enumerable: !0,
- get: function() {
- return i[o]
- }
- })
- }
- })
- }),
- Object.freeze(Object.defineProperty(a, Symbol.toStringTag, {
- value: "Module"
- }))
- }
- const p$2 = function() {
- const e = document.createElement("link").relList;
- if (e && e.supports && e.supports("modulepreload"))
- return;
- for (const s of document.querySelectorAll('link[rel="modulepreload"]'))
- o(s);
- new MutationObserver(s=>{
- for (const c of s)
- if (c.type === "childList")
- for (const d of c.addedNodes)
- d.tagName === "LINK" && d.rel === "modulepreload" && o(d)
- }
- ).observe(document, {
- childList: !0,
- subtree: !0
- });
- function i(s) {
- const c = {};
- return s.integrity && (c.integrity = s.integrity),
- s.referrerpolicy && (c.referrerPolicy = s.referrerpolicy),
- s.crossorigin === "use-credentials" ? c.credentials = "include" : s.crossorigin === "anonymous" ? c.credentials = "omit" : c.credentials = "same-origin",
- c
- }
- function o(s) {
- if (s.ep)
- return;
- s.ep = !0;
- const c = i(s);
- fetch(s.href, c)
- }
- };
- p$2();
- var commonjsGlobal = typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : {};
- function commonjsRequire(a) {
- 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.')
- }
- var react = {
- exports: {}
- }
- , react_production_min = {};
- /*
- object-assign
- (c) Sindre Sorhus
- @license MIT
- */
- var getOwnPropertySymbols = Object.getOwnPropertySymbols
- , hasOwnProperty = Object.prototype.hasOwnProperty
- , propIsEnumerable = Object.prototype.propertyIsEnumerable;
- function toObject(a) {
- if (a == null)
- throw new TypeError("Object.assign cannot be called with null or undefined");
- return Object(a)
- }
- function shouldUseNative() {
- try {
- if (!Object.assign)
- return !1;
- var a = new String("abc");
- if (a[5] = "de",
- Object.getOwnPropertyNames(a)[0] === "5")
- return !1;
- for (var e = {}, i = 0; i < 10; i++)
- e["_" + String.fromCharCode(i)] = i;
- var o = Object.getOwnPropertyNames(e).map(function(c) {
- return e[c]
- });
- if (o.join("") !== "0123456789")
- return !1;
- var s = {};
- return "abcdefghijklmnopqrst".split("").forEach(function(c) {
- s[c] = c
- }),
- Object.keys(Object.assign({}, s)).join("") === "abcdefghijklmnopqrst"
- } catch {
- return !1
- }
- }
- var objectAssign = shouldUseNative() ? Object.assign : function(a, e) {
- for (var i, o = toObject(a), s, c = 1; c < arguments.length; c++) {
- i = Object(arguments[c]);
- for (var d in i)
- hasOwnProperty.call(i, d) && (o[d] = i[d]);
- if (getOwnPropertySymbols) {
- s = getOwnPropertySymbols(i);
- for (var _ = 0; _ < s.length; _++)
- propIsEnumerable.call(i, s[_]) && (o[s[_]] = i[s[_]])
- }
- }
- return o
- }
- ;
- /** @license React v17.0.2
- * react.production.min.js
- *
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
- var l = objectAssign
- , n$1 = 60103
- , p$1 = 60106;
- react_production_min.Fragment = 60107;
- react_production_min.StrictMode = 60108;
- react_production_min.Profiler = 60114;
- var q$1 = 60109
- , r$1 = 60110
- , t = 60112;
- react_production_min.Suspense = 60113;
- var u = 60115
- , v = 60116;
- if (typeof Symbol == "function" && Symbol.for) {
- var w = Symbol.for;
- n$1 = w("react.element"),
- p$1 = w("react.portal"),
- react_production_min.Fragment = w("react.fragment"),
- react_production_min.StrictMode = w("react.strict_mode"),
- react_production_min.Profiler = w("react.profiler"),
- q$1 = w("react.provider"),
- r$1 = w("react.context"),
- t = w("react.forward_ref"),
- react_production_min.Suspense = w("react.suspense"),
- u = w("react.memo"),
- v = w("react.lazy")
- }
- var x = typeof Symbol == "function" && Symbol.iterator;
- function y$1(a) {
- return a === null || typeof a != "object" ? null : (a = x && a[x] || a["@@iterator"],
- typeof a == "function" ? a : null)
- }
- function z(a) {
- for (var e = "https://reactjs.org/docs/error-decoder.html?invariant=" + a, i = 1; i < arguments.length; i++)
- e += "&args[]=" + encodeURIComponent(arguments[i]);
- 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."
- }
- var A = {
- isMounted: function() {
- return !1
- },
- enqueueForceUpdate: function() {},
- enqueueReplaceState: function() {},
- enqueueSetState: function() {}
- }
- , B$1 = {};
- function C(a, e, i) {
- this.props = a,
- this.context = e,
- this.refs = B$1,
- this.updater = i || A
- }
- C.prototype.isReactComponent = {};
- C.prototype.setState = function(a, e) {
- if (typeof a != "object" && typeof a != "function" && a != null)
- throw Error(z(85));
- this.updater.enqueueSetState(this, a, e, "setState")
- }
- ;
- C.prototype.forceUpdate = function(a) {
- this.updater.enqueueForceUpdate(this, a, "forceUpdate")
- }
- ;
- function D$1() {}
- D$1.prototype = C.prototype;
- function E$1(a, e, i) {
- this.props = a,
- this.context = e,
- this.refs = B$1,
- this.updater = i || A
- }
- var F$1 = E$1.prototype = new D$1;
- F$1.constructor = E$1;
- l(F$1, C.prototype);
- F$1.isPureReactComponent = !0;
- var G$1 = {
- current: null
- }
- , H$1 = Object.prototype.hasOwnProperty
- , I$1 = {
- key: !0,
- ref: !0,
- __self: !0,
- __source: !0
- };
- function J(a, e, i) {
- var o, s = {}, c = null, d = null;
- if (e != null)
- for (o in e.ref !== void 0 && (d = e.ref),
- e.key !== void 0 && (c = "" + e.key),
- e)
- H$1.call(e, o) && !I$1.hasOwnProperty(o) && (s[o] = e[o]);
- var _ = arguments.length - 2;
- if (_ === 1)
- s.children = i;
- else if (1 < _) {
- for (var b = Array(_), k = 0; k < _; k++)
- b[k] = arguments[k + 2];
- s.children = b
- }
- if (a && a.defaultProps)
- for (o in _ = a.defaultProps,
- _)
- s[o] === void 0 && (s[o] = _[o]);
- return {
- $$typeof: n$1,
- type: a,
- key: c,
- ref: d,
- props: s,
- _owner: G$1.current
- }
- }
- function K(a, e) {
- return {
- $$typeof: n$1,
- type: a.type,
- key: e,
- ref: a.ref,
- props: a.props,
- _owner: a._owner
- }
- }
- function L(a) {
- return typeof a == "object" && a !== null && a.$$typeof === n$1
- }
- function escape$1(a) {
- var e = {
- "=": "=0",
- ":": "=2"
- };
- return "$" + a.replace(/[=:]/g, function(i) {
- return e[i]
- })
- }
- var M$1 = /\/+/g;
- function N$1(a, e) {
- return typeof a == "object" && a !== null && a.key != null ? escape$1("" + a.key) : e.toString(36)
- }
- function O$1(a, e, i, o, s) {
- var c = typeof a;
- (c === "undefined" || c === "boolean") && (a = null);
- var d = !1;
- if (a === null)
- d = !0;
- else
- switch (c) {
- case "string":
- case "number":
- d = !0;
- break;
- case "object":
- switch (a.$$typeof) {
- case n$1:
- case p$1:
- d = !0
- }
- }
- if (d)
- return d = a,
- s = s(d),
- a = o === "" ? "." + N$1(d, 0) : o,
- Array.isArray(s) ? (i = "",
- a != null && (i = a.replace(M$1, "$&/") + "/"),
- O$1(s, e, i, "", function(k) {
- return k
- })) : s != null && (L(s) && (s = K(s, i + (!s.key || d && d.key === s.key ? "" : ("" + s.key).replace(M$1, "$&/") + "/") + a)),
- e.push(s)),
- 1;
- if (d = 0,
- o = o === "" ? "." : o + ":",
- Array.isArray(a))
- for (var _ = 0; _ < a.length; _++) {
- c = a[_];
- var b = o + N$1(c, _);
- d += O$1(c, e, i, b, s)
- }
- else if (b = y$1(a),
- typeof b == "function")
- for (a = b.call(a),
- _ = 0; !(c = a.next()).done; )
- c = c.value,
- b = o + N$1(c, _++),
- d += O$1(c, e, i, b, s);
- else if (c === "object")
- throw e = "" + a,
- Error(z(31, e === "[object Object]" ? "object with keys {" + Object.keys(a).join(", ") + "}" : e));
- return d
- }
- function P$1(a, e, i) {
- if (a == null)
- return a;
- var o = []
- , s = 0;
- return O$1(a, o, "", "", function(c) {
- return e.call(i, c, s++)
- }),
- o
- }
- function Q(a) {
- if (a._status === -1) {
- var e = a._result;
- e = e(),
- a._status = 0,
- a._result = e,
- e.then(function(i) {
- a._status === 0 && (i = i.default,
- a._status = 1,
- a._result = i)
- }, function(i) {
- a._status === 0 && (a._status = 2,
- a._result = i)
- })
- }
- if (a._status === 1)
- return a._result;
- throw a._result
- }
- var R$1 = {
- current: null
- };
- function S$1() {
- var a = R$1.current;
- if (a === null)
- throw Error(z(321));
- return a
- }
- var T$1 = {
- ReactCurrentDispatcher: R$1,
- ReactCurrentBatchConfig: {
- transition: 0
- },
- ReactCurrentOwner: G$1,
- IsSomeRendererActing: {
- current: !1
- },
- assign: l
- };
- react_production_min.Children = {
- map: P$1,
- forEach: function(a, e, i) {
- P$1(a, function() {
- e.apply(this, arguments)
- }, i)
- },
- count: function(a) {
- var e = 0;
- return P$1(a, function() {
- e++
- }),
- e
- },
- toArray: function(a) {
- return P$1(a, function(e) {
- return e
- }) || []
- },
- only: function(a) {
- if (!L(a))
- throw Error(z(143));
- return a
- }
- };
- react_production_min.Component = C;
- react_production_min.PureComponent = E$1;
- react_production_min.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = T$1;
- react_production_min.cloneElement = function(a, e, i) {
- if (a == null)
- throw Error(z(267, a));
- var o = l({}, a.props)
- , s = a.key
- , c = a.ref
- , d = a._owner;
- if (e != null) {
- if (e.ref !== void 0 && (c = e.ref,
- d = G$1.current),
- e.key !== void 0 && (s = "" + e.key),
- a.type && a.type.defaultProps)
- var _ = a.type.defaultProps;
- for (b in e)
- H$1.call(e, b) && !I$1.hasOwnProperty(b) && (o[b] = e[b] === void 0 && _ !== void 0 ? _[b] : e[b])
- }
- var b = arguments.length - 2;
- if (b === 1)
- o.children = i;
- else if (1 < b) {
- _ = Array(b);
- for (var k = 0; k < b; k++)
- _[k] = arguments[k + 2];
- o.children = _
- }
- return {
- $$typeof: n$1,
- type: a.type,
- key: s,
- ref: c,
- props: o,
- _owner: d
- }
- }
- ;
- react_production_min.createContext = function(a, e) {
- return e === void 0 && (e = null),
- a = {
- $$typeof: r$1,
- _calculateChangedBits: e,
- _currentValue: a,
- _currentValue2: a,
- _threadCount: 0,
- Provider: null,
- Consumer: null
- },
- a.Provider = {
- $$typeof: q$1,
- _context: a
- },
- a.Consumer = a
- }
- ;
- react_production_min.createElement = J;
- react_production_min.createFactory = function(a) {
- var e = J.bind(null, a);
- return e.type = a,
- e
- }
- ;
- react_production_min.createRef = function() {
- return {
- current: null
- }
- }
- ;
- react_production_min.forwardRef = function(a) {
- return {
- $$typeof: t,
- render: a
- }
- }
- ;
- react_production_min.isValidElement = L;
- react_production_min.lazy = function(a) {
- return {
- $$typeof: v,
- _payload: {
- _status: -1,
- _result: a
- },
- _init: Q
- }
- }
- ;
- react_production_min.memo = function(a, e) {
- return {
- $$typeof: u,
- type: a,
- compare: e === void 0 ? null : e
- }
- }
- ;
- react_production_min.useCallback = function(a, e) {
- return S$1().useCallback(a, e)
- }
- ;
- react_production_min.useContext = function(a, e) {
- return S$1().useContext(a, e)
- }
- ;
- react_production_min.useDebugValue = function() {}
- ;
- react_production_min.useEffect = function(a, e) {
- return S$1().useEffect(a, e)
- }
- ;
- react_production_min.useImperativeHandle = function(a, e, i) {
- return S$1().useImperativeHandle(a, e, i)
- }
- ;
- react_production_min.useLayoutEffect = function(a, e) {
- return S$1().useLayoutEffect(a, e)
- }
- ;
- react_production_min.useMemo = function(a, e) {
- return S$1().useMemo(a, e)
- }
- ;
- react_production_min.useReducer = function(a, e, i) {
- return S$1().useReducer(a, e, i)
- }
- ;
- react_production_min.useRef = function(a) {
- return S$1().useRef(a)
- }
- ;
- react_production_min.useState = function(a) {
- return S$1().useState(a)
- }
- ;
- react_production_min.version = "17.0.2";
- react.exports = react_production_min;
- var React = react.exports
- , reactDom = {
- exports: {}
- }
- , reactDom_production_min = {}
- , scheduler = {
- exports: {}
- }
- , scheduler_production_min = {};
- /** @license React v0.20.2
- * scheduler.production.min.js
- *
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
- (function(a) {
- var e, i, o, s;
- if (typeof performance == "object" && typeof performance.now == "function") {
- var c = performance;
- a.unstable_now = function() {
- return c.now()
- }
- } else {
- var d = Date
- , _ = d.now();
- a.unstable_now = function() {
- return d.now() - _
- }
- }
- if (typeof window == "undefined" || typeof MessageChannel != "function") {
- var b = null
- , k = null
- , j = function() {
- if (b !== null)
- try {
- var bt = a.unstable_now();
- b(!0, bt),
- b = null
- } catch (Rt) {
- throw setTimeout(j, 0),
- Rt
- }
- };
- e = function(bt) {
- b !== null ? setTimeout(e, 0, bt) : (b = bt,
- setTimeout(j, 0))
- }
- ,
- i = function(bt, Rt) {
- k = setTimeout(bt, Rt)
- }
- ,
- o = function() {
- clearTimeout(k)
- }
- ,
- a.unstable_shouldYield = function() {
- return !1
- }
- ,
- s = a.unstable_forceFrameRate = function() {}
- } else {
- var $ = window.setTimeout
- , _e = window.clearTimeout;
- if (typeof console != "undefined") {
- var et = window.cancelAnimationFrame;
- 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"),
- 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")
- }
- var tt = !1
- , rt = null
- , it = -1
- , nt = 5
- , ot = 0;
- a.unstable_shouldYield = function() {
- return a.unstable_now() >= ot
- }
- ,
- s = function() {}
- ,
- a.unstable_forceFrameRate = function(bt) {
- 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
- }
- ;
- var at = new MessageChannel
- , st = at.port2;
- at.port1.onmessage = function() {
- if (rt !== null) {
- var bt = a.unstable_now();
- ot = bt + nt;
- try {
- rt(!0, bt) ? st.postMessage(null) : (tt = !1,
- rt = null)
- } catch (Rt) {
- throw st.postMessage(null),
- Rt
- }
- } else
- tt = !1
- }
- ,
- e = function(bt) {
- rt = bt,
- tt || (tt = !0,
- st.postMessage(null))
- }
- ,
- i = function(bt, Rt) {
- it = $(function() {
- bt(a.unstable_now())
- }, Rt)
- }
- ,
- o = function() {
- _e(it),
- it = -1
- }
- }
- function ut(bt, Rt) {
- var Mt = bt.length;
- bt.push(Rt);
- e: for (; ; ) {
- var Pt = Mt - 1 >>> 1
- , It = bt[Pt];
- if (It !== void 0 && 0 < ft(It, Rt))
- bt[Pt] = Rt,
- bt[Mt] = It,
- Mt = Pt;
- else
- break e
- }
- }
- function ct(bt) {
- return bt = bt[0],
- bt === void 0 ? null : bt
- }
- function lt(bt) {
- var Rt = bt[0];
- if (Rt !== void 0) {
- var Mt = bt.pop();
- if (Mt !== Rt) {
- bt[0] = Mt;
- e: for (var Pt = 0, It = bt.length; Pt < It; ) {
- var Dt = 2 * (Pt + 1) - 1
- , Ct = bt[Dt]
- , Ot = Dt + 1
- , wt = bt[Ot];
- if (Ct !== void 0 && 0 > ft(Ct, Mt))
- wt !== void 0 && 0 > ft(wt, Ct) ? (bt[Pt] = wt,
- bt[Ot] = Mt,
- Pt = Ot) : (bt[Pt] = Ct,
- bt[Dt] = Mt,
- Pt = Dt);
- else if (wt !== void 0 && 0 > ft(wt, Mt))
- bt[Pt] = wt,
- bt[Ot] = Mt,
- Pt = Ot;
- else
- break e
- }
- }
- return Rt
- }
- return null
- }
- function ft(bt, Rt) {
- var Mt = bt.sortIndex - Rt.sortIndex;
- return Mt !== 0 ? Mt : bt.id - Rt.id
- }
- var ht = []
- , pt = []
- , dt = 1
- , _t = null
- , mt = 3
- , vt = !1
- , yt = !1
- , Et = !1;
- function At(bt) {
- for (var Rt = ct(pt); Rt !== null; ) {
- if (Rt.callback === null)
- lt(pt);
- else if (Rt.startTime <= bt)
- lt(pt),
- Rt.sortIndex = Rt.expirationTime,
- ut(ht, Rt);
- else
- break;
- Rt = ct(pt)
- }
- }
- function gt(bt) {
- if (Et = !1,
- At(bt),
- !yt)
- if (ct(ht) !== null)
- yt = !0,
- e(St);
- else {
- var Rt = ct(pt);
- Rt !== null && i(gt, Rt.startTime - bt)
- }
- }
- function St(bt, Rt) {
- yt = !1,
- Et && (Et = !1,
- o()),
- vt = !0;
- var Mt = mt;
- try {
- for (At(Rt),
- _t = ct(ht); _t !== null && (!(_t.expirationTime > Rt) || bt && !a.unstable_shouldYield()); ) {
- var Pt = _t.callback;
- if (typeof Pt == "function") {
- _t.callback = null,
- mt = _t.priorityLevel;
- var It = Pt(_t.expirationTime <= Rt);
- Rt = a.unstable_now(),
- typeof It == "function" ? _t.callback = It : _t === ct(ht) && lt(ht),
- At(Rt)
- } else
- lt(ht);
- _t = ct(ht)
- }
- if (_t !== null)
- var Dt = !0;
- else {
- var Ct = ct(pt);
- Ct !== null && i(gt, Ct.startTime - Rt),
- Dt = !1
- }
- return Dt
- } finally {
- _t = null,
- mt = Mt,
- vt = !1
- }
- }
- var xt = s;
- a.unstable_IdlePriority = 5,
- a.unstable_ImmediatePriority = 1,
- a.unstable_LowPriority = 4,
- a.unstable_NormalPriority = 3,
- a.unstable_Profiling = null,
- a.unstable_UserBlockingPriority = 2,
- a.unstable_cancelCallback = function(bt) {
- bt.callback = null
- }
- ,
- a.unstable_continueExecution = function() {
- yt || vt || (yt = !0,
- e(St))
- }
- ,
- a.unstable_getCurrentPriorityLevel = function() {
- return mt
- }
- ,
- a.unstable_getFirstCallbackNode = function() {
- return ct(ht)
- }
- ,
- a.unstable_next = function(bt) {
- switch (mt) {
- case 1:
- case 2:
- case 3:
- var Rt = 3;
- break;
- default:
- Rt = mt
- }
- var Mt = mt;
- mt = Rt;
- try {
- return bt()
- } finally {
- mt = Mt
- }
- }
- ,
- a.unstable_pauseExecution = function() {}
- ,
- a.unstable_requestPaint = xt,
- a.unstable_runWithPriority = function(bt, Rt) {
- switch (bt) {
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- break;
- default:
- bt = 3
- }
- var Mt = mt;
- mt = bt;
- try {
- return Rt()
- } finally {
- mt = Mt
- }
- }
- ,
- a.unstable_scheduleCallback = function(bt, Rt, Mt) {
- var Pt = a.unstable_now();
- switch (typeof Mt == "object" && Mt !== null ? (Mt = Mt.delay,
- Mt = typeof Mt == "number" && 0 < Mt ? Pt + Mt : Pt) : Mt = Pt,
- bt) {
- case 1:
- var It = -1;
- break;
- case 2:
- It = 250;
- break;
- case 5:
- It = 1073741823;
- break;
- case 4:
- It = 1e4;
- break;
- default:
- It = 5e3
- }
- return It = Mt + It,
- bt = {
- id: dt++,
- callback: Rt,
- priorityLevel: bt,
- startTime: Mt,
- expirationTime: It,
- sortIndex: -1
- },
- Mt > Pt ? (bt.sortIndex = Mt,
- ut(pt, bt),
- ct(ht) === null && bt === ct(pt) && (Et ? o() : Et = !0,
- i(gt, Mt - Pt))) : (bt.sortIndex = It,
- ut(ht, bt),
- yt || vt || (yt = !0,
- e(St))),
- bt
- }
- ,
- a.unstable_wrapCallback = function(bt) {
- var Rt = mt;
- return function() {
- var Mt = mt;
- mt = Rt;
- try {
- return bt.apply(this, arguments)
- } finally {
- mt = Mt
- }
- }
- }
- }
- )(scheduler_production_min);
- scheduler.exports = scheduler_production_min;
- /** @license React v17.0.2
- * react-dom.production.min.js
- *
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
- var aa = react.exports
- , m$1 = objectAssign
- , r = scheduler.exports;
- function y(a) {
- for (var e = "https://reactjs.org/docs/error-decoder.html?invariant=" + a, i = 1; i < arguments.length; i++)
- e += "&args[]=" + encodeURIComponent(arguments[i]);
- 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."
- }
- if (!aa)
- throw Error(y(227));
- var ba = new Set
- , ca = {};
- function da(a, e) {
- ea(a, e),
- ea(a + "Capture", e)
- }
- function ea(a, e) {
- for (ca[a] = e,
- a = 0; a < e.length; a++)
- ba.add(e[a])
- }
- var fa = !(typeof window == "undefined" || typeof window.document == "undefined" || typeof window.document.createElement == "undefined")
- , 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]*$/
- , ia = Object.prototype.hasOwnProperty
- , ja = {}
- , ka = {};
- function la(a) {
- return ia.call(ka, a) ? !0 : ia.call(ja, a) ? !1 : ha.test(a) ? ka[a] = !0 : (ja[a] = !0,
- !1)
- }
- function ma(a, e, i, o) {
- if (i !== null && i.type === 0)
- return !1;
- switch (typeof e) {
- case "function":
- case "symbol":
- return !0;
- case "boolean":
- return o ? !1 : i !== null ? !i.acceptsBooleans : (a = a.toLowerCase().slice(0, 5),
- a !== "data-" && a !== "aria-");
- default:
- return !1
- }
- }
- function na(a, e, i, o) {
- if (e === null || typeof e == "undefined" || ma(a, e, i, o))
- return !0;
- if (o)
- return !1;
- if (i !== null)
- switch (i.type) {
- case 3:
- return !e;
- case 4:
- return e === !1;
- case 5:
- return isNaN(e);
- case 6:
- return isNaN(e) || 1 > e
- }
- return !1
- }
- function B(a, e, i, o, s, c, d) {
- this.acceptsBooleans = e === 2 || e === 3 || e === 4,
- this.attributeName = o,
- this.attributeNamespace = s,
- this.mustUseProperty = i,
- this.propertyName = a,
- this.type = e,
- this.sanitizeURL = c,
- this.removeEmptyString = d
- }
- var D = {};
- "children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(a) {
- D[a] = new B(a,0,!1,a,null,!1,!1)
- });
- [["acceptCharset", "accept-charset"], ["className", "class"], ["htmlFor", "for"], ["httpEquiv", "http-equiv"]].forEach(function(a) {
- var e = a[0];
- D[e] = new B(e,1,!1,a[1],null,!1,!1)
- });
- ["contentEditable", "draggable", "spellCheck", "value"].forEach(function(a) {
- D[a] = new B(a,2,!1,a.toLowerCase(),null,!1,!1)
- });
- ["autoReverse", "externalResourcesRequired", "focusable", "preserveAlpha"].forEach(function(a) {
- D[a] = new B(a,2,!1,a,null,!1,!1)
- });
- "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) {
- D[a] = new B(a,3,!1,a.toLowerCase(),null,!1,!1)
- });
- ["checked", "multiple", "muted", "selected"].forEach(function(a) {
- D[a] = new B(a,3,!0,a,null,!1,!1)
- });
- ["capture", "download"].forEach(function(a) {
- D[a] = new B(a,4,!1,a,null,!1,!1)
- });
- ["cols", "rows", "size", "span"].forEach(function(a) {
- D[a] = new B(a,6,!1,a,null,!1,!1)
- });
- ["rowSpan", "start"].forEach(function(a) {
- D[a] = new B(a,5,!1,a.toLowerCase(),null,!1,!1)
- });
- var oa = /[\-:]([a-z])/g;
- function pa(a) {
- return a[1].toUpperCase()
- }
- "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) {
- var e = a.replace(oa, pa);
- D[e] = new B(e,1,!1,a,null,!1,!1)
- });
- "xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(a) {
- var e = a.replace(oa, pa);
- D[e] = new B(e,1,!1,a,"http://www.w3.org/1999/xlink",!1,!1)
- });
- ["xml:base", "xml:lang", "xml:space"].forEach(function(a) {
- var e = a.replace(oa, pa);
- D[e] = new B(e,1,!1,a,"http://www.w3.org/XML/1998/namespace",!1,!1)
- });
- ["tabIndex", "crossOrigin"].forEach(function(a) {
- D[a] = new B(a,1,!1,a.toLowerCase(),null,!1,!1)
- });
- D.xlinkHref = new B("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);
- ["src", "href", "action", "formAction"].forEach(function(a) {
- D[a] = new B(a,1,!1,a.toLowerCase(),null,!0,!0)
- });
- function qa(a, e, i, o) {
- var s = D.hasOwnProperty(e) ? D[e] : null
- , c = s !== null ? s.type === 0 : o ? !1 : !(!(2 < e.length) || e[0] !== "o" && e[0] !== "O" || e[1] !== "n" && e[1] !== "N");
- c || (na(e, i, s, o) && (i = null),
- 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,
- o = s.attributeNamespace,
- i === null ? a.removeAttribute(e) : (s = s.type,
- i = s === 3 || s === 4 && i === !0 ? "" : "" + i,
- o ? a.setAttributeNS(o, e, i) : a.setAttribute(e, i))))
- }
- var ra = aa.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
- , sa = 60103
- , ta = 60106
- , ua = 60107
- , wa = 60108
- , xa = 60114
- , ya = 60109
- , za = 60110
- , Aa = 60112
- , Ba = 60113
- , Ca = 60120
- , Da = 60115
- , Ea = 60116
- , Fa = 60121
- , Ga = 60128
- , Ha = 60129
- , Ia = 60130
- , Ja = 60131;
- if (typeof Symbol == "function" && Symbol.for) {
- var E = Symbol.for;
- sa = E("react.element"),
- ta = E("react.portal"),
- ua = E("react.fragment"),
- wa = E("react.strict_mode"),
- xa = E("react.profiler"),
- ya = E("react.provider"),
- za = E("react.context"),
- Aa = E("react.forward_ref"),
- Ba = E("react.suspense"),
- Ca = E("react.suspense_list"),
- Da = E("react.memo"),
- Ea = E("react.lazy"),
- Fa = E("react.block"),
- E("react.scope"),
- Ga = E("react.opaque.id"),
- Ha = E("react.debug_trace_mode"),
- Ia = E("react.offscreen"),
- Ja = E("react.legacy_hidden")
- }
- var Ka = typeof Symbol == "function" && Symbol.iterator;
- function La(a) {
- return a === null || typeof a != "object" ? null : (a = Ka && a[Ka] || a["@@iterator"],
- typeof a == "function" ? a : null)
- }
- var Ma;
- function Na(a) {
- if (Ma === void 0)
- try {
- throw Error()
- } catch (i) {
- var e = i.stack.trim().match(/\n( *(at )?)/);
- Ma = e && e[1] || ""
- }
- return `
- ` + Ma + a
- }
- var Oa = !1;
- function Pa(a, e) {
- if (!a || Oa)
- return "";
- Oa = !0;
- var i = Error.prepareStackTrace;
- Error.prepareStackTrace = void 0;
- try {
- if (e)
- if (e = function() {
- throw Error()
- }
- ,
- Object.defineProperty(e.prototype, "props", {
- set: function() {
- throw Error()
- }
- }),
- typeof Reflect == "object" && Reflect.construct) {
- try {
- Reflect.construct(e, [])
- } catch (b) {
- var o = b
- }
- Reflect.construct(a, [], e)
- } else {
- try {
- e.call()
- } catch (b) {
- o = b
- }
- a.call(e.prototype)
- }
- else {
- try {
- throw Error()
- } catch (b) {
- o = b
- }
- a()
- }
- } catch (b) {
- if (b && o && typeof b.stack == "string") {
- for (var s = b.stack.split(`
- `), c = o.stack.split(`
- `), d = s.length - 1, _ = c.length - 1; 1 <= d && 0 <= _ && s[d] !== c[_]; )
- _--;
- for (; 1 <= d && 0 <= _; d--,
- _--)
- if (s[d] !== c[_]) {
- if (d !== 1 || _ !== 1)
- do
- if (d--,
- _--,
- 0 > _ || s[d] !== c[_])
- return `
- ` + s[d].replace(" at new ", " at ");
- while (1 <= d && 0 <= _);
- break
- }
- }
- } finally {
- Oa = !1,
- Error.prepareStackTrace = i
- }
- return (a = a ? a.displayName || a.name : "") ? Na(a) : ""
- }
- function Qa(a) {
- switch (a.tag) {
- case 5:
- return Na(a.type);
- case 16:
- return Na("Lazy");
- case 13:
- return Na("Suspense");
- case 19:
- return Na("SuspenseList");
- case 0:
- case 2:
- case 15:
- return a = Pa(a.type, !1),
- a;
- case 11:
- return a = Pa(a.type.render, !1),
- a;
- case 22:
- return a = Pa(a.type._render, !1),
- a;
- case 1:
- return a = Pa(a.type, !0),
- a;
- default:
- return ""
- }
- }
- function Ra(a) {
- if (a == null)
- return null;
- if (typeof a == "function")
- return a.displayName || a.name || null;
- if (typeof a == "string")
- return a;
- switch (a) {
- case ua:
- return "Fragment";
- case ta:
- return "Portal";
- case xa:
- return "Profiler";
- case wa:
- return "StrictMode";
- case Ba:
- return "Suspense";
- case Ca:
- return "SuspenseList"
- }
- if (typeof a == "object")
- switch (a.$$typeof) {
- case za:
- return (a.displayName || "Context") + ".Consumer";
- case ya:
- return (a._context.displayName || "Context") + ".Provider";
- case Aa:
- var e = a.render;
- return e = e.displayName || e.name || "",
- a.displayName || (e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef");
- case Da:
- return Ra(a.type);
- case Fa:
- return Ra(a._render);
- case Ea:
- e = a._payload,
- a = a._init;
- try {
- return Ra(a(e))
- } catch {}
- }
- return null
- }
- function Sa(a) {
- switch (typeof a) {
- case "boolean":
- case "number":
- case "object":
- case "string":
- case "undefined":
- return a;
- default:
- return ""
- }
- }
- function Ta(a) {
- var e = a.type;
- return (a = a.nodeName) && a.toLowerCase() === "input" && (e === "checkbox" || e === "radio")
- }
- function Ua(a) {
- var e = Ta(a) ? "checked" : "value"
- , i = Object.getOwnPropertyDescriptor(a.constructor.prototype, e)
- , o = "" + a[e];
- if (!a.hasOwnProperty(e) && typeof i != "undefined" && typeof i.get == "function" && typeof i.set == "function") {
- var s = i.get
- , c = i.set;
- return Object.defineProperty(a, e, {
- configurable: !0,
- get: function() {
- return s.call(this)
- },
- set: function(d) {
- o = "" + d,
- c.call(this, d)
- }
- }),
- Object.defineProperty(a, e, {
- enumerable: i.enumerable
- }),
- {
- getValue: function() {
- return o
- },
- setValue: function(d) {
- o = "" + d
- },
- stopTracking: function() {
- a._valueTracker = null,
- delete a[e]
- }
- }
- }
- }
- function Va(a) {
- a._valueTracker || (a._valueTracker = Ua(a))
- }
- function Wa(a) {
- if (!a)
- return !1;
- var e = a._valueTracker;
- if (!e)
- return !0;
- var i = e.getValue()
- , o = "";
- return a && (o = Ta(a) ? a.checked ? "true" : "false" : a.value),
- a = o,
- a !== i ? (e.setValue(a),
- !0) : !1
- }
- function Xa(a) {
- if (a = a || (typeof document != "undefined" ? document : void 0),
- typeof a == "undefined")
- return null;
- try {
- return a.activeElement || a.body
- } catch {
- return a.body
- }
- }
- function Ya(a, e) {
- var i = e.checked;
- return m$1({}, e, {
- defaultChecked: void 0,
- defaultValue: void 0,
- value: void 0,
- checked: i != null ? i : a._wrapperState.initialChecked
- })
- }
- function Za(a, e) {
- var i = e.defaultValue == null ? "" : e.defaultValue
- , o = e.checked != null ? e.checked : e.defaultChecked;
- i = Sa(e.value != null ? e.value : i),
- a._wrapperState = {
- initialChecked: o,
- initialValue: i,
- controlled: e.type === "checkbox" || e.type === "radio" ? e.checked != null : e.value != null
- }
- }
- function $a(a, e) {
- e = e.checked,
- e != null && qa(a, "checked", e, !1)
- }
- function ab(a, e) {
- $a(a, e);
- var i = Sa(e.value)
- , o = e.type;
- if (i != null)
- o === "number" ? (i === 0 && a.value === "" || a.value != i) && (a.value = "" + i) : a.value !== "" + i && (a.value = "" + i);
- else if (o === "submit" || o === "reset") {
- a.removeAttribute("value");
- return
- }
- e.hasOwnProperty("value") ? bb(a, e.type, i) : e.hasOwnProperty("defaultValue") && bb(a, e.type, Sa(e.defaultValue)),
- e.checked == null && e.defaultChecked != null && (a.defaultChecked = !!e.defaultChecked)
- }
- function cb(a, e, i) {
- if (e.hasOwnProperty("value") || e.hasOwnProperty("defaultValue")) {
- var o = e.type;
- if (!(o !== "submit" && o !== "reset" || e.value !== void 0 && e.value !== null))
- return;
- e = "" + a._wrapperState.initialValue,
- i || e === a.value || (a.value = e),
- a.defaultValue = e
- }
- i = a.name,
- i !== "" && (a.name = ""),
- a.defaultChecked = !!a._wrapperState.initialChecked,
- i !== "" && (a.name = i)
- }
- function bb(a, e, i) {
- (e !== "number" || Xa(a.ownerDocument) !== a) && (i == null ? a.defaultValue = "" + a._wrapperState.initialValue : a.defaultValue !== "" + i && (a.defaultValue = "" + i))
- }
- function db(a) {
- var e = "";
- return aa.Children.forEach(a, function(i) {
- i != null && (e += i)
- }),
- e
- }
- function eb(a, e) {
- return a = m$1({
- children: void 0
- }, e),
- (e = db(e.children)) && (a.children = e),
- a
- }
- function fb(a, e, i, o) {
- if (a = a.options,
- e) {
- e = {};
- for (var s = 0; s < i.length; s++)
- e["$" + i[s]] = !0;
- for (i = 0; i < a.length; i++)
- s = e.hasOwnProperty("$" + a[i].value),
- a[i].selected !== s && (a[i].selected = s),
- s && o && (a[i].defaultSelected = !0)
- } else {
- for (i = "" + Sa(i),
- e = null,
- s = 0; s < a.length; s++) {
- if (a[s].value === i) {
- a[s].selected = !0,
- o && (a[s].defaultSelected = !0);
- return
- }
- e !== null || a[s].disabled || (e = a[s])
- }
- e !== null && (e.selected = !0)
- }
- }
- function gb(a, e) {
- if (e.dangerouslySetInnerHTML != null)
- throw Error(y(91));
- return m$1({}, e, {
- value: void 0,
- defaultValue: void 0,
- children: "" + a._wrapperState.initialValue
- })
- }
- function hb(a, e) {
- var i = e.value;
- if (i == null) {
- if (i = e.children,
- e = e.defaultValue,
- i != null) {
- if (e != null)
- throw Error(y(92));
- if (Array.isArray(i)) {
- if (!(1 >= i.length))
- throw Error(y(93));
- i = i[0]
- }
- e = i
- }
- e == null && (e = ""),
- i = e
- }
- a._wrapperState = {
- initialValue: Sa(i)
- }
- }
- function ib(a, e) {
- var i = Sa(e.value)
- , o = Sa(e.defaultValue);
- i != null && (i = "" + i,
- i !== a.value && (a.value = i),
- e.defaultValue == null && a.defaultValue !== i && (a.defaultValue = i)),
- o != null && (a.defaultValue = "" + o)
- }
- function jb(a) {
- var e = a.textContent;
- e === a._wrapperState.initialValue && e !== "" && e !== null && (a.value = e)
- }
- var kb = {
- html: "http://www.w3.org/1999/xhtml",
- mathml: "http://www.w3.org/1998/Math/MathML",
- svg: "http://www.w3.org/2000/svg"
- };
- function lb(a) {
- switch (a) {
- case "svg":
- return "http://www.w3.org/2000/svg";
- case "math":
- return "http://www.w3.org/1998/Math/MathML";
- default:
- return "http://www.w3.org/1999/xhtml"
- }
- }
- function mb(a, e) {
- 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
- }
- var nb, ob = function(a) {
- return typeof MSApp != "undefined" && MSApp.execUnsafeLocalFunction ? function(e, i, o, s) {
- MSApp.execUnsafeLocalFunction(function() {
- return a(e, i, o, s)
- })
- }
- : a
- }(function(a, e) {
- if (a.namespaceURI !== kb.svg || "innerHTML"in a)
- a.innerHTML = e;
- else {
- for (nb = nb || document.createElement("div"),
- nb.innerHTML = "<svg>" + e.valueOf().toString() + "</svg>",
- e = nb.firstChild; a.firstChild; )
- a.removeChild(a.firstChild);
- for (; e.firstChild; )
- a.appendChild(e.firstChild)
- }
- });
- function pb(a, e) {
- if (e) {
- var i = a.firstChild;
- if (i && i === a.lastChild && i.nodeType === 3) {
- i.nodeValue = e;
- return
- }
- }
- a.textContent = e
- }
- var qb = {
- animationIterationCount: !0,
- borderImageOutset: !0,
- borderImageSlice: !0,
- borderImageWidth: !0,
- boxFlex: !0,
- boxFlexGroup: !0,
- boxOrdinalGroup: !0,
- columnCount: !0,
- columns: !0,
- flex: !0,
- flexGrow: !0,
- flexPositive: !0,
- flexShrink: !0,
- flexNegative: !0,
- flexOrder: !0,
- gridArea: !0,
- gridRow: !0,
- gridRowEnd: !0,
- gridRowSpan: !0,
- gridRowStart: !0,
- gridColumn: !0,
- gridColumnEnd: !0,
- gridColumnSpan: !0,
- gridColumnStart: !0,
- fontWeight: !0,
- lineClamp: !0,
- lineHeight: !0,
- opacity: !0,
- order: !0,
- orphans: !0,
- tabSize: !0,
- widows: !0,
- zIndex: !0,
- zoom: !0,
- fillOpacity: !0,
- floodOpacity: !0,
- stopOpacity: !0,
- strokeDasharray: !0,
- strokeDashoffset: !0,
- strokeMiterlimit: !0,
- strokeOpacity: !0,
- strokeWidth: !0
- }
- , rb = ["Webkit", "ms", "Moz", "O"];
- Object.keys(qb).forEach(function(a) {
- rb.forEach(function(e) {
- e = e + a.charAt(0).toUpperCase() + a.substring(1),
- qb[e] = qb[a]
- })
- });
- function sb(a, e, i) {
- return e == null || typeof e == "boolean" || e === "" ? "" : i || typeof e != "number" || e === 0 || qb.hasOwnProperty(a) && qb[a] ? ("" + e).trim() : e + "px"
- }
- function tb(a, e) {
- a = a.style;
- for (var i in e)
- if (e.hasOwnProperty(i)) {
- var o = i.indexOf("--") === 0
- , s = sb(i, e[i], o);
- i === "float" && (i = "cssFloat"),
- o ? a.setProperty(i, s) : a[i] = s
- }
- }
- var ub = m$1({
- menuitem: !0
- }, {
- area: !0,
- base: !0,
- br: !0,
- col: !0,
- embed: !0,
- hr: !0,
- img: !0,
- input: !0,
- keygen: !0,
- link: !0,
- meta: !0,
- param: !0,
- source: !0,
- track: !0,
- wbr: !0
- });
- function vb(a, e) {
- if (e) {
- if (ub[a] && (e.children != null || e.dangerouslySetInnerHTML != null))
- throw Error(y(137, a));
- if (e.dangerouslySetInnerHTML != null) {
- if (e.children != null)
- throw Error(y(60));
- if (!(typeof e.dangerouslySetInnerHTML == "object" && "__html"in e.dangerouslySetInnerHTML))
- throw Error(y(61))
- }
- if (e.style != null && typeof e.style != "object")
- throw Error(y(62))
- }
- }
- function wb(a, e) {
- if (a.indexOf("-") === -1)
- return typeof e.is == "string";
- switch (a) {
- case "annotation-xml":
- case "color-profile":
- case "font-face":
- case "font-face-src":
- case "font-face-uri":
- case "font-face-format":
- case "font-face-name":
- case "missing-glyph":
- return !1;
- default:
- return !0
- }
- }
- function xb(a) {
- return a = a.target || a.srcElement || window,
- a.correspondingUseElement && (a = a.correspondingUseElement),
- a.nodeType === 3 ? a.parentNode : a
- }
- var yb = null
- , zb = null
- , Ab = null;
- function Bb(a) {
- if (a = Cb(a)) {
- if (typeof yb != "function")
- throw Error(y(280));
- var e = a.stateNode;
- e && (e = Db(e),
- yb(a.stateNode, a.type, e))
- }
- }
- function Eb(a) {
- zb ? Ab ? Ab.push(a) : Ab = [a] : zb = a
- }
- function Fb() {
- if (zb) {
- var a = zb
- , e = Ab;
- if (Ab = zb = null,
- Bb(a),
- e)
- for (a = 0; a < e.length; a++)
- Bb(e[a])
- }
- }
- function Gb(a, e) {
- return a(e)
- }
- function Hb(a, e, i, o, s) {
- return a(e, i, o, s)
- }
- function Ib() {}
- var Jb = Gb
- , Kb = !1
- , Lb = !1;
- function Mb() {
- (zb !== null || Ab !== null) && (Ib(),
- Fb())
- }
- function Nb(a, e, i) {
- if (Lb)
- return a(e, i);
- Lb = !0;
- try {
- return Jb(a, e, i)
- } finally {
- Lb = !1,
- Mb()
- }
- }
- function Ob(a, e) {
- var i = a.stateNode;
- if (i === null)
- return null;
- var o = Db(i);
- if (o === null)
- return null;
- i = o[e];
- e: switch (e) {
- case "onClick":
- case "onClickCapture":
- case "onDoubleClick":
- case "onDoubleClickCapture":
- case "onMouseDown":
- case "onMouseDownCapture":
- case "onMouseMove":
- case "onMouseMoveCapture":
- case "onMouseUp":
- case "onMouseUpCapture":
- case "onMouseEnter":
- (o = !o.disabled) || (a = a.type,
- o = !(a === "button" || a === "input" || a === "select" || a === "textarea")),
- a = !o;
- break e;
- default:
- a = !1
- }
- if (a)
- return null;
- if (i && typeof i != "function")
- throw Error(y(231, e, typeof i));
- return i
- }
- var Pb = !1;
- if (fa)
- try {
- var Qb = {};
- Object.defineProperty(Qb, "passive", {
- get: function() {
- Pb = !0
- }
- }),
- window.addEventListener("test", Qb, Qb),
- window.removeEventListener("test", Qb, Qb)
- } catch {
- Pb = !1
- }
- function Rb(a, e, i, o, s, c, d, _, b) {
- var k = Array.prototype.slice.call(arguments, 3);
- try {
- e.apply(i, k)
- } catch (j) {
- this.onError(j)
- }
- }
- var Sb = !1
- , Tb = null
- , Ub = !1
- , Vb = null
- , Wb = {
- onError: function(a) {
- Sb = !0,
- Tb = a
- }
- };
- function Xb(a, e, i, o, s, c, d, _, b) {
- Sb = !1,
- Tb = null,
- Rb.apply(Wb, arguments)
- }
- function Yb(a, e, i, o, s, c, d, _, b) {
- if (Xb.apply(this, arguments),
- Sb) {
- if (Sb) {
- var k = Tb;
- Sb = !1,
- Tb = null
- } else
- throw Error(y(198));
- Ub || (Ub = !0,
- Vb = k)
- }
- }
- function Zb(a) {
- var e = a
- , i = a;
- if (a.alternate)
- for (; e.return; )
- e = e.return;
- else {
- a = e;
- do
- e = a,
- (e.flags & 1026) !== 0 && (i = e.return),
- a = e.return;
- while (a)
- }
- return e.tag === 3 ? i : null
- }
- function $b(a) {
- if (a.tag === 13) {
- var e = a.memoizedState;
- if (e === null && (a = a.alternate,
- a !== null && (e = a.memoizedState)),
- e !== null)
- return e.dehydrated
- }
- return null
- }
- function ac(a) {
- if (Zb(a) !== a)
- throw Error(y(188))
- }
- function bc(a) {
- var e = a.alternate;
- if (!e) {
- if (e = Zb(a),
- e === null)
- throw Error(y(188));
- return e !== a ? null : a
- }
- for (var i = a, o = e; ; ) {
- var s = i.return;
- if (s === null)
- break;
- var c = s.alternate;
- if (c === null) {
- if (o = s.return,
- o !== null) {
- i = o;
- continue
- }
- break
- }
- if (s.child === c.child) {
- for (c = s.child; c; ) {
- if (c === i)
- return ac(s),
- a;
- if (c === o)
- return ac(s),
- e;
- c = c.sibling
- }
- throw Error(y(188))
- }
- if (i.return !== o.return)
- i = s,
- o = c;
- else {
- for (var d = !1, _ = s.child; _; ) {
- if (_ === i) {
- d = !0,
- i = s,
- o = c;
- break
- }
- if (_ === o) {
- d = !0,
- o = s,
- i = c;
- break
- }
- _ = _.sibling
- }
- if (!d) {
- for (_ = c.child; _; ) {
- if (_ === i) {
- d = !0,
- i = c,
- o = s;
- break
- }
- if (_ === o) {
- d = !0,
- o = c,
- i = s;
- break
- }
- _ = _.sibling
- }
- if (!d)
- throw Error(y(189))
- }
- }
- if (i.alternate !== o)
- throw Error(y(190))
- }
- if (i.tag !== 3)
- throw Error(y(188));
- return i.stateNode.current === i ? a : e
- }
- function cc(a) {
- if (a = bc(a),
- !a)
- return null;
- for (var e = a; ; ) {
- if (e.tag === 5 || e.tag === 6)
- return e;
- if (e.child)
- e.child.return = e,
- e = e.child;
- else {
- if (e === a)
- break;
- for (; !e.sibling; ) {
- if (!e.return || e.return === a)
- return null;
- e = e.return
- }
- e.sibling.return = e.return,
- e = e.sibling
- }
- }
- return null
- }
- function dc(a, e) {
- for (var i = a.alternate; e !== null; ) {
- if (e === a || e === i)
- return !0;
- e = e.return
- }
- return !1
- }
- 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(" ");
- function rc(a, e, i, o, s) {
- return {
- blockedOn: a,
- domEventName: e,
- eventSystemFlags: i | 16,
- nativeEvent: s,
- targetContainers: [o]
- }
- }
- function sc(a, e) {
- switch (a) {
- case "focusin":
- case "focusout":
- kc = null;
- break;
- case "dragenter":
- case "dragleave":
- lc = null;
- break;
- case "mouseover":
- case "mouseout":
- mc = null;
- break;
- case "pointerover":
- case "pointerout":
- nc.delete(e.pointerId);
- break;
- case "gotpointercapture":
- case "lostpointercapture":
- oc.delete(e.pointerId)
- }
- }
- function tc(a, e, i, o, s, c) {
- return a === null || a.nativeEvent !== c ? (a = rc(e, i, o, s, c),
- e !== null && (e = Cb(e),
- e !== null && fc(e)),
- a) : (a.eventSystemFlags |= o,
- e = a.targetContainers,
- s !== null && e.indexOf(s) === -1 && e.push(s),
- a)
- }
- function uc(a, e, i, o, s) {
- switch (e) {
- case "focusin":
- return kc = tc(kc, a, e, i, o, s),
- !0;
- case "dragenter":
- return lc = tc(lc, a, e, i, o, s),
- !0;
- case "mouseover":
- return mc = tc(mc, a, e, i, o, s),
- !0;
- case "pointerover":
- var c = s.pointerId;
- return nc.set(c, tc(nc.get(c) || null, a, e, i, o, s)),
- !0;
- case "gotpointercapture":
- return c = s.pointerId,
- oc.set(c, tc(oc.get(c) || null, a, e, i, o, s)),
- !0
- }
- return !1
- }
- function vc(a) {
- var e = wc(a.target);
- if (e !== null) {
- var i = Zb(e);
- if (i !== null) {
- if (e = i.tag,
- e === 13) {
- if (e = $b(i),
- e !== null) {
- a.blockedOn = e,
- hc(a.lanePriority, function() {
- r.unstable_runWithPriority(a.priority, function() {
- gc(i)
- })
- });
- return
- }
- } else if (e === 3 && i.stateNode.hydrate) {
- a.blockedOn = i.tag === 3 ? i.stateNode.containerInfo : null;
- return
- }
- }
- }
- a.blockedOn = null
- }
- function xc(a) {
- if (a.blockedOn !== null)
- return !1;
- for (var e = a.targetContainers; 0 < e.length; ) {
- var i = yc(a.domEventName, a.eventSystemFlags, e[0], a.nativeEvent);
- if (i !== null)
- return e = Cb(i),
- e !== null && fc(e),
- a.blockedOn = i,
- !1;
- e.shift()
- }
- return !0
- }
- function zc(a, e, i) {
- xc(a) && i.delete(e)
- }
- function Ac() {
- for (ic = !1; 0 < jc.length; ) {
- var a = jc[0];
- if (a.blockedOn !== null) {
- a = Cb(a.blockedOn),
- a !== null && ec(a);
- break
- }
- for (var e = a.targetContainers; 0 < e.length; ) {
- var i = yc(a.domEventName, a.eventSystemFlags, e[0], a.nativeEvent);
- if (i !== null) {
- a.blockedOn = i;
- break
- }
- e.shift()
- }
- a.blockedOn === null && jc.shift()
- }
- kc !== null && xc(kc) && (kc = null),
- lc !== null && xc(lc) && (lc = null),
- mc !== null && xc(mc) && (mc = null),
- nc.forEach(zc),
- oc.forEach(zc)
- }
- function Bc(a, e) {
- a.blockedOn === e && (a.blockedOn = null,
- ic || (ic = !0,
- r.unstable_scheduleCallback(r.unstable_NormalPriority, Ac)))
- }
- function Cc(a) {
- function e(s) {
- return Bc(s, a)
- }
- if (0 < jc.length) {
- Bc(jc[0], a);
- for (var i = 1; i < jc.length; i++) {
- var o = jc[i];
- o.blockedOn === a && (o.blockedOn = null)
- }
- }
- for (kc !== null && Bc(kc, a),
- lc !== null && Bc(lc, a),
- mc !== null && Bc(mc, a),
- nc.forEach(e),
- oc.forEach(e),
- i = 0; i < pc.length; i++)
- o = pc[i],
- o.blockedOn === a && (o.blockedOn = null);
- for (; 0 < pc.length && (i = pc[0],
- i.blockedOn === null); )
- vc(i),
- i.blockedOn === null && pc.shift()
- }
- function Dc(a, e) {
- var i = {};
- return i[a.toLowerCase()] = e.toLowerCase(),
- i["Webkit" + a] = "webkit" + e,
- i["Moz" + a] = "moz" + e,
- i
- }
- var Ec = {
- animationend: Dc("Animation", "AnimationEnd"),
- animationiteration: Dc("Animation", "AnimationIteration"),
- animationstart: Dc("Animation", "AnimationStart"),
- transitionend: Dc("Transition", "TransitionEnd")
- }
- , Fc = {}
- , Gc = {};
- fa && (Gc = document.createElement("div").style,
- "AnimationEvent"in window || (delete Ec.animationend.animation,
- delete Ec.animationiteration.animation,
- delete Ec.animationstart.animation),
- "TransitionEvent"in window || delete Ec.transitionend.transition);
- function Hc(a) {
- if (Fc[a])
- return Fc[a];
- if (!Ec[a])
- return a;
- var e = Ec[a], i;
- for (i in e)
- if (e.hasOwnProperty(i) && i in Gc)
- return Fc[a] = e[i];
- return a
- }
- var Ic = Hc("animationend")
- , Jc = Hc("animationiteration")
- , Kc = Hc("animationstart")
- , Lc = Hc("transitionend")
- , Mc = new Map
- , Nc = new Map
- , 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"];
- function Pc(a, e) {
- for (var i = 0; i < a.length; i += 2) {
- var o = a[i]
- , s = a[i + 1];
- s = "on" + (s[0].toUpperCase() + s.slice(1)),
- Nc.set(o, e),
- Mc.set(o, s),
- da(s, [o])
- }
- }
- var Qc = r.unstable_now;
- Qc();
- var F = 8;
- function Rc(a) {
- if ((1 & a) !== 0)
- return F = 15,
- 1;
- if ((2 & a) !== 0)
- return F = 14,
- 2;
- if ((4 & a) !== 0)
- return F = 13,
- 4;
- var e = 24 & a;
- return e !== 0 ? (F = 12,
- e) : (a & 32) !== 0 ? (F = 11,
- 32) : (e = 192 & a,
- e !== 0 ? (F = 10,
- e) : (a & 256) !== 0 ? (F = 9,
- 256) : (e = 3584 & a,
- e !== 0 ? (F = 8,
- e) : (a & 4096) !== 0 ? (F = 7,
- 4096) : (e = 4186112 & a,
- e !== 0 ? (F = 6,
- e) : (e = 62914560 & a,
- e !== 0 ? (F = 5,
- e) : a & 67108864 ? (F = 4,
- 67108864) : (a & 134217728) !== 0 ? (F = 3,
- 134217728) : (e = 805306368 & a,
- e !== 0 ? (F = 2,
- e) : (1073741824 & a) !== 0 ? (F = 1,
- 1073741824) : (F = 8,
- a))))))
- }
- function Sc(a) {
- switch (a) {
- case 99:
- return 15;
- case 98:
- return 10;
- case 97:
- case 96:
- return 8;
- case 95:
- return 2;
- default:
- return 0
- }
- }
- function Tc(a) {
- switch (a) {
- case 15:
- case 14:
- return 99;
- case 13:
- case 12:
- case 11:
- case 10:
- return 98;
- case 9:
- case 8:
- case 7:
- case 6:
- case 4:
- case 5:
- return 97;
- case 3:
- case 2:
- case 1:
- return 95;
- case 0:
- return 90;
- default:
- throw Error(y(358, a))
- }
- }
- function Uc(a, e) {
- var i = a.pendingLanes;
- if (i === 0)
- return F = 0;
- var o = 0
- , s = 0
- , c = a.expiredLanes
- , d = a.suspendedLanes
- , _ = a.pingedLanes;
- if (c !== 0)
- o = c,
- s = F = 15;
- else if (c = i & 134217727,
- c !== 0) {
- var b = c & ~d;
- b !== 0 ? (o = Rc(b),
- s = F) : (_ &= c,
- _ !== 0 && (o = Rc(_),
- s = F))
- } else
- c = i & ~d,
- c !== 0 ? (o = Rc(c),
- s = F) : _ !== 0 && (o = Rc(_),
- s = F);
- if (o === 0)
- return 0;
- if (o = 31 - Vc(o),
- o = i & ((0 > o ? 0 : 1 << o) << 1) - 1,
- e !== 0 && e !== o && (e & d) === 0) {
- if (Rc(e),
- s <= F)
- return e;
- F = s
- }
- if (e = a.entangledLanes,
- e !== 0)
- for (a = a.entanglements,
- e &= o; 0 < e; )
- i = 31 - Vc(e),
- s = 1 << i,
- o |= a[i],
- e &= ~s;
- return o
- }
- function Wc(a) {
- return a = a.pendingLanes & -1073741825,
- a !== 0 ? a : a & 1073741824 ? 1073741824 : 0
- }
- function Xc(a, e) {
- switch (a) {
- case 15:
- return 1;
- case 14:
- return 2;
- case 12:
- return a = Yc(24 & ~e),
- a === 0 ? Xc(10, e) : a;
- case 10:
- return a = Yc(192 & ~e),
- a === 0 ? Xc(8, e) : a;
- case 8:
- return a = Yc(3584 & ~e),
- a === 0 && (a = Yc(4186112 & ~e),
- a === 0 && (a = 512)),
- a;
- case 2:
- return e = Yc(805306368 & ~e),
- e === 0 && (e = 268435456),
- e
- }
- throw Error(y(358, a))
- }
- function Yc(a) {
- return a & -a
- }
- function Zc(a) {
- for (var e = [], i = 0; 31 > i; i++)
- e.push(a);
- return e
- }
- function $c(a, e, i) {
- a.pendingLanes |= e;
- var o = e - 1;
- a.suspendedLanes &= o,
- a.pingedLanes &= o,
- a = a.eventTimes,
- e = 31 - Vc(e),
- a[e] = i
- }
- var Vc = Math.clz32 ? Math.clz32 : ad
- , bd = Math.log
- , cd = Math.LN2;
- function ad(a) {
- return a === 0 ? 32 : 31 - (bd(a) / cd | 0) | 0
- }
- var dd = r.unstable_UserBlockingPriority
- , ed = r.unstable_runWithPriority
- , fd = !0;
- function gd(a, e, i, o) {
- Kb || Ib();
- var s = hd
- , c = Kb;
- Kb = !0;
- try {
- Hb(s, a, e, i, o)
- } finally {
- (Kb = c) || Mb()
- }
- }
- function id(a, e, i, o) {
- ed(dd, hd.bind(null, a, e, i, o))
- }
- function hd(a, e, i, o) {
- if (fd) {
- var s;
- if ((s = (e & 4) === 0) && 0 < jc.length && -1 < qc.indexOf(a))
- a = rc(null, a, e, i, o),
- jc.push(a);
- else {
- var c = yc(a, e, i, o);
- if (c === null)
- s && sc(a, o);
- else {
- if (s) {
- if (-1 < qc.indexOf(a)) {
- a = rc(c, a, e, i, o),
- jc.push(a);
- return
- }
- if (uc(c, a, e, i, o))
- return;
- sc(a, o)
- }
- jd(a, e, o, null, i)
- }
- }
- }
- }
- function yc(a, e, i, o) {
- var s = xb(o);
- if (s = wc(s),
- s !== null) {
- var c = Zb(s);
- if (c === null)
- s = null;
- else {
- var d = c.tag;
- if (d === 13) {
- if (s = $b(c),
- s !== null)
- return s;
- s = null
- } else if (d === 3) {
- if (c.stateNode.hydrate)
- return c.tag === 3 ? c.stateNode.containerInfo : null;
- s = null
- } else
- c !== s && (s = null)
- }
- }
- return jd(a, e, o, s, i),
- null
- }
- var kd = null
- , ld = null
- , md = null;
- function nd() {
- if (md)
- return md;
- var a, e = ld, i = e.length, o, s = "value"in kd ? kd.value : kd.textContent, c = s.length;
- for (a = 0; a < i && e[a] === s[a]; a++)
- ;
- var d = i - a;
- for (o = 1; o <= d && e[i - o] === s[c - o]; o++)
- ;
- return md = s.slice(a, 1 < o ? 1 - o : void 0)
- }
- function od(a) {
- var e = a.keyCode;
- return "charCode"in a ? (a = a.charCode,
- a === 0 && e === 13 && (a = 13)) : a = e,
- a === 10 && (a = 13),
- 32 <= a || a === 13 ? a : 0
- }
- function pd() {
- return !0
- }
- function qd() {
- return !1
- }
- function rd(a) {
- function e(i, o, s, c, d) {
- this._reactName = i,
- this._targetInst = s,
- this.type = o,
- this.nativeEvent = c,
- this.target = d,
- this.currentTarget = null;
- for (var _ in a)
- a.hasOwnProperty(_) && (i = a[_],
- this[_] = i ? i(c) : c[_]);
- return this.isDefaultPrevented = (c.defaultPrevented != null ? c.defaultPrevented : c.returnValue === !1) ? pd : qd,
- this.isPropagationStopped = qd,
- this
- }
- return m$1(e.prototype, {
- preventDefault: function() {
- this.defaultPrevented = !0;
- var i = this.nativeEvent;
- i && (i.preventDefault ? i.preventDefault() : typeof i.returnValue != "unknown" && (i.returnValue = !1),
- this.isDefaultPrevented = pd)
- },
- stopPropagation: function() {
- var i = this.nativeEvent;
- i && (i.stopPropagation ? i.stopPropagation() : typeof i.cancelBubble != "unknown" && (i.cancelBubble = !0),
- this.isPropagationStopped = pd)
- },
- persist: function() {},
- isPersistent: pd
- }),
- e
- }
- var sd = {
- eventPhase: 0,
- bubbles: 0,
- cancelable: 0,
- timeStamp: function(a) {
- return a.timeStamp || Date.now()
- },
- defaultPrevented: 0,
- isTrusted: 0
- }, td = rd(sd), ud = m$1({}, sd, {
- view: 0,
- detail: 0
- }), vd = rd(ud), wd, xd, yd, Ad = m$1({}, ud, {
- screenX: 0,
- screenY: 0,
- clientX: 0,
- clientY: 0,
- pageX: 0,
- pageY: 0,
- ctrlKey: 0,
- shiftKey: 0,
- altKey: 0,
- metaKey: 0,
- getModifierState: zd,
- button: 0,
- buttons: 0,
- relatedTarget: function(a) {
- return a.relatedTarget === void 0 ? a.fromElement === a.srcElement ? a.toElement : a.fromElement : a.relatedTarget
- },
- movementX: function(a) {
- return "movementX"in a ? a.movementX : (a !== yd && (yd && a.type === "mousemove" ? (wd = a.screenX - yd.screenX,
- xd = a.screenY - yd.screenY) : xd = wd = 0,
- yd = a),
- wd)
- },
- movementY: function(a) {
- return "movementY"in a ? a.movementY : xd
- }
- }), Bd = rd(Ad), Cd = m$1({}, Ad, {
- dataTransfer: 0
- }), Dd = rd(Cd), Ed = m$1({}, ud, {
- relatedTarget: 0
- }), Fd = rd(Ed), Gd = m$1({}, sd, {
- animationName: 0,
- elapsedTime: 0,
- pseudoElement: 0
- }), Hd = rd(Gd), Id = m$1({}, sd, {
- clipboardData: function(a) {
- return "clipboardData"in a ? a.clipboardData : window.clipboardData
- }
- }), Jd = rd(Id), Kd = m$1({}, sd, {
- data: 0
- }), Ld = rd(Kd), Md = {
- Esc: "Escape",
- Spacebar: " ",
- Left: "ArrowLeft",
- Up: "ArrowUp",
- Right: "ArrowRight",
- Down: "ArrowDown",
- Del: "Delete",
- Win: "OS",
- Menu: "ContextMenu",
- Apps: "ContextMenu",
- Scroll: "ScrollLock",
- MozPrintableKey: "Unidentified"
- }, Nd = {
- 8: "Backspace",
- 9: "Tab",
- 12: "Clear",
- 13: "Enter",
- 16: "Shift",
- 17: "Control",
- 18: "Alt",
- 19: "Pause",
- 20: "CapsLock",
- 27: "Escape",
- 32: " ",
- 33: "PageUp",
- 34: "PageDown",
- 35: "End",
- 36: "Home",
- 37: "ArrowLeft",
- 38: "ArrowUp",
- 39: "ArrowRight",
- 40: "ArrowDown",
- 45: "Insert",
- 46: "Delete",
- 112: "F1",
- 113: "F2",
- 114: "F3",
- 115: "F4",
- 116: "F5",
- 117: "F6",
- 118: "F7",
- 119: "F8",
- 120: "F9",
- 121: "F10",
- 122: "F11",
- 123: "F12",
- 144: "NumLock",
- 145: "ScrollLock",
- 224: "Meta"
- }, Od = {
- Alt: "altKey",
- Control: "ctrlKey",
- Meta: "metaKey",
- Shift: "shiftKey"
- };
- function Pd(a) {
- var e = this.nativeEvent;
- return e.getModifierState ? e.getModifierState(a) : (a = Od[a]) ? !!e[a] : !1
- }
- function zd() {
- return Pd
- }
- var Qd = m$1({}, ud, {
- key: function(a) {
- if (a.key) {
- var e = Md[a.key] || a.key;
- if (e !== "Unidentified")
- return e
- }
- return a.type === "keypress" ? (a = od(a),
- a === 13 ? "Enter" : String.fromCharCode(a)) : a.type === "keydown" || a.type === "keyup" ? Nd[a.keyCode] || "Unidentified" : ""
- },
- code: 0,
- location: 0,
- ctrlKey: 0,
- shiftKey: 0,
- altKey: 0,
- metaKey: 0,
- repeat: 0,
- locale: 0,
- getModifierState: zd,
- charCode: function(a) {
- return a.type === "keypress" ? od(a) : 0
- },
- keyCode: function(a) {
- return a.type === "keydown" || a.type === "keyup" ? a.keyCode : 0
- },
- which: function(a) {
- return a.type === "keypress" ? od(a) : a.type === "keydown" || a.type === "keyup" ? a.keyCode : 0
- }
- })
- , Rd = rd(Qd)
- , Sd = m$1({}, Ad, {
- pointerId: 0,
- width: 0,
- height: 0,
- pressure: 0,
- tangentialPressure: 0,
- tiltX: 0,
- tiltY: 0,
- twist: 0,
- pointerType: 0,
- isPrimary: 0
- })
- , Td = rd(Sd)
- , Ud = m$1({}, ud, {
- touches: 0,
- targetTouches: 0,
- changedTouches: 0,
- altKey: 0,
- metaKey: 0,
- ctrlKey: 0,
- shiftKey: 0,
- getModifierState: zd
- })
- , Vd = rd(Ud)
- , Wd = m$1({}, sd, {
- propertyName: 0,
- elapsedTime: 0,
- pseudoElement: 0
- })
- , Xd = rd(Wd)
- , Yd = m$1({}, Ad, {
- deltaX: function(a) {
- return "deltaX"in a ? a.deltaX : "wheelDeltaX"in a ? -a.wheelDeltaX : 0
- },
- deltaY: function(a) {
- return "deltaY"in a ? a.deltaY : "wheelDeltaY"in a ? -a.wheelDeltaY : "wheelDelta"in a ? -a.wheelDelta : 0
- },
- deltaZ: 0,
- deltaMode: 0
- })
- , Zd = rd(Yd)
- , $d = [9, 13, 27, 32]
- , ae = fa && "CompositionEvent"in window
- , be = null;
- fa && "documentMode"in document && (be = document.documentMode);
- var ce = fa && "TextEvent"in window && !be
- , de = fa && (!ae || be && 8 < be && 11 >= be)
- , ee = String.fromCharCode(32)
- , fe = !1;
- function ge(a, e) {
- switch (a) {
- case "keyup":
- return $d.indexOf(e.keyCode) !== -1;
- case "keydown":
- return e.keyCode !== 229;
- case "keypress":
- case "mousedown":
- case "focusout":
- return !0;
- default:
- return !1
- }
- }
- function he(a) {
- return a = a.detail,
- typeof a == "object" && "data"in a ? a.data : null
- }
- var ie = !1;
- function je(a, e) {
- switch (a) {
- case "compositionend":
- return he(e);
- case "keypress":
- return e.which !== 32 ? null : (fe = !0,
- ee);
- case "textInput":
- return a = e.data,
- a === ee && fe ? null : a;
- default:
- return null
- }
- }
- function ke(a, e) {
- if (ie)
- return a === "compositionend" || !ae && ge(a, e) ? (a = nd(),
- md = ld = kd = null,
- ie = !1,
- a) : null;
- switch (a) {
- case "paste":
- return null;
- case "keypress":
- if (!(e.ctrlKey || e.altKey || e.metaKey) || e.ctrlKey && e.altKey) {
- if (e.char && 1 < e.char.length)
- return e.char;
- if (e.which)
- return String.fromCharCode(e.which)
- }
- return null;
- case "compositionend":
- return de && e.locale !== "ko" ? null : e.data;
- default:
- return null
- }
- }
- var le = {
- color: !0,
- date: !0,
- datetime: !0,
- "datetime-local": !0,
- email: !0,
- month: !0,
- number: !0,
- password: !0,
- range: !0,
- search: !0,
- tel: !0,
- text: !0,
- time: !0,
- url: !0,
- week: !0
- };
- function me(a) {
- var e = a && a.nodeName && a.nodeName.toLowerCase();
- return e === "input" ? !!le[a.type] : e === "textarea"
- }
- function ne(a, e, i, o) {
- Eb(o),
- e = oe(e, "onChange"),
- 0 < e.length && (i = new td("onChange","change",null,i,o),
- a.push({
- event: i,
- listeners: e
- }))
- }
- var pe = null
- , qe = null;
- function re(a) {
- se(a, 0)
- }
- function te(a) {
- var e = ue(a);
- if (Wa(e))
- return a
- }
- function ve(a, e) {
- if (a === "change")
- return e
- }
- var we = !1;
- if (fa) {
- var xe;
- if (fa) {
- var ye = "oninput"in document;
- if (!ye) {
- var ze = document.createElement("div");
- ze.setAttribute("oninput", "return;"),
- ye = typeof ze.oninput == "function"
- }
- xe = ye
- } else
- xe = !1;
- we = xe && (!document.documentMode || 9 < document.documentMode)
- }
- function Ae() {
- pe && (pe.detachEvent("onpropertychange", Be),
- qe = pe = null)
- }
- function Be(a) {
- if (a.propertyName === "value" && te(qe)) {
- var e = [];
- if (ne(e, qe, a, xb(a)),
- a = re,
- Kb)
- a(e);
- else {
- Kb = !0;
- try {
- Gb(a, e)
- } finally {
- Kb = !1,
- Mb()
- }
- }
- }
- }
- function Ce(a, e, i) {
- a === "focusin" ? (Ae(),
- pe = e,
- qe = i,
- pe.attachEvent("onpropertychange", Be)) : a === "focusout" && Ae()
- }
- function De(a) {
- if (a === "selectionchange" || a === "keyup" || a === "keydown")
- return te(qe)
- }
- function Ee(a, e) {
- if (a === "click")
- return te(e)
- }
- function Fe(a, e) {
- if (a === "input" || a === "change")
- return te(e)
- }
- function Ge(a, e) {
- return a === e && (a !== 0 || 1 / a === 1 / e) || a !== a && e !== e
- }
- var He = typeof Object.is == "function" ? Object.is : Ge
- , Ie = Object.prototype.hasOwnProperty;
- function Je(a, e) {
- if (He(a, e))
- return !0;
- if (typeof a != "object" || a === null || typeof e != "object" || e === null)
- return !1;
- var i = Object.keys(a)
- , o = Object.keys(e);
- if (i.length !== o.length)
- return !1;
- for (o = 0; o < i.length; o++)
- if (!Ie.call(e, i[o]) || !He(a[i[o]], e[i[o]]))
- return !1;
- return !0
- }
- function Ke(a) {
- for (; a && a.firstChild; )
- a = a.firstChild;
- return a
- }
- function Le(a, e) {
- var i = Ke(a);
- a = 0;
- for (var o; i; ) {
- if (i.nodeType === 3) {
- if (o = a + i.textContent.length,
- a <= e && o >= e)
- return {
- node: i,
- offset: e - a
- };
- a = o
- }
- e: {
- for (; i; ) {
- if (i.nextSibling) {
- i = i.nextSibling;
- break e
- }
- i = i.parentNode
- }
- i = void 0
- }
- i = Ke(i)
- }
- }
- function Me(a, e) {
- 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
- }
- function Ne() {
- for (var a = window, e = Xa(); e instanceof a.HTMLIFrameElement; ) {
- try {
- var i = typeof e.contentWindow.location.href == "string"
- } catch {
- i = !1
- }
- if (i)
- a = e.contentWindow;
- else
- break;
- e = Xa(a.document)
- }
- return e
- }
- function Oe(a) {
- var e = a && a.nodeName && a.nodeName.toLowerCase();
- return e && (e === "input" && (a.type === "text" || a.type === "search" || a.type === "tel" || a.type === "url" || a.type === "password") || e === "textarea" || a.contentEditable === "true")
- }
- var Pe = fa && "documentMode"in document && 11 >= document.documentMode
- , Qe = null
- , Re = null
- , Se = null
- , Te = !1;
- function Ue(a, e, i) {
- var o = i.window === i ? i.document : i.nodeType === 9 ? i : i.ownerDocument;
- Te || Qe == null || Qe !== Xa(o) || (o = Qe,
- "selectionStart"in o && Oe(o) ? o = {
- start: o.selectionStart,
- end: o.selectionEnd
- } : (o = (o.ownerDocument && o.ownerDocument.defaultView || window).getSelection(),
- o = {
- anchorNode: o.anchorNode,
- anchorOffset: o.anchorOffset,
- focusNode: o.focusNode,
- focusOffset: o.focusOffset
- }),
- Se && Je(Se, o) || (Se = o,
- o = oe(Re, "onSelect"),
- 0 < o.length && (e = new td("onSelect","select",null,e,i),
- a.push({
- event: e,
- listeners: o
- }),
- e.target = Qe)))
- }
- 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);
- 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);
- Pc(Oc, 2);
- for (var Ve = "change selectionchange textInput compositionstart compositionend compositionupdate".split(" "), We = 0; We < Ve.length; We++)
- Nc.set(Ve[We], 0);
- ea("onMouseEnter", ["mouseout", "mouseover"]);
- ea("onMouseLeave", ["mouseout", "mouseover"]);
- ea("onPointerEnter", ["pointerout", "pointerover"]);
- ea("onPointerLeave", ["pointerout", "pointerover"]);
- da("onChange", "change click focusin focusout input keydown keyup selectionchange".split(" "));
- da("onSelect", "focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));
- da("onBeforeInput", ["compositionend", "keypress", "textInput", "paste"]);
- da("onCompositionEnd", "compositionend focusout keydown keypress keyup mousedown".split(" "));
- da("onCompositionStart", "compositionstart focusout keydown keypress keyup mousedown".split(" "));
- da("onCompositionUpdate", "compositionupdate focusout keydown keypress keyup mousedown".split(" "));
- 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(" ")
- , Ye = new Set("cancel close invalid load scroll toggle".split(" ").concat(Xe));
- function Ze(a, e, i) {
- var o = a.type || "unknown-event";
- a.currentTarget = i,
- Yb(o, e, void 0, a),
- a.currentTarget = null
- }
- function se(a, e) {
- e = (e & 4) !== 0;
- for (var i = 0; i < a.length; i++) {
- var o = a[i]
- , s = o.event;
- o = o.listeners;
- e: {
- var c = void 0;
- if (e)
- for (var d = o.length - 1; 0 <= d; d--) {
- var _ = o[d]
- , b = _.instance
- , k = _.currentTarget;
- if (_ = _.listener,
- b !== c && s.isPropagationStopped())
- break e;
- Ze(s, _, k),
- c = b
- }
- else
- for (d = 0; d < o.length; d++) {
- if (_ = o[d],
- b = _.instance,
- k = _.currentTarget,
- _ = _.listener,
- b !== c && s.isPropagationStopped())
- break e;
- Ze(s, _, k),
- c = b
- }
- }
- }
- if (Ub)
- throw a = Vb,
- Ub = !1,
- Vb = null,
- a
- }
- function G(a, e) {
- var i = $e(e)
- , o = a + "__bubble";
- i.has(o) || (af(e, a, 2, !1),
- i.add(o))
- }
- var bf = "_reactListening" + Math.random().toString(36).slice(2);
- function cf(a) {
- a[bf] || (a[bf] = !0,
- ba.forEach(function(e) {
- Ye.has(e) || df(e, !1, a, null),
- df(e, !0, a, null)
- }))
- }
- function df(a, e, i, o) {
- var s = 4 < arguments.length && arguments[4] !== void 0 ? arguments[4] : 0
- , c = i;
- if (a === "selectionchange" && i.nodeType !== 9 && (c = i.ownerDocument),
- o !== null && !e && Ye.has(a)) {
- if (a !== "scroll")
- return;
- s |= 2,
- c = o
- }
- var d = $e(c)
- , _ = a + "__" + (e ? "capture" : "bubble");
- d.has(_) || (e && (s |= 4),
- af(c, a, s, e),
- d.add(_))
- }
- function af(a, e, i, o) {
- var s = Nc.get(e);
- switch (s === void 0 ? 2 : s) {
- case 0:
- s = gd;
- break;
- case 1:
- s = id;
- break;
- default:
- s = hd
- }
- i = s.bind(null, e, i, a),
- s = void 0,
- !Pb || e !== "touchstart" && e !== "touchmove" && e !== "wheel" || (s = !0),
- o ? s !== void 0 ? a.addEventListener(e, i, {
- capture: !0,
- passive: s
- }) : a.addEventListener(e, i, !0) : s !== void 0 ? a.addEventListener(e, i, {
- passive: s
- }) : a.addEventListener(e, i, !1)
- }
- function jd(a, e, i, o, s) {
- var c = o;
- if ((e & 1) === 0 && (e & 2) === 0 && o !== null)
- e: for (; ; ) {
- if (o === null)
- return;
- var d = o.tag;
- if (d === 3 || d === 4) {
- var _ = o.stateNode.containerInfo;
- if (_ === s || _.nodeType === 8 && _.parentNode === s)
- break;
- if (d === 4)
- for (d = o.return; d !== null; ) {
- var b = d.tag;
- if ((b === 3 || b === 4) && (b = d.stateNode.containerInfo,
- b === s || b.nodeType === 8 && b.parentNode === s))
- return;
- d = d.return
- }
- for (; _ !== null; ) {
- if (d = wc(_),
- d === null)
- return;
- if (b = d.tag,
- b === 5 || b === 6) {
- o = c = d;
- continue e
- }
- _ = _.parentNode
- }
- }
- o = o.return
- }
- Nb(function() {
- var k = c
- , j = xb(i)
- , $ = [];
- e: {
- var _e = Mc.get(a);
- if (_e !== void 0) {
- var et = td
- , tt = a;
- switch (a) {
- case "keypress":
- if (od(i) === 0)
- break e;
- case "keydown":
- case "keyup":
- et = Rd;
- break;
- case "focusin":
- tt = "focus",
- et = Fd;
- break;
- case "focusout":
- tt = "blur",
- et = Fd;
- break;
- case "beforeblur":
- case "afterblur":
- et = Fd;
- break;
- case "click":
- if (i.button === 2)
- break e;
- case "auxclick":
- case "dblclick":
- case "mousedown":
- case "mousemove":
- case "mouseup":
- case "mouseout":
- case "mouseover":
- case "contextmenu":
- et = Bd;
- break;
- case "drag":
- case "dragend":
- case "dragenter":
- case "dragexit":
- case "dragleave":
- case "dragover":
- case "dragstart":
- case "drop":
- et = Dd;
- break;
- case "touchcancel":
- case "touchend":
- case "touchmove":
- case "touchstart":
- et = Vd;
- break;
- case Ic:
- case Jc:
- case Kc:
- et = Hd;
- break;
- case Lc:
- et = Xd;
- break;
- case "scroll":
- et = vd;
- break;
- case "wheel":
- et = Zd;
- break;
- case "copy":
- case "cut":
- case "paste":
- et = Jd;
- break;
- case "gotpointercapture":
- case "lostpointercapture":
- case "pointercancel":
- case "pointerdown":
- case "pointermove":
- case "pointerout":
- case "pointerover":
- case "pointerup":
- et = Td
- }
- var rt = (e & 4) !== 0
- , it = !rt && a === "scroll"
- , nt = rt ? _e !== null ? _e + "Capture" : null : _e;
- rt = [];
- for (var ot = k, at; ot !== null; ) {
- at = ot;
- var st = at.stateNode;
- if (at.tag === 5 && st !== null && (at = st,
- nt !== null && (st = Ob(ot, nt),
- st != null && rt.push(ef(ot, st, at)))),
- it)
- break;
- ot = ot.return
- }
- 0 < rt.length && (_e = new et(_e,tt,null,i,j),
- $.push({
- event: _e,
- listeners: rt
- }))
- }
- }
- if ((e & 7) === 0) {
- e: {
- if (_e = a === "mouseover" || a === "pointerover",
- et = a === "mouseout" || a === "pointerout",
- _e && (e & 16) === 0 && (tt = i.relatedTarget || i.fromElement) && (wc(tt) || tt[ff]))
- break e;
- if ((et || _e) && (_e = j.window === j ? j : (_e = j.ownerDocument) ? _e.defaultView || _e.parentWindow : window,
- et ? (tt = i.relatedTarget || i.toElement,
- et = k,
- tt = tt ? wc(tt) : null,
- tt !== null && (it = Zb(tt),
- tt !== it || tt.tag !== 5 && tt.tag !== 6) && (tt = null)) : (et = null,
- tt = k),
- et !== tt)) {
- if (rt = Bd,
- st = "onMouseLeave",
- nt = "onMouseEnter",
- ot = "mouse",
- (a === "pointerout" || a === "pointerover") && (rt = Td,
- st = "onPointerLeave",
- nt = "onPointerEnter",
- ot = "pointer"),
- it = et == null ? _e : ue(et),
- at = tt == null ? _e : ue(tt),
- _e = new rt(st,ot + "leave",et,i,j),
- _e.target = it,
- _e.relatedTarget = at,
- st = null,
- wc(j) === k && (rt = new rt(nt,ot + "enter",tt,i,j),
- rt.target = at,
- rt.relatedTarget = it,
- st = rt),
- it = st,
- et && tt)
- t: {
- for (rt = et,
- nt = tt,
- ot = 0,
- at = rt; at; at = gf(at))
- ot++;
- for (at = 0,
- st = nt; st; st = gf(st))
- at++;
- for (; 0 < ot - at; )
- rt = gf(rt),
- ot--;
- for (; 0 < at - ot; )
- nt = gf(nt),
- at--;
- for (; ot--; ) {
- if (rt === nt || nt !== null && rt === nt.alternate)
- break t;
- rt = gf(rt),
- nt = gf(nt)
- }
- rt = null
- }
- else
- rt = null;
- et !== null && hf($, _e, et, rt, !1),
- tt !== null && it !== null && hf($, it, tt, rt, !0)
- }
- }
- e: {
- if (_e = k ? ue(k) : window,
- et = _e.nodeName && _e.nodeName.toLowerCase(),
- et === "select" || et === "input" && _e.type === "file")
- var ut = ve;
- else if (me(_e))
- if (we)
- ut = Fe;
- else {
- ut = De;
- var ct = Ce
- }
- else
- (et = _e.nodeName) && et.toLowerCase() === "input" && (_e.type === "checkbox" || _e.type === "radio") && (ut = Ee);
- if (ut && (ut = ut(a, k))) {
- ne($, ut, i, j);
- break e
- }
- ct && ct(a, _e, k),
- a === "focusout" && (ct = _e._wrapperState) && ct.controlled && _e.type === "number" && bb(_e, "number", _e.value)
- }
- switch (ct = k ? ue(k) : window,
- a) {
- case "focusin":
- (me(ct) || ct.contentEditable === "true") && (Qe = ct,
- Re = k,
- Se = null);
- break;
- case "focusout":
- Se = Re = Qe = null;
- break;
- case "mousedown":
- Te = !0;
- break;
- case "contextmenu":
- case "mouseup":
- case "dragend":
- Te = !1,
- Ue($, i, j);
- break;
- case "selectionchange":
- if (Pe)
- break;
- case "keydown":
- case "keyup":
- Ue($, i, j)
- }
- var lt;
- if (ae)
- e: {
- switch (a) {
- case "compositionstart":
- var ft = "onCompositionStart";
- break e;
- case "compositionend":
- ft = "onCompositionEnd";
- break e;
- case "compositionupdate":
- ft = "onCompositionUpdate";
- break e
- }
- ft = void 0
- }
- else
- ie ? ge(a, i) && (ft = "onCompositionEnd") : a === "keydown" && i.keyCode === 229 && (ft = "onCompositionStart");
- ft && (de && i.locale !== "ko" && (ie || ft !== "onCompositionStart" ? ft === "onCompositionEnd" && ie && (lt = nd()) : (kd = j,
- ld = "value"in kd ? kd.value : kd.textContent,
- ie = !0)),
- ct = oe(k, ft),
- 0 < ct.length && (ft = new Ld(ft,a,null,i,j),
- $.push({
- event: ft,
- listeners: ct
- }),
- lt ? ft.data = lt : (lt = he(i),
- lt !== null && (ft.data = lt)))),
- (lt = ce ? je(a, i) : ke(a, i)) && (k = oe(k, "onBeforeInput"),
- 0 < k.length && (j = new Ld("onBeforeInput","beforeinput",null,i,j),
- $.push({
- event: j,
- listeners: k
- }),
- j.data = lt))
- }
- se($, e)
- })
- }
- function ef(a, e, i) {
- return {
- instance: a,
- listener: e,
- currentTarget: i
- }
- }
- function oe(a, e) {
- for (var i = e + "Capture", o = []; a !== null; ) {
- var s = a
- , c = s.stateNode;
- s.tag === 5 && c !== null && (s = c,
- c = Ob(a, i),
- c != null && o.unshift(ef(a, c, s)),
- c = Ob(a, e),
- c != null && o.push(ef(a, c, s))),
- a = a.return
- }
- return o
- }
- function gf(a) {
- if (a === null)
- return null;
- do
- a = a.return;
- while (a && a.tag !== 5);
- return a || null
- }
- function hf(a, e, i, o, s) {
- for (var c = e._reactName, d = []; i !== null && i !== o; ) {
- var _ = i
- , b = _.alternate
- , k = _.stateNode;
- if (b !== null && b === o)
- break;
- _.tag === 5 && k !== null && (_ = k,
- s ? (b = Ob(i, c),
- b != null && d.unshift(ef(i, b, _))) : s || (b = Ob(i, c),
- b != null && d.push(ef(i, b, _)))),
- i = i.return
- }
- d.length !== 0 && a.push({
- event: e,
- listeners: d
- })
- }
- function jf() {}
- var kf = null
- , lf = null;
- function mf(a, e) {
- switch (a) {
- case "button":
- case "input":
- case "select":
- case "textarea":
- return !!e.autoFocus
- }
- return !1
- }
- function nf(a, e) {
- 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
- }
- var of = typeof setTimeout == "function" ? setTimeout : void 0
- , pf = typeof clearTimeout == "function" ? clearTimeout : void 0;
- function qf(a) {
- a.nodeType === 1 ? a.textContent = "" : a.nodeType === 9 && (a = a.body,
- a != null && (a.textContent = ""))
- }
- function rf(a) {
- for (; a != null; a = a.nextSibling) {
- var e = a.nodeType;
- if (e === 1 || e === 3)
- break
- }
- return a
- }
- function sf(a) {
- a = a.previousSibling;
- for (var e = 0; a; ) {
- if (a.nodeType === 8) {
- var i = a.data;
- if (i === "$" || i === "$!" || i === "$?") {
- if (e === 0)
- return a;
- e--
- } else
- i === "/$" && e++
- }
- a = a.previousSibling
- }
- return null
- }
- var tf = 0;
- function uf(a) {
- return {
- $$typeof: Ga,
- toString: a,
- valueOf: a
- }
- }
- var vf = Math.random().toString(36).slice(2)
- , wf = "__reactFiber$" + vf
- , xf = "__reactProps$" + vf
- , ff = "__reactContainer$" + vf
- , yf = "__reactEvents$" + vf;
- function wc(a) {
- var e = a[wf];
- if (e)
- return e;
- for (var i = a.parentNode; i; ) {
- if (e = i[ff] || i[wf]) {
- if (i = e.alternate,
- e.child !== null || i !== null && i.child !== null)
- for (a = sf(a); a !== null; ) {
- if (i = a[wf])
- return i;
- a = sf(a)
- }
- return e
- }
- a = i,
- i = a.parentNode
- }
- return null
- }
- function Cb(a) {
- return a = a[wf] || a[ff],
- !a || a.tag !== 5 && a.tag !== 6 && a.tag !== 13 && a.tag !== 3 ? null : a
- }
- function ue(a) {
- if (a.tag === 5 || a.tag === 6)
- return a.stateNode;
- throw Error(y(33))
- }
- function Db(a) {
- return a[xf] || null
- }
- function $e(a) {
- var e = a[yf];
- return e === void 0 && (e = a[yf] = new Set),
- e
- }
- var zf = []
- , Af = -1;
- function Bf(a) {
- return {
- current: a
- }
- }
- function H(a) {
- 0 > Af || (a.current = zf[Af],
- zf[Af] = null,
- Af--)
- }
- function I(a, e) {
- Af++,
- zf[Af] = a.current,
- a.current = e
- }
- var Cf = {}
- , M = Bf(Cf)
- , N = Bf(!1)
- , Df = Cf;
- function Ef(a, e) {
- var i = a.type.contextTypes;
- if (!i)
- return Cf;
- var o = a.stateNode;
- if (o && o.__reactInternalMemoizedUnmaskedChildContext === e)
- return o.__reactInternalMemoizedMaskedChildContext;
- var s = {}, c;
- for (c in i)
- s[c] = e[c];
- return o && (a = a.stateNode,
- a.__reactInternalMemoizedUnmaskedChildContext = e,
- a.__reactInternalMemoizedMaskedChildContext = s),
- s
- }
- function Ff(a) {
- return a = a.childContextTypes,
- a != null
- }
- function Gf() {
- H(N),
- H(M)
- }
- function Hf(a, e, i) {
- if (M.current !== Cf)
- throw Error(y(168));
- I(M, e),
- I(N, i)
- }
- function If(a, e, i) {
- var o = a.stateNode;
- if (a = e.childContextTypes,
- typeof o.getChildContext != "function")
- return i;
- o = o.getChildContext();
- for (var s in o)
- if (!(s in a))
- throw Error(y(108, Ra(e) || "Unknown", s));
- return m$1({}, i, o)
- }
- function Jf(a) {
- return a = (a = a.stateNode) && a.__reactInternalMemoizedMergedChildContext || Cf,
- Df = M.current,
- I(M, a),
- I(N, N.current),
- !0
- }
- function Kf(a, e, i) {
- var o = a.stateNode;
- if (!o)
- throw Error(y(169));
- i ? (a = If(a, e, Df),
- o.__reactInternalMemoizedMergedChildContext = a,
- H(N),
- H(M),
- I(M, a)) : H(N),
- I(N, i)
- }
- var Lf = null
- , Mf = null
- , Nf = r.unstable_runWithPriority
- , Of = r.unstable_scheduleCallback
- , Pf = r.unstable_cancelCallback
- , Qf = r.unstable_shouldYield
- , Rf = r.unstable_requestPaint
- , Sf = r.unstable_now
- , Tf = r.unstable_getCurrentPriorityLevel
- , Uf = r.unstable_ImmediatePriority
- , Vf = r.unstable_UserBlockingPriority
- , Wf = r.unstable_NormalPriority
- , Xf = r.unstable_LowPriority
- , Yf = r.unstable_IdlePriority
- , Zf = {}
- , $f = Rf !== void 0 ? Rf : function() {}
- , ag = null
- , bg = null
- , cg = !1
- , dg = Sf()
- , O = 1e4 > dg ? Sf : function() {
- return Sf() - dg
- }
- ;
- function eg() {
- switch (Tf()) {
- case Uf:
- return 99;
- case Vf:
- return 98;
- case Wf:
- return 97;
- case Xf:
- return 96;
- case Yf:
- return 95;
- default:
- throw Error(y(332))
- }
- }
- function fg(a) {
- switch (a) {
- case 99:
- return Uf;
- case 98:
- return Vf;
- case 97:
- return Wf;
- case 96:
- return Xf;
- case 95:
- return Yf;
- default:
- throw Error(y(332))
- }
- }
- function gg(a, e) {
- return a = fg(a),
- Nf(a, e)
- }
- function hg(a, e, i) {
- return a = fg(a),
- Of(a, e, i)
- }
- function ig() {
- if (bg !== null) {
- var a = bg;
- bg = null,
- Pf(a)
- }
- jg()
- }
- function jg() {
- if (!cg && ag !== null) {
- cg = !0;
- var a = 0;
- try {
- var e = ag;
- gg(99, function() {
- for (; a < e.length; a++) {
- var i = e[a];
- do
- i = i(!0);
- while (i !== null)
- }
- }),
- ag = null
- } catch (i) {
- throw ag !== null && (ag = ag.slice(a + 1)),
- Of(Uf, ig),
- i
- } finally {
- cg = !1
- }
- }
- }
- var kg = ra.ReactCurrentBatchConfig;
- function lg(a, e) {
- if (a && a.defaultProps) {
- e = m$1({}, e),
- a = a.defaultProps;
- for (var i in a)
- e[i] === void 0 && (e[i] = a[i]);
- return e
- }
- return e
- }
- var mg = Bf(null)
- , ng = null
- , og = null
- , pg = null;
- function qg() {
- pg = og = ng = null
- }
- function rg(a) {
- var e = mg.current;
- H(mg),
- a.type._context._currentValue = e
- }
- function sg(a, e) {
- for (; a !== null; ) {
- var i = a.alternate;
- if ((a.childLanes & e) === e) {
- if (i === null || (i.childLanes & e) === e)
- break;
- i.childLanes |= e
- } else
- a.childLanes |= e,
- i !== null && (i.childLanes |= e);
- a = a.return
- }
- }
- function tg(a, e) {
- ng = a,
- pg = og = null,
- a = a.dependencies,
- a !== null && a.firstContext !== null && ((a.lanes & e) !== 0 && (ug = !0),
- a.firstContext = null)
- }
- function vg(a, e) {
- if (pg !== a && e !== !1 && e !== 0)
- if ((typeof e != "number" || e === 1073741823) && (pg = a,
- e = 1073741823),
- e = {
- context: a,
- observedBits: e,
- next: null
- },
- og === null) {
- if (ng === null)
- throw Error(y(308));
- og = e,
- ng.dependencies = {
- lanes: 0,
- firstContext: e,
- responders: null
- }
- } else
- og = og.next = e;
- return a._currentValue
- }
- var wg = !1;
- function xg(a) {
- a.updateQueue = {
- baseState: a.memoizedState,
- firstBaseUpdate: null,
- lastBaseUpdate: null,
- shared: {
- pending: null
- },
- effects: null
- }
- }
- function yg(a, e) {
- a = a.updateQueue,
- e.updateQueue === a && (e.updateQueue = {
- baseState: a.baseState,
- firstBaseUpdate: a.firstBaseUpdate,
- lastBaseUpdate: a.lastBaseUpdate,
- shared: a.shared,
- effects: a.effects
- })
- }
- function zg(a, e) {
- return {
- eventTime: a,
- lane: e,
- tag: 0,
- payload: null,
- callback: null,
- next: null
- }
- }
- function Ag(a, e) {
- if (a = a.updateQueue,
- a !== null) {
- a = a.shared;
- var i = a.pending;
- i === null ? e.next = e : (e.next = i.next,
- i.next = e),
- a.pending = e
- }
- }
- function Bg(a, e) {
- var i = a.updateQueue
- , o = a.alternate;
- if (o !== null && (o = o.updateQueue,
- i === o)) {
- var s = null
- , c = null;
- if (i = i.firstBaseUpdate,
- i !== null) {
- do {
- var d = {
- eventTime: i.eventTime,
- lane: i.lane,
- tag: i.tag,
- payload: i.payload,
- callback: i.callback,
- next: null
- };
- c === null ? s = c = d : c = c.next = d,
- i = i.next
- } while (i !== null);
- c === null ? s = c = e : c = c.next = e
- } else
- s = c = e;
- i = {
- baseState: o.baseState,
- firstBaseUpdate: s,
- lastBaseUpdate: c,
- shared: o.shared,
- effects: o.effects
- },
- a.updateQueue = i;
- return
- }
- a = i.lastBaseUpdate,
- a === null ? i.firstBaseUpdate = e : a.next = e,
- i.lastBaseUpdate = e
- }
- function Cg(a, e, i, o) {
- var s = a.updateQueue;
- wg = !1;
- var c = s.firstBaseUpdate
- , d = s.lastBaseUpdate
- , _ = s.shared.pending;
- if (_ !== null) {
- s.shared.pending = null;
- var b = _
- , k = b.next;
- b.next = null,
- d === null ? c = k : d.next = k,
- d = b;
- var j = a.alternate;
- if (j !== null) {
- j = j.updateQueue;
- var $ = j.lastBaseUpdate;
- $ !== d && ($ === null ? j.firstBaseUpdate = k : $.next = k,
- j.lastBaseUpdate = b)
- }
- }
- if (c !== null) {
- $ = s.baseState,
- d = 0,
- j = k = b = null;
- do {
- _ = c.lane;
- var _e = c.eventTime;
- if ((o & _) === _) {
- j !== null && (j = j.next = {
- eventTime: _e,
- lane: 0,
- tag: c.tag,
- payload: c.payload,
- callback: c.callback,
- next: null
- });
- e: {
- var et = a
- , tt = c;
- switch (_ = e,
- _e = i,
- tt.tag) {
- case 1:
- if (et = tt.payload,
- typeof et == "function") {
- $ = et.call(_e, $, _);
- break e
- }
- $ = et;
- break e;
- case 3:
- et.flags = et.flags & -4097 | 64;
- case 0:
- if (et = tt.payload,
- _ = typeof et == "function" ? et.call(_e, $, _) : et,
- _ == null)
- break e;
- $ = m$1({}, $, _);
- break e;
- case 2:
- wg = !0
- }
- }
- c.callback !== null && (a.flags |= 32,
- _ = s.effects,
- _ === null ? s.effects = [c] : _.push(c))
- } else
- _e = {
- eventTime: _e,
- lane: _,
- tag: c.tag,
- payload: c.payload,
- callback: c.callback,
- next: null
- },
- j === null ? (k = j = _e,
- b = $) : j = j.next = _e,
- d |= _;
- if (c = c.next,
- c === null) {
- if (_ = s.shared.pending,
- _ === null)
- break;
- c = _.next,
- _.next = null,
- s.lastBaseUpdate = _,
- s.shared.pending = null
- }
- } while (1);
- j === null && (b = $),
- s.baseState = b,
- s.firstBaseUpdate = k,
- s.lastBaseUpdate = j,
- Dg |= d,
- a.lanes = d,
- a.memoizedState = $
- }
- }
- function Eg(a, e, i) {
- if (a = e.effects,
- e.effects = null,
- a !== null)
- for (e = 0; e < a.length; e++) {
- var o = a[e]
- , s = o.callback;
- if (s !== null) {
- if (o.callback = null,
- o = i,
- typeof s != "function")
- throw Error(y(191, s));
- s.call(o)
- }
- }
- }
- var Fg = new aa.Component().refs;
- function Gg(a, e, i, o) {
- e = a.memoizedState,
- i = i(o, e),
- i = i == null ? e : m$1({}, e, i),
- a.memoizedState = i,
- a.lanes === 0 && (a.updateQueue.baseState = i)
- }
- var Kg = {
- isMounted: function(a) {
- return (a = a._reactInternals) ? Zb(a) === a : !1
- },
- enqueueSetState: function(a, e, i) {
- a = a._reactInternals;
- var o = Hg()
- , s = Ig(a)
- , c = zg(o, s);
- c.payload = e,
- i != null && (c.callback = i),
- Ag(a, c),
- Jg(a, s, o)
- },
- enqueueReplaceState: function(a, e, i) {
- a = a._reactInternals;
- var o = Hg()
- , s = Ig(a)
- , c = zg(o, s);
- c.tag = 1,
- c.payload = e,
- i != null && (c.callback = i),
- Ag(a, c),
- Jg(a, s, o)
- },
- enqueueForceUpdate: function(a, e) {
- a = a._reactInternals;
- var i = Hg()
- , o = Ig(a)
- , s = zg(i, o);
- s.tag = 2,
- e != null && (s.callback = e),
- Ag(a, s),
- Jg(a, o, i)
- }
- };
- function Lg(a, e, i, o, s, c, d) {
- return a = a.stateNode,
- typeof a.shouldComponentUpdate == "function" ? a.shouldComponentUpdate(o, c, d) : e.prototype && e.prototype.isPureReactComponent ? !Je(i, o) || !Je(s, c) : !0
- }
- function Mg(a, e, i) {
- var o = !1
- , s = Cf
- , c = e.contextType;
- return typeof c == "object" && c !== null ? c = vg(c) : (s = Ff(e) ? Df : M.current,
- o = e.contextTypes,
- c = (o = o != null) ? Ef(a, s) : Cf),
- e = new e(i,c),
- a.memoizedState = e.state !== null && e.state !== void 0 ? e.state : null,
- e.updater = Kg,
- a.stateNode = e,
- e._reactInternals = a,
- o && (a = a.stateNode,
- a.__reactInternalMemoizedUnmaskedChildContext = s,
- a.__reactInternalMemoizedMaskedChildContext = c),
- e
- }
- function Ng(a, e, i, o) {
- a = e.state,
- typeof e.componentWillReceiveProps == "function" && e.componentWillReceiveProps(i, o),
- typeof e.UNSAFE_componentWillReceiveProps == "function" && e.UNSAFE_componentWillReceiveProps(i, o),
- e.state !== a && Kg.enqueueReplaceState(e, e.state, null)
- }
- function Og(a, e, i, o) {
- var s = a.stateNode;
- s.props = i,
- s.state = a.memoizedState,
- s.refs = Fg,
- xg(a);
- var c = e.contextType;
- typeof c == "object" && c !== null ? s.context = vg(c) : (c = Ff(e) ? Df : M.current,
- s.context = Ef(a, c)),
- Cg(a, i, s, o),
- s.state = a.memoizedState,
- c = e.getDerivedStateFromProps,
- typeof c == "function" && (Gg(a, e, c, i),
- s.state = a.memoizedState),
- typeof e.getDerivedStateFromProps == "function" || typeof s.getSnapshotBeforeUpdate == "function" || typeof s.UNSAFE_componentWillMount != "function" && typeof s.componentWillMount != "function" || (e = s.state,
- typeof s.componentWillMount == "function" && s.componentWillMount(),
- typeof s.UNSAFE_componentWillMount == "function" && s.UNSAFE_componentWillMount(),
- e !== s.state && Kg.enqueueReplaceState(s, s.state, null),
- Cg(a, i, s, o),
- s.state = a.memoizedState),
- typeof s.componentDidMount == "function" && (a.flags |= 4)
- }
- var Pg = Array.isArray;
- function Qg(a, e, i) {
- if (a = i.ref,
- a !== null && typeof a != "function" && typeof a != "object") {
- if (i._owner) {
- if (i = i._owner,
- i) {
- if (i.tag !== 1)
- throw Error(y(309));
- var o = i.stateNode
- }
- if (!o)
- throw Error(y(147, a));
- var s = "" + a;
- return e !== null && e.ref !== null && typeof e.ref == "function" && e.ref._stringRef === s ? e.ref : (e = function(c) {
- var d = o.refs;
- d === Fg && (d = o.refs = {}),
- c === null ? delete d[s] : d[s] = c
- }
- ,
- e._stringRef = s,
- e)
- }
- if (typeof a != "string")
- throw Error(y(284));
- if (!i._owner)
- throw Error(y(290, a))
- }
- return a
- }
- function Rg(a, e) {
- if (a.type !== "textarea")
- throw Error(y(31, Object.prototype.toString.call(e) === "[object Object]" ? "object with keys {" + Object.keys(e).join(", ") + "}" : e))
- }
- function Sg(a) {
- function e(it, nt) {
- if (a) {
- var ot = it.lastEffect;
- ot !== null ? (ot.nextEffect = nt,
- it.lastEffect = nt) : it.firstEffect = it.lastEffect = nt,
- nt.nextEffect = null,
- nt.flags = 8
- }
- }
- function i(it, nt) {
- if (!a)
- return null;
- for (; nt !== null; )
- e(it, nt),
- nt = nt.sibling;
- return null
- }
- function o(it, nt) {
- for (it = new Map; nt !== null; )
- nt.key !== null ? it.set(nt.key, nt) : it.set(nt.index, nt),
- nt = nt.sibling;
- return it
- }
- function s(it, nt) {
- return it = Tg(it, nt),
- it.index = 0,
- it.sibling = null,
- it
- }
- function c(it, nt, ot) {
- return it.index = ot,
- a ? (ot = it.alternate,
- ot !== null ? (ot = ot.index,
- ot < nt ? (it.flags = 2,
- nt) : ot) : (it.flags = 2,
- nt)) : nt
- }
- function d(it) {
- return a && it.alternate === null && (it.flags = 2),
- it
- }
- function _(it, nt, ot, at) {
- return nt === null || nt.tag !== 6 ? (nt = Ug(ot, it.mode, at),
- nt.return = it,
- nt) : (nt = s(nt, ot),
- nt.return = it,
- nt)
- }
- function b(it, nt, ot, at) {
- return nt !== null && nt.elementType === ot.type ? (at = s(nt, ot.props),
- at.ref = Qg(it, nt, ot),
- at.return = it,
- at) : (at = Vg(ot.type, ot.key, ot.props, null, it.mode, at),
- at.ref = Qg(it, nt, ot),
- at.return = it,
- at)
- }
- function k(it, nt, ot, at) {
- return nt === null || nt.tag !== 4 || nt.stateNode.containerInfo !== ot.containerInfo || nt.stateNode.implementation !== ot.implementation ? (nt = Wg(ot, it.mode, at),
- nt.return = it,
- nt) : (nt = s(nt, ot.children || []),
- nt.return = it,
- nt)
- }
- function j(it, nt, ot, at, st) {
- return nt === null || nt.tag !== 7 ? (nt = Xg(ot, it.mode, at, st),
- nt.return = it,
- nt) : (nt = s(nt, ot),
- nt.return = it,
- nt)
- }
- function $(it, nt, ot) {
- if (typeof nt == "string" || typeof nt == "number")
- return nt = Ug("" + nt, it.mode, ot),
- nt.return = it,
- nt;
- if (typeof nt == "object" && nt !== null) {
- switch (nt.$$typeof) {
- case sa:
- return ot = Vg(nt.type, nt.key, nt.props, null, it.mode, ot),
- ot.ref = Qg(it, null, nt),
- ot.return = it,
- ot;
- case ta:
- return nt = Wg(nt, it.mode, ot),
- nt.return = it,
- nt
- }
- if (Pg(nt) || La(nt))
- return nt = Xg(nt, it.mode, ot, null),
- nt.return = it,
- nt;
- Rg(it, nt)
- }
- return null
- }
- function _e(it, nt, ot, at) {
- var st = nt !== null ? nt.key : null;
- if (typeof ot == "string" || typeof ot == "number")
- return st !== null ? null : _(it, nt, "" + ot, at);
- if (typeof ot == "object" && ot !== null) {
- switch (ot.$$typeof) {
- case sa:
- return ot.key === st ? ot.type === ua ? j(it, nt, ot.props.children, at, st) : b(it, nt, ot, at) : null;
- case ta:
- return ot.key === st ? k(it, nt, ot, at) : null
- }
- if (Pg(ot) || La(ot))
- return st !== null ? null : j(it, nt, ot, at, null);
- Rg(it, ot)
- }
- return null
- }
- function et(it, nt, ot, at, st) {
- if (typeof at == "string" || typeof at == "number")
- return it = it.get(ot) || null,
- _(nt, it, "" + at, st);
- if (typeof at == "object" && at !== null) {
- switch (at.$$typeof) {
- case sa:
- return it = it.get(at.key === null ? ot : at.key) || null,
- at.type === ua ? j(nt, it, at.props.children, st, at.key) : b(nt, it, at, st);
- case ta:
- return it = it.get(at.key === null ? ot : at.key) || null,
- k(nt, it, at, st)
- }
- if (Pg(at) || La(at))
- return it = it.get(ot) || null,
- j(nt, it, at, st, null);
- Rg(nt, at)
- }
- return null
- }
- function tt(it, nt, ot, at) {
- for (var st = null, ut = null, ct = nt, lt = nt = 0, ft = null; ct !== null && lt < ot.length; lt++) {
- ct.index > lt ? (ft = ct,
- ct = null) : ft = ct.sibling;
- var ht = _e(it, ct, ot[lt], at);
- if (ht === null) {
- ct === null && (ct = ft);
- break
- }
- a && ct && ht.alternate === null && e(it, ct),
- nt = c(ht, nt, lt),
- ut === null ? st = ht : ut.sibling = ht,
- ut = ht,
- ct = ft
- }
- if (lt === ot.length)
- return i(it, ct),
- st;
- if (ct === null) {
- for (; lt < ot.length; lt++)
- ct = $(it, ot[lt], at),
- ct !== null && (nt = c(ct, nt, lt),
- ut === null ? st = ct : ut.sibling = ct,
- ut = ct);
- return st
- }
- for (ct = o(it, ct); lt < ot.length; lt++)
- ft = et(ct, it, lt, ot[lt], at),
- ft !== null && (a && ft.alternate !== null && ct.delete(ft.key === null ? lt : ft.key),
- nt = c(ft, nt, lt),
- ut === null ? st = ft : ut.sibling = ft,
- ut = ft);
- return a && ct.forEach(function(pt) {
- return e(it, pt)
- }),
- st
- }
- function rt(it, nt, ot, at) {
- var st = La(ot);
- if (typeof st != "function")
- throw Error(y(150));
- if (ot = st.call(ot),
- ot == null)
- throw Error(y(151));
- for (var ut = st = null, ct = nt, lt = nt = 0, ft = null, ht = ot.next(); ct !== null && !ht.done; lt++,
- ht = ot.next()) {
- ct.index > lt ? (ft = ct,
- ct = null) : ft = ct.sibling;
- var pt = _e(it, ct, ht.value, at);
- if (pt === null) {
- ct === null && (ct = ft);
- break
- }
- a && ct && pt.alternate === null && e(it, ct),
- nt = c(pt, nt, lt),
- ut === null ? st = pt : ut.sibling = pt,
- ut = pt,
- ct = ft
- }
- if (ht.done)
- return i(it, ct),
- st;
- if (ct === null) {
- for (; !ht.done; lt++,
- ht = ot.next())
- ht = $(it, ht.value, at),
- ht !== null && (nt = c(ht, nt, lt),
- ut === null ? st = ht : ut.sibling = ht,
- ut = ht);
- return st
- }
- for (ct = o(it, ct); !ht.done; lt++,
- ht = ot.next())
- ht = et(ct, it, lt, ht.value, at),
- ht !== null && (a && ht.alternate !== null && ct.delete(ht.key === null ? lt : ht.key),
- nt = c(ht, nt, lt),
- ut === null ? st = ht : ut.sibling = ht,
- ut = ht);
- return a && ct.forEach(function(dt) {
- return e(it, dt)
- }),
- st
- }
- return function(it, nt, ot, at) {
- var st = typeof ot == "object" && ot !== null && ot.type === ua && ot.key === null;
- st && (ot = ot.props.children);
- var ut = typeof ot == "object" && ot !== null;
- if (ut)
- switch (ot.$$typeof) {
- case sa:
- e: {
- for (ut = ot.key,
- st = nt; st !== null; ) {
- if (st.key === ut) {
- switch (st.tag) {
- case 7:
- if (ot.type === ua) {
- i(it, st.sibling),
- nt = s(st, ot.props.children),
- nt.return = it,
- it = nt;
- break e
- }
- break;
- default:
- if (st.elementType === ot.type) {
- i(it, st.sibling),
- nt = s(st, ot.props),
- nt.ref = Qg(it, st, ot),
- nt.return = it,
- it = nt;
- break e
- }
- }
- i(it, st);
- break
- } else
- e(it, st);
- st = st.sibling
- }
- ot.type === ua ? (nt = Xg(ot.props.children, it.mode, at, ot.key),
- nt.return = it,
- it = nt) : (at = Vg(ot.type, ot.key, ot.props, null, it.mode, at),
- at.ref = Qg(it, nt, ot),
- at.return = it,
- it = at)
- }
- return d(it);
- case ta:
- e: {
- for (st = ot.key; nt !== null; ) {
- if (nt.key === st)
- if (nt.tag === 4 && nt.stateNode.containerInfo === ot.containerInfo && nt.stateNode.implementation === ot.implementation) {
- i(it, nt.sibling),
- nt = s(nt, ot.children || []),
- nt.return = it,
- it = nt;
- break e
- } else {
- i(it, nt);
- break
- }
- else
- e(it, nt);
- nt = nt.sibling
- }
- nt = Wg(ot, it.mode, at),
- nt.return = it,
- it = nt
- }
- return d(it)
- }
- if (typeof ot == "string" || typeof ot == "number")
- return ot = "" + ot,
- nt !== null && nt.tag === 6 ? (i(it, nt.sibling),
- nt = s(nt, ot),
- nt.return = it,
- it = nt) : (i(it, nt),
- nt = Ug(ot, it.mode, at),
- nt.return = it,
- it = nt),
- d(it);
- if (Pg(ot))
- return tt(it, nt, ot, at);
- if (La(ot))
- return rt(it, nt, ot, at);
- if (ut && Rg(it, ot),
- typeof ot == "undefined" && !st)
- switch (it.tag) {
- case 1:
- case 22:
- case 0:
- case 11:
- case 15:
- throw Error(y(152, Ra(it.type) || "Component"))
- }
- return i(it, nt)
- }
- }
- var Yg = Sg(!0)
- , Zg = Sg(!1)
- , $g = {}
- , ah = Bf($g)
- , bh = Bf($g)
- , ch = Bf($g);
- function dh(a) {
- if (a === $g)
- throw Error(y(174));
- return a
- }
- function eh(a, e) {
- switch (I(ch, e),
- I(bh, a),
- I(ah, $g),
- a = e.nodeType,
- a) {
- case 9:
- case 11:
- e = (e = e.documentElement) ? e.namespaceURI : mb(null, "");
- break;
- default:
- a = a === 8 ? e.parentNode : e,
- e = a.namespaceURI || null,
- a = a.tagName,
- e = mb(e, a)
- }
- H(ah),
- I(ah, e)
- }
- function fh() {
- H(ah),
- H(bh),
- H(ch)
- }
- function gh(a) {
- dh(ch.current);
- var e = dh(ah.current)
- , i = mb(e, a.type);
- e !== i && (I(bh, a),
- I(ah, i))
- }
- function hh(a) {
- bh.current === a && (H(ah),
- H(bh))
- }
- var P = Bf(0);
- function ih(a) {
- for (var e = a; e !== null; ) {
- if (e.tag === 13) {
- var i = e.memoizedState;
- if (i !== null && (i = i.dehydrated,
- i === null || i.data === "$?" || i.data === "$!"))
- return e
- } else if (e.tag === 19 && e.memoizedProps.revealOrder !== void 0) {
- if ((e.flags & 64) !== 0)
- return e
- } else if (e.child !== null) {
- e.child.return = e,
- e = e.child;
- continue
- }
- if (e === a)
- break;
- for (; e.sibling === null; ) {
- if (e.return === null || e.return === a)
- return null;
- e = e.return
- }
- e.sibling.return = e.return,
- e = e.sibling
- }
- return null
- }
- var jh = null
- , kh = null
- , lh = !1;
- function mh(a, e) {
- var i = nh(5, null, null, 0);
- i.elementType = "DELETED",
- i.type = "DELETED",
- i.stateNode = e,
- i.return = a,
- i.flags = 8,
- a.lastEffect !== null ? (a.lastEffect.nextEffect = i,
- a.lastEffect = i) : a.firstEffect = a.lastEffect = i
- }
- function oh(a, e) {
- switch (a.tag) {
- case 5:
- var i = a.type;
- return e = e.nodeType !== 1 || i.toLowerCase() !== e.nodeName.toLowerCase() ? null : e,
- e !== null ? (a.stateNode = e,
- !0) : !1;
- case 6:
- return e = a.pendingProps === "" || e.nodeType !== 3 ? null : e,
- e !== null ? (a.stateNode = e,
- !0) : !1;
- case 13:
- return !1;
- default:
- return !1
- }
- }
- function ph(a) {
- if (lh) {
- var e = kh;
- if (e) {
- var i = e;
- if (!oh(a, e)) {
- if (e = rf(i.nextSibling),
- !e || !oh(a, e)) {
- a.flags = a.flags & -1025 | 2,
- lh = !1,
- jh = a;
- return
- }
- mh(jh, i)
- }
- jh = a,
- kh = rf(e.firstChild)
- } else
- a.flags = a.flags & -1025 | 2,
- lh = !1,
- jh = a
- }
- }
- function qh(a) {
- for (a = a.return; a !== null && a.tag !== 5 && a.tag !== 3 && a.tag !== 13; )
- a = a.return;
- jh = a
- }
- function rh(a) {
- if (a !== jh)
- return !1;
- if (!lh)
- return qh(a),
- lh = !0,
- !1;
- var e = a.type;
- if (a.tag !== 5 || e !== "head" && e !== "body" && !nf(e, a.memoizedProps))
- for (e = kh; e; )
- mh(a, e),
- e = rf(e.nextSibling);
- if (qh(a),
- a.tag === 13) {
- if (a = a.memoizedState,
- a = a !== null ? a.dehydrated : null,
- !a)
- throw Error(y(317));
- e: {
- for (a = a.nextSibling,
- e = 0; a; ) {
- if (a.nodeType === 8) {
- var i = a.data;
- if (i === "/$") {
- if (e === 0) {
- kh = rf(a.nextSibling);
- break e
- }
- e--
- } else
- i !== "$" && i !== "$!" && i !== "$?" || e++
- }
- a = a.nextSibling
- }
- kh = null
- }
- } else
- kh = jh ? rf(a.stateNode.nextSibling) : null;
- return !0
- }
- function sh() {
- kh = jh = null,
- lh = !1
- }
- var th = [];
- function uh() {
- for (var a = 0; a < th.length; a++)
- th[a]._workInProgressVersionPrimary = null;
- th.length = 0
- }
- var vh = ra.ReactCurrentDispatcher
- , wh = ra.ReactCurrentBatchConfig
- , xh = 0
- , R = null
- , S = null
- , T = null
- , yh = !1
- , zh = !1;
- function Ah() {
- throw Error(y(321))
- }
- function Bh(a, e) {
- if (e === null)
- return !1;
- for (var i = 0; i < e.length && i < a.length; i++)
- if (!He(a[i], e[i]))
- return !1;
- return !0
- }
- function Ch(a, e, i, o, s, c) {
- if (xh = c,
- R = e,
- e.memoizedState = null,
- e.updateQueue = null,
- e.lanes = 0,
- vh.current = a === null || a.memoizedState === null ? Dh : Eh,
- a = i(o, s),
- zh) {
- c = 0;
- do {
- if (zh = !1,
- !(25 > c))
- throw Error(y(301));
- c += 1,
- T = S = null,
- e.updateQueue = null,
- vh.current = Fh,
- a = i(o, s)
- } while (zh)
- }
- if (vh.current = Gh,
- e = S !== null && S.next !== null,
- xh = 0,
- T = S = R = null,
- yh = !1,
- e)
- throw Error(y(300));
- return a
- }
- function Hh() {
- var a = {
- memoizedState: null,
- baseState: null,
- baseQueue: null,
- queue: null,
- next: null
- };
- return T === null ? R.memoizedState = T = a : T = T.next = a,
- T
- }
- function Ih() {
- if (S === null) {
- var a = R.alternate;
- a = a !== null ? a.memoizedState : null
- } else
- a = S.next;
- var e = T === null ? R.memoizedState : T.next;
- if (e !== null)
- T = e,
- S = a;
- else {
- if (a === null)
- throw Error(y(310));
- S = a,
- a = {
- memoizedState: S.memoizedState,
- baseState: S.baseState,
- baseQueue: S.baseQueue,
- queue: S.queue,
- next: null
- },
- T === null ? R.memoizedState = T = a : T = T.next = a
- }
- return T
- }
- function Jh(a, e) {
- return typeof e == "function" ? e(a) : e
- }
- function Kh(a) {
- var e = Ih()
- , i = e.queue;
- if (i === null)
- throw Error(y(311));
- i.lastRenderedReducer = a;
- var o = S
- , s = o.baseQueue
- , c = i.pending;
- if (c !== null) {
- if (s !== null) {
- var d = s.next;
- s.next = c.next,
- c.next = d
- }
- o.baseQueue = s = c,
- i.pending = null
- }
- if (s !== null) {
- s = s.next,
- o = o.baseState;
- var _ = d = c = null
- , b = s;
- do {
- var k = b.lane;
- if ((xh & k) === k)
- _ !== null && (_ = _.next = {
- lane: 0,
- action: b.action,
- eagerReducer: b.eagerReducer,
- eagerState: b.eagerState,
- next: null
- }),
- o = b.eagerReducer === a ? b.eagerState : a(o, b.action);
- else {
- var j = {
- lane: k,
- action: b.action,
- eagerReducer: b.eagerReducer,
- eagerState: b.eagerState,
- next: null
- };
- _ === null ? (d = _ = j,
- c = o) : _ = _.next = j,
- R.lanes |= k,
- Dg |= k
- }
- b = b.next
- } while (b !== null && b !== s);
- _ === null ? c = o : _.next = d,
- He(o, e.memoizedState) || (ug = !0),
- e.memoizedState = o,
- e.baseState = c,
- e.baseQueue = _,
- i.lastRenderedState = o
- }
- return [e.memoizedState, i.dispatch]
- }
- function Lh(a) {
- var e = Ih()
- , i = e.queue;
- if (i === null)
- throw Error(y(311));
- i.lastRenderedReducer = a;
- var o = i.dispatch
- , s = i.pending
- , c = e.memoizedState;
- if (s !== null) {
- i.pending = null;
- var d = s = s.next;
- do
- c = a(c, d.action),
- d = d.next;
- while (d !== s);
- He(c, e.memoizedState) || (ug = !0),
- e.memoizedState = c,
- e.baseQueue === null && (e.baseState = c),
- i.lastRenderedState = c
- }
- return [c, o]
- }
- function Mh(a, e, i) {
- var o = e._getVersion;
- o = o(e._source);
- var s = e._workInProgressVersionPrimary;
- if (s !== null ? a = s === o : (a = a.mutableReadLanes,
- (a = (xh & a) === a) && (e._workInProgressVersionPrimary = o,
- th.push(e))),
- a)
- return i(e._source);
- throw th.push(e),
- Error(y(350))
- }
- function Nh(a, e, i, o) {
- var s = U;
- if (s === null)
- throw Error(y(349));
- var c = e._getVersion
- , d = c(e._source)
- , _ = vh.current
- , b = _.useState(function() {
- return Mh(s, e, i)
- })
- , k = b[1]
- , j = b[0];
- b = T;
- var $ = a.memoizedState
- , _e = $.refs
- , et = _e.getSnapshot
- , tt = $.source;
- $ = $.subscribe;
- var rt = R;
- return a.memoizedState = {
- refs: _e,
- source: e,
- subscribe: o
- },
- _.useEffect(function() {
- _e.getSnapshot = i,
- _e.setSnapshot = k;
- var it = c(e._source);
- if (!He(d, it)) {
- it = i(e._source),
- He(j, it) || (k(it),
- it = Ig(rt),
- s.mutableReadLanes |= it & s.pendingLanes),
- it = s.mutableReadLanes,
- s.entangledLanes |= it;
- for (var nt = s.entanglements, ot = it; 0 < ot; ) {
- var at = 31 - Vc(ot)
- , st = 1 << at;
- nt[at] |= it,
- ot &= ~st
- }
- }
- }, [i, e, o]),
- _.useEffect(function() {
- return o(e._source, function() {
- var it = _e.getSnapshot
- , nt = _e.setSnapshot;
- try {
- nt(it(e._source));
- var ot = Ig(rt);
- s.mutableReadLanes |= ot & s.pendingLanes
- } catch (at) {
- nt(function() {
- throw at
- })
- }
- })
- }, [e, o]),
- He(et, i) && He(tt, e) && He($, o) || (a = {
- pending: null,
- dispatch: null,
- lastRenderedReducer: Jh,
- lastRenderedState: j
- },
- a.dispatch = k = Oh.bind(null, R, a),
- b.queue = a,
- b.baseQueue = null,
- j = Mh(s, e, i),
- b.memoizedState = b.baseState = j),
- j
- }
- function Ph(a, e, i) {
- var o = Ih();
- return Nh(o, a, e, i)
- }
- function Qh(a) {
- var e = Hh();
- return typeof a == "function" && (a = a()),
- e.memoizedState = e.baseState = a,
- a = e.queue = {
- pending: null,
- dispatch: null,
- lastRenderedReducer: Jh,
- lastRenderedState: a
- },
- a = a.dispatch = Oh.bind(null, R, a),
- [e.memoizedState, a]
- }
- function Rh(a, e, i, o) {
- return a = {
- tag: a,
- create: e,
- destroy: i,
- deps: o,
- next: null
- },
- e = R.updateQueue,
- e === null ? (e = {
- lastEffect: null
- },
- R.updateQueue = e,
- e.lastEffect = a.next = a) : (i = e.lastEffect,
- i === null ? e.lastEffect = a.next = a : (o = i.next,
- i.next = a,
- a.next = o,
- e.lastEffect = a)),
- a
- }
- function Sh(a) {
- var e = Hh();
- return a = {
- current: a
- },
- e.memoizedState = a
- }
- function Th() {
- return Ih().memoizedState
- }
- function Uh(a, e, i, o) {
- var s = Hh();
- R.flags |= a,
- s.memoizedState = Rh(1 | e, i, void 0, o === void 0 ? null : o)
- }
- function Vh(a, e, i, o) {
- var s = Ih();
- o = o === void 0 ? null : o;
- var c = void 0;
- if (S !== null) {
- var d = S.memoizedState;
- if (c = d.destroy,
- o !== null && Bh(o, d.deps)) {
- Rh(e, i, c, o);
- return
- }
- }
- R.flags |= a,
- s.memoizedState = Rh(1 | e, i, c, o)
- }
- function Wh(a, e) {
- return Uh(516, 4, a, e)
- }
- function Xh(a, e) {
- return Vh(516, 4, a, e)
- }
- function Yh(a, e) {
- return Vh(4, 2, a, e)
- }
- function Zh(a, e) {
- if (typeof e == "function")
- return a = a(),
- e(a),
- function() {
- e(null)
- }
- ;
- if (e != null)
- return a = a(),
- e.current = a,
- function() {
- e.current = null
- }
- }
- function $h(a, e, i) {
- return i = i != null ? i.concat([a]) : null,
- Vh(4, 2, Zh.bind(null, e, a), i)
- }
- function ai() {}
- function bi(a, e) {
- var i = Ih();
- e = e === void 0 ? null : e;
- var o = i.memoizedState;
- return o !== null && e !== null && Bh(e, o[1]) ? o[0] : (i.memoizedState = [a, e],
- a)
- }
- function ci(a, e) {
- var i = Ih();
- e = e === void 0 ? null : e;
- var o = i.memoizedState;
- return o !== null && e !== null && Bh(e, o[1]) ? o[0] : (a = a(),
- i.memoizedState = [a, e],
- a)
- }
- function di(a, e) {
- var i = eg();
- gg(98 > i ? 98 : i, function() {
- a(!0)
- }),
- gg(97 < i ? 97 : i, function() {
- var o = wh.transition;
- wh.transition = 1;
- try {
- a(!1),
- e()
- } finally {
- wh.transition = o
- }
- })
- }
- function Oh(a, e, i) {
- var o = Hg()
- , s = Ig(a)
- , c = {
- lane: s,
- action: i,
- eagerReducer: null,
- eagerState: null,
- next: null
- }
- , d = e.pending;
- if (d === null ? c.next = c : (c.next = d.next,
- d.next = c),
- e.pending = c,
- d = a.alternate,
- a === R || d !== null && d === R)
- zh = yh = !0;
- else {
- if (a.lanes === 0 && (d === null || d.lanes === 0) && (d = e.lastRenderedReducer,
- d !== null))
- try {
- var _ = e.lastRenderedState
- , b = d(_, i);
- if (c.eagerReducer = d,
- c.eagerState = b,
- He(b, _))
- return
- } catch {} finally {}
- Jg(a, s, o)
- }
- }
- var Gh = {
- readContext: vg,
- useCallback: Ah,
- useContext: Ah,
- useEffect: Ah,
- useImperativeHandle: Ah,
- useLayoutEffect: Ah,
- useMemo: Ah,
- useReducer: Ah,
- useRef: Ah,
- useState: Ah,
- useDebugValue: Ah,
- useDeferredValue: Ah,
- useTransition: Ah,
- useMutableSource: Ah,
- useOpaqueIdentifier: Ah,
- unstable_isNewReconciler: !1
- }
- , Dh = {
- readContext: vg,
- useCallback: function(a, e) {
- return Hh().memoizedState = [a, e === void 0 ? null : e],
- a
- },
- useContext: vg,
- useEffect: Wh,
- useImperativeHandle: function(a, e, i) {
- return i = i != null ? i.concat([a]) : null,
- Uh(4, 2, Zh.bind(null, e, a), i)
- },
- useLayoutEffect: function(a, e) {
- return Uh(4, 2, a, e)
- },
- useMemo: function(a, e) {
- var i = Hh();
- return e = e === void 0 ? null : e,
- a = a(),
- i.memoizedState = [a, e],
- a
- },
- useReducer: function(a, e, i) {
- var o = Hh();
- return e = i !== void 0 ? i(e) : e,
- o.memoizedState = o.baseState = e,
- a = o.queue = {
- pending: null,
- dispatch: null,
- lastRenderedReducer: a,
- lastRenderedState: e
- },
- a = a.dispatch = Oh.bind(null, R, a),
- [o.memoizedState, a]
- },
- useRef: Sh,
- useState: Qh,
- useDebugValue: ai,
- useDeferredValue: function(a) {
- var e = Qh(a)
- , i = e[0]
- , o = e[1];
- return Wh(function() {
- var s = wh.transition;
- wh.transition = 1;
- try {
- o(a)
- } finally {
- wh.transition = s
- }
- }, [a]),
- i
- },
- useTransition: function() {
- var a = Qh(!1)
- , e = a[0];
- return a = di.bind(null, a[1]),
- Sh(a),
- [a, e]
- },
- useMutableSource: function(a, e, i) {
- var o = Hh();
- return o.memoizedState = {
- refs: {
- getSnapshot: e,
- setSnapshot: null
- },
- source: a,
- subscribe: i
- },
- Nh(o, a, e, i)
- },
- useOpaqueIdentifier: function() {
- if (lh) {
- var a = !1
- , e = uf(function() {
- throw a || (a = !0,
- i("r:" + (tf++).toString(36))),
- Error(y(355))
- })
- , i = Qh(e)[1];
- return (R.mode & 2) === 0 && (R.flags |= 516,
- Rh(5, function() {
- i("r:" + (tf++).toString(36))
- }, void 0, null)),
- e
- }
- return e = "r:" + (tf++).toString(36),
- Qh(e),
- e
- },
- unstable_isNewReconciler: !1
- }
- , Eh = {
- readContext: vg,
- useCallback: bi,
- useContext: vg,
- useEffect: Xh,
- useImperativeHandle: $h,
- useLayoutEffect: Yh,
- useMemo: ci,
- useReducer: Kh,
- useRef: Th,
- useState: function() {
- return Kh(Jh)
- },
- useDebugValue: ai,
- useDeferredValue: function(a) {
- var e = Kh(Jh)
- , i = e[0]
- , o = e[1];
- return Xh(function() {
- var s = wh.transition;
- wh.transition = 1;
- try {
- o(a)
- } finally {
- wh.transition = s
- }
- }, [a]),
- i
- },
- useTransition: function() {
- var a = Kh(Jh)[0];
- return [Th().current, a]
- },
- useMutableSource: Ph,
- useOpaqueIdentifier: function() {
- return Kh(Jh)[0]
- },
- unstable_isNewReconciler: !1
- }
- , Fh = {
- readContext: vg,
- useCallback: bi,
- useContext: vg,
- useEffect: Xh,
- useImperativeHandle: $h,
- useLayoutEffect: Yh,
- useMemo: ci,
- useReducer: Lh,
- useRef: Th,
- useState: function() {
- return Lh(Jh)
- },
- useDebugValue: ai,
- useDeferredValue: function(a) {
- var e = Lh(Jh)
- , i = e[0]
- , o = e[1];
- return Xh(function() {
- var s = wh.transition;
- wh.transition = 1;
- try {
- o(a)
- } finally {
- wh.transition = s
- }
- }, [a]),
- i
- },
- useTransition: function() {
- var a = Lh(Jh)[0];
- return [Th().current, a]
- },
- useMutableSource: Ph,
- useOpaqueIdentifier: function() {
- return Lh(Jh)[0]
- },
- unstable_isNewReconciler: !1
- }
- , ei = ra.ReactCurrentOwner
- , ug = !1;
- function fi(a, e, i, o) {
- e.child = a === null ? Zg(e, null, i, o) : Yg(e, a.child, i, o)
- }
- function gi(a, e, i, o, s) {
- i = i.render;
- var c = e.ref;
- return tg(e, s),
- o = Ch(a, e, i, o, c, s),
- a !== null && !ug ? (e.updateQueue = a.updateQueue,
- e.flags &= -517,
- a.lanes &= ~s,
- hi(a, e, s)) : (e.flags |= 1,
- fi(a, e, o, s),
- e.child)
- }
- function ii(a, e, i, o, s, c) {
- if (a === null) {
- var d = i.type;
- return typeof d == "function" && !ji(d) && d.defaultProps === void 0 && i.compare === null && i.defaultProps === void 0 ? (e.tag = 15,
- e.type = d,
- ki(a, e, d, o, s, c)) : (a = Vg(i.type, null, o, e, e.mode, c),
- a.ref = e.ref,
- a.return = e,
- e.child = a)
- }
- return d = a.child,
- (s & c) === 0 && (s = d.memoizedProps,
- i = i.compare,
- i = i !== null ? i : Je,
- i(s, o) && a.ref === e.ref) ? hi(a, e, c) : (e.flags |= 1,
- a = Tg(d, o),
- a.ref = e.ref,
- a.return = e,
- e.child = a)
- }
- function ki(a, e, i, o, s, c) {
- if (a !== null && Je(a.memoizedProps, o) && a.ref === e.ref)
- if (ug = !1,
- (c & s) !== 0)
- (a.flags & 16384) !== 0 && (ug = !0);
- else
- return e.lanes = a.lanes,
- hi(a, e, c);
- return li(a, e, i, o, c)
- }
- function mi(a, e, i) {
- var o = e.pendingProps
- , s = o.children
- , c = a !== null ? a.memoizedState : null;
- if (o.mode === "hidden" || o.mode === "unstable-defer-without-hiding")
- if ((e.mode & 4) === 0)
- e.memoizedState = {
- baseLanes: 0
- },
- ni(e, i);
- else if ((i & 1073741824) !== 0)
- e.memoizedState = {
- baseLanes: 0
- },
- ni(e, c !== null ? c.baseLanes : i);
- else
- return a = c !== null ? c.baseLanes | i : i,
- e.lanes = e.childLanes = 1073741824,
- e.memoizedState = {
- baseLanes: a
- },
- ni(e, a),
- null;
- else
- c !== null ? (o = c.baseLanes | i,
- e.memoizedState = null) : o = i,
- ni(e, o);
- return fi(a, e, s, i),
- e.child
- }
- function oi(a, e) {
- var i = e.ref;
- (a === null && i !== null || a !== null && a.ref !== i) && (e.flags |= 128)
- }
- function li(a, e, i, o, s) {
- var c = Ff(i) ? Df : M.current;
- return c = Ef(e, c),
- tg(e, s),
- i = Ch(a, e, i, o, c, s),
- a !== null && !ug ? (e.updateQueue = a.updateQueue,
- e.flags &= -517,
- a.lanes &= ~s,
- hi(a, e, s)) : (e.flags |= 1,
- fi(a, e, i, s),
- e.child)
- }
- function pi(a, e, i, o, s) {
- if (Ff(i)) {
- var c = !0;
- Jf(e)
- } else
- c = !1;
- if (tg(e, s),
- e.stateNode === null)
- a !== null && (a.alternate = null,
- e.alternate = null,
- e.flags |= 2),
- Mg(e, i, o),
- Og(e, i, o, s),
- o = !0;
- else if (a === null) {
- var d = e.stateNode
- , _ = e.memoizedProps;
- d.props = _;
- var b = d.context
- , k = i.contextType;
- typeof k == "object" && k !== null ? k = vg(k) : (k = Ff(i) ? Df : M.current,
- k = Ef(e, k));
- var j = i.getDerivedStateFromProps
- , $ = typeof j == "function" || typeof d.getSnapshotBeforeUpdate == "function";
- $ || typeof d.UNSAFE_componentWillReceiveProps != "function" && typeof d.componentWillReceiveProps != "function" || (_ !== o || b !== k) && Ng(e, d, o, k),
- wg = !1;
- var _e = e.memoizedState;
- d.state = _e,
- Cg(e, o, d, s),
- b = e.memoizedState,
- _ !== o || _e !== b || N.current || wg ? (typeof j == "function" && (Gg(e, i, j, o),
- b = e.memoizedState),
- (_ = wg || Lg(e, i, _, o, _e, b, k)) ? ($ || typeof d.UNSAFE_componentWillMount != "function" && typeof d.componentWillMount != "function" || (typeof d.componentWillMount == "function" && d.componentWillMount(),
- typeof d.UNSAFE_componentWillMount == "function" && d.UNSAFE_componentWillMount()),
- typeof d.componentDidMount == "function" && (e.flags |= 4)) : (typeof d.componentDidMount == "function" && (e.flags |= 4),
- e.memoizedProps = o,
- e.memoizedState = b),
- d.props = o,
- d.state = b,
- d.context = k,
- o = _) : (typeof d.componentDidMount == "function" && (e.flags |= 4),
- o = !1)
- } else {
- d = e.stateNode,
- yg(a, e),
- _ = e.memoizedProps,
- k = e.type === e.elementType ? _ : lg(e.type, _),
- d.props = k,
- $ = e.pendingProps,
- _e = d.context,
- b = i.contextType,
- typeof b == "object" && b !== null ? b = vg(b) : (b = Ff(i) ? Df : M.current,
- b = Ef(e, b));
- var et = i.getDerivedStateFromProps;
- (j = typeof et == "function" || typeof d.getSnapshotBeforeUpdate == "function") || typeof d.UNSAFE_componentWillReceiveProps != "function" && typeof d.componentWillReceiveProps != "function" || (_ !== $ || _e !== b) && Ng(e, d, o, b),
- wg = !1,
- _e = e.memoizedState,
- d.state = _e,
- Cg(e, o, d, s);
- var tt = e.memoizedState;
- _ !== $ || _e !== tt || N.current || wg ? (typeof et == "function" && (Gg(e, i, et, o),
- tt = e.memoizedState),
- (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),
- typeof d.UNSAFE_componentWillUpdate == "function" && d.UNSAFE_componentWillUpdate(o, tt, b)),
- typeof d.componentDidUpdate == "function" && (e.flags |= 4),
- typeof d.getSnapshotBeforeUpdate == "function" && (e.flags |= 256)) : (typeof d.componentDidUpdate != "function" || _ === a.memoizedProps && _e === a.memoizedState || (e.flags |= 4),
- typeof d.getSnapshotBeforeUpdate != "function" || _ === a.memoizedProps && _e === a.memoizedState || (e.flags |= 256),
- e.memoizedProps = o,
- e.memoizedState = tt),
- d.props = o,
- d.state = tt,
- d.context = b,
- o = k) : (typeof d.componentDidUpdate != "function" || _ === a.memoizedProps && _e === a.memoizedState || (e.flags |= 4),
- typeof d.getSnapshotBeforeUpdate != "function" || _ === a.memoizedProps && _e === a.memoizedState || (e.flags |= 256),
- o = !1)
- }
- return qi(a, e, i, o, c, s)
- }
- function qi(a, e, i, o, s, c) {
- oi(a, e);
- var d = (e.flags & 64) !== 0;
- if (!o && !d)
- return s && Kf(e, i, !1),
- hi(a, e, c);
- o = e.stateNode,
- ei.current = e;
- var _ = d && typeof i.getDerivedStateFromError != "function" ? null : o.render();
- return e.flags |= 1,
- a !== null && d ? (e.child = Yg(e, a.child, null, c),
- e.child = Yg(e, null, _, c)) : fi(a, e, _, c),
- e.memoizedState = o.state,
- s && Kf(e, i, !0),
- e.child
- }
- function ri(a) {
- var e = a.stateNode;
- e.pendingContext ? Hf(a, e.pendingContext, e.pendingContext !== e.context) : e.context && Hf(a, e.context, !1),
- eh(a, e.containerInfo)
- }
- var si = {
- dehydrated: null,
- retryLane: 0
- };
- function ti(a, e, i) {
- var o = e.pendingProps, s = P.current, c = !1, d;
- return (d = (e.flags & 64) !== 0) || (d = a !== null && a.memoizedState === null ? !1 : (s & 2) !== 0),
- d ? (c = !0,
- e.flags &= -65) : a !== null && a.memoizedState === null || o.fallback === void 0 || o.unstable_avoidThisFallback === !0 || (s |= 1),
- I(P, s & 1),
- a === null ? (o.fallback !== void 0 && ph(e),
- a = o.children,
- s = o.fallback,
- c ? (a = ui(e, a, s, i),
- e.child.memoizedState = {
- baseLanes: i
- },
- e.memoizedState = si,
- a) : typeof o.unstable_expectedLoadTime == "number" ? (a = ui(e, a, s, i),
- e.child.memoizedState = {
- baseLanes: i
- },
- e.memoizedState = si,
- e.lanes = 33554432,
- a) : (i = vi({
- mode: "visible",
- children: a
- }, e.mode, i, null),
- i.return = e,
- e.child = i)) : a.memoizedState !== null ? c ? (o = wi(a, e, o.children, o.fallback, i),
- c = e.child,
- s = a.child.memoizedState,
- c.memoizedState = s === null ? {
- baseLanes: i
- } : {
- baseLanes: s.baseLanes | i
- },
- c.childLanes = a.childLanes & ~i,
- e.memoizedState = si,
- o) : (i = xi(a, e, o.children, i),
- e.memoizedState = null,
- i) : c ? (o = wi(a, e, o.children, o.fallback, i),
- c = e.child,
- s = a.child.memoizedState,
- c.memoizedState = s === null ? {
- baseLanes: i
- } : {
- baseLanes: s.baseLanes | i
- },
- c.childLanes = a.childLanes & ~i,
- e.memoizedState = si,
- o) : (i = xi(a, e, o.children, i),
- e.memoizedState = null,
- i)
- }
- function ui(a, e, i, o) {
- var s = a.mode
- , c = a.child;
- return e = {
- mode: "hidden",
- children: e
- },
- (s & 2) === 0 && c !== null ? (c.childLanes = 0,
- c.pendingProps = e) : c = vi(e, s, 0, null),
- i = Xg(i, s, o, null),
- c.return = a,
- i.return = a,
- c.sibling = i,
- a.child = c,
- i
- }
- function xi(a, e, i, o) {
- var s = a.child;
- return a = s.sibling,
- i = Tg(s, {
- mode: "visible",
- children: i
- }),
- (e.mode & 2) === 0 && (i.lanes = o),
- i.return = e,
- i.sibling = null,
- a !== null && (a.nextEffect = null,
- a.flags = 8,
- e.firstEffect = e.lastEffect = a),
- e.child = i
- }
- function wi(a, e, i, o, s) {
- var c = e.mode
- , d = a.child;
- a = d.sibling;
- var _ = {
- mode: "hidden",
- children: i
- };
- return (c & 2) === 0 && e.child !== d ? (i = e.child,
- i.childLanes = 0,
- i.pendingProps = _,
- d = i.lastEffect,
- d !== null ? (e.firstEffect = i.firstEffect,
- e.lastEffect = d,
- d.nextEffect = null) : e.firstEffect = e.lastEffect = null) : i = Tg(d, _),
- a !== null ? o = Tg(a, o) : (o = Xg(o, c, s, null),
- o.flags |= 2),
- o.return = e,
- i.return = e,
- i.sibling = o,
- e.child = i,
- o
- }
- function yi(a, e) {
- a.lanes |= e;
- var i = a.alternate;
- i !== null && (i.lanes |= e),
- sg(a.return, e)
- }
- function zi(a, e, i, o, s, c) {
- var d = a.memoizedState;
- d === null ? a.memoizedState = {
- isBackwards: e,
- rendering: null,
- renderingStartTime: 0,
- last: o,
- tail: i,
- tailMode: s,
- lastEffect: c
- } : (d.isBackwards = e,
- d.rendering = null,
- d.renderingStartTime = 0,
- d.last = o,
- d.tail = i,
- d.tailMode = s,
- d.lastEffect = c)
- }
- function Ai(a, e, i) {
- var o = e.pendingProps
- , s = o.revealOrder
- , c = o.tail;
- if (fi(a, e, o.children, i),
- o = P.current,
- (o & 2) !== 0)
- o = o & 1 | 2,
- e.flags |= 64;
- else {
- if (a !== null && (a.flags & 64) !== 0)
- e: for (a = e.child; a !== null; ) {
- if (a.tag === 13)
- a.memoizedState !== null && yi(a, i);
- else if (a.tag === 19)
- yi(a, i);
- else if (a.child !== null) {
- a.child.return = a,
- a = a.child;
- continue
- }
- if (a === e)
- break e;
- for (; a.sibling === null; ) {
- if (a.return === null || a.return === e)
- break e;
- a = a.return
- }
- a.sibling.return = a.return,
- a = a.sibling
- }
- o &= 1
- }
- if (I(P, o),
- (e.mode & 2) === 0)
- e.memoizedState = null;
- else
- switch (s) {
- case "forwards":
- for (i = e.child,
- s = null; i !== null; )
- a = i.alternate,
- a !== null && ih(a) === null && (s = i),
- i = i.sibling;
- i = s,
- i === null ? (s = e.child,
- e.child = null) : (s = i.sibling,
- i.sibling = null),
- zi(e, !1, s, i, c, e.lastEffect);
- break;
- case "backwards":
- for (i = null,
- s = e.child,
- e.child = null; s !== null; ) {
- if (a = s.alternate,
- a !== null && ih(a) === null) {
- e.child = s;
- break
- }
- a = s.sibling,
- s.sibling = i,
- i = s,
- s = a
- }
- zi(e, !0, i, null, c, e.lastEffect);
- break;
- case "together":
- zi(e, !1, null, null, void 0, e.lastEffect);
- break;
- default:
- e.memoizedState = null
- }
- return e.child
- }
- function hi(a, e, i) {
- if (a !== null && (e.dependencies = a.dependencies),
- Dg |= e.lanes,
- (i & e.childLanes) !== 0) {
- if (a !== null && e.child !== a.child)
- throw Error(y(153));
- if (e.child !== null) {
- for (a = e.child,
- i = Tg(a, a.pendingProps),
- e.child = i,
- i.return = e; a.sibling !== null; )
- a = a.sibling,
- i = i.sibling = Tg(a, a.pendingProps),
- i.return = e;
- i.sibling = null
- }
- return e.child
- }
- return null
- }
- var Bi, Ci, Di, Ei;
- Bi = function(a, e) {
- for (var i = e.child; i !== null; ) {
- if (i.tag === 5 || i.tag === 6)
- a.appendChild(i.stateNode);
- else if (i.tag !== 4 && i.child !== null) {
- i.child.return = i,
- i = i.child;
- continue
- }
- if (i === e)
- break;
- for (; i.sibling === null; ) {
- if (i.return === null || i.return === e)
- return;
- i = i.return
- }
- i.sibling.return = i.return,
- i = i.sibling
- }
- }
- ;
- Ci = function() {}
- ;
- Di = function(a, e, i, o) {
- var s = a.memoizedProps;
- if (s !== o) {
- a = e.stateNode,
- dh(ah.current);
- var c = null;
- switch (i) {
- case "input":
- s = Ya(a, s),
- o = Ya(a, o),
- c = [];
- break;
- case "option":
- s = eb(a, s),
- o = eb(a, o),
- c = [];
- break;
- case "select":
- s = m$1({}, s, {
- value: void 0
- }),
- o = m$1({}, o, {
- value: void 0
- }),
- c = [];
- break;
- case "textarea":
- s = gb(a, s),
- o = gb(a, o),
- c = [];
- break;
- default:
- typeof s.onClick != "function" && typeof o.onClick == "function" && (a.onclick = jf)
- }
- vb(i, o);
- var d;
- i = null;
- for (k in s)
- if (!o.hasOwnProperty(k) && s.hasOwnProperty(k) && s[k] != null)
- if (k === "style") {
- var _ = s[k];
- for (d in _)
- _.hasOwnProperty(d) && (i || (i = {}),
- i[d] = "")
- } else
- k !== "dangerouslySetInnerHTML" && k !== "children" && k !== "suppressContentEditableWarning" && k !== "suppressHydrationWarning" && k !== "autoFocus" && (ca.hasOwnProperty(k) ? c || (c = []) : (c = c || []).push(k, null));
- for (k in o) {
- var b = o[k];
- if (_ = s != null ? s[k] : void 0,
- o.hasOwnProperty(k) && b !== _ && (b != null || _ != null))
- if (k === "style")
- if (_) {
- for (d in _)
- !_.hasOwnProperty(d) || b && b.hasOwnProperty(d) || (i || (i = {}),
- i[d] = "");
- for (d in b)
- b.hasOwnProperty(d) && _[d] !== b[d] && (i || (i = {}),
- i[d] = b[d])
- } else
- i || (c || (c = []),
- c.push(k, i)),
- i = b;
- else
- k === "dangerouslySetInnerHTML" ? (b = b ? b.__html : void 0,
- _ = _ ? _.__html : void 0,
- 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),
- c || _ === b || (c = [])) : typeof b == "object" && b !== null && b.$$typeof === Ga ? b.toString() : (c = c || []).push(k, b))
- }
- i && (c = c || []).push("style", i);
- var k = c;
- (e.updateQueue = k) && (e.flags |= 4)
- }
- }
- ;
- Ei = function(a, e, i, o) {
- i !== o && (e.flags |= 4)
- }
- ;
- function Fi(a, e) {
- if (!lh)
- switch (a.tailMode) {
- case "hidden":
- e = a.tail;
- for (var i = null; e !== null; )
- e.alternate !== null && (i = e),
- e = e.sibling;
- i === null ? a.tail = null : i.sibling = null;
- break;
- case "collapsed":
- i = a.tail;
- for (var o = null; i !== null; )
- i.alternate !== null && (o = i),
- i = i.sibling;
- o === null ? e || a.tail === null ? a.tail = null : a.tail.sibling = null : o.sibling = null
- }
- }
- function Gi(a, e, i) {
- var o = e.pendingProps;
- switch (e.tag) {
- case 2:
- case 16:
- case 15:
- case 0:
- case 11:
- case 7:
- case 8:
- case 12:
- case 9:
- case 14:
- return null;
- case 1:
- return Ff(e.type) && Gf(),
- null;
- case 3:
- return fh(),
- H(N),
- H(M),
- uh(),
- o = e.stateNode,
- o.pendingContext && (o.context = o.pendingContext,
- o.pendingContext = null),
- (a === null || a.child === null) && (rh(e) ? e.flags |= 4 : o.hydrate || (e.flags |= 256)),
- Ci(e),
- null;
- case 5:
- hh(e);
- var s = dh(ch.current);
- if (i = e.type,
- a !== null && e.stateNode != null)
- Di(a, e, i, o, s),
- a.ref !== e.ref && (e.flags |= 128);
- else {
- if (!o) {
- if (e.stateNode === null)
- throw Error(y(166));
- return null
- }
- if (a = dh(ah.current),
- rh(e)) {
- o = e.stateNode,
- i = e.type;
- var c = e.memoizedProps;
- switch (o[wf] = e,
- o[xf] = c,
- i) {
- case "dialog":
- G("cancel", o),
- G("close", o);
- break;
- case "iframe":
- case "object":
- case "embed":
- G("load", o);
- break;
- case "video":
- case "audio":
- for (a = 0; a < Xe.length; a++)
- G(Xe[a], o);
- break;
- case "source":
- G("error", o);
- break;
- case "img":
- case "image":
- case "link":
- G("error", o),
- G("load", o);
- break;
- case "details":
- G("toggle", o);
- break;
- case "input":
- Za(o, c),
- G("invalid", o);
- break;
- case "select":
- o._wrapperState = {
- wasMultiple: !!c.multiple
- },
- G("invalid", o);
- break;
- case "textarea":
- hb(o, c),
- G("invalid", o)
- }
- vb(i, c),
- a = null;
- for (var d in c)
- c.hasOwnProperty(d) && (s = c[d],
- 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));
- switch (i) {
- case "input":
- Va(o),
- cb(o, c, !0);
- break;
- case "textarea":
- Va(o),
- jb(o);
- break;
- case "select":
- case "option":
- break;
- default:
- typeof c.onClick == "function" && (o.onclick = jf)
- }
- o = a,
- e.updateQueue = o,
- o !== null && (e.flags |= 4)
- } else {
- switch (d = s.nodeType === 9 ? s : s.ownerDocument,
- a === kb.html && (a = lb(i)),
- a === kb.html ? i === "script" ? (a = d.createElement("div"),
- a.innerHTML = "<script><\/script>",
- a = a.removeChild(a.firstChild)) : typeof o.is == "string" ? a = d.createElement(i, {
- is: o.is
- }) : (a = d.createElement(i),
- i === "select" && (d = a,
- o.multiple ? d.multiple = !0 : o.size && (d.size = o.size))) : a = d.createElementNS(a, i),
- a[wf] = e,
- a[xf] = o,
- Bi(a, e, !1, !1),
- e.stateNode = a,
- d = wb(i, o),
- i) {
- case "dialog":
- G("cancel", a),
- G("close", a),
- s = o;
- break;
- case "iframe":
- case "object":
- case "embed":
- G("load", a),
- s = o;
- break;
- case "video":
- case "audio":
- for (s = 0; s < Xe.length; s++)
- G(Xe[s], a);
- s = o;
- break;
- case "source":
- G("error", a),
- s = o;
- break;
- case "img":
- case "image":
- case "link":
- G("error", a),
- G("load", a),
- s = o;
- break;
- case "details":
- G("toggle", a),
- s = o;
- break;
- case "input":
- Za(a, o),
- s = Ya(a, o),
- G("invalid", a);
- break;
- case "option":
- s = eb(a, o);
- break;
- case "select":
- a._wrapperState = {
- wasMultiple: !!o.multiple
- },
- s = m$1({}, o, {
- value: void 0
- }),
- G("invalid", a);
- break;
- case "textarea":
- hb(a, o),
- s = gb(a, o),
- G("invalid", a);
- break;
- default:
- s = o
- }
- vb(i, s);
- var _ = s;
- for (c in _)
- if (_.hasOwnProperty(c)) {
- var b = _[c];
- c === "style" ? tb(a, b) : c === "dangerouslySetInnerHTML" ? (b = b ? b.__html : void 0,
- 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))
- }
- switch (i) {
- case "input":
- Va(a),
- cb(a, o, !1);
- break;
- case "textarea":
- Va(a),
- jb(a);
- break;
- case "option":
- o.value != null && a.setAttribute("value", "" + Sa(o.value));
- break;
- case "select":
- a.multiple = !!o.multiple,
- c = o.value,
- c != null ? fb(a, !!o.multiple, c, !1) : o.defaultValue != null && fb(a, !!o.multiple, o.defaultValue, !0);
- break;
- default:
- typeof s.onClick == "function" && (a.onclick = jf)
- }
- mf(i, o) && (e.flags |= 4)
- }
- e.ref !== null && (e.flags |= 128)
- }
- return null;
- case 6:
- if (a && e.stateNode != null)
- Ei(a, e, a.memoizedProps, o);
- else {
- if (typeof o != "string" && e.stateNode === null)
- throw Error(y(166));
- i = dh(ch.current),
- dh(ah.current),
- rh(e) ? (o = e.stateNode,
- i = e.memoizedProps,
- o[wf] = e,
- o.nodeValue !== i && (e.flags |= 4)) : (o = (i.nodeType === 9 ? i : i.ownerDocument).createTextNode(o),
- o[wf] = e,
- e.stateNode = o)
- }
- return null;
- case 13:
- return H(P),
- o = e.memoizedState,
- (e.flags & 64) !== 0 ? (e.lanes = i,
- e) : (o = o !== null,
- i = !1,
- a === null ? e.memoizedProps.fallback !== void 0 && rh(e) : i = a.memoizedState !== null,
- 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),
- U === null || (Dg & 134217727) === 0 && (Hi & 134217727) === 0 || Ii(U, W))),
- (o || i) && (e.flags |= 4),
- null);
- case 4:
- return fh(),
- Ci(e),
- a === null && cf(e.stateNode.containerInfo),
- null;
- case 10:
- return rg(e),
- null;
- case 17:
- return Ff(e.type) && Gf(),
- null;
- case 19:
- if (H(P),
- o = e.memoizedState,
- o === null)
- return null;
- if (c = (e.flags & 64) !== 0,
- d = o.rendering,
- d === null)
- if (c)
- Fi(o, !1);
- else {
- if (V !== 0 || a !== null && (a.flags & 64) !== 0)
- for (a = e.child; a !== null; ) {
- if (d = ih(a),
- d !== null) {
- for (e.flags |= 64,
- Fi(o, !1),
- c = d.updateQueue,
- c !== null && (e.updateQueue = c,
- e.flags |= 4),
- o.lastEffect === null && (e.firstEffect = null),
- e.lastEffect = o.lastEffect,
- o = i,
- i = e.child; i !== null; )
- c = i,
- a = o,
- c.flags &= 2,
- c.nextEffect = null,
- c.firstEffect = null,
- c.lastEffect = null,
- d = c.alternate,
- d === null ? (c.childLanes = 0,
- c.lanes = a,
- c.child = null,
- c.memoizedProps = null,
- c.memoizedState = null,
- c.updateQueue = null,
- c.dependencies = null,
- c.stateNode = null) : (c.childLanes = d.childLanes,
- c.lanes = d.lanes,
- c.child = d.child,
- c.memoizedProps = d.memoizedProps,
- c.memoizedState = d.memoizedState,
- c.updateQueue = d.updateQueue,
- c.type = d.type,
- a = d.dependencies,
- c.dependencies = a === null ? null : {
- lanes: a.lanes,
- firstContext: a.firstContext
- }),
- i = i.sibling;
- return I(P, P.current & 1 | 2),
- e.child
- }
- a = a.sibling
- }
- o.tail !== null && O() > Ji && (e.flags |= 64,
- c = !0,
- Fi(o, !1),
- e.lanes = 33554432)
- }
- else {
- if (!c)
- if (a = ih(d),
- a !== null) {
- if (e.flags |= 64,
- c = !0,
- i = a.updateQueue,
- i !== null && (e.updateQueue = i,
- e.flags |= 4),
- Fi(o, !0),
- o.tail === null && o.tailMode === "hidden" && !d.alternate && !lh)
- return e = e.lastEffect = o.lastEffect,
- e !== null && (e.nextEffect = null),
- null
- } else
- 2 * O() - o.renderingStartTime > Ji && i !== 1073741824 && (e.flags |= 64,
- c = !0,
- Fi(o, !1),
- e.lanes = 33554432);
- o.isBackwards ? (d.sibling = e.child,
- e.child = d) : (i = o.last,
- i !== null ? i.sibling = d : e.child = d,
- o.last = d)
- }
- return o.tail !== null ? (i = o.tail,
- o.rendering = i,
- o.tail = i.sibling,
- o.lastEffect = e.lastEffect,
- o.renderingStartTime = O(),
- i.sibling = null,
- e = P.current,
- I(P, c ? e & 1 | 2 : e & 1),
- i) : null;
- case 23:
- case 24:
- return Ki(),
- a !== null && a.memoizedState !== null != (e.memoizedState !== null) && o.mode !== "unstable-defer-without-hiding" && (e.flags |= 4),
- null
- }
- throw Error(y(156, e.tag))
- }
- function Li(a) {
- switch (a.tag) {
- case 1:
- Ff(a.type) && Gf();
- var e = a.flags;
- return e & 4096 ? (a.flags = e & -4097 | 64,
- a) : null;
- case 3:
- if (fh(),
- H(N),
- H(M),
- uh(),
- e = a.flags,
- (e & 64) !== 0)
- throw Error(y(285));
- return a.flags = e & -4097 | 64,
- a;
- case 5:
- return hh(a),
- null;
- case 13:
- return H(P),
- e = a.flags,
- e & 4096 ? (a.flags = e & -4097 | 64,
- a) : null;
- case 19:
- return H(P),
- null;
- case 4:
- return fh(),
- null;
- case 10:
- return rg(a),
- null;
- case 23:
- case 24:
- return Ki(),
- null;
- default:
- return null
- }
- }
- function Mi(a, e) {
- try {
- var i = ""
- , o = e;
- do
- i += Qa(o),
- o = o.return;
- while (o);
- var s = i
- } catch (c) {
- s = `
- Error generating stack: ` + c.message + `
- ` + c.stack
- }
- return {
- value: a,
- source: e,
- stack: s
- }
- }
- function Ni(a, e) {
- try {
- console.error(e.value)
- } catch (i) {
- setTimeout(function() {
- throw i
- })
- }
- }
- var Oi = typeof WeakMap == "function" ? WeakMap : Map;
- function Pi(a, e, i) {
- i = zg(-1, i),
- i.tag = 3,
- i.payload = {
- element: null
- };
- var o = e.value;
- return i.callback = function() {
- Qi || (Qi = !0,
- Ri = o),
- Ni(a, e)
- }
- ,
- i
- }
- function Si(a, e, i) {
- i = zg(-1, i),
- i.tag = 3;
- var o = a.type.getDerivedStateFromError;
- if (typeof o == "function") {
- var s = e.value;
- i.payload = function() {
- return Ni(a, e),
- o(s)
- }
- }
- var c = a.stateNode;
- return c !== null && typeof c.componentDidCatch == "function" && (i.callback = function() {
- typeof o != "function" && (Ti === null ? Ti = new Set([this]) : Ti.add(this),
- Ni(a, e));
- var d = e.stack;
- this.componentDidCatch(e.value, {
- componentStack: d !== null ? d : ""
- })
- }
- ),
- i
- }
- var Ui = typeof WeakSet == "function" ? WeakSet : Set;
- function Vi(a) {
- var e = a.ref;
- if (e !== null)
- if (typeof e == "function")
- try {
- e(null)
- } catch (i) {
- Wi(a, i)
- }
- else
- e.current = null
- }
- function Xi(a, e) {
- switch (e.tag) {
- case 0:
- case 11:
- case 15:
- case 22:
- return;
- case 1:
- if (e.flags & 256 && a !== null) {
- var i = a.memoizedProps
- , o = a.memoizedState;
- a = e.stateNode,
- e = a.getSnapshotBeforeUpdate(e.elementType === e.type ? i : lg(e.type, i), o),
- a.__reactInternalSnapshotBeforeUpdate = e
- }
- return;
- case 3:
- e.flags & 256 && qf(e.stateNode.containerInfo);
- return;
- case 5:
- case 6:
- case 4:
- case 17:
- return
- }
- throw Error(y(163))
- }
- function Yi(a, e, i) {
- switch (i.tag) {
- case 0:
- case 11:
- case 15:
- case 22:
- if (e = i.updateQueue,
- e = e !== null ? e.lastEffect : null,
- e !== null) {
- a = e = e.next;
- do {
- if ((a.tag & 3) === 3) {
- var o = a.create;
- a.destroy = o()
- }
- a = a.next
- } while (a !== e)
- }
- if (e = i.updateQueue,
- e = e !== null ? e.lastEffect : null,
- e !== null) {
- a = e = e.next;
- do {
- var s = a;
- o = s.next,
- s = s.tag,
- (s & 4) !== 0 && (s & 1) !== 0 && (Zi(i, a),
- $i(i, a)),
- a = o
- } while (a !== e)
- }
- return;
- case 1:
- a = i.stateNode,
- i.flags & 4 && (e === null ? a.componentDidMount() : (o = i.elementType === i.type ? e.memoizedProps : lg(i.type, e.memoizedProps),
- a.componentDidUpdate(o, e.memoizedState, a.__reactInternalSnapshotBeforeUpdate))),
- e = i.updateQueue,
- e !== null && Eg(i, e, a);
- return;
- case 3:
- if (e = i.updateQueue,
- e !== null) {
- if (a = null,
- i.child !== null)
- switch (i.child.tag) {
- case 5:
- a = i.child.stateNode;
- break;
- case 1:
- a = i.child.stateNode
- }
- Eg(i, e, a)
- }
- return;
- case 5:
- a = i.stateNode,
- e === null && i.flags & 4 && mf(i.type, i.memoizedProps) && a.focus();
- return;
- case 6:
- return;
- case 4:
- return;
- case 12:
- return;
- case 13:
- i.memoizedState === null && (i = i.alternate,
- i !== null && (i = i.memoizedState,
- i !== null && (i = i.dehydrated,
- i !== null && Cc(i))));
- return;
- case 19:
- case 17:
- case 20:
- case 21:
- case 23:
- case 24:
- return
- }
- throw Error(y(163))
- }
- function aj(a, e) {
- for (var i = a; ; ) {
- if (i.tag === 5) {
- var o = i.stateNode;
- if (e)
- o = o.style,
- typeof o.setProperty == "function" ? o.setProperty("display", "none", "important") : o.display = "none";
- else {
- o = i.stateNode;
- var s = i.memoizedProps.style;
- s = s != null && s.hasOwnProperty("display") ? s.display : null,
- o.style.display = sb("display", s)
- }
- } else if (i.tag === 6)
- i.stateNode.nodeValue = e ? "" : i.memoizedProps;
- else if ((i.tag !== 23 && i.tag !== 24 || i.memoizedState === null || i === a) && i.child !== null) {
- i.child.return = i,
- i = i.child;
- continue
- }
- if (i === a)
- break;
- for (; i.sibling === null; ) {
- if (i.return === null || i.return === a)
- return;
- i = i.return
- }
- i.sibling.return = i.return,
- i = i.sibling
- }
- }
- function bj(a, e) {
- if (Mf && typeof Mf.onCommitFiberUnmount == "function")
- try {
- Mf.onCommitFiberUnmount(Lf, e)
- } catch {}
- switch (e.tag) {
- case 0:
- case 11:
- case 14:
- case 15:
- case 22:
- if (a = e.updateQueue,
- a !== null && (a = a.lastEffect,
- a !== null)) {
- var i = a = a.next;
- do {
- var o = i
- , s = o.destroy;
- if (o = o.tag,
- s !== void 0)
- if ((o & 4) !== 0)
- Zi(e, i);
- else {
- o = e;
- try {
- s()
- } catch (c) {
- Wi(o, c)
- }
- }
- i = i.next
- } while (i !== a)
- }
- break;
- case 1:
- if (Vi(e),
- a = e.stateNode,
- typeof a.componentWillUnmount == "function")
- try {
- a.props = e.memoizedProps,
- a.state = e.memoizedState,
- a.componentWillUnmount()
- } catch (c) {
- Wi(e, c)
- }
- break;
- case 5:
- Vi(e);
- break;
- case 4:
- cj(a, e)
- }
- }
- function dj(a) {
- a.alternate = null,
- a.child = null,
- a.dependencies = null,
- a.firstEffect = null,
- a.lastEffect = null,
- a.memoizedProps = null,
- a.memoizedState = null,
- a.pendingProps = null,
- a.return = null,
- a.updateQueue = null
- }
- function ej(a) {
- return a.tag === 5 || a.tag === 3 || a.tag === 4
- }
- function fj(a) {
- e: {
- for (var e = a.return; e !== null; ) {
- if (ej(e))
- break e;
- e = e.return
- }
- throw Error(y(160))
- }
- var i = e;
- switch (e = i.stateNode,
- i.tag) {
- case 5:
- var o = !1;
- break;
- case 3:
- e = e.containerInfo,
- o = !0;
- break;
- case 4:
- e = e.containerInfo,
- o = !0;
- break;
- default:
- throw Error(y(161))
- }
- i.flags & 16 && (pb(e, ""),
- i.flags &= -17);
- e: t: for (i = a; ; ) {
- for (; i.sibling === null; ) {
- if (i.return === null || ej(i.return)) {
- i = null;
- break e
- }
- i = i.return
- }
- for (i.sibling.return = i.return,
- i = i.sibling; i.tag !== 5 && i.tag !== 6 && i.tag !== 18; ) {
- if (i.flags & 2 || i.child === null || i.tag === 4)
- continue t;
- i.child.return = i,
- i = i.child
- }
- if (!(i.flags & 2)) {
- i = i.stateNode;
- break e
- }
- }
- o ? gj(a, i, e) : hj(a, i, e)
- }
- function gj(a, e, i) {
- var o = a.tag
- , s = o === 5 || o === 6;
- if (s)
- a = s ? a.stateNode : a.stateNode.instance,
- e ? i.nodeType === 8 ? i.parentNode.insertBefore(a, e) : i.insertBefore(a, e) : (i.nodeType === 8 ? (e = i.parentNode,
- e.insertBefore(a, i)) : (e = i,
- e.appendChild(a)),
- i = i._reactRootContainer,
- i != null || e.onclick !== null || (e.onclick = jf));
- else if (o !== 4 && (a = a.child,
- a !== null))
- for (gj(a, e, i),
- a = a.sibling; a !== null; )
- gj(a, e, i),
- a = a.sibling
- }
- function hj(a, e, i) {
- var o = a.tag
- , s = o === 5 || o === 6;
- if (s)
- a = s ? a.stateNode : a.stateNode.instance,
- e ? i.insertBefore(a, e) : i.appendChild(a);
- else if (o !== 4 && (a = a.child,
- a !== null))
- for (hj(a, e, i),
- a = a.sibling; a !== null; )
- hj(a, e, i),
- a = a.sibling
- }
- function cj(a, e) {
- for (var i = e, o = !1, s, c; ; ) {
- if (!o) {
- o = i.return;
- e: for (; ; ) {
- if (o === null)
- throw Error(y(160));
- switch (s = o.stateNode,
- o.tag) {
- case 5:
- c = !1;
- break e;
- case 3:
- s = s.containerInfo,
- c = !0;
- break e;
- case 4:
- s = s.containerInfo,
- c = !0;
- break e
- }
- o = o.return
- }
- o = !0
- }
- if (i.tag === 5 || i.tag === 6) {
- e: for (var d = a, _ = i, b = _; ; )
- if (bj(d, b),
- b.child !== null && b.tag !== 4)
- b.child.return = b,
- b = b.child;
- else {
- if (b === _)
- break e;
- for (; b.sibling === null; ) {
- if (b.return === null || b.return === _)
- break e;
- b = b.return
- }
- b.sibling.return = b.return,
- b = b.sibling
- }
- c ? (d = s,
- _ = i.stateNode,
- d.nodeType === 8 ? d.parentNode.removeChild(_) : d.removeChild(_)) : s.removeChild(i.stateNode)
- } else if (i.tag === 4) {
- if (i.child !== null) {
- s = i.stateNode.containerInfo,
- c = !0,
- i.child.return = i,
- i = i.child;
- continue
- }
- } else if (bj(a, i),
- i.child !== null) {
- i.child.return = i,
- i = i.child;
- continue
- }
- if (i === e)
- break;
- for (; i.sibling === null; ) {
- if (i.return === null || i.return === e)
- return;
- i = i.return,
- i.tag === 4 && (o = !1)
- }
- i.sibling.return = i.return,
- i = i.sibling
- }
- }
- function ij(a, e) {
- switch (e.tag) {
- case 0:
- case 11:
- case 14:
- case 15:
- case 22:
- var i = e.updateQueue;
- if (i = i !== null ? i.lastEffect : null,
- i !== null) {
- var o = i = i.next;
- do
- (o.tag & 3) === 3 && (a = o.destroy,
- o.destroy = void 0,
- a !== void 0 && a()),
- o = o.next;
- while (o !== i)
- }
- return;
- case 1:
- return;
- case 5:
- if (i = e.stateNode,
- i != null) {
- o = e.memoizedProps;
- var s = a !== null ? a.memoizedProps : o;
- a = e.type;
- var c = e.updateQueue;
- if (e.updateQueue = null,
- c !== null) {
- for (i[xf] = o,
- a === "input" && o.type === "radio" && o.name != null && $a(i, o),
- wb(a, s),
- e = wb(a, o),
- s = 0; s < c.length; s += 2) {
- var d = c[s]
- , _ = c[s + 1];
- d === "style" ? tb(i, _) : d === "dangerouslySetInnerHTML" ? ob(i, _) : d === "children" ? pb(i, _) : qa(i, d, _, e)
- }
- switch (a) {
- case "input":
- ab(i, o);
- break;
- case "textarea":
- ib(i, o);
- break;
- case "select":
- a = i._wrapperState.wasMultiple,
- i._wrapperState.wasMultiple = !!o.multiple,
- c = o.value,
- 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))
- }
- }
- }
- return;
- case 6:
- if (e.stateNode === null)
- throw Error(y(162));
- e.stateNode.nodeValue = e.memoizedProps;
- return;
- case 3:
- i = e.stateNode,
- i.hydrate && (i.hydrate = !1,
- Cc(i.containerInfo));
- return;
- case 12:
- return;
- case 13:
- e.memoizedState !== null && (jj = O(),
- aj(e.child, !0)),
- kj(e);
- return;
- case 19:
- kj(e);
- return;
- case 17:
- return;
- case 23:
- case 24:
- aj(e, e.memoizedState !== null);
- return
- }
- throw Error(y(163))
- }
- function kj(a) {
- var e = a.updateQueue;
- if (e !== null) {
- a.updateQueue = null;
- var i = a.stateNode;
- i === null && (i = a.stateNode = new Ui),
- e.forEach(function(o) {
- var s = lj.bind(null, a, o);
- i.has(o) || (i.add(o),
- o.then(s, s))
- })
- }
- }
- function mj(a, e) {
- return a !== null && (a = a.memoizedState,
- a === null || a.dehydrated !== null) ? (e = e.memoizedState,
- e !== null && e.dehydrated === null) : !1
- }
- var nj = Math.ceil
- , oj = ra.ReactCurrentDispatcher
- , pj = ra.ReactCurrentOwner
- , X = 0
- , U = null
- , Y = null
- , W = 0
- , qj = 0
- , rj = Bf(0)
- , V = 0
- , sj = null
- , tj = 0
- , Dg = 0
- , Hi = 0
- , uj = 0
- , vj = null
- , jj = 0
- , Ji = 1 / 0;
- function wj() {
- Ji = O() + 500
- }
- var Z = null
- , Qi = !1
- , Ri = null
- , Ti = null
- , xj = !1
- , yj = null
- , zj = 90
- , Aj = []
- , Bj = []
- , Cj = null
- , Dj = 0
- , Ej = null
- , Fj = -1
- , Gj = 0
- , Hj = 0
- , Ij = null
- , Jj = !1;
- function Hg() {
- return (X & 48) !== 0 ? O() : Fj !== -1 ? Fj : Fj = O()
- }
- function Ig(a) {
- if (a = a.mode,
- (a & 2) === 0)
- return 1;
- if ((a & 4) === 0)
- return eg() === 99 ? 1 : 2;
- if (Gj === 0 && (Gj = tj),
- kg.transition !== 0) {
- Hj !== 0 && (Hj = vj !== null ? vj.pendingLanes : 0),
- a = Gj;
- var e = 4186112 & ~Hj;
- return e &= -e,
- e === 0 && (a = 4186112 & ~a,
- e = a & -a,
- e === 0 && (e = 8192)),
- e
- }
- return a = eg(),
- (X & 4) !== 0 && a === 98 ? a = Xc(12, Gj) : (a = Sc(a),
- a = Xc(a, Gj)),
- a
- }
- function Jg(a, e, i) {
- if (50 < Dj)
- throw Dj = 0,
- Ej = null,
- Error(y(185));
- if (a = Kj(a, e),
- a === null)
- return null;
- $c(a, e, i),
- a === U && (Hi |= e,
- V === 4 && Ii(a, W));
- var o = eg();
- e === 1 ? (X & 8) !== 0 && (X & 48) === 0 ? Lj(a) : (Mj(a, i),
- X === 0 && (wj(),
- ig())) : ((X & 4) === 0 || o !== 98 && o !== 99 || (Cj === null ? Cj = new Set([a]) : Cj.add(a)),
- Mj(a, i)),
- vj = a
- }
- function Kj(a, e) {
- a.lanes |= e;
- var i = a.alternate;
- for (i !== null && (i.lanes |= e),
- i = a,
- a = a.return; a !== null; )
- a.childLanes |= e,
- i = a.alternate,
- i !== null && (i.childLanes |= e),
- i = a,
- a = a.return;
- return i.tag === 3 ? i.stateNode : null
- }
- function Mj(a, e) {
- for (var i = a.callbackNode, o = a.suspendedLanes, s = a.pingedLanes, c = a.expirationTimes, d = a.pendingLanes; 0 < d; ) {
- var _ = 31 - Vc(d)
- , b = 1 << _
- , k = c[_];
- if (k === -1) {
- if ((b & o) === 0 || (b & s) !== 0) {
- k = e,
- Rc(b);
- var j = F;
- c[_] = 10 <= j ? k + 250 : 6 <= j ? k + 5e3 : -1
- }
- } else
- k <= e && (a.expiredLanes |= b);
- d &= ~b
- }
- if (o = Uc(a, a === U ? W : 0),
- e = F,
- o === 0)
- i !== null && (i !== Zf && Pf(i),
- a.callbackNode = null,
- a.callbackPriority = 0);
- else {
- if (i !== null) {
- if (a.callbackPriority === e)
- return;
- i !== Zf && Pf(i)
- }
- e === 15 ? (i = Lj.bind(null, a),
- ag === null ? (ag = [i],
- bg = Of(Uf, jg)) : ag.push(i),
- i = Zf) : e === 14 ? i = hg(99, Lj.bind(null, a)) : (i = Tc(e),
- i = hg(i, Nj.bind(null, a))),
- a.callbackPriority = e,
- a.callbackNode = i
- }
- }
- function Nj(a) {
- if (Fj = -1,
- Hj = Gj = 0,
- (X & 48) !== 0)
- throw Error(y(327));
- var e = a.callbackNode;
- if (Oj() && a.callbackNode !== e)
- return null;
- var i = Uc(a, a === U ? W : 0);
- if (i === 0)
- return null;
- var o = i
- , s = X;
- X |= 16;
- var c = Pj();
- (U !== a || W !== o) && (wj(),
- Qj(a, o));
- do
- try {
- Rj();
- break
- } catch (_) {
- Sj(a, _)
- }
- while (1);
- if (qg(),
- oj.current = c,
- X = s,
- Y !== null ? o = 0 : (U = null,
- W = 0,
- o = V),
- (tj & Hi) !== 0)
- Qj(a, 0);
- else if (o !== 0) {
- if (o === 2 && (X |= 64,
- a.hydrate && (a.hydrate = !1,
- qf(a.containerInfo)),
- i = Wc(a),
- i !== 0 && (o = Tj(a, i))),
- o === 1)
- throw e = sj,
- Qj(a, 0),
- Ii(a, i),
- Mj(a, O()),
- e;
- switch (a.finishedWork = a.current.alternate,
- a.finishedLanes = i,
- o) {
- case 0:
- case 1:
- throw Error(y(345));
- case 2:
- Uj(a);
- break;
- case 3:
- if (Ii(a, i),
- (i & 62914560) === i && (o = jj + 500 - O(),
- 10 < o)) {
- if (Uc(a, 0) !== 0)
- break;
- if (s = a.suspendedLanes,
- (s & i) !== i) {
- Hg(),
- a.pingedLanes |= a.suspendedLanes & s;
- break
- }
- a.timeoutHandle = of(Uj.bind(null, a), o);
- break
- }
- Uj(a);
- break;
- case 4:
- if (Ii(a, i),
- (i & 4186112) === i)
- break;
- for (o = a.eventTimes,
- s = -1; 0 < i; ) {
- var d = 31 - Vc(i);
- c = 1 << d,
- d = o[d],
- d > s && (s = d),
- i &= ~c
- }
- if (i = s,
- i = O() - i,
- i = (120 > i ? 120 : 480 > i ? 480 : 1080 > i ? 1080 : 1920 > i ? 1920 : 3e3 > i ? 3e3 : 4320 > i ? 4320 : 1960 * nj(i / 1960)) - i,
- 10 < i) {
- a.timeoutHandle = of(Uj.bind(null, a), i);
- break
- }
- Uj(a);
- break;
- case 5:
- Uj(a);
- break;
- default:
- throw Error(y(329))
- }
- }
- return Mj(a, O()),
- a.callbackNode === e ? Nj.bind(null, a) : null
- }
- function Ii(a, e) {
- for (e &= ~uj,
- e &= ~Hi,
- a.suspendedLanes |= e,
- a.pingedLanes &= ~e,
- a = a.expirationTimes; 0 < e; ) {
- var i = 31 - Vc(e)
- , o = 1 << i;
- a[i] = -1,
- e &= ~o
- }
- }
- function Lj(a) {
- if ((X & 48) !== 0)
- throw Error(y(327));
- if (Oj(),
- a === U && (a.expiredLanes & W) !== 0) {
- var e = W
- , i = Tj(a, e);
- (tj & Hi) !== 0 && (e = Uc(a, e),
- i = Tj(a, e))
- } else
- e = Uc(a, 0),
- i = Tj(a, e);
- if (a.tag !== 0 && i === 2 && (X |= 64,
- a.hydrate && (a.hydrate = !1,
- qf(a.containerInfo)),
- e = Wc(a),
- e !== 0 && (i = Tj(a, e))),
- i === 1)
- throw i = sj,
- Qj(a, 0),
- Ii(a, e),
- Mj(a, O()),
- i;
- return a.finishedWork = a.current.alternate,
- a.finishedLanes = e,
- Uj(a),
- Mj(a, O()),
- null
- }
- function Vj() {
- if (Cj !== null) {
- var a = Cj;
- Cj = null,
- a.forEach(function(e) {
- e.expiredLanes |= 24 & e.pendingLanes,
- Mj(e, O())
- })
- }
- ig()
- }
- function Wj(a, e) {
- var i = X;
- X |= 1;
- try {
- return a(e)
- } finally {
- X = i,
- X === 0 && (wj(),
- ig())
- }
- }
- function Xj(a, e) {
- var i = X;
- X &= -2,
- X |= 8;
- try {
- return a(e)
- } finally {
- X = i,
- X === 0 && (wj(),
- ig())
- }
- }
- function ni(a, e) {
- I(rj, qj),
- qj |= e,
- tj |= e
- }
- function Ki() {
- qj = rj.current,
- H(rj)
- }
- function Qj(a, e) {
- a.finishedWork = null,
- a.finishedLanes = 0;
- var i = a.timeoutHandle;
- if (i !== -1 && (a.timeoutHandle = -1,
- pf(i)),
- Y !== null)
- for (i = Y.return; i !== null; ) {
- var o = i;
- switch (o.tag) {
- case 1:
- o = o.type.childContextTypes,
- o != null && Gf();
- break;
- case 3:
- fh(),
- H(N),
- H(M),
- uh();
- break;
- case 5:
- hh(o);
- break;
- case 4:
- fh();
- break;
- case 13:
- H(P);
- break;
- case 19:
- H(P);
- break;
- case 10:
- rg(o);
- break;
- case 23:
- case 24:
- Ki()
- }
- i = i.return
- }
- U = a,
- Y = Tg(a.current, null),
- W = qj = tj = e,
- V = 0,
- sj = null,
- uj = Hi = Dg = 0
- }
- function Sj(a, e) {
- do {
- var i = Y;
- try {
- if (qg(),
- vh.current = Gh,
- yh) {
- for (var o = R.memoizedState; o !== null; ) {
- var s = o.queue;
- s !== null && (s.pending = null),
- o = o.next
- }
- yh = !1
- }
- if (xh = 0,
- T = S = R = null,
- zh = !1,
- pj.current = null,
- i === null || i.return === null) {
- V = 1,
- sj = e,
- Y = null;
- break
- }
- e: {
- var c = a
- , d = i.return
- , _ = i
- , b = e;
- if (e = W,
- _.flags |= 2048,
- _.firstEffect = _.lastEffect = null,
- b !== null && typeof b == "object" && typeof b.then == "function") {
- var k = b;
- if ((_.mode & 2) === 0) {
- var j = _.alternate;
- j ? (_.updateQueue = j.updateQueue,
- _.memoizedState = j.memoizedState,
- _.lanes = j.lanes) : (_.updateQueue = null,
- _.memoizedState = null)
- }
- var $ = (P.current & 1) !== 0
- , _e = d;
- do {
- var et;
- if (et = _e.tag === 13) {
- var tt = _e.memoizedState;
- if (tt !== null)
- et = tt.dehydrated !== null;
- else {
- var rt = _e.memoizedProps;
- et = rt.fallback === void 0 ? !1 : rt.unstable_avoidThisFallback !== !0 ? !0 : !$
- }
- }
- if (et) {
- var it = _e.updateQueue;
- if (it === null) {
- var nt = new Set;
- nt.add(k),
- _e.updateQueue = nt
- } else
- it.add(k);
- if ((_e.mode & 2) === 0) {
- if (_e.flags |= 64,
- _.flags |= 16384,
- _.flags &= -2981,
- _.tag === 1)
- if (_.alternate === null)
- _.tag = 17;
- else {
- var ot = zg(-1, 1);
- ot.tag = 2,
- Ag(_, ot)
- }
- _.lanes |= 1;
- break e
- }
- b = void 0,
- _ = e;
- var at = c.pingCache;
- if (at === null ? (at = c.pingCache = new Oi,
- b = new Set,
- at.set(k, b)) : (b = at.get(k),
- b === void 0 && (b = new Set,
- at.set(k, b))),
- !b.has(_)) {
- b.add(_);
- var st = Yj.bind(null, c, k, _);
- k.then(st, st)
- }
- _e.flags |= 4096,
- _e.lanes = e;
- break e
- }
- _e = _e.return
- } while (_e !== null);
- b = Error((Ra(_.type) || "A React component") + ` suspended while rendering, but no fallback UI was specified.
- Add a <Suspense fallback=...> component higher in the tree to provide a loading indicator or placeholder to display.`)
- }
- V !== 5 && (V = 2),
- b = Mi(b, _),
- _e = d;
- do {
- switch (_e.tag) {
- case 3:
- c = b,
- _e.flags |= 4096,
- e &= -e,
- _e.lanes |= e;
- var ut = Pi(_e, c, e);
- Bg(_e, ut);
- break e;
- case 1:
- c = b;
- var ct = _e.type
- , lt = _e.stateNode;
- if ((_e.flags & 64) === 0 && (typeof ct.getDerivedStateFromError == "function" || lt !== null && typeof lt.componentDidCatch == "function" && (Ti === null || !Ti.has(lt)))) {
- _e.flags |= 4096,
- e &= -e,
- _e.lanes |= e;
- var ft = Si(_e, c, e);
- Bg(_e, ft);
- break e
- }
- }
- _e = _e.return
- } while (_e !== null)
- }
- Zj(i)
- } catch (ht) {
- e = ht,
- Y === i && i !== null && (Y = i = i.return);
- continue
- }
- break
- } while (1)
- }
- function Pj() {
- var a = oj.current;
- return oj.current = Gh,
- a === null ? Gh : a
- }
- function Tj(a, e) {
- var i = X;
- X |= 16;
- var o = Pj();
- U === a && W === e || Qj(a, e);
- do
- try {
- ak();
- break
- } catch (s) {
- Sj(a, s)
- }
- while (1);
- if (qg(),
- X = i,
- oj.current = o,
- Y !== null)
- throw Error(y(261));
- return U = null,
- W = 0,
- V
- }
- function ak() {
- for (; Y !== null; )
- bk(Y)
- }
- function Rj() {
- for (; Y !== null && !Qf(); )
- bk(Y)
- }
- function bk(a) {
- var e = ck(a.alternate, a, qj);
- a.memoizedProps = a.pendingProps,
- e === null ? Zj(a) : Y = e,
- pj.current = null
- }
- function Zj(a) {
- var e = a;
- do {
- var i = e.alternate;
- if (a = e.return,
- (e.flags & 2048) === 0) {
- if (i = Gi(i, e, qj),
- i !== null) {
- Y = i;
- return
- }
- if (i = e,
- i.tag !== 24 && i.tag !== 23 || i.memoizedState === null || (qj & 1073741824) !== 0 || (i.mode & 4) === 0) {
- for (var o = 0, s = i.child; s !== null; )
- o |= s.lanes | s.childLanes,
- s = s.sibling;
- i.childLanes = o
- }
- a !== null && (a.flags & 2048) === 0 && (a.firstEffect === null && (a.firstEffect = e.firstEffect),
- e.lastEffect !== null && (a.lastEffect !== null && (a.lastEffect.nextEffect = e.firstEffect),
- a.lastEffect = e.lastEffect),
- 1 < e.flags && (a.lastEffect !== null ? a.lastEffect.nextEffect = e : a.firstEffect = e,
- a.lastEffect = e))
- } else {
- if (i = Li(e),
- i !== null) {
- i.flags &= 2047,
- Y = i;
- return
- }
- a !== null && (a.firstEffect = a.lastEffect = null,
- a.flags |= 2048)
- }
- if (e = e.sibling,
- e !== null) {
- Y = e;
- return
- }
- Y = e = a
- } while (e !== null);
- V === 0 && (V = 5)
- }
- function Uj(a) {
- var e = eg();
- return gg(99, dk.bind(null, a, e)),
- null
- }
- function dk(a, e) {
- do
- Oj();
- while (yj !== null);
- if ((X & 48) !== 0)
- throw Error(y(327));
- var i = a.finishedWork;
- if (i === null)
- return null;
- if (a.finishedWork = null,
- a.finishedLanes = 0,
- i === a.current)
- throw Error(y(177));
- a.callbackNode = null;
- var o = i.lanes | i.childLanes
- , s = o
- , c = a.pendingLanes & ~s;
- a.pendingLanes = s,
- a.suspendedLanes = 0,
- a.pingedLanes = 0,
- a.expiredLanes &= s,
- a.mutableReadLanes &= s,
- a.entangledLanes &= s,
- s = a.entanglements;
- for (var d = a.eventTimes, _ = a.expirationTimes; 0 < c; ) {
- var b = 31 - Vc(c)
- , k = 1 << b;
- s[b] = 0,
- d[b] = -1,
- _[b] = -1,
- c &= ~k
- }
- if (Cj !== null && (o & 24) === 0 && Cj.has(a) && Cj.delete(a),
- a === U && (Y = U = null,
- W = 0),
- 1 < i.flags ? i.lastEffect !== null ? (i.lastEffect.nextEffect = i,
- o = i.firstEffect) : o = i : o = i.firstEffect,
- o !== null) {
- if (s = X,
- X |= 32,
- pj.current = null,
- kf = fd,
- d = Ne(),
- Oe(d)) {
- if ("selectionStart"in d)
- _ = {
- start: d.selectionStart,
- end: d.selectionEnd
- };
- else
- e: if (_ = (_ = d.ownerDocument) && _.defaultView || window,
- (k = _.getSelection && _.getSelection()) && k.rangeCount !== 0) {
- _ = k.anchorNode,
- c = k.anchorOffset,
- b = k.focusNode,
- k = k.focusOffset;
- try {
- _.nodeType,
- b.nodeType
- } catch {
- _ = null;
- break e
- }
- var j = 0
- , $ = -1
- , _e = -1
- , et = 0
- , tt = 0
- , rt = d
- , it = null;
- t: for (; ; ) {
- for (var nt; rt !== _ || c !== 0 && rt.nodeType !== 3 || ($ = j + c),
- rt !== b || k !== 0 && rt.nodeType !== 3 || (_e = j + k),
- rt.nodeType === 3 && (j += rt.nodeValue.length),
- (nt = rt.firstChild) !== null; )
- it = rt,
- rt = nt;
- for (; ; ) {
- if (rt === d)
- break t;
- if (it === _ && ++et === c && ($ = j),
- it === b && ++tt === k && (_e = j),
- (nt = rt.nextSibling) !== null)
- break;
- rt = it,
- it = rt.parentNode
- }
- rt = nt
- }
- _ = $ === -1 || _e === -1 ? null : {
- start: $,
- end: _e
- }
- } else
- _ = null;
- _ = _ || {
- start: 0,
- end: 0
- }
- } else
- _ = null;
- lf = {
- focusedElem: d,
- selectionRange: _
- },
- fd = !1,
- Ij = null,
- Jj = !1,
- Z = o;
- do
- try {
- ek()
- } catch (ht) {
- if (Z === null)
- throw Error(y(330));
- Wi(Z, ht),
- Z = Z.nextEffect
- }
- while (Z !== null);
- Ij = null,
- Z = o;
- do
- try {
- for (d = a; Z !== null; ) {
- var ot = Z.flags;
- if (ot & 16 && pb(Z.stateNode, ""),
- ot & 128) {
- var at = Z.alternate;
- if (at !== null) {
- var st = at.ref;
- st !== null && (typeof st == "function" ? st(null) : st.current = null)
- }
- }
- switch (ot & 1038) {
- case 2:
- fj(Z),
- Z.flags &= -3;
- break;
- case 6:
- fj(Z),
- Z.flags &= -3,
- ij(Z.alternate, Z);
- break;
- case 1024:
- Z.flags &= -1025;
- break;
- case 1028:
- Z.flags &= -1025,
- ij(Z.alternate, Z);
- break;
- case 4:
- ij(Z.alternate, Z);
- break;
- case 8:
- _ = Z,
- cj(d, _);
- var ut = _.alternate;
- dj(_),
- ut !== null && dj(ut)
- }
- Z = Z.nextEffect
- }
- } catch (ht) {
- if (Z === null)
- throw Error(y(330));
- Wi(Z, ht),
- Z = Z.nextEffect
- }
- while (Z !== null);
- if (st = lf,
- at = Ne(),
- ot = st.focusedElem,
- d = st.selectionRange,
- at !== ot && ot && ot.ownerDocument && Me(ot.ownerDocument.documentElement, ot)) {
- for (d !== null && Oe(ot) && (at = d.start,
- st = d.end,
- st === void 0 && (st = at),
- "selectionStart"in ot ? (ot.selectionStart = at,
- ot.selectionEnd = Math.min(st, ot.value.length)) : (st = (at = ot.ownerDocument || document) && at.defaultView || window,
- st.getSelection && (st = st.getSelection(),
- _ = ot.textContent.length,
- ut = Math.min(d.start, _),
- d = d.end === void 0 ? ut : Math.min(d.end, _),
- !st.extend && ut > d && (_ = d,
- d = ut,
- ut = _),
- _ = Le(ot, ut),
- c = Le(ot, d),
- _ && c && (st.rangeCount !== 1 || st.anchorNode !== _.node || st.anchorOffset !== _.offset || st.focusNode !== c.node || st.focusOffset !== c.offset) && (at = at.createRange(),
- at.setStart(_.node, _.offset),
- st.removeAllRanges(),
- ut > d ? (st.addRange(at),
- st.extend(c.node, c.offset)) : (at.setEnd(c.node, c.offset),
- st.addRange(at)))))),
- at = [],
- st = ot; st = st.parentNode; )
- st.nodeType === 1 && at.push({
- element: st,
- left: st.scrollLeft,
- top: st.scrollTop
- });
- for (typeof ot.focus == "function" && ot.focus(),
- ot = 0; ot < at.length; ot++)
- st = at[ot],
- st.element.scrollLeft = st.left,
- st.element.scrollTop = st.top
- }
- fd = !!kf,
- lf = kf = null,
- a.current = i,
- Z = o;
- do
- try {
- for (ot = a; Z !== null; ) {
- var ct = Z.flags;
- if (ct & 36 && Yi(ot, Z.alternate, Z),
- ct & 128) {
- at = void 0;
- var lt = Z.ref;
- if (lt !== null) {
- var ft = Z.stateNode;
- switch (Z.tag) {
- case 5:
- at = ft;
- break;
- default:
- at = ft
- }
- typeof lt == "function" ? lt(at) : lt.current = at
- }
- }
- Z = Z.nextEffect
- }
- } catch (ht) {
- if (Z === null)
- throw Error(y(330));
- Wi(Z, ht),
- Z = Z.nextEffect
- }
- while (Z !== null);
- Z = null,
- $f(),
- X = s
- } else
- a.current = i;
- if (xj)
- xj = !1,
- yj = a,
- zj = e;
- else
- for (Z = o; Z !== null; )
- e = Z.nextEffect,
- Z.nextEffect = null,
- Z.flags & 8 && (ct = Z,
- ct.sibling = null,
- ct.stateNode = null),
- Z = e;
- if (o = a.pendingLanes,
- o === 0 && (Ti = null),
- o === 1 ? a === Ej ? Dj++ : (Dj = 0,
- Ej = a) : Dj = 0,
- i = i.stateNode,
- Mf && typeof Mf.onCommitFiberRoot == "function")
- try {
- Mf.onCommitFiberRoot(Lf, i, void 0, (i.current.flags & 64) === 64)
- } catch {}
- if (Mj(a, O()),
- Qi)
- throw Qi = !1,
- a = Ri,
- Ri = null,
- a;
- return (X & 8) !== 0 || ig(),
- null
- }
- function ek() {
- for (; Z !== null; ) {
- var a = Z.alternate;
- Jj || Ij === null || ((Z.flags & 8) !== 0 ? dc(Z, Ij) && (Jj = !0) : Z.tag === 13 && mj(a, Z) && dc(Z, Ij) && (Jj = !0));
- var e = Z.flags;
- (e & 256) !== 0 && Xi(a, Z),
- (e & 512) === 0 || xj || (xj = !0,
- hg(97, function() {
- return Oj(),
- null
- })),
- Z = Z.nextEffect
- }
- }
- function Oj() {
- if (zj !== 90) {
- var a = 97 < zj ? 97 : zj;
- return zj = 90,
- gg(a, fk)
- }
- return !1
- }
- function $i(a, e) {
- Aj.push(e, a),
- xj || (xj = !0,
- hg(97, function() {
- return Oj(),
- null
- }))
- }
- function Zi(a, e) {
- Bj.push(e, a),
- xj || (xj = !0,
- hg(97, function() {
- return Oj(),
- null
- }))
- }
- function fk() {
- if (yj === null)
- return !1;
- var a = yj;
- if (yj = null,
- (X & 48) !== 0)
- throw Error(y(331));
- var e = X;
- X |= 32;
- var i = Bj;
- Bj = [];
- for (var o = 0; o < i.length; o += 2) {
- var s = i[o]
- , c = i[o + 1]
- , d = s.destroy;
- if (s.destroy = void 0,
- typeof d == "function")
- try {
- d()
- } catch (b) {
- if (c === null)
- throw Error(y(330));
- Wi(c, b)
- }
- }
- for (i = Aj,
- Aj = [],
- o = 0; o < i.length; o += 2) {
- s = i[o],
- c = i[o + 1];
- try {
- var _ = s.create;
- s.destroy = _()
- } catch (b) {
- if (c === null)
- throw Error(y(330));
- Wi(c, b)
- }
- }
- for (_ = a.current.firstEffect; _ !== null; )
- a = _.nextEffect,
- _.nextEffect = null,
- _.flags & 8 && (_.sibling = null,
- _.stateNode = null),
- _ = a;
- return X = e,
- ig(),
- !0
- }
- function gk(a, e, i) {
- e = Mi(i, e),
- e = Pi(a, e, 1),
- Ag(a, e),
- e = Hg(),
- a = Kj(a, 1),
- a !== null && ($c(a, 1, e),
- Mj(a, e))
- }
- function Wi(a, e) {
- if (a.tag === 3)
- gk(a, a, e);
- else
- for (var i = a.return; i !== null; ) {
- if (i.tag === 3) {
- gk(i, a, e);
- break
- } else if (i.tag === 1) {
- var o = i.stateNode;
- if (typeof i.type.getDerivedStateFromError == "function" || typeof o.componentDidCatch == "function" && (Ti === null || !Ti.has(o))) {
- a = Mi(e, a);
- var s = Si(i, a, 1);
- if (Ag(i, s),
- s = Hg(),
- i = Kj(i, 1),
- i !== null)
- $c(i, 1, s),
- Mj(i, s);
- else if (typeof o.componentDidCatch == "function" && (Ti === null || !Ti.has(o)))
- try {
- o.componentDidCatch(e, a)
- } catch {}
- break
- }
- }
- i = i.return
- }
- }
- function Yj(a, e, i) {
- var o = a.pingCache;
- o !== null && o.delete(e),
- e = Hg(),
- a.pingedLanes |= a.suspendedLanes & i,
- U === a && (W & i) === i && (V === 4 || V === 3 && (W & 62914560) === W && 500 > O() - jj ? Qj(a, 0) : uj |= i),
- Mj(a, e)
- }
- function lj(a, e) {
- var i = a.stateNode;
- i !== null && i.delete(e),
- e = 0,
- e === 0 && (e = a.mode,
- (e & 2) === 0 ? e = 1 : (e & 4) === 0 ? e = eg() === 99 ? 1 : 2 : (Gj === 0 && (Gj = tj),
- e = Yc(62914560 & ~Gj),
- e === 0 && (e = 4194304))),
- i = Hg(),
- a = Kj(a, e),
- a !== null && ($c(a, e, i),
- Mj(a, i))
- }
- var ck;
- ck = function(a, e, i) {
- var o = e.lanes;
- if (a !== null)
- if (a.memoizedProps !== e.pendingProps || N.current)
- ug = !0;
- else if ((i & o) !== 0)
- ug = (a.flags & 16384) !== 0;
- else {
- switch (ug = !1,
- e.tag) {
- case 3:
- ri(e),
- sh();
- break;
- case 5:
- gh(e);
- break;
- case 1:
- Ff(e.type) && Jf(e);
- break;
- case 4:
- eh(e, e.stateNode.containerInfo);
- break;
- case 10:
- o = e.memoizedProps.value;
- var s = e.type._context;
- I(mg, s._currentValue),
- s._currentValue = o;
- break;
- case 13:
- if (e.memoizedState !== null)
- return (i & e.child.childLanes) !== 0 ? ti(a, e, i) : (I(P, P.current & 1),
- e = hi(a, e, i),
- e !== null ? e.sibling : null);
- I(P, P.current & 1);
- break;
- case 19:
- if (o = (i & e.childLanes) !== 0,
- (a.flags & 64) !== 0) {
- if (o)
- return Ai(a, e, i);
- e.flags |= 64
- }
- if (s = e.memoizedState,
- s !== null && (s.rendering = null,
- s.tail = null,
- s.lastEffect = null),
- I(P, P.current),
- o)
- break;
- return null;
- case 23:
- case 24:
- return e.lanes = 0,
- mi(a, e, i)
- }
- return hi(a, e, i)
- }
- else
- ug = !1;
- switch (e.lanes = 0,
- e.tag) {
- case 2:
- if (o = e.type,
- a !== null && (a.alternate = null,
- e.alternate = null,
- e.flags |= 2),
- a = e.pendingProps,
- s = Ef(e, M.current),
- tg(e, i),
- s = Ch(null, e, o, a, s, i),
- e.flags |= 1,
- typeof s == "object" && s !== null && typeof s.render == "function" && s.$$typeof === void 0) {
- if (e.tag = 1,
- e.memoizedState = null,
- e.updateQueue = null,
- Ff(o)) {
- var c = !0;
- Jf(e)
- } else
- c = !1;
- e.memoizedState = s.state !== null && s.state !== void 0 ? s.state : null,
- xg(e);
- var d = o.getDerivedStateFromProps;
- typeof d == "function" && Gg(e, o, d, a),
- s.updater = Kg,
- e.stateNode = s,
- s._reactInternals = e,
- Og(e, o, a, i),
- e = qi(null, e, o, !0, c, i)
- } else
- e.tag = 0,
- fi(null, e, s, i),
- e = e.child;
- return e;
- case 16:
- s = e.elementType;
- e: {
- switch (a !== null && (a.alternate = null,
- e.alternate = null,
- e.flags |= 2),
- a = e.pendingProps,
- c = s._init,
- s = c(s._payload),
- e.type = s,
- c = e.tag = hk(s),
- a = lg(s, a),
- c) {
- case 0:
- e = li(null, e, s, a, i);
- break e;
- case 1:
- e = pi(null, e, s, a, i);
- break e;
- case 11:
- e = gi(null, e, s, a, i);
- break e;
- case 14:
- e = ii(null, e, s, lg(s.type, a), o, i);
- break e
- }
- throw Error(y(306, s, ""))
- }
- return e;
- case 0:
- return o = e.type,
- s = e.pendingProps,
- s = e.elementType === o ? s : lg(o, s),
- li(a, e, o, s, i);
- case 1:
- return o = e.type,
- s = e.pendingProps,
- s = e.elementType === o ? s : lg(o, s),
- pi(a, e, o, s, i);
- case 3:
- if (ri(e),
- o = e.updateQueue,
- a === null || o === null)
- throw Error(y(282));
- if (o = e.pendingProps,
- s = e.memoizedState,
- s = s !== null ? s.element : null,
- yg(a, e),
- Cg(e, o, null, i),
- o = e.memoizedState.element,
- o === s)
- sh(),
- e = hi(a, e, i);
- else {
- if (s = e.stateNode,
- (c = s.hydrate) && (kh = rf(e.stateNode.containerInfo.firstChild),
- jh = e,
- c = lh = !0),
- c) {
- if (a = s.mutableSourceEagerHydrationData,
- a != null)
- for (s = 0; s < a.length; s += 2)
- c = a[s],
- c._workInProgressVersionPrimary = a[s + 1],
- th.push(c);
- for (i = Zg(e, null, o, i),
- e.child = i; i; )
- i.flags = i.flags & -3 | 1024,
- i = i.sibling
- } else
- fi(a, e, o, i),
- sh();
- e = e.child
- }
- return e;
- case 5:
- return gh(e),
- a === null && ph(e),
- o = e.type,
- s = e.pendingProps,
- c = a !== null ? a.memoizedProps : null,
- d = s.children,
- nf(o, s) ? d = null : c !== null && nf(o, c) && (e.flags |= 16),
- oi(a, e),
- fi(a, e, d, i),
- e.child;
- case 6:
- return a === null && ph(e),
- null;
- case 13:
- return ti(a, e, i);
- case 4:
- return eh(e, e.stateNode.containerInfo),
- o = e.pendingProps,
- a === null ? e.child = Yg(e, null, o, i) : fi(a, e, o, i),
- e.child;
- case 11:
- return o = e.type,
- s = e.pendingProps,
- s = e.elementType === o ? s : lg(o, s),
- gi(a, e, o, s, i);
- case 7:
- return fi(a, e, e.pendingProps, i),
- e.child;
- case 8:
- return fi(a, e, e.pendingProps.children, i),
- e.child;
- case 12:
- return fi(a, e, e.pendingProps.children, i),
- e.child;
- case 10:
- e: {
- o = e.type._context,
- s = e.pendingProps,
- d = e.memoizedProps,
- c = s.value;
- var _ = e.type._context;
- if (I(mg, _._currentValue),
- _._currentValue = c,
- d !== null)
- if (_ = d.value,
- c = He(_, c) ? 0 : (typeof o._calculateChangedBits == "function" ? o._calculateChangedBits(_, c) : 1073741823) | 0,
- c === 0) {
- if (d.children === s.children && !N.current) {
- e = hi(a, e, i);
- break e
- }
- } else
- for (_ = e.child,
- _ !== null && (_.return = e); _ !== null; ) {
- var b = _.dependencies;
- if (b !== null) {
- d = _.child;
- for (var k = b.firstContext; k !== null; ) {
- if (k.context === o && (k.observedBits & c) !== 0) {
- _.tag === 1 && (k = zg(-1, i & -i),
- k.tag = 2,
- Ag(_, k)),
- _.lanes |= i,
- k = _.alternate,
- k !== null && (k.lanes |= i),
- sg(_.return, i),
- b.lanes |= i;
- break
- }
- k = k.next
- }
- } else
- d = _.tag === 10 && _.type === e.type ? null : _.child;
- if (d !== null)
- d.return = _;
- else
- for (d = _; d !== null; ) {
- if (d === e) {
- d = null;
- break
- }
- if (_ = d.sibling,
- _ !== null) {
- _.return = d.return,
- d = _;
- break
- }
- d = d.return
- }
- _ = d
- }
- fi(a, e, s.children, i),
- e = e.child
- }
- return e;
- case 9:
- return s = e.type,
- c = e.pendingProps,
- o = c.children,
- tg(e, i),
- s = vg(s, c.unstable_observedBits),
- o = o(s),
- e.flags |= 1,
- fi(a, e, o, i),
- e.child;
- case 14:
- return s = e.type,
- c = lg(s, e.pendingProps),
- c = lg(s.type, c),
- ii(a, e, s, c, o, i);
- case 15:
- return ki(a, e, e.type, e.pendingProps, o, i);
- case 17:
- return o = e.type,
- s = e.pendingProps,
- s = e.elementType === o ? s : lg(o, s),
- a !== null && (a.alternate = null,
- e.alternate = null,
- e.flags |= 2),
- e.tag = 1,
- Ff(o) ? (a = !0,
- Jf(e)) : a = !1,
- tg(e, i),
- Mg(e, o, s),
- Og(e, o, s, i),
- qi(null, e, o, !0, a, i);
- case 19:
- return Ai(a, e, i);
- case 23:
- return mi(a, e, i);
- case 24:
- return mi(a, e, i)
- }
- throw Error(y(156, e.tag))
- }
- ;
- function ik(a, e, i, o) {
- this.tag = a,
- this.key = i,
- this.sibling = this.child = this.return = this.stateNode = this.type = this.elementType = null,
- this.index = 0,
- this.ref = null,
- this.pendingProps = e,
- this.dependencies = this.memoizedState = this.updateQueue = this.memoizedProps = null,
- this.mode = o,
- this.flags = 0,
- this.lastEffect = this.firstEffect = this.nextEffect = null,
- this.childLanes = this.lanes = 0,
- this.alternate = null
- }
- function nh(a, e, i, o) {
- return new ik(a,e,i,o)
- }
- function ji(a) {
- return a = a.prototype,
- !(!a || !a.isReactComponent)
- }
- function hk(a) {
- if (typeof a == "function")
- return ji(a) ? 1 : 0;
- if (a != null) {
- if (a = a.$$typeof,
- a === Aa)
- return 11;
- if (a === Da)
- return 14
- }
- return 2
- }
- function Tg(a, e) {
- var i = a.alternate;
- return i === null ? (i = nh(a.tag, e, a.key, a.mode),
- i.elementType = a.elementType,
- i.type = a.type,
- i.stateNode = a.stateNode,
- i.alternate = a,
- a.alternate = i) : (i.pendingProps = e,
- i.type = a.type,
- i.flags = 0,
- i.nextEffect = null,
- i.firstEffect = null,
- i.lastEffect = null),
- i.childLanes = a.childLanes,
- i.lanes = a.lanes,
- i.child = a.child,
- i.memoizedProps = a.memoizedProps,
- i.memoizedState = a.memoizedState,
- i.updateQueue = a.updateQueue,
- e = a.dependencies,
- i.dependencies = e === null ? null : {
- lanes: e.lanes,
- firstContext: e.firstContext
- },
- i.sibling = a.sibling,
- i.index = a.index,
- i.ref = a.ref,
- i
- }
- function Vg(a, e, i, o, s, c) {
- var d = 2;
- if (o = a,
- typeof a == "function")
- ji(a) && (d = 1);
- else if (typeof a == "string")
- d = 5;
- else
- e: switch (a) {
- case ua:
- return Xg(i.children, s, c, e);
- case Ha:
- d = 8,
- s |= 16;
- break;
- case wa:
- d = 8,
- s |= 1;
- break;
- case xa:
- return a = nh(12, i, e, s | 8),
- a.elementType = xa,
- a.type = xa,
- a.lanes = c,
- a;
- case Ba:
- return a = nh(13, i, e, s),
- a.type = Ba,
- a.elementType = Ba,
- a.lanes = c,
- a;
- case Ca:
- return a = nh(19, i, e, s),
- a.elementType = Ca,
- a.lanes = c,
- a;
- case Ia:
- return vi(i, s, c, e);
- case Ja:
- return a = nh(24, i, e, s),
- a.elementType = Ja,
- a.lanes = c,
- a;
- default:
- if (typeof a == "object" && a !== null)
- switch (a.$$typeof) {
- case ya:
- d = 10;
- break e;
- case za:
- d = 9;
- break e;
- case Aa:
- d = 11;
- break e;
- case Da:
- d = 14;
- break e;
- case Ea:
- d = 16,
- o = null;
- break e;
- case Fa:
- d = 22;
- break e
- }
- throw Error(y(130, a == null ? a : typeof a, ""))
- }
- return e = nh(d, i, e, s),
- e.elementType = a,
- e.type = o,
- e.lanes = c,
- e
- }
- function Xg(a, e, i, o) {
- return a = nh(7, a, o, e),
- a.lanes = i,
- a
- }
- function vi(a, e, i, o) {
- return a = nh(23, a, o, e),
- a.elementType = Ia,
- a.lanes = i,
- a
- }
- function Ug(a, e, i) {
- return a = nh(6, a, null, e),
- a.lanes = i,
- a
- }
- function Wg(a, e, i) {
- return e = nh(4, a.children !== null ? a.children : [], a.key, e),
- e.lanes = i,
- e.stateNode = {
- containerInfo: a.containerInfo,
- pendingChildren: null,
- implementation: a.implementation
- },
- e
- }
- function jk(a, e, i) {
- this.tag = e,
- this.containerInfo = a,
- this.finishedWork = this.pingCache = this.current = this.pendingChildren = null,
- this.timeoutHandle = -1,
- this.pendingContext = this.context = null,
- this.hydrate = i,
- this.callbackNode = null,
- this.callbackPriority = 0,
- this.eventTimes = Zc(0),
- this.expirationTimes = Zc(-1),
- this.entangledLanes = this.finishedLanes = this.mutableReadLanes = this.expiredLanes = this.pingedLanes = this.suspendedLanes = this.pendingLanes = 0,
- this.entanglements = Zc(0),
- this.mutableSourceEagerHydrationData = null
- }
- function kk(a, e, i) {
- var o = 3 < arguments.length && arguments[3] !== void 0 ? arguments[3] : null;
- return {
- $$typeof: ta,
- key: o == null ? null : "" + o,
- children: a,
- containerInfo: e,
- implementation: i
- }
- }
- function lk(a, e, i, o) {
- var s = e.current
- , c = Hg()
- , d = Ig(s);
- e: if (i) {
- i = i._reactInternals;
- t: {
- if (Zb(i) !== i || i.tag !== 1)
- throw Error(y(170));
- var _ = i;
- do {
- switch (_.tag) {
- case 3:
- _ = _.stateNode.context;
- break t;
- case 1:
- if (Ff(_.type)) {
- _ = _.stateNode.__reactInternalMemoizedMergedChildContext;
- break t
- }
- }
- _ = _.return
- } while (_ !== null);
- throw Error(y(171))
- }
- if (i.tag === 1) {
- var b = i.type;
- if (Ff(b)) {
- i = If(i, b, _);
- break e
- }
- }
- i = _
- } else
- i = Cf;
- return e.context === null ? e.context = i : e.pendingContext = i,
- e = zg(c, d),
- e.payload = {
- element: a
- },
- o = o === void 0 ? null : o,
- o !== null && (e.callback = o),
- Ag(s, e),
- Jg(s, d, c),
- d
- }
- function mk(a) {
- if (a = a.current,
- !a.child)
- return null;
- switch (a.child.tag) {
- case 5:
- return a.child.stateNode;
- default:
- return a.child.stateNode
- }
- }
- function nk(a, e) {
- if (a = a.memoizedState,
- a !== null && a.dehydrated !== null) {
- var i = a.retryLane;
- a.retryLane = i !== 0 && i < e ? i : e
- }
- }
- function ok(a, e) {
- nk(a, e),
- (a = a.alternate) && nk(a, e)
- }
- function pk() {
- return null
- }
- function qk(a, e, i) {
- var o = i != null && i.hydrationOptions != null && i.hydrationOptions.mutableSources || null;
- if (i = new jk(a,e,i != null && i.hydrate === !0),
- e = nh(3, null, null, e === 2 ? 7 : e === 1 ? 3 : 0),
- i.current = e,
- e.stateNode = i,
- xg(e),
- a[ff] = i.current,
- cf(a.nodeType === 8 ? a.parentNode : a),
- o)
- for (a = 0; a < o.length; a++) {
- e = o[a];
- var s = e._getVersion;
- s = s(e._source),
- i.mutableSourceEagerHydrationData == null ? i.mutableSourceEagerHydrationData = [e, s] : i.mutableSourceEagerHydrationData.push(e, s)
- }
- this._internalRoot = i
- }
- qk.prototype.render = function(a) {
- lk(a, this._internalRoot, null, null)
- }
- ;
- qk.prototype.unmount = function() {
- var a = this._internalRoot
- , e = a.containerInfo;
- lk(null, a, null, function() {
- e[ff] = null
- })
- }
- ;
- function rk(a) {
- return !(!a || a.nodeType !== 1 && a.nodeType !== 9 && a.nodeType !== 11 && (a.nodeType !== 8 || a.nodeValue !== " react-mount-point-unstable "))
- }
- function sk(a, e) {
- if (e || (e = a ? a.nodeType === 9 ? a.documentElement : a.firstChild : null,
- e = !(!e || e.nodeType !== 1 || !e.hasAttribute("data-reactroot"))),
- !e)
- for (var i; i = a.lastChild; )
- a.removeChild(i);
- return new qk(a,0,e ? {
- hydrate: !0
- } : void 0)
- }
- function tk(a, e, i, o, s) {
- var c = i._reactRootContainer;
- if (c) {
- var d = c._internalRoot;
- if (typeof s == "function") {
- var _ = s;
- s = function() {
- var k = mk(d);
- _.call(k)
- }
- }
- lk(e, d, a, s)
- } else {
- if (c = i._reactRootContainer = sk(i, o),
- d = c._internalRoot,
- typeof s == "function") {
- var b = s;
- s = function() {
- var k = mk(d);
- b.call(k)
- }
- }
- Xj(function() {
- lk(e, d, a, s)
- })
- }
- return mk(d)
- }
- ec = function(a) {
- if (a.tag === 13) {
- var e = Hg();
- Jg(a, 4, e),
- ok(a, 4)
- }
- }
- ;
- fc = function(a) {
- if (a.tag === 13) {
- var e = Hg();
- Jg(a, 67108864, e),
- ok(a, 67108864)
- }
- }
- ;
- gc = function(a) {
- if (a.tag === 13) {
- var e = Hg()
- , i = Ig(a);
- Jg(a, i, e),
- ok(a, i)
- }
- }
- ;
- hc = function(a, e) {
- return e()
- }
- ;
- yb = function(a, e, i) {
- switch (e) {
- case "input":
- if (ab(a, i),
- e = i.name,
- i.type === "radio" && e != null) {
- for (i = a; i.parentNode; )
- i = i.parentNode;
- for (i = i.querySelectorAll("input[name=" + JSON.stringify("" + e) + '][type="radio"]'),
- e = 0; e < i.length; e++) {
- var o = i[e];
- if (o !== a && o.form === a.form) {
- var s = Db(o);
- if (!s)
- throw Error(y(90));
- Wa(o),
- ab(o, s)
- }
- }
- }
- break;
- case "textarea":
- ib(a, i);
- break;
- case "select":
- e = i.value,
- e != null && fb(a, !!i.multiple, e, !1)
- }
- }
- ;
- Gb = Wj;
- Hb = function(a, e, i, o, s) {
- var c = X;
- X |= 4;
- try {
- return gg(98, a.bind(null, e, i, o, s))
- } finally {
- X = c,
- X === 0 && (wj(),
- ig())
- }
- }
- ;
- Ib = function() {
- (X & 49) === 0 && (Vj(),
- Oj())
- }
- ;
- Jb = function(a, e) {
- var i = X;
- X |= 2;
- try {
- return a(e)
- } finally {
- X = i,
- X === 0 && (wj(),
- ig())
- }
- }
- ;
- function uk(a, e) {
- var i = 2 < arguments.length && arguments[2] !== void 0 ? arguments[2] : null;
- if (!rk(e))
- throw Error(y(200));
- return kk(a, e, null, i)
- }
- var vk = {
- Events: [Cb, ue, Db, Eb, Fb, Oj, {
- current: !1
- }]
- }
- , wk = {
- findFiberByHostInstance: wc,
- bundleType: 0,
- version: "17.0.2",
- rendererPackageName: "react-dom"
- }
- , xk = {
- bundleType: wk.bundleType,
- version: wk.version,
- rendererPackageName: wk.rendererPackageName,
- rendererConfig: wk.rendererConfig,
- overrideHookState: null,
- overrideHookStateDeletePath: null,
- overrideHookStateRenamePath: null,
- overrideProps: null,
- overridePropsDeletePath: null,
- overridePropsRenamePath: null,
- setSuspenseHandler: null,
- scheduleUpdate: null,
- currentDispatcherRef: ra.ReactCurrentDispatcher,
- findHostInstanceByFiber: function(a) {
- return a = cc(a),
- a === null ? null : a.stateNode
- },
- findFiberByHostInstance: wk.findFiberByHostInstance || pk,
- findHostInstancesForRefresh: null,
- scheduleRefresh: null,
- scheduleRoot: null,
- setRefreshHandler: null,
- getCurrentFiber: null
- };
- if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ != "undefined") {
- var yk = __REACT_DEVTOOLS_GLOBAL_HOOK__;
- if (!yk.isDisabled && yk.supportsFiber)
- try {
- Lf = yk.inject(xk),
- Mf = yk
- } catch {}
- }
- reactDom_production_min.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = vk;
- reactDom_production_min.createPortal = uk;
- reactDom_production_min.findDOMNode = function(a) {
- if (a == null)
- return null;
- if (a.nodeType === 1)
- return a;
- var e = a._reactInternals;
- if (e === void 0)
- throw typeof a.render == "function" ? Error(y(188)) : Error(y(268, Object.keys(a)));
- return a = cc(e),
- a = a === null ? null : a.stateNode,
- a
- }
- ;
- reactDom_production_min.flushSync = function(a, e) {
- var i = X;
- if ((i & 48) !== 0)
- return a(e);
- X |= 1;
- try {
- if (a)
- return gg(99, a.bind(null, e))
- } finally {
- X = i,
- ig()
- }
- }
- ;
- reactDom_production_min.hydrate = function(a, e, i) {
- if (!rk(e))
- throw Error(y(200));
- return tk(null, a, e, !0, i)
- }
- ;
- reactDom_production_min.render = function(a, e, i) {
- if (!rk(e))
- throw Error(y(200));
- return tk(null, a, e, !1, i)
- }
- ;
- reactDom_production_min.unmountComponentAtNode = function(a) {
- if (!rk(a))
- throw Error(y(40));
- return a._reactRootContainer ? (Xj(function() {
- tk(null, null, a, !1, function() {
- a._reactRootContainer = null,
- a[ff] = null
- })
- }),
- !0) : !1
- }
- ;
- reactDom_production_min.unstable_batchedUpdates = Wj;
- reactDom_production_min.unstable_createPortal = function(a, e) {
- return uk(a, e, 2 < arguments.length && arguments[2] !== void 0 ? arguments[2] : null)
- }
- ;
- reactDom_production_min.unstable_renderSubtreeIntoContainer = function(a, e, i, o) {
- if (!rk(i))
- throw Error(y(200));
- if (a == null || a._reactInternals === void 0)
- throw Error(y(38));
- return tk(a, e, i, !1, o)
- }
- ;
- reactDom_production_min.version = "17.0.2";
- function checkDCE() {
- if (!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ == "undefined" || typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE != "function"))
- try {
- __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(checkDCE)
- } catch (a) {
- console.error(a)
- }
- }
- checkDCE(),
- reactDom.exports = reactDom_production_min;
- var ReactDOM = reactDom.exports;
- let logDisabled_ = !0
- , deprecationWarnings_ = !0;
- function extractVersion(a, e, i) {
- const o = a.match(e);
- return o && o.length >= i && parseInt(o[i], 10)
- }
- function wrapPeerConnectionEvent(a, e, i) {
- if (!a.RTCPeerConnection)
- return;
- const o = a.RTCPeerConnection.prototype
- , s = o.addEventListener;
- o.addEventListener = function(d, _) {
- if (d !== e)
- return s.apply(this, arguments);
- const b = k=>{
- const j = i(k);
- j && (_.handleEvent ? _.handleEvent(j) : _(j))
- }
- ;
- return this._eventMap = this._eventMap || {},
- this._eventMap[e] || (this._eventMap[e] = new Map),
- this._eventMap[e].set(_, b),
- s.apply(this, [d, b])
- }
- ;
- const c = o.removeEventListener;
- o.removeEventListener = function(d, _) {
- if (d !== e || !this._eventMap || !this._eventMap[e])
- return c.apply(this, arguments);
- if (!this._eventMap[e].has(_))
- return c.apply(this, arguments);
- const b = this._eventMap[e].get(_);
- return this._eventMap[e].delete(_),
- this._eventMap[e].size === 0 && delete this._eventMap[e],
- Object.keys(this._eventMap).length === 0 && delete this._eventMap,
- c.apply(this, [d, b])
- }
- ,
- Object.defineProperty(o, "on" + e, {
- get() {
- return this["_on" + e]
- },
- set(d) {
- this["_on" + e] && (this.removeEventListener(e, this["_on" + e]),
- delete this["_on" + e]),
- d && this.addEventListener(e, this["_on" + e] = d)
- },
- enumerable: !0,
- configurable: !0
- })
- }
- function disableLog(a) {
- return typeof a != "boolean" ? new Error("Argument type: " + typeof a + ". Please use a boolean.") : (logDisabled_ = a,
- a ? "adapter.js logging disabled" : "adapter.js logging enabled")
- }
- function disableWarnings(a) {
- return typeof a != "boolean" ? new Error("Argument type: " + typeof a + ". Please use a boolean.") : (deprecationWarnings_ = !a,
- "adapter.js deprecation warnings " + (a ? "disabled" : "enabled"))
- }
- function log$L() {
- if (typeof window == "object") {
- if (logDisabled_)
- return;
- typeof console != "undefined" && typeof console.log == "function" && console.log.apply(console, arguments)
- }
- }
- function deprecated(a, e) {
- !deprecationWarnings_ || console.warn(a + " is deprecated, please use " + e + " instead.")
- }
- function detectBrowser(a) {
- const e = {
- browser: null,
- version: null
- };
- if (typeof a == "undefined" || !a.navigator)
- return e.browser = "Not a browser.",
- e;
- const {navigator: i} = a;
- if (i.mozGetUserMedia)
- e.browser = "firefox",
- e.version = extractVersion(i.userAgent, /Firefox\/(\d+)\./, 1);
- else if (i.webkitGetUserMedia || a.isSecureContext === !1 && a.webkitRTCPeerConnection && !a.RTCIceGatherer)
- e.browser = "chrome",
- e.version = extractVersion(i.userAgent, /Chrom(e|ium)\/(\d+)\./, 2);
- else if (a.RTCPeerConnection && i.userAgent.match(/AppleWebKit\/(\d+)\./))
- e.browser = "safari",
- e.version = extractVersion(i.userAgent, /AppleWebKit\/(\d+)\./, 1),
- e.supportsUnifiedPlan = a.RTCRtpTransceiver && "currentDirection"in a.RTCRtpTransceiver.prototype;
- else
- return e.browser = "Not a supported browser.",
- e;
- return e
- }
- function isObject$1(a) {
- return Object.prototype.toString.call(a) === "[object Object]"
- }
- function compactObject(a) {
- return isObject$1(a) ? Object.keys(a).reduce(function(e, i) {
- const o = isObject$1(a[i])
- , s = o ? compactObject(a[i]) : a[i]
- , c = o && !Object.keys(s).length;
- return s === void 0 || c ? e : Object.assign(e, {
- [i]: s
- })
- }, {}) : a
- }
- function walkStats(a, e, i) {
- !e || i.has(e.id) || (i.set(e.id, e),
- Object.keys(e).forEach(o=>{
- o.endsWith("Id") ? walkStats(a, a.get(e[o]), i) : o.endsWith("Ids") && e[o].forEach(s=>{
- walkStats(a, a.get(s), i)
- }
- )
- }
- ))
- }
- function filterStats(a, e, i) {
- const o = i ? "outbound-rtp" : "inbound-rtp"
- , s = new Map;
- if (e === null)
- return s;
- const c = [];
- return a.forEach(d=>{
- d.type === "track" && d.trackIdentifier === e.id && c.push(d)
- }
- ),
- c.forEach(d=>{
- a.forEach(_=>{
- _.type === o && _.trackId === d.id && walkStats(a, _, s)
- }
- )
- }
- ),
- s
- }
- const logging = log$L;
- function shimGetUserMedia$2(a, e) {
- const i = a && a.navigator;
- if (!i.mediaDevices)
- return;
- const o = function(_) {
- if (typeof _ != "object" || _.mandatory || _.optional)
- return _;
- const b = {};
- return Object.keys(_).forEach(k=>{
- if (k === "require" || k === "advanced" || k === "mediaSource")
- return;
- const j = typeof _[k] == "object" ? _[k] : {
- ideal: _[k]
- };
- j.exact !== void 0 && typeof j.exact == "number" && (j.min = j.max = j.exact);
- const $ = function(_e, et) {
- return _e ? _e + et.charAt(0).toUpperCase() + et.slice(1) : et === "deviceId" ? "sourceId" : et
- };
- if (j.ideal !== void 0) {
- b.optional = b.optional || [];
- let _e = {};
- typeof j.ideal == "number" ? (_e[$("min", k)] = j.ideal,
- b.optional.push(_e),
- _e = {},
- _e[$("max", k)] = j.ideal,
- b.optional.push(_e)) : (_e[$("", k)] = j.ideal,
- b.optional.push(_e))
- }
- j.exact !== void 0 && typeof j.exact != "number" ? (b.mandatory = b.mandatory || {},
- b.mandatory[$("", k)] = j.exact) : ["min", "max"].forEach(_e=>{
- j[_e] !== void 0 && (b.mandatory = b.mandatory || {},
- b.mandatory[$(_e, k)] = j[_e])
- }
- )
- }
- ),
- _.advanced && (b.optional = (b.optional || []).concat(_.advanced)),
- b
- }
- , s = function(_, b) {
- if (e.version >= 61)
- return b(_);
- if (_ = JSON.parse(JSON.stringify(_)),
- _ && typeof _.audio == "object") {
- const k = function(j, $, _e) {
- $in j && !(_e in j) && (j[_e] = j[$],
- delete j[$])
- };
- _ = JSON.parse(JSON.stringify(_)),
- k(_.audio, "autoGainControl", "googAutoGainControl"),
- k(_.audio, "noiseSuppression", "googNoiseSuppression"),
- _.audio = o(_.audio)
- }
- if (_ && typeof _.video == "object") {
- let k = _.video.facingMode;
- k = k && (typeof k == "object" ? k : {
- ideal: k
- });
- const j = e.version < 66;
- if (k && (k.exact === "user" || k.exact === "environment" || k.ideal === "user" || k.ideal === "environment") && !(i.mediaDevices.getSupportedConstraints && i.mediaDevices.getSupportedConstraints().facingMode && !j)) {
- delete _.video.facingMode;
- let$;
- if (k.exact === "environment" || k.ideal === "environment" ? $ = ["back", "rear"] : (k.exact === "user" || k.ideal === "user") && ($ = ["front"]),
- $)
- return i.mediaDevices.enumerateDevices().then(_e=>{
- _e = _e.filter(tt=>tt.kind === "videoinput");
- let et = _e.find(tt=>$.some(rt=>tt.label.toLowerCase().includes(rt)));
- return !et && _e.length && $.includes("back") && (et = _e[_e.length - 1]),
- et && (_.video.deviceId = k.exact ? {
- exact: et.deviceId
- } : {
- ideal: et.deviceId
- }),
- _.video = o(_.video),
- logging("chrome: " + JSON.stringify(_)),
- b(_)
- }
- )
- }
- _.video = o(_.video)
- }
- return logging("chrome: " + JSON.stringify(_)),
- b(_)
- }
- , c = function(_) {
- return e.version >= 64 ? _ : {
- name: {
- PermissionDeniedError: "NotAllowedError",
- PermissionDismissedError: "NotAllowedError",
- InvalidStateError: "NotAllowedError",
- DevicesNotFoundError: "NotFoundError",
- ConstraintNotSatisfiedError: "OverconstrainedError",
- TrackStartError: "NotReadableError",
- MediaDeviceFailedDueToShutdown: "NotAllowedError",
- MediaDeviceKillSwitchOn: "NotAllowedError",
- TabCaptureError: "AbortError",
- ScreenCaptureError: "AbortError",
- DeviceCaptureError: "AbortError"
- }[_.name] || _.name,
- message: _.message,
- constraint: _.constraint || _.constraintName,
- toString() {
- return this.name + (this.message && ": ") + this.message
- }
- }
- }
- , d = function(_, b, k) {
- s(_, j=>{
- i.webkitGetUserMedia(j, b, $=>{
- k && k(c($))
- }
- )
- }
- )
- };
- if (i.getUserMedia = d.bind(i),
- i.mediaDevices.getUserMedia) {
- const _ = i.mediaDevices.getUserMedia.bind(i.mediaDevices);
- i.mediaDevices.getUserMedia = function(b) {
- return s(b, k=>_(k).then(j=>{
- if (k.audio && !j.getAudioTracks().length || k.video && !j.getVideoTracks().length)
- throw j.getTracks().forEach($=>{
- $.stop()
- }
- ),
- new DOMException("","NotFoundError");
- return j
- }
- , j=>Promise.reject(c(j))))
- }
- }
- }
- function shimGetDisplayMedia$1(a, e) {
- if (!(a.navigator.mediaDevices && "getDisplayMedia"in a.navigator.mediaDevices) && !!a.navigator.mediaDevices) {
- if (typeof e != "function") {
- console.error("shimGetDisplayMedia: getSourceId argument is not a function");
- return
- }
- a.navigator.mediaDevices.getDisplayMedia = function(o) {
- return e(o).then(s=>{
- const c = o.video && o.video.width
- , d = o.video && o.video.height
- , _ = o.video && o.video.frameRate;
- return o.video = {
- mandatory: {
- chromeMediaSource: "desktop",
- chromeMediaSourceId: s,
- maxFrameRate: _ || 3
- }
- },
- c && (o.video.mandatory.maxWidth = c),
- d && (o.video.mandatory.maxHeight = d),
- a.navigator.mediaDevices.getUserMedia(o)
- }
- )
- }
- }
- }
- function shimMediaStream(a) {
- a.MediaStream = a.MediaStream || a.webkitMediaStream
- }
- function shimOnTrack$1(a) {
- if (typeof a == "object" && a.RTCPeerConnection && !("ontrack"in a.RTCPeerConnection.prototype)) {
- Object.defineProperty(a.RTCPeerConnection.prototype, "ontrack", {
- get() {
- return this._ontrack
- },
- set(i) {
- this._ontrack && this.removeEventListener("track", this._ontrack),
- this.addEventListener("track", this._ontrack = i)
- },
- enumerable: !0,
- configurable: !0
- });
- const e = a.RTCPeerConnection.prototype.setRemoteDescription;
- a.RTCPeerConnection.prototype.setRemoteDescription = function() {
- return this._ontrackpoly || (this._ontrackpoly = o=>{
- o.stream.addEventListener("addtrack", s=>{
- let c;
- a.RTCPeerConnection.prototype.getReceivers ? c = this.getReceivers().find(_=>_.track && _.track.id === s.track.id) : c = {
- track: s.track
- };
- const d = new Event("track");
- d.track = s.track,
- d.receiver = c,
- d.transceiver = {
- receiver: c
- },
- d.streams = [o.stream],
- this.dispatchEvent(d)
- }
- ),
- o.stream.getTracks().forEach(s=>{
- let c;
- a.RTCPeerConnection.prototype.getReceivers ? c = this.getReceivers().find(_=>_.track && _.track.id === s.id) : c = {
- track: s
- };
- const d = new Event("track");
- d.track = s,
- d.receiver = c,
- d.transceiver = {
- receiver: c
- },
- d.streams = [o.stream],
- this.dispatchEvent(d)
- }
- )
- }
- ,
- this.addEventListener("addstream", this._ontrackpoly)),
- e.apply(this, arguments)
- }
- } else
- wrapPeerConnectionEvent(a, "track", e=>(e.transceiver || Object.defineProperty(e, "transceiver", {
- value: {
- receiver: e.receiver
- }
- }),
- e))
- }
- function shimGetSendersWithDtmf(a) {
- if (typeof a == "object" && a.RTCPeerConnection && !("getSenders"in a.RTCPeerConnection.prototype) && "createDTMFSender"in a.RTCPeerConnection.prototype) {
- const e = function(s, c) {
- return {
- track: c,
- get dtmf() {
- return this._dtmf === void 0 && (c.kind === "audio" ? this._dtmf = s.createDTMFSender(c) : this._dtmf = null),
- this._dtmf
- },
- _pc: s
- }
- };
- if (!a.RTCPeerConnection.prototype.getSenders) {
- a.RTCPeerConnection.prototype.getSenders = function() {
- return this._senders = this._senders || [],
- this._senders.slice()
- }
- ;
- const s = a.RTCPeerConnection.prototype.addTrack;
- a.RTCPeerConnection.prototype.addTrack = function(_, b) {
- let k = s.apply(this, arguments);
- return k || (k = e(this, _),
- this._senders.push(k)),
- k
- }
- ;
- const c = a.RTCPeerConnection.prototype.removeTrack;
- a.RTCPeerConnection.prototype.removeTrack = function(_) {
- c.apply(this, arguments);
- const b = this._senders.indexOf(_);
- b !== -1 && this._senders.splice(b, 1)
- }
- }
- const i = a.RTCPeerConnection.prototype.addStream;
- a.RTCPeerConnection.prototype.addStream = function(c) {
- this._senders = this._senders || [],
- i.apply(this, [c]),
- c.getTracks().forEach(d=>{
- this._senders.push(e(this, d))
- }
- )
- }
- ;
- const o = a.RTCPeerConnection.prototype.removeStream;
- a.RTCPeerConnection.prototype.removeStream = function(c) {
- this._senders = this._senders || [],
- o.apply(this, [c]),
- c.getTracks().forEach(d=>{
- const _ = this._senders.find(b=>b.track === d);
- _ && this._senders.splice(this._senders.indexOf(_), 1)
- }
- )
- }
- } else if (typeof a == "object" && a.RTCPeerConnection && "getSenders"in a.RTCPeerConnection.prototype && "createDTMFSender"in a.RTCPeerConnection.prototype && a.RTCRtpSender && !("dtmf"in a.RTCRtpSender.prototype)) {
- const e = a.RTCPeerConnection.prototype.getSenders;
- a.RTCPeerConnection.prototype.getSenders = function() {
- const o = e.apply(this, []);
- return o.forEach(s=>s._pc = this),
- o
- }
- ,
- Object.defineProperty(a.RTCRtpSender.prototype, "dtmf", {
- get() {
- return this._dtmf === void 0 && (this.track.kind === "audio" ? this._dtmf = this._pc.createDTMFSender(this.track) : this._dtmf = null),
- this._dtmf
- }
- })
- }
- }
- function shimGetStats(a) {
- if (!a.RTCPeerConnection)
- return;
- const e = a.RTCPeerConnection.prototype.getStats;
- a.RTCPeerConnection.prototype.getStats = function() {
- const [o,s,c] = arguments;
- if (arguments.length > 0 && typeof o == "function")
- return e.apply(this, arguments);
- if (e.length === 0 && (arguments.length === 0 || typeof o != "function"))
- return e.apply(this, []);
- const d = function(b) {
- const k = {};
- return b.result().forEach($=>{
- const _e = {
- id: $.id,
- timestamp: $.timestamp,
- type: {
- localcandidate: "local-candidate",
- remotecandidate: "remote-candidate"
- }[$.type] || $.type
- };
- $.names().forEach(et=>{
- _e[et] = $.stat(et)
- }
- ),
- k[_e.id] = _e
- }
- ),
- k
- }
- , _ = function(b) {
- return new Map(Object.keys(b).map(k=>[k, b[k]]))
- };
- if (arguments.length >= 2) {
- const b = function(k) {
- s(_(d(k)))
- };
- return e.apply(this, [b, o])
- }
- return new Promise((b,k)=>{
- e.apply(this, [function(j) {
- b(_(d(j)))
- }
- , k])
- }
- ).then(s, c)
- }
- }
- function shimSenderReceiverGetStats(a) {
- if (!(typeof a == "object" && a.RTCPeerConnection && a.RTCRtpSender && a.RTCRtpReceiver))
- return;
- if (!("getStats"in a.RTCRtpSender.prototype)) {
- const i = a.RTCPeerConnection.prototype.getSenders;
- i && (a.RTCPeerConnection.prototype.getSenders = function() {
- const c = i.apply(this, []);
- return c.forEach(d=>d._pc = this),
- c
- }
- );
- const o = a.RTCPeerConnection.prototype.addTrack;
- o && (a.RTCPeerConnection.prototype.addTrack = function() {
- const c = o.apply(this, arguments);
- return c._pc = this,
- c
- }
- ),
- a.RTCRtpSender.prototype.getStats = function() {
- const c = this;
- return this._pc.getStats().then(d=>filterStats(d, c.track, !0))
- }
- }
- if (!("getStats"in a.RTCRtpReceiver.prototype)) {
- const i = a.RTCPeerConnection.prototype.getReceivers;
- i && (a.RTCPeerConnection.prototype.getReceivers = function() {
- const s = i.apply(this, []);
- return s.forEach(c=>c._pc = this),
- s
- }
- ),
- wrapPeerConnectionEvent(a, "track", o=>(o.receiver._pc = o.srcElement,
- o)),
- a.RTCRtpReceiver.prototype.getStats = function() {
- const s = this;
- return this._pc.getStats().then(c=>filterStats(c, s.track, !1))
- }
- }
- if (!("getStats"in a.RTCRtpSender.prototype && "getStats"in a.RTCRtpReceiver.prototype))
- return;
- const e = a.RTCPeerConnection.prototype.getStats;
- a.RTCPeerConnection.prototype.getStats = function() {
- if (arguments.length > 0 && arguments[0]instanceof a.MediaStreamTrack) {
- const o = arguments[0];
- let s, c, d;
- return this.getSenders().forEach(_=>{
- _.track === o && (s ? d = !0 : s = _)
- }
- ),
- this.getReceivers().forEach(_=>(_.track === o && (c ? d = !0 : c = _),
- _.track === o)),
- 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"))
- }
- return e.apply(this, arguments)
- }
- }
- function shimAddTrackRemoveTrackWithNative(a) {
- a.RTCPeerConnection.prototype.getLocalStreams = function() {
- return this._shimmedLocalStreams = this._shimmedLocalStreams || {},
- Object.keys(this._shimmedLocalStreams).map(d=>this._shimmedLocalStreams[d][0])
- }
- ;
- const e = a.RTCPeerConnection.prototype.addTrack;
- a.RTCPeerConnection.prototype.addTrack = function(d, _) {
- if (!_)
- return e.apply(this, arguments);
- this._shimmedLocalStreams = this._shimmedLocalStreams || {};
- const b = e.apply(this, arguments);
- return this._shimmedLocalStreams[_.id] ? this._shimmedLocalStreams[_.id].indexOf(b) === -1 && this._shimmedLocalStreams[_.id].push(b) : this._shimmedLocalStreams[_.id] = [_, b],
- b
- }
- ;
- const i = a.RTCPeerConnection.prototype.addStream;
- a.RTCPeerConnection.prototype.addStream = function(d) {
- this._shimmedLocalStreams = this._shimmedLocalStreams || {},
- d.getTracks().forEach(k=>{
- if (this.getSenders().find($=>$.track === k))
- throw new DOMException("Track already exists.","InvalidAccessError")
- }
- );
- const _ = this.getSenders();
- i.apply(this, arguments);
- const b = this.getSenders().filter(k=>_.indexOf(k) === -1);
- this._shimmedLocalStreams[d.id] = [d].concat(b)
- }
- ;
- const o = a.RTCPeerConnection.prototype.removeStream;
- a.RTCPeerConnection.prototype.removeStream = function(d) {
- return this._shimmedLocalStreams = this._shimmedLocalStreams || {},
- delete this._shimmedLocalStreams[d.id],
- o.apply(this, arguments)
- }
- ;
- const s = a.RTCPeerConnection.prototype.removeTrack;
- a.RTCPeerConnection.prototype.removeTrack = function(d) {
- return this._shimmedLocalStreams = this._shimmedLocalStreams || {},
- d && Object.keys(this._shimmedLocalStreams).forEach(_=>{
- const b = this._shimmedLocalStreams[_].indexOf(d);
- b !== -1 && this._shimmedLocalStreams[_].splice(b, 1),
- this._shimmedLocalStreams[_].length === 1 && delete this._shimmedLocalStreams[_]
- }
- ),
- s.apply(this, arguments)
- }
- }
- function shimAddTrackRemoveTrack(a, e) {
- if (!a.RTCPeerConnection)
- return;
- if (a.RTCPeerConnection.prototype.addTrack && e.version >= 65)
- return shimAddTrackRemoveTrackWithNative(a);
- const i = a.RTCPeerConnection.prototype.getLocalStreams;
- a.RTCPeerConnection.prototype.getLocalStreams = function() {
- const j = i.apply(this);
- return this._reverseStreams = this._reverseStreams || {},
- j.map($=>this._reverseStreams[$.id])
- }
- ;
- const o = a.RTCPeerConnection.prototype.addStream;
- a.RTCPeerConnection.prototype.addStream = function(j) {
- if (this._streams = this._streams || {},
- this._reverseStreams = this._reverseStreams || {},
- j.getTracks().forEach($=>{
- if (this.getSenders().find(et=>et.track === $))
- throw new DOMException("Track already exists.","InvalidAccessError")
- }
- ),
- !this._reverseStreams[j.id]) {
- const $ = new a.MediaStream(j.getTracks());
- this._streams[j.id] = $,
- this._reverseStreams[$.id] = j,
- j = $
- }
- o.apply(this, [j])
- }
- ;
- const s = a.RTCPeerConnection.prototype.removeStream;
- a.RTCPeerConnection.prototype.removeStream = function(j) {
- this._streams = this._streams || {},
- this._reverseStreams = this._reverseStreams || {},
- s.apply(this, [this._streams[j.id] || j]),
- delete this._reverseStreams[this._streams[j.id] ? this._streams[j.id].id : j.id],
- delete this._streams[j.id]
- }
- ,
- a.RTCPeerConnection.prototype.addTrack = function(j, $) {
- if (this.signalingState === "closed")
- throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");
- const _e = [].slice.call(arguments, 1);
- if (_e.length !== 1 || !_e[0].getTracks().find(rt=>rt === j))
- throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");
- if (this.getSenders().find(rt=>rt.track === j))
- throw new DOMException("Track already exists.","InvalidAccessError");
- this._streams = this._streams || {},
- this._reverseStreams = this._reverseStreams || {};
- const tt = this._streams[$.id];
- if (tt)
- tt.addTrack(j),
- Promise.resolve().then(()=>{
- this.dispatchEvent(new Event("negotiationneeded"))
- }
- );
- else {
- const rt = new a.MediaStream([j]);
- this._streams[$.id] = rt,
- this._reverseStreams[rt.id] = $,
- this.addStream(rt)
- }
- return this.getSenders().find(rt=>rt.track === j)
- }
- ;
- function c(k, j) {
- let$ = j.sdp;
- return Object.keys(k._reverseStreams || []).forEach(_e=>{
- const et = k._reverseStreams[_e]
- , tt = k._streams[et.id];
- $ = $.replace(new RegExp(tt.id,"g"), et.id)
- }
- ),
- new RTCSessionDescription({
- type: j.type,
- sdp: $
- })
- }
- function d(k, j) {
- let$ = j.sdp;
- return Object.keys(k._reverseStreams || []).forEach(_e=>{
- const et = k._reverseStreams[_e]
- , tt = k._streams[et.id];
- $ = $.replace(new RegExp(et.id,"g"), tt.id)
- }
- ),
- new RTCSessionDescription({
- type: j.type,
- sdp: $
- })
- }
- ["createOffer", "createAnswer"].forEach(function(k) {
- const j = a.RTCPeerConnection.prototype[k]
- , $ = {
- [k]() {
- const _e = arguments;
- return arguments.length && typeof arguments[0] == "function" ? j.apply(this, [tt=>{
- const rt = c(this, tt);
- _e[0].apply(null, [rt])
- }
- , tt=>{
- _e[1] && _e[1].apply(null, tt)
- }
- , arguments[2]]) : j.apply(this, arguments).then(tt=>c(this, tt))
- }
- };
- a.RTCPeerConnection.prototype[k] = $[k]
- });
- const _ = a.RTCPeerConnection.prototype.setLocalDescription;
- a.RTCPeerConnection.prototype.setLocalDescription = function() {
- return !arguments.length || !arguments[0].type ? _.apply(this, arguments) : (arguments[0] = d(this, arguments[0]),
- _.apply(this, arguments))
- }
- ;
- const b = Object.getOwnPropertyDescriptor(a.RTCPeerConnection.prototype, "localDescription");
- Object.defineProperty(a.RTCPeerConnection.prototype, "localDescription", {
- get() {
- const k = b.get.apply(this);
- return k.type === "" ? k : c(this, k)
- }
- }),
- a.RTCPeerConnection.prototype.removeTrack = function(j) {
- if (this.signalingState === "closed")
- throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");
- if (!j._pc)
- throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");
- if (!(j._pc === this))
- throw new DOMException("Sender was not created by this connection.","InvalidAccessError");
- this._streams = this._streams || {};
- let _e;
- Object.keys(this._streams).forEach(et=>{
- this._streams[et].getTracks().find(rt=>j.track === rt) && (_e = this._streams[et])
- }
- ),
- _e && (_e.getTracks().length === 1 ? this.removeStream(this._reverseStreams[_e.id]) : _e.removeTrack(j.track),
- this.dispatchEvent(new Event("negotiationneeded")))
- }
- }
- function shimPeerConnection$1(a, e) {
- !a.RTCPeerConnection && a.webkitRTCPeerConnection && (a.RTCPeerConnection = a.webkitRTCPeerConnection),
- !!a.RTCPeerConnection && e.version < 53 && ["setLocalDescription", "setRemoteDescription", "addIceCandidate"].forEach(function(i) {
- const o = a.RTCPeerConnection.prototype[i]
- , s = {
- [i]() {
- return arguments[0] = new (i === "addIceCandidate" ? a.RTCIceCandidate : a.RTCSessionDescription)(arguments[0]),
- o.apply(this, arguments)
- }
- };
- a.RTCPeerConnection.prototype[i] = s[i]
- })
- }
- function fixNegotiationNeeded(a, e) {
- wrapPeerConnectionEvent(a, "negotiationneeded", i=>{
- const o = i.target;
- if (!((e.version < 72 || o.getConfiguration && o.getConfiguration().sdpSemantics === "plan-b") && o.signalingState !== "stable"))
- return i
- }
- )
- }
- var chromeShim = Object.freeze(Object.defineProperty({
- __proto__: null,
- shimMediaStream,
- shimOnTrack: shimOnTrack$1,
- shimGetSendersWithDtmf,
- shimGetStats,
- shimSenderReceiverGetStats,
- shimAddTrackRemoveTrackWithNative,
- shimAddTrackRemoveTrack,
- shimPeerConnection: shimPeerConnection$1,
- fixNegotiationNeeded,
- shimGetUserMedia: shimGetUserMedia$2,
- shimGetDisplayMedia: shimGetDisplayMedia$1
- }, Symbol.toStringTag, {
- value: "Module"
- }));
- function shimGetUserMedia$1(a, e) {
- const i = a && a.navigator
- , o = a && a.MediaStreamTrack;
- if (i.getUserMedia = function(s, c, d) {
- deprecated("navigator.getUserMedia", "navigator.mediaDevices.getUserMedia"),
- i.mediaDevices.getUserMedia(s).then(c, d)
- }
- ,
- !(e.version > 55 && "autoGainControl"in i.mediaDevices.getSupportedConstraints())) {
- const s = function(d, _, b) {
- _ in d && !(b in d) && (d[b] = d[_],
- delete d[_])
- }
- , c = i.mediaDevices.getUserMedia.bind(i.mediaDevices);
- if (i.mediaDevices.getUserMedia = function(d) {
- return typeof d == "object" && typeof d.audio == "object" && (d = JSON.parse(JSON.stringify(d)),
- s(d.audio, "autoGainControl", "mozAutoGainControl"),
- s(d.audio, "noiseSuppression", "mozNoiseSuppression")),
- c(d)
- }
- ,
- o && o.prototype.getSettings) {
- const d = o.prototype.getSettings;
- o.prototype.getSettings = function() {
- const _ = d.apply(this, arguments);
- return s(_, "mozAutoGainControl", "autoGainControl"),
- s(_, "mozNoiseSuppression", "noiseSuppression"),
- _
- }
- }
- if (o && o.prototype.applyConstraints) {
- const d = o.prototype.applyConstraints;
- o.prototype.applyConstraints = function(_) {
- return this.kind === "audio" && typeof _ == "object" && (_ = JSON.parse(JSON.stringify(_)),
- s(_, "autoGainControl", "mozAutoGainControl"),
- s(_, "noiseSuppression", "mozNoiseSuppression")),
- d.apply(this, [_])
- }
- }
- }
- }
- function shimGetDisplayMedia(a, e) {
- a.navigator.mediaDevices && "getDisplayMedia"in a.navigator.mediaDevices || !a.navigator.mediaDevices || (a.navigator.mediaDevices.getDisplayMedia = function(o) {
- if (!(o && o.video)) {
- const s = new DOMException("getDisplayMedia without video constraints is undefined");
- return s.name = "NotFoundError",
- s.code = 8,
- Promise.reject(s)
- }
- return o.video === !0 ? o.video = {
- mediaSource: e
- } : o.video.mediaSource = e,
- a.navigator.mediaDevices.getUserMedia(o)
- }
- )
- }
- function shimOnTrack(a) {
- typeof a == "object" && a.RTCTrackEvent && "receiver"in a.RTCTrackEvent.prototype && !("transceiver"in a.RTCTrackEvent.prototype) && Object.defineProperty(a.RTCTrackEvent.prototype, "transceiver", {
- get() {
- return {
- receiver: this.receiver
- }
- }
- })
- }
- function shimPeerConnection(a, e) {
- if (typeof a != "object" || !(a.RTCPeerConnection || a.mozRTCPeerConnection))
- return;
- !a.RTCPeerConnection && a.mozRTCPeerConnection && (a.RTCPeerConnection = a.mozRTCPeerConnection),
- e.version < 53 && ["setLocalDescription", "setRemoteDescription", "addIceCandidate"].forEach(function(s) {
- const c = a.RTCPeerConnection.prototype[s]
- , d = {
- [s]() {
- return arguments[0] = new (s === "addIceCandidate" ? a.RTCIceCandidate : a.RTCSessionDescription)(arguments[0]),
- c.apply(this, arguments)
- }
- };
- a.RTCPeerConnection.prototype[s] = d[s]
- });
- const i = {
- inboundrtp: "inbound-rtp",
- outboundrtp: "outbound-rtp",
- candidatepair: "candidate-pair",
- localcandidate: "local-candidate",
- remotecandidate: "remote-candidate"
- }
- , o = a.RTCPeerConnection.prototype.getStats;
- a.RTCPeerConnection.prototype.getStats = function() {
- const [c,d,_] = arguments;
- return o.apply(this, [c || null]).then(b=>{
- if (e.version < 53 && !d)
- try {
- b.forEach(k=>{
- k.type = i[k.type] || k.type
- }
- )
- } catch (k) {
- if (k.name !== "TypeError")
- throw k;
- b.forEach((j,$)=>{
- b.set($, Object.assign({}, j, {
- type: i[j.type] || j.type
- }))
- }
- )
- }
- return b
- }
- ).then(d, _)
- }
- }
- function shimSenderGetStats(a) {
- if (!(typeof a == "object" && a.RTCPeerConnection && a.RTCRtpSender) || a.RTCRtpSender && "getStats"in a.RTCRtpSender.prototype)
- return;
- const e = a.RTCPeerConnection.prototype.getSenders;
- e && (a.RTCPeerConnection.prototype.getSenders = function() {
- const s = e.apply(this, []);
- return s.forEach(c=>c._pc = this),
- s
- }
- );
- const i = a.RTCPeerConnection.prototype.addTrack;
- i && (a.RTCPeerConnection.prototype.addTrack = function() {
- const s = i.apply(this, arguments);
- return s._pc = this,
- s
- }
- ),
- a.RTCRtpSender.prototype.getStats = function() {
- return this.track ? this._pc.getStats(this.track) : Promise.resolve(new Map)
- }
- }
- function shimReceiverGetStats(a) {
- if (!(typeof a == "object" && a.RTCPeerConnection && a.RTCRtpSender) || a.RTCRtpSender && "getStats"in a.RTCRtpReceiver.prototype)
- return;
- const e = a.RTCPeerConnection.prototype.getReceivers;
- e && (a.RTCPeerConnection.prototype.getReceivers = function() {
- const o = e.apply(this, []);
- return o.forEach(s=>s._pc = this),
- o
- }
- ),
- wrapPeerConnectionEvent(a, "track", i=>(i.receiver._pc = i.srcElement,
- i)),
- a.RTCRtpReceiver.prototype.getStats = function() {
- return this._pc.getStats(this.track)
- }
- }
- function shimRemoveStream(a) {
- !a.RTCPeerConnection || "removeStream"in a.RTCPeerConnection.prototype || (a.RTCPeerConnection.prototype.removeStream = function(i) {
- deprecated("removeStream", "removeTrack"),
- this.getSenders().forEach(o=>{
- o.track && i.getTracks().includes(o.track) && this.removeTrack(o)
- }
- )
- }
- )
- }
- function shimRTCDataChannel(a) {
- a.DataChannel && !a.RTCDataChannel && (a.RTCDataChannel = a.DataChannel)
- }
- function shimAddTransceiver(a) {
- if (!(typeof a == "object" && a.RTCPeerConnection))
- return;
- const e = a.RTCPeerConnection.prototype.addTransceiver;
- e && (a.RTCPeerConnection.prototype.addTransceiver = function() {
- this.setParametersPromises = [];
- const o = arguments[1]
- , s = o && "sendEncodings"in o;
- s && o.sendEncodings.forEach(d=>{
- if ("rid"in d && !/^[a-z0-9]{0,16}$/i.test(d.rid))
- throw new TypeError("Invalid RID value provided.");
- if ("scaleResolutionDownBy"in d && !(parseFloat(d.scaleResolutionDownBy) >= 1))
- throw new RangeError("scale_resolution_down_by must be >= 1.0");
- if ("maxFramerate"in d && !(parseFloat(d.maxFramerate) >= 0))
- throw new RangeError("max_framerate must be >= 0.0")
- }
- );
- const c = e.apply(this, arguments);
- if (s) {
- const {sender: d} = c
- , _ = d.getParameters();
- (!("encodings"in _) || _.encodings.length === 1 && Object.keys(_.encodings[0]).length === 0) && (_.encodings = o.sendEncodings,
- d.sendEncodings = o.sendEncodings,
- this.setParametersPromises.push(d.setParameters(_).then(()=>{
- delete d.sendEncodings
- }
- ).catch(()=>{
- delete d.sendEncodings
- }
- )))
- }
- return c
- }
- )
- }
- function shimGetParameters(a) {
- if (!(typeof a == "object" && a.RTCRtpSender))
- return;
- const e = a.RTCRtpSender.prototype.getParameters;
- e && (a.RTCRtpSender.prototype.getParameters = function() {
- const o = e.apply(this, arguments);
- return "encodings"in o || (o.encodings = [].concat(this.sendEncodings || [{}])),
- o
- }
- )
- }
- function shimCreateOffer(a) {
- if (!(typeof a == "object" && a.RTCPeerConnection))
- return;
- const e = a.RTCPeerConnection.prototype.createOffer;
- a.RTCPeerConnection.prototype.createOffer = function() {
- return this.setParametersPromises && this.setParametersPromises.length ? Promise.all(this.setParametersPromises).then(()=>e.apply(this, arguments)).finally(()=>{
- this.setParametersPromises = []
- }
- ) : e.apply(this, arguments)
- }
- }
- function shimCreateAnswer(a) {
- if (!(typeof a == "object" && a.RTCPeerConnection))
- return;
- const e = a.RTCPeerConnection.prototype.createAnswer;
- a.RTCPeerConnection.prototype.createAnswer = function() {
- return this.setParametersPromises && this.setParametersPromises.length ? Promise.all(this.setParametersPromises).then(()=>e.apply(this, arguments)).finally(()=>{
- this.setParametersPromises = []
- }
- ) : e.apply(this, arguments)
- }
- }
- var firefoxShim = Object.freeze(Object.defineProperty({
- __proto__: null,
- shimOnTrack,
- shimPeerConnection,
- shimSenderGetStats,
- shimReceiverGetStats,
- shimRemoveStream,
- shimRTCDataChannel,
- shimAddTransceiver,
- shimGetParameters,
- shimCreateOffer,
- shimCreateAnswer,
- shimGetUserMedia: shimGetUserMedia$1,
- shimGetDisplayMedia
- }, Symbol.toStringTag, {
- value: "Module"
- }));
- function shimLocalStreamsAPI(a) {
- if (!(typeof a != "object" || !a.RTCPeerConnection)) {
- if ("getLocalStreams"in a.RTCPeerConnection.prototype || (a.RTCPeerConnection.prototype.getLocalStreams = function() {
- return this._localStreams || (this._localStreams = []),
- this._localStreams
- }
- ),
- !("addStream"in a.RTCPeerConnection.prototype)) {
- const e = a.RTCPeerConnection.prototype.addTrack;
- a.RTCPeerConnection.prototype.addStream = function(o) {
- this._localStreams || (this._localStreams = []),
- this._localStreams.includes(o) || this._localStreams.push(o),
- o.getAudioTracks().forEach(s=>e.call(this, s, o)),
- o.getVideoTracks().forEach(s=>e.call(this, s, o))
- }
- ,
- a.RTCPeerConnection.prototype.addTrack = function(o, ...s) {
- return s && s.forEach(c=>{
- this._localStreams ? this._localStreams.includes(c) || this._localStreams.push(c) : this._localStreams = [c]
- }
- ),
- e.apply(this, arguments)
- }
- }
- "removeStream"in a.RTCPeerConnection.prototype || (a.RTCPeerConnection.prototype.removeStream = function(i) {
- this._localStreams || (this._localStreams = []);
- const o = this._localStreams.indexOf(i);
- if (o === -1)
- return;
- this._localStreams.splice(o, 1);
- const s = i.getTracks();
- this.getSenders().forEach(c=>{
- s.includes(c.track) && this.removeTrack(c)
- }
- )
- }
- )
- }
- }
- function shimRemoteStreamsAPI(a) {
- if (!(typeof a != "object" || !a.RTCPeerConnection) && ("getRemoteStreams"in a.RTCPeerConnection.prototype || (a.RTCPeerConnection.prototype.getRemoteStreams = function() {
- return this._remoteStreams ? this._remoteStreams : []
- }
- ),
- !("onaddstream"in a.RTCPeerConnection.prototype))) {
- Object.defineProperty(a.RTCPeerConnection.prototype, "onaddstream", {
- get() {
- return this._onaddstream
- },
- set(i) {
- this._onaddstream && (this.removeEventListener("addstream", this._onaddstream),
- this.removeEventListener("track", this._onaddstreampoly)),
- this.addEventListener("addstream", this._onaddstream = i),
- this.addEventListener("track", this._onaddstreampoly = o=>{
- o.streams.forEach(s=>{
- if (this._remoteStreams || (this._remoteStreams = []),
- this._remoteStreams.includes(s))
- return;
- this._remoteStreams.push(s);
- const c = new Event("addstream");
- c.stream = s,
- this.dispatchEvent(c)
- }
- )
- }
- )
- }
- });
- const e = a.RTCPeerConnection.prototype.setRemoteDescription;
- a.RTCPeerConnection.prototype.setRemoteDescription = function() {
- const o = this;
- return this._onaddstreampoly || this.addEventListener("track", this._onaddstreampoly = function(s) {
- s.streams.forEach(c=>{
- if (o._remoteStreams || (o._remoteStreams = []),
- o._remoteStreams.indexOf(c) >= 0)
- return;
- o._remoteStreams.push(c);
- const d = new Event("addstream");
- d.stream = c,
- o.dispatchEvent(d)
- }
- )
- }
- ),
- e.apply(o, arguments)
- }
- }
- }
- function shimCallbacksAPI(a) {
- if (typeof a != "object" || !a.RTCPeerConnection)
- return;
- const e = a.RTCPeerConnection.prototype
- , i = e.createOffer
- , o = e.createAnswer
- , s = e.setLocalDescription
- , c = e.setRemoteDescription
- , d = e.addIceCandidate;
- e.createOffer = function(k, j) {
- const $ = arguments.length >= 2 ? arguments[2] : arguments[0]
- , _e = i.apply(this, [$]);
- return j ? (_e.then(k, j),
- Promise.resolve()) : _e
- }
- ,
- e.createAnswer = function(k, j) {
- const $ = arguments.length >= 2 ? arguments[2] : arguments[0]
- , _e = o.apply(this, [$]);
- return j ? (_e.then(k, j),
- Promise.resolve()) : _e
- }
- ;
- let _ = function(b, k, j) {
- const $ = s.apply(this, [b]);
- return j ? ($.then(k, j),
- Promise.resolve()) : $
- };
- e.setLocalDescription = _,
- _ = function(b, k, j) {
- const $ = c.apply(this, [b]);
- return j ? ($.then(k, j),
- Promise.resolve()) : $
- }
- ,
- e.setRemoteDescription = _,
- _ = function(b, k, j) {
- const $ = d.apply(this, [b]);
- return j ? ($.then(k, j),
- Promise.resolve()) : $
- }
- ,
- e.addIceCandidate = _
- }
- function shimGetUserMedia(a) {
- const e = a && a.navigator;
- if (e.mediaDevices && e.mediaDevices.getUserMedia) {
- const i = e.mediaDevices
- , o = i.getUserMedia.bind(i);
- e.mediaDevices.getUserMedia = s=>o(shimConstraints(s))
- }
- !e.getUserMedia && e.mediaDevices && e.mediaDevices.getUserMedia && (e.getUserMedia = function(o, s, c) {
- e.mediaDevices.getUserMedia(o).then(s, c)
- }
- .bind(e))
- }
- function shimConstraints(a) {
- return a && a.video !== void 0 ? Object.assign({}, a, {
- video: compactObject(a.video)
- }) : a
- }
- function shimRTCIceServerUrls(a) {
- if (!a.RTCPeerConnection)
- return;
- const e = a.RTCPeerConnection;
- a.RTCPeerConnection = function(o, s) {
- if (o && o.iceServers) {
- const c = [];
- for (let d = 0; d < o.iceServers.length; d++) {
- let _ = o.iceServers[d];
- !_.hasOwnProperty("urls") && _.hasOwnProperty("url") ? (deprecated("RTCIceServer.url", "RTCIceServer.urls"),
- _ = JSON.parse(JSON.stringify(_)),
- _.urls = _.url,
- delete _.url,
- c.push(_)) : c.push(o.iceServers[d])
- }
- o.iceServers = c
- }
- return new e(o,s)
- }
- ,
- a.RTCPeerConnection.prototype = e.prototype,
- "generateCertificate"in e && Object.defineProperty(a.RTCPeerConnection, "generateCertificate", {
- get() {
- return e.generateCertificate
- }
- })
- }
- function shimTrackEventTransceiver(a) {
- typeof a == "object" && a.RTCTrackEvent && "receiver"in a.RTCTrackEvent.prototype && !("transceiver"in a.RTCTrackEvent.prototype) && Object.defineProperty(a.RTCTrackEvent.prototype, "transceiver", {
- get() {
- return {
- receiver: this.receiver
- }
- }
- })
- }
- function shimCreateOfferLegacy(a) {
- const e = a.RTCPeerConnection.prototype.createOffer;
- a.RTCPeerConnection.prototype.createOffer = function(o) {
- if (o) {
- typeof o.offerToReceiveAudio != "undefined" && (o.offerToReceiveAudio = !!o.offerToReceiveAudio);
- const s = this.getTransceivers().find(d=>d.receiver.track.kind === "audio");
- 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", {
- direction: "recvonly"
- }),
- typeof o.offerToReceiveVideo != "undefined" && (o.offerToReceiveVideo = !!o.offerToReceiveVideo);
- const c = this.getTransceivers().find(d=>d.receiver.track.kind === "video");
- 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", {
- direction: "recvonly"
- })
- }
- return e.apply(this, arguments)
- }
- }
- function shimAudioContext(a) {
- typeof a != "object" || a.AudioContext || (a.AudioContext = a.webkitAudioContext)
- }
- var safariShim = Object.freeze(Object.defineProperty({
- __proto__: null,
- shimLocalStreamsAPI,
- shimRemoteStreamsAPI,
- shimCallbacksAPI,
- shimGetUserMedia,
- shimConstraints,
- shimRTCIceServerUrls,
- shimTrackEventTransceiver,
- shimCreateOfferLegacy,
- shimAudioContext
- }, Symbol.toStringTag, {
- value: "Module"
- }))
- , sdp$1 = {
- exports: {}
- };
- (function(a) {
- const e = {};
- e.generateIdentifier = function() {
- return Math.random().toString(36).substr(2, 10)
- }
- ,
- e.localCName = e.generateIdentifier(),
- e.splitLines = function(i) {
- return i.trim().split(`
- `).map(o=>o.trim())
- }
- ,
- e.splitSections = function(i) {
- return i.split(`
- m=`).map((s,c)=>(c > 0 ? "m=" + s : s).trim() + `\r
- `)
- }
- ,
- e.getDescription = function(i) {
- const o = e.splitSections(i);
- return o && o[0]
- }
- ,
- e.getMediaSections = function(i) {
- const o = e.splitSections(i);
- return o.shift(),
- o
- }
- ,
- e.matchPrefix = function(i, o) {
- return e.splitLines(i).filter(s=>s.indexOf(o) === 0)
- }
- ,
- e.parseCandidate = function(i) {
- let o;
- i.indexOf("a=candidate:") === 0 ? o = i.substring(12).split(" ") : o = i.substring(10).split(" ");
- const s = {
- foundation: o[0],
- component: {
- 1: "rtp",
- 2: "rtcp"
- }[o[1]] || o[1],
- protocol: o[2].toLowerCase(),
- priority: parseInt(o[3], 10),
- ip: o[4],
- address: o[4],
- port: parseInt(o[5], 10),
- type: o[7]
- };
- for (let c = 8; c < o.length; c += 2)
- switch (o[c]) {
- case "raddr":
- s.relatedAddress = o[c + 1];
- break;
- case "rport":
- s.relatedPort = parseInt(o[c + 1], 10);
- break;
- case "tcptype":
- s.tcpType = o[c + 1];
- break;
- case "ufrag":
- s.ufrag = o[c + 1],
- s.usernameFragment = o[c + 1];
- break;
- default:
- s[o[c]] === void 0 && (s[o[c]] = o[c + 1]);
- break
- }
- return s
- }
- ,
- e.writeCandidate = function(i) {
- const o = [];
- o.push(i.foundation);
- const s = i.component;
- s === "rtp" ? o.push(1) : s === "rtcp" ? o.push(2) : o.push(s),
- o.push(i.protocol.toUpperCase()),
- o.push(i.priority),
- o.push(i.address || i.ip),
- o.push(i.port);
- const c = i.type;
- return o.push("typ"),
- o.push(c),
- c !== "host" && i.relatedAddress && i.relatedPort && (o.push("raddr"),
- o.push(i.relatedAddress),
- o.push("rport"),
- o.push(i.relatedPort)),
- i.tcpType && i.protocol.toLowerCase() === "tcp" && (o.push("tcptype"),
- o.push(i.tcpType)),
- (i.usernameFragment || i.ufrag) && (o.push("ufrag"),
- o.push(i.usernameFragment || i.ufrag)),
- "candidate:" + o.join(" ")
- }
- ,
- e.parseIceOptions = function(i) {
- return i.substr(14).split(" ")
- }
- ,
- e.parseRtpMap = function(i) {
- let o = i.substr(9).split(" ");
- const s = {
- payloadType: parseInt(o.shift(), 10)
- };
- return o = o[0].split("/"),
- s.name = o[0],
- s.clockRate = parseInt(o[1], 10),
- s.channels = o.length === 3 ? parseInt(o[2], 10) : 1,
- s.numChannels = s.channels,
- s
- }
- ,
- e.writeRtpMap = function(i) {
- let o = i.payloadType;
- i.preferredPayloadType !== void 0 && (o = i.preferredPayloadType);
- const s = i.channels || i.numChannels || 1;
- return "a=rtpmap:" + o + " " + i.name + "/" + i.clockRate + (s !== 1 ? "/" + s : "") + `\r
- `
- }
- ,
- e.parseExtmap = function(i) {
- const o = i.substr(9).split(" ");
- return {
- id: parseInt(o[0], 10),
- direction: o[0].indexOf("/") > 0 ? o[0].split("/")[1] : "sendrecv",
- uri: o[1]
- }
- }
- ,
- e.writeExtmap = function(i) {
- return "a=extmap:" + (i.id || i.preferredId) + (i.direction && i.direction !== "sendrecv" ? "/" + i.direction : "") + " " + i.uri + `\r
- `
- }
- ,
- e.parseFmtp = function(i) {
- const o = {};
- let s;
- const c = i.substr(i.indexOf(" ") + 1).split(";");
- for (let d = 0; d < c.length; d++)
- s = c[d].trim().split("="),
- o[s[0].trim()] = s[1];
- return o
- }
- ,
- e.writeFmtp = function(i) {
- let o = ""
- , s = i.payloadType;
- if (i.preferredPayloadType !== void 0 && (s = i.preferredPayloadType),
- i.parameters && Object.keys(i.parameters).length) {
- const c = [];
- Object.keys(i.parameters).forEach(d=>{
- i.parameters[d] !== void 0 ? c.push(d + "=" + i.parameters[d]) : c.push(d)
- }
- ),
- o += "a=fmtp:" + s + " " + c.join(";") + `\r
- `
- }
- return o
- }
- ,
- e.parseRtcpFb = function(i) {
- const o = i.substr(i.indexOf(" ") + 1).split(" ");
- return {
- type: o.shift(),
- parameter: o.join(" ")
- }
- }
- ,
- e.writeRtcpFb = function(i) {
- let o = ""
- , s = i.payloadType;
- return i.preferredPayloadType !== void 0 && (s = i.preferredPayloadType),
- i.rtcpFeedback && i.rtcpFeedback.length && i.rtcpFeedback.forEach(c=>{
- o += "a=rtcp-fb:" + s + " " + c.type + (c.parameter && c.parameter.length ? " " + c.parameter : "") + `\r
- `
- }
- ),
- o
- }
- ,
- e.parseSsrcMedia = function(i) {
- const o = i.indexOf(" ")
- , s = {
- ssrc: parseInt(i.substr(7, o - 7), 10)
- }
- , c = i.indexOf(":", o);
- return c > -1 ? (s.attribute = i.substr(o + 1, c - o - 1),
- s.value = i.substr(c + 1)) : s.attribute = i.substr(o + 1),
- s
- }
- ,
- e.parseSsrcGroup = function(i) {
- const o = i.substr(13).split(" ");
- return {
- semantics: o.shift(),
- ssrcs: o.map(s=>parseInt(s, 10))
- }
- }
- ,
- e.getMid = function(i) {
- const o = e.matchPrefix(i, "a=mid:")[0];
- if (o)
- return o.substr(6)
- }
- ,
- e.parseFingerprint = function(i) {
- const o = i.substr(14).split(" ");
- return {
- algorithm: o[0].toLowerCase(),
- value: o[1].toUpperCase()
- }
- }
- ,
- e.getDtlsParameters = function(i, o) {
- const s = e.matchPrefix(i + o, "a=fingerprint:");
- return {
- role: "auto",
- fingerprints: s.map(e.parseFingerprint)
- }
- }
- ,
- e.writeDtlsParameters = function(i, o) {
- let s = "a=setup:" + o + `\r
- `;
- return i.fingerprints.forEach(c=>{
- s += "a=fingerprint:" + c.algorithm + " " + c.value + `\r
- `
- }
- ),
- s
- }
- ,
- e.parseCryptoLine = function(i) {
- const o = i.substr(9).split(" ");
- return {
- tag: parseInt(o[0], 10),
- cryptoSuite: o[1],
- keyParams: o[2],
- sessionParams: o.slice(3)
- }
- }
- ,
- e.writeCryptoLine = function(i) {
- return "a=crypto:" + i.tag + " " + i.cryptoSuite + " " + (typeof i.keyParams == "object" ? e.writeCryptoKeyParams(i.keyParams) : i.keyParams) + (i.sessionParams ? " " + i.sessionParams.join(" ") : "") + `\r
- `
- }
- ,
- e.parseCryptoKeyParams = function(i) {
- if (i.indexOf("inline:") !== 0)
- return null;
- const o = i.substr(7).split("|");
- return {
- keyMethod: "inline",
- keySalt: o[0],
- lifeTime: o[1],
- mkiValue: o[2] ? o[2].split(":")[0] : void 0,
- mkiLength: o[2] ? o[2].split(":")[1] : void 0
- }
- }
- ,
- e.writeCryptoKeyParams = function(i) {
- return i.keyMethod + ":" + i.keySalt + (i.lifeTime ? "|" + i.lifeTime : "") + (i.mkiValue && i.mkiLength ? "|" + i.mkiValue + ":" + i.mkiLength : "")
- }
- ,
- e.getCryptoParameters = function(i, o) {
- return e.matchPrefix(i + o, "a=crypto:").map(e.parseCryptoLine)
- }
- ,
- e.getIceParameters = function(i, o) {
- const s = e.matchPrefix(i + o, "a=ice-ufrag:")[0]
- , c = e.matchPrefix(i + o, "a=ice-pwd:")[0];
- return s && c ? {
- usernameFragment: s.substr(12),
- password: c.substr(10)
- } : null
- }
- ,
- e.writeIceParameters = function(i) {
- let o = "a=ice-ufrag:" + i.usernameFragment + `\r
- a=ice-pwd:` + i.password + `\r
- `;
- return i.iceLite && (o += `a=ice-lite\r
- `),
- o
- }
- ,
- e.parseRtpParameters = function(i) {
- const o = {
- codecs: [],
- headerExtensions: [],
- fecMechanisms: [],
- rtcp: []
- }
- , c = e.splitLines(i)[0].split(" ");
- for (let d = 3; d < c.length; d++) {
- const _ = c[d]
- , b = e.matchPrefix(i, "a=rtpmap:" + _ + " ")[0];
- if (b) {
- const k = e.parseRtpMap(b)
- , j = e.matchPrefix(i, "a=fmtp:" + _ + " ");
- switch (k.parameters = j.length ? e.parseFmtp(j[0]) : {},
- k.rtcpFeedback = e.matchPrefix(i, "a=rtcp-fb:" + _ + " ").map(e.parseRtcpFb),
- o.codecs.push(k),
- k.name.toUpperCase()) {
- case "RED":
- case "ULPFEC":
- o.fecMechanisms.push(k.name.toUpperCase());
- break
- }
- }
- }
- return e.matchPrefix(i, "a=extmap:").forEach(d=>{
- o.headerExtensions.push(e.parseExtmap(d))
- }
- ),
- o
- }
- ,
- e.writeRtpDescription = function(i, o) {
- let s = "";
- s += "m=" + i + " ",
- s += o.codecs.length > 0 ? "9" : "0",
- s += " UDP/TLS/RTP/SAVPF ",
- s += o.codecs.map(d=>d.preferredPayloadType !== void 0 ? d.preferredPayloadType : d.payloadType).join(" ") + `\r
- `,
- s += `c=IN IP4 0.0.0.0\r
- `,
- s += `a=rtcp:9 IN IP4 0.0.0.0\r
- `,
- o.codecs.forEach(d=>{
- s += e.writeRtpMap(d),
- s += e.writeFmtp(d),
- s += e.writeRtcpFb(d)
- }
- );
- let c = 0;
- return o.codecs.forEach(d=>{
- d.maxptime > c && (c = d.maxptime)
- }
- ),
- c > 0 && (s += "a=maxptime:" + c + `\r
- `),
- o.headerExtensions && o.headerExtensions.forEach(d=>{
- s += e.writeExtmap(d)
- }
- ),
- s
- }
- ,
- e.parseRtpEncodingParameters = function(i) {
- const o = []
- , s = e.parseRtpParameters(i)
- , c = s.fecMechanisms.indexOf("RED") !== -1
- , d = s.fecMechanisms.indexOf("ULPFEC") !== -1
- , _ = e.matchPrefix(i, "a=ssrc:").map(_e=>e.parseSsrcMedia(_e)).filter(_e=>_e.attribute === "cname")
- , b = _.length > 0 && _[0].ssrc;
- let k;
- const j = e.matchPrefix(i, "a=ssrc-group:FID").map(_e=>_e.substr(17).split(" ").map(tt=>parseInt(tt, 10)));
- j.length > 0 && j[0].length > 1 && j[0][0] === b && (k = j[0][1]),
- s.codecs.forEach(_e=>{
- if (_e.name.toUpperCase() === "RTX" && _e.parameters.apt) {
- let et = {
- ssrc: b,
- codecPayloadType: parseInt(_e.parameters.apt, 10)
- };
- b && k && (et.rtx = {
- ssrc: k
- }),
- o.push(et),
- c && (et = JSON.parse(JSON.stringify(et)),
- et.fec = {
- ssrc: b,
- mechanism: d ? "red+ulpfec" : "red"
- },
- o.push(et))
- }
- }
- ),
- o.length === 0 && b && o.push({
- ssrc: b
- });
- let$ = e.matchPrefix(i, "b=");
- 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,
- o.forEach(_e=>{
- _e.maxBitrate = $
- }
- )),
- o
- }
- ,
- e.parseRtcpParameters = function(i) {
- const o = {}
- , s = e.matchPrefix(i, "a=ssrc:").map(_=>e.parseSsrcMedia(_)).filter(_=>_.attribute === "cname")[0];
- s && (o.cname = s.value,
- o.ssrc = s.ssrc);
- const c = e.matchPrefix(i, "a=rtcp-rsize");
- o.reducedSize = c.length > 0,
- o.compound = c.length === 0;
- const d = e.matchPrefix(i, "a=rtcp-mux");
- return o.mux = d.length > 0,
- o
- }
- ,
- e.writeRtcpParameters = function(i) {
- let o = "";
- return i.reducedSize && (o += `a=rtcp-rsize\r
- `),
- i.mux && (o += `a=rtcp-mux\r
- `),
- i.ssrc !== void 0 && i.cname && (o += "a=ssrc:" + i.ssrc + " cname:" + i.cname + `\r
- `),
- o
- }
- ,
- e.parseMsid = function(i) {
- let o;
- const s = e.matchPrefix(i, "a=msid:");
- if (s.length === 1)
- return o = s[0].substr(7).split(" "),
- {
- stream: o[0],
- track: o[1]
- };
- const c = e.matchPrefix(i, "a=ssrc:").map(d=>e.parseSsrcMedia(d)).filter(d=>d.attribute === "msid");
- if (c.length > 0)
- return o = c[0].value.split(" "),
- {
- stream: o[0],
- track: o[1]
- }
- }
- ,
- e.parseSctpDescription = function(i) {
- const o = e.parseMLine(i)
- , s = e.matchPrefix(i, "a=max-message-size:");
- let c;
- s.length > 0 && (c = parseInt(s[0].substr(19), 10)),
- isNaN(c) && (c = 65536);
- const d = e.matchPrefix(i, "a=sctp-port:");
- if (d.length > 0)
- return {
- port: parseInt(d[0].substr(12), 10),
- protocol: o.fmt,
- maxMessageSize: c
- };
- const _ = e.matchPrefix(i, "a=sctpmap:");
- if (_.length > 0) {
- const b = _[0].substr(10).split(" ");
- return {
- port: parseInt(b[0], 10),
- protocol: b[1],
- maxMessageSize: c
- }
- }
- }
- ,
- e.writeSctpDescription = function(i, o) {
- let s = [];
- return i.protocol !== "DTLS/SCTP" ? s = ["m=" + i.kind + " 9 " + i.protocol + " " + o.protocol + `\r
- `, `c=IN IP4 0.0.0.0\r
- `, "a=sctp-port:" + o.port + `\r
- `] : s = ["m=" + i.kind + " 9 " + i.protocol + " " + o.port + `\r
- `, `c=IN IP4 0.0.0.0\r
- `, "a=sctpmap:" + o.port + " " + o.protocol + ` 65535\r
- `],
- o.maxMessageSize !== void 0 && s.push("a=max-message-size:" + o.maxMessageSize + `\r
- `),
- s.join("")
- }
- ,
- e.generateSessionId = function() {
- return Math.random().toString().substr(2, 21)
- }
- ,
- e.writeSessionBoilerplate = function(i, o, s) {
- let c;
- const d = o !== void 0 ? o : 2;
- return i ? c = i : c = e.generateSessionId(),
- `v=0\r
- o=` + (s || "thisisadapterortc") + " " + c + " " + d + ` IN IP4 127.0.0.1\r
- s=-\r
- t=0 0\r
- `
- }
- ,
- e.getDirection = function(i, o) {
- const s = e.splitLines(i);
- for (let c = 0; c < s.length; c++)
- switch (s[c]) {
- case "a=sendrecv":
- case "a=sendonly":
- case "a=recvonly":
- case "a=inactive":
- return s[c].substr(2)
- }
- return o ? e.getDirection(o) : "sendrecv"
- }
- ,
- e.getKind = function(i) {
- return e.splitLines(i)[0].split(" ")[0].substr(2)
- }
- ,
- e.isRejected = function(i) {
- return i.split(" ", 2)[1] === "0"
- }
- ,
- e.parseMLine = function(i) {
- const s = e.splitLines(i)[0].substr(2).split(" ");
- return {
- kind: s[0],
- port: parseInt(s[1], 10),
- protocol: s[2],
- fmt: s.slice(3).join(" ")
- }
- }
- ,
- e.parseOLine = function(i) {
- const s = e.matchPrefix(i, "o=")[0].substr(2).split(" ");
- return {
- username: s[0],
- sessionId: s[1],
- sessionVersion: parseInt(s[2], 10),
- netType: s[3],
- addressType: s[4],
- address: s[5]
- }
- }
- ,
- e.isValidSDP = function(i) {
- if (typeof i != "string" || i.length === 0)
- return !1;
- const o = e.splitLines(i);
- for (let s = 0; s < o.length; s++)
- if (o[s].length < 2 || o[s].charAt(1) !== "=")
- return !1;
- return !0
- }
- ,
- a.exports = e
- }
- )(sdp$1);
- var SDPUtils = sdp$1.exports
- , sdp = _mergeNamespaces({
- __proto__: null,
- default: SDPUtils
- }, [sdp$1.exports]);
- function shimRTCIceCandidate(a) {
- if (!a.RTCIceCandidate || a.RTCIceCandidate && "foundation"in a.RTCIceCandidate.prototype)
- return;
- const e = a.RTCIceCandidate;
- a.RTCIceCandidate = function(o) {
- if (typeof o == "object" && o.candidate && o.candidate.indexOf("a=") === 0 && (o = JSON.parse(JSON.stringify(o)),
- o.candidate = o.candidate.substr(2)),
- o.candidate && o.candidate.length) {
- const s = new e(o)
- , c = SDPUtils.parseCandidate(o.candidate)
- , d = Object.assign(s, c);
- return d.toJSON = function() {
- return {
- candidate: d.candidate,
- sdpMid: d.sdpMid,
- sdpMLineIndex: d.sdpMLineIndex,
- usernameFragment: d.usernameFragment
- }
- }
- ,
- d
- }
- return new e(o)
- }
- ,
- a.RTCIceCandidate.prototype = e.prototype,
- wrapPeerConnectionEvent(a, "icecandidate", i=>(i.candidate && Object.defineProperty(i, "candidate", {
- value: new a.RTCIceCandidate(i.candidate),
- writable: "false"
- }),
- i))
- }
- function shimMaxMessageSize(a, e) {
- if (!a.RTCPeerConnection)
- return;
- "sctp"in a.RTCPeerConnection.prototype || Object.defineProperty(a.RTCPeerConnection.prototype, "sctp", {
- get() {
- return typeof this._sctp == "undefined" ? null : this._sctp
- }
- });
- const i = function(_) {
- if (!_ || !_.sdp)
- return !1;
- const b = SDPUtils.splitSections(_.sdp);
- return b.shift(),
- b.some(k=>{
- const j = SDPUtils.parseMLine(k);
- return j && j.kind === "application" && j.protocol.indexOf("SCTP") !== -1
- }
- )
- }
- , o = function(_) {
- const b = _.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);
- if (b === null || b.length < 2)
- return -1;
- const k = parseInt(b[1], 10);
- return k !== k ? -1 : k
- }
- , s = function(_) {
- let b = 65536;
- return e.browser === "firefox" && (e.version < 57 ? _ === -1 ? b = 16384 : b = 2147483637 : e.version < 60 ? b = e.version === 57 ? 65535 : 65536 : b = 2147483637),
- b
- }
- , c = function(_, b) {
- let k = 65536;
- e.browser === "firefox" && e.version === 57 && (k = 65535);
- const j = SDPUtils.matchPrefix(_.sdp, "a=max-message-size:");
- return j.length > 0 ? k = parseInt(j[0].substr(19), 10) : e.browser === "firefox" && b !== -1 && (k = 2147483637),
- k
- }
- , d = a.RTCPeerConnection.prototype.setRemoteDescription;
- a.RTCPeerConnection.prototype.setRemoteDescription = function() {
- if (this._sctp = null,
- e.browser === "chrome" && e.version >= 76) {
- const {sdpSemantics: b} = this.getConfiguration();
- b === "plan-b" && Object.defineProperty(this, "sctp", {
- get() {
- return typeof this._sctp == "undefined" ? null : this._sctp
- },
- enumerable: !0,
- configurable: !0
- })
- }
- if (i(arguments[0])) {
- const b = o(arguments[0])
- , k = s(b)
- , j = c(arguments[0], b);
- let$;
- k === 0 && j === 0 ? $ = Number.POSITIVE_INFINITY : k === 0 || j === 0 ? $ = Math.max(k, j) : $ = Math.min(k, j);
- const _e = {};
- Object.defineProperty(_e, "maxMessageSize", {
- get() {
- return $
- }
- }),
- this._sctp = _e
- }
- return d.apply(this, arguments)
- }
- }
- function shimSendThrowTypeError(a) {
- if (!(a.RTCPeerConnection && "createDataChannel"in a.RTCPeerConnection.prototype))
- return;
- function e(o, s) {
- const c = o.send;
- o.send = function() {
- const _ = arguments[0]
- , b = _.length || _.size || _.byteLength;
- if (o.readyState === "open" && s.sctp && b > s.sctp.maxMessageSize)
- throw new TypeError("Message too large (can send a maximum of " + s.sctp.maxMessageSize + " bytes)");
- return c.apply(o, arguments)
- }
- }
- const i = a.RTCPeerConnection.prototype.createDataChannel;
- a.RTCPeerConnection.prototype.createDataChannel = function() {
- const s = i.apply(this, arguments);
- return e(s, this),
- s
- }
- ,
- wrapPeerConnectionEvent(a, "datachannel", o=>(e(o.channel, o.target),
- o))
- }
- function shimConnectionState(a) {
- if (!a.RTCPeerConnection || "connectionState"in a.RTCPeerConnection.prototype)
- return;
- const e = a.RTCPeerConnection.prototype;
- Object.defineProperty(e, "connectionState", {
- get() {
- return {
- completed: "connected",
- checking: "connecting"
- }[this.iceConnectionState] || this.iceConnectionState
- },
- enumerable: !0,
- configurable: !0
- }),
- Object.defineProperty(e, "onconnectionstatechange", {
- get() {
- return this._onconnectionstatechange || null
- },
- set(i) {
- this._onconnectionstatechange && (this.removeEventListener("connectionstatechange", this._onconnectionstatechange),
- delete this._onconnectionstatechange),
- i && this.addEventListener("connectionstatechange", this._onconnectionstatechange = i)
- },
- enumerable: !0,
- configurable: !0
- }),
- ["setLocalDescription", "setRemoteDescription"].forEach(i=>{
- const o = e[i];
- e[i] = function() {
- return this._connectionstatechangepoly || (this._connectionstatechangepoly = s=>{
- const c = s.target;
- if (c._lastConnectionState !== c.connectionState) {
- c._lastConnectionState = c.connectionState;
- const d = new Event("connectionstatechange",s);
- c.dispatchEvent(d)
- }
- return s
- }
- ,
- this.addEventListener("iceconnectionstatechange", this._connectionstatechangepoly)),
- o.apply(this, arguments)
- }
- }
- )
- }
- function removeExtmapAllowMixed(a, e) {
- if (!a.RTCPeerConnection || e.browser === "chrome" && e.version >= 71 || e.browser === "safari" && e.version >= 605)
- return;
- const i = a.RTCPeerConnection.prototype.setRemoteDescription;
- a.RTCPeerConnection.prototype.setRemoteDescription = function(s) {
- if (s && s.sdp && s.sdp.indexOf(`
- a=extmap-allow-mixed`) !== -1) {
- const c = s.sdp.split(`
- `).filter(d=>d.trim() !== "a=extmap-allow-mixed").join(`
- `);
- a.RTCSessionDescription && s instanceof a.RTCSessionDescription ? arguments[0] = new a.RTCSessionDescription({
- type: s.type,
- sdp: c
- }) : s.sdp = c
- }
- return i.apply(this, arguments)
- }
- }
- function shimAddIceCandidateNullOrEmpty(a, e) {
- if (!(a.RTCPeerConnection && a.RTCPeerConnection.prototype))
- return;
- const i = a.RTCPeerConnection.prototype.addIceCandidate;
- !i || i.length === 0 || (a.RTCPeerConnection.prototype.addIceCandidate = function() {
- 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),
- Promise.resolve())
- }
- )
- }
- function shimParameterlessSetLocalDescription(a, e) {
- if (!(a.RTCPeerConnection && a.RTCPeerConnection.prototype))
- return;
- const i = a.RTCPeerConnection.prototype.setLocalDescription;
- !i || i.length === 0 || (a.RTCPeerConnection.prototype.setLocalDescription = function() {
- let s = arguments[0] || {};
- if (typeof s != "object" || s.type && s.sdp)
- return i.apply(this, arguments);
- if (s = {
- type: s.type,
- sdp: s.sdp
- },
- !s.type)
- switch (this.signalingState) {
- case "stable":
- case "have-local-offer":
- case "have-remote-pranswer":
- s.type = "offer";
- break;
- default:
- s.type = "answer";
- break
- }
- 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]))
- }
- )
- }
- var commonShim = Object.freeze(Object.defineProperty({
- __proto__: null,
- shimRTCIceCandidate,
- shimMaxMessageSize,
- shimSendThrowTypeError,
- shimConnectionState,
- removeExtmapAllowMixed,
- shimAddIceCandidateNullOrEmpty,
- shimParameterlessSetLocalDescription
- }, Symbol.toStringTag, {
- value: "Module"
- }));
- function adapterFactory({window: a}={}, e={
- shimChrome: !0,
- shimFirefox: !0,
- shimSafari: !0
- }) {
- const i = log$L
- , o = detectBrowser(a)
- , s = {
- browserDetails: o,
- commonShim,
- extractVersion,
- disableLog,
- disableWarnings,
- sdp
- };
- switch (o.browser) {
- case "chrome":
- if (!chromeShim || !shimPeerConnection$1 || !e.shimChrome)
- return i("Chrome shim is not included in this adapter release."),
- s;
- if (o.version === null)
- return i("Chrome shim can not determine version, not shimming."),
- s;
- i("adapter.js shimming chrome."),
- s.browserShim = chromeShim,
- shimAddIceCandidateNullOrEmpty(a, o),
- shimParameterlessSetLocalDescription(a),
- shimGetUserMedia$2(a, o),
- shimMediaStream(a),
- shimPeerConnection$1(a, o),
- shimOnTrack$1(a),
- shimAddTrackRemoveTrack(a, o),
- shimGetSendersWithDtmf(a),
- shimGetStats(a),
- shimSenderReceiverGetStats(a),
- fixNegotiationNeeded(a, o),
- shimRTCIceCandidate(a),
- shimConnectionState(a),
- shimMaxMessageSize(a, o),
- shimSendThrowTypeError(a),
- removeExtmapAllowMixed(a, o);
- break;
- case "firefox":
- if (!firefoxShim || !shimPeerConnection || !e.shimFirefox)
- return i("Firefox shim is not included in this adapter release."),
- s;
- i("adapter.js shimming firefox."),
- s.browserShim = firefoxShim,
- shimAddIceCandidateNullOrEmpty(a, o),
- shimParameterlessSetLocalDescription(a),
- shimGetUserMedia$1(a, o),
- shimPeerConnection(a, o),
- shimOnTrack(a),
- shimRemoveStream(a),
- shimSenderGetStats(a),
- shimReceiverGetStats(a),
- shimRTCDataChannel(a),
- shimAddTransceiver(a),
- shimGetParameters(a),
- shimCreateOffer(a),
- shimCreateAnswer(a),
- shimRTCIceCandidate(a),
- shimConnectionState(a),
- shimMaxMessageSize(a, o),
- shimSendThrowTypeError(a);
- break;
- case "safari":
- if (!safariShim || !e.shimSafari)
- return i("Safari shim is not included in this adapter release."),
- s;
- i("adapter.js shimming safari."),
- s.browserShim = safariShim,
- shimAddIceCandidateNullOrEmpty(a, o),
- shimParameterlessSetLocalDescription(a),
- shimRTCIceServerUrls(a),
- shimCreateOfferLegacy(a),
- shimCallbacksAPI(a),
- shimLocalStreamsAPI(a),
- shimRemoteStreamsAPI(a),
- shimTrackEventTransceiver(a),
- shimGetUserMedia(a),
- shimAudioContext(a),
- shimRTCIceCandidate(a),
- shimMaxMessageSize(a, o),
- shimSendThrowTypeError(a),
- removeExtmapAllowMixed(a, o);
- break;
- default:
- i("Unsupported browser!");
- break
- }
- return s
- }
- adapterFactory({
- window: typeof window == "undefined" ? void 0 : window
- });
- Promise.prototype._timeout = function(a, e) {
- let i;
- return new Promise((o,s)=>(i = window.setTimeout(()=>{
- s(e)
- }
- , a),
- this.then(c=>{
- clearTimeout(i),
- o(c)
- }
- , c=>{
- clearTimeout(i),
- s(c)
- }
- )))
- }
- ;
- function clear() {
- const a = console.log;
- console.log = function(...e) {
- typeof e[0] == "string" && e[0].indexOf("Babylon.js") == 0 || a(...e)
- }
- }
- clear();
- var Constants = function() {
- function a() {}
- return a.ALPHA_DISABLE = 0,
- a.ALPHA_ADD = 1,
- a.ALPHA_COMBINE = 2,
- a.ALPHA_SUBTRACT = 3,
- a.ALPHA_MULTIPLY = 4,
- a.ALPHA_MAXIMIZED = 5,
- a.ALPHA_ONEONE = 6,
- a.ALPHA_PREMULTIPLIED = 7,
- a.ALPHA_PREMULTIPLIED_PORTERDUFF = 8,
- a.ALPHA_INTERPOLATE = 9,
- a.ALPHA_SCREENMODE = 10,
- a.ALPHA_ONEONE_ONEONE = 11,
- a.ALPHA_ALPHATOCOLOR = 12,
- a.ALPHA_REVERSEONEMINUS = 13,
- a.ALPHA_SRC_DSTONEMINUSSRCALPHA = 14,
- a.ALPHA_ONEONE_ONEZERO = 15,
- a.ALPHA_EXCLUSION = 16,
- a.ALPHA_LAYER_ACCUMULATE = 17,
- a.ALPHA_EQUATION_ADD = 0,
- a.ALPHA_EQUATION_SUBSTRACT = 1,
- a.ALPHA_EQUATION_REVERSE_SUBTRACT = 2,
- a.ALPHA_EQUATION_MAX = 3,
- a.ALPHA_EQUATION_MIN = 4,
- a.ALPHA_EQUATION_DARKEN = 5,
- a.DELAYLOADSTATE_NONE = 0,
- a.DELAYLOADSTATE_LOADED = 1,
- a.DELAYLOADSTATE_LOADING = 2,
- a.DELAYLOADSTATE_NOTLOADED = 4,
- a.NEVER = 512,
- a.ALWAYS = 519,
- a.LESS = 513,
- a.EQUAL = 514,
- a.LEQUAL = 515,
- a.GREATER = 516,
- a.GEQUAL = 518,
- a.NOTEQUAL = 517,
- a.KEEP = 7680,
- a.ZERO = 0,
- a.REPLACE = 7681,
- a.INCR = 7682,
- a.DECR = 7683,
- a.INVERT = 5386,
- a.INCR_WRAP = 34055,
- a.DECR_WRAP = 34056,
- a.TEXTURE_CLAMP_ADDRESSMODE = 0,
- a.TEXTURE_WRAP_ADDRESSMODE = 1,
- a.TEXTURE_MIRROR_ADDRESSMODE = 2,
- a.TEXTURE_CREATIONFLAG_STORAGE = 1,
- a.TEXTUREFORMAT_ALPHA = 0,
- a.TEXTUREFORMAT_LUMINANCE = 1,
- a.TEXTUREFORMAT_LUMINANCE_ALPHA = 2,
- a.TEXTUREFORMAT_RGB = 4,
- a.TEXTUREFORMAT_RGBA = 5,
- a.TEXTUREFORMAT_RED = 6,
- a.TEXTUREFORMAT_R = 6,
- a.TEXTUREFORMAT_RG = 7,
- a.TEXTUREFORMAT_RED_INTEGER = 8,
- a.TEXTUREFORMAT_R_INTEGER = 8,
- a.TEXTUREFORMAT_RG_INTEGER = 9,
- a.TEXTUREFORMAT_RGB_INTEGER = 10,
- a.TEXTUREFORMAT_RGBA_INTEGER = 11,
- a.TEXTUREFORMAT_BGRA = 12,
- a.TEXTUREFORMAT_DEPTH24_STENCIL8 = 13,
- a.TEXTUREFORMAT_DEPTH32_FLOAT = 14,
- a.TEXTUREFORMAT_DEPTH16 = 15,
- a.TEXTUREFORMAT_DEPTH24 = 16,
- a.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM = 36492,
- a.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT = 36495,
- a.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT = 36494,
- a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5 = 33779,
- a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3 = 33778,
- a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1 = 33777,
- a.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1 = 33776,
- a.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4 = 37808,
- a.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL = 36196,
- a.TEXTURETYPE_UNSIGNED_BYTE = 0,
- a.TEXTURETYPE_UNSIGNED_INT = 0,
- a.TEXTURETYPE_FLOAT = 1,
- a.TEXTURETYPE_HALF_FLOAT = 2,
- a.TEXTURETYPE_BYTE = 3,
- a.TEXTURETYPE_SHORT = 4,
- a.TEXTURETYPE_UNSIGNED_SHORT = 5,
- a.TEXTURETYPE_INT = 6,
- a.TEXTURETYPE_UNSIGNED_INTEGER = 7,
- a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = 8,
- a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = 9,
- a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = 10,
- a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = 11,
- a.TEXTURETYPE_UNSIGNED_INT_24_8 = 12,
- a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = 13,
- a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = 14,
- a.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = 15,
- a.TEXTURETYPE_UNDEFINED = 16,
- a.TEXTURE_NEAREST_SAMPLINGMODE = 1,
- a.TEXTURE_NEAREST_NEAREST = 1,
- a.TEXTURE_BILINEAR_SAMPLINGMODE = 2,
- a.TEXTURE_LINEAR_LINEAR = 2,
- a.TEXTURE_TRILINEAR_SAMPLINGMODE = 3,
- a.TEXTURE_LINEAR_LINEAR_MIPLINEAR = 3,
- a.TEXTURE_NEAREST_NEAREST_MIPNEAREST = 4,
- a.TEXTURE_NEAREST_LINEAR_MIPNEAREST = 5,
- a.TEXTURE_NEAREST_LINEAR_MIPLINEAR = 6,
- a.TEXTURE_NEAREST_LINEAR = 7,
- a.TEXTURE_NEAREST_NEAREST_MIPLINEAR = 8,
- a.TEXTURE_LINEAR_NEAREST_MIPNEAREST = 9,
- a.TEXTURE_LINEAR_NEAREST_MIPLINEAR = 10,
- a.TEXTURE_LINEAR_LINEAR_MIPNEAREST = 11,
- a.TEXTURE_LINEAR_NEAREST = 12,
- a.TEXTURE_EXPLICIT_MODE = 0,
- a.TEXTURE_SPHERICAL_MODE = 1,
- a.TEXTURE_PLANAR_MODE = 2,
- a.TEXTURE_CUBIC_MODE = 3,
- a.TEXTURE_PROJECTION_MODE = 4,
- a.TEXTURE_SKYBOX_MODE = 5,
- a.TEXTURE_INVCUBIC_MODE = 6,
- a.TEXTURE_EQUIRECTANGULAR_MODE = 7,
- a.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = 8,
- a.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = 9,
- a.TEXTURE_FILTERING_QUALITY_OFFLINE = 4096,
- a.TEXTURE_FILTERING_QUALITY_HIGH = 64,
- a.TEXTURE_FILTERING_QUALITY_MEDIUM = 16,
- a.TEXTURE_FILTERING_QUALITY_LOW = 8,
- a.SCALEMODE_FLOOR = 1,
- a.SCALEMODE_NEAREST = 2,
- a.SCALEMODE_CEILING = 3,
- a.MATERIAL_TextureDirtyFlag = 1,
- a.MATERIAL_LightDirtyFlag = 2,
- a.MATERIAL_FresnelDirtyFlag = 4,
- a.MATERIAL_AttributesDirtyFlag = 8,
- a.MATERIAL_MiscDirtyFlag = 16,
- a.MATERIAL_PrePassDirtyFlag = 32,
- a.MATERIAL_AllDirtyFlag = 63,
- a.MATERIAL_TriangleFillMode = 0,
- a.MATERIAL_WireFrameFillMode = 1,
- a.MATERIAL_PointFillMode = 2,
- a.MATERIAL_PointListDrawMode = 3,
- a.MATERIAL_LineListDrawMode = 4,
- a.MATERIAL_LineLoopDrawMode = 5,
- a.MATERIAL_LineStripDrawMode = 6,
- a.MATERIAL_TriangleStripDrawMode = 7,
- a.MATERIAL_TriangleFanDrawMode = 8,
- a.MATERIAL_ClockWiseSideOrientation = 0,
- a.MATERIAL_CounterClockWiseSideOrientation = 1,
- a.ACTION_NothingTrigger = 0,
- a.ACTION_OnPickTrigger = 1,
- a.ACTION_OnLeftPickTrigger = 2,
- a.ACTION_OnRightPickTrigger = 3,
- a.ACTION_OnCenterPickTrigger = 4,
- a.ACTION_OnPickDownTrigger = 5,
- a.ACTION_OnDoublePickTrigger = 6,
- a.ACTION_OnPickUpTrigger = 7,
- a.ACTION_OnPickOutTrigger = 16,
- a.ACTION_OnLongPressTrigger = 8,
- a.ACTION_OnPointerOverTrigger = 9,
- a.ACTION_OnPointerOutTrigger = 10,
- a.ACTION_OnEveryFrameTrigger = 11,
- a.ACTION_OnIntersectionEnterTrigger = 12,
- a.ACTION_OnIntersectionExitTrigger = 13,
- a.ACTION_OnKeyDownTrigger = 14,
- a.ACTION_OnKeyUpTrigger = 15,
- a.PARTICLES_BILLBOARDMODE_Y = 2,
- a.PARTICLES_BILLBOARDMODE_ALL = 7,
- a.PARTICLES_BILLBOARDMODE_STRETCHED = 8,
- a.MESHES_CULLINGSTRATEGY_STANDARD = 0,
- a.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = 1,
- a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = 2,
- a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = 3,
- a.SCENELOADER_NO_LOGGING = 0,
- a.SCENELOADER_MINIMAL_LOGGING = 1,
- a.SCENELOADER_SUMMARY_LOGGING = 2,
- a.SCENELOADER_DETAILED_LOGGING = 3,
- a.PREPASS_IRRADIANCE_TEXTURE_TYPE = 0,
- a.PREPASS_POSITION_TEXTURE_TYPE = 1,
- a.PREPASS_VELOCITY_TEXTURE_TYPE = 2,
- a.PREPASS_REFLECTIVITY_TEXTURE_TYPE = 3,
- a.PREPASS_COLOR_TEXTURE_TYPE = 4,
- a.PREPASS_DEPTH_TEXTURE_TYPE = 5,
- a.PREPASS_NORMAL_TEXTURE_TYPE = 6,
- a.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE = 7,
- a.BUFFER_CREATIONFLAG_READ = 1,
- a.BUFFER_CREATIONFLAG_WRITE = 2,
- a.BUFFER_CREATIONFLAG_READWRITE = 3,
- a.BUFFER_CREATIONFLAG_UNIFORM = 4,
- a.BUFFER_CREATIONFLAG_VERTEX = 8,
- a.BUFFER_CREATIONFLAG_INDEX = 16,
- a.BUFFER_CREATIONFLAG_STORAGE = 32,
- a.RENDERPASS_MAIN = 0,
- a.INPUT_ALT_KEY = 18,
- a.INPUT_CTRL_KEY = 17,
- a.INPUT_META_KEY1 = 91,
- a.INPUT_META_KEY2 = 92,
- a.INPUT_META_KEY3 = 93,
- a.INPUT_SHIFT_KEY = 16,
- a.SNAPSHOTRENDERING_STANDARD = 0,
- a.SNAPSHOTRENDERING_FAST = 1,
- a.PERSPECTIVE_CAMERA = 0,
- a.ORTHOGRAPHIC_CAMERA = 1,
- a.FOVMODE_VERTICAL_FIXED = 0,
- a.FOVMODE_HORIZONTAL_FIXED = 1,
- a.RIG_MODE_NONE = 0,
- a.RIG_MODE_STEREOSCOPIC_ANAGLYPH = 10,
- a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL = 11,
- a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED = 12,
- a.RIG_MODE_STEREOSCOPIC_OVERUNDER = 13,
- a.RIG_MODE_STEREOSCOPIC_INTERLACED = 14,
- a.RIG_MODE_VR = 20,
- a.RIG_MODE_WEBVR = 21,
- a.RIG_MODE_CUSTOM = 22,
- a.MAX_SUPPORTED_UV_SETS = 6,
- a.GL_ALPHA_EQUATION_ADD = 32774,
- a.GL_ALPHA_EQUATION_MIN = 32775,
- a.GL_ALPHA_EQUATION_MAX = 32776,
- a.GL_ALPHA_EQUATION_SUBTRACT = 32778,
- a.GL_ALPHA_EQUATION_REVERSE_SUBTRACT = 32779,
- a.GL_ALPHA_FUNCTION_SRC = 768,
- a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR = 769,
- a.GL_ALPHA_FUNCTION_SRC_ALPHA = 770,
- a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA = 771,
- a.GL_ALPHA_FUNCTION_DST_ALPHA = 772,
- a.GL_ALPHA_FUNCTION_ONE_MINUS_DST_ALPHA = 773,
- a.GL_ALPHA_FUNCTION_DST_COLOR = 774,
- a.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR = 775,
- a.GL_ALPHA_FUNCTION_SRC_ALPHA_SATURATED = 776,
- a.GL_ALPHA_FUNCTION_CONSTANT_COLOR = 32769,
- a.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_COLOR = 32770,
- a.GL_ALPHA_FUNCTION_CONSTANT_ALPHA = 32771,
- a.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_ALPHA = 32772,
- a
- }();
- /*! *****************************************************************************
- Copyright (c) Microsoft Corporation.
- Permission to use, copy, modify, and/or distribute this software for any
- purpose with or without fee is hereby granted.
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- PERFORMANCE OF THIS SOFTWARE.
- ***************************************************************************** */
- var extendStatics = function(a, e) {
- return extendStatics = Object.setPrototypeOf || {
- __proto__: []
- }instanceof Array && function(i, o) {
- i.__proto__ = o
- }
- || function(i, o) {
- for (var s in o)
- Object.prototype.hasOwnProperty.call(o, s) && (i[s] = o[s])
- }
- ,
- extendStatics(a, e)
- };
- function __extends(a, e) {
- if (typeof e != "function" && e !== null)
- throw new TypeError("Class extends value " + String(e) + " is not a constructor or null");
- extendStatics(a, e);
- function i() {
- this.constructor = a
- }
- a.prototype = e === null ? Object.create(e) : (i.prototype = e.prototype,
- new i)
- }
- var __assign = function() {
- return __assign = Object.assign || function(e) {
- for (var i, o = 1, s = arguments.length; o < s; o++) {
- i = arguments[o];
- for (var c in i)
- Object.prototype.hasOwnProperty.call(i, c) && (e[c] = i[c])
- }
- return e
- }
- ,
- __assign.apply(this, arguments)
- };
- function __decorate(a, e, i, o) {
- var s = arguments.length, c = s < 3 ? e : o === null ? o = Object.getOwnPropertyDescriptor(e, i) : o, d;
- if (typeof Reflect == "object" && typeof Reflect.decorate == "function")
- c = Reflect.decorate(a, e, i, o);
- else
- for (var _ = a.length - 1; _ >= 0; _--)
- (d = a[_]) && (c = (s < 3 ? d(c) : s > 3 ? d(e, i, c) : d(e, i)) || c);
- return s > 3 && c && Object.defineProperty(e, i, c),
- c
- }
- function __awaiter(a, e, i, o) {
- function s(c) {
- return c instanceof i ? c : new i(function(d) {
- d(c)
- }
- )
- }
- return new (i || (i = Promise))(function(c, d) {
- function _(j) {
- try {
- k(o.next(j))
- } catch ($) {
- d($)
- }
- }
- function b(j) {
- try {
- k(o.throw(j))
- } catch ($) {
- d($)
- }
- }
- function k(j) {
- j.done ? c(j.value) : s(j.value).then(_, b)
- }
- k((o = o.apply(a, e || [])).next())
- }
- )
- }
- function __generator(a, e) {
- var i = {
- label: 0,
- sent: function() {
- if (c[0] & 1)
- throw c[1];
- return c[1]
- },
- trys: [],
- ops: []
- }, o, s, c, d;
- return d = {
- next: _(0),
- throw: _(1),
- return: _(2)
- },
- typeof Symbol == "function" && (d[Symbol.iterator] = function() {
- return this
- }
- ),
- d;
- function _(k) {
- return function(j) {
- return b([k, j])
- }
- }
- function b(k) {
- if (o)
- throw new TypeError("Generator is already executing.");
- for (; i; )
- try {
- if (o = 1,
- s && (c = k[0] & 2 ? s.return : k[0] ? s.throw || ((c = s.return) && c.call(s),
- 0) : s.next) && !(c = c.call(s, k[1])).done)
- return c;
- switch (s = 0,
- c && (k = [k[0] & 2, c.value]),
- k[0]) {
- case 0:
- case 1:
- c = k;
- break;
- case 4:
- return i.label++,
- {
- value: k[1],
- done: !1
- };
- case 5:
- i.label++,
- s = k[1],
- k = [0];
- continue;
- case 7:
- k = i.ops.pop(),
- i.trys.pop();
- continue;
- default:
- if (c = i.trys,
- !(c = c.length > 0 && c[c.length - 1]) && (k[0] === 6 || k[0] === 2)) {
- i = 0;
- continue
- }
- if (k[0] === 3 && (!c || k[1] > c[0] && k[1] < c[3])) {
- i.label = k[1];
- break
- }
- if (k[0] === 6 && i.label < c[1]) {
- i.label = c[1],
- c = k;
- break
- }
- if (c && i.label < c[2]) {
- i.label = c[2],
- i.ops.push(k);
- break
- }
- c[2] && i.ops.pop(),
- i.trys.pop();
- continue
- }
- k = e.call(a, i)
- } catch (j) {
- k = [6, j],
- s = 0
- } finally {
- o = c = 0
- }
- if (k[0] & 5)
- throw k[1];
- return {
- value: k[0] ? k[1] : void 0,
- done: !0
- }
- }
- }
- function __spreadArray(a, e, i) {
- if (i || arguments.length === 2)
- for (var o = 0, s = e.length, c; o < s; o++)
- (c || !(o in e)) && (c || (c = Array.prototype.slice.call(e, 0, o)),
- c[o] = e[o]);
- return a.concat(c || Array.prototype.slice.call(e))
- }
- var EngineStore = function() {
- function a() {}
- return Object.defineProperty(a, "LastCreatedEngine", {
- get: function() {
- return this.Instances.length === 0 ? null : this.Instances[this.Instances.length - 1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "LastCreatedScene", {
- get: function() {
- return this._LastCreatedScene
- },
- enumerable: !1,
- configurable: !0
- }),
- a.Instances = new Array,
- a._LastCreatedScene = null,
- a.UseFallbackTexture = !0,
- a.FallbackTexture = "",
- a
- }()
- , EventState = function() {
- function a(e, i, o, s) {
- i === void 0 && (i = !1),
- this.initialize(e, i, o, s)
- }
- return a.prototype.initialize = function(e, i, o, s) {
- return i === void 0 && (i = !1),
- this.mask = e,
- this.skipNextObservers = i,
- this.target = o,
- this.currentTarget = s,
- this
- }
- ,
- a
- }()
- , Observer = function() {
- function a(e, i, o) {
- o === void 0 && (o = null),
- this.callback = e,
- this.mask = i,
- this.scope = o,
- this._willBeUnregistered = !1,
- this.unregisterOnNextCall = !1
- }
- return a
- }()
- , Observable = function() {
- function a(e) {
- this._observers = new Array,
- this._eventState = new EventState(0),
- e && (this._onObserverAdded = e)
- }
- return a.FromPromise = function(e, i) {
- var o = new a;
- return e.then(function(s) {
- o.notifyObservers(s)
- }).catch(function(s) {
- if (i)
- i.notifyObservers(s);
- else
- throw s
- }),
- o
- }
- ,
- Object.defineProperty(a.prototype, "observers", {
- get: function() {
- return this._observers
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.add = function(e, i, o, s, c) {
- if (i === void 0 && (i = -1),
- o === void 0 && (o = !1),
- s === void 0 && (s = null),
- c === void 0 && (c = !1),
- !e)
- return null;
- var d = new Observer(e,i,s);
- return d.unregisterOnNextCall = c,
- o ? this._observers.unshift(d) : this._observers.push(d),
- this._onObserverAdded && this._onObserverAdded(d),
- d
- }
- ,
- a.prototype.addOnce = function(e) {
- return this.add(e, void 0, void 0, void 0, !0)
- }
- ,
- a.prototype.remove = function(e) {
- if (!e)
- return !1;
- var i = this._observers.indexOf(e);
- return i !== -1 ? (this._deferUnregister(e),
- !0) : !1
- }
- ,
- a.prototype.removeCallback = function(e, i) {
- for (var o = 0; o < this._observers.length; o++) {
- var s = this._observers[o];
- if (!s._willBeUnregistered && s.callback === e && (!i || i === s.scope))
- return this._deferUnregister(s),
- !0
- }
- return !1
- }
- ,
- a.prototype._deferUnregister = function(e) {
- var i = this;
- e.unregisterOnNextCall = !1,
- e._willBeUnregistered = !0,
- setTimeout(function() {
- i._remove(e)
- }, 0)
- }
- ,
- a.prototype._remove = function(e) {
- if (!e)
- return !1;
- var i = this._observers.indexOf(e);
- return i !== -1 ? (this._observers.splice(i, 1),
- !0) : !1
- }
- ,
- a.prototype.makeObserverTopPriority = function(e) {
- this._remove(e),
- this._observers.unshift(e)
- }
- ,
- a.prototype.makeObserverBottomPriority = function(e) {
- this._remove(e),
- this._observers.push(e)
- }
- ,
- a.prototype.notifyObservers = function(e, i, o, s, c) {
- if (i === void 0 && (i = -1),
- !this._observers.length)
- return !0;
- var d = this._eventState;
- d.mask = i,
- d.target = o,
- d.currentTarget = s,
- d.skipNextObservers = !1,
- d.lastReturnValue = e,
- d.userInfo = c;
- for (var _ = 0, b = this._observers; _ < b.length; _++) {
- var k = b[_];
- if (!k._willBeUnregistered && (k.mask & i && (k.scope ? d.lastReturnValue = k.callback.apply(k.scope, [e, d]) : d.lastReturnValue = k.callback(e, d),
- k.unregisterOnNextCall && this._deferUnregister(k)),
- d.skipNextObservers))
- return !1
- }
- return !0
- }
- ,
- a.prototype.notifyObserversWithPromise = function(e, i, o, s, c) {
- var d = this;
- i === void 0 && (i = -1);
- var _ = Promise.resolve(e);
- if (!this._observers.length)
- return _;
- var b = this._eventState;
- return b.mask = i,
- b.target = o,
- b.currentTarget = s,
- b.skipNextObservers = !1,
- b.userInfo = c,
- this._observers.forEach(function(k) {
- b.skipNextObservers || k._willBeUnregistered || k.mask & i && (k.scope ? _ = _.then(function(j) {
- return b.lastReturnValue = j,
- k.callback.apply(k.scope, [e, b])
- }) : _ = _.then(function(j) {
- return b.lastReturnValue = j,
- k.callback(e, b)
- }),
- k.unregisterOnNextCall && d._deferUnregister(k))
- }),
- _.then(function() {
- return e
- })
- }
- ,
- a.prototype.notifyObserver = function(e, i, o) {
- if (o === void 0 && (o = -1),
- !e._willBeUnregistered) {
- var s = this._eventState;
- s.mask = o,
- s.skipNextObservers = !1,
- e.callback(i, s),
- e.unregisterOnNextCall && this._deferUnregister(e)
- }
- }
- ,
- a.prototype.hasObservers = function() {
- return this._observers.length > 0
- }
- ,
- a.prototype.clear = function() {
- this._observers = new Array,
- this._onObserverAdded = null
- }
- ,
- a.prototype.clone = function() {
- var e = new a;
- return e._observers = this._observers.slice(0),
- e
- }
- ,
- a.prototype.hasSpecificMask = function(e) {
- e === void 0 && (e = -1);
- for (var i = 0, o = this._observers; i < o.length; i++) {
- var s = o[i];
- if (s.mask & e || s.mask === e)
- return !0
- }
- return !1
- }
- ,
- a
- }();
- function IsWindowObjectExist() {
- return typeof window != "undefined"
- }
- function IsNavigatorAvailable() {
- return typeof navigator != "undefined"
- }
- function IsDocumentAvailable() {
- return typeof document != "undefined"
- }
- function GetDOMTextContent(a) {
- for (var e = "", i = a.firstChild; i; )
- i.nodeType === 3 && (e += i.textContent),
- i = i.nextSibling;
- return e
- }
- var DomManagement = {
- IsWindowObjectExist,
- IsNavigatorAvailable,
- IsDocumentAvailable,
- GetDOMTextContent
- }
- , Logger$2 = function() {
- function a() {}
- return a._CheckLimit = function(e, i) {
- var o = a._LogLimitOutputs[e];
- return o ? o.current++ : (o = {
- limit: i,
- current: 1
- },
- a._LogLimitOutputs[e] = o),
- o.current <= o.limit
- }
- ,
- a._GenerateLimitMessage = function(e, i) {
- var o = a._LogLimitOutputs[e];
- if (!(!o || !a.MessageLimitReached) && o.current === o.limit)
- switch (i) {
- case 0:
- a.Log(a.MessageLimitReached.replace(/%LIMIT%/g, "" + o.limit).replace(/%TYPE%/g, "log"));
- break;
- case 1:
- a.Warn(a.MessageLimitReached.replace(/%LIMIT%/g, "" + o.limit).replace(/%TYPE%/g, "warning"));
- break;
- case 2:
- a.Error(a.MessageLimitReached.replace(/%LIMIT%/g, "" + o.limit).replace(/%TYPE%/g, "error"));
- break
- }
- }
- ,
- a._AddLogEntry = function(e) {
- a._LogCache = e + a._LogCache,
- a.OnNewCacheEntry && a.OnNewCacheEntry(e)
- }
- ,
- a._FormatMessage = function(e) {
- var i = function(s) {
- return s < 10 ? "0" + s : "" + s
- }
- , o = new Date;
- return "[" + i(o.getHours()) + ":" + i(o.getMinutes()) + ":" + i(o.getSeconds()) + "]: " + e
- }
- ,
- a._LogDisabled = function(e, i) {}
- ,
- a._LogEnabled = function(e, i) {
- if (!(i !== void 0 && !a._CheckLimit(e, i))) {
- var o = a._FormatMessage(e);
- console.log("BJS - " + o);
- var s = "<div style='color:white'>" + o + "</div><br>";
- a._AddLogEntry(s),
- a._GenerateLimitMessage(e, 0)
- }
- }
- ,
- a._WarnDisabled = function(e, i) {}
- ,
- a._WarnEnabled = function(e, i) {
- if (!(i !== void 0 && !a._CheckLimit(e, i))) {
- var o = a._FormatMessage(e);
- console.warn("BJS - " + o);
- var s = "<div style='color:orange'>" + e + "</div><br>";
- a._AddLogEntry(s),
- a._GenerateLimitMessage(e, 1)
- }
- }
- ,
- a._ErrorDisabled = function(e, i) {}
- ,
- a._ErrorEnabled = function(e, i) {
- if (!(i !== void 0 && !a._CheckLimit(e, i))) {
- var o = a._FormatMessage(e);
- a.errorsCount++,
- console.error("BJS - " + o);
- var s = "<div style='color:red'>" + o + "</div><br>";
- a._AddLogEntry(s),
- a._GenerateLimitMessage(e, 2)
- }
- }
- ,
- Object.defineProperty(a, "LogCache", {
- get: function() {
- return a._LogCache
- },
- enumerable: !1,
- configurable: !0
- }),
- a.ClearLogCache = function() {
- a._LogCache = "",
- a._LogLimitOutputs = {},
- a.errorsCount = 0
- }
- ,
- Object.defineProperty(a, "LogLevels", {
- set: function(e) {
- (e & a.MessageLogLevel) === a.MessageLogLevel ? a.Log = a._LogEnabled : a.Log = a._LogDisabled,
- (e & a.WarningLogLevel) === a.WarningLogLevel ? a.Warn = a._WarnEnabled : a.Warn = a._WarnDisabled,
- (e & a.ErrorLogLevel) === a.ErrorLogLevel ? a.Error = a._ErrorEnabled : a.Error = a._ErrorDisabled
- },
- enumerable: !1,
- configurable: !0
- }),
- a.NoneLogLevel = 0,
- a.MessageLogLevel = 1,
- a.WarningLogLevel = 2,
- a.ErrorLogLevel = 4,
- a.AllLogLevel = 7,
- a.MessageLimitReached = "Too many %TYPE%s (%LIMIT%), no more %TYPE%s will be reported for this message.",
- a._LogCache = "",
- a._LogLimitOutputs = {},
- a.errorsCount = 0,
- a.Log = a._LogEnabled,
- a.Warn = a._WarnEnabled,
- a.Error = a._ErrorEnabled,
- a
- }()
- , EndsWith = function(a, e) {
- return a.indexOf(e, a.length - e.length) !== -1
- }
- , StartsWith = function(a, e) {
- return a ? a.indexOf(e) === 0 : !1
- }
- , Decode = function(a) {
- if (typeof TextDecoder != "undefined")
- return new TextDecoder().decode(a);
- for (var e = "", i = 0; i < a.byteLength; i++)
- e += String.fromCharCode(a[i]);
- return e
- }
- , EncodeArrayBufferToBase64 = function(a) {
- 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; )
- o = $[j++],
- s = j < $.length ? $[j++] : Number.NaN,
- c = j < $.length ? $[j++] : Number.NaN,
- d = o >> 2,
- _ = (o & 3) << 4 | s >> 4,
- b = (s & 15) << 2 | c >> 6,
- k = c & 63,
- isNaN(s) ? b = k = 64 : isNaN(c) && (k = 64),
- i += e.charAt(d) + e.charAt(_) + e.charAt(b) + e.charAt(k);
- return i
- }
- , DecodeBase64ToString = function(a) {
- return atob(a)
- }
- , DecodeBase64ToBinary = function(a) {
- for (var e = DecodeBase64ToString(a), i = e.length, o = new Uint8Array(new ArrayBuffer(i)), s = 0; s < i; s++)
- o[s] = e.charCodeAt(s);
- return o.buffer
- }
- , PadNumber = function(a, e) {
- for (var i = String(a); i.length < e; )
- i = "0" + i;
- return i
- }
- , StringTools = {
- EndsWith,
- StartsWith,
- Decode,
- EncodeArrayBufferToBase64,
- DecodeBase64ToString,
- DecodeBase64ToBinary,
- PadNumber
- }
- , ShaderCodeNode = function() {
- function a() {
- this.children = []
- }
- return a.prototype.isValid = function(e) {
- return !0
- }
- ,
- a.prototype.process = function(e, i) {
- var o = "";
- if (this.line) {
- var s = this.line
- , c = i.processor;
- if (c) {
- if (c.lineProcessor && (s = c.lineProcessor(s, i.isFragment, i.processingContext)),
- c.attributeProcessor && StartsWith(this.line, "attribute"))
- s = c.attributeProcessor(this.line, e, i.processingContext);
- else if (c.varyingProcessor && StartsWith(this.line, "varying"))
- s = c.varyingProcessor(this.line, i.isFragment, e, i.processingContext);
- else if (c.uniformProcessor && c.uniformRegexp && c.uniformRegexp.test(this.line))
- i.lookForClosingBracketForUniformBuffer || (s = c.uniformProcessor(this.line, i.isFragment, e, i.processingContext));
- else if (c.uniformBufferProcessor && c.uniformBufferRegexp && c.uniformBufferRegexp.test(this.line))
- i.lookForClosingBracketForUniformBuffer || (s = c.uniformBufferProcessor(this.line, i.isFragment, i.processingContext),
- i.lookForClosingBracketForUniformBuffer = !0);
- else if (c.textureProcessor && c.textureRegexp && c.textureRegexp.test(this.line))
- s = c.textureProcessor(this.line, i.isFragment, e, i.processingContext);
- else if ((c.uniformProcessor || c.uniformBufferProcessor) && StartsWith(this.line, "uniform") && !i.lookForClosingBracketForUniformBuffer) {
- var d = /uniform\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/;
- 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),
- i.lookForClosingBracketForUniformBuffer = !0)
- }
- i.lookForClosingBracketForUniformBuffer && this.line.indexOf("}") !== -1 && (i.lookForClosingBracketForUniformBuffer = !1,
- c.endOfUniformBufferProcessor && (s = c.endOfUniformBufferProcessor(this.line, i.isFragment, i.processingContext)))
- }
- o += s + `\r
- `
- }
- return this.children.forEach(function(_) {
- o += _.process(e, i)
- }),
- this.additionalDefineKey && (e[this.additionalDefineKey] = this.additionalDefineValue || "true"),
- o
- }
- ,
- a
- }()
- , ShaderCodeCursor = function() {
- function a() {}
- return Object.defineProperty(a.prototype, "currentLine", {
- get: function() {
- return this._lines[this.lineIndex]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "canRead", {
- get: function() {
- return this.lineIndex < this._lines.length - 1
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "lines", {
- set: function(e) {
- this._lines = [];
- for (var i = 0, o = e; i < o.length; i++) {
- var s = o[i];
- if (s[0] === "#") {
- this._lines.push(s);
- continue
- }
- for (var c = s.split(";"), d = 0; d < c.length; d++) {
- var _ = c[d];
- _ = _.trim(),
- _ && this._lines.push(_ + (d !== c.length - 1 ? ";" : ""))
- }
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- a
- }()
- , ShaderCodeConditionNode = function(a) {
- __extends(e, a);
- function e() {
- return a !== null && a.apply(this, arguments) || this
- }
- return e.prototype.process = function(i, o) {
- for (var s = 0; s < this.children.length; s++) {
- var c = this.children[s];
- if (c.isValid(i))
- return c.process(i, o)
- }
- return ""
- }
- ,
- e
- }(ShaderCodeNode)
- , ShaderCodeTestNode = function(a) {
- __extends(e, a);
- function e() {
- return a !== null && a.apply(this, arguments) || this
- }
- return e.prototype.isValid = function(i) {
- return this.testExpression.isTrue(i)
- }
- ,
- e
- }(ShaderCodeNode)
- , ShaderDefineExpression = function() {
- function a() {}
- return a.prototype.isTrue = function(e) {
- return !0
- }
- ,
- a.postfixToInfix = function(e) {
- for (var i = [], o = 0, s = e; o < s.length; o++) {
- var c = s[o];
- if (a._OperatorPriority[c] === void 0)
- i.push(c);
- else {
- var d = i[i.length - 1]
- , _ = i[i.length - 2];
- i.length -= 2,
- i.push("(" + _ + c + d + ")")
- }
- }
- return i[i.length - 1]
- }
- ,
- a.infixToPostfix = function(e) {
- for (var i = [], o = -1, s = function() {
- k = k.trim(),
- k !== "" && (i.push(k),
- k = "")
- }, c = function(_e) {
- o < a._Stack.length - 1 && (a._Stack[++o] = _e)
- }, d = function() {
- return a._Stack[o]
- }, _ = function() {
- return o === -1 ? "!!INVALID EXPRESSION!!" : a._Stack[o--]
- }, b = 0, k = ""; b < e.length; ) {
- var j = e.charAt(b)
- , $ = b < e.length - 1 ? e.substr(b, 2) : "";
- if (j === "(")
- k = "",
- c(j);
- else if (j === ")") {
- for (s(); o !== -1 && d() !== "("; )
- i.push(_());
- _()
- } else if (a._OperatorPriority[$] > 1) {
- for (s(); o !== -1 && a._OperatorPriority[d()] >= a._OperatorPriority[$]; )
- i.push(_());
- c($),
- b++
- } else
- k += j;
- b++
- }
- for (s(); o !== -1; )
- d() === "(" ? _() : i.push(_());
- return i
- }
- ,
- a._OperatorPriority = {
- ")": 0,
- "(": 1,
- "||": 2,
- "&&": 3
- },
- a._Stack = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],
- a
- }()
- , ShaderDefineIsDefinedOperator = function(a) {
- __extends(e, a);
- function e(i, o) {
- o === void 0 && (o = !1);
- var s = a.call(this) || this;
- return s.define = i,
- s.not = o,
- s
- }
- return e.prototype.isTrue = function(i) {
- var o = i[this.define] !== void 0;
- return this.not && (o = !o),
- o
- }
- ,
- e
- }(ShaderDefineExpression)
- , ShaderDefineOrOperator = function(a) {
- __extends(e, a);
- function e() {
- return a !== null && a.apply(this, arguments) || this
- }
- return e.prototype.isTrue = function(i) {
- return this.leftOperand.isTrue(i) || this.rightOperand.isTrue(i)
- }
- ,
- e
- }(ShaderDefineExpression)
- , ShaderDefineAndOperator = function(a) {
- __extends(e, a);
- function e() {
- return a !== null && a.apply(this, arguments) || this
- }
- return e.prototype.isTrue = function(i) {
- return this.leftOperand.isTrue(i) && this.rightOperand.isTrue(i)
- }
- ,
- e
- }(ShaderDefineExpression)
- , ShaderDefineArithmeticOperator = function(a) {
- __extends(e, a);
- function e(i, o, s) {
- var c = a.call(this) || this;
- return c.define = i,
- c.operand = o,
- c.testValue = s,
- c
- }
- return e.prototype.isTrue = function(i) {
- var o = i[this.define];
- o === void 0 && (o = this.define);
- var s = !1
- , c = parseInt(o)
- , d = parseInt(this.testValue);
- switch (this.operand) {
- case ">":
- s = c > d;
- break;
- case "<":
- s = c < d;
- break;
- case "<=":
- s = c <= d;
- break;
- case ">=":
- s = c >= d;
- break;
- case "==":
- s = c === d;
- break
- }
- return s
- }
- ,
- e
- }(ShaderDefineExpression);
- function _WarnImport(a) {
- return a + " needs to be imported before as it contains a side-effect required by your code."
- }
- var ShaderLanguage;
- (function(a) {
- a[a.GLSL = 0] = "GLSL",
- a[a.WGSL = 1] = "WGSL"
- }
- )(ShaderLanguage || (ShaderLanguage = {}));
- var regexSE = /defined\s*?\((.+?)\)/g, regexSERevert = /defined\s*?\[(.+?)\]/g, ShaderProcessor = function() {
- function a() {}
- return a.Initialize = function(e) {
- e.processor && e.processor.initializeShaders && e.processor.initializeShaders(e.processingContext)
- }
- ,
- a.Process = function(e, i, o, s) {
- var c = this, d;
- !((d = i.processor) === null || d === void 0) && d.preProcessShaderCode && (e = i.processor.preProcessShaderCode(e)),
- this._ProcessIncludes(e, i, function(_) {
- var b = c._ProcessShaderConversion(_, i, s);
- o(b)
- })
- }
- ,
- a.PreProcess = function(e, i, o, s) {
- var c = this, d;
- !((d = i.processor) === null || d === void 0) && d.preProcessShaderCode && (e = i.processor.preProcessShaderCode(e)),
- this._ProcessIncludes(e, i, function(_) {
- var b = c._ApplyPreProcessing(_, i, s);
- o(b)
- })
- }
- ,
- a.Finalize = function(e, i, o) {
- return !o.processor || !o.processor.finalizeShaders ? {
- vertexCode: e,
- fragmentCode: i
- } : o.processor.finalizeShaders(e, i, o.processingContext)
- }
- ,
- a._ProcessPrecision = function(e, i) {
- var o;
- if (!((o = i.processor) === null || o === void 0) && o.noPrecision)
- return e;
- var s = i.shouldUseHighPrecisionShader;
- return e.indexOf("precision highp float") === -1 ? s ? e = `precision highp float;
- ` + e : e = `precision mediump float;
- ` + e : s || (e = e.replace("precision highp float", "precision mediump float")),
- e
- }
- ,
- a._ExtractOperation = function(e) {
- var i = /defined\((.+)\)/
- , o = i.exec(e);
- if (o && o.length)
- return new ShaderDefineIsDefinedOperator(o[1].trim(),e[0] === "!");
- for (var s = ["==", ">=", "<=", "<", ">"], c = "", d = 0, _ = 0, b = s; _ < b.length && (c = b[_],
- d = e.indexOf(c),
- !(d > -1)); _++)
- ;
- if (d === -1)
- return new ShaderDefineIsDefinedOperator(e);
- var k = e.substring(0, d).trim()
- , j = e.substring(d + c.length).trim();
- return new ShaderDefineArithmeticOperator(k,c,j)
- }
- ,
- a._BuildSubExpression = function(e) {
- e = e.replace(regexSE, "defined[$1]");
- for (var i = ShaderDefineExpression.infixToPostfix(e), o = [], s = 0, c = i; s < c.length; s++) {
- var d = c[s];
- if (d !== "||" && d !== "&&")
- o.push(d);
- else if (o.length >= 2) {
- var _ = o[o.length - 1]
- , b = o[o.length - 2];
- o.length -= 2;
- var k = d == "&&" ? new ShaderDefineAndOperator : new ShaderDefineOrOperator;
- typeof _ == "string" && (_ = _.replace(regexSERevert, "defined($1)")),
- typeof b == "string" && (b = b.replace(regexSERevert, "defined($1)")),
- k.leftOperand = typeof b == "string" ? this._ExtractOperation(b) : b,
- k.rightOperand = typeof _ == "string" ? this._ExtractOperation(_) : _,
- o.push(k)
- }
- }
- var j = o[o.length - 1];
- return typeof j == "string" && (j = j.replace(regexSERevert, "defined($1)")),
- typeof j == "string" ? this._ExtractOperation(j) : j
- }
- ,
- a._BuildExpression = function(e, i) {
- var o = new ShaderCodeTestNode
- , s = e.substring(0, i)
- , c = e.substring(i);
- return c = c.substring(0, (c.indexOf("//") + 1 || c.length + 1) - 1).trim(),
- s === "#ifdef" ? o.testExpression = new ShaderDefineIsDefinedOperator(c) : s === "#ifndef" ? o.testExpression = new ShaderDefineIsDefinedOperator(c,!0) : o.testExpression = this._BuildSubExpression(c),
- o
- }
- ,
- a._MoveCursorWithinIf = function(e, i, o) {
- for (var s = e.currentLine; this._MoveCursor(e, o); ) {
- s = e.currentLine;
- var c = s.substring(0, 5).toLowerCase();
- if (c === "#else") {
- var d = new ShaderCodeNode;
- i.children.push(d),
- this._MoveCursor(e, d);
- return
- } else if (c === "#elif") {
- var _ = this._BuildExpression(s, 5);
- i.children.push(_),
- o = _
- }
- }
- }
- ,
- a._MoveCursor = function(e, i) {
- for (; e.canRead; ) {
- e.lineIndex++;
- var o = e.currentLine
- , s = /(#ifdef)|(#else)|(#elif)|(#endif)|(#ifndef)|(#if)/
- , c = s.exec(o);
- if (c && c.length) {
- var d = c[0];
- switch (d) {
- case "#ifdef":
- {
- var _ = new ShaderCodeConditionNode;
- i.children.push(_);
- var b = this._BuildExpression(o, 6);
- _.children.push(b),
- this._MoveCursorWithinIf(e, _, b);
- break
- }
- case "#else":
- case "#elif":
- return !0;
- case "#endif":
- return !1;
- case "#ifndef":
- {
- var _ = new ShaderCodeConditionNode;
- i.children.push(_);
- var b = this._BuildExpression(o, 7);
- _.children.push(b),
- this._MoveCursorWithinIf(e, _, b);
- break
- }
- case "#if":
- {
- var _ = new ShaderCodeConditionNode
- , b = this._BuildExpression(o, 3);
- i.children.push(_),
- _.children.push(b),
- this._MoveCursorWithinIf(e, _, b);
- break
- }
- }
- } else {
- var k = new ShaderCodeNode;
- if (k.line = o,
- i.children.push(k),
- o[0] === "#" && o[1] === "d") {
- var j = o.replace(";", "").split(" ");
- k.additionalDefineKey = j[1],
- j.length === 3 && (k.additionalDefineValue = j[2])
- }
- }
- }
- return !1
- }
- ,
- a._EvaluatePreProcessors = function(e, i, o) {
- var s = new ShaderCodeNode
- , c = new ShaderCodeCursor;
- return c.lineIndex = -1,
- c.lines = e.split(`
- `),
- this._MoveCursor(c, s),
- s.process(i, o)
- }
- ,
- a._PreparePreProcessors = function(e, i) {
- for (var o, s = e.defines, c = {}, d = 0, _ = s; d < _.length; d++) {
- var b = _[d]
- , k = b.replace("#define", "").replace(";", "").trim()
- , j = k.split(" ");
- c[j[0]] = j.length > 1 ? j[1] : ""
- }
- return ((o = e.processor) === null || o === void 0 ? void 0 : o.shaderLanguage) === ShaderLanguage.GLSL && (c.GL_ES = "true"),
- c.__VERSION__ = e.version,
- c[e.platformName] = "true",
- i._getGlobalDefines(c),
- c
- }
- ,
- a._ProcessShaderConversion = function(e, i, o) {
- var s = this._ProcessPrecision(e, i);
- if (!i.processor)
- return s;
- if (i.processor.shaderLanguage === ShaderLanguage.GLSL && s.indexOf("#version 3") !== -1)
- return s.replace("#version 300 es", "");
- var c = i.defines
- , d = this._PreparePreProcessors(i, o);
- return i.processor.preProcessor && (s = i.processor.preProcessor(s, c, i.isFragment, i.processingContext)),
- s = this._EvaluatePreProcessors(s, d, i),
- i.processor.postProcessor && (s = i.processor.postProcessor(s, c, i.isFragment, i.processingContext, o)),
- o._features.needShaderCodeInlining && (s = o.inlineShaderCode(s)),
- s
- }
- ,
- a._ApplyPreProcessing = function(e, i, o) {
- var s, c, d = e, _ = i.defines, b = this._PreparePreProcessors(i, o);
- return !((s = i.processor) === null || s === void 0) && s.preProcessor && (d = i.processor.preProcessor(d, _, i.isFragment, i.processingContext)),
- d = this._EvaluatePreProcessors(d, b, i),
- !((c = i.processor) === null || c === void 0) && c.postProcessor && (d = i.processor.postProcessor(d, _, i.isFragment, i.processingContext, o)),
- o._features.needShaderCodeInlining && (d = o.inlineShaderCode(d)),
- d
- }
- ,
- a._ProcessIncludes = function(e, i, o) {
- for (var s = this, c = /#include\s?<(.+)>(\((.*)\))*(\[(.*)\])*/g, d = c.exec(e), _ = new String(e), b = !1; d != null; ) {
- var k = d[1];
- if (k.indexOf("__decl__") !== -1 && (k = k.replace(/__decl__/, ""),
- i.supportsUniformBuffers && (k = k.replace(/Vertex/, "Ubo"),
- k = k.replace(/Fragment/, "Ubo")),
- k = k + "Declaration"),
- i.includesShadersStore[k]) {
- var j = i.includesShadersStore[k];
- if (d[2])
- for (var $ = d[3].split(","), _e = 0; _e < $.length; _e += 2) {
- var et = new RegExp($[_e],"g")
- , tt = $[_e + 1];
- j = j.replace(et, tt)
- }
- if (d[4]) {
- var rt = d[5];
- if (rt.indexOf("..") !== -1) {
- var it = rt.split("..")
- , nt = parseInt(it[0])
- , ot = parseInt(it[1])
- , at = j.slice(0);
- j = "",
- isNaN(ot) && (ot = i.indexParameters[it[1]]);
- for (var st = nt; st < ot; st++)
- i.supportsUniformBuffers || (at = at.replace(/light\{X\}.(\w*)/g, function(ct, lt) {
- return lt + "{X}"
- })),
- j += at.replace(/\{X\}/g, st.toString()) + `
- `
- } else
- i.supportsUniformBuffers || (j = j.replace(/light\{X\}.(\w*)/g, function(ct, lt) {
- return lt + "{X}"
- })),
- j = j.replace(/\{X\}/g, rt)
- }
- _ = _.replace(d[0], j),
- b = b || j.indexOf("#include<") >= 0 || j.indexOf("#include <") >= 0
- } else {
- var ut = i.shadersRepository + "ShadersInclude/" + k + ".fx";
- a._FileToolsLoadFile(ut, function(ct) {
- i.includesShadersStore[k] = ct,
- s._ProcessIncludes(_, i, o)
- });
- return
- }
- d = c.exec(e)
- }
- b ? this._ProcessIncludes(_.toString(), i, o) : o(_)
- }
- ,
- a._FileToolsLoadFile = function(e, i, o, s, c, d) {
- throw _WarnImport("FileTools")
- }
- ,
- a
- }(), ShaderStore = function() {
- function a() {}
- return a.GetShadersRepository = function(e) {
- return e === void 0 && (e = ShaderLanguage.GLSL),
- e === ShaderLanguage.GLSL ? a.ShadersRepository : a.ShadersRepositoryWGSL
- }
- ,
- a.GetShadersStore = function(e) {
- return e === void 0 && (e = ShaderLanguage.GLSL),
- e === ShaderLanguage.GLSL ? a.ShadersStore : a.ShadersStoreWGSL
- }
- ,
- a.GetIncludesShadersStore = function(e) {
- return e === void 0 && (e = ShaderLanguage.GLSL),
- e === ShaderLanguage.GLSL ? a.IncludesShadersStore : a.IncludesShadersStoreWGSL
- }
- ,
- a.ShadersRepository = "src/Shaders/",
- a.ShadersStore = {},
- a.IncludesShadersStore = {},
- a.ShadersRepositoryWGSL = "src/ShadersWGSL/",
- a.ShadersStoreWGSL = {},
- a.IncludesShadersStoreWGSL = {},
- a
- }(), Effect = function() {
- function a(e, i, o, s, c, d, _, b, k, j, $, _e) {
- var et = this;
- s === void 0 && (s = null),
- d === void 0 && (d = null),
- _ === void 0 && (_ = null),
- b === void 0 && (b = null),
- k === void 0 && (k = null),
- $ === void 0 && ($ = ""),
- _e === void 0 && (_e = ShaderLanguage.GLSL);
- var tt, rt;
- this.name = null,
- this.defines = "",
- this.onCompiled = null,
- this.onError = null,
- this.onBind = null,
- this.uniqueId = 0,
- this.onCompileObservable = new Observable,
- this.onErrorObservable = new Observable,
- this._onBindObservable = null,
- this._wasPreviouslyReady = !1,
- this._bonesComputationForcedToCPU = !1,
- this._uniformBuffersNames = {},
- this._multiTarget = !1,
- this._samplers = {},
- this._isReady = !1,
- this._compilationError = "",
- this._allFallbacksProcessed = !1,
- this._uniforms = {},
- this._key = "",
- this._fallbacks = null,
- this._vertexSourceCodeOverride = "",
- this._fragmentSourceCodeOverride = "",
- this._transformFeedbackVaryings = null,
- this._pipelineContext = null,
- this._vertexSourceCode = "",
- this._fragmentSourceCode = "",
- this._rawVertexSourceCode = "",
- this._rawFragmentSourceCode = "",
- this.name = e,
- this._key = $;
- var it = null;
- if (i.attributes) {
- var nt = i;
- if (this._engine = o,
- this._attributesNames = nt.attributes,
- this._uniformsNames = nt.uniformsNames.concat(nt.samplers),
- this._samplerList = nt.samplers.slice(),
- this.defines = nt.defines,
- this.onError = nt.onError,
- this.onCompiled = nt.onCompiled,
- this._fallbacks = nt.fallbacks,
- this._indexParameters = nt.indexParameters,
- this._transformFeedbackVaryings = nt.transformFeedbackVaryings || null,
- this._multiTarget = !!nt.multiTarget,
- this._shaderLanguage = (tt = nt.shaderLanguage) !== null && tt !== void 0 ? tt : ShaderLanguage.GLSL,
- nt.uniformBuffersNames) {
- this._uniformBuffersNamesList = nt.uniformBuffersNames.slice();
- for (var ot = 0; ot < nt.uniformBuffersNames.length; ot++)
- this._uniformBuffersNames[nt.uniformBuffersNames[ot]] = ot
- }
- it = (rt = nt.processFinalCode) !== null && rt !== void 0 ? rt : null
- } else
- this._engine = c,
- this.defines = d == null ? "" : d,
- this._uniformsNames = o.concat(s),
- this._samplerList = s ? s.slice() : [],
- this._attributesNames = i,
- this._uniformBuffersNamesList = [],
- this._shaderLanguage = _e,
- this.onError = k,
- this.onCompiled = b,
- this._indexParameters = j,
- this._fallbacks = _;
- this._attributeLocationByName = {},
- this.uniqueId = a._uniqueIdSeed++;
- var at, st, ut = IsWindowObjectExist() ? this._engine.getHostDocument() : null;
- e.vertexSource ? at = "source:" + e.vertexSource : e.vertexElement ? (at = ut ? ut.getElementById(e.vertexElement) : null,
- at || (at = e.vertexElement)) : at = e.vertex || e,
- e.fragmentSource ? st = "source:" + e.fragmentSource : e.fragmentElement ? (st = ut ? ut.getElementById(e.fragmentElement) : null,
- st || (st = e.fragmentElement)) : st = e.fragment || e,
- this._processingContext = this._engine._getShaderProcessingContext(this._shaderLanguage);
- var ct = {
- defines: this.defines.split(`
- `),
- indexParameters: this._indexParameters,
- isFragment: !1,
- shouldUseHighPrecisionShader: this._engine._shouldUseHighPrecisionShader,
- processor: this._engine._getShaderProcessor(this._shaderLanguage),
- supportsUniformBuffers: this._engine.supportsUniformBuffers,
- shadersRepository: ShaderStore.GetShadersRepository(this._shaderLanguage),
- includesShadersStore: ShaderStore.GetIncludesShadersStore(this._shaderLanguage),
- version: (this._engine.version * 100).toString(),
- platformName: this._engine.shaderPlatformName,
- processingContext: this._processingContext,
- isNDCHalfZRange: this._engine.isNDCHalfZRange,
- useReverseDepthBuffer: this._engine.useReverseDepthBuffer
- }
- , lt = [void 0, void 0]
- , ft = function() {
- if (lt[0] && lt[1]) {
- ct.isFragment = !0;
- var ht = lt[0]
- , pt = lt[1];
- ShaderProcessor.Process(pt, ct, function(dt) {
- it && (dt = it("fragment", dt));
- var _t = ShaderProcessor.Finalize(ht, dt, ct);
- et._useFinalCode(_t.vertexCode, _t.fragmentCode, e)
- }, et._engine)
- }
- };
- this._loadShader(at, "Vertex", "", function(ht) {
- ShaderProcessor.Initialize(ct),
- ShaderProcessor.Process(ht, ct, function(pt) {
- et._rawVertexSourceCode = ht,
- it && (pt = it("vertex", pt)),
- lt[0] = pt,
- ft()
- }, et._engine)
- }),
- this._loadShader(st, "Fragment", "Pixel", function(ht) {
- et._rawFragmentSourceCode = ht,
- lt[1] = ht,
- ft()
- })
- }
- return Object.defineProperty(a, "ShadersRepository", {
- get: function() {
- return ShaderStore.ShadersRepository
- },
- set: function(e) {
- ShaderStore.ShadersRepository = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "onBindObservable", {
- get: function() {
- return this._onBindObservable || (this._onBindObservable = new Observable),
- this._onBindObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._useFinalCode = function(e, i, o) {
- if (o) {
- var s = o.vertexElement || o.vertex || o.spectorName || o
- , c = o.fragmentElement || o.fragment || o.spectorName || o;
- this._vertexSourceCode = (this._shaderLanguage === ShaderLanguage.WGSL ? "//" : "") + "#define SHADER_NAME vertex:" + s + `
- ` + e,
- this._fragmentSourceCode = (this._shaderLanguage === ShaderLanguage.WGSL ? "//" : "") + "#define SHADER_NAME fragment:" + c + `
- ` + i
- } else
- this._vertexSourceCode = e,
- this._fragmentSourceCode = i;
- this._prepareEffect()
- }
- ,
- Object.defineProperty(a.prototype, "key", {
- get: function() {
- return this._key
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.isReady = function() {
- try {
- return this._isReadyInternal()
- } catch {
- return !1
- }
- }
- ,
- a.prototype._isReadyInternal = function() {
- return this._isReady ? !0 : this._pipelineContext ? this._pipelineContext.isReady : !1
- }
- ,
- a.prototype.getEngine = function() {
- return this._engine
- }
- ,
- a.prototype.getPipelineContext = function() {
- return this._pipelineContext
- }
- ,
- a.prototype.getAttributesNames = function() {
- return this._attributesNames
- }
- ,
- a.prototype.getAttributeLocation = function(e) {
- return this._attributes[e]
- }
- ,
- a.prototype.getAttributeLocationByName = function(e) {
- return this._attributeLocationByName[e]
- }
- ,
- a.prototype.getAttributesCount = function() {
- return this._attributes.length
- }
- ,
- a.prototype.getUniformIndex = function(e) {
- return this._uniformsNames.indexOf(e)
- }
- ,
- a.prototype.getUniform = function(e) {
- return this._uniforms[e]
- }
- ,
- a.prototype.getSamplers = function() {
- return this._samplerList
- }
- ,
- a.prototype.getUniformNames = function() {
- return this._uniformsNames
- }
- ,
- a.prototype.getUniformBuffersNames = function() {
- return this._uniformBuffersNamesList
- }
- ,
- a.prototype.getIndexParameters = function() {
- return this._indexParameters
- }
- ,
- a.prototype.getCompilationError = function() {
- return this._compilationError
- }
- ,
- a.prototype.allFallbacksProcessed = function() {
- return this._allFallbacksProcessed
- }
- ,
- a.prototype.executeWhenCompiled = function(e) {
- var i = this;
- if (this.isReady()) {
- e(this);
- return
- }
- this.onCompileObservable.add(function(o) {
- e(o)
- }),
- (!this._pipelineContext || this._pipelineContext.isAsync) && setTimeout(function() {
- i._checkIsReady(null)
- }, 16)
- }
- ,
- a.prototype._checkIsReady = function(e) {
- var i = this;
- try {
- if (this._isReadyInternal())
- return
- } catch (o) {
- this._processCompilationErrors(o, e);
- return
- }
- setTimeout(function() {
- i._checkIsReady(e)
- }, 16)
- }
- ,
- a.prototype._loadShader = function(e, i, o, s) {
- if (typeof HTMLElement != "undefined" && e instanceof HTMLElement) {
- var c = GetDOMTextContent(e);
- s(c);
- return
- }
- if (e.substr(0, 7) === "source:") {
- s(e.substr(7));
- return
- }
- if (e.substr(0, 7) === "base64:") {
- var d = window.atob(e.substr(7));
- s(d);
- return
- }
- var _ = ShaderStore.GetShadersStore(this._shaderLanguage);
- if (_[e + i + "Shader"]) {
- s(_[e + i + "Shader"]);
- return
- }
- if (o && _[e + o + "Shader"]) {
- s(_[e + o + "Shader"]);
- return
- }
- var b;
- e[0] === "." || e[0] === "/" || e.indexOf("http") > -1 ? b = e : b = ShaderStore.GetShadersRepository(this._shaderLanguage) + e,
- this._engine._loadFile(b + "." + i.toLowerCase() + ".fx", s)
- }
- ,
- Object.defineProperty(a.prototype, "vertexSourceCode", {
- get: function() {
- var e, i;
- 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
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "fragmentSourceCode", {
- get: function() {
- var e, i;
- 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
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "rawVertexSourceCode", {
- get: function() {
- return this._rawVertexSourceCode
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "rawFragmentSourceCode", {
- get: function() {
- return this._rawFragmentSourceCode
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._rebuildProgram = function(e, i, o, s) {
- var c = this;
- this._isReady = !1,
- this._vertexSourceCodeOverride = e,
- this._fragmentSourceCodeOverride = i,
- this.onError = function(d, _) {
- s && s(_)
- }
- ,
- this.onCompiled = function() {
- var d = c.getEngine().scenes;
- if (d)
- for (var _ = 0; _ < d.length; _++)
- d[_].markAllMaterialsAsDirty(63);
- c._pipelineContext._handlesSpectorRebuildCallback(o)
- }
- ,
- this._fallbacks = null,
- this._prepareEffect()
- }
- ,
- a.prototype._prepareEffect = function() {
- var e = this
- , i = this._attributesNames
- , o = this.defines
- , s = this._pipelineContext;
- this._isReady = !1;
- try {
- var c = this._engine;
- this._pipelineContext = c.createPipelineContext(this._processingContext),
- this._pipelineContext._name = this._key;
- var d = this._rebuildProgram.bind(this);
- 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),
- c._executeWhenRenderingStateIsCompiled(this._pipelineContext, function() {
- if (e._attributes = [],
- e._pipelineContext._fillEffectInformation(e, e._uniformBuffersNames, e._uniformsNames, e._uniforms, e._samplerList, e._samplers, i, e._attributes),
- i)
- for (var _ = 0; _ < i.length; _++) {
- var b = i[_];
- e._attributeLocationByName[b] = e._attributes[_]
- }
- c.bindSamplers(e),
- e._compilationError = "",
- e._isReady = !0,
- e.onCompiled && e.onCompiled(e),
- e.onCompileObservable.notifyObservers(e),
- e.onCompileObservable.clear(),
- e._fallbacks && e._fallbacks.unBindMesh(),
- s && e.getEngine()._deletePipelineContext(s)
- }),
- this._pipelineContext.isAsync && this._checkIsReady(s)
- } catch (_) {
- this._processCompilationErrors(_, s)
- }
- }
- ,
- a.prototype._getShaderCodeAndErrorLine = function(e, i, o) {
- var s = o ? /FRAGMENT SHADER ERROR: 0:(\d+?):/ : /VERTEX SHADER ERROR: 0:(\d+?):/
- , c = null;
- if (i && e) {
- var d = i.match(s);
- if (d && d.length === 2) {
- var _ = parseInt(d[1])
- , b = e.split(`
- `, -1);
- b.length >= _ && (c = "Offending line [" + _ + "] in " + (o ? "fragment" : "vertex") + " code: " + b[_ - 1])
- }
- }
- return [e, c]
- }
- ,
- a.prototype._processCompilationErrors = function(e, i) {
- var o, s, c, d, _;
- i === void 0 && (i = null),
- this._compilationError = e.message;
- var b = this._attributesNames
- , k = this._fallbacks;
- if (Logger$2.Error("Unable to compile effect:"),
- Logger$2.Error("Uniforms: " + this._uniformsNames.map(function(et) {
- return " " + et
- })),
- Logger$2.Error("Attributes: " + b.map(function(et) {
- return " " + et
- })),
- Logger$2.Error(`Defines:\r
- ` + this.defines),
- a.LogShaderCodeOnCompilationError) {
- var j = null
- , $ = null
- , _e = null;
- !((c = this._pipelineContext) === null || c === void 0) && c._getVertexShaderCode() && (o = this._getShaderCodeAndErrorLine(this._pipelineContext._getVertexShaderCode(), this._compilationError, !1),
- _e = o[0],
- j = o[1],
- _e && (Logger$2.Error("Vertex code:"),
- Logger$2.Error(_e))),
- !((d = this._pipelineContext) === null || d === void 0) && d._getFragmentShaderCode() && (s = this._getShaderCodeAndErrorLine((_ = this._pipelineContext) === null || _ === void 0 ? void 0 : _._getFragmentShaderCode(), this._compilationError, !0),
- _e = s[0],
- $ = s[1],
- _e && (Logger$2.Error("Fragment code:"),
- Logger$2.Error(_e))),
- j && Logger$2.Error(j),
- $ && Logger$2.Error($)
- }
- Logger$2.Error("Error: " + this._compilationError),
- i && (this._pipelineContext = i,
- this._isReady = !0,
- this.onError && this.onError(this, this._compilationError),
- this.onErrorObservable.notifyObservers(this)),
- k ? (this._pipelineContext = null,
- k.hasMoreFallbacks ? (this._allFallbacksProcessed = !1,
- Logger$2.Error("Trying next fallback."),
- this.defines = k.reduce(this.defines, this),
- this._prepareEffect()) : (this._allFallbacksProcessed = !0,
- this.onError && this.onError(this, this._compilationError),
- this.onErrorObservable.notifyObservers(this),
- this.onErrorObservable.clear(),
- this._fallbacks && this._fallbacks.unBindMesh())) : this._allFallbacksProcessed = !0
- }
- ,
- Object.defineProperty(a.prototype, "isSupported", {
- get: function() {
- return this._compilationError === ""
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._bindTexture = function(e, i) {
- this._engine._bindTexture(this._samplers[e], i, e)
- }
- ,
- a.prototype.setTexture = function(e, i) {
- this._engine.setTexture(this._samplers[e], this._uniforms[e], i, e)
- }
- ,
- a.prototype.setDepthStencilTexture = function(e, i) {
- this._engine.setDepthStencilTexture(this._samplers[e], this._uniforms[e], i, e)
- }
- ,
- a.prototype.setTextureArray = function(e, i) {
- var o = e + "Ex";
- if (this._samplerList.indexOf(o + "0") === -1) {
- for (var s = this._samplerList.indexOf(e), c = 1; c < i.length; c++) {
- var d = o + (c - 1).toString();
- this._samplerList.splice(s + c, 0, d)
- }
- for (var _ = 0, b = 0, k = this._samplerList; b < k.length; b++) {
- var j = k[b];
- this._samplers[j] = _,
- _ += 1
- }
- }
- this._engine.setTextureArray(this._samplers[e], this._uniforms[e], i, e)
- }
- ,
- a.prototype.setTextureFromPostProcess = function(e, i) {
- this._engine.setTextureFromPostProcess(this._samplers[e], i, e)
- }
- ,
- a.prototype.setTextureFromPostProcessOutput = function(e, i) {
- this._engine.setTextureFromPostProcessOutput(this._samplers[e], i, e)
- }
- ,
- a.prototype.bindUniformBuffer = function(e, i) {
- var o = this._uniformBuffersNames[i];
- o === void 0 || a._baseCache[o] === e && this._engine._features.useUBOBindingCache || (a._baseCache[o] = e,
- this._engine.bindUniformBufferBase(e, o, i))
- }
- ,
- a.prototype.bindUniformBlock = function(e, i) {
- this._engine.bindUniformBlock(this._pipelineContext, e, i)
- }
- ,
- a.prototype.setInt = function(e, i) {
- return this._pipelineContext.setInt(e, i),
- this
- }
- ,
- a.prototype.setInt2 = function(e, i, o) {
- return this._pipelineContext.setInt2(e, i, o),
- this
- }
- ,
- a.prototype.setInt3 = function(e, i, o, s) {
- return this._pipelineContext.setInt3(e, i, o, s),
- this
- }
- ,
- a.prototype.setInt4 = function(e, i, o, s, c) {
- return this._pipelineContext.setInt4(e, i, o, s, c),
- this
- }
- ,
- a.prototype.setIntArray = function(e, i) {
- return this._pipelineContext.setIntArray(e, i),
- this
- }
- ,
- a.prototype.setIntArray2 = function(e, i) {
- return this._pipelineContext.setIntArray2(e, i),
- this
- }
- ,
- a.prototype.setIntArray3 = function(e, i) {
- return this._pipelineContext.setIntArray3(e, i),
- this
- }
- ,
- a.prototype.setIntArray4 = function(e, i) {
- return this._pipelineContext.setIntArray4(e, i),
- this
- }
- ,
- a.prototype.setFloatArray = function(e, i) {
- return this._pipelineContext.setArray(e, i),
- this
- }
- ,
- a.prototype.setFloatArray2 = function(e, i) {
- return this._pipelineContext.setArray2(e, i),
- this
- }
- ,
- a.prototype.setFloatArray3 = function(e, i) {
- return this._pipelineContext.setArray3(e, i),
- this
- }
- ,
- a.prototype.setFloatArray4 = function(e, i) {
- return this._pipelineContext.setArray4(e, i),
- this
- }
- ,
- a.prototype.setArray = function(e, i) {
- return this._pipelineContext.setArray(e, i),
- this
- }
- ,
- a.prototype.setArray2 = function(e, i) {
- return this._pipelineContext.setArray2(e, i),
- this
- }
- ,
- a.prototype.setArray3 = function(e, i) {
- return this._pipelineContext.setArray3(e, i),
- this
- }
- ,
- a.prototype.setArray4 = function(e, i) {
- return this._pipelineContext.setArray4(e, i),
- this
- }
- ,
- a.prototype.setMatrices = function(e, i) {
- return this._pipelineContext.setMatrices(e, i),
- this
- }
- ,
- a.prototype.setMatrix = function(e, i) {
- return this._pipelineContext.setMatrix(e, i),
- this
- }
- ,
- a.prototype.setMatrix3x3 = function(e, i) {
- return this._pipelineContext.setMatrix3x3(e, i),
- this
- }
- ,
- a.prototype.setMatrix2x2 = function(e, i) {
- return this._pipelineContext.setMatrix2x2(e, i),
- this
- }
- ,
- a.prototype.setFloat = function(e, i) {
- return this._pipelineContext.setFloat(e, i),
- this
- }
- ,
- a.prototype.setBool = function(e, i) {
- return this._pipelineContext.setInt(e, i ? 1 : 0),
- this
- }
- ,
- a.prototype.setVector2 = function(e, i) {
- return this._pipelineContext.setVector2(e, i),
- this
- }
- ,
- a.prototype.setFloat2 = function(e, i, o) {
- return this._pipelineContext.setFloat2(e, i, o),
- this
- }
- ,
- a.prototype.setVector3 = function(e, i) {
- return this._pipelineContext.setVector3(e, i),
- this
- }
- ,
- a.prototype.setFloat3 = function(e, i, o, s) {
- return this._pipelineContext.setFloat3(e, i, o, s),
- this
- }
- ,
- a.prototype.setVector4 = function(e, i) {
- return this._pipelineContext.setVector4(e, i),
- this
- }
- ,
- a.prototype.setFloat4 = function(e, i, o, s, c) {
- return this._pipelineContext.setFloat4(e, i, o, s, c),
- this
- }
- ,
- a.prototype.setColor3 = function(e, i) {
- return this._pipelineContext.setColor3(e, i),
- this
- }
- ,
- a.prototype.setColor4 = function(e, i, o) {
- return this._pipelineContext.setColor4(e, i, o),
- this
- }
- ,
- a.prototype.setDirectColor4 = function(e, i) {
- return this._pipelineContext.setDirectColor4(e, i),
- this
- }
- ,
- a.prototype.dispose = function() {
- this._pipelineContext && this._pipelineContext.dispose(),
- this._engine._releaseEffect(this)
- }
- ,
- a.RegisterShader = function(e, i, o, s) {
- s === void 0 && (s = ShaderLanguage.GLSL),
- i && (ShaderStore.GetShadersStore(s)[e + "PixelShader"] = i),
- o && (ShaderStore.GetShadersStore(s)[e + "VertexShader"] = o)
- }
- ,
- a.ResetCache = function() {
- a._baseCache = {}
- }
- ,
- a.LogShaderCodeOnCompilationError = !0,
- a._uniqueIdSeed = 0,
- a._baseCache = {},
- a.ShadersStore = ShaderStore.ShadersStore,
- a.IncludesShadersStore = ShaderStore.IncludesShadersStore,
- a
- }(), DepthCullingState = function() {
- function a(e) {
- e === void 0 && (e = !0),
- this._isDepthTestDirty = !1,
- this._isDepthMaskDirty = !1,
- this._isDepthFuncDirty = !1,
- this._isCullFaceDirty = !1,
- this._isCullDirty = !1,
- this._isZOffsetDirty = !1,
- this._isFrontFaceDirty = !1,
- e && this.reset()
- }
- return Object.defineProperty(a.prototype, "isDirty", {
- get: function() {
- return this._isDepthFuncDirty || this._isDepthTestDirty || this._isDepthMaskDirty || this._isCullFaceDirty || this._isCullDirty || this._isZOffsetDirty || this._isFrontFaceDirty
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "zOffset", {
- get: function() {
- return this._zOffset
- },
- set: function(e) {
- this._zOffset !== e && (this._zOffset = e,
- this._isZOffsetDirty = !0)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "zOffsetUnits", {
- get: function() {
- return this._zOffsetUnits
- },
- set: function(e) {
- this._zOffsetUnits !== e && (this._zOffsetUnits = e,
- this._isZOffsetDirty = !0)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "cullFace", {
- get: function() {
- return this._cullFace
- },
- set: function(e) {
- this._cullFace !== e && (this._cullFace = e,
- this._isCullFaceDirty = !0)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "cull", {
- get: function() {
- return this._cull
- },
- set: function(e) {
- this._cull !== e && (this._cull = e,
- this._isCullDirty = !0)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "depthFunc", {
- get: function() {
- return this._depthFunc
- },
- set: function(e) {
- this._depthFunc !== e && (this._depthFunc = e,
- this._isDepthFuncDirty = !0)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "depthMask", {
- get: function() {
- return this._depthMask
- },
- set: function(e) {
- this._depthMask !== e && (this._depthMask = e,
- this._isDepthMaskDirty = !0)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "depthTest", {
- get: function() {
- return this._depthTest
- },
- set: function(e) {
- this._depthTest !== e && (this._depthTest = e,
- this._isDepthTestDirty = !0)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "frontFace", {
- get: function() {
- return this._frontFace
- },
- set: function(e) {
- this._frontFace !== e && (this._frontFace = e,
- this._isFrontFaceDirty = !0)
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.reset = function() {
- this._depthMask = !0,
- this._depthTest = !0,
- this._depthFunc = null,
- this._cullFace = null,
- this._cull = null,
- this._zOffset = 0,
- this._zOffsetUnits = 0,
- this._frontFace = null,
- this._isDepthTestDirty = !0,
- this._isDepthMaskDirty = !0,
- this._isDepthFuncDirty = !1,
- this._isCullFaceDirty = !1,
- this._isCullDirty = !1,
- this._isZOffsetDirty = !0,
- this._isFrontFaceDirty = !1
- }
- ,
- a.prototype.apply = function(e) {
- !this.isDirty || (this._isCullDirty && (this.cull ? e.enable(e.CULL_FACE) : e.disable(e.CULL_FACE),
- this._isCullDirty = !1),
- this._isCullFaceDirty && (e.cullFace(this.cullFace),
- this._isCullFaceDirty = !1),
- this._isDepthMaskDirty && (e.depthMask(this.depthMask),
- this._isDepthMaskDirty = !1),
- this._isDepthTestDirty && (this.depthTest ? e.enable(e.DEPTH_TEST) : e.disable(e.DEPTH_TEST),
- this._isDepthTestDirty = !1),
- this._isDepthFuncDirty && (e.depthFunc(this.depthFunc),
- this._isDepthFuncDirty = !1),
- this._isZOffsetDirty && (this.zOffset || this.zOffsetUnits ? (e.enable(e.POLYGON_OFFSET_FILL),
- e.polygonOffset(this.zOffset, this.zOffsetUnits)) : e.disable(e.POLYGON_OFFSET_FILL),
- this._isZOffsetDirty = !1),
- this._isFrontFaceDirty && (e.frontFace(this.frontFace),
- this._isFrontFaceDirty = !1))
- }
- ,
- a
- }(), StencilState = function() {
- function a() {
- this.reset()
- }
- return a.prototype.reset = function() {
- this.enabled = !1,
- this.mask = 255,
- this.func = a.ALWAYS,
- this.funcRef = 1,
- this.funcMask = 255,
- this.opStencilFail = a.KEEP,
- this.opDepthFail = a.KEEP,
- this.opStencilDepthPass = a.REPLACE
- }
- ,
- Object.defineProperty(a.prototype, "stencilFunc", {
- get: function() {
- return this.func
- },
- set: function(e) {
- this.func = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "stencilFuncRef", {
- get: function() {
- return this.funcRef
- },
- set: function(e) {
- this.funcRef = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "stencilFuncMask", {
- get: function() {
- return this.funcMask
- },
- set: function(e) {
- this.funcMask = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "stencilOpStencilFail", {
- get: function() {
- return this.opStencilFail
- },
- set: function(e) {
- this.opStencilFail = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "stencilOpDepthFail", {
- get: function() {
- return this.opDepthFail
- },
- set: function(e) {
- this.opDepthFail = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "stencilOpStencilDepthPass", {
- get: function() {
- return this.opStencilDepthPass
- },
- set: function(e) {
- this.opStencilDepthPass = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "stencilMask", {
- get: function() {
- return this.mask
- },
- set: function(e) {
- this.mask = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "stencilTest", {
- get: function() {
- return this.enabled
- },
- set: function(e) {
- this.enabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.ALWAYS = 519,
- a.KEEP = 7680,
- a.REPLACE = 7681,
- a
- }(), AlphaState = function() {
- function a() {
- this._blendFunctionParameters = new Array(4),
- this._blendEquationParameters = new Array(2),
- this._blendConstants = new Array(4),
- this._isBlendConstantsDirty = !1,
- this._alphaBlend = !1,
- this._isAlphaBlendDirty = !1,
- this._isBlendFunctionParametersDirty = !1,
- this._isBlendEquationParametersDirty = !1,
- this.reset()
- }
- return Object.defineProperty(a.prototype, "isDirty", {
- get: function() {
- return this._isAlphaBlendDirty || this._isBlendFunctionParametersDirty || this._isBlendEquationParametersDirty
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "alphaBlend", {
- get: function() {
- return this._alphaBlend
- },
- set: function(e) {
- this._alphaBlend !== e && (this._alphaBlend = e,
- this._isAlphaBlendDirty = !0)
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.setAlphaBlendConstants = function(e, i, o, s) {
- this._blendConstants[0] === e && this._blendConstants[1] === i && this._blendConstants[2] === o && this._blendConstants[3] === s || (this._blendConstants[0] = e,
- this._blendConstants[1] = i,
- this._blendConstants[2] = o,
- this._blendConstants[3] = s,
- this._isBlendConstantsDirty = !0)
- }
- ,
- a.prototype.setAlphaBlendFunctionParameters = function(e, i, o, s) {
- this._blendFunctionParameters[0] === e && this._blendFunctionParameters[1] === i && this._blendFunctionParameters[2] === o && this._blendFunctionParameters[3] === s || (this._blendFunctionParameters[0] = e,
- this._blendFunctionParameters[1] = i,
- this._blendFunctionParameters[2] = o,
- this._blendFunctionParameters[3] = s,
- this._isBlendFunctionParametersDirty = !0)
- }
- ,
- a.prototype.setAlphaEquationParameters = function(e, i) {
- this._blendEquationParameters[0] === e && this._blendEquationParameters[1] === i || (this._blendEquationParameters[0] = e,
- this._blendEquationParameters[1] = i,
- this._isBlendEquationParametersDirty = !0)
- }
- ,
- a.prototype.reset = function() {
- this._alphaBlend = !1,
- this._blendFunctionParameters[0] = null,
- this._blendFunctionParameters[1] = null,
- this._blendFunctionParameters[2] = null,
- this._blendFunctionParameters[3] = null,
- this._blendEquationParameters[0] = null,
- this._blendEquationParameters[1] = null,
- this._blendConstants[0] = null,
- this._blendConstants[1] = null,
- this._blendConstants[2] = null,
- this._blendConstants[3] = null,
- this._isAlphaBlendDirty = !0,
- this._isBlendFunctionParametersDirty = !1,
- this._isBlendEquationParametersDirty = !1,
- this._isBlendConstantsDirty = !1
- }
- ,
- a.prototype.apply = function(e) {
- !this.isDirty || (this._isAlphaBlendDirty && (this._alphaBlend ? e.enable(e.BLEND) : e.disable(e.BLEND),
- this._isAlphaBlendDirty = !1),
- this._isBlendFunctionParametersDirty && (e.blendFuncSeparate(this._blendFunctionParameters[0], this._blendFunctionParameters[1], this._blendFunctionParameters[2], this._blendFunctionParameters[3]),
- this._isBlendFunctionParametersDirty = !1),
- this._isBlendEquationParametersDirty && (e.blendEquationSeparate(this._blendEquationParameters[0], this._blendEquationParameters[1]),
- this._isBlendEquationParametersDirty = !1),
- this._isBlendConstantsDirty && (e.blendColor(this._blendConstants[0], this._blendConstants[1], this._blendConstants[2], this._blendConstants[3]),
- this._isBlendConstantsDirty = !1))
- }
- ,
- a
- }(), TextureSampler = function() {
- function a() {
- this.samplingMode = -1,
- this._useMipMaps = !0,
- this._cachedWrapU = null,
- this._cachedWrapV = null,
- this._cachedWrapR = null,
- this._cachedAnisotropicFilteringLevel = null,
- this._comparisonFunction = 0
- }
- return Object.defineProperty(a.prototype, "wrapU", {
- get: function() {
- return this._cachedWrapU
- },
- set: function(e) {
- this._cachedWrapU = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "wrapV", {
- get: function() {
- return this._cachedWrapV
- },
- set: function(e) {
- this._cachedWrapV = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "wrapR", {
- get: function() {
- return this._cachedWrapR
- },
- set: function(e) {
- this._cachedWrapR = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "anisotropicFilteringLevel", {
- get: function() {
- return this._cachedAnisotropicFilteringLevel
- },
- set: function(e) {
- this._cachedAnisotropicFilteringLevel = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "comparisonFunction", {
- get: function() {
- return this._comparisonFunction
- },
- set: function(e) {
- this._comparisonFunction = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "useMipMaps", {
- get: function() {
- return this._useMipMaps
- },
- set: function(e) {
- this._useMipMaps = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.setParameters = function(e, i, o, s, c, d) {
- return e === void 0 && (e = 1),
- i === void 0 && (i = 1),
- o === void 0 && (o = 1),
- s === void 0 && (s = 1),
- c === void 0 && (c = 2),
- d === void 0 && (d = 0),
- this._cachedWrapU = e,
- this._cachedWrapV = i,
- this._cachedWrapR = o,
- this._cachedAnisotropicFilteringLevel = s,
- this.samplingMode = c,
- this._comparisonFunction = d,
- this
- }
- ,
- a.prototype.compareSampler = function(e) {
- 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
- }
- ,
- a
- }(), InternalTextureSource;
- (function(a) {
- a[a.Unknown = 0] = "Unknown",
- a[a.Url = 1] = "Url",
- a[a.Temp = 2] = "Temp",
- a[a.Raw = 3] = "Raw",
- a[a.Dynamic = 4] = "Dynamic",
- a[a.RenderTarget = 5] = "RenderTarget",
- a[a.MultiRenderTarget = 6] = "MultiRenderTarget",
- a[a.Cube = 7] = "Cube",
- a[a.CubeRaw = 8] = "CubeRaw",
- a[a.CubePrefiltered = 9] = "CubePrefiltered",
- a[a.Raw3D = 10] = "Raw3D",
- a[a.Raw2DArray = 11] = "Raw2DArray",
- a[a.DepthStencil = 12] = "DepthStencil",
- a[a.CubeRawRGBD = 13] = "CubeRawRGBD",
- a[a.Depth = 14] = "Depth"
- }
- )(InternalTextureSource || (InternalTextureSource = {}));
- var InternalTexture = function(a) {
- __extends(e, a);
- function e(i, o, s) {
- s === void 0 && (s = !1);
- var c = a.call(this) || this;
- return c.isReady = !1,
- c.isCube = !1,
- c.is3D = !1,
- c.is2DArray = !1,
- c.isMultiview = !1,
- c.url = "",
- c.generateMipMaps = !1,
- c.samples = 0,
- c.type = -1,
- c.format = -1,
- c.onLoadedObservable = new Observable,
- c.onErrorObservable = new Observable,
- c.onRebuildCallback = null,
- c.width = 0,
- c.height = 0,
- c.depth = 0,
- c.baseWidth = 0,
- c.baseHeight = 0,
- c.baseDepth = 0,
- c.invertY = !1,
- c._invertVScale = !1,
- c._associatedChannel = -1,
- c._source = InternalTextureSource.Unknown,
- c._buffer = null,
- c._bufferView = null,
- c._bufferViewArray = null,
- c._bufferViewArrayArray = null,
- c._size = 0,
- c._extension = "",
- c._files = null,
- c._workingCanvas = null,
- c._workingContext = null,
- c._cachedCoordinatesMode = null,
- c._isDisabled = !1,
- c._compression = null,
- c._sphericalPolynomial = null,
- c._sphericalPolynomialPromise = null,
- c._sphericalPolynomialComputed = !1,
- c._lodGenerationScale = 0,
- c._lodGenerationOffset = 0,
- c._useSRGBBuffer = !1,
- c._lodTextureHigh = null,
- c._lodTextureMid = null,
- c._lodTextureLow = null,
- c._isRGBD = !1,
- c._linearSpecularLOD = !1,
- c._irradianceTexture = null,
- c._hardwareTexture = null,
- c._references = 1,
- c._gammaSpace = null,
- c._engine = i,
- c._source = o,
- c._uniqueId = e._Counter++,
- s || (c._hardwareTexture = i._createHardwareTexture()),
- c
- }
- return Object.defineProperty(e.prototype, "useMipMaps", {
- get: function() {
- return this.generateMipMaps
- },
- set: function(i) {
- this.generateMipMaps = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "uniqueId", {
- get: function() {
- return this._uniqueId
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getEngine = function() {
- return this._engine
- }
- ,
- Object.defineProperty(e.prototype, "source", {
- get: function() {
- return this._source
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.incrementReferences = function() {
- this._references++
- }
- ,
- e.prototype.updateSize = function(i, o, s) {
- s === void 0 && (s = 1),
- this._engine.updateTextureDimensions(this, i, o, s),
- this.width = i,
- this.height = o,
- this.depth = s,
- this.baseWidth = i,
- this.baseHeight = o,
- this.baseDepth = s,
- this._size = i * o * s
- }
- ,
- e.prototype._rebuild = function() {
- var i = this, o;
- if (this.isReady = !1,
- this._cachedCoordinatesMode = null,
- this._cachedWrapU = null,
- this._cachedWrapV = null,
- this._cachedWrapR = null,
- this._cachedAnisotropicFilteringLevel = null,
- this.onRebuildCallback) {
- var s = this.onRebuildCallback(this)
- , c = function(_) {
- _._swapAndDie(i, !1),
- i.isReady = s.isReady
- };
- s.isAsync ? s.proxy.then(c) : c(s.proxy);
- return
- }
- var d;
- switch (this.source) {
- case InternalTextureSource.Temp:
- break;
- case InternalTextureSource.Url:
- d = this._engine.createTexture((o = this._originalUrl) !== null && o !== void 0 ? o : this.url, !this.generateMipMaps, this.invertY, null, this.samplingMode, function() {
- d._swapAndDie(i, !1),
- i.isReady = !0
- }, null, this._buffer, void 0, this.format, this._extension, void 0, void 0, void 0, this._useSRGBBuffer);
- return;
- case InternalTextureSource.Raw:
- d = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression, this.type),
- d._swapAndDie(this, !1),
- this.isReady = !0;
- break;
- case InternalTextureSource.Raw3D:
- d = this._engine.createRawTexture3D(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression, this.type),
- d._swapAndDie(this, !1),
- this.isReady = !0;
- break;
- case InternalTextureSource.Raw2DArray:
- d = this._engine.createRawTexture2DArray(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression, this.type),
- d._swapAndDie(this, !1),
- this.isReady = !0;
- break;
- case InternalTextureSource.Dynamic:
- d = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode),
- d._swapAndDie(this, !1),
- this._engine.updateDynamicTexture(this, this._engine.getRenderingCanvas(), this.invertY, void 0, void 0, !0);
- break;
- case InternalTextureSource.Cube:
- d = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, function() {
- d._swapAndDie(i, !1),
- i.isReady = !0
- }, null, this.format, this._extension, !1, 0, 0, null, void 0, this._useSRGBBuffer);
- return;
- case InternalTextureSource.CubeRaw:
- d = this._engine.createRawCubeTexture(this._bufferViewArray, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression),
- d._swapAndDie(this, !1),
- this.isReady = !0;
- break;
- case InternalTextureSource.CubeRawRGBD:
- return;
- case InternalTextureSource.CubePrefiltered:
- d = this._engine.createPrefilteredCubeTexture(this.url, null, this._lodGenerationScale, this._lodGenerationOffset, function(_) {
- _ && _._swapAndDie(i, !1),
- i.isReady = !0
- }, null, this.format, this._extension),
- d._sphericalPolynomial = this._sphericalPolynomial;
- return
- }
- }
- ,
- e.prototype._swapAndDie = function(i, o) {
- var s;
- o === void 0 && (o = !0),
- (s = this._hardwareTexture) === null || s === void 0 || s.setUsage(i._source, this.generateMipMaps, this.isCube, this.width, this.height),
- i._hardwareTexture = this._hardwareTexture,
- o && (i._isRGBD = this._isRGBD),
- this._lodTextureHigh && (i._lodTextureHigh && i._lodTextureHigh.dispose(),
- i._lodTextureHigh = this._lodTextureHigh),
- this._lodTextureMid && (i._lodTextureMid && i._lodTextureMid.dispose(),
- i._lodTextureMid = this._lodTextureMid),
- this._lodTextureLow && (i._lodTextureLow && i._lodTextureLow.dispose(),
- i._lodTextureLow = this._lodTextureLow),
- this._irradianceTexture && (i._irradianceTexture && i._irradianceTexture.dispose(),
- i._irradianceTexture = this._irradianceTexture);
- var c = this._engine.getLoadedTexturesCache()
- , d = c.indexOf(this);
- d !== -1 && c.splice(d, 1);
- var d = c.indexOf(i);
- d === -1 && c.push(i)
- }
- ,
- e.prototype.dispose = function() {
- this._references--,
- this.onLoadedObservable.clear(),
- this.onErrorObservable.clear(),
- this._references === 0 && (this._engine._releaseTexture(this),
- this._hardwareTexture = null)
- }
- ,
- e._Counter = 0,
- e
- }(TextureSampler)
- , WebGLShaderProcessor = function() {
- function a() {
- this.shaderLanguage = ShaderLanguage.GLSL
- }
- return a.prototype.postProcessor = function(e, i, o, s, c) {
- if (!c.getCaps().drawBuffersExtension) {
- var d = /#extension.+GL_EXT_draw_buffers.+(enable|require)/g;
- e = e.replace(d, "")
- }
- return e
- }
- ,
- a
- }()
- , WebGL2ShaderProcessor = function() {
- function a() {
- this.shaderLanguage = ShaderLanguage.GLSL
- }
- return a.prototype.attributeProcessor = function(e) {
- return e.replace("attribute", "in")
- }
- ,
- a.prototype.varyingProcessor = function(e, i) {
- return e.replace("varying", i ? "in" : "out")
- }
- ,
- a.prototype.postProcessor = function(e, i, o, s, c) {
- var d = e.search(/#extension.+GL_EXT_draw_buffers.+require/) !== -1
- , _ = /#extension.+(GL_OVR_multiview2|GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g;
- if (e = e.replace(_, ""),
- e = e.replace(/texture2D\s*\(/g, "texture("),
- o)
- e = e.replace(/texture2DLodEXT\s*\(/g, "textureLod("),
- e = e.replace(/textureCubeLodEXT\s*\(/g, "textureLod("),
- e = e.replace(/textureCube\s*\(/g, "texture("),
- e = e.replace(/gl_FragDepthEXT/g, "gl_FragDepth"),
- e = e.replace(/gl_FragColor/g, "glFragColor"),
- e = e.replace(/gl_FragData/g, "glFragData"),
- e = e.replace(/void\s+?main\s*\(/g, (d ? "" : `out vec4 glFragColor;
- `) + "void main(");
- else {
- var b = i.indexOf("#define MULTIVIEW") !== -1;
- if (b)
- return `#extension GL_OVR_multiview2 : require
- layout (num_views = 2) in;
- ` + e
- }
- return e
- }
- ,
- a
- }()
- , DataBuffer = function() {
- function a() {
- this.references = 0,
- this.capacity = 0,
- this.is32Bits = !1,
- this.uniqueId = a._Counter++
- }
- return Object.defineProperty(a.prototype, "underlyingResource", {
- get: function() {
- return null
- },
- enumerable: !1,
- configurable: !0
- }),
- a._Counter = 0,
- a
- }()
- , WebGLDataBuffer = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this) || this;
- return o._buffer = i,
- o
- }
- return Object.defineProperty(e.prototype, "underlyingResource", {
- get: function() {
- return this._buffer
- },
- enumerable: !1,
- configurable: !0
- }),
- e
- }(DataBuffer)
- , WebGLPipelineContext = function() {
- function a() {
- this._valueCache = {},
- this.vertexCompilationError = null,
- this.fragmentCompilationError = null,
- this.programLinkError = null,
- this.programValidationError = null
- }
- return Object.defineProperty(a.prototype, "isAsync", {
- get: function() {
- return this.isParallelCompiled
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "isReady", {
- get: function() {
- return this.program ? this.isParallelCompiled ? this.engine._isRenderingStateCompiled(this) : !0 : !1
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._handlesSpectorRebuildCallback = function(e) {
- e && this.program && e(this.program)
- }
- ,
- a.prototype._fillEffectInformation = function(e, i, o, s, c, d, _, b) {
- var k = this.engine;
- if (k.supportsUniformBuffers)
- for (var j in i)
- e.bindUniformBlock(j, i[j]);
- var $ = this.engine.getUniforms(this, o);
- $.forEach(function(nt, ot) {
- s[o[ot]] = nt
- }),
- this._uniforms = s;
- var _e;
- for (_e = 0; _e < c.length; _e++) {
- var et = e.getUniform(c[_e]);
- et == null && (c.splice(_e, 1),
- _e--)
- }
- c.forEach(function(nt, ot) {
- d[nt] = ot
- });
- for (var tt = 0, rt = k.getAttributes(this, _); tt < rt.length; tt++) {
- var it = rt[tt];
- b.push(it)
- }
- }
- ,
- a.prototype.dispose = function() {
- this._uniforms = {}
- }
- ,
- a.prototype._cacheMatrix = function(e, i) {
- var o = this._valueCache[e]
- , s = i.updateFlag;
- return o !== void 0 && o === s ? !1 : (this._valueCache[e] = s,
- !0)
- }
- ,
- a.prototype._cacheFloat2 = function(e, i, o) {
- var s = this._valueCache[e];
- if (!s || s.length !== 2)
- return s = [i, o],
- this._valueCache[e] = s,
- !0;
- var c = !1;
- return s[0] !== i && (s[0] = i,
- c = !0),
- s[1] !== o && (s[1] = o,
- c = !0),
- c
- }
- ,
- a.prototype._cacheFloat3 = function(e, i, o, s) {
- var c = this._valueCache[e];
- if (!c || c.length !== 3)
- return c = [i, o, s],
- this._valueCache[e] = c,
- !0;
- var d = !1;
- return c[0] !== i && (c[0] = i,
- d = !0),
- c[1] !== o && (c[1] = o,
- d = !0),
- c[2] !== s && (c[2] = s,
- d = !0),
- d
- }
- ,
- a.prototype._cacheFloat4 = function(e, i, o, s, c) {
- var d = this._valueCache[e];
- if (!d || d.length !== 4)
- return d = [i, o, s, c],
- this._valueCache[e] = d,
- !0;
- var _ = !1;
- return d[0] !== i && (d[0] = i,
- _ = !0),
- d[1] !== o && (d[1] = o,
- _ = !0),
- d[2] !== s && (d[2] = s,
- _ = !0),
- d[3] !== c && (d[3] = c,
- _ = !0),
- _
- }
- ,
- a.prototype.setInt = function(e, i) {
- var o = this._valueCache[e];
- o !== void 0 && o === i || this.engine.setInt(this._uniforms[e], i) && (this._valueCache[e] = i)
- }
- ,
- a.prototype.setInt2 = function(e, i, o) {
- this._cacheFloat2(e, i, o) && (this.engine.setInt2(this._uniforms[e], i, o) || (this._valueCache[e] = null))
- }
- ,
- a.prototype.setInt3 = function(e, i, o, s) {
- this._cacheFloat3(e, i, o, s) && (this.engine.setInt3(this._uniforms[e], i, o, s) || (this._valueCache[e] = null))
- }
- ,
- a.prototype.setInt4 = function(e, i, o, s, c) {
- this._cacheFloat4(e, i, o, s, c) && (this.engine.setInt4(this._uniforms[e], i, o, s, c) || (this._valueCache[e] = null))
- }
- ,
- a.prototype.setIntArray = function(e, i) {
- this._valueCache[e] = null,
- this.engine.setIntArray(this._uniforms[e], i)
- }
- ,
- a.prototype.setIntArray2 = function(e, i) {
- this._valueCache[e] = null,
- this.engine.setIntArray2(this._uniforms[e], i)
- }
- ,
- a.prototype.setIntArray3 = function(e, i) {
- this._valueCache[e] = null,
- this.engine.setIntArray3(this._uniforms[e], i)
- }
- ,
- a.prototype.setIntArray4 = function(e, i) {
- this._valueCache[e] = null,
- this.engine.setIntArray4(this._uniforms[e], i)
- }
- ,
- a.prototype.setArray = function(e, i) {
- this._valueCache[e] = null,
- this.engine.setArray(this._uniforms[e], i)
- }
- ,
- a.prototype.setArray2 = function(e, i) {
- this._valueCache[e] = null,
- this.engine.setArray2(this._uniforms[e], i)
- }
- ,
- a.prototype.setArray3 = function(e, i) {
- this._valueCache[e] = null,
- this.engine.setArray3(this._uniforms[e], i)
- }
- ,
- a.prototype.setArray4 = function(e, i) {
- this._valueCache[e] = null,
- this.engine.setArray4(this._uniforms[e], i)
- }
- ,
- a.prototype.setMatrices = function(e, i) {
- !i || (this._valueCache[e] = null,
- this.engine.setMatrices(this._uniforms[e], i))
- }
- ,
- a.prototype.setMatrix = function(e, i) {
- this._cacheMatrix(e, i) && (this.engine.setMatrices(this._uniforms[e], i.toArray()) || (this._valueCache[e] = null))
- }
- ,
- a.prototype.setMatrix3x3 = function(e, i) {
- this._valueCache[e] = null,
- this.engine.setMatrix3x3(this._uniforms[e], i)
- }
- ,
- a.prototype.setMatrix2x2 = function(e, i) {
- this._valueCache[e] = null,
- this.engine.setMatrix2x2(this._uniforms[e], i)
- }
- ,
- a.prototype.setFloat = function(e, i) {
- var o = this._valueCache[e];
- o !== void 0 && o === i || this.engine.setFloat(this._uniforms[e], i) && (this._valueCache[e] = i)
- }
- ,
- a.prototype.setVector2 = function(e, i) {
- this._cacheFloat2(e, i.x, i.y) && (this.engine.setFloat2(this._uniforms[e], i.x, i.y) || (this._valueCache[e] = null))
- }
- ,
- a.prototype.setFloat2 = function(e, i, o) {
- this._cacheFloat2(e, i, o) && (this.engine.setFloat2(this._uniforms[e], i, o) || (this._valueCache[e] = null))
- }
- ,
- a.prototype.setVector3 = function(e, i) {
- 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))
- }
- ,
- a.prototype.setFloat3 = function(e, i, o, s) {
- this._cacheFloat3(e, i, o, s) && (this.engine.setFloat3(this._uniforms[e], i, o, s) || (this._valueCache[e] = null))
- }
- ,
- a.prototype.setVector4 = function(e, i) {
- 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))
- }
- ,
- a.prototype.setFloat4 = function(e, i, o, s, c) {
- this._cacheFloat4(e, i, o, s, c) && (this.engine.setFloat4(this._uniforms[e], i, o, s, c) || (this._valueCache[e] = null))
- }
- ,
- a.prototype.setColor3 = function(e, i) {
- 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))
- }
- ,
- a.prototype.setColor4 = function(e, i, o) {
- 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))
- }
- ,
- a.prototype.setDirectColor4 = function(e, i) {
- 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))
- }
- ,
- a.prototype._getVertexShaderCode = function() {
- return this.vertexShader ? this.engine._getShaderSource(this.vertexShader) : null
- }
- ,
- a.prototype._getFragmentShaderCode = function() {
- return this.fragmentShader ? this.engine._getShaderSource(this.fragmentShader) : null
- }
- ,
- a
- }()
- , PerformanceConfigurator = function() {
- function a() {}
- return a.SetMatrixPrecision = function(e) {
- if (a.MatrixTrackPrecisionChange = !1,
- e && !a.MatrixUse64Bits && a.MatrixTrackedMatrices)
- for (var i = 0; i < a.MatrixTrackedMatrices.length; ++i) {
- var o = a.MatrixTrackedMatrices[i]
- , s = o._m;
- o._m = new Array(16);
- for (var c = 0; c < 16; ++c)
- o._m[c] = s[c]
- }
- a.MatrixUse64Bits = e,
- a.MatrixCurrentType = a.MatrixUse64Bits ? Array : Float32Array,
- a.MatrixTrackedMatrices = null
- }
- ,
- a.MatrixUse64Bits = !1,
- a.MatrixTrackPrecisionChange = !0,
- a.MatrixCurrentType = Float32Array,
- a.MatrixTrackedMatrices = [],
- a
- }()
- , WebGLHardwareTexture = function() {
- function a(e, i) {
- if (e === void 0 && (e = null),
- this._MSAARenderBuffer = null,
- this._context = i,
- !e && (e = i.createTexture(),
- !e))
- throw new Error("Unable to create webGL texture");
- this.set(e)
- }
- return Object.defineProperty(a.prototype, "underlyingResource", {
- get: function() {
- return this._webGLTexture
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.setUsage = function(e, i, o, s, c) {}
- ,
- a.prototype.set = function(e) {
- this._webGLTexture = e
- }
- ,
- a.prototype.reset = function() {
- this._webGLTexture = null,
- this._MSAARenderBuffer = null
- }
- ,
- a.prototype.release = function() {
- this._MSAARenderBuffer && (this._context.deleteRenderbuffer(this._MSAARenderBuffer),
- this._MSAARenderBuffer = null),
- this._webGLTexture && this._context.deleteTexture(this._webGLTexture),
- this.reset()
- }
- ,
- a
- }()
- , DrawWrapper = function() {
- function a(e, i) {
- i === void 0 && (i = !0),
- this.effect = null,
- this.defines = null,
- this.drawContext = e.createDrawContext(),
- i && (this.materialContext = e.createMaterialContext())
- }
- return a.IsWrapper = function(e) {
- return e.getPipelineContext === void 0
- }
- ,
- a.GetEffect = function(e) {
- return e.getPipelineContext === void 0 ? e.effect : e
- }
- ,
- a.prototype.setEffect = function(e, i, o) {
- var s;
- o === void 0 && (o = !0),
- this.effect = e,
- i !== void 0 && (this.defines = i),
- o && ((s = this.drawContext) === null || s === void 0 || s.reset())
- }
- ,
- a.prototype.dispose = function() {
- var e;
- (e = this.drawContext) === null || e === void 0 || e.dispose()
- }
- ,
- a
- }()
- , StencilStateComposer = function() {
- function a(e) {
- e === void 0 && (e = !0),
- this._isStencilTestDirty = !1,
- this._isStencilMaskDirty = !1,
- this._isStencilFuncDirty = !1,
- this._isStencilOpDirty = !1,
- this.useStencilGlobalOnly = !1,
- e && this.reset()
- }
- return Object.defineProperty(a.prototype, "isDirty", {
- get: function() {
- return this._isStencilTestDirty || this._isStencilMaskDirty || this._isStencilFuncDirty || this._isStencilOpDirty
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "func", {
- get: function() {
- return this._func
- },
- set: function(e) {
- this._func !== e && (this._func = e,
- this._isStencilFuncDirty = !0)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "funcRef", {
- get: function() {
- return this._funcRef
- },
- set: function(e) {
- this._funcRef !== e && (this._funcRef = e,
- this._isStencilFuncDirty = !0)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "funcMask", {
- get: function() {
- return this._funcMask
- },
- set: function(e) {
- this._funcMask !== e && (this._funcMask = e,
- this._isStencilFuncDirty = !0)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "opStencilFail", {
- get: function() {
- return this._opStencilFail
- },
- set: function(e) {
- this._opStencilFail !== e && (this._opStencilFail = e,
- this._isStencilOpDirty = !0)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "opDepthFail", {
- get: function() {
- return this._opDepthFail
- },
- set: function(e) {
- this._opDepthFail !== e && (this._opDepthFail = e,
- this._isStencilOpDirty = !0)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "opStencilDepthPass", {
- get: function() {
- return this._opStencilDepthPass
- },
- set: function(e) {
- this._opStencilDepthPass !== e && (this._opStencilDepthPass = e,
- this._isStencilOpDirty = !0)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "mask", {
- get: function() {
- return this._mask
- },
- set: function(e) {
- this._mask !== e && (this._mask = e,
- this._isStencilMaskDirty = !0)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "enabled", {
- get: function() {
- return this._enabled
- },
- set: function(e) {
- this._enabled !== e && (this._enabled = e,
- this._isStencilTestDirty = !0)
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.reset = function() {
- var e;
- this.stencilMaterial = void 0,
- (e = this.stencilGlobal) === null || e === void 0 || e.reset(),
- this._isStencilTestDirty = !0,
- this._isStencilMaskDirty = !0,
- this._isStencilFuncDirty = !0,
- this._isStencilOpDirty = !0
- }
- ,
- a.prototype.apply = function(e) {
- var i;
- if (!!e) {
- var o = !this.useStencilGlobalOnly && !!(!((i = this.stencilMaterial) === null || i === void 0) && i.enabled);
- this.enabled = o ? this.stencilMaterial.enabled : this.stencilGlobal.enabled,
- this.func = o ? this.stencilMaterial.func : this.stencilGlobal.func,
- this.funcRef = o ? this.stencilMaterial.funcRef : this.stencilGlobal.funcRef,
- this.funcMask = o ? this.stencilMaterial.funcMask : this.stencilGlobal.funcMask,
- this.opStencilFail = o ? this.stencilMaterial.opStencilFail : this.stencilGlobal.opStencilFail,
- this.opDepthFail = o ? this.stencilMaterial.opDepthFail : this.stencilGlobal.opDepthFail,
- this.opStencilDepthPass = o ? this.stencilMaterial.opStencilDepthPass : this.stencilGlobal.opStencilDepthPass,
- this.mask = o ? this.stencilMaterial.mask : this.stencilGlobal.mask,
- this.isDirty && (this._isStencilTestDirty && (this.enabled ? e.enable(e.STENCIL_TEST) : e.disable(e.STENCIL_TEST),
- this._isStencilTestDirty = !1),
- this._isStencilMaskDirty && (e.stencilMask(this.mask),
- this._isStencilMaskDirty = !1),
- this._isStencilFuncDirty && (e.stencilFunc(this.func, this.funcRef, this.funcMask),
- this._isStencilFuncDirty = !1),
- this._isStencilOpDirty && (e.stencilOp(this.opStencilFail, this.opDepthFail, this.opStencilDepthPass),
- this._isStencilOpDirty = !1))
- }
- }
- ,
- a
- }()
- , BufferPointer = function() {
- function a() {}
- return a
- }()
- , ThinEngine = function() {
- function a(e, i, o, s) {
- var c = this;
- this.forcePOTTextures = !1,
- this.isFullscreen = !1,
- this.cullBackFaces = null,
- this.renderEvenInBackground = !0,
- this.preventCacheWipeBetweenFrames = !1,
- this.validateShaderPrograms = !1,
- this._useReverseDepthBuffer = !1,
- this.isNDCHalfZRange = !1,
- this.hasOriginBottomLeft = !0,
- this.disableUniformBuffers = !1,
- this.onDisposeObservable = new Observable,
- this._frameId = 0,
- this._uniformBuffers = new Array,
- this._storageBuffers = new Array,
- this._webGLVersion = 1,
- this._windowIsBackground = !1,
- this._highPrecisionShadersAllowed = !0,
- this._badOS = !1,
- this._badDesktopOS = !1,
- this._renderingQueueLaunched = !1,
- this._activeRenderLoops = new Array,
- this.onContextLostObservable = new Observable,
- this.onContextRestoredObservable = new Observable,
- this._contextWasLost = !1,
- this._doNotHandleContextLost = !1,
- this.disableVertexArrayObjects = !1,
- this._colorWrite = !0,
- this._colorWriteChanged = !0,
- this._depthCullingState = new DepthCullingState,
- this._stencilStateComposer = new StencilStateComposer,
- this._stencilState = new StencilState,
- this._alphaState = new AlphaState,
- this._alphaMode = 1,
- this._alphaEquation = 0,
- this._internalTexturesCache = new Array,
- this._renderTargetWrapperCache = new Array,
- this._activeChannel = 0,
- this._currentTextureChannel = -1,
- this._boundTexturesCache = {},
- this._compiledEffects = {},
- this._vertexAttribArraysEnabled = [],
- this._uintIndicesCurrentlySet = !1,
- this._currentBoundBuffer = new Array,
- this._currentFramebuffer = null,
- this._dummyFramebuffer = null,
- this._currentBufferPointers = new Array,
- this._currentInstanceLocations = new Array,
- this._currentInstanceBuffers = new Array,
- this._vaoRecordInProgress = !1,
- this._mustWipeVertexAttributes = !1,
- this._nextFreeTextureSlots = new Array,
- this._maxSimultaneousTextures = 0,
- this._activeRequests = new Array,
- this._transformTextureUrl = null,
- this.hostInformation = {
- isMobile: !1
- },
- this.premultipliedAlpha = !0,
- this.onBeforeTextureInitObservable = new Observable,
- this._isWebGPU = !1,
- this._snapshotRenderingMode = 0,
- this._viewportCached = {
- x: 0,
- y: 0,
- z: 0,
- w: 0
- },
- this._unpackFlipYCached = null,
- this.enableUnpackFlipYCached = !0,
- this._boundUniforms = {};
- var d = null;
- if (o = o || {},
- this._stencilStateComposer.stencilGlobal = this._stencilState,
- PerformanceConfigurator.SetMatrixPrecision(!!o.useHighPrecisionMatrix),
- !!e) {
- if (s = s || o.adaptToDeviceRatio || !1,
- e.getContext) {
- if (d = e,
- this._renderingCanvas = d,
- i !== void 0 && (o.antialias = i),
- o.deterministicLockstep === void 0 && (o.deterministicLockstep = !1),
- o.lockstepMaxSteps === void 0 && (o.lockstepMaxSteps = 4),
- o.timeStep === void 0 && (o.timeStep = 1 / 60),
- o.preserveDrawingBuffer === void 0 && (o.preserveDrawingBuffer = !1),
- o.audioEngine === void 0 && (o.audioEngine = !0),
- o.audioEngineOptions !== void 0 && o.audioEngineOptions.audioContext !== void 0 && (this._audioContext = o.audioEngineOptions.audioContext),
- o.audioEngineOptions !== void 0 && o.audioEngineOptions.audioDestination !== void 0 && (this._audioDestination = o.audioEngineOptions.audioDestination),
- o.stencil === void 0 && (o.stencil = !0),
- o.premultipliedAlpha === !1 && (this.premultipliedAlpha = !1),
- o.xrCompatible === void 0 && (o.xrCompatible = !0),
- this._doNotHandleContextLost = !!o.doNotHandleContextLost,
- navigator && navigator.userAgent) {
- this._checkForMobile = function() {
- var dt = navigator.userAgent;
- c.hostInformation.isMobile = dt.indexOf("Mobile") !== -1 || dt.indexOf("Mac") !== -1 && IsDocumentAvailable() && "ontouchend"in document
- }
- ,
- this._checkForMobile(),
- IsWindowObjectExist() && window.addEventListener("resize", this._checkForMobile);
- for (var _ = navigator.userAgent, b = 0, k = a.ExceptionList; b < k.length; b++) {
- var j = k[b]
- , $ = j.key
- , _e = j.targets
- , et = new RegExp($);
- if (et.test(_)) {
- if (j.capture && j.captureConstraint) {
- var tt = j.capture
- , rt = j.captureConstraint
- , it = new RegExp(tt)
- , nt = it.exec(_);
- if (nt && nt.length > 0) {
- var ot = parseInt(nt[nt.length - 1]);
- if (ot >= rt)
- continue
- }
- }
- for (var at = 0, st = _e; at < st.length; at++) {
- var ut = st[at];
- switch (ut) {
- case "uniformBuffer":
- this.disableUniformBuffers = !0;
- break;
- case "vao":
- this.disableVertexArrayObjects = !0;
- break
- }
- }
- }
- }
- }
- if (this._doNotHandleContextLost || (this._onContextLost = function(dt) {
- dt.preventDefault(),
- c._contextWasLost = !0,
- Logger$2.Warn("WebGL context lost."),
- c.onContextLostObservable.notifyObservers(c)
- }
- ,
- this._onContextRestored = function() {
- c._restoreEngineAfterContextLost(c._initGLContext.bind(c))
- }
- ,
- d.addEventListener("webglcontextlost", this._onContextLost, !1),
- d.addEventListener("webglcontextrestored", this._onContextRestored, !1),
- o.powerPreference = "high-performance"),
- this._badDesktopOS = /^((?!chrome|android).)*safari/i.test(navigator.userAgent),
- this._badDesktopOS && (o.xrCompatible = !1),
- !o.disableWebGL2Support)
- try {
- this._gl = d.getContext("webgl2", o) || d.getContext("experimental-webgl2", o),
- this._gl && (this._webGLVersion = 2,
- this._shaderPlatformName = "WEBGL2",
- this._gl.deleteQuery || (this._webGLVersion = 1,
- this._shaderPlatformName = "WEBGL1"))
- } catch {}
- if (!this._gl) {
- if (!d)
- throw new Error("The provided canvas is null or undefined.");
- try {
- this._gl = d.getContext("webgl", o) || d.getContext("experimental-webgl", o)
- } catch {
- throw new Error("WebGL not supported")
- }
- }
- if (!this._gl)
- throw new Error("WebGL not supported")
- } else {
- this._gl = e,
- this._renderingCanvas = this._gl.canvas,
- this._gl.renderbufferStorageMultisample ? (this._webGLVersion = 2,
- this._shaderPlatformName = "WEBGL2") : this._shaderPlatformName = "WEBGL1";
- var ct = this._gl.getContextAttributes();
- ct && (o.stencil = ct.stencil)
- }
- this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._gl.NONE),
- o.useHighPrecisionFloats !== void 0 && (this._highPrecisionShadersAllowed = o.useHighPrecisionFloats);
- var lt = IsWindowObjectExist() && window.devicePixelRatio || 1
- , ft = o.limitDeviceRatio || lt;
- this._hardwareScalingLevel = s ? 1 / Math.min(ft, lt) : 1,
- this.resize(),
- this._isStencilEnable = !!o.stencil,
- this._initGLContext(),
- this._initFeatures();
- for (var ht = 0; ht < this._caps.maxVertexAttribs; ht++)
- this._currentBufferPointers[ht] = new BufferPointer;
- this._shaderProcessor = this.webGLVersion > 1 ? new WebGL2ShaderProcessor : new WebGLShaderProcessor,
- this._badOS = /iPad/i.test(navigator.userAgent) || /iPhone/i.test(navigator.userAgent),
- this._creationOptions = o;
- var pt = "Babylon.js v" + a.Version;
- console.log(pt + (" - " + this.description)),
- this._renderingCanvas && this._renderingCanvas.setAttribute && this._renderingCanvas.setAttribute("data-engine", pt)
- }
- }
- return Object.defineProperty(a, "NpmPackage", {
- get: function() {
- return "babylonjs@5.0.0-alpha.63"
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "Version", {
- get: function() {
- return "5.0.0-alpha.63"
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "description", {
- get: function() {
- var e = this.name + this.webGLVersion;
- return this._caps.parallelShaderCompile && (e += " - Parallel shader compilation"),
- e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "name", {
- get: function() {
- return "WebGL"
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "version", {
- get: function() {
- return this._webGLVersion
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "ShadersRepository", {
- get: function() {
- return Effect.ShadersRepository
- },
- set: function(e) {
- Effect.ShadersRepository = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._getShaderProcessor = function(e) {
- return this._shaderProcessor
- }
- ,
- Object.defineProperty(a.prototype, "useReverseDepthBuffer", {
- get: function() {
- return this._useReverseDepthBuffer
- },
- set: function(e) {
- e !== this._useReverseDepthBuffer && (this._useReverseDepthBuffer = e,
- e ? this._depthCullingState.depthFunc = 518 : this._depthCullingState.depthFunc = 515)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "frameId", {
- get: function() {
- return this._frameId
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "supportsUniformBuffers", {
- get: function() {
- return this.webGLVersion > 1 && !this.disableUniformBuffers
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "_shouldUseHighPrecisionShader", {
- get: function() {
- return !!(this._caps.highPrecisionShaderSupported && this._highPrecisionShadersAllowed)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "needPOTTextures", {
- get: function() {
- return this._webGLVersion < 2 || this.forcePOTTextures
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "activeRenderLoops", {
- get: function() {
- return this._activeRenderLoops
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "doNotHandleContextLost", {
- get: function() {
- return this._doNotHandleContextLost
- },
- set: function(e) {
- this._doNotHandleContextLost = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "_supportsHardwareTextureRescaling", {
- get: function() {
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "framebufferDimensionsObject", {
- set: function(e) {
- this._framebufferDimensionsObject = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "currentViewport", {
- get: function() {
- return this._cachedViewport
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "emptyTexture", {
- get: function() {
- return this._emptyTexture || (this._emptyTexture = this.createRawTexture(new Uint8Array(4), 1, 1, 5, !1, !1, 1)),
- this._emptyTexture
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "emptyTexture3D", {
- get: function() {
- return this._emptyTexture3D || (this._emptyTexture3D = this.createRawTexture3D(new Uint8Array(4), 1, 1, 1, 5, !1, !1, 1)),
- this._emptyTexture3D
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "emptyTexture2DArray", {
- get: function() {
- return this._emptyTexture2DArray || (this._emptyTexture2DArray = this.createRawTexture2DArray(new Uint8Array(4), 1, 1, 1, 5, !1, !1, 1)),
- this._emptyTexture2DArray
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "emptyCubeTexture", {
- get: function() {
- if (!this._emptyCubeTexture) {
- var e = new Uint8Array(4)
- , i = [e, e, e, e, e, e];
- this._emptyCubeTexture = this.createRawCubeTexture(i, 1, 5, 0, !1, !1, 1)
- }
- return this._emptyCubeTexture
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "isWebGPU", {
- get: function() {
- return this._isWebGPU
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "shaderPlatformName", {
- get: function() {
- return this._shaderPlatformName
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "snapshotRendering", {
- get: function() {
- return !1
- },
- set: function(e) {},
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "snapshotRenderingMode", {
- get: function() {
- return this._snapshotRenderingMode
- },
- set: function(e) {
- this._snapshotRenderingMode = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.snapshotRenderingReset = function() {
- this.snapshotRendering = !1
- }
- ,
- a._createCanvas = function(e, i) {
- if (typeof document == "undefined")
- return new OffscreenCanvas(e,i);
- var o = document.createElement("canvas");
- return o.width = e,
- o.height = i,
- o
- }
- ,
- a.prototype.createCanvas = function(e, i) {
- return a._createCanvas(e, i)
- }
- ,
- a.prototype.createCanvasImage = function() {
- return document.createElement("img")
- }
- ,
- a.prototype._restoreEngineAfterContextLost = function(e) {
- var i = this;
- setTimeout(function() {
- return __awaiter(i, void 0, void 0, function() {
- var o, s, c, d, _;
- return __generator(this, function(b) {
- switch (b.label) {
- case 0:
- return this._dummyFramebuffer = null,
- o = this._depthCullingState.depthTest,
- s = this._depthCullingState.depthFunc,
- c = this._depthCullingState.depthMask,
- d = this._stencilState.stencilTest,
- [4, e()];
- case 1:
- return b.sent(),
- this._rebuildEffects(),
- (_ = this._rebuildComputeEffects) === null || _ === void 0 || _.call(this),
- this._rebuildInternalTextures(),
- this._rebuildRenderTargetWrappers(),
- this._rebuildBuffers(),
- this.wipeCaches(!0),
- this._depthCullingState.depthTest = o,
- this._depthCullingState.depthFunc = s,
- this._depthCullingState.depthMask = c,
- this._stencilState.stencilTest = d,
- Logger$2.Warn(this.name + " context successfully restored."),
- this.onContextRestoredObservable.notifyObservers(this),
- this._contextWasLost = !1,
- [2]
- }
- })
- })
- }, 0)
- }
- ,
- a.prototype._sharedInit = function(e, i, o) {
- this._renderingCanvas = e
- }
- ,
- a.prototype._getShaderProcessingContext = function(e) {
- return null
- }
- ,
- a.prototype._rebuildInternalTextures = function() {
- for (var e = this._internalTexturesCache.slice(), i = 0, o = e; i < o.length; i++) {
- var s = o[i];
- s._rebuild()
- }
- }
- ,
- a.prototype._rebuildRenderTargetWrappers = function() {
- for (var e = this._renderTargetWrapperCache.slice(), i = 0, o = e; i < o.length; i++) {
- var s = o[i];
- s._rebuild()
- }
- }
- ,
- a.prototype._rebuildEffects = function() {
- for (var e in this._compiledEffects) {
- var i = this._compiledEffects[e];
- i._pipelineContext = null,
- i._wasPreviouslyReady = !1,
- i._prepareEffect()
- }
- Effect.ResetCache()
- }
- ,
- a.prototype.areAllEffectsReady = function() {
- for (var e in this._compiledEffects) {
- var i = this._compiledEffects[e];
- if (!i.isReady())
- return !1
- }
- return !0
- }
- ,
- a.prototype._rebuildBuffers = function() {
- for (var e = 0, i = this._uniformBuffers; e < i.length; e++) {
- var o = i[e];
- o._rebuild()
- }
- for (var s = 0, c = this._storageBuffers; s < c.length; s++) {
- var d = c[s];
- d._rebuild()
- }
- }
- ,
- a.prototype._initGLContext = function() {
- this._caps = {
- maxTexturesImageUnits: this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),
- maxCombinedTexturesImageUnits: this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS),
- maxVertexTextureImageUnits: this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS),
- maxTextureSize: this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),
- maxSamples: this._webGLVersion > 1 ? this._gl.getParameter(this._gl.MAX_SAMPLES) : 1,
- maxCubemapTextureSize: this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE),
- maxRenderTextureSize: this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE),
- maxVertexAttribs: this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS),
- maxVaryingVectors: this._gl.getParameter(this._gl.MAX_VARYING_VECTORS),
- maxFragmentUniformVectors: this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS),
- maxVertexUniformVectors: this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS),
- parallelShaderCompile: this._gl.getExtension("KHR_parallel_shader_compile") || void 0,
- standardDerivatives: this._webGLVersion > 1 || this._gl.getExtension("OES_standard_derivatives") !== null,
- maxAnisotropy: 1,
- astc: this._gl.getExtension("WEBGL_compressed_texture_astc") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_astc"),
- bptc: this._gl.getExtension("EXT_texture_compression_bptc") || this._gl.getExtension("WEBKIT_EXT_texture_compression_bptc"),
- s3tc: this._gl.getExtension("WEBGL_compressed_texture_s3tc") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc"),
- s3tc_srgb: this._gl.getExtension("WEBGL_compressed_texture_s3tc_srgb") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc_srgb"),
- pvrtc: this._gl.getExtension("WEBGL_compressed_texture_pvrtc") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),
- etc1: this._gl.getExtension("WEBGL_compressed_texture_etc1") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc1"),
- etc2: this._gl.getExtension("WEBGL_compressed_texture_etc") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc") || this._gl.getExtension("WEBGL_compressed_texture_es3_0"),
- textureAnisotropicFilterExtension: this._gl.getExtension("EXT_texture_filter_anisotropic") || this._gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic") || this._gl.getExtension("MOZ_EXT_texture_filter_anisotropic"),
- uintIndices: this._webGLVersion > 1 || this._gl.getExtension("OES_element_index_uint") !== null,
- fragmentDepthSupported: this._webGLVersion > 1 || this._gl.getExtension("EXT_frag_depth") !== null,
- highPrecisionShaderSupported: !1,
- timerQuery: this._gl.getExtension("EXT_disjoint_timer_query_webgl2") || this._gl.getExtension("EXT_disjoint_timer_query"),
- supportOcclusionQuery: this._webGLVersion > 1,
- canUseTimestampForTimerQuery: !1,
- drawBuffersExtension: !1,
- maxMSAASamples: 1,
- colorBufferFloat: !!(this._webGLVersion > 1 && this._gl.getExtension("EXT_color_buffer_float")),
- textureFloat: !!(this._webGLVersion > 1 || this._gl.getExtension("OES_texture_float")),
- textureHalfFloat: !!(this._webGLVersion > 1 || this._gl.getExtension("OES_texture_half_float")),
- textureHalfFloatRender: !1,
- textureFloatLinearFiltering: !1,
- textureFloatRender: !1,
- textureHalfFloatLinearFiltering: !1,
- vertexArrayObject: !1,
- instancedArrays: !1,
- textureLOD: !!(this._webGLVersion > 1 || this._gl.getExtension("EXT_shader_texture_lod")),
- blendMinMax: !1,
- multiview: this._gl.getExtension("OVR_multiview2"),
- oculusMultiview: this._gl.getExtension("OCULUS_multiview"),
- depthTextureExtension: !1,
- canUseGLInstanceID: this._webGLVersion > 1,
- canUseGLVertexID: this._webGLVersion > 1,
- supportComputeShaders: !1,
- supportSRGBBuffers: !1
- },
- this._glVersion = this._gl.getParameter(this._gl.VERSION);
- var e = this._gl.getExtension("WEBGL_debug_renderer_info");
- if (e != null && (this._glRenderer = this._gl.getParameter(e.UNMASKED_RENDERER_WEBGL),
- this._glVendor = this._gl.getParameter(e.UNMASKED_VENDOR_WEBGL)),
- this._glVendor || (this._glVendor = "Unknown vendor"),
- this._glRenderer || (this._glRenderer = "Unknown renderer"),
- this._gl.HALF_FLOAT_OES !== 36193 && (this._gl.HALF_FLOAT_OES = 36193),
- this._gl.RGBA16F !== 34842 && (this._gl.RGBA16F = 34842),
- this._gl.RGBA32F !== 34836 && (this._gl.RGBA32F = 34836),
- this._gl.DEPTH24_STENCIL8 !== 35056 && (this._gl.DEPTH24_STENCIL8 = 35056),
- this._caps.timerQuery && (this._webGLVersion === 1 && (this._gl.getQuery = this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery)),
- this._caps.canUseTimestampForTimerQuery = this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT, this._caps.timerQuery.QUERY_COUNTER_BITS_EXT) > 0),
- this._caps.maxAnisotropy = this._caps.textureAnisotropicFilterExtension ? this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0,
- this._caps.textureFloatLinearFiltering = !!(this._caps.textureFloat && this._gl.getExtension("OES_texture_float_linear")),
- this._caps.textureFloatRender = !!(this._caps.textureFloat && this._canRenderToFloatFramebuffer()),
- this._caps.textureHalfFloatLinearFiltering = !!(this._webGLVersion > 1 || this._caps.textureHalfFloat && this._gl.getExtension("OES_texture_half_float_linear")),
- this._caps.astc && (this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR = this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR),
- this._caps.bptc && (this._gl.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT = this._caps.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT),
- this._caps.s3tc_srgb && (this._gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT = this._caps.s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,
- this._gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT = this._caps.s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT),
- this._webGLVersion > 1 && this._gl.HALF_FLOAT_OES !== 5131 && (this._gl.HALF_FLOAT_OES = 5131),
- this._caps.textureHalfFloatRender = this._caps.textureHalfFloat && this._canRenderToHalfFloatFramebuffer(),
- this._webGLVersion > 1)
- this._caps.drawBuffersExtension = !0,
- this._caps.maxMSAASamples = this._gl.getParameter(this._gl.MAX_SAMPLES);
- else {
- var i = this._gl.getExtension("WEBGL_draw_buffers");
- if (i !== null) {
- this._caps.drawBuffersExtension = !0,
- this._gl.drawBuffers = i.drawBuffersWEBGL.bind(i),
- this._gl.DRAW_FRAMEBUFFER = this._gl.FRAMEBUFFER;
- for (var o = 0; o < 16; o++)
- this._gl["COLOR_ATTACHMENT" + o + "_WEBGL"] = i["COLOR_ATTACHMENT" + o + "_WEBGL"]
- }
- }
- if (this._webGLVersion > 1)
- this._caps.depthTextureExtension = !0;
- else {
- var s = this._gl.getExtension("WEBGL_depth_texture");
- s != null && (this._caps.depthTextureExtension = !0,
- this._gl.UNSIGNED_INT_24_8 = s.UNSIGNED_INT_24_8_WEBGL)
- }
- if (this.disableVertexArrayObjects)
- this._caps.vertexArrayObject = !1;
- else if (this._webGLVersion > 1)
- this._caps.vertexArrayObject = !0;
- else {
- var c = this._gl.getExtension("OES_vertex_array_object");
- c != null && (this._caps.vertexArrayObject = !0,
- this._gl.createVertexArray = c.createVertexArrayOES.bind(c),
- this._gl.bindVertexArray = c.bindVertexArrayOES.bind(c),
- this._gl.deleteVertexArray = c.deleteVertexArrayOES.bind(c))
- }
- if (this._webGLVersion > 1)
- this._caps.instancedArrays = !0;
- else {
- var d = this._gl.getExtension("ANGLE_instanced_arrays");
- d != null ? (this._caps.instancedArrays = !0,
- this._gl.drawArraysInstanced = d.drawArraysInstancedANGLE.bind(d),
- this._gl.drawElementsInstanced = d.drawElementsInstancedANGLE.bind(d),
- this._gl.vertexAttribDivisor = d.vertexAttribDivisorANGLE.bind(d)) : this._caps.instancedArrays = !1
- }
- if (this._gl.getShaderPrecisionFormat) {
- var _ = this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER, this._gl.HIGH_FLOAT)
- , b = this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER, this._gl.HIGH_FLOAT);
- _ && b && (this._caps.highPrecisionShaderSupported = _.precision !== 0 && b.precision !== 0)
- }
- if (this._webGLVersion > 1)
- this._caps.blendMinMax = !0;
- else {
- var k = this._gl.getExtension("EXT_blend_minmax");
- k != null && (this._caps.blendMinMax = !0,
- this._gl.MAX = k.MAX_EXT,
- this._gl.MIN = k.MIN_EXT)
- }
- if (this._webGLVersion > 1)
- this._caps.supportSRGBBuffers = !0;
- else {
- var j = this._gl.getExtension("EXT_sRGB");
- j != null && (this._caps.supportSRGBBuffers = !0,
- this._gl.SRGB = j.SRGB_EXT,
- this._gl.SRGB8 = j.SRGB_ALPHA_EXT,
- this._gl.SRGB8_ALPHA8 = j.SRGB_ALPHA_EXT)
- }
- this._depthCullingState.depthTest = !0,
- this._depthCullingState.depthFunc = this._gl.LEQUAL,
- this._depthCullingState.depthMask = !0,
- this._maxSimultaneousTextures = this._caps.maxCombinedTexturesImageUnits;
- for (var $ = 0; $ < this._maxSimultaneousTextures; $++)
- this._nextFreeTextureSlots.push($)
- }
- ,
- a.prototype._initFeatures = function() {
- this._features = {
- forceBitmapOverHTMLImageElement: !1,
- supportRenderAndCopyToLodForFloatTextures: this._webGLVersion !== 1,
- supportDepthStencilTexture: this._webGLVersion !== 1,
- supportShadowSamplers: this._webGLVersion !== 1,
- uniformBufferHardCheckMatrix: !1,
- allowTexturePrefiltering: this._webGLVersion !== 1,
- trackUbosInFrame: !1,
- checkUbosContentBeforeUpload: !1,
- supportCSM: this._webGLVersion !== 1,
- basisNeedsPOT: this._webGLVersion === 1,
- support3DTextures: this._webGLVersion !== 1,
- needTypeSuffixInShaderConstants: this._webGLVersion !== 1,
- supportMSAA: this._webGLVersion !== 1,
- supportSSAO2: this._webGLVersion !== 1,
- supportExtendedTextureFormats: this._webGLVersion !== 1,
- supportSwitchCaseInShader: this._webGLVersion !== 1,
- supportSyncTextureRead: !0,
- needsInvertingBitmap: !0,
- useUBOBindingCache: !0,
- needShaderCodeInlining: !1,
- needToAlwaysBindUniformBuffers: !1,
- supportRenderPasses: !1,
- _collectUbosUpdatedInFrame: !1
- }
- }
- ,
- Object.defineProperty(a.prototype, "webGLVersion", {
- get: function() {
- return this._webGLVersion
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.getClassName = function() {
- return "ThinEngine"
- }
- ,
- Object.defineProperty(a.prototype, "isStencilEnable", {
- get: function() {
- return this._isStencilEnable
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._prepareWorkingCanvas = function() {
- if (!this._workingCanvas) {
- this._workingCanvas = this.createCanvas(1, 1);
- var e = this._workingCanvas.getContext("2d");
- e && (this._workingContext = e)
- }
- }
- ,
- a.prototype.resetTextureCache = function() {
- for (var e in this._boundTexturesCache)
- !this._boundTexturesCache.hasOwnProperty(e) || (this._boundTexturesCache[e] = null);
- this._currentTextureChannel = -1
- }
- ,
- a.prototype.getInfo = function() {
- return this.getGlInfo()
- }
- ,
- a.prototype.getGlInfo = function() {
- return {
- vendor: this._glVendor,
- renderer: this._glRenderer,
- version: this._glVersion
- }
- }
- ,
- a.prototype.setHardwareScalingLevel = function(e) {
- this._hardwareScalingLevel = e,
- this.resize()
- }
- ,
- a.prototype.getHardwareScalingLevel = function() {
- return this._hardwareScalingLevel
- }
- ,
- a.prototype.getLoadedTexturesCache = function() {
- return this._internalTexturesCache
- }
- ,
- a.prototype.getCaps = function() {
- return this._caps
- }
- ,
- a.prototype.stopRenderLoop = function(e) {
- if (!e) {
- this._activeRenderLoops = [];
- return
- }
- var i = this._activeRenderLoops.indexOf(e);
- i >= 0 && this._activeRenderLoops.splice(i, 1)
- }
- ,
- a.prototype._renderLoop = function() {
- if (!this._contextWasLost) {
- var e = !0;
- if (!this.renderEvenInBackground && this._windowIsBackground && (e = !1),
- e) {
- this.beginFrame();
- for (var i = 0; i < this._activeRenderLoops.length; i++) {
- var o = this._activeRenderLoops[i];
- o()
- }
- this.endFrame()
- }
- }
- this._activeRenderLoops.length > 0 ? this._frameHandler = this._queueNewFrame(this._boundRenderFunction, this.getHostWindow()) : this._renderingQueueLaunched = !1
- }
- ,
- a.prototype.getRenderingCanvas = function() {
- return this._renderingCanvas
- }
- ,
- a.prototype.getAudioContext = function() {
- return this._audioContext
- }
- ,
- a.prototype.getAudioDestination = function() {
- return this._audioDestination
- }
- ,
- a.prototype.getHostWindow = function() {
- return IsWindowObjectExist() ? this._renderingCanvas && this._renderingCanvas.ownerDocument && this._renderingCanvas.ownerDocument.defaultView ? this._renderingCanvas.ownerDocument.defaultView : window : null
- }
- ,
- a.prototype.getRenderWidth = function(e) {
- return e === void 0 && (e = !1),
- !e && this._currentRenderTarget ? this._currentRenderTarget.width : this._framebufferDimensionsObject ? this._framebufferDimensionsObject.framebufferWidth : this._gl.drawingBufferWidth
- }
- ,
- a.prototype.getRenderHeight = function(e) {
- return e === void 0 && (e = !1),
- !e && this._currentRenderTarget ? this._currentRenderTarget.height : this._framebufferDimensionsObject ? this._framebufferDimensionsObject.framebufferHeight : this._gl.drawingBufferHeight
- }
- ,
- a.prototype._queueNewFrame = function(e, i) {
- return a.QueueNewFrame(e, i)
- }
- ,
- a.prototype.runRenderLoop = function(e) {
- this._activeRenderLoops.indexOf(e) === -1 && (this._activeRenderLoops.push(e),
- this._renderingQueueLaunched || (this._renderingQueueLaunched = !0,
- this._boundRenderFunction = this._renderLoop.bind(this),
- this._frameHandler = this._queueNewFrame(this._boundRenderFunction, this.getHostWindow())))
- }
- ,
- a.prototype.clear = function(e, i, o, s) {
- s === void 0 && (s = !1);
- var c = this.stencilStateComposer.useStencilGlobalOnly;
- this.stencilStateComposer.useStencilGlobalOnly = !0,
- this.applyStates(),
- this.stencilStateComposer.useStencilGlobalOnly = c;
- var d = 0;
- i && e && (this._gl.clearColor(e.r, e.g, e.b, e.a !== void 0 ? e.a : 1),
- d |= this._gl.COLOR_BUFFER_BIT),
- o && (this.useReverseDepthBuffer ? (this._depthCullingState.depthFunc = this._gl.GEQUAL,
- this._gl.clearDepth(0)) : this._gl.clearDepth(1),
- d |= this._gl.DEPTH_BUFFER_BIT),
- s && (this._gl.clearStencil(0),
- d |= this._gl.STENCIL_BUFFER_BIT),
- this._gl.clear(d)
- }
- ,
- a.prototype._viewport = function(e, i, o, s) {
- (e !== this._viewportCached.x || i !== this._viewportCached.y || o !== this._viewportCached.z || s !== this._viewportCached.w) && (this._viewportCached.x = e,
- this._viewportCached.y = i,
- this._viewportCached.z = o,
- this._viewportCached.w = s,
- this._gl.viewport(e, i, o, s))
- }
- ,
- a.prototype.setViewport = function(e, i, o) {
- var s = i || this.getRenderWidth()
- , c = o || this.getRenderHeight()
- , d = e.x || 0
- , _ = e.y || 0;
- this._cachedViewport = e,
- this._viewport(d * s, _ * c, s * e.width, c * e.height)
- }
- ,
- a.prototype.beginFrame = function() {}
- ,
- a.prototype.endFrame = function() {
- this._badOS && this.flushFramebuffer(),
- this._frameId++
- }
- ,
- a.prototype.resize = function(e) {
- e === void 0 && (e = !1);
- var i, o;
- IsWindowObjectExist() ? (i = this._renderingCanvas ? this._renderingCanvas.clientWidth || this._renderingCanvas.width : window.innerWidth,
- o = this._renderingCanvas ? this._renderingCanvas.clientHeight || this._renderingCanvas.height : window.innerHeight) : (i = this._renderingCanvas ? this._renderingCanvas.width : 100,
- o = this._renderingCanvas ? this._renderingCanvas.height : 100),
- this.setSize(i / this._hardwareScalingLevel, o / this._hardwareScalingLevel, e)
- }
- ,
- a.prototype.setSize = function(e, i, o) {
- return o === void 0 && (o = !1),
- !this._renderingCanvas || (e = e | 0,
- i = i | 0,
- !o && this._renderingCanvas.width === e && this._renderingCanvas.height === i) ? !1 : (this._renderingCanvas.width = e,
- this._renderingCanvas.height = i,
- !0)
- }
- ,
- a.prototype.bindFramebuffer = function(e, i, o, s, c, d, _) {
- var b, k, j, $, _e;
- i === void 0 && (i = 0),
- d === void 0 && (d = 0),
- _ === void 0 && (_ = 0);
- var et = e;
- this._currentRenderTarget && this.unBindFramebuffer(this._currentRenderTarget),
- this._currentRenderTarget = e,
- this._bindUnboundFramebuffer(et._MSAAFramebuffer ? et._MSAAFramebuffer : et._framebuffer);
- var tt = this._gl;
- 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);
- var rt = e._depthStencilTexture;
- if (rt) {
- var it = e._depthStencilTextureWithStencil ? tt.DEPTH_STENCIL_ATTACHMENT : tt.DEPTH_ATTACHMENT;
- 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)
- }
- this._cachedViewport && !c ? this.setViewport(this._cachedViewport, o, s) : (o || (o = e.width,
- d && (o = o / Math.pow(2, d))),
- s || (s = e.height,
- d && (s = s / Math.pow(2, d))),
- this._viewport(0, 0, o, s)),
- this.wipeCaches()
- }
- ,
- a.prototype.setState = function(e, i, o, s, c, d, _) {
- var b, k;
- i === void 0 && (i = 0),
- s === void 0 && (s = !1),
- _ === void 0 && (_ = 0),
- (this._depthCullingState.cull !== e || o) && (this._depthCullingState.cull = e);
- var j = !((k = (b = this.cullBackFaces) !== null && b !== void 0 ? b : c) !== null && k !== void 0) || k ? this._gl.BACK : this._gl.FRONT;
- (this._depthCullingState.cullFace !== j || o) && (this._depthCullingState.cullFace = j),
- this.setZOffset(i),
- this.setZOffsetUnits(_);
- var $ = s ? this._gl.CW : this._gl.CCW;
- (this._depthCullingState.frontFace !== $ || o) && (this._depthCullingState.frontFace = $),
- this._stencilStateComposer.stencilMaterial = d
- }
- ,
- a.prototype.setZOffset = function(e) {
- this._depthCullingState.zOffset = this.useReverseDepthBuffer ? -e : e
- }
- ,
- a.prototype.getZOffset = function() {
- var e = this._depthCullingState.zOffset;
- return this.useReverseDepthBuffer ? -e : e
- }
- ,
- a.prototype.setZOffsetUnits = function(e) {
- this._depthCullingState.zOffsetUnits = this.useReverseDepthBuffer ? -e : e
- }
- ,
- a.prototype.getZOffsetUnits = function() {
- var e = this._depthCullingState.zOffsetUnits;
- return this.useReverseDepthBuffer ? -e : e
- }
- ,
- a.prototype._bindUnboundFramebuffer = function(e) {
- this._currentFramebuffer !== e && (this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, e),
- this._currentFramebuffer = e)
- }
- ,
- a.prototype._currentFrameBufferIsDefaultFrameBuffer = function() {
- return this._currentFramebuffer === null
- }
- ,
- a.prototype.generateMipmaps = function(e) {
- this._bindTextureDirectly(this._gl.TEXTURE_2D, e, !0),
- this._gl.generateMipmap(this._gl.TEXTURE_2D),
- this._bindTextureDirectly(this._gl.TEXTURE_2D, null)
- }
- ,
- a.prototype.unBindFramebuffer = function(e, i, o) {
- var s;
- i === void 0 && (i = !1);
- var c = e;
- this._currentRenderTarget = null;
- var d = this._gl;
- if (c._MSAAFramebuffer) {
- if (e.isMulti) {
- this.unBindMultiColorAttachmentFramebuffer(e, i, o);
- return
- }
- d.bindFramebuffer(d.READ_FRAMEBUFFER, c._MSAAFramebuffer),
- d.bindFramebuffer(d.DRAW_FRAMEBUFFER, c._framebuffer),
- d.blitFramebuffer(0, 0, e.width, e.height, 0, 0, e.width, e.height, d.COLOR_BUFFER_BIT, d.NEAREST)
- }
- ((s = e.texture) === null || s === void 0 ? void 0 : s.generateMipMaps) && !i && !e.isCube && this.generateMipmaps(e.texture),
- o && (c._MSAAFramebuffer && this._bindUnboundFramebuffer(c._framebuffer),
- o()),
- this._bindUnboundFramebuffer(null)
- }
- ,
- a.prototype.flushFramebuffer = function() {
- this._gl.flush()
- }
- ,
- a.prototype.restoreDefaultFramebuffer = function() {
- this._currentRenderTarget ? this.unBindFramebuffer(this._currentRenderTarget) : this._bindUnboundFramebuffer(null),
- this._cachedViewport && this.setViewport(this._cachedViewport),
- this.wipeCaches()
- }
- ,
- a.prototype._resetVertexBufferBinding = function() {
- this.bindArrayBuffer(null),
- this._cachedVertexBuffers = null
- }
- ,
- a.prototype.createVertexBuffer = function(e) {
- return this._createVertexBuffer(e, this._gl.STATIC_DRAW)
- }
- ,
- a.prototype._createVertexBuffer = function(e, i) {
- var o = this._gl.createBuffer();
- if (!o)
- throw new Error("Unable to create vertex buffer");
- var s = new WebGLDataBuffer(o);
- return this.bindArrayBuffer(s),
- e instanceof Array ? this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(e), i) : this._gl.bufferData(this._gl.ARRAY_BUFFER, e, i),
- this._resetVertexBufferBinding(),
- s.references = 1,
- s
- }
- ,
- a.prototype.createDynamicVertexBuffer = function(e) {
- return this._createVertexBuffer(e, this._gl.DYNAMIC_DRAW)
- }
- ,
- a.prototype._resetIndexBufferBinding = function() {
- this.bindIndexBuffer(null),
- this._cachedIndexBuffer = null
- }
- ,
- a.prototype.createIndexBuffer = function(e, i) {
- var o = this._gl.createBuffer()
- , s = new WebGLDataBuffer(o);
- if (!o)
- throw new Error("Unable to create index buffer");
- this.bindIndexBuffer(s);
- var c = this._normalizeIndexData(e);
- return this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, c, i ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW),
- this._resetIndexBufferBinding(),
- s.references = 1,
- s.is32Bits = c.BYTES_PER_ELEMENT === 4,
- s
- }
- ,
- a.prototype._normalizeIndexData = function(e) {
- var i = e.BYTES_PER_ELEMENT;
- if (i === 2)
- return e;
- if (this._caps.uintIndices) {
- if (e instanceof Uint32Array)
- return e;
- for (var o = 0; o < e.length; o++)
- if (e[o] >= 65535)
- return new Uint32Array(e);
- return new Uint16Array(e)
- }
- return new Uint16Array(e)
- }
- ,
- a.prototype.bindArrayBuffer = function(e) {
- this._vaoRecordInProgress || this._unbindVertexArrayObject(),
- this.bindBuffer(e, this._gl.ARRAY_BUFFER)
- }
- ,
- a.prototype.bindUniformBlock = function(e, i, o) {
- var s = e.program
- , c = this._gl.getUniformBlockIndex(s, i);
- this._gl.uniformBlockBinding(s, c, o)
- }
- ,
- a.prototype.bindIndexBuffer = function(e) {
- this._vaoRecordInProgress || this._unbindVertexArrayObject(),
- this.bindBuffer(e, this._gl.ELEMENT_ARRAY_BUFFER)
- }
- ,
- a.prototype.bindBuffer = function(e, i) {
- (this._vaoRecordInProgress || this._currentBoundBuffer[i] !== e) && (this._gl.bindBuffer(i, e ? e.underlyingResource : null),
- this._currentBoundBuffer[i] = e)
- }
- ,
- a.prototype.updateArrayBuffer = function(e) {
- this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, e)
- }
- ,
- a.prototype._vertexAttribPointer = function(e, i, o, s, c, d, _) {
- var b = this._currentBufferPointers[i];
- if (!!b) {
- var k = !1;
- b.active ? (b.buffer !== e && (b.buffer = e,
- k = !0),
- b.size !== o && (b.size = o,
- k = !0),
- b.type !== s && (b.type = s,
- k = !0),
- b.normalized !== c && (b.normalized = c,
- k = !0),
- b.stride !== d && (b.stride = d,
- k = !0),
- b.offset !== _ && (b.offset = _,
- k = !0)) : (k = !0,
- b.active = !0,
- b.index = i,
- b.size = o,
- b.type = s,
- b.normalized = c,
- b.stride = d,
- b.offset = _,
- b.buffer = e),
- (k || this._vaoRecordInProgress) && (this.bindArrayBuffer(e),
- this._gl.vertexAttribPointer(i, o, s, c, d, _))
- }
- }
- ,
- a.prototype._bindIndexBufferWithCache = function(e) {
- e != null && this._cachedIndexBuffer !== e && (this._cachedIndexBuffer = e,
- this.bindIndexBuffer(e),
- this._uintIndicesCurrentlySet = e.is32Bits)
- }
- ,
- a.prototype._bindVertexBuffersAttributes = function(e, i, o) {
- var s = i.getAttributesNames();
- this._vaoRecordInProgress || this._unbindVertexArrayObject(),
- this.unbindAllAttributes();
- for (var c = 0; c < s.length; c++) {
- var d = i.getAttributeLocation(c);
- if (d >= 0) {
- var _ = s[c]
- , b = null;
- if (o && (b = o[_]),
- b || (b = e[_]),
- !b)
- continue;
- this._gl.enableVertexAttribArray(d),
- this._vaoRecordInProgress || (this._vertexAttribArraysEnabled[d] = !0);
- var k = b.getBuffer();
- k && (this._vertexAttribPointer(k, d, b.getSize(), b.type, b.normalized, b.byteStride, b.byteOffset),
- b.getIsInstanced() && (this._gl.vertexAttribDivisor(d, b.getInstanceDivisor()),
- this._vaoRecordInProgress || (this._currentInstanceLocations.push(d),
- this._currentInstanceBuffers.push(k))))
- }
- }
- }
- ,
- a.prototype.recordVertexArrayObject = function(e, i, o, s) {
- var c = this._gl.createVertexArray();
- return this._vaoRecordInProgress = !0,
- this._gl.bindVertexArray(c),
- this._mustWipeVertexAttributes = !0,
- this._bindVertexBuffersAttributes(e, o, s),
- this.bindIndexBuffer(i),
- this._vaoRecordInProgress = !1,
- this._gl.bindVertexArray(null),
- c
- }
- ,
- a.prototype.bindVertexArrayObject = function(e, i) {
- this._cachedVertexArrayObject !== e && (this._cachedVertexArrayObject = e,
- this._gl.bindVertexArray(e),
- this._cachedVertexBuffers = null,
- this._cachedIndexBuffer = null,
- this._uintIndicesCurrentlySet = i != null && i.is32Bits,
- this._mustWipeVertexAttributes = !0)
- }
- ,
- a.prototype.bindBuffersDirectly = function(e, i, o, s, c) {
- if (this._cachedVertexBuffers !== e || this._cachedEffectForVertexBuffers !== c) {
- this._cachedVertexBuffers = e,
- this._cachedEffectForVertexBuffers = c;
- var d = c.getAttributesCount();
- this._unbindVertexArrayObject(),
- this.unbindAllAttributes();
- for (var _ = 0, b = 0; b < d; b++)
- if (b < o.length) {
- var k = c.getAttributeLocation(b);
- k >= 0 && (this._gl.enableVertexAttribArray(k),
- this._vertexAttribArraysEnabled[k] = !0,
- this._vertexAttribPointer(e, k, o[b], this._gl.FLOAT, !1, s, _)),
- _ += o[b] * 4
- }
- }
- this._bindIndexBufferWithCache(i)
- }
- ,
- a.prototype._unbindVertexArrayObject = function() {
- !this._cachedVertexArrayObject || (this._cachedVertexArrayObject = null,
- this._gl.bindVertexArray(null))
- }
- ,
- a.prototype.bindBuffers = function(e, i, o, s) {
- (this._cachedVertexBuffers !== e || this._cachedEffectForVertexBuffers !== o) && (this._cachedVertexBuffers = e,
- this._cachedEffectForVertexBuffers = o,
- this._bindVertexBuffersAttributes(e, o, s)),
- this._bindIndexBufferWithCache(i)
- }
- ,
- a.prototype.unbindInstanceAttributes = function() {
- for (var e, i = 0, o = this._currentInstanceLocations.length; i < o; i++) {
- var s = this._currentInstanceBuffers[i];
- e != s && s.references && (e = s,
- this.bindArrayBuffer(s));
- var c = this._currentInstanceLocations[i];
- this._gl.vertexAttribDivisor(c, 0)
- }
- this._currentInstanceBuffers.length = 0,
- this._currentInstanceLocations.length = 0
- }
- ,
- a.prototype.releaseVertexArrayObject = function(e) {
- this._gl.deleteVertexArray(e)
- }
- ,
- a.prototype._releaseBuffer = function(e) {
- return e.references--,
- e.references === 0 ? (this._deleteBuffer(e),
- !0) : !1
- }
- ,
- a.prototype._deleteBuffer = function(e) {
- this._gl.deleteBuffer(e.underlyingResource)
- }
- ,
- a.prototype.updateAndBindInstancesBuffer = function(e, i, o) {
- if (this.bindArrayBuffer(e),
- i && this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, i),
- o[0].index !== void 0)
- this.bindInstancesBuffer(e, o, !0);
- else
- for (var s = 0; s < 4; s++) {
- var c = o[s];
- this._vertexAttribArraysEnabled[c] || (this._gl.enableVertexAttribArray(c),
- this._vertexAttribArraysEnabled[c] = !0),
- this._vertexAttribPointer(e, c, 4, this._gl.FLOAT, !1, 64, s * 16),
- this._gl.vertexAttribDivisor(c, 1),
- this._currentInstanceLocations.push(c),
- this._currentInstanceBuffers.push(e)
- }
- }
- ,
- a.prototype.bindInstancesBuffer = function(e, i, o) {
- o === void 0 && (o = !0),
- this.bindArrayBuffer(e);
- var s = 0;
- if (o)
- for (var c = 0; c < i.length; c++) {
- var d = i[c];
- s += d.attributeSize * 4
- }
- for (var c = 0; c < i.length; c++) {
- var d = i[c];
- d.index === void 0 && (d.index = this._currentEffect.getAttributeLocationByName(d.attributeName)),
- !(d.index < 0) && (this._vertexAttribArraysEnabled[d.index] || (this._gl.enableVertexAttribArray(d.index),
- this._vertexAttribArraysEnabled[d.index] = !0),
- this._vertexAttribPointer(e, d.index, d.attributeSize, d.attributeType || this._gl.FLOAT, d.normalized || !1, s, d.offset),
- this._gl.vertexAttribDivisor(d.index, d.divisor === void 0 ? 1 : d.divisor),
- this._currentInstanceLocations.push(d.index),
- this._currentInstanceBuffers.push(e))
- }
- }
- ,
- a.prototype.disableInstanceAttributeByName = function(e) {
- if (!!this._currentEffect) {
- var i = this._currentEffect.getAttributeLocationByName(e);
- this.disableInstanceAttribute(i)
- }
- }
- ,
- a.prototype.disableInstanceAttribute = function(e) {
- for (var i = !1, o; (o = this._currentInstanceLocations.indexOf(e)) !== -1; )
- this._currentInstanceLocations.splice(o, 1),
- this._currentInstanceBuffers.splice(o, 1),
- i = !0,
- o = this._currentInstanceLocations.indexOf(e);
- i && (this._gl.vertexAttribDivisor(e, 0),
- this.disableAttributeByIndex(e))
- }
- ,
- a.prototype.disableAttributeByIndex = function(e) {
- this._gl.disableVertexAttribArray(e),
- this._vertexAttribArraysEnabled[e] = !1,
- this._currentBufferPointers[e].active = !1
- }
- ,
- a.prototype.draw = function(e, i, o, s) {
- this.drawElementsType(e ? 0 : 1, i, o, s)
- }
- ,
- a.prototype.drawPointClouds = function(e, i, o) {
- this.drawArraysType(2, e, i, o)
- }
- ,
- a.prototype.drawUnIndexed = function(e, i, o, s) {
- this.drawArraysType(e ? 0 : 1, i, o, s)
- }
- ,
- a.prototype.drawElementsType = function(e, i, o, s) {
- this.applyStates(),
- this._reportDrawCall();
- var c = this._drawMode(e)
- , d = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT
- , _ = this._uintIndicesCurrentlySet ? 4 : 2;
- s ? this._gl.drawElementsInstanced(c, o, d, i * _, s) : this._gl.drawElements(c, o, d, i * _)
- }
- ,
- a.prototype.drawArraysType = function(e, i, o, s) {
- this.applyStates(),
- this._reportDrawCall();
- var c = this._drawMode(e);
- s ? this._gl.drawArraysInstanced(c, i, o, s) : this._gl.drawArrays(c, i, o)
- }
- ,
- a.prototype._drawMode = function(e) {
- switch (e) {
- case 0:
- return this._gl.TRIANGLES;
- case 2:
- return this._gl.POINTS;
- case 1:
- return this._gl.LINES;
- case 3:
- return this._gl.POINTS;
- case 4:
- return this._gl.LINES;
- case 5:
- return this._gl.LINE_LOOP;
- case 6:
- return this._gl.LINE_STRIP;
- case 7:
- return this._gl.TRIANGLE_STRIP;
- case 8:
- return this._gl.TRIANGLE_FAN;
- default:
- return this._gl.TRIANGLES
- }
- }
- ,
- a.prototype._reportDrawCall = function() {}
- ,
- a.prototype._releaseEffect = function(e) {
- if (this._compiledEffects[e._key]) {
- delete this._compiledEffects[e._key];
- var i = e.getPipelineContext();
- i && this._deletePipelineContext(i)
- }
- }
- ,
- a.prototype._deletePipelineContext = function(e) {
- var i = e;
- i && i.program && (i.program.__SPECTOR_rebuildProgram = null,
- this._gl.deleteProgram(i.program))
- }
- ,
- a.prototype._getGlobalDefines = function(e) {
- if (e) {
- this.isNDCHalfZRange ? e.IS_NDC_HALF_ZRANGE = "" : delete e.IS_NDC_HALF_ZRANGE,
- this.useReverseDepthBuffer ? e.USE_REVERSE_DEPTHBUFFER = "" : delete e.USE_REVERSE_DEPTHBUFFER;
- return
- } else {
- var i = "";
- return this.isNDCHalfZRange && (i += "#define IS_NDC_HALF_ZRANGE"),
- this.useReverseDepthBuffer && (i && (i += `
- `),
- i += "#define USE_REVERSE_DEPTHBUFFER"),
- i
- }
- }
- ,
- a.prototype.createEffect = function(e, i, o, s, c, d, _, b, k, j) {
- var $;
- j === void 0 && (j = ShaderLanguage.GLSL);
- var _e = e.vertexElement || e.vertex || e.vertexToken || e.vertexSource || e
- , et = e.fragmentElement || e.fragment || e.fragmentToken || e.fragmentSource || e
- , tt = this._getGlobalDefines()
- , rt = ($ = c != null ? c : i.defines) !== null && $ !== void 0 ? $ : "";
- tt && (rt += tt);
- var it = _e + "+" + et + "@" + rt;
- if (this._compiledEffects[it]) {
- var nt = this._compiledEffects[it];
- return _ && nt.isReady() && _(nt),
- nt
- }
- var ot = new Effect(e,i,o,s,this,c,d,_,b,k,it,j);
- return this._compiledEffects[it] = ot,
- ot
- }
- ,
- a._ConcatenateShader = function(e, i, o) {
- return o === void 0 && (o = ""),
- o + (i ? i + `
- ` : "") + e
- }
- ,
- a.prototype._compileShader = function(e, i, o, s) {
- return this._compileRawShader(a._ConcatenateShader(e, o, s), i)
- }
- ,
- a.prototype._compileRawShader = function(e, i) {
- for (var o = this._gl; o.getError() != o.NO_ERROR; )
- ;
- var s = o.createShader(i === "vertex" ? o.VERTEX_SHADER : o.FRAGMENT_SHADER);
- if (!s)
- throw new Error("Something went wrong while creating a gl " + i + " shader object. gl error=" + o.getError() + ", gl isContextLost=" + o.isContextLost() + ", _contextWasLost=" + this._contextWasLost);
- return o.shaderSource(s, e),
- o.compileShader(s),
- s
- }
- ,
- a.prototype._getShaderSource = function(e) {
- return this._gl.getShaderSource(e)
- }
- ,
- a.prototype.createRawShaderProgram = function(e, i, o, s, c) {
- c === void 0 && (c = null),
- s = s || this._gl;
- var d = this._compileRawShader(i, "vertex")
- , _ = this._compileRawShader(o, "fragment");
- return this._createShaderProgram(e, d, _, s, c)
- }
- ,
- a.prototype.createShaderProgram = function(e, i, o, s, c, d) {
- d === void 0 && (d = null),
- c = c || this._gl;
- var _ = this._webGLVersion > 1 ? `#version 300 es
- #define WEBGL2
- ` : ""
- , b = this._compileShader(i, "vertex", s, _)
- , k = this._compileShader(o, "fragment", s, _);
- return this._createShaderProgram(e, b, k, c, d)
- }
- ,
- a.prototype.inlineShaderCode = function(e) {
- return e
- }
- ,
- a.prototype.createPipelineContext = function(e) {
- var i = new WebGLPipelineContext;
- return i.engine = this,
- this._caps.parallelShaderCompile && (i.isParallelCompiled = !0),
- i
- }
- ,
- a.prototype.createMaterialContext = function() {}
- ,
- a.prototype.createDrawContext = function() {}
- ,
- a.prototype._createShaderProgram = function(e, i, o, s, c) {
- var d = s.createProgram();
- if (e.program = d,
- !d)
- throw new Error("Unable to create program");
- return s.attachShader(d, i),
- s.attachShader(d, o),
- s.linkProgram(d),
- e.context = s,
- e.vertexShader = i,
- e.fragmentShader = o,
- e.isParallelCompiled || this._finalizePipelineContext(e),
- d
- }
- ,
- a.prototype._finalizePipelineContext = function(e) {
- var i = e.context
- , o = e.vertexShader
- , s = e.fragmentShader
- , c = e.program
- , d = i.getProgramParameter(c, i.LINK_STATUS);
- if (!d) {
- if (!this._gl.getShaderParameter(o, this._gl.COMPILE_STATUS)) {
- var _ = this._gl.getShaderInfoLog(o);
- if (_)
- throw e.vertexCompilationError = _,
- new Error("VERTEX SHADER " + _)
- }
- if (!this._gl.getShaderParameter(s, this._gl.COMPILE_STATUS)) {
- var _ = this._gl.getShaderInfoLog(s);
- if (_)
- throw e.fragmentCompilationError = _,
- new Error("FRAGMENT SHADER " + _)
- }
- var b = i.getProgramInfoLog(c);
- if (b)
- throw e.programLinkError = b,
- new Error(b)
- }
- if (this.validateShaderPrograms) {
- i.validateProgram(c);
- var k = i.getProgramParameter(c, i.VALIDATE_STATUS);
- if (!k) {
- var b = i.getProgramInfoLog(c);
- if (b)
- throw e.programValidationError = b,
- new Error(b)
- }
- }
- i.deleteShader(o),
- i.deleteShader(s),
- e.vertexShader = void 0,
- e.fragmentShader = void 0,
- e.onCompiled && (e.onCompiled(),
- e.onCompiled = void 0)
- }
- ,
- a.prototype._preparePipelineContext = function(e, i, o, s, c, d, _, b, k, j) {
- var $ = e;
- s ? $.program = this.createRawShaderProgram($, i, o, void 0, k) : $.program = this.createShaderProgram($, i, o, b, void 0, k),
- $.program.__SPECTOR_rebuildProgram = _
- }
- ,
- a.prototype._isRenderingStateCompiled = function(e) {
- var i = e;
- return this._gl.getProgramParameter(i.program, this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR) ? (this._finalizePipelineContext(i),
- !0) : !1
- }
- ,
- a.prototype._executeWhenRenderingStateIsCompiled = function(e, i) {
- var o = e;
- if (!o.isParallelCompiled) {
- i();
- return
- }
- var s = o.onCompiled;
- s ? o.onCompiled = function() {
- s(),
- i()
- }
- : o.onCompiled = i
- }
- ,
- a.prototype.getUniforms = function(e, i) {
- for (var o = new Array, s = e, c = 0; c < i.length; c++)
- o.push(this._gl.getUniformLocation(s.program, i[c]));
- return o
- }
- ,
- a.prototype.getAttributes = function(e, i) {
- for (var o = [], s = e, c = 0; c < i.length; c++)
- try {
- o.push(this._gl.getAttribLocation(s.program, i[c]))
- } catch {
- o.push(-1)
- }
- return o
- }
- ,
- a.prototype.enableEffect = function(e) {
- e = e !== null && DrawWrapper.IsWrapper(e) ? e.effect : e,
- !(!e || e === this._currentEffect) && (this._stencilStateComposer.stencilMaterial = void 0,
- e = e,
- this.bindSamplers(e),
- this._currentEffect = e,
- e.onBind && e.onBind(e),
- e._onBindObservable && e._onBindObservable.notifyObservers(e))
- }
- ,
- a.prototype.setInt = function(e, i) {
- return e ? (this._gl.uniform1i(e, i),
- !0) : !1
- }
- ,
- a.prototype.setInt2 = function(e, i, o) {
- return e ? (this._gl.uniform2i(e, i, o),
- !0) : !1
- }
- ,
- a.prototype.setInt3 = function(e, i, o, s) {
- return e ? (this._gl.uniform3i(e, i, o, s),
- !0) : !1
- }
- ,
- a.prototype.setInt4 = function(e, i, o, s, c) {
- return e ? (this._gl.uniform4i(e, i, o, s, c),
- !0) : !1
- }
- ,
- a.prototype.setIntArray = function(e, i) {
- return e ? (this._gl.uniform1iv(e, i),
- !0) : !1
- }
- ,
- a.prototype.setIntArray2 = function(e, i) {
- return !e || i.length % 2 !== 0 ? !1 : (this._gl.uniform2iv(e, i),
- !0)
- }
- ,
- a.prototype.setIntArray3 = function(e, i) {
- return !e || i.length % 3 !== 0 ? !1 : (this._gl.uniform3iv(e, i),
- !0)
- }
- ,
- a.prototype.setIntArray4 = function(e, i) {
- return !e || i.length % 4 !== 0 ? !1 : (this._gl.uniform4iv(e, i),
- !0)
- }
- ,
- a.prototype.setArray = function(e, i) {
- return !e || i.length < 1 ? !1 : (this._gl.uniform1fv(e, i),
- !0)
- }
- ,
- a.prototype.setArray2 = function(e, i) {
- return !e || i.length % 2 !== 0 ? !1 : (this._gl.uniform2fv(e, i),
- !0)
- }
- ,
- a.prototype.setArray3 = function(e, i) {
- return !e || i.length % 3 !== 0 ? !1 : (this._gl.uniform3fv(e, i),
- !0)
- }
- ,
- a.prototype.setArray4 = function(e, i) {
- return !e || i.length % 4 !== 0 ? !1 : (this._gl.uniform4fv(e, i),
- !0)
- }
- ,
- a.prototype.setMatrices = function(e, i) {
- return e ? (this._gl.uniformMatrix4fv(e, !1, i),
- !0) : !1
- }
- ,
- a.prototype.setMatrix3x3 = function(e, i) {
- return e ? (this._gl.uniformMatrix3fv(e, !1, i),
- !0) : !1
- }
- ,
- a.prototype.setMatrix2x2 = function(e, i) {
- return e ? (this._gl.uniformMatrix2fv(e, !1, i),
- !0) : !1
- }
- ,
- a.prototype.setFloat = function(e, i) {
- return e ? (this._gl.uniform1f(e, i),
- !0) : !1
- }
- ,
- a.prototype.setFloat2 = function(e, i, o) {
- return e ? (this._gl.uniform2f(e, i, o),
- !0) : !1
- }
- ,
- a.prototype.setFloat3 = function(e, i, o, s) {
- return e ? (this._gl.uniform3f(e, i, o, s),
- !0) : !1
- }
- ,
- a.prototype.setFloat4 = function(e, i, o, s, c) {
- return e ? (this._gl.uniform4f(e, i, o, s, c),
- !0) : !1
- }
- ,
- a.prototype.applyStates = function() {
- if (this._depthCullingState.apply(this._gl),
- this._stencilStateComposer.apply(this._gl),
- this._alphaState.apply(this._gl),
- this._colorWriteChanged) {
- this._colorWriteChanged = !1;
- var e = this._colorWrite;
- this._gl.colorMask(e, e, e, e)
- }
- }
- ,
- a.prototype.setColorWrite = function(e) {
- e !== this._colorWrite && (this._colorWriteChanged = !0,
- this._colorWrite = e)
- }
- ,
- a.prototype.getColorWrite = function() {
- return this._colorWrite
- }
- ,
- Object.defineProperty(a.prototype, "depthCullingState", {
- get: function() {
- return this._depthCullingState
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "alphaState", {
- get: function() {
- return this._alphaState
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "stencilState", {
- get: function() {
- return this._stencilState
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "stencilStateComposer", {
- get: function() {
- return this._stencilStateComposer
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.clearInternalTexturesCache = function() {
- this._internalTexturesCache = []
- }
- ,
- a.prototype.wipeCaches = function(e) {
- this.preventCacheWipeBetweenFrames && !e || (this._currentEffect = null,
- this._viewportCached.x = 0,
- this._viewportCached.y = 0,
- this._viewportCached.z = 0,
- this._viewportCached.w = 0,
- this._unbindVertexArrayObject(),
- e && (this._currentProgram = null,
- this.resetTextureCache(),
- this._stencilStateComposer.reset(),
- this._depthCullingState.reset(),
- this._depthCullingState.depthFunc = this._gl.LEQUAL,
- this._alphaState.reset(),
- this._alphaMode = 1,
- this._alphaEquation = 0,
- this._colorWrite = !0,
- this._colorWriteChanged = !0,
- this._unpackFlipYCached = null,
- this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._gl.NONE),
- this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0),
- this._mustWipeVertexAttributes = !0,
- this.unbindAllAttributes()),
- this._resetVertexBufferBinding(),
- this._cachedIndexBuffer = null,
- this._cachedEffectForVertexBuffers = null,
- this.bindIndexBuffer(null))
- }
- ,
- a.prototype._getSamplingParameters = function(e, i) {
- var o = this._gl
- , s = o.NEAREST
- , c = o.NEAREST;
- switch (e) {
- case 11:
- s = o.LINEAR,
- i ? c = o.LINEAR_MIPMAP_NEAREST : c = o.LINEAR;
- break;
- case 3:
- s = o.LINEAR,
- i ? c = o.LINEAR_MIPMAP_LINEAR : c = o.LINEAR;
- break;
- case 8:
- s = o.NEAREST,
- i ? c = o.NEAREST_MIPMAP_LINEAR : c = o.NEAREST;
- break;
- case 4:
- s = o.NEAREST,
- i ? c = o.NEAREST_MIPMAP_NEAREST : c = o.NEAREST;
- break;
- case 5:
- s = o.NEAREST,
- i ? c = o.LINEAR_MIPMAP_NEAREST : c = o.LINEAR;
- break;
- case 6:
- s = o.NEAREST,
- i ? c = o.LINEAR_MIPMAP_LINEAR : c = o.LINEAR;
- break;
- case 7:
- s = o.NEAREST,
- c = o.LINEAR;
- break;
- case 1:
- s = o.NEAREST,
- c = o.NEAREST;
- break;
- case 9:
- s = o.LINEAR,
- i ? c = o.NEAREST_MIPMAP_NEAREST : c = o.NEAREST;
- break;
- case 10:
- s = o.LINEAR,
- i ? c = o.NEAREST_MIPMAP_LINEAR : c = o.NEAREST;
- break;
- case 2:
- s = o.LINEAR,
- c = o.LINEAR;
- break;
- case 12:
- s = o.LINEAR,
- c = o.NEAREST;
- break
- }
- return {
- min: c,
- mag: s
- }
- }
- ,
- a.prototype._createTexture = function() {
- var e = this._gl.createTexture();
- if (!e)
- throw new Error("Unable to create texture");
- return e
- }
- ,
- a.prototype._createHardwareTexture = function() {
- return new WebGLHardwareTexture(this._createTexture(),this._gl)
- }
- ,
- a.prototype._createInternalTexture = function(e, i, o, s) {
- s === void 0 && (s = InternalTextureSource.Unknown);
- var c = {};
- i !== void 0 && typeof i == "object" ? (c.generateMipMaps = i.generateMipMaps,
- c.type = i.type === void 0 ? 0 : i.type,
- c.samplingMode = i.samplingMode === void 0 ? 3 : i.samplingMode,
- c.format = i.format === void 0 ? 5 : i.format) : (c.generateMipMaps = i,
- c.type = 0,
- c.samplingMode = 3,
- c.format = 5),
- (c.type === 1 && !this._caps.textureFloatLinearFiltering || c.type === 2 && !this._caps.textureHalfFloatLinearFiltering) && (c.samplingMode = 1),
- c.type === 1 && !this._caps.textureFloat && (c.type = 0,
- Logger$2.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE"));
- var d = this._gl
- , _ = new InternalTexture(this,s)
- , b = e.width || e
- , k = e.height || e
- , j = e.layers || 0
- , $ = this._getSamplingParameters(c.samplingMode, !!c.generateMipMaps)
- , _e = j !== 0 ? d.TEXTURE_2D_ARRAY : d.TEXTURE_2D
- , et = this._getRGBABufferInternalSizedFormat(c.type, c.format)
- , tt = this._getInternalFormat(c.format)
- , rt = this._getWebGLTextureType(c.type);
- return this._bindTextureDirectly(_e, _),
- j !== 0 ? (_.is2DArray = !0,
- d.texImage3D(_e, 0, et, b, k, j, 0, tt, rt, null)) : d.texImage2D(_e, 0, et, b, k, 0, tt, rt, null),
- d.texParameteri(_e, d.TEXTURE_MAG_FILTER, $.mag),
- d.texParameteri(_e, d.TEXTURE_MIN_FILTER, $.min),
- d.texParameteri(_e, d.TEXTURE_WRAP_S, d.CLAMP_TO_EDGE),
- d.texParameteri(_e, d.TEXTURE_WRAP_T, d.CLAMP_TO_EDGE),
- c.generateMipMaps && this._gl.generateMipmap(_e),
- this._bindTextureDirectly(_e, null),
- _.baseWidth = b,
- _.baseHeight = k,
- _.width = b,
- _.height = k,
- _.depth = j,
- _.isReady = !0,
- _.samples = 1,
- _.generateMipMaps = !!c.generateMipMaps,
- _.samplingMode = c.samplingMode,
- _.type = c.type,
- _.format = c.format,
- this._internalTexturesCache.push(_),
- _
- }
- ,
- a.prototype._getUseSRGBBuffer = function(e, i) {
- return e && this._caps.supportSRGBBuffers && (this.webGLVersion > 1 || this.isWebGPU || i)
- }
- ,
- a.prototype._createTextureBase = function(e, i, o, s, c, d, _, b, k, j, $, _e, et, tt, rt, it) {
- var nt = this;
- c === void 0 && (c = 3),
- d === void 0 && (d = null),
- _ === void 0 && (_ = null),
- j === void 0 && (j = null),
- $ === void 0 && ($ = null),
- _e === void 0 && (_e = null),
- et === void 0 && (et = null),
- e = e || "";
- var ot = e.substr(0, 5) === "data:"
- , at = e.substr(0, 5) === "blob:"
- , st = ot && e.indexOf(";base64,") !== -1
- , ut = $ || new InternalTexture(this,InternalTextureSource.Url)
- , ct = e;
- this._transformTextureUrl && !st && !$ && !j && (e = this._transformTextureUrl(e)),
- ct !== e && (ut._originalUrl = ct);
- var lt = e.lastIndexOf(".")
- , ft = et || (lt > -1 ? e.substring(lt).toLowerCase() : "")
- , ht = null
- , pt = ft.indexOf("?");
- pt > -1 && (ft = ft.split("?")[0]);
- for (var dt = 0, _t = a._TextureLoaders; dt < _t.length; dt++) {
- var mt = _t[dt];
- if (mt.canLoad(ft, tt)) {
- ht = mt;
- break
- }
- }
- s && s._addPendingData(ut),
- ut.url = e,
- ut.generateMipMaps = !i,
- ut.samplingMode = c,
- ut.invertY = o,
- ut._useSRGBBuffer = this._getUseSRGBBuffer(!!it, i),
- this._doNotHandleContextLost || (ut._buffer = j);
- var vt = null;
- d && !$ && (vt = ut.onLoadedObservable.add(d)),
- $ || this._internalTexturesCache.push(ut);
- var yt = function(gt, St) {
- s && s._removePendingData(ut),
- e === ct ? (vt && ut.onLoadedObservable.remove(vt),
- EngineStore.UseFallbackTexture && nt._createTextureBase(EngineStore.FallbackTexture, i, ut.invertY, s, c, null, _, b, k, j, ut),
- gt = (gt || "Unknown error") + (EngineStore.UseFallbackTexture ? " - Fallback texture was used" : ""),
- ut.onErrorObservable.notifyObservers({
- message: gt,
- exception: St
- }),
- _ && _(gt, St)) : (Logger$2.Warn("Failed to load " + e + ", falling back to " + ct),
- nt._createTextureBase(ct, i, ut.invertY, s, c, d, _, b, k, j, ut, _e, et, tt, rt, it))
- };
- if (ht) {
- var Et = function(gt) {
- ht.loadData(gt, ut, function(St, xt, bt, Rt, Mt, Pt) {
- Pt ? yt("TextureLoader failed to load data") : b(ut, ft, s, {
- width: St,
- height: xt
- }, ut.invertY, !bt, Rt, function() {
- return Mt(),
- !1
- }, c)
- }, rt)
- };
- 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) {
- return Et(new Uint8Array(gt))
- }, void 0, s ? s.offlineProvider : void 0, !0, function(gt, St) {
- yt("Unable to load " + (gt && gt.responseURL,
- St))
- })
- } else {
- var At = function(gt) {
- at && !nt._doNotHandleContextLost && (ut._buffer = gt),
- b(ut, ft, s, gt, ut.invertY, i, !1, k, c)
- };
- !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 ? {
- imageOrientation: "flipY"
- } : 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 ? {
- imageOrientation: "flipY"
- } : void 0) : j && At(j)
- }
- return ut
- }
- ,
- a.prototype.createTexture = function(e, i, o, s, c, d, _, b, k, j, $, _e, et, tt, rt) {
- var it = this;
- return c === void 0 && (c = 3),
- d === void 0 && (d = null),
- _ === void 0 && (_ = null),
- b === void 0 && (b = null),
- k === void 0 && (k = null),
- j === void 0 && (j = null),
- $ === void 0 && ($ = null),
- this._createTextureBase(e, i, o, s, c, d, _, this._prepareWebGLTexture.bind(this), function(nt, ot, at, st, ut, ct) {
- var lt = it._gl
- , ft = at.width === nt && at.height === ot
- , ht = j ? it._getInternalFormat(j, ut._useSRGBBuffer) : st === ".jpg" && !ut._useSRGBBuffer ? lt.RGB : ut._useSRGBBuffer ? lt.SRGB8_ALPHA8 : lt.RGBA
- , pt = j ? it._getInternalFormat(j) : st === ".jpg" && !ut._useSRGBBuffer ? lt.RGB : lt.RGBA;
- if (ut._useSRGBBuffer && it.webGLVersion === 1 && (pt = ht),
- ft)
- return lt.texImage2D(lt.TEXTURE_2D, 0, ht, pt, lt.UNSIGNED_BYTE, at),
- !1;
- var dt = it._caps.maxTextureSize;
- if (at.width > dt || at.height > dt || !it._supportsHardwareTextureRescaling)
- return it._prepareWorkingCanvas(),
- !it._workingCanvas || !it._workingContext || (it._workingCanvas.width = nt,
- it._workingCanvas.height = ot,
- it._workingContext.drawImage(at, 0, 0, at.width, at.height, 0, 0, nt, ot),
- lt.texImage2D(lt.TEXTURE_2D, 0, ht, pt, lt.UNSIGNED_BYTE, it._workingCanvas),
- ut.width = nt,
- ut.height = ot),
- !1;
- var _t = new InternalTexture(it,InternalTextureSource.Temp);
- return it._bindTextureDirectly(lt.TEXTURE_2D, _t, !0),
- lt.texImage2D(lt.TEXTURE_2D, 0, ht, pt, lt.UNSIGNED_BYTE, at),
- it._rescaleTexture(_t, ut, s, ht, function() {
- it._releaseTexture(_t),
- it._bindTextureDirectly(lt.TEXTURE_2D, ut, !0),
- ct()
- }),
- !0
- }, b, k, j, $, _e, et, rt)
- }
- ,
- a._FileToolsLoadImage = function(e, i, o, s, c, d) {
- throw _WarnImport("FileTools")
- }
- ,
- a.prototype._rescaleTexture = function(e, i, o, s, c) {}
- ,
- a.prototype.createRawTexture = function(e, i, o, s, c, d, _, b, k) {
- throw _WarnImport("Engine.RawTexture")
- }
- ,
- a.prototype.createRawCubeTexture = function(e, i, o, s, c, d, _, b) {
- throw _WarnImport("Engine.RawTexture")
- }
- ,
- a.prototype.createRawTexture3D = function(e, i, o, s, c, d, _, b, k, j) {
- throw _WarnImport("Engine.RawTexture")
- }
- ,
- a.prototype.createRawTexture2DArray = function(e, i, o, s, c, d, _, b, k, j) {
- throw _WarnImport("Engine.RawTexture")
- }
- ,
- a.prototype._unpackFlipY = function(e) {
- this._unpackFlipYCached !== e && (this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, e ? 1 : 0),
- this.enableUnpackFlipYCached && (this._unpackFlipYCached = e))
- }
- ,
- a.prototype._getUnpackAlignement = function() {
- return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT)
- }
- ,
- a.prototype._getTextureTarget = function(e) {
- 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
- }
- ,
- a.prototype.updateTextureSamplingMode = function(e, i, o) {
- o === void 0 && (o = !1);
- var s = this._getTextureTarget(i)
- , c = this._getSamplingParameters(e, i.generateMipMaps || o);
- this._setTextureParameterInteger(s, this._gl.TEXTURE_MAG_FILTER, c.mag, i),
- this._setTextureParameterInteger(s, this._gl.TEXTURE_MIN_FILTER, c.min),
- o && (i.generateMipMaps = !0,
- this._gl.generateMipmap(s)),
- this._bindTextureDirectly(s, null),
- i.samplingMode = e
- }
- ,
- a.prototype.updateTextureDimensions = function(e, i, o, s) {}
- ,
- a.prototype.updateTextureWrappingMode = function(e, i, o, s) {
- o === void 0 && (o = null),
- s === void 0 && (s = null);
- var c = this._getTextureTarget(e);
- i !== null && (this._setTextureParameterInteger(c, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(i), e),
- e._cachedWrapU = i),
- o !== null && (this._setTextureParameterInteger(c, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(o), e),
- e._cachedWrapV = o),
- (e.is2DArray || e.is3D) && s !== null && (this._setTextureParameterInteger(c, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(s), e),
- e._cachedWrapR = s),
- this._bindTextureDirectly(c, null)
- }
- ,
- a.prototype._setupDepthStencilTexture = function(e, i, o, s, c, d) {
- d === void 0 && (d = 1);
- var _ = i.width || i
- , b = i.height || i
- , k = i.layers || 0;
- e.baseWidth = _,
- e.baseHeight = b,
- e.width = _,
- e.height = b,
- e.is2DArray = k > 0,
- e.depth = k,
- e.isReady = !0,
- e.samples = d,
- e.generateMipMaps = !1,
- e.samplingMode = s ? 2 : 1,
- e.type = 0,
- e._comparisonFunction = c;
- var j = this._gl
- , $ = this._getTextureTarget(e)
- , _e = this._getSamplingParameters(e.samplingMode, !1);
- j.texParameteri($, j.TEXTURE_MAG_FILTER, _e.mag),
- j.texParameteri($, j.TEXTURE_MIN_FILTER, _e.min),
- j.texParameteri($, j.TEXTURE_WRAP_S, j.CLAMP_TO_EDGE),
- j.texParameteri($, j.TEXTURE_WRAP_T, j.CLAMP_TO_EDGE),
- c === 0 ? (j.texParameteri($, j.TEXTURE_COMPARE_FUNC, 515),
- j.texParameteri($, j.TEXTURE_COMPARE_MODE, j.NONE)) : (j.texParameteri($, j.TEXTURE_COMPARE_FUNC, c),
- j.texParameteri($, j.TEXTURE_COMPARE_MODE, j.COMPARE_REF_TO_TEXTURE))
- }
- ,
- a.prototype._uploadCompressedDataToTextureDirectly = function(e, i, o, s, c, d, _) {
- d === void 0 && (d = 0),
- _ === void 0 && (_ = 0);
- var b = this._gl
- , k = b.TEXTURE_2D;
- if (e.isCube && (k = b.TEXTURE_CUBE_MAP_POSITIVE_X + d),
- e._useSRGBBuffer)
- switch (i) {
- case 36492:
- i = b.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT;
- break;
- case 37808:
- i = b.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;
- break;
- case 33776:
- this._caps.s3tc_srgb ? i = b.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT : e._useSRGBBuffer = !1;
- break;
- case 33779:
- this._caps.s3tc_srgb ? i = b.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT : e._useSRGBBuffer = !1;
- break;
- default:
- e._useSRGBBuffer = !1;
- break
- }
- this._gl.compressedTexImage2D(k, _, i, o, s, 0, c)
- }
- ,
- a.prototype._uploadDataToTextureDirectly = function(e, i, o, s, c, d) {
- o === void 0 && (o = 0),
- s === void 0 && (s = 0),
- d === void 0 && (d = !1);
- var _ = this._gl
- , b = this._getWebGLTextureType(e.type)
- , k = this._getInternalFormat(e.format)
- , j = c === void 0 ? this._getRGBABufferInternalSizedFormat(e.type, e.format, e._useSRGBBuffer) : this._getInternalFormat(c, e._useSRGBBuffer);
- this._unpackFlipY(e.invertY);
- var $ = _.TEXTURE_2D;
- e.isCube && ($ = _.TEXTURE_CUBE_MAP_POSITIVE_X + o);
- var _e = Math.round(Math.log(e.width) * Math.LOG2E)
- , et = Math.round(Math.log(e.height) * Math.LOG2E)
- , tt = d ? e.width : Math.pow(2, Math.max(_e - s, 0))
- , rt = d ? e.height : Math.pow(2, Math.max(et - s, 0));
- _.texImage2D($, s, j, tt, rt, 0, k, b, i)
- }
- ,
- a.prototype.updateTextureData = function(e, i, o, s, c, d, _, b) {
- _ === void 0 && (_ = 0),
- b === void 0 && (b = 0);
- var k = this._gl
- , j = this._getWebGLTextureType(e.type)
- , $ = this._getInternalFormat(e.format);
- this._unpackFlipY(e.invertY);
- var _e = k.TEXTURE_2D;
- e.isCube && (_e = k.TEXTURE_CUBE_MAP_POSITIVE_X + _),
- k.texSubImage2D(_e, b, o, s, c, d, $, j, i)
- }
- ,
- a.prototype._uploadArrayBufferViewToTexture = function(e, i, o, s) {
- o === void 0 && (o = 0),
- s === void 0 && (s = 0);
- var c = this._gl
- , d = e.isCube ? c.TEXTURE_CUBE_MAP : c.TEXTURE_2D;
- this._bindTextureDirectly(d, e, !0),
- this._uploadDataToTextureDirectly(e, i, o, s),
- this._bindTextureDirectly(d, null, !0)
- }
- ,
- a.prototype._prepareWebGLTextureContinuation = function(e, i, o, s, c) {
- var d = this._gl;
- if (!!d) {
- var _ = this._getSamplingParameters(c, !o);
- d.texParameteri(d.TEXTURE_2D, d.TEXTURE_MAG_FILTER, _.mag),
- d.texParameteri(d.TEXTURE_2D, d.TEXTURE_MIN_FILTER, _.min),
- !o && !s && d.generateMipmap(d.TEXTURE_2D),
- this._bindTextureDirectly(d.TEXTURE_2D, null),
- i && i._removePendingData(e),
- e.onLoadedObservable.notifyObservers(e),
- e.onLoadedObservable.clear()
- }
- }
- ,
- a.prototype._prepareWebGLTexture = function(e, i, o, s, c, d, _, b, k) {
- var j = this;
- k === void 0 && (k = 3);
- var $ = this.getCaps().maxTextureSize
- , _e = Math.min($, this.needPOTTextures ? a.GetExponentOfTwo(s.width, $) : s.width)
- , et = Math.min($, this.needPOTTextures ? a.GetExponentOfTwo(s.height, $) : s.height)
- , tt = this._gl;
- if (!!tt) {
- if (!e._hardwareTexture) {
- o && o._removePendingData(e);
- return
- }
- this._bindTextureDirectly(tt.TEXTURE_2D, e, !0),
- this._unpackFlipY(c === void 0 ? !0 : !!c),
- e.baseWidth = s.width,
- e.baseHeight = s.height,
- e.width = _e,
- e.height = et,
- e.isReady = !0,
- !b(_e, et, s, i, e, function() {
- j._prepareWebGLTextureContinuation(e, o, d, _, k)
- }) && this._prepareWebGLTextureContinuation(e, o, d, _, k)
- }
- }
- ,
- a.prototype._setupFramebufferDepthAttachments = function(e, i, o, s, c) {
- c === void 0 && (c = 1);
- var d = this._gl;
- if (e && i)
- return this._createRenderBuffer(o, s, c, d.DEPTH_STENCIL, d.DEPTH24_STENCIL8, d.DEPTH_STENCIL_ATTACHMENT);
- if (i) {
- var _ = d.DEPTH_COMPONENT16;
- return this._webGLVersion > 1 && (_ = d.DEPTH_COMPONENT32F),
- this._createRenderBuffer(o, s, c, _, _, d.DEPTH_ATTACHMENT)
- }
- return e ? this._createRenderBuffer(o, s, c, d.STENCIL_INDEX8, d.STENCIL_INDEX8, d.STENCIL_ATTACHMENT) : null
- }
- ,
- a.prototype._createRenderBuffer = function(e, i, o, s, c, d, _) {
- _ === void 0 && (_ = !0);
- var b = this._gl
- , k = b.createRenderbuffer();
- return b.bindRenderbuffer(b.RENDERBUFFER, k),
- o > 1 && b.renderbufferStorageMultisample ? b.renderbufferStorageMultisample(b.RENDERBUFFER, o, c, e, i) : b.renderbufferStorage(b.RENDERBUFFER, s, e, i),
- b.framebufferRenderbuffer(b.FRAMEBUFFER, d, b.RENDERBUFFER, k),
- _ && b.bindRenderbuffer(b.RENDERBUFFER, null),
- k
- }
- ,
- a.prototype._releaseTexture = function(e) {
- var i;
- this._deleteTexture((i = e._hardwareTexture) === null || i === void 0 ? void 0 : i.underlyingResource),
- this.unbindAllTextures();
- var o = this._internalTexturesCache.indexOf(e);
- o !== -1 && this._internalTexturesCache.splice(o, 1),
- e._lodTextureHigh && e._lodTextureHigh.dispose(),
- e._lodTextureMid && e._lodTextureMid.dispose(),
- e._lodTextureLow && e._lodTextureLow.dispose(),
- e._irradianceTexture && e._irradianceTexture.dispose()
- }
- ,
- a.prototype._releaseRenderTargetWrapper = function(e) {
- var i = this._renderTargetWrapperCache.indexOf(e);
- i !== -1 && this._renderTargetWrapperCache.splice(i, 1)
- }
- ,
- a.prototype._deleteTexture = function(e) {
- e && this._gl.deleteTexture(e)
- }
- ,
- a.prototype._setProgram = function(e) {
- this._currentProgram !== e && (this._gl.useProgram(e),
- this._currentProgram = e)
- }
- ,
- a.prototype.bindSamplers = function(e) {
- var i = e.getPipelineContext();
- this._setProgram(i.program);
- for (var o = e.getSamplers(), s = 0; s < o.length; s++) {
- var c = e.getUniform(o[s]);
- c && (this._boundUniforms[s] = c)
- }
- this._currentEffect = null
- }
- ,
- a.prototype._activateCurrentTexture = function() {
- this._currentTextureChannel !== this._activeChannel && (this._gl.activeTexture(this._gl.TEXTURE0 + this._activeChannel),
- this._currentTextureChannel = this._activeChannel)
- }
- ,
- a.prototype._bindTextureDirectly = function(e, i, o, s) {
- var c, d;
- o === void 0 && (o = !1),
- s === void 0 && (s = !1);
- var _ = !1
- , b = i && i._associatedChannel > -1;
- o && b && (this._activeChannel = i._associatedChannel);
- var k = this._boundTexturesCache[this._activeChannel];
- if (k !== i || s) {
- if (this._activateCurrentTexture(),
- i && i.isMultiview)
- throw console.error(e, i),
- "_bindTextureDirectly called with a multiview texture!";
- 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),
- this._boundTexturesCache[this._activeChannel] = i,
- i && (i._associatedChannel = this._activeChannel)
- } else
- o && (_ = !0,
- this._activateCurrentTexture());
- return b && !o && this._bindSamplerUniformToChannel(i._associatedChannel, this._activeChannel),
- _
- }
- ,
- a.prototype._bindTexture = function(e, i, o) {
- if (e !== void 0) {
- i && (i._associatedChannel = e),
- this._activeChannel = e;
- var s = i ? this._getTextureTarget(i) : this._gl.TEXTURE_2D;
- this._bindTextureDirectly(s, i)
- }
- }
- ,
- a.prototype.unbindAllTextures = function() {
- for (var e = 0; e < this._maxSimultaneousTextures; e++)
- this._activeChannel = e,
- this._bindTextureDirectly(this._gl.TEXTURE_2D, null),
- this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null),
- this.webGLVersion > 1 && (this._bindTextureDirectly(this._gl.TEXTURE_3D, null),
- this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY, null))
- }
- ,
- a.prototype.setTexture = function(e, i, o, s) {
- e !== void 0 && (i && (this._boundUniforms[e] = i),
- this._setTexture(e, o))
- }
- ,
- a.prototype._bindSamplerUniformToChannel = function(e, i) {
- var o = this._boundUniforms[e];
- !o || o._currentState === i || (this._gl.uniform1i(o, i),
- o._currentState = i)
- }
- ,
- a.prototype._getTextureWrapMode = function(e) {
- switch (e) {
- case 1:
- return this._gl.REPEAT;
- case 0:
- return this._gl.CLAMP_TO_EDGE;
- case 2:
- return this._gl.MIRRORED_REPEAT
- }
- return this._gl.REPEAT
- }
- ,
- a.prototype._setTexture = function(e, i, o, s, c) {
- if (o === void 0 && (o = !1),
- s === void 0 && (s = !1),
- !i)
- return this._boundTexturesCache[e] != null && (this._activeChannel = e,
- this._bindTextureDirectly(this._gl.TEXTURE_2D, null),
- this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null),
- this.webGLVersion > 1 && (this._bindTextureDirectly(this._gl.TEXTURE_3D, null),
- this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY, null))),
- !1;
- if (i.video)
- this._activeChannel = e,
- i.update();
- else if (i.delayLoadState === 4)
- return i.delayLoad(),
- !1;
- var d;
- 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,
- !o && d && (d._associatedChannel = e);
- var _ = !0;
- this._boundTexturesCache[e] === d && (o || this._bindSamplerUniformToChannel(d._associatedChannel, e),
- _ = !1),
- this._activeChannel = e;
- var b = this._getTextureTarget(d);
- if (_ && this._bindTextureDirectly(b, d, o),
- d && !d.isMultiview) {
- if (d.isCube && d._cachedCoordinatesMode !== i.coordinatesMode) {
- d._cachedCoordinatesMode = i.coordinatesMode;
- var k = i.coordinatesMode !== 3 && i.coordinatesMode !== 5 ? 1 : 0;
- i.wrapU = k,
- i.wrapV = k
- }
- d._cachedWrapU !== i.wrapU && (d._cachedWrapU = i.wrapU,
- this._setTextureParameterInteger(b, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(i.wrapU), d)),
- d._cachedWrapV !== i.wrapV && (d._cachedWrapV = i.wrapV,
- this._setTextureParameterInteger(b, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(i.wrapV), d)),
- d.is3D && d._cachedWrapR !== i.wrapR && (d._cachedWrapR = i.wrapR,
- this._setTextureParameterInteger(b, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(i.wrapR), d)),
- this._setAnisotropicLevel(b, d, i.anisotropicFilteringLevel)
- }
- return !0
- }
- ,
- a.prototype.setTextureArray = function(e, i, o, s) {
- if (!(e === void 0 || !i)) {
- (!this._textureUnits || this._textureUnits.length !== o.length) && (this._textureUnits = new Int32Array(o.length));
- for (var c = 0; c < o.length; c++) {
- var d = o[c].getInternalTexture();
- d ? (this._textureUnits[c] = e + c,
- d._associatedChannel = e + c) : this._textureUnits[c] = -1
- }
- this._gl.uniform1iv(i, this._textureUnits);
- for (var _ = 0; _ < o.length; _++)
- this._setTexture(this._textureUnits[_], o[_], !0)
- }
- }
- ,
- a.prototype._setAnisotropicLevel = function(e, i, o) {
- var s = this._caps.textureAnisotropicFilterExtension;
- i.samplingMode !== 11 && i.samplingMode !== 3 && i.samplingMode !== 2 && (o = 1),
- s && i._cachedAnisotropicFilteringLevel !== o && (this._setTextureParameterFloat(e, s.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(o, this._caps.maxAnisotropy), i),
- i._cachedAnisotropicFilteringLevel = o)
- }
- ,
- a.prototype._setTextureParameterFloat = function(e, i, o, s) {
- this._bindTextureDirectly(e, s, !0, !0),
- this._gl.texParameterf(e, i, o)
- }
- ,
- a.prototype._setTextureParameterInteger = function(e, i, o, s) {
- s && this._bindTextureDirectly(e, s, !0, !0),
- this._gl.texParameteri(e, i, o)
- }
- ,
- a.prototype.unbindAllAttributes = function() {
- if (this._mustWipeVertexAttributes) {
- this._mustWipeVertexAttributes = !1;
- for (var e = 0; e < this._caps.maxVertexAttribs; e++)
- this.disableAttributeByIndex(e);
- return
- }
- for (var e = 0, i = this._vertexAttribArraysEnabled.length; e < i; e++)
- e >= this._caps.maxVertexAttribs || !this._vertexAttribArraysEnabled[e] || this.disableAttributeByIndex(e)
- }
- ,
- a.prototype.releaseEffects = function() {
- for (var e in this._compiledEffects) {
- var i = this._compiledEffects[e].getPipelineContext();
- this._deletePipelineContext(i)
- }
- this._compiledEffects = {}
- }
- ,
- a.prototype.dispose = function() {
- var e;
- this.stopRenderLoop(),
- this.onBeforeTextureInitObservable && this.onBeforeTextureInitObservable.clear(),
- this._emptyTexture && (this._releaseTexture(this._emptyTexture),
- this._emptyTexture = null),
- this._emptyCubeTexture && (this._releaseTexture(this._emptyCubeTexture),
- this._emptyCubeTexture = null),
- this._dummyFramebuffer && this._gl.deleteFramebuffer(this._dummyFramebuffer),
- this.releaseEffects(),
- (e = this.releaseComputeEffects) === null || e === void 0 || e.call(this),
- this.unbindAllAttributes(),
- this._boundUniforms = [],
- IsWindowObjectExist() && this._renderingCanvas && (this._doNotHandleContextLost || (this._renderingCanvas.removeEventListener("webglcontextlost", this._onContextLost),
- this._renderingCanvas.removeEventListener("webglcontextrestored", this._onContextRestored)),
- window.removeEventListener("resize", this._checkForMobile)),
- this._workingCanvas = null,
- this._workingContext = null,
- this._currentBufferPointers = [],
- this._renderingCanvas = null,
- this._currentProgram = null,
- this._boundRenderFunction = null,
- Effect.ResetCache();
- for (var i = 0, o = this._activeRequests; i < o.length; i++) {
- var s = o[i];
- s.abort()
- }
- this.onDisposeObservable.notifyObservers(this),
- this.onDisposeObservable.clear()
- }
- ,
- a.prototype.attachContextLostEvent = function(e) {
- this._renderingCanvas && this._renderingCanvas.addEventListener("webglcontextlost", e, !1)
- }
- ,
- a.prototype.attachContextRestoredEvent = function(e) {
- this._renderingCanvas && this._renderingCanvas.addEventListener("webglcontextrestored", e, !1)
- }
- ,
- a.prototype.getError = function() {
- return this._gl.getError()
- }
- ,
- a.prototype._canRenderToFloatFramebuffer = function() {
- return this._webGLVersion > 1 ? this._caps.colorBufferFloat : this._canRenderToFramebuffer(1)
- }
- ,
- a.prototype._canRenderToHalfFloatFramebuffer = function() {
- return this._webGLVersion > 1 ? this._caps.colorBufferFloat : this._canRenderToFramebuffer(2)
- }
- ,
- a.prototype._canRenderToFramebuffer = function(e) {
- for (var i = this._gl; i.getError() !== i.NO_ERROR; )
- ;
- var o = !0
- , s = i.createTexture();
- i.bindTexture(i.TEXTURE_2D, s),
- i.texImage2D(i.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(e), 1, 1, 0, i.RGBA, this._getWebGLTextureType(e), null),
- i.texParameteri(i.TEXTURE_2D, i.TEXTURE_MIN_FILTER, i.NEAREST),
- i.texParameteri(i.TEXTURE_2D, i.TEXTURE_MAG_FILTER, i.NEAREST);
- var c = i.createFramebuffer();
- i.bindFramebuffer(i.FRAMEBUFFER, c),
- i.framebufferTexture2D(i.FRAMEBUFFER, i.COLOR_ATTACHMENT0, i.TEXTURE_2D, s, 0);
- var d = i.checkFramebufferStatus(i.FRAMEBUFFER);
- if (o = o && d === i.FRAMEBUFFER_COMPLETE,
- o = o && i.getError() === i.NO_ERROR,
- o && (i.clear(i.COLOR_BUFFER_BIT),
- o = o && i.getError() === i.NO_ERROR),
- o) {
- i.bindFramebuffer(i.FRAMEBUFFER, null);
- var _ = i.RGBA
- , b = i.UNSIGNED_BYTE
- , k = new Uint8Array(4);
- i.readPixels(0, 0, 1, 1, _, b, k),
- o = o && i.getError() === i.NO_ERROR
- }
- for (i.deleteTexture(s),
- i.deleteFramebuffer(c),
- i.bindFramebuffer(i.FRAMEBUFFER, null); !o && i.getError() !== i.NO_ERROR; )
- ;
- return o
- }
- ,
- a.prototype._getWebGLTextureType = function(e) {
- if (this._webGLVersion === 1) {
- switch (e) {
- case 1:
- return this._gl.FLOAT;
- case 2:
- return this._gl.HALF_FLOAT_OES;
- case 0:
- return this._gl.UNSIGNED_BYTE;
- case 8:
- return this._gl.UNSIGNED_SHORT_4_4_4_4;
- case 9:
- return this._gl.UNSIGNED_SHORT_5_5_5_1;
- case 10:
- return this._gl.UNSIGNED_SHORT_5_6_5
- }
- return this._gl.UNSIGNED_BYTE
- }
- switch (e) {
- case 3:
- return this._gl.BYTE;
- case 0:
- return this._gl.UNSIGNED_BYTE;
- case 4:
- return this._gl.SHORT;
- case 5:
- return this._gl.UNSIGNED_SHORT;
- case 6:
- return this._gl.INT;
- case 7:
- return this._gl.UNSIGNED_INT;
- case 1:
- return this._gl.FLOAT;
- case 2:
- return this._gl.HALF_FLOAT;
- case 8:
- return this._gl.UNSIGNED_SHORT_4_4_4_4;
- case 9:
- return this._gl.UNSIGNED_SHORT_5_5_5_1;
- case 10:
- return this._gl.UNSIGNED_SHORT_5_6_5;
- case 11:
- return this._gl.UNSIGNED_INT_2_10_10_10_REV;
- case 12:
- return this._gl.UNSIGNED_INT_24_8;
- case 13:
- return this._gl.UNSIGNED_INT_10F_11F_11F_REV;
- case 14:
- return this._gl.UNSIGNED_INT_5_9_9_9_REV;
- case 15:
- return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV
- }
- return this._gl.UNSIGNED_BYTE
- }
- ,
- a.prototype._getInternalFormat = function(e, i) {
- i === void 0 && (i = !1);
- var o = i ? this._gl.SRGB8_ALPHA8 : this._gl.RGBA;
- switch (e) {
- case 0:
- o = this._gl.ALPHA;
- break;
- case 1:
- o = this._gl.LUMINANCE;
- break;
- case 2:
- o = this._gl.LUMINANCE_ALPHA;
- break;
- case 6:
- o = this._gl.RED;
- break;
- case 7:
- o = this._gl.RG;
- break;
- case 4:
- o = i ? this._gl.SRGB : this._gl.RGB;
- break;
- case 5:
- o = i ? this._gl.SRGB8_ALPHA8 : this._gl.RGBA;
- break
- }
- if (this._webGLVersion > 1)
- switch (e) {
- case 8:
- o = this._gl.RED_INTEGER;
- break;
- case 9:
- o = this._gl.RG_INTEGER;
- break;
- case 10:
- o = this._gl.RGB_INTEGER;
- break;
- case 11:
- o = this._gl.RGBA_INTEGER;
- break
- }
- return o
- }
- ,
- a.prototype._getRGBABufferInternalSizedFormat = function(e, i, o) {
- if (o === void 0 && (o = !1),
- this._webGLVersion === 1) {
- if (i !== void 0)
- switch (i) {
- case 0:
- return this._gl.ALPHA;
- case 1:
- return this._gl.LUMINANCE;
- case 2:
- return this._gl.LUMINANCE_ALPHA;
- case 4:
- return o ? this._gl.SRGB : this._gl.RGB
- }
- return this._gl.RGBA
- }
- switch (e) {
- case 3:
- switch (i) {
- case 6:
- return this._gl.R8_SNORM;
- case 7:
- return this._gl.RG8_SNORM;
- case 4:
- return this._gl.RGB8_SNORM;
- case 8:
- return this._gl.R8I;
- case 9:
- return this._gl.RG8I;
- case 10:
- return this._gl.RGB8I;
- case 11:
- return this._gl.RGBA8I;
- default:
- return this._gl.RGBA8_SNORM
- }
- case 0:
- switch (i) {
- case 6:
- return this._gl.R8;
- case 7:
- return this._gl.RG8;
- case 4:
- return o ? this._gl.SRGB8 : this._gl.RGB8;
- case 5:
- return o ? this._gl.SRGB8_ALPHA8 : this._gl.RGBA8;
- case 8:
- return this._gl.R8UI;
- case 9:
- return this._gl.RG8UI;
- case 10:
- return this._gl.RGB8UI;
- case 11:
- return this._gl.RGBA8UI;
- case 0:
- return this._gl.ALPHA;
- case 1:
- return this._gl.LUMINANCE;
- case 2:
- return this._gl.LUMINANCE_ALPHA;
- default:
- return this._gl.RGBA8
- }
- case 4:
- switch (i) {
- case 8:
- return this._gl.R16I;
- case 9:
- return this._gl.RG16I;
- case 10:
- return this._gl.RGB16I;
- case 11:
- return this._gl.RGBA16I;
- default:
- return this._gl.RGBA16I
- }
- case 5:
- switch (i) {
- case 8:
- return this._gl.R16UI;
- case 9:
- return this._gl.RG16UI;
- case 10:
- return this._gl.RGB16UI;
- case 11:
- return this._gl.RGBA16UI;
- default:
- return this._gl.RGBA16UI
- }
- case 6:
- switch (i) {
- case 8:
- return this._gl.R32I;
- case 9:
- return this._gl.RG32I;
- case 10:
- return this._gl.RGB32I;
- case 11:
- return this._gl.RGBA32I;
- default:
- return this._gl.RGBA32I
- }
- case 7:
- switch (i) {
- case 8:
- return this._gl.R32UI;
- case 9:
- return this._gl.RG32UI;
- case 10:
- return this._gl.RGB32UI;
- case 11:
- return this._gl.RGBA32UI;
- default:
- return this._gl.RGBA32UI
- }
- case 1:
- switch (i) {
- case 6:
- return this._gl.R32F;
- case 7:
- return this._gl.RG32F;
- case 4:
- return this._gl.RGB32F;
- case 5:
- return this._gl.RGBA32F;
- default:
- return this._gl.RGBA32F
- }
- case 2:
- switch (i) {
- case 6:
- return this._gl.R16F;
- case 7:
- return this._gl.RG16F;
- case 4:
- return this._gl.RGB16F;
- case 5:
- return this._gl.RGBA16F;
- default:
- return this._gl.RGBA16F
- }
- case 10:
- return this._gl.RGB565;
- case 13:
- return this._gl.R11F_G11F_B10F;
- case 14:
- return this._gl.RGB9_E5;
- case 8:
- return this._gl.RGBA4;
- case 9:
- return this._gl.RGB5_A1;
- case 11:
- switch (i) {
- case 5:
- return this._gl.RGB10_A2;
- case 11:
- return this._gl.RGB10_A2UI;
- default:
- return this._gl.RGB10_A2
- }
- }
- return o ? this._gl.SRGB8_ALPHA8 : this._gl.RGBA8
- }
- ,
- a.prototype._getRGBAMultiSampleBufferFormat = function(e) {
- return e === 1 ? this._gl.RGBA32F : e === 2 ? this._gl.RGBA16F : this._gl.RGBA8
- }
- ,
- a.prototype._loadFile = function(e, i, o, s, c, d) {
- var _ = this
- , b = a._FileToolsLoadFile(e, i, o, s, c, d);
- return this._activeRequests.push(b),
- b.onCompleteObservable.add(function(k) {
- _._activeRequests.splice(_._activeRequests.indexOf(k), 1)
- }),
- b
- }
- ,
- a._FileToolsLoadFile = function(e, i, o, s, c, d) {
- throw _WarnImport("FileTools")
- }
- ,
- a.prototype.readPixels = function(e, i, o, s, c, d) {
- c === void 0 && (c = !0),
- d === void 0 && (d = !0);
- var _ = c ? 4 : 3
- , b = c ? this._gl.RGBA : this._gl.RGB
- , k = new Uint8Array(s * o * _);
- return d && this.flushFramebuffer(),
- this._gl.readPixels(e, i, o, s, b, this._gl.UNSIGNED_BYTE, k),
- Promise.resolve(k)
- }
- ,
- Object.defineProperty(a, "IsSupportedAsync", {
- get: function() {
- return Promise.resolve(this.isSupported())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "IsSupported", {
- get: function() {
- return this.isSupported()
- },
- enumerable: !1,
- configurable: !0
- }),
- a.isSupported = function() {
- if (this._HasMajorPerformanceCaveat !== null)
- return !this._HasMajorPerformanceCaveat;
- if (this._IsSupported === null)
- try {
- var e = this._createCanvas(1, 1)
- , i = e.getContext("webgl") || e.getContext("experimental-webgl");
- this._IsSupported = i != null && !!window.WebGLRenderingContext
- } catch {
- this._IsSupported = !1
- }
- return this._IsSupported
- }
- ,
- Object.defineProperty(a, "HasMajorPerformanceCaveat", {
- get: function() {
- if (this._HasMajorPerformanceCaveat === null)
- try {
- var e = this._createCanvas(1, 1)
- , i = e.getContext("webgl", {
- failIfMajorPerformanceCaveat: !0
- }) || e.getContext("experimental-webgl", {
- failIfMajorPerformanceCaveat: !0
- });
- this._HasMajorPerformanceCaveat = !i
- } catch {
- this._HasMajorPerformanceCaveat = !1
- }
- return this._HasMajorPerformanceCaveat
- },
- enumerable: !1,
- configurable: !0
- }),
- a.CeilingPOT = function(e) {
- return e--,
- e |= e >> 1,
- e |= e >> 2,
- e |= e >> 4,
- e |= e >> 8,
- e |= e >> 16,
- e++,
- e
- }
- ,
- a.FloorPOT = function(e) {
- return e = e | e >> 1,
- e = e | e >> 2,
- e = e | e >> 4,
- e = e | e >> 8,
- e = e | e >> 16,
- e - (e >> 1)
- }
- ,
- a.NearestPOT = function(e) {
- var i = a.CeilingPOT(e)
- , o = a.FloorPOT(e);
- return i - e > e - o ? o : i
- }
- ,
- a.GetExponentOfTwo = function(e, i, o) {
- o === void 0 && (o = 2);
- var s;
- switch (o) {
- case 1:
- s = a.FloorPOT(e);
- break;
- case 2:
- s = a.NearestPOT(e);
- break;
- case 3:
- default:
- s = a.CeilingPOT(e);
- break
- }
- return Math.min(s, i)
- }
- ,
- a.QueueNewFrame = function(e, i) {
- return IsWindowObjectExist() ? (i || (i = window),
- 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)
- }
- ,
- a.prototype.getHostDocument = function() {
- return this._renderingCanvas && this._renderingCanvas.ownerDocument ? this._renderingCanvas.ownerDocument : document
- }
- ,
- a.ExceptionList = [{
- key: "Chrome/63.0",
- capture: "63\\.0\\.3239\\.(\\d+)",
- captureConstraint: 108,
- targets: ["uniformBuffer"]
- }, {
- key: "Firefox/58",
- capture: null,
- captureConstraint: null,
- targets: ["uniformBuffer"]
- }, {
- key: "Firefox/59",
- capture: null,
- captureConstraint: null,
- targets: ["uniformBuffer"]
- }, {
- key: "Chrome/72.+?Mobile",
- capture: null,
- captureConstraint: null,
- targets: ["vao"]
- }, {
- key: "Chrome/73.+?Mobile",
- capture: null,
- captureConstraint: null,
- targets: ["vao"]
- }, {
- key: "Chrome/74.+?Mobile",
- capture: null,
- captureConstraint: null,
- targets: ["vao"]
- }, {
- key: "Mac OS.+Chrome/71",
- capture: null,
- captureConstraint: null,
- targets: ["vao"]
- }, {
- key: "Mac OS.+Chrome/72",
- capture: null,
- captureConstraint: null,
- targets: ["vao"]
- }],
- a._TextureLoaders = [],
- a.CollisionsEpsilon = .001,
- a._IsSupported = null,
- a._HasMajorPerformanceCaveat = null,
- a
- }()
- , PrecisionDate = function() {
- function a() {}
- return Object.defineProperty(a, "Now", {
- get: function() {
- return DomManagement.IsWindowObjectExist() && window.performance && window.performance.now ? window.performance.now() : Date.now()
- },
- enumerable: !1,
- configurable: !0
- }),
- a
- }()
- , PerformanceMonitor = function() {
- function a(e) {
- e === void 0 && (e = 30),
- this._enabled = !0,
- this._rollingFrameTime = new RollingAverage(e)
- }
- return a.prototype.sampleFrame = function(e) {
- if (e === void 0 && (e = PrecisionDate.Now),
- !!this._enabled) {
- if (this._lastFrameTimeMs != null) {
- var i = e - this._lastFrameTimeMs;
- this._rollingFrameTime.add(i)
- }
- this._lastFrameTimeMs = e
- }
- }
- ,
- Object.defineProperty(a.prototype, "averageFrameTime", {
- get: function() {
- return this._rollingFrameTime.average
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "averageFrameTimeVariance", {
- get: function() {
- return this._rollingFrameTime.variance
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "instantaneousFrameTime", {
- get: function() {
- return this._rollingFrameTime.history(0)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "averageFPS", {
- get: function() {
- return 1e3 / this._rollingFrameTime.average
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "instantaneousFPS", {
- get: function() {
- var e = this._rollingFrameTime.history(0);
- return e === 0 ? 0 : 1e3 / e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "isSaturated", {
- get: function() {
- return this._rollingFrameTime.isSaturated()
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.enable = function() {
- this._enabled = !0
- }
- ,
- a.prototype.disable = function() {
- this._enabled = !1,
- this._lastFrameTimeMs = null
- }
- ,
- Object.defineProperty(a.prototype, "isEnabled", {
- get: function() {
- return this._enabled
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.reset = function() {
- this._lastFrameTimeMs = null,
- this._rollingFrameTime.reset()
- }
- ,
- a
- }()
- , RollingAverage = function() {
- function a(e) {
- this._samples = new Array(e),
- this.reset()
- }
- return a.prototype.add = function(e) {
- var i;
- if (this.isSaturated()) {
- var o = this._samples[this._pos];
- i = o - this.average,
- this.average -= i / (this._sampleCount - 1),
- this._m2 -= i * (o - this.average)
- } else
- this._sampleCount++;
- i = e - this.average,
- this.average += i / this._sampleCount,
- this._m2 += i * (e - this.average),
- this.variance = this._m2 / (this._sampleCount - 1),
- this._samples[this._pos] = e,
- this._pos++,
- this._pos %= this._samples.length
- }
- ,
- a.prototype.history = function(e) {
- if (e >= this._sampleCount || e >= this._samples.length)
- return 0;
- var i = this._wrapPosition(this._pos - 1);
- return this._samples[this._wrapPosition(i - e)]
- }
- ,
- a.prototype.isSaturated = function() {
- return this._sampleCount >= this._samples.length
- }
- ,
- a.prototype.reset = function() {
- this.average = 0,
- this.variance = 0,
- this._sampleCount = 0,
- this._pos = 0,
- this._m2 = 0
- }
- ,
- a.prototype._wrapPosition = function(e) {
- var i = this._samples.length;
- return (e % i + i) % i
- }
- ,
- a
- }()
- , PerfCounter = function() {
- function a() {
- this._startMonitoringTime = 0,
- this._min = 0,
- this._max = 0,
- this._average = 0,
- this._lastSecAverage = 0,
- this._current = 0,
- this._totalValueCount = 0,
- this._totalAccumulated = 0,
- this._lastSecAccumulated = 0,
- this._lastSecTime = 0,
- this._lastSecValueCount = 0
- }
- return Object.defineProperty(a.prototype, "min", {
- get: function() {
- return this._min
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "max", {
- get: function() {
- return this._max
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "average", {
- get: function() {
- return this._average
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "lastSecAverage", {
- get: function() {
- return this._lastSecAverage
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "current", {
- get: function() {
- return this._current
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "total", {
- get: function() {
- return this._totalAccumulated
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "count", {
- get: function() {
- return this._totalValueCount
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.fetchNewFrame = function() {
- this._totalValueCount++,
- this._current = 0,
- this._lastSecValueCount++
- }
- ,
- a.prototype.addCount = function(e, i) {
- !a.Enabled || (this._current += e,
- i && this._fetchResult())
- }
- ,
- a.prototype.beginMonitoring = function() {
- !a.Enabled || (this._startMonitoringTime = PrecisionDate.Now)
- }
- ,
- a.prototype.endMonitoring = function(e) {
- if (e === void 0 && (e = !0),
- !!a.Enabled) {
- e && this.fetchNewFrame();
- var i = PrecisionDate.Now;
- this._current = i - this._startMonitoringTime,
- e && this._fetchResult()
- }
- }
- ,
- a.prototype._fetchResult = function() {
- this._totalAccumulated += this._current,
- this._lastSecAccumulated += this._current,
- this._min = Math.min(this._min, this._current),
- this._max = Math.max(this._max, this._current),
- this._average = this._totalAccumulated / this._totalValueCount;
- var e = PrecisionDate.Now;
- e - this._lastSecTime > 1e3 && (this._lastSecAverage = this._lastSecAccumulated / this._lastSecValueCount,
- this._lastSecTime = e,
- this._lastSecAccumulated = 0,
- this._lastSecValueCount = 0)
- }
- ,
- a.Enabled = !0,
- a
- }();
- ThinEngine.prototype.setAlphaConstants = function(a, e, i, o) {
- this._alphaState.setAlphaBlendConstants(a, e, i, o)
- }
- ;
- ThinEngine.prototype.setAlphaMode = function(a, e) {
- if (e === void 0 && (e = !1),
- this._alphaMode !== a) {
- switch (a) {
- case 0:
- this._alphaState.alphaBlend = !1;
- break;
- case 7:
- this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE),
- this._alphaState.alphaBlend = !0;
- break;
- case 8:
- this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA),
- this._alphaState.alphaBlend = !0;
- break;
- case 2:
- this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE),
- this._alphaState.alphaBlend = !0;
- break;
- case 6:
- this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ZERO, this._gl.ONE),
- this._alphaState.alphaBlend = !0;
- break;
- case 1:
- this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ONE),
- this._alphaState.alphaBlend = !0;
- break;
- case 3:
- this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE),
- this._alphaState.alphaBlend = !0;
- break;
- case 4:
- this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR, this._gl.ZERO, this._gl.ONE, this._gl.ONE),
- this._alphaState.alphaBlend = !0;
- break;
- case 5:
- this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE),
- this._alphaState.alphaBlend = !0;
- break;
- case 9:
- this._alphaState.setAlphaBlendFunctionParameters(this._gl.CONSTANT_COLOR, this._gl.ONE_MINUS_CONSTANT_COLOR, this._gl.CONSTANT_ALPHA, this._gl.ONE_MINUS_CONSTANT_ALPHA),
- this._alphaState.alphaBlend = !0;
- break;
- case 10:
- this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA),
- this._alphaState.alphaBlend = !0;
- break;
- case 11:
- this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ONE, this._gl.ONE),
- this._alphaState.alphaBlend = !0;
- break;
- case 12:
- this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ZERO),
- this._alphaState.alphaBlend = !0;
- break;
- case 13:
- 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),
- this._alphaState.alphaBlend = !0;
- break;
- case 14:
- this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA),
- this._alphaState.alphaBlend = !0;
- break;
- case 15:
- this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ONE, this._gl.ZERO),
- this._alphaState.alphaBlend = !0;
- break;
- case 16:
- this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE_MINUS_DST_COLOR, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ZERO, this._gl.ONE),
- this._alphaState.alphaBlend = !0;
- break;
- case 17:
- this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA),
- this._alphaState.alphaBlend = !0;
- break
- }
- e || (this.depthCullingState.depthMask = a === 0),
- this._alphaMode = a
- }
- }
- ;
- ThinEngine.prototype.getAlphaMode = function() {
- return this._alphaMode
- }
- ;
- ThinEngine.prototype.setAlphaEquation = function(a) {
- if (this._alphaEquation !== a) {
- switch (a) {
- case 0:
- this._alphaState.setAlphaEquationParameters(32774, 32774);
- break;
- case 1:
- this._alphaState.setAlphaEquationParameters(32778, 32778);
- break;
- case 2:
- this._alphaState.setAlphaEquationParameters(32779, 32779);
- break;
- case 3:
- this._alphaState.setAlphaEquationParameters(32776, 32776);
- break;
- case 4:
- this._alphaState.setAlphaEquationParameters(32775, 32775);
- break;
- case 5:
- this._alphaState.setAlphaEquationParameters(32775, 32774);
- break
- }
- this._alphaEquation = a
- }
- }
- ;
- ThinEngine.prototype.getAlphaEquation = function() {
- return this._alphaEquation
- }
- ;
- function allocateAndCopyTypedBuffer(a, e, i, o) {
- switch (i === void 0 && (i = !1),
- a) {
- case 3:
- {
- var s = e instanceof ArrayBuffer ? new Int8Array(e) : new Int8Array(e);
- return o && s.set(new Int8Array(o)),
- s
- }
- case 0:
- {
- var c = e instanceof ArrayBuffer ? new Uint8Array(e) : new Uint8Array(e);
- return o && c.set(new Uint8Array(o)),
- c
- }
- case 4:
- {
- var d = e instanceof ArrayBuffer ? new Int16Array(e) : new Int16Array(i ? e / 2 : e);
- return o && d.set(new Int16Array(o)),
- d
- }
- case 5:
- case 8:
- case 9:
- case 10:
- case 2:
- {
- var _ = e instanceof ArrayBuffer ? new Uint16Array(e) : new Uint16Array(i ? e / 2 : e);
- return o && _.set(new Uint16Array(o)),
- _
- }
- case 6:
- {
- var b = e instanceof ArrayBuffer ? new Int32Array(e) : new Int32Array(i ? e / 4 : e);
- return o && b.set(new Int32Array(o)),
- b
- }
- case 7:
- case 11:
- case 12:
- case 13:
- case 14:
- case 15:
- {
- var k = e instanceof ArrayBuffer ? new Uint32Array(e) : new Uint32Array(i ? e / 4 : e);
- return o && k.set(new Uint32Array(o)),
- k
- }
- case 1:
- {
- var j = e instanceof ArrayBuffer ? new Float32Array(e) : new Float32Array(i ? e / 4 : e);
- return o && j.set(new Float32Array(o)),
- j
- }
- }
- var $ = e instanceof ArrayBuffer ? new Uint8Array(e) : new Uint8Array(e);
- return o && $.set(new Uint8Array(o)),
- $
- }
- ThinEngine.prototype._readTexturePixelsSync = function(a, e, i, o, s, c, d, _) {
- var b, k;
- o === void 0 && (o = -1),
- s === void 0 && (s = 0),
- c === void 0 && (c = null),
- d === void 0 && (d = !0),
- _ === void 0 && (_ = !1);
- var j = this._gl;
- if (!j)
- throw new Error("Engine does not have gl rendering context.");
- if (!this._dummyFramebuffer) {
- var $ = j.createFramebuffer();
- if (!$)
- throw new Error("Unable to create dummy framebuffer");
- this._dummyFramebuffer = $
- }
- j.bindFramebuffer(j.FRAMEBUFFER, this._dummyFramebuffer),
- 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);
- var _e = a.type !== void 0 ? this._getWebGLTextureType(a.type) : j.UNSIGNED_BYTE;
- if (_)
- c || (c = allocateAndCopyTypedBuffer(a.type, 4 * e * i));
- else
- switch (_e) {
- case j.UNSIGNED_BYTE:
- c || (c = new Uint8Array(4 * e * i)),
- _e = j.UNSIGNED_BYTE;
- break;
- default:
- c || (c = new Float32Array(4 * e * i)),
- _e = j.FLOAT;
- break
- }
- return d && this.flushFramebuffer(),
- j.readPixels(0, 0, e, i, j.RGBA, _e, c),
- j.bindFramebuffer(j.FRAMEBUFFER, this._currentFramebuffer),
- c
- }
- ;
- ThinEngine.prototype._readTexturePixels = function(a, e, i, o, s, c, d, _) {
- return o === void 0 && (o = -1),
- s === void 0 && (s = 0),
- c === void 0 && (c = null),
- d === void 0 && (d = !0),
- _ === void 0 && (_ = !1),
- Promise.resolve(this._readTexturePixelsSync(a, e, i, o, s, c, d, _))
- }
- ;
- ThinEngine.prototype.updateDynamicIndexBuffer = function(a, e, i) {
- this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null,
- this.bindIndexBuffer(a);
- var o;
- e instanceof Uint16Array || e instanceof Uint32Array ? o = e : o = a.is32Bits ? new Uint32Array(e) : new Uint16Array(e),
- this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, o, this._gl.DYNAMIC_DRAW),
- this._resetIndexBufferBinding()
- }
- ;
- ThinEngine.prototype.updateDynamicVertexBuffer = function(a, e, i, o) {
- this.bindArrayBuffer(a),
- i === void 0 && (i = 0);
- var s = e.length || e.byteLength;
- 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),
- this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, e)),
- this._resetVertexBufferBinding()
- }
- ;
- var Engine = function(a) {
- __extends(e, a);
- function e(i, o, s, c) {
- c === void 0 && (c = !1);
- var d = a.call(this, i, o, s, c) || this;
- if (d.enableOfflineSupport = !1,
- d.disableManifestCheck = !1,
- d.scenes = new Array,
- d._virtualScenes = new Array,
- d.onNewSceneAddedObservable = new Observable,
- d.postProcesses = new Array,
- d.isPointerLock = !1,
- d.onResizeObservable = new Observable,
- d.onCanvasBlurObservable = new Observable,
- d.onCanvasFocusObservable = new Observable,
- d.onCanvasPointerOutObservable = new Observable,
- d.onBeginFrameObservable = new Observable,
- d.customAnimationFrameRequester = null,
- d.onEndFrameObservable = new Observable,
- d.onBeforeShaderCompilationObservable = new Observable,
- d.onAfterShaderCompilationObservable = new Observable,
- d._deterministicLockstep = !1,
- d._lockstepMaxSteps = 4,
- d._timeStep = 1 / 60,
- d._fps = 60,
- d._deltaTime = 0,
- d._drawCalls = new PerfCounter,
- d.canvasTabIndex = 1,
- d.disablePerformanceMonitorInBackground = !1,
- d._performanceMonitor = new PerformanceMonitor,
- d._compatibilityMode = !0,
- d.currentRenderPassId = 0,
- d._renderPassNames = ["main"],
- e.Instances.push(d),
- !i)
- return d;
- if (d._features.supportRenderPasses = !0,
- s = d._creationOptions,
- i.getContext) {
- var _ = i;
- if (d._sharedInit(_, !!s.doNotHandleTouchAction, s.audioEngine),
- IsWindowObjectExist()) {
- var b = document;
- d._onFullscreenChange = function() {
- 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),
- d.isFullscreen && d._pointerLockRequested && _ && e._RequestPointerlock(_)
- }
- ,
- document.addEventListener("fullscreenchange", d._onFullscreenChange, !1),
- document.addEventListener("mozfullscreenchange", d._onFullscreenChange, !1),
- document.addEventListener("webkitfullscreenchange", d._onFullscreenChange, !1),
- document.addEventListener("msfullscreenchange", d._onFullscreenChange, !1),
- d._onPointerLockChange = function() {
- d.isPointerLock = b.mozPointerLockElement === _ || b.webkitPointerLockElement === _ || b.msPointerLockElement === _ || b.pointerLockElement === _
- }
- ,
- document.addEventListener("pointerlockchange", d._onPointerLockChange, !1),
- document.addEventListener("mspointerlockchange", d._onPointerLockChange, !1),
- document.addEventListener("mozpointerlockchange", d._onPointerLockChange, !1),
- document.addEventListener("webkitpointerlockchange", d._onPointerLockChange, !1),
- !e.audioEngine && s.audioEngine && e.AudioEngineFactory && (e.audioEngine = e.AudioEngineFactory(d.getRenderingCanvas(), d.getAudioContext(), d.getAudioDestination()))
- }
- d._connectVREvents(),
- d.enableOfflineSupport = e.OfflineProviderFactory !== void 0,
- d._deterministicLockstep = !!s.deterministicLockstep,
- d._lockstepMaxSteps = s.lockstepMaxSteps || 0,
- d._timeStep = s.timeStep || 1 / 60
- }
- return d._prepareVRComponent(),
- s.autoEnableWebVR && d.initWebVR(),
- d
- }
- return Object.defineProperty(e, "NpmPackage", {
- get: function() {
- return ThinEngine.NpmPackage
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "Version", {
- get: function() {
- return ThinEngine.Version
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "Instances", {
- get: function() {
- return EngineStore.Instances
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "LastCreatedEngine", {
- get: function() {
- return EngineStore.LastCreatedEngine
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "LastCreatedScene", {
- get: function() {
- return EngineStore.LastCreatedScene
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.createImageBitmap = function(i, o) {
- return createImageBitmap(i, o)
- }
- ,
- e.prototype.resizeImageBitmap = function(i, o, s) {
- var c = this.createCanvas(o, s)
- , d = c.getContext("2d");
- if (!d)
- throw new Error("Unable to get 2d context for resizeImageBitmap");
- d.drawImage(i, 0, 0);
- var _ = d.getImageData(0, 0, o, s).data;
- return _
- }
- ,
- e.MarkAllMaterialsAsDirty = function(i, o) {
- for (var s = 0; s < e.Instances.length; s++)
- for (var c = e.Instances[s], d = 0; d < c.scenes.length; d++)
- c.scenes[d].markAllMaterialsAsDirty(i, o)
- }
- ,
- e.DefaultLoadingScreenFactory = function(i) {
- throw _WarnImport("LoadingScreen")
- }
- ,
- Object.defineProperty(e.prototype, "_supportsHardwareTextureRescaling", {
- get: function() {
- return !!e._RescalePostProcessFactory
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "performanceMonitor", {
- get: function() {
- return this._performanceMonitor
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "compatibilityMode", {
- get: function() {
- return this._compatibilityMode
- },
- set: function(i) {
- this._compatibilityMode = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getInputElement = function() {
- return this._renderingCanvas
- }
- ,
- e.prototype._sharedInit = function(i, o, s) {
- var c = this;
- if (a.prototype._sharedInit.call(this, i, o, s),
- this._onCanvasFocus = function() {
- c.onCanvasFocusObservable.notifyObservers(c)
- }
- ,
- this._onCanvasBlur = function() {
- c.onCanvasBlurObservable.notifyObservers(c)
- }
- ,
- i.addEventListener("focus", this._onCanvasFocus),
- i.addEventListener("blur", this._onCanvasBlur),
- this._onBlur = function() {
- c.disablePerformanceMonitorInBackground && c._performanceMonitor.disable(),
- c._windowIsBackground = !0
- }
- ,
- this._onFocus = function() {
- c.disablePerformanceMonitorInBackground && c._performanceMonitor.enable(),
- c._windowIsBackground = !1
- }
- ,
- this._onCanvasPointerOut = function(_) {
- document.elementFromPoint(_.clientX, _.clientY) !== i && c.onCanvasPointerOutObservable.notifyObservers(_)
- }
- ,
- IsWindowObjectExist()) {
- var d = this.getHostWindow();
- d && (d.addEventListener("blur", this._onBlur),
- d.addEventListener("focus", this._onFocus))
- }
- i.addEventListener("pointerout", this._onCanvasPointerOut),
- o || this._disableTouchAction(),
- !e.audioEngine && s && e.AudioEngineFactory && (e.audioEngine = e.AudioEngineFactory(this.getRenderingCanvas(), this.getAudioContext(), this.getAudioDestination()))
- }
- ,
- e.prototype.getAspectRatio = function(i, o) {
- o === void 0 && (o = !1);
- var s = i.viewport;
- return this.getRenderWidth(o) * s.width / (this.getRenderHeight(o) * s.height)
- }
- ,
- e.prototype.getScreenAspectRatio = function() {
- return this.getRenderWidth(!0) / this.getRenderHeight(!0)
- }
- ,
- e.prototype.getRenderingCanvasClientRect = function() {
- return this._renderingCanvas ? this._renderingCanvas.getBoundingClientRect() : null
- }
- ,
- e.prototype.getInputElementClientRect = function() {
- return this._renderingCanvas ? this.getInputElement().getBoundingClientRect() : null
- }
- ,
- e.prototype.isDeterministicLockStep = function() {
- return this._deterministicLockstep
- }
- ,
- e.prototype.getLockstepMaxSteps = function() {
- return this._lockstepMaxSteps
- }
- ,
- e.prototype.getTimeStep = function() {
- return this._timeStep * 1e3
- }
- ,
- e.prototype.generateMipMapsForCubemap = function(i, o) {
- if (o === void 0 && (o = !0),
- i.generateMipMaps) {
- var s = this._gl;
- this._bindTextureDirectly(s.TEXTURE_CUBE_MAP, i, !0),
- s.generateMipmap(s.TEXTURE_CUBE_MAP),
- o && this._bindTextureDirectly(s.TEXTURE_CUBE_MAP, null)
- }
- }
- ,
- e.prototype.getDepthBuffer = function() {
- return this._depthCullingState.depthTest
- }
- ,
- e.prototype.setDepthBuffer = function(i) {
- this._depthCullingState.depthTest = i
- }
- ,
- e.prototype.getDepthWrite = function() {
- return this._depthCullingState.depthMask
- }
- ,
- e.prototype.setDepthWrite = function(i) {
- this._depthCullingState.depthMask = i
- }
- ,
- e.prototype.getStencilBuffer = function() {
- return this._stencilState.stencilTest
- }
- ,
- e.prototype.setStencilBuffer = function(i) {
- this._stencilState.stencilTest = i
- }
- ,
- e.prototype.getStencilMask = function() {
- return this._stencilState.stencilMask
- }
- ,
- e.prototype.setStencilMask = function(i) {
- this._stencilState.stencilMask = i
- }
- ,
- e.prototype.getStencilFunction = function() {
- return this._stencilState.stencilFunc
- }
- ,
- e.prototype.getStencilFunctionReference = function() {
- return this._stencilState.stencilFuncRef
- }
- ,
- e.prototype.getStencilFunctionMask = function() {
- return this._stencilState.stencilFuncMask
- }
- ,
- e.prototype.setStencilFunction = function(i) {
- this._stencilState.stencilFunc = i
- }
- ,
- e.prototype.setStencilFunctionReference = function(i) {
- this._stencilState.stencilFuncRef = i
- }
- ,
- e.prototype.setStencilFunctionMask = function(i) {
- this._stencilState.stencilFuncMask = i
- }
- ,
- e.prototype.getStencilOperationFail = function() {
- return this._stencilState.stencilOpStencilFail
- }
- ,
- e.prototype.getStencilOperationDepthFail = function() {
- return this._stencilState.stencilOpDepthFail
- }
- ,
- e.prototype.getStencilOperationPass = function() {
- return this._stencilState.stencilOpStencilDepthPass
- }
- ,
- e.prototype.setStencilOperationFail = function(i) {
- this._stencilState.stencilOpStencilFail = i
- }
- ,
- e.prototype.setStencilOperationDepthFail = function(i) {
- this._stencilState.stencilOpDepthFail = i
- }
- ,
- e.prototype.setStencilOperationPass = function(i) {
- this._stencilState.stencilOpStencilDepthPass = i
- }
- ,
- e.prototype.setDitheringState = function(i) {
- i ? this._gl.enable(this._gl.DITHER) : this._gl.disable(this._gl.DITHER)
- }
- ,
- e.prototype.setRasterizerState = function(i) {
- i ? this._gl.disable(this._gl.RASTERIZER_DISCARD) : this._gl.enable(this._gl.RASTERIZER_DISCARD)
- }
- ,
- e.prototype.getDepthFunction = function() {
- return this._depthCullingState.depthFunc
- }
- ,
- e.prototype.setDepthFunction = function(i) {
- this._depthCullingState.depthFunc = i
- }
- ,
- e.prototype.setDepthFunctionToGreater = function() {
- this.setDepthFunction(516)
- }
- ,
- e.prototype.setDepthFunctionToGreaterOrEqual = function() {
- this.setDepthFunction(518)
- }
- ,
- e.prototype.setDepthFunctionToLess = function() {
- this.setDepthFunction(513)
- }
- ,
- e.prototype.setDepthFunctionToLessOrEqual = function() {
- this.setDepthFunction(515)
- }
- ,
- e.prototype.cacheStencilState = function() {
- this._cachedStencilBuffer = this.getStencilBuffer(),
- this._cachedStencilFunction = this.getStencilFunction(),
- this._cachedStencilMask = this.getStencilMask(),
- this._cachedStencilOperationPass = this.getStencilOperationPass(),
- this._cachedStencilOperationFail = this.getStencilOperationFail(),
- this._cachedStencilOperationDepthFail = this.getStencilOperationDepthFail(),
- this._cachedStencilReference = this.getStencilFunctionReference()
- }
- ,
- e.prototype.restoreStencilState = function() {
- this.setStencilFunction(this._cachedStencilFunction),
- this.setStencilMask(this._cachedStencilMask),
- this.setStencilBuffer(this._cachedStencilBuffer),
- this.setStencilOperationPass(this._cachedStencilOperationPass),
- this.setStencilOperationFail(this._cachedStencilOperationFail),
- this.setStencilOperationDepthFail(this._cachedStencilOperationDepthFail),
- this.setStencilFunctionReference(this._cachedStencilReference)
- }
- ,
- e.prototype.setDirectViewport = function(i, o, s, c) {
- var d = this._cachedViewport;
- return this._cachedViewport = null,
- this._viewport(i, o, s, c),
- d
- }
- ,
- e.prototype.scissorClear = function(i, o, s, c, d) {
- this.enableScissor(i, o, s, c),
- this.clear(d, !0, !0, !0),
- this.disableScissor()
- }
- ,
- e.prototype.enableScissor = function(i, o, s, c) {
- var d = this._gl;
- d.enable(d.SCISSOR_TEST),
- d.scissor(i, o, s, c)
- }
- ,
- e.prototype.disableScissor = function() {
- var i = this._gl;
- i.disable(i.SCISSOR_TEST)
- }
- ,
- e.prototype._reportDrawCall = function(i) {
- i === void 0 && (i = 1),
- this._drawCalls.addCount(i, !1)
- }
- ,
- e.prototype.initWebVR = function() {
- throw _WarnImport("WebVRCamera")
- }
- ,
- e.prototype._prepareVRComponent = function() {}
- ,
- e.prototype._connectVREvents = function(i, o) {}
- ,
- e.prototype._submitVRFrame = function() {}
- ,
- e.prototype.disableVR = function() {}
- ,
- e.prototype.isVRPresenting = function() {
- return !1
- }
- ,
- e.prototype._requestVRFrame = function() {}
- ,
- e.prototype._loadFileAsync = function(i, o, s) {
- var c = this;
- return new Promise(function(d, _) {
- c._loadFile(i, function(b) {
- d(b)
- }, void 0, o, s, function(b, k) {
- _(k)
- })
- }
- )
- }
- ,
- e.prototype.getVertexShaderSource = function(i) {
- var o = this._gl.getAttachedShaders(i);
- return o ? this._gl.getShaderSource(o[0]) : null
- }
- ,
- e.prototype.getFragmentShaderSource = function(i) {
- var o = this._gl.getAttachedShaders(i);
- return o ? this._gl.getShaderSource(o[1]) : null
- }
- ,
- e.prototype.setDepthStencilTexture = function(i, o, s, c) {
- i !== void 0 && (o && (this._boundUniforms[i] = o),
- !s || !s.depthStencilTexture ? this._setTexture(i, null, void 0, void 0, c) : this._setTexture(i, s, !1, !0, c))
- }
- ,
- e.prototype.setTextureFromPostProcess = function(i, o, s) {
- var c, d = null;
- o && (o._textures.data[o._currentRenderTextureInd] ? d = o._textures.data[o._currentRenderTextureInd] : o._forcedOutputTexture && (d = o._forcedOutputTexture)),
- this._bindTexture(i, (c = d == null ? void 0 : d.texture) !== null && c !== void 0 ? c : null, s)
- }
- ,
- e.prototype.setTextureFromPostProcessOutput = function(i, o, s) {
- var c, d;
- 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)
- }
- ,
- e.prototype._rebuildBuffers = function() {
- for (var i = 0, o = this.scenes; i < o.length; i++) {
- var s = o[i];
- s.resetCachedMaterial(),
- s._rebuildGeometries(),
- s._rebuildTextures()
- }
- for (var c = 0, d = this._virtualScenes; c < d.length; c++) {
- var s = d[c];
- s.resetCachedMaterial(),
- s._rebuildGeometries(),
- s._rebuildTextures()
- }
- a.prototype._rebuildBuffers.call(this)
- }
- ,
- e.prototype._renderFrame = function() {
- for (var i = 0; i < this._activeRenderLoops.length; i++) {
- var o = this._activeRenderLoops[i];
- o()
- }
- }
- ,
- e.prototype._renderLoop = function() {
- if (!this._contextWasLost) {
- var i = !0;
- !this.renderEvenInBackground && this._windowIsBackground && (i = !1),
- i && (this.beginFrame(),
- this._renderViews() || this._renderFrame(),
- this.endFrame())
- }
- this._activeRenderLoops.length > 0 ? this.customAnimationFrameRequester ? (this.customAnimationFrameRequester.requestID = this._queueNewFrame(this.customAnimationFrameRequester.renderFunction || this._boundRenderFunction, this.customAnimationFrameRequester),
- this._frameHandler = this.customAnimationFrameRequester.requestID) : this.isVRPresenting() ? this._requestVRFrame() : this._frameHandler = this._queueNewFrame(this._boundRenderFunction, this.getHostWindow()) : this._renderingQueueLaunched = !1
- }
- ,
- e.prototype._renderViews = function() {
- return !1
- }
- ,
- e.prototype.switchFullscreen = function(i) {
- this.isFullscreen ? this.exitFullscreen() : this.enterFullscreen(i)
- }
- ,
- e.prototype.enterFullscreen = function(i) {
- this.isFullscreen || (this._pointerLockRequested = i,
- this._renderingCanvas && e._RequestFullscreen(this._renderingCanvas))
- }
- ,
- e.prototype.exitFullscreen = function() {
- this.isFullscreen && e._ExitFullscreen()
- }
- ,
- e.prototype.enterPointerlock = function() {
- this._renderingCanvas && e._RequestPointerlock(this._renderingCanvas)
- }
- ,
- e.prototype.exitPointerlock = function() {
- e._ExitPointerlock()
- }
- ,
- e.prototype.beginFrame = function() {
- this._measureFps(),
- this.onBeginFrameObservable.notifyObservers(this),
- a.prototype.beginFrame.call(this)
- }
- ,
- e.prototype.endFrame = function() {
- a.prototype.endFrame.call(this),
- this._submitVRFrame(),
- this.onEndFrameObservable.notifyObservers(this)
- }
- ,
- e.prototype.resize = function(i) {
- i === void 0 && (i = !1),
- !this.isVRPresenting() && a.prototype.resize.call(this, i)
- }
- ,
- e.prototype.setSize = function(i, o, s) {
- if (s === void 0 && (s = !1),
- !this._renderingCanvas || !a.prototype.setSize.call(this, i, o, s))
- return !1;
- if (this.scenes) {
- for (var c = 0; c < this.scenes.length; c++)
- for (var d = this.scenes[c], _ = 0; _ < d.cameras.length; _++) {
- var b = d.cameras[_];
- b._currentRenderId = 0
- }
- this.onResizeObservable.hasObservers() && this.onResizeObservable.notifyObservers(this)
- }
- return !0
- }
- ,
- e.prototype._deletePipelineContext = function(i) {
- var o = i;
- o && o.program && o.transformFeedback && (this.deleteTransformFeedback(o.transformFeedback),
- o.transformFeedback = null),
- a.prototype._deletePipelineContext.call(this, i)
- }
- ,
- e.prototype.createShaderProgram = function(i, o, s, c, d, _) {
- _ === void 0 && (_ = null),
- d = d || this._gl,
- this.onBeforeShaderCompilationObservable.notifyObservers(this);
- var b = a.prototype.createShaderProgram.call(this, i, o, s, c, d, _);
- return this.onAfterShaderCompilationObservable.notifyObservers(this),
- b
- }
- ,
- e.prototype._createShaderProgram = function(i, o, s, c, d) {
- d === void 0 && (d = null);
- var _ = c.createProgram();
- if (i.program = _,
- !_)
- throw new Error("Unable to create program");
- if (c.attachShader(_, o),
- c.attachShader(_, s),
- this.webGLVersion > 1 && d) {
- var b = this.createTransformFeedback();
- this.bindTransformFeedback(b),
- this.setTranformFeedbackVaryings(_, d),
- i.transformFeedback = b
- }
- return c.linkProgram(_),
- this.webGLVersion > 1 && d && this.bindTransformFeedback(null),
- i.context = c,
- i.vertexShader = o,
- i.fragmentShader = s,
- i.isParallelCompiled || this._finalizePipelineContext(i),
- _
- }
- ,
- e.prototype._releaseTexture = function(i) {
- a.prototype._releaseTexture.call(this, i)
- }
- ,
- e.prototype._releaseRenderTargetWrapper = function(i) {
- a.prototype._releaseRenderTargetWrapper.call(this, i),
- this.scenes.forEach(function(o) {
- o.postProcesses.forEach(function(s) {
- s._outputTexture === i && (s._outputTexture = null)
- }),
- o.cameras.forEach(function(s) {
- s._postProcesses.forEach(function(c) {
- c && c._outputTexture === i && (c._outputTexture = null)
- })
- })
- })
- }
- ,
- e.prototype.getRenderPassNames = function() {
- return this._renderPassNames
- }
- ,
- e.prototype.getCurrentRenderPassName = function() {
- return this._renderPassNames[this.currentRenderPassId]
- }
- ,
- e.prototype.createRenderPassId = function(i) {
- var o = ++e._RenderPassIdCounter;
- return this._renderPassNames[o] = i != null ? i : "NONAME",
- o
- }
- ,
- e.prototype.releaseRenderPassId = function(i) {
- this._renderPassNames[i] = void 0;
- for (var o = 0; o < this.scenes.length; ++o)
- for (var s = this.scenes[o], c = 0; c < s.meshes.length; ++c) {
- var d = s.meshes[c];
- if (d.subMeshes)
- for (var _ = 0; _ < d.subMeshes.length; ++_) {
- var b = d.subMeshes[_];
- b._removeDrawWrapper(i)
- }
- }
- }
- ,
- e.prototype._rescaleTexture = function(i, o, s, c, d) {
- var _ = this;
- this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, this._gl.LINEAR),
- this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, this._gl.LINEAR),
- this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._gl.CLAMP_TO_EDGE),
- this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._gl.CLAMP_TO_EDGE);
- var b = this.createRenderTargetTexture({
- width: o.width,
- height: o.height
- }, {
- generateMipMaps: !1,
- type: 0,
- samplingMode: 2,
- generateDepthBuffer: !1,
- generateStencilBuffer: !1
- });
- !this._rescalePostProcess && e._RescalePostProcessFactory && (this._rescalePostProcess = e._RescalePostProcessFactory(this)),
- this._rescalePostProcess.externalTextureSamplerBinding = !0,
- this._rescalePostProcess.getEffect().executeWhenCompiled(function() {
- _._rescalePostProcess.onApply = function(j) {
- j._bindTexture("textureSampler", i)
- }
- ;
- var k = s;
- k || (k = _.scenes[_.scenes.length - 1]),
- k.postProcessManager.directRender([_._rescalePostProcess], b, !0),
- _._bindTextureDirectly(_._gl.TEXTURE_2D, o, !0),
- _._gl.copyTexImage2D(_._gl.TEXTURE_2D, 0, c, 0, 0, o.width, o.height, 0),
- _.unBindFramebuffer(b),
- b.dispose(),
- d && d()
- })
- }
- ,
- e.prototype.getFps = function() {
- return this._fps
- }
- ,
- e.prototype.getDeltaTime = function() {
- return this._deltaTime
- }
- ,
- e.prototype._measureFps = function() {
- this._performanceMonitor.sampleFrame(),
- this._fps = this._performanceMonitor.averageFPS,
- this._deltaTime = this._performanceMonitor.instantaneousFrameTime || 0
- }
- ,
- e.prototype._uploadImageToTexture = function(i, o, s, c) {
- s === void 0 && (s = 0),
- c === void 0 && (c = 0);
- var d = this._gl
- , _ = this._getWebGLTextureType(i.type)
- , b = this._getInternalFormat(i.format)
- , k = this._getRGBABufferInternalSizedFormat(i.type, b)
- , j = i.isCube ? d.TEXTURE_CUBE_MAP : d.TEXTURE_2D;
- this._bindTextureDirectly(j, i, !0),
- this._unpackFlipY(i.invertY);
- var $ = d.TEXTURE_2D;
- i.isCube && ($ = d.TEXTURE_CUBE_MAP_POSITIVE_X + s),
- d.texImage2D($, c, k, b, _, o),
- this._bindTextureDirectly(j, null, !0)
- }
- ,
- e.prototype.updateTextureComparisonFunction = function(i, o) {
- if (this.webGLVersion === 1) {
- Logger$2.Error("WebGL 1 does not support texture comparison.");
- return
- }
- var s = this._gl;
- i.isCube ? (this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, i, !0),
- o === 0 ? (s.texParameteri(s.TEXTURE_CUBE_MAP, s.TEXTURE_COMPARE_FUNC, 515),
- s.texParameteri(s.TEXTURE_CUBE_MAP, s.TEXTURE_COMPARE_MODE, s.NONE)) : (s.texParameteri(s.TEXTURE_CUBE_MAP, s.TEXTURE_COMPARE_FUNC, o),
- s.texParameteri(s.TEXTURE_CUBE_MAP, s.TEXTURE_COMPARE_MODE, s.COMPARE_REF_TO_TEXTURE)),
- this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null)) : (this._bindTextureDirectly(this._gl.TEXTURE_2D, i, !0),
- o === 0 ? (s.texParameteri(s.TEXTURE_2D, s.TEXTURE_COMPARE_FUNC, 515),
- s.texParameteri(s.TEXTURE_2D, s.TEXTURE_COMPARE_MODE, s.NONE)) : (s.texParameteri(s.TEXTURE_2D, s.TEXTURE_COMPARE_FUNC, o),
- s.texParameteri(s.TEXTURE_2D, s.TEXTURE_COMPARE_MODE, s.COMPARE_REF_TO_TEXTURE)),
- this._bindTextureDirectly(this._gl.TEXTURE_2D, null)),
- i._comparisonFunction = o
- }
- ,
- e.prototype.createInstancesBuffer = function(i) {
- var o = this._gl.createBuffer();
- if (!o)
- throw new Error("Unable to create instance buffer");
- var s = new WebGLDataBuffer(o);
- return s.capacity = i,
- this.bindArrayBuffer(s),
- this._gl.bufferData(this._gl.ARRAY_BUFFER, i, this._gl.DYNAMIC_DRAW),
- s.references = 1,
- s
- }
- ,
- e.prototype.deleteInstancesBuffer = function(i) {
- this._gl.deleteBuffer(i)
- }
- ,
- e.prototype._clientWaitAsync = function(i, o, s) {
- o === void 0 && (o = 0),
- s === void 0 && (s = 10);
- var c = this._gl;
- return new Promise(function(d, _) {
- var b = function() {
- var k = c.clientWaitSync(i, o, 0);
- if (k == c.WAIT_FAILED) {
- _();
- return
- }
- if (k == c.TIMEOUT_EXPIRED) {
- setTimeout(b, s);
- return
- }
- d()
- };
- b()
- }
- )
- }
- ,
- e.prototype._readPixelsAsync = function(i, o, s, c, d, _, b) {
- if (this._webGLVersion < 2)
- throw new Error("_readPixelsAsync only work on WebGL2+");
- var k = this._gl
- , j = k.createBuffer();
- k.bindBuffer(k.PIXEL_PACK_BUFFER, j),
- k.bufferData(k.PIXEL_PACK_BUFFER, b.byteLength, k.STREAM_READ),
- k.readPixels(i, o, s, c, d, _, 0),
- k.bindBuffer(k.PIXEL_PACK_BUFFER, null);
- var $ = k.fenceSync(k.SYNC_GPU_COMMANDS_COMPLETE, 0);
- return $ ? (k.flush(),
- this._clientWaitAsync($, 0, 10).then(function() {
- return k.deleteSync($),
- k.bindBuffer(k.PIXEL_PACK_BUFFER, j),
- k.getBufferSubData(k.PIXEL_PACK_BUFFER, 0, b),
- k.bindBuffer(k.PIXEL_PACK_BUFFER, null),
- k.deleteBuffer(j),
- b
- })) : null
- }
- ,
- e.prototype.dispose = function() {
- for (this.hideLoadingUI(),
- this.onNewSceneAddedObservable.clear(); this.postProcesses.length; )
- this.postProcesses[0].dispose();
- for (this._rescalePostProcess && this._rescalePostProcess.dispose(); this.scenes.length; )
- this.scenes[0].dispose();
- for (; this._virtualScenes.length; )
- this._virtualScenes[0].dispose();
- e.Instances.length === 1 && e.audioEngine && (e.audioEngine.dispose(),
- e.audioEngine = null),
- this.disableVR(),
- this.deviceInputSystem && this.deviceInputSystem.dispose(),
- IsWindowObjectExist() && (window.removeEventListener("blur", this._onBlur),
- window.removeEventListener("focus", this._onFocus),
- this._renderingCanvas && (this._renderingCanvas.removeEventListener("focus", this._onCanvasFocus),
- this._renderingCanvas.removeEventListener("blur", this._onCanvasBlur),
- this._renderingCanvas.removeEventListener("pointerout", this._onCanvasPointerOut)),
- IsDocumentAvailable() && (document.removeEventListener("fullscreenchange", this._onFullscreenChange),
- document.removeEventListener("mozfullscreenchange", this._onFullscreenChange),
- document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange),
- document.removeEventListener("msfullscreenchange", this._onFullscreenChange),
- document.removeEventListener("pointerlockchange", this._onPointerLockChange),
- document.removeEventListener("mspointerlockchange", this._onPointerLockChange),
- document.removeEventListener("mozpointerlockchange", this._onPointerLockChange),
- document.removeEventListener("webkitpointerlockchange", this._onPointerLockChange))),
- a.prototype.dispose.call(this);
- var i = e.Instances.indexOf(this);
- i >= 0 && e.Instances.splice(i, 1),
- this.onResizeObservable.clear(),
- this.onCanvasBlurObservable.clear(),
- this.onCanvasFocusObservable.clear(),
- this.onCanvasPointerOutObservable.clear(),
- this.onBeginFrameObservable.clear(),
- this.onEndFrameObservable.clear()
- }
- ,
- e.prototype._disableTouchAction = function() {
- !this._renderingCanvas || !this._renderingCanvas.setAttribute || (this._renderingCanvas.setAttribute("touch-action", "none"),
- this._renderingCanvas.style.touchAction = "none",
- this._renderingCanvas.style.msTouchAction = "none")
- }
- ,
- e.prototype.displayLoadingUI = function() {
- if (!!IsWindowObjectExist()) {
- var i = this.loadingScreen;
- i && i.displayLoadingUI()
- }
- }
- ,
- e.prototype.hideLoadingUI = function() {
- if (!!IsWindowObjectExist()) {
- var i = this._loadingScreen;
- i && i.hideLoadingUI()
- }
- }
- ,
- Object.defineProperty(e.prototype, "loadingScreen", {
- get: function() {
- return !this._loadingScreen && this._renderingCanvas && (this._loadingScreen = e.DefaultLoadingScreenFactory(this._renderingCanvas)),
- this._loadingScreen
- },
- set: function(i) {
- this._loadingScreen = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "loadingUIText", {
- set: function(i) {
- this.loadingScreen.loadingUIText = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "loadingUIBackgroundColor", {
- set: function(i) {
- this.loadingScreen.loadingUIBackgroundColor = i
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.createVideoElement = function(i) {
- return document.createElement("video")
- }
- ,
- e._RequestPointerlock = function(i) {
- i.requestPointerLock = i.requestPointerLock || i.msRequestPointerLock || i.mozRequestPointerLock || i.webkitRequestPointerLock,
- i.requestPointerLock && i.requestPointerLock()
- }
- ,
- e._ExitPointerlock = function() {
- var i = document;
- document.exitPointerLock = document.exitPointerLock || i.msExitPointerLock || i.mozExitPointerLock || i.webkitExitPointerLock,
- document.exitPointerLock && document.exitPointerLock()
- }
- ,
- e._RequestFullscreen = function(i) {
- var o = i.requestFullscreen || i.msRequestFullscreen || i.webkitRequestFullscreen || i.mozRequestFullScreen;
- !o || o.call(i)
- }
- ,
- e._ExitFullscreen = function() {
- var i = document;
- document.exitFullscreen ? document.exitFullscreen() : i.mozCancelFullScreen ? i.mozCancelFullScreen() : i.webkitCancelFullScreen ? i.webkitCancelFullScreen() : i.msCancelFullScreen && i.msCancelFullScreen()
- }
- ,
- e.prototype.getFontOffset = function(i) {
- var o = document.createElement("span");
- o.innerHTML = "Hg",
- o.setAttribute("style", "font: " + i + " !important");
- var s = document.createElement("div");
- s.style.display = "inline-block",
- s.style.width = "1px",
- s.style.height = "0px",
- s.style.verticalAlign = "bottom";
- var c = document.createElement("div");
- c.style.whiteSpace = "nowrap",
- c.appendChild(o),
- c.appendChild(s),
- document.body.appendChild(c);
- var d = 0
- , _ = 0;
- try {
- _ = s.getBoundingClientRect().top - o.getBoundingClientRect().top,
- s.style.verticalAlign = "baseline",
- d = s.getBoundingClientRect().top - o.getBoundingClientRect().top
- } finally {
- document.body.removeChild(c)
- }
- return {
- ascent: d,
- height: _,
- descent: _ - d
- }
- }
- ,
- e.ALPHA_DISABLE = 0,
- e.ALPHA_ADD = 1,
- e.ALPHA_COMBINE = 2,
- e.ALPHA_SUBTRACT = 3,
- e.ALPHA_MULTIPLY = 4,
- e.ALPHA_MAXIMIZED = 5,
- e.ALPHA_ONEONE = 6,
- e.ALPHA_PREMULTIPLIED = 7,
- e.ALPHA_PREMULTIPLIED_PORTERDUFF = 8,
- e.ALPHA_INTERPOLATE = 9,
- e.ALPHA_SCREENMODE = 10,
- e.DELAYLOADSTATE_NONE = 0,
- e.DELAYLOADSTATE_LOADED = 1,
- e.DELAYLOADSTATE_LOADING = 2,
- e.DELAYLOADSTATE_NOTLOADED = 4,
- e.NEVER = 512,
- e.ALWAYS = 519,
- e.LESS = 513,
- e.EQUAL = 514,
- e.LEQUAL = 515,
- e.GREATER = 516,
- e.GEQUAL = 518,
- e.NOTEQUAL = 517,
- e.KEEP = 7680,
- e.REPLACE = 7681,
- e.INCR = 7682,
- e.DECR = 7683,
- e.INVERT = 5386,
- e.INCR_WRAP = 34055,
- e.DECR_WRAP = 34056,
- e.TEXTURE_CLAMP_ADDRESSMODE = 0,
- e.TEXTURE_WRAP_ADDRESSMODE = 1,
- e.TEXTURE_MIRROR_ADDRESSMODE = 2,
- e.TEXTUREFORMAT_ALPHA = 0,
- e.TEXTUREFORMAT_LUMINANCE = 1,
- e.TEXTUREFORMAT_LUMINANCE_ALPHA = 2,
- e.TEXTUREFORMAT_RGB = 4,
- e.TEXTUREFORMAT_RGBA = 5,
- e.TEXTUREFORMAT_RED = 6,
- e.TEXTUREFORMAT_R = 6,
- e.TEXTUREFORMAT_RG = 7,
- e.TEXTUREFORMAT_RED_INTEGER = 8,
- e.TEXTUREFORMAT_R_INTEGER = 8,
- e.TEXTUREFORMAT_RG_INTEGER = 9,
- e.TEXTUREFORMAT_RGB_INTEGER = 10,
- e.TEXTUREFORMAT_RGBA_INTEGER = 11,
- e.TEXTURETYPE_UNSIGNED_BYTE = 0,
- e.TEXTURETYPE_UNSIGNED_INT = 0,
- e.TEXTURETYPE_FLOAT = 1,
- e.TEXTURETYPE_HALF_FLOAT = 2,
- e.TEXTURETYPE_BYTE = 3,
- e.TEXTURETYPE_SHORT = 4,
- e.TEXTURETYPE_UNSIGNED_SHORT = 5,
- e.TEXTURETYPE_INT = 6,
- e.TEXTURETYPE_UNSIGNED_INTEGER = 7,
- e.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = 8,
- e.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = 9,
- e.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = 10,
- e.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = 11,
- e.TEXTURETYPE_UNSIGNED_INT_24_8 = 12,
- e.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = 13,
- e.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = 14,
- e.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = 15,
- e.TEXTURE_NEAREST_SAMPLINGMODE = 1,
- e.TEXTURE_BILINEAR_SAMPLINGMODE = 2,
- e.TEXTURE_TRILINEAR_SAMPLINGMODE = 3,
- e.TEXTURE_NEAREST_NEAREST_MIPLINEAR = 8,
- e.TEXTURE_LINEAR_LINEAR_MIPNEAREST = 11,
- e.TEXTURE_LINEAR_LINEAR_MIPLINEAR = 3,
- e.TEXTURE_NEAREST_NEAREST_MIPNEAREST = 4,
- e.TEXTURE_NEAREST_LINEAR_MIPNEAREST = 5,
- e.TEXTURE_NEAREST_LINEAR_MIPLINEAR = 6,
- e.TEXTURE_NEAREST_LINEAR = 7,
- e.TEXTURE_NEAREST_NEAREST = 1,
- e.TEXTURE_LINEAR_NEAREST_MIPNEAREST = 9,
- e.TEXTURE_LINEAR_NEAREST_MIPLINEAR = 10,
- e.TEXTURE_LINEAR_LINEAR = 2,
- e.TEXTURE_LINEAR_NEAREST = 12,
- e.TEXTURE_EXPLICIT_MODE = 0,
- e.TEXTURE_SPHERICAL_MODE = 1,
- e.TEXTURE_PLANAR_MODE = 2,
- e.TEXTURE_CUBIC_MODE = 3,
- e.TEXTURE_PROJECTION_MODE = 4,
- e.TEXTURE_SKYBOX_MODE = 5,
- e.TEXTURE_INVCUBIC_MODE = 6,
- e.TEXTURE_EQUIRECTANGULAR_MODE = 7,
- e.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = 8,
- e.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = 9,
- e.SCALEMODE_FLOOR = 1,
- e.SCALEMODE_NEAREST = 2,
- e.SCALEMODE_CEILING = 3,
- e._RescalePostProcessFactory = null,
- e._RenderPassIdCounter = 0,
- e
- }(ThinEngine)
- , RenderTargetWrapper = function() {
- function a(e, i, o, s) {
- this._textures = null,
- this._attachments = null,
- this._generateStencilBuffer = !1,
- this._generateDepthBuffer = !1,
- this._depthStencilTextureWithStencil = !1,
- this._isMulti = e,
- this._isCube = i,
- this._size = o,
- this._engine = s,
- this._depthStencilTexture = null
- }
- return Object.defineProperty(a.prototype, "isCube", {
- get: function() {
- return this._isCube
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "isMulti", {
- get: function() {
- return this._isMulti
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "is2DArray", {
- get: function() {
- return this.layers > 0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "size", {
- get: function() {
- return this.width
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "width", {
- get: function() {
- return this._size.width || this._size
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "height", {
- get: function() {
- return this._size.height || this._size
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "layers", {
- get: function() {
- return this._size.layers || 0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "texture", {
- get: function() {
- var e, i;
- return (i = (e = this._textures) === null || e === void 0 ? void 0 : e[0]) !== null && i !== void 0 ? i : null
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "textures", {
- get: function() {
- return this._textures
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "samples", {
- get: function() {
- var e, i;
- return (i = (e = this.texture) === null || e === void 0 ? void 0 : e.samples) !== null && i !== void 0 ? i : 1
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.setSamples = function(e, i, o) {
- return i === void 0 && (i = !0),
- o === void 0 && (o = !1),
- this.samples === e && !o ? e : this._isMulti ? this._engine.updateMultipleRenderTargetTextureSampleCount(this, e, i) : this._engine.updateRenderTargetTextureSampleCount(this, e)
- }
- ,
- a.prototype.setTextures = function(e) {
- Array.isArray(e) ? this._textures = e : e ? this._textures = [e] : this._textures = null
- }
- ,
- a.prototype.setTexture = function(e, i, o) {
- i === void 0 && (i = 0),
- o === void 0 && (o = !0),
- this._textures || (this._textures = []),
- this._textures[i] && o && this._textures[i].dispose(),
- this._textures[i] = e
- }
- ,
- a.prototype.createDepthStencilTexture = function(e, i, o, s, c) {
- var d;
- return e === void 0 && (e = 0),
- i === void 0 && (i = !0),
- o === void 0 && (o = !1),
- s === void 0 && (s = 1),
- c === void 0 && (c = 15),
- (d = this._depthStencilTexture) === null || d === void 0 || d.dispose(),
- this._depthStencilTextureWithStencil = o,
- this._depthStencilTexture = this._engine.createDepthStencilTexture(this._size, {
- bilinearFiltering: i,
- comparisonFunction: e,
- generateStencil: o,
- isCube: this._isCube,
- samples: s,
- depthTextureFormat: c
- }, this),
- this._depthStencilTexture
- }
- ,
- a.prototype._shareDepth = function(e) {
- this._depthStencilTexture && (e._depthStencilTexture && e._depthStencilTexture.dispose(),
- e._depthStencilTexture = this._depthStencilTexture,
- this._depthStencilTexture.incrementReferences())
- }
- ,
- a.prototype._swapAndDie = function(e) {
- this.texture && this.texture._swapAndDie(e),
- this._textures = null,
- this.dispose(!0)
- }
- ,
- a.prototype._cloneRenderTargetWrapper = function() {
- var e, i, o, s, c, d, _ = null;
- if (this._isMulti) {
- var b = this.textures;
- if (b && b.length > 0) {
- var k = !1
- , j = b.length
- , $ = b[b.length - 1]._source;
- ($ === InternalTextureSource.Depth || $ === InternalTextureSource.DepthStencil) && (k = !0,
- j--);
- for (var _e = [], et = [], tt = 0; tt < j; ++tt) {
- var rt = b[tt];
- _e.push(rt.samplingMode),
- et.push(rt.type)
- }
- var it = {
- samplingModes: _e,
- generateMipMaps: b[0].generateMipMaps,
- generateDepthBuffer: this._generateDepthBuffer,
- generateStencilBuffer: this._generateStencilBuffer,
- generateDepthTexture: k,
- types: et,
- textureCount: j
- }
- , nt = {
- width: this.width,
- height: this.height
- };
- _ = this._engine.createMultipleRenderTarget(nt, it)
- }
- } else {
- var ot = {};
- if (ot.generateDepthBuffer = this._generateDepthBuffer,
- ot.generateMipMaps = (i = (e = this.texture) === null || e === void 0 ? void 0 : e.generateMipMaps) !== null && i !== void 0 ? i : !1,
- ot.generateStencilBuffer = this._generateStencilBuffer,
- ot.samplingMode = (o = this.texture) === null || o === void 0 ? void 0 : o.samplingMode,
- ot.type = (s = this.texture) === null || s === void 0 ? void 0 : s.type,
- ot.format = (c = this.texture) === null || c === void 0 ? void 0 : c.format,
- this.isCube)
- _ = this._engine.createRenderTargetCubeTexture(this.width, ot);
- else {
- var nt = {
- width: this.width,
- height: this.height,
- layers: this.is2DArray ? (d = this.texture) === null || d === void 0 ? void 0 : d.depth : void 0
- };
- _ = this._engine.createRenderTargetTexture(nt, ot)
- }
- _.texture.isReady = !0
- }
- return _
- }
- ,
- a.prototype._swapRenderTargetWrapper = function(e) {
- if (this._textures && e._textures)
- for (var i = 0; i < this._textures.length; ++i)
- this._textures[i]._swapAndDie(e._textures[i], !1),
- e._textures[i].isReady = !0;
- this._depthStencilTexture && e._depthStencilTexture && (this._depthStencilTexture._swapAndDie(e._depthStencilTexture),
- e._depthStencilTexture.isReady = !0),
- this._textures = null,
- this._depthStencilTexture = null
- }
- ,
- a.prototype._rebuild = function() {
- var e = this._cloneRenderTargetWrapper();
- if (!!e) {
- if (this._depthStencilTexture) {
- var i = this._depthStencilTexture.samplingMode
- , o = i === 2 || i === 3 || i === 11;
- e.createDepthStencilTexture(this._depthStencilTexture._comparisonFunction, o, this._depthStencilTextureWithStencil, this._depthStencilTexture.samples)
- }
- this.samples > 1 && e.setSamples(this.samples),
- e._swapRenderTargetWrapper(this),
- e.dispose()
- }
- }
- ,
- a.prototype.releaseTextures = function() {
- var e, i;
- if (this._textures)
- for (var o = 0; (i = o < ((e = this._textures) === null || e === void 0 ? void 0 : e.length)) !== null && i !== void 0 && i; ++o)
- this._textures[o].dispose();
- this._textures = null
- }
- ,
- a.prototype.dispose = function(e) {
- var i;
- e === void 0 && (e = !1),
- e || ((i = this._depthStencilTexture) === null || i === void 0 || i.dispose(),
- this._depthStencilTexture = null,
- this.releaseTextures()),
- this._engine._releaseRenderTargetWrapper(this)
- }
- ,
- a
- }()
- , NullEngineOptions = function() {
- function a() {
- this.renderWidth = 512,
- this.renderHeight = 256,
- this.textureSize = 512,
- this.deterministicLockstep = !1,
- this.lockstepMaxSteps = 4
- }
- return a
- }();
- (function(a) {
- __extends(e, a);
- function e(i) {
- i === void 0 && (i = new NullEngineOptions);
- var o = a.call(this, null) || this;
- Engine.Instances.push(o),
- i.deterministicLockstep === void 0 && (i.deterministicLockstep = !1),
- i.lockstepMaxSteps === void 0 && (i.lockstepMaxSteps = 4),
- o._options = i,
- PerformanceConfigurator.SetMatrixPrecision(!!i.useHighPrecisionMatrix),
- o._caps = {
- maxTexturesImageUnits: 16,
- maxVertexTextureImageUnits: 16,
- maxCombinedTexturesImageUnits: 32,
- maxTextureSize: 512,
- maxCubemapTextureSize: 512,
- maxRenderTextureSize: 512,
- maxVertexAttribs: 16,
- maxVaryingVectors: 16,
- maxFragmentUniformVectors: 16,
- maxVertexUniformVectors: 16,
- standardDerivatives: !1,
- astc: null,
- pvrtc: null,
- etc1: null,
- etc2: null,
- bptc: null,
- maxAnisotropy: 0,
- uintIndices: !1,
- fragmentDepthSupported: !1,
- highPrecisionShaderSupported: !0,
- colorBufferFloat: !1,
- textureFloat: !1,
- textureFloatLinearFiltering: !1,
- textureFloatRender: !1,
- textureHalfFloat: !1,
- textureHalfFloatLinearFiltering: !1,
- textureHalfFloatRender: !1,
- textureLOD: !1,
- drawBuffersExtension: !1,
- depthTextureExtension: !1,
- vertexArrayObject: !1,
- instancedArrays: !1,
- supportOcclusionQuery: !1,
- canUseTimestampForTimerQuery: !1,
- maxMSAASamples: 1,
- blendMinMax: !1,
- canUseGLInstanceID: !1,
- canUseGLVertexID: !1,
- supportComputeShaders: !1,
- supportSRGBBuffers: !1
- },
- o._features = {
- forceBitmapOverHTMLImageElement: !1,
- supportRenderAndCopyToLodForFloatTextures: !1,
- supportDepthStencilTexture: !1,
- supportShadowSamplers: !1,
- uniformBufferHardCheckMatrix: !1,
- allowTexturePrefiltering: !1,
- trackUbosInFrame: !1,
- checkUbosContentBeforeUpload: !1,
- supportCSM: !1,
- basisNeedsPOT: !1,
- support3DTextures: !1,
- needTypeSuffixInShaderConstants: !1,
- supportMSAA: !1,
- supportSSAO2: !1,
- supportExtendedTextureFormats: !1,
- supportSwitchCaseInShader: !1,
- supportSyncTextureRead: !1,
- needsInvertingBitmap: !1,
- useUBOBindingCache: !1,
- needShaderCodeInlining: !1,
- needToAlwaysBindUniformBuffers: !1,
- supportRenderPasses: !0,
- _collectUbosUpdatedInFrame: !1
- },
- Logger$2.Log("Babylon.js v" + Engine.Version + " - Null engine");
- var s = typeof self != "undefined" ? self : typeof global != "undefined" ? global : window;
- return typeof URL == "undefined" && (s.URL = {
- createObjectURL: function() {},
- revokeObjectURL: function() {}
- }),
- typeof Blob == "undefined" && (s.Blob = function() {}
- ),
- o
- }
- return e.prototype.isDeterministicLockStep = function() {
- return this._options.deterministicLockstep
- }
- ,
- e.prototype.getLockstepMaxSteps = function() {
- return this._options.lockstepMaxSteps
- }
- ,
- e.prototype.getHardwareScalingLevel = function() {
- return 1
- }
- ,
- e.prototype.createVertexBuffer = function(i) {
- var o = new DataBuffer;
- return o.references = 1,
- o
- }
- ,
- e.prototype.createIndexBuffer = function(i) {
- var o = new DataBuffer;
- return o.references = 1,
- o
- }
- ,
- e.prototype.clear = function(i, o, s, c) {}
- ,
- e.prototype.getRenderWidth = function(i) {
- return i === void 0 && (i = !1),
- !i && this._currentRenderTarget ? this._currentRenderTarget.width : this._options.renderWidth
- }
- ,
- e.prototype.getRenderHeight = function(i) {
- return i === void 0 && (i = !1),
- !i && this._currentRenderTarget ? this._currentRenderTarget.height : this._options.renderHeight
- }
- ,
- e.prototype.setViewport = function(i, o, s) {
- this._cachedViewport = i
- }
- ,
- e.prototype.createShaderProgram = function(i, o, s, c, d) {
- return {
- __SPECTOR_rebuildProgram: null
- }
- }
- ,
- e.prototype.getUniforms = function(i, o) {
- return []
- }
- ,
- e.prototype.getAttributes = function(i, o) {
- return []
- }
- ,
- e.prototype.bindSamplers = function(i) {
- this._currentEffect = null
- }
- ,
- e.prototype.enableEffect = function(i) {
- i = i !== null && DrawWrapper.IsWrapper(i) ? i.effect : i,
- this._currentEffect = i,
- i && (i.onBind && i.onBind(i),
- i._onBindObservable && i._onBindObservable.notifyObservers(i))
- }
- ,
- e.prototype.setState = function(i, o, s, c, d, _, b) {}
- ,
- e.prototype.setIntArray = function(i, o) {
- return !0
- }
- ,
- e.prototype.setIntArray2 = function(i, o) {
- return !0
- }
- ,
- e.prototype.setIntArray3 = function(i, o) {
- return !0
- }
- ,
- e.prototype.setIntArray4 = function(i, o) {
- return !0
- }
- ,
- e.prototype.setFloatArray = function(i, o) {
- return !0
- }
- ,
- e.prototype.setFloatArray2 = function(i, o) {
- return !0
- }
- ,
- e.prototype.setFloatArray3 = function(i, o) {
- return !0
- }
- ,
- e.prototype.setFloatArray4 = function(i, o) {
- return !0
- }
- ,
- e.prototype.setArray = function(i, o) {
- return !0
- }
- ,
- e.prototype.setArray2 = function(i, o) {
- return !0
- }
- ,
- e.prototype.setArray3 = function(i, o) {
- return !0
- }
- ,
- e.prototype.setArray4 = function(i, o) {
- return !0
- }
- ,
- e.prototype.setMatrices = function(i, o) {
- return !0
- }
- ,
- e.prototype.setMatrix3x3 = function(i, o) {
- return !0
- }
- ,
- e.prototype.setMatrix2x2 = function(i, o) {
- return !0
- }
- ,
- e.prototype.setFloat = function(i, o) {
- return !0
- }
- ,
- e.prototype.setFloat2 = function(i, o, s) {
- return !0
- }
- ,
- e.prototype.setFloat3 = function(i, o, s, c) {
- return !0
- }
- ,
- e.prototype.setBool = function(i, o) {
- return !0
- }
- ,
- e.prototype.setFloat4 = function(i, o, s, c, d) {
- return !0
- }
- ,
- e.prototype.setAlphaMode = function(i, o) {
- o === void 0 && (o = !1),
- this._alphaMode !== i && (this.alphaState.alphaBlend = i !== 0,
- o || this.setDepthWrite(i === 0),
- this._alphaMode = i)
- }
- ,
- e.prototype.bindBuffers = function(i, o, s) {}
- ,
- e.prototype.wipeCaches = function(i) {
- this.preventCacheWipeBetweenFrames || (this.resetTextureCache(),
- this._currentEffect = null,
- i && (this._currentProgram = null,
- this._stencilStateComposer.reset(),
- this.depthCullingState.reset(),
- this.alphaState.reset()),
- this._cachedVertexBuffers = null,
- this._cachedIndexBuffer = null,
- this._cachedEffectForVertexBuffers = null)
- }
- ,
- e.prototype.draw = function(i, o, s, c) {}
- ,
- e.prototype.drawElementsType = function(i, o, s, c) {}
- ,
- e.prototype.drawArraysType = function(i, o, s, c) {}
- ,
- e.prototype._createTexture = function() {
- return {}
- }
- ,
- e.prototype._releaseTexture = function(i) {}
- ,
- e.prototype.createTexture = function(i, o, s, c, d, _, b, k, j, $, _e, et) {
- d === void 0 && (d = 3),
- _ === void 0 && (_ = null),
- $ === void 0 && ($ = null);
- var tt = new InternalTexture(this,InternalTextureSource.Url)
- , rt = String(i);
- return tt.url = rt,
- tt.generateMipMaps = !o,
- tt.samplingMode = d,
- tt.invertY = s,
- tt.baseWidth = this._options.textureSize,
- tt.baseHeight = this._options.textureSize,
- tt.width = this._options.textureSize,
- tt.height = this._options.textureSize,
- $ && (tt.format = $),
- tt.isReady = !0,
- _ && _(),
- this._internalTexturesCache.push(tt),
- tt
- }
- ,
- e.prototype._createHardwareRenderTargetWrapper = function(i, o, s) {
- var c = new RenderTargetWrapper(i,o,s,this);
- return this._renderTargetWrapperCache.push(c),
- c
- }
- ,
- e.prototype.createRenderTargetTexture = function(i, o) {
- var s = this._createHardwareRenderTargetWrapper(!1, !1, i)
- , c = {};
- o !== void 0 && typeof o == "object" ? (c.generateMipMaps = o.generateMipMaps,
- c.generateDepthBuffer = o.generateDepthBuffer === void 0 ? !0 : o.generateDepthBuffer,
- c.generateStencilBuffer = c.generateDepthBuffer && o.generateStencilBuffer,
- c.type = o.type === void 0 ? 0 : o.type,
- c.samplingMode = o.samplingMode === void 0 ? 3 : o.samplingMode) : (c.generateMipMaps = o,
- c.generateDepthBuffer = !0,
- c.generateStencilBuffer = !1,
- c.type = 0,
- c.samplingMode = 3);
- var d = new InternalTexture(this,InternalTextureSource.RenderTarget)
- , _ = i.width || i
- , b = i.height || i;
- return s._generateDepthBuffer = c.generateDepthBuffer,
- s._generateStencilBuffer = !!c.generateStencilBuffer,
- d.baseWidth = _,
- d.baseHeight = b,
- d.width = _,
- d.height = b,
- d.isReady = !0,
- d.samples = 1,
- d.generateMipMaps = !!c.generateMipMaps,
- d.samplingMode = c.samplingMode,
- d.type = c.type,
- this._internalTexturesCache.push(d),
- s
- }
- ,
- e.prototype.updateTextureSamplingMode = function(i, o) {
- o.samplingMode = i
- }
- ,
- e.prototype.createRawTexture = function(i, o, s, c, d, _, b, k, j, $) {
- k === void 0 && (k = null),
- j === void 0 && (j = 0);
- var _e = new InternalTexture(this,InternalTextureSource.Raw);
- return _e.baseWidth = o,
- _e.baseHeight = s,
- _e.width = o,
- _e.height = s,
- _e.format = c,
- _e.generateMipMaps = d,
- _e.samplingMode = b,
- _e.invertY = _,
- _e._compression = k,
- _e.type = j,
- this._doNotHandleContextLost || (_e._bufferView = i),
- _e
- }
- ,
- e.prototype.updateRawTexture = function(i, o, s, c, d, _) {
- d === void 0 && (d = null),
- _ === void 0 && (_ = 0),
- i && (i._bufferView = o,
- i.format = s,
- i.invertY = c,
- i._compression = d,
- i.type = _)
- }
- ,
- e.prototype.bindFramebuffer = function(i, o, s, c, d) {
- this._currentRenderTarget && this.unBindFramebuffer(this._currentRenderTarget),
- this._currentRenderTarget = i,
- this._currentFramebuffer = null,
- this._cachedViewport && !d && this.setViewport(this._cachedViewport, s, c)
- }
- ,
- e.prototype.unBindFramebuffer = function(i, o, s) {
- this._currentRenderTarget = null,
- s && s(),
- this._currentFramebuffer = null
- }
- ,
- e.prototype.createDynamicVertexBuffer = function(i) {
- var o = new DataBuffer;
- return o.references = 1,
- o.capacity = 1,
- o
- }
- ,
- e.prototype.updateDynamicTexture = function(i, o, s, c, d) {}
- ,
- e.prototype.areAllEffectsReady = function() {
- return !0
- }
- ,
- e.prototype.getError = function() {
- return 0
- }
- ,
- e.prototype._getUnpackAlignement = function() {
- return 1
- }
- ,
- e.prototype._unpackFlipY = function(i) {}
- ,
- e.prototype.updateDynamicIndexBuffer = function(i, o, s) {}
- ,
- e.prototype.updateDynamicVertexBuffer = function(i, o, s, c) {}
- ,
- e.prototype._bindTextureDirectly = function(i, o) {
- return this._boundTexturesCache[this._activeChannel] !== o ? (this._boundTexturesCache[this._activeChannel] = o,
- !0) : !1
- }
- ,
- e.prototype._bindTexture = function(i, o) {
- i < 0 || this._bindTextureDirectly(0, o)
- }
- ,
- e.prototype._deleteBuffer = function(i) {}
- ,
- e.prototype.releaseEffects = function() {}
- ,
- e.prototype.displayLoadingUI = function() {}
- ,
- e.prototype.hideLoadingUI = function() {}
- ,
- e.prototype._uploadCompressedDataToTextureDirectly = function(i, o, s, c, d, _, b) {}
- ,
- e.prototype._uploadDataToTextureDirectly = function(i, o, s, c) {}
- ,
- e.prototype._uploadArrayBufferViewToTexture = function(i, o, s, c) {}
- ,
- e.prototype._uploadImageToTexture = function(i, o, s, c) {}
- ,
- e
- }
- )(Engine);
- ThinEngine.prototype._debugPushGroup = function(a, e) {}
- ;
- ThinEngine.prototype._debugPopGroup = function(a) {}
- ;
- ThinEngine.prototype._debugInsertMarker = function(a, e) {}
- ;
- ThinEngine.prototype._debugFlushPendingCommands = function() {}
- ;
- var cloneValue = function(a, e) {
- return !a || a.getClassName && a.getClassName() === "Mesh" ? null : a.getClassName && a.getClassName() === "SubMesh" ? a.clone(e) : a.clone ? a.clone() : null
- };
- function getAllPropertyNames(a) {
- var e = [];
- do
- Object.getOwnPropertyNames(a).forEach(function(i) {
- e.indexOf(i) === -1 && e.push(i)
- });
- while (a = Object.getPrototypeOf(a));
- return e
- }
- var DeepCopier = function() {
- function a() {}
- return a.DeepCopy = function(e, i, o, s) {
- for (var c = getAllPropertyNames(e), d = 0, _ = c; d < _.length; d++) {
- var b = _[d];
- if (!(b[0] === "_" && (!s || s.indexOf(b) === -1)) && !EndsWith(b, "Observable") && !(o && o.indexOf(b) !== -1)) {
- var k = e[b]
- , j = typeof k;
- if (j !== "function")
- try {
- if (j === "object")
- if (k instanceof Array) {
- if (i[b] = [],
- k.length > 0)
- if (typeof k[0] == "object")
- for (var $ = 0; $ < k.length; $++) {
- var _e = cloneValue(k[$], i);
- i[b].indexOf(_e) === -1 && i[b].push(_e)
- }
- else
- i[b] = k.slice(0)
- } else
- i[b] = cloneValue(k, i);
- else
- i[b] = k
- } catch (et) {
- Logger$2.Warn(et.message)
- }
- }
- }
- }
- ,
- a
- }();
- function createXMLHttpRequest() {
- return typeof _native != "undefined" && _native.XMLHttpRequest ? new _native.XMLHttpRequest : new XMLHttpRequest
- }
- var WebRequest = function() {
- function a() {
- this._xhr = createXMLHttpRequest()
- }
- return a.prototype._injectCustomRequestHeaders = function() {
- for (var e in a.CustomRequestHeaders) {
- var i = a.CustomRequestHeaders[e];
- i && this._xhr.setRequestHeader(e, i)
- }
- }
- ,
- Object.defineProperty(a.prototype, "onprogress", {
- get: function() {
- return this._xhr.onprogress
- },
- set: function(e) {
- this._xhr.onprogress = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "readyState", {
- get: function() {
- return this._xhr.readyState
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "status", {
- get: function() {
- return this._xhr.status
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "statusText", {
- get: function() {
- return this._xhr.statusText
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "response", {
- get: function() {
- return this._xhr.response
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "responseURL", {
- get: function() {
- return this._xhr.responseURL
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "responseText", {
- get: function() {
- return this._xhr.responseText
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "responseType", {
- get: function() {
- return this._xhr.responseType
- },
- set: function(e) {
- this._xhr.responseType = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "timeout", {
- get: function() {
- return this._xhr.timeout
- },
- set: function(e) {
- this._xhr.timeout = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.addEventListener = function(e, i, o) {
- this._xhr.addEventListener(e, i, o)
- }
- ,
- a.prototype.removeEventListener = function(e, i, o) {
- this._xhr.removeEventListener(e, i, o)
- }
- ,
- a.prototype.abort = function() {
- this._xhr.abort()
- }
- ,
- a.prototype.send = function(e) {
- a.CustomRequestHeaders && this._injectCustomRequestHeaders(),
- this._xhr.send(e)
- }
- ,
- a.prototype.open = function(e, i) {
- for (var o = 0, s = a.CustomRequestModifiers; o < s.length; o++) {
- var c = s[o];
- c(this._xhr, i)
- }
- return i = i.replace("file:http:", "http:"),
- i = i.replace("file:https:", "https:"),
- this._xhr.open(e, i, !0)
- }
- ,
- a.prototype.setRequestHeader = function(e, i) {
- this._xhr.setRequestHeader(e, i)
- }
- ,
- a.prototype.getResponseHeader = function(e) {
- return this._xhr.getResponseHeader(e)
- }
- ,
- a.CustomRequestHeaders = {},
- a.CustomRequestModifiers = new Array,
- a
- }(), FilesInputStore = function() {
- function a() {}
- return a.FilesToLoad = {},
- a
- }(), RetryStrategy = function() {
- function a() {}
- return a.ExponentialBackoff = function(e, i) {
- return e === void 0 && (e = 3),
- i === void 0 && (i = 500),
- function(o, s, c) {
- return s.status !== 0 || c >= e || o.indexOf("file:") !== -1 ? -1 : Math.pow(2, c) * i
- }
- }
- ,
- a
- }(), BaseError = function(a) {
- __extends(e, a);
- function e() {
- return a !== null && a.apply(this, arguments) || this
- }
- return e._setPrototypeOf = Object.setPrototypeOf || function(i, o) {
- return i.__proto__ = o,
- i
- }
- ,
- e
- }(Error), TimingTools = function() {
- function a() {}
- return a.SetImmediate = function(e) {
- IsWindowObjectExist() && window.setImmediate ? window.setImmediate(e) : setTimeout(e, 1)
- }
- ,
- a
- }(), FileTools, _injectLTSFileTools = function(a, e, i, o, s, c, d, _, b, k) {
- FileTools = {
- DecodeBase64UrlToBinary: a,
- DecodeBase64UrlToString: e,
- DefaultRetryStrategy: i.DefaultRetryStrategy,
- BaseUrl: i.BaseUrl,
- CorsBehavior: i.CorsBehavior,
- PreprocessUrl: i.PreprocessUrl,
- IsBase64DataUrl: o,
- IsFileURL: s,
- LoadFile: c,
- LoadImage: d,
- ReadFile: _,
- RequestFile: b,
- SetCorsBehavior: k
- },
- Object.defineProperty(FileTools, "DefaultRetryStrategy", {
- get: function() {
- return i.DefaultRetryStrategy
- },
- set: function(j) {
- i.DefaultRetryStrategy = j
- }
- }),
- Object.defineProperty(FileTools, "BaseUrl", {
- get: function() {
- return i.BaseUrl
- },
- set: function(j) {
- i.BaseUrl = j
- }
- }),
- Object.defineProperty(FileTools, "PreprocessUrl", {
- get: function() {
- return i.PreprocessUrl
- },
- set: function(j) {
- i.PreprocessUrl = j
- }
- }),
- Object.defineProperty(FileTools, "CorsBehavior", {
- get: function() {
- return i.CorsBehavior
- },
- set: function(j) {
- i.CorsBehavior = j
- }
- })
- }, base64DataUrlRegEx = new RegExp(/^data:([^,]+\/[^,]+)?;base64,/i), LoadFileError = function(a) {
- __extends(e, a);
- function e(i, o) {
- var s = a.call(this, i) || this;
- return s.name = "LoadFileError",
- BaseError._setPrototypeOf(s, e.prototype),
- o instanceof WebRequest ? s.request = o : s.file = o,
- s
- }
- return e
- }(BaseError), RequestFileError = function(a) {
- __extends(e, a);
- function e(i, o) {
- var s = a.call(this, i) || this;
- return s.request = o,
- s.name = "RequestFileError",
- BaseError._setPrototypeOf(s, e.prototype),
- s
- }
- return e
- }(BaseError), ReadFileError = function(a) {
- __extends(e, a);
- function e(i, o) {
- var s = a.call(this, i) || this;
- return s.file = o,
- s.name = "ReadFileError",
- BaseError._setPrototypeOf(s, e.prototype),
- s
- }
- return e
- }(BaseError), FileToolsOptions = {
- DefaultRetryStrategy: RetryStrategy.ExponentialBackoff(),
- BaseUrl: "",
- CorsBehavior: "anonymous",
- PreprocessUrl: function(a) {
- return a
- }
- }, _CleanUrl = function(a) {
- return a = a.replace(/#/mg, "%23"),
- a
- }, SetCorsBehavior = function(a, e) {
- if (!(a && a.indexOf("data:") === 0) && FileToolsOptions.CorsBehavior)
- if (typeof FileToolsOptions.CorsBehavior == "string" || FileToolsOptions.CorsBehavior instanceof String)
- e.crossOrigin = FileToolsOptions.CorsBehavior;
- else {
- var i = FileToolsOptions.CorsBehavior(a);
- i && (e.crossOrigin = i)
- }
- }, LoadImage = function(a, e, i, o, s, c) {
- var d;
- s === void 0 && (s = "");
- var _, b = !1;
- a instanceof ArrayBuffer || ArrayBuffer.isView(a) ? typeof Blob != "undefined" ? (_ = URL.createObjectURL(new Blob([a],{
- type: s
- })),
- b = !0) : _ = "data:" + s + ";base64," + EncodeArrayBufferToBase64(a) : a instanceof Blob ? (_ = URL.createObjectURL(a),
- b = !0) : (_ = _CleanUrl(a),
- _ = FileToolsOptions.PreprocessUrl(a));
- var k = EngineStore.LastCreatedEngine
- , j = function(ot) {
- if (i) {
- var at = _ || a.toString();
- i("Error while trying to load image: " + (at.indexOf("http") === 0 || at.length <= 128 ? at : at.slice(0, 128) + "..."), ot)
- }
- };
- if (typeof Image == "undefined" || ((d = k == null ? void 0 : k._features.forceBitmapOverHTMLImageElement) !== null && d !== void 0 ? d : !1))
- return LoadFile(_, function(ot) {
- k.createImageBitmap(new Blob([ot],{
- type: s
- }), __assign({
- premultiplyAlpha: "none"
- }, c)).then(function(at) {
- e(at),
- b && URL.revokeObjectURL(_)
- }).catch(function(at) {
- i && i("Error while trying to load image: " + a, at)
- })
- }, void 0, o || void 0, !0, function(ot, at) {
- j(at)
- }),
- null;
- var $ = new Image;
- SetCorsBehavior(_, $);
- var _e = function() {
- $.removeEventListener("load", _e),
- $.removeEventListener("error", et),
- e($),
- b && $.src && URL.revokeObjectURL($.src)
- }
- , et = function(ot) {
- $.removeEventListener("load", _e),
- $.removeEventListener("error", et),
- j(ot),
- b && $.src && URL.revokeObjectURL($.src)
- };
- $.addEventListener("load", _e),
- $.addEventListener("error", et);
- var tt = function() {
- $.src = _
- }
- , rt = function() {
- o && o.loadImage(_, $)
- };
- if (_.substr(0, 5) !== "data:" && o && o.enableTexturesOffline)
- o.open(rt, tt);
- else {
- if (_.indexOf("file:") !== -1) {
- var it = decodeURIComponent(_.substring(5).toLowerCase());
- if (FilesInputStore.FilesToLoad[it]) {
- try {
- var nt;
- try {
- nt = URL.createObjectURL(FilesInputStore.FilesToLoad[it])
- } catch {
- nt = URL.createObjectURL(FilesInputStore.FilesToLoad[it])
- }
- $.src = nt,
- b = !0
- } catch {
- $.src = ""
- }
- return $
- }
- }
- tt()
- }
- return $
- }, ReadFile = function(a, e, i, o, s) {
- var c = new FileReader
- , d = {
- onCompleteObservable: new Observable,
- abort: function() {
- return c.abort()
- }
- };
- return c.onloadend = function(_) {
- return d.onCompleteObservable.notifyObservers(d)
- }
- ,
- s && (c.onerror = function(_) {
- s(new ReadFileError("Unable to read " + a.name,a))
- }
- ),
- c.onload = function(_) {
- e(_.target.result)
- }
- ,
- i && (c.onprogress = i),
- o ? c.readAsArrayBuffer(a) : c.readAsText(a),
- d
- }, LoadFile = function(a, e, i, o, s, c, d) {
- if (a.name)
- return ReadFile(a, e, i, s, c ? function($) {
- c(void 0, $)
- }
- : void 0);
- var _ = a;
- if (_.indexOf("file:") !== -1) {
- var b = decodeURIComponent(_.substring(5).toLowerCase());
- b.indexOf("./") === 0 && (b = b.substring(2));
- var k = FilesInputStore.FilesToLoad[b];
- if (k)
- return ReadFile(k, e, i, s, c ? function($) {
- return c(void 0, new LoadFileError($.message,$.file))
- }
- : void 0)
- }
- if (IsBase64DataUrl(_)) {
- var j = {
- onCompleteObservable: new Observable,
- abort: function() {
- return function() {}
- }
- };
- try {
- e(s ? DecodeBase64UrlToBinary(_) : DecodeBase64UrlToString(_))
- } catch ($) {
- c ? c(void 0, $) : Logger$2.Error($.message || "Failed to parse the Data URL")
- }
- return TimingTools.SetImmediate(function() {
- j.onCompleteObservable.notifyObservers(j)
- }),
- j
- }
- return RequestFile(_, function($, _e) {
- e($, _e ? _e.responseURL : void 0)
- }, i, o, s, c ? function($) {
- c($.request, new LoadFileError($.message,$.request))
- }
- : void 0, d)
- }, RequestFile = function(a, e, i, o, s, c, d) {
- a = _CleanUrl(a),
- a = FileToolsOptions.PreprocessUrl(a);
- var _ = FileToolsOptions.BaseUrl + a
- , b = !1
- , k = {
- onCompleteObservable: new Observable,
- abort: function() {
- return b = !0
- }
- }
- , j = function() {
- var et = new WebRequest
- , tt = null;
- k.abort = function() {
- b = !0,
- et.readyState !== (XMLHttpRequest.DONE || 4) && et.abort(),
- tt !== null && (clearTimeout(tt),
- tt = null)
- }
- ;
- var rt = function(nt) {
- var ot = nt.message || "Unknown error";
- c ? c(new RequestFileError(ot,et)) : Logger$2.Error(ot)
- }
- , it = function(nt) {
- if (et.open("GET", _),
- d)
- try {
- d(et)
- } catch (st) {
- rt(st);
- return
- }
- s && (et.responseType = "arraybuffer"),
- i && et.addEventListener("progress", i);
- var ot = function() {
- et.removeEventListener("loadend", ot),
- k.onCompleteObservable.notifyObservers(k),
- k.onCompleteObservable.clear()
- };
- et.addEventListener("loadend", ot);
- var at = function() {
- if (!b && et.readyState === (XMLHttpRequest.DONE || 4)) {
- if (et.removeEventListener("readystatechange", at),
- et.status >= 200 && et.status < 300 || et.status === 0 && (!IsWindowObjectExist() || IsFileURL())) {
- try {
- e(s ? et.response : et.responseText, et)
- } catch (lt) {
- rt(lt)
- }
- return
- }
- var st = FileToolsOptions.DefaultRetryStrategy;
- if (st) {
- var ut = st(_, et, nt);
- if (ut !== -1) {
- et.removeEventListener("loadend", ot),
- et = new WebRequest,
- tt = setTimeout(function() {
- return it(nt + 1)
- }, ut);
- return
- }
- }
- var ct = new RequestFileError("Error status: " + et.status + " " + et.statusText + " - Unable to load " + _,et);
- c && c(ct)
- }
- };
- et.addEventListener("readystatechange", at),
- et.send()
- };
- it(0)
- };
- if (o && o.enableSceneOffline) {
- var $ = function(et) {
- et && et.status > 400 ? c && c(et) : j()
- }
- , _e = function() {
- o && o.loadFile(FileToolsOptions.BaseUrl + a, function(et) {
- b || e(et),
- k.onCompleteObservable.notifyObservers(k)
- }, i ? function(et) {
- b || i(et)
- }
- : void 0, $, s)
- };
- o.open(_e, $)
- } else
- j();
- return k
- }, IsFileURL = function() {
- return typeof location != "undefined" && location.protocol === "file:"
- }, IsBase64DataUrl = function(a) {
- return base64DataUrlRegEx.test(a)
- };
- function DecodeBase64UrlToBinary(a) {
- return DecodeBase64ToBinary(a.split(",")[1])
- }
- var DecodeBase64UrlToString = function(a) {
- return DecodeBase64ToString(a.split(",")[1])
- }
- , initSideEffects$1 = function() {
- ThinEngine._FileToolsLoadImage = LoadImage,
- ThinEngine._FileToolsLoadFile = LoadFile,
- ShaderProcessor._FileToolsLoadFile = LoadFile
- };
- initSideEffects$1();
- _injectLTSFileTools(DecodeBase64UrlToBinary, DecodeBase64UrlToString, FileToolsOptions, IsBase64DataUrl, IsFileURL, LoadFile, LoadImage, ReadFile, RequestFile, SetCorsBehavior);
- var PromiseStates;
- (function(a) {
- a[a.Pending = 0] = "Pending",
- a[a.Fulfilled = 1] = "Fulfilled",
- a[a.Rejected = 2] = "Rejected"
- }
- )(PromiseStates || (PromiseStates = {}));
- var FulFillmentAgregator = function() {
- function a() {
- this.count = 0,
- this.target = 0,
- this.results = []
- }
- return a
- }()
- , InternalPromise = function() {
- function a(e) {
- var i = this;
- if (this._state = PromiseStates.Pending,
- this._children = new Array,
- this._rejectWasConsumed = !1,
- !!e)
- try {
- e(function(o) {
- i._resolve(o)
- }, function(o) {
- i._reject(o)
- })
- } catch (o) {
- this._reject(o)
- }
- }
- return Object.defineProperty(a.prototype, "_result", {
- get: function() {
- return this._resultValue
- },
- set: function(e) {
- this._resultValue = e,
- this._parent && this._parent._result === void 0 && (this._parent._result = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.catch = function(e) {
- return this.then(void 0, e)
- }
- ,
- a.prototype.then = function(e, i) {
- var o = this
- , s = new a;
- return s._onFulfilled = e,
- s._onRejected = i,
- this._children.push(s),
- s._parent = this,
- this._state !== PromiseStates.Pending && setTimeout(function() {
- o._state === PromiseStates.Fulfilled || o._rejectWasConsumed ? s._resolve(o._result) : s._reject(o._reason)
- }),
- s
- }
- ,
- a.prototype._moveChildren = function(e) {
- var i, o = this;
- if ((i = this._children).push.apply(i, e.splice(0, e.length)),
- this._children.forEach(function(k) {
- k._parent = o
- }),
- this._state === PromiseStates.Fulfilled)
- for (var s = 0, c = this._children; s < c.length; s++) {
- var d = c[s];
- d._resolve(this._result)
- }
- else if (this._state === PromiseStates.Rejected)
- for (var _ = 0, b = this._children; _ < b.length; _++) {
- var d = b[_];
- d._reject(this._reason)
- }
- }
- ,
- a.prototype._resolve = function(e) {
- try {
- this._state = PromiseStates.Fulfilled;
- var i = null;
- if (this._onFulfilled && (i = this._onFulfilled(e)),
- i != null)
- if (i._state !== void 0) {
- var o = i;
- o._parent = this,
- o._moveChildren(this._children),
- e = o._result
- } else
- e = i;
- this._result = e;
- for (var s = 0, c = this._children; s < c.length; s++) {
- var d = c[s];
- d._resolve(e)
- }
- this._children.length = 0,
- delete this._onFulfilled,
- delete this._onRejected
- } catch (_) {
- this._reject(_, !0)
- }
- }
- ,
- a.prototype._reject = function(e, i) {
- if (i === void 0 && (i = !1),
- this._state = PromiseStates.Rejected,
- this._reason = e,
- this._onRejected && !i)
- try {
- this._onRejected(e),
- this._rejectWasConsumed = !0
- } catch (d) {
- e = d
- }
- for (var o = 0, s = this._children; o < s.length; o++) {
- var c = s[o];
- this._rejectWasConsumed ? c._resolve(null) : c._reject(e)
- }
- this._children.length = 0,
- delete this._onFulfilled,
- delete this._onRejected
- }
- ,
- a.resolve = function(e) {
- var i = new a;
- return i._resolve(e),
- i
- }
- ,
- a._RegisterForFulfillment = function(e, i, o) {
- e.then(function(s) {
- return i.results[o] = s,
- i.count++,
- i.count === i.target && i.rootPromise._resolve(i.results),
- null
- }, function(s) {
- i.rootPromise._state !== PromiseStates.Rejected && i.rootPromise._reject(s)
- })
- }
- ,
- a.all = function(e) {
- var i = new a
- , o = new FulFillmentAgregator;
- if (o.target = e.length,
- o.rootPromise = i,
- e.length)
- for (var s = 0; s < e.length; s++)
- a._RegisterForFulfillment(e[s], o, s);
- else
- i._resolve([]);
- return i
- }
- ,
- a.race = function(e) {
- var i = new a;
- if (e.length)
- for (var o = 0, s = e; o < s.length; o++) {
- var c = s[o];
- c.then(function(d) {
- return i && (i._resolve(d),
- i = null),
- null
- }, function(d) {
- i && (i._reject(d),
- i = null)
- })
- }
- return i
- }
- ,
- a
- }()
- , PromisePolyfill = function() {
- function a() {}
- return a.Apply = function(e) {
- if (e === void 0 && (e = !1),
- e || typeof Promise == "undefined") {
- var i = window;
- i.Promise = InternalPromise
- }
- }
- ,
- a
- }()
- , _RegisteredTypes = {};
- function RegisterClass(a, e) {
- _RegisteredTypes[a] = e
- }
- function GetClass(a) {
- return _RegisteredTypes[a]
- }
- var InstantiationTools = function() {
- function a() {}
- return a.Instantiate = function(e) {
- if (this.RegisteredExternalClasses && this.RegisteredExternalClasses[e])
- return this.RegisteredExternalClasses[e];
- var i = GetClass(e);
- if (i)
- return i;
- Logger$2.Warn(e + " not found, you may have missed an import.");
- for (var o = e.split("."), s = window || this, c = 0, d = o.length; c < d; c++)
- s = s[o[c]];
- return typeof s != "function" ? null : s
- }
- ,
- a.RegisteredExternalClasses = {},
- a
- }();
- function RandomGUID() {
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(a) {
- var e = Math.random() * 16 | 0
- , i = a === "x" ? e : e & 3 | 8;
- return i.toString(16)
- })
- }
- var SliceTools = function() {
- function a() {}
- return a.Slice = function(e, i, o) {
- return e.slice ? e.slice(i, o) : Array.prototype.slice.call(e, i, o)
- }
- ,
- a.SliceToArray = function(e, i, o) {
- return Array.isArray(e) ? e.slice(i, o) : Array.prototype.slice.call(e, i, o)
- }
- ,
- a
- }()
- , Tools = function() {
- function a() {}
- return Object.defineProperty(a, "BaseUrl", {
- get: function() {
- return FileToolsOptions.BaseUrl
- },
- set: function(e) {
- FileToolsOptions.BaseUrl = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "DefaultRetryStrategy", {
- get: function() {
- return FileToolsOptions.DefaultRetryStrategy
- },
- set: function(e) {
- FileToolsOptions.DefaultRetryStrategy = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "CorsBehavior", {
- get: function() {
- return FileToolsOptions.CorsBehavior
- },
- set: function(e) {
- FileToolsOptions.CorsBehavior = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "UseFallbackTexture", {
- get: function() {
- return EngineStore.UseFallbackTexture
- },
- set: function(e) {
- EngineStore.UseFallbackTexture = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "RegisteredExternalClasses", {
- get: function() {
- return InstantiationTools.RegisteredExternalClasses
- },
- set: function(e) {
- InstantiationTools.RegisteredExternalClasses = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "fallbackTexture", {
- get: function() {
- return EngineStore.FallbackTexture
- },
- set: function(e) {
- EngineStore.FallbackTexture = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.FetchToRef = function(e, i, o, s, c, d) {
- var _ = Math.abs(e) * o % o | 0
- , b = Math.abs(i) * s % s | 0
- , k = (_ + b * o) * 4;
- d.r = c[k] / 255,
- d.g = c[k + 1] / 255,
- d.b = c[k + 2] / 255,
- d.a = c[k + 3] / 255
- }
- ,
- a.Mix = function(e, i, o) {
- return e * (1 - o) + i * o
- }
- ,
- a.Instantiate = function(e) {
- return InstantiationTools.Instantiate(e)
- }
- ,
- a.Slice = function(e, i, o) {
- return SliceTools.Slice(e, i, o)
- }
- ,
- a.SliceToArray = function(e, i, o) {
- return SliceTools.SliceToArray(e, i, o)
- }
- ,
- a.SetImmediate = function(e) {
- TimingTools.SetImmediate(e)
- }
- ,
- a.IsExponentOfTwo = function(e) {
- var i = 1;
- do
- i *= 2;
- while (i < e);
- return i === e
- }
- ,
- a.FloatRound = function(e) {
- return Math.fround ? Math.fround(e) : (a._tmpFloatArray[0] = e,
- a._tmpFloatArray[0])
- }
- ,
- a.GetFilename = function(e) {
- var i = e.lastIndexOf("/");
- return i < 0 ? e : e.substring(i + 1)
- }
- ,
- a.GetFolderPath = function(e, i) {
- i === void 0 && (i = !1);
- var o = e.lastIndexOf("/");
- return o < 0 ? i ? e : "" : e.substring(0, o + 1)
- }
- ,
- a.ToDegrees = function(e) {
- return e * 180 / Math.PI
- }
- ,
- a.ToRadians = function(e) {
- return e * Math.PI / 180
- }
- ,
- a.MakeArray = function(e, i) {
- return i !== !0 && (e === void 0 || e == null) ? null : Array.isArray(e) ? e : [e]
- }
- ,
- a.GetPointerPrefix = function(e) {
- var i = "pointer";
- return IsWindowObjectExist() && !window.PointerEvent && IsNavigatorAvailable() && !navigator.pointerEnabled && (i = "mouse"),
- e._badDesktopOS && !e._badOS && !(document && "ontouchend"in document) && (i = "mouse"),
- i
- }
- ,
- a.SetCorsBehavior = function(e, i) {
- SetCorsBehavior(e, i)
- }
- ,
- a.CleanUrl = function(e) {
- return e = e.replace(/#/gm, "%23"),
- e
- }
- ,
- Object.defineProperty(a, "PreprocessUrl", {
- get: function() {
- return FileToolsOptions.PreprocessUrl
- },
- set: function(e) {
- FileToolsOptions.PreprocessUrl = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.LoadImage = function(e, i, o, s, c, d) {
- return LoadImage(e, i, o, s, c, d)
- }
- ,
- a.LoadFile = function(e, i, o, s, c, d) {
- return LoadFile(e, i, o, s, c, d)
- }
- ,
- a.LoadFileAsync = function(e, i) {
- return i === void 0 && (i = !0),
- new Promise(function(o, s) {
- LoadFile(e, function(c) {
- o(c)
- }, void 0, void 0, i, function(c, d) {
- s(d)
- })
- }
- )
- }
- ,
- a.LoadScript = function(e, i, o, s) {
- if (!!IsWindowObjectExist()) {
- var c = document.getElementsByTagName("head")[0]
- , d = document.createElement("script");
- d.setAttribute("type", "text/javascript"),
- d.setAttribute("src", e),
- s && (d.id = s),
- d.onload = function() {
- i && i()
- }
- ,
- d.onerror = function(_) {
- o && o("Unable to load script '" + e + "'", _)
- }
- ,
- c.appendChild(d)
- }
- }
- ,
- a.LoadScriptAsync = function(e, i) {
- var o = this;
- return new Promise(function(s, c) {
- o.LoadScript(e, function() {
- s()
- }, function(d, _) {
- c(_)
- })
- }
- )
- }
- ,
- a.ReadFileAsDataURL = function(e, i, o) {
- var s = new FileReader
- , c = {
- onCompleteObservable: new Observable,
- abort: function() {
- return s.abort()
- }
- };
- return s.onloadend = function(d) {
- c.onCompleteObservable.notifyObservers(c)
- }
- ,
- s.onload = function(d) {
- i(d.target.result)
- }
- ,
- s.onprogress = o,
- s.readAsDataURL(e),
- c
- }
- ,
- a.ReadFile = function(e, i, o, s, c) {
- return ReadFile(e, i, o, s, c)
- }
- ,
- a.FileAsURL = function(e) {
- var i = new Blob([e])
- , o = window.URL || window.webkitURL
- , s = o.createObjectURL(i);
- return s
- }
- ,
- a.Format = function(e, i) {
- return i === void 0 && (i = 2),
- e.toFixed(i)
- }
- ,
- a.DeepCopy = function(e, i, o, s) {
- DeepCopier.DeepCopy(e, i, o, s)
- }
- ,
- a.IsEmpty = function(e) {
- for (var i in e)
- if (e.hasOwnProperty(i))
- return !1;
- return !0
- }
- ,
- a.RegisterTopRootEvents = function(e, i) {
- for (var o = 0; o < i.length; o++) {
- var s = i[o];
- e.addEventListener(s.name, s.handler, !1);
- try {
- window.parent && window.parent.addEventListener(s.name, s.handler, !1)
- } catch {}
- }
- }
- ,
- a.UnregisterTopRootEvents = function(e, i) {
- for (var o = 0; o < i.length; o++) {
- var s = i[o];
- e.removeEventListener(s.name, s.handler);
- try {
- e.parent && e.parent.removeEventListener(s.name, s.handler)
- } catch {}
- }
- }
- ,
- a.DumpFramebuffer = function(e, i, o, s, c, d) {
- return c === void 0 && (c = "image/png"),
- __awaiter(this, void 0, void 0, function() {
- var _, b;
- return __generator(this, function(k) {
- switch (k.label) {
- case 0:
- return [4, o.readPixels(0, 0, e, i)];
- case 1:
- return _ = k.sent(),
- b = new Uint8Array(_.buffer),
- a.DumpData(e, i, b, s, c, d, !0),
- [2]
- }
- })
- })
- }
- ,
- a.DumpData = function(e, i, o, s, c, d, _, b, k) {
- c === void 0 && (c = "image/png"),
- _ === void 0 && (_ = !1),
- b === void 0 && (b = !1),
- a._ScreenshotCanvas || (a._ScreenshotCanvas = document.createElement("canvas")),
- a._ScreenshotCanvas.width = e,
- a._ScreenshotCanvas.height = i;
- var j = a._ScreenshotCanvas.getContext("2d");
- if (j) {
- if (o instanceof Float32Array) {
- for (var $ = new Uint8Array(o.length), _e = o.length; _e--; ) {
- var et = o[_e];
- $[_e] = et < 0 ? 0 : et > 1 ? 1 : Math.round(et * 255)
- }
- o = $
- }
- var tt = j.createImageData(e, i)
- , rt = tt.data;
- rt.set(o),
- j.putImageData(tt, 0, 0);
- var it = a._ScreenshotCanvas;
- if (_) {
- var nt = document.createElement("canvas");
- nt.width = e,
- nt.height = i;
- var ot = nt.getContext("2d");
- if (!ot)
- return;
- ot.translate(0, i),
- ot.scale(1, -1),
- ot.drawImage(a._ScreenshotCanvas, 0, 0),
- it = nt
- }
- b ? a.ToBlob(it, function(at) {
- var st = new FileReader;
- st.onload = function(ut) {
- var ct = ut.target.result;
- s && s(ct)
- }
- ,
- st.readAsArrayBuffer(at)
- }, c, k) : a.EncodeScreenshotCanvasData(s, c, d, it, k)
- }
- }
- ,
- a.DumpDataAsync = function(e, i, o, s, c, d, _, b) {
- return s === void 0 && (s = "image/png"),
- d === void 0 && (d = !1),
- _ === void 0 && (_ = !1),
- new Promise(function(k) {
- a.DumpData(e, i, o, function(j) {
- return k(j)
- }, s, c, d, _, b)
- }
- )
- }
- ,
- a.ToBlob = function(e, i, o, s) {
- o === void 0 && (o = "image/png"),
- e.toBlob || (e.toBlob = function(c, d, _) {
- var b = this;
- setTimeout(function() {
- for (var k = atob(b.toDataURL(d, _).split(",")[1]), j = k.length, $ = new Uint8Array(j), _e = 0; _e < j; _e++)
- $[_e] = k.charCodeAt(_e);
- c(new Blob([$]))
- })
- }
- ),
- e.toBlob(function(c) {
- i(c)
- }, o, s)
- }
- ,
- a.EncodeScreenshotCanvasData = function(e, i, o, s, c) {
- if (i === void 0 && (i = "image/png"),
- e) {
- var d = (s != null ? s : a._ScreenshotCanvas).toDataURL(i, c);
- e(d)
- } else
- this.ToBlob(s != null ? s : a._ScreenshotCanvas, function(_) {
- if ("download"in document.createElement("a")) {
- if (!o) {
- var b = new Date
- , k = (b.getFullYear() + "-" + (b.getMonth() + 1)).slice(2) + "-" + b.getDate() + "_" + b.getHours() + "-" + ("0" + b.getMinutes()).slice(-2);
- o = "screenshot_" + k + ".png"
- }
- a.Download(_, o)
- } else {
- var j = URL.createObjectURL(_)
- , $ = window.open("");
- if (!$)
- return;
- var _e = $.document.createElement("img");
- _e.onload = function() {
- URL.revokeObjectURL(j)
- }
- ,
- _e.src = j,
- $.document.body.appendChild(_e)
- }
- }, i, c)
- }
- ,
- a.Download = function(e, i) {
- if (navigator && navigator.msSaveBlob) {
- navigator.msSaveBlob(e, i);
- return
- }
- var o = window.URL.createObjectURL(e)
- , s = document.createElement("a");
- document.body.appendChild(s),
- s.style.display = "none",
- s.href = o,
- s.download = i,
- s.addEventListener("click", function() {
- s.parentElement && s.parentElement.removeChild(s)
- }),
- s.click(),
- window.URL.revokeObjectURL(o)
- }
- ,
- a.BackCompatCameraNoPreventDefault = function(e) {
- return typeof e[0] == "boolean" ? e[0] : typeof e[1] == "boolean" ? e[1] : !1
- }
- ,
- a.CreateScreenshot = function(e, i, o, s, c) {
- throw _WarnImport("ScreenshotTools")
- }
- ,
- a.CreateScreenshotAsync = function(e, i, o, s) {
- throw _WarnImport("ScreenshotTools")
- }
- ,
- a.CreateScreenshotUsingRenderTarget = function(e, i, o, s, c, d, _, b) {
- throw _WarnImport("ScreenshotTools")
- }
- ,
- a.CreateScreenshotUsingRenderTargetAsync = function(e, i, o, s, c, d, _) {
- throw _WarnImport("ScreenshotTools")
- }
- ,
- a.RandomId = function() {
- return RandomGUID()
- }
- ,
- a.IsBase64 = function(e) {
- return IsBase64DataUrl(e)
- }
- ,
- a.DecodeBase64 = function(e) {
- return DecodeBase64UrlToBinary(e)
- }
- ,
- Object.defineProperty(a, "errorsCount", {
- get: function() {
- return Logger$2.errorsCount
- },
- enumerable: !1,
- configurable: !0
- }),
- a.Log = function(e) {
- Logger$2.Log(e)
- }
- ,
- a.Warn = function(e) {
- Logger$2.Warn(e)
- }
- ,
- a.Error = function(e) {
- Logger$2.Error(e)
- }
- ,
- Object.defineProperty(a, "LogCache", {
- get: function() {
- return Logger$2.LogCache
- },
- enumerable: !1,
- configurable: !0
- }),
- a.ClearLogCache = function() {
- Logger$2.ClearLogCache()
- }
- ,
- Object.defineProperty(a, "LogLevels", {
- set: function(e) {
- Logger$2.LogLevels = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "PerformanceLogLevel", {
- set: function(e) {
- if ((e & a.PerformanceUserMarkLogLevel) === a.PerformanceUserMarkLogLevel) {
- a.StartPerformanceCounter = a._StartUserMark,
- a.EndPerformanceCounter = a._EndUserMark;
- return
- }
- if ((e & a.PerformanceConsoleLogLevel) === a.PerformanceConsoleLogLevel) {
- a.StartPerformanceCounter = a._StartPerformanceConsole,
- a.EndPerformanceCounter = a._EndPerformanceConsole;
- return
- }
- a.StartPerformanceCounter = a._StartPerformanceCounterDisabled,
- a.EndPerformanceCounter = a._EndPerformanceCounterDisabled
- },
- enumerable: !1,
- configurable: !0
- }),
- a._StartPerformanceCounterDisabled = function(e, i) {}
- ,
- a._EndPerformanceCounterDisabled = function(e, i) {}
- ,
- a._StartUserMark = function(e, i) {
- if (i === void 0 && (i = !0),
- !a._performance) {
- if (!IsWindowObjectExist())
- return;
- a._performance = window.performance
- }
- !i || !a._performance.mark || a._performance.mark(e + "-Begin")
- }
- ,
- a._EndUserMark = function(e, i) {
- i === void 0 && (i = !0),
- !(!i || !a._performance.mark) && (a._performance.mark(e + "-End"),
- a._performance.measure(e, e + "-Begin", e + "-End"))
- }
- ,
- a._StartPerformanceConsole = function(e, i) {
- i === void 0 && (i = !0),
- i && (a._StartUserMark(e, i),
- console.time && console.time(e))
- }
- ,
- a._EndPerformanceConsole = function(e, i) {
- i === void 0 && (i = !0),
- i && (a._EndUserMark(e, i),
- console.timeEnd(e))
- }
- ,
- Object.defineProperty(a, "Now", {
- get: function() {
- return PrecisionDate.Now
- },
- enumerable: !1,
- configurable: !0
- }),
- a.GetClassName = function(e, i) {
- i === void 0 && (i = !1);
- var o = null;
- if (!i && e.getClassName)
- o = e.getClassName();
- else {
- if (e instanceof Object) {
- var s = i ? e : Object.getPrototypeOf(e);
- o = s.constructor.__bjsclassName__
- }
- o || (o = typeof e)
- }
- return o
- }
- ,
- a.First = function(e, i) {
- for (var o = 0, s = e; o < s.length; o++) {
- var c = s[o];
- if (i(c))
- return c
- }
- return null
- }
- ,
- a.getFullClassName = function(e, i) {
- i === void 0 && (i = !1);
- var o = null
- , s = null;
- if (!i && e.getClassName)
- o = e.getClassName();
- else {
- if (e instanceof Object) {
- var c = i ? e : Object.getPrototypeOf(e);
- o = c.constructor.__bjsclassName__,
- s = c.constructor.__bjsmoduleName__
- }
- o || (o = typeof e)
- }
- return o ? (s != null ? s + "." : "") + o : null
- }
- ,
- a.DelayAsync = function(e) {
- return new Promise(function(i) {
- setTimeout(function() {
- i()
- }, e)
- }
- )
- }
- ,
- a.IsSafari = function() {
- return IsNavigatorAvailable() ? /^((?!chrome|android).)*safari/i.test(navigator.userAgent) : !1
- }
- ,
- a.UseCustomRequestHeaders = !1,
- a.CustomRequestHeaders = WebRequest.CustomRequestHeaders,
- a._tmpFloatArray = new Float32Array(1),
- a.GetDOMTextContent = GetDOMTextContent,
- a.GetAbsoluteUrl = typeof document == "object" ? function(e) {
- var i = document.createElement("a");
- return i.href = e,
- i.href
- }
- : typeof URL == "function" && typeof location == "object" ? function(e) {
- return new URL(e,location.origin).href
- }
- : function(e) {
- throw new Error("Unable to get absolute URL. Override BABYLON.Tools.GetAbsoluteUrl to a custom implementation for the current context.")
- }
- ,
- a.NoneLogLevel = Logger$2.NoneLogLevel,
- a.MessageLogLevel = Logger$2.MessageLogLevel,
- a.WarningLogLevel = Logger$2.WarningLogLevel,
- a.ErrorLogLevel = Logger$2.ErrorLogLevel,
- a.AllLogLevel = Logger$2.AllLogLevel,
- a.IsWindowObjectExist = IsWindowObjectExist,
- a.PerformanceNoneLogLevel = 0,
- a.PerformanceUserMarkLogLevel = 1,
- a.PerformanceConsoleLogLevel = 2,
- a.StartPerformanceCounter = a._StartPerformanceCounterDisabled,
- a.EndPerformanceCounter = a._EndPerformanceCounterDisabled,
- a
- }()
- , AsyncLoop = function() {
- function a(e, i, o, s) {
- s === void 0 && (s = 0),
- this.iterations = e,
- this.index = s - 1,
- this._done = !1,
- this._fn = i,
- this._successCallback = o
- }
- return a.prototype.executeNext = function() {
- this._done || (this.index + 1 < this.iterations ? (++this.index,
- this._fn(this)) : this.breakLoop())
- }
- ,
- a.prototype.breakLoop = function() {
- this._done = !0,
- this._successCallback()
- }
- ,
- a.Run = function(e, i, o, s) {
- s === void 0 && (s = 0);
- var c = new a(e,i,o,s);
- return c.executeNext(),
- c
- }
- ,
- a.SyncAsyncForLoop = function(e, i, o, s, c, d) {
- return d === void 0 && (d = 0),
- a.Run(Math.ceil(e / i), function(_) {
- c && c() ? _.breakLoop() : setTimeout(function() {
- for (var b = 0; b < i; ++b) {
- var k = _.index * i + b;
- if (k >= e)
- break;
- if (o(k),
- c && c()) {
- _.breakLoop();
- break
- }
- }
- _.executeNext()
- }, d)
- }, s)
- }
- ,
- a
- }();
- 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";
- PromisePolyfill.Apply();
- var Scalar = function() {
- function a() {}
- return a.WithinEpsilon = function(e, i, o) {
- return o === void 0 && (o = 1401298e-51),
- Math.abs(e - i) <= o
- }
- ,
- a.ToHex = function(e) {
- var i = e.toString(16);
- return e <= 15 ? ("0" + i).toUpperCase() : i.toUpperCase()
- }
- ,
- a.Sign = function(e) {
- return e = +e,
- e === 0 || isNaN(e) ? e : e > 0 ? 1 : -1
- }
- ,
- a.Clamp = function(e, i, o) {
- return i === void 0 && (i = 0),
- o === void 0 && (o = 1),
- Math.min(o, Math.max(i, e))
- }
- ,
- a.Log2 = function(e) {
- return Math.log(e) * Math.LOG2E
- }
- ,
- a.ILog2 = function(e) {
- if (Math.log2)
- return Math.floor(Math.log2(e));
- if (e < 0)
- return NaN;
- if (e === 0)
- return -1 / 0;
- var i = 0;
- if (e < 1) {
- for (; e < 1; )
- i++,
- e = e * 2;
- i = -i
- } else if (e > 1)
- for (; e > 1; )
- i++,
- e = Math.floor(e / 2);
- return i
- }
- ,
- a.Repeat = function(e, i) {
- return e - Math.floor(e / i) * i
- }
- ,
- a.Normalize = function(e, i, o) {
- return (e - i) / (o - i)
- }
- ,
- a.Denormalize = function(e, i, o) {
- return e * (o - i) + i
- }
- ,
- a.DeltaAngle = function(e, i) {
- var o = a.Repeat(i - e, 360);
- return o > 180 && (o -= 360),
- o
- }
- ,
- a.PingPong = function(e, i) {
- var o = a.Repeat(e, i * 2);
- return i - Math.abs(o - i)
- }
- ,
- a.SmoothStep = function(e, i, o) {
- var s = a.Clamp(o);
- return s = -2 * s * s * s + 3 * s * s,
- i * s + e * (1 - s)
- }
- ,
- a.MoveTowards = function(e, i, o) {
- var s = 0;
- return Math.abs(i - e) <= o ? s = i : s = e + a.Sign(i - e) * o,
- s
- }
- ,
- a.MoveTowardsAngle = function(e, i, o) {
- var s = a.DeltaAngle(e, i)
- , c = 0;
- return -o < s && s < o ? c = i : (i = e + s,
- c = a.MoveTowards(e, i, o)),
- c
- }
- ,
- a.Lerp = function(e, i, o) {
- return e + (i - e) * o
- }
- ,
- a.LerpAngle = function(e, i, o) {
- var s = a.Repeat(i - e, 360);
- return s > 180 && (s -= 360),
- e + s * a.Clamp(o)
- }
- ,
- a.InverseLerp = function(e, i, o) {
- var s = 0;
- return e != i ? s = a.Clamp((o - e) / (i - e)) : s = 0,
- s
- }
- ,
- a.Hermite = function(e, i, o, s, c) {
- var d = c * c
- , _ = c * d
- , b = 2 * _ - 3 * d + 1
- , k = -2 * _ + 3 * d
- , j = _ - 2 * d + c
- , $ = _ - d;
- return e * b + o * k + i * j + s * $
- }
- ,
- a.Hermite1stDerivative = function(e, i, o, s, c) {
- var d = c * c;
- return (d - c) * 6 * e + (3 * d - 4 * c + 1) * i + (-d + c) * 6 * o + (3 * d - 2 * c) * s
- }
- ,
- a.RandomRange = function(e, i) {
- return e === i ? e : Math.random() * (i - e) + e
- }
- ,
- a.RangeToPercent = function(e, i, o) {
- return (e - i) / (o - i)
- }
- ,
- a.PercentToRange = function(e, i, o) {
- return (o - i) * e + i
- }
- ,
- a.NormalizeRadians = function(e) {
- return e -= a.TwoPi * Math.floor((e + Math.PI) / a.TwoPi),
- e
- }
- ,
- a.HCF = function(e, i) {
- var o = e % i;
- return o === 0 ? i : a.HCF(i, o)
- }
- ,
- a.TwoPi = Math.PI * 2,
- a
- }()
- , ToGammaSpace = 1 / 2.2
- , ToLinearSpace = 2.2
- , PHI = (1 + Math.sqrt(5)) / 2
- , Epsilon = .001
- , ArrayTools = function() {
- function a() {}
- return a.BuildArray = function(e, i) {
- for (var o = [], s = 0; s < e; ++s)
- o.push(i());
- return o
- }
- ,
- a.BuildTuple = function(e, i) {
- return a.BuildArray(e, i)
- }
- ,
- a
- }()
- , Vector2 = function() {
- function a(e, i) {
- e === void 0 && (e = 0),
- i === void 0 && (i = 0),
- this.x = e,
- this.y = i
- }
- return a.prototype.toString = function() {
- return "{X: " + this.x + " Y: " + this.y + "}"
- }
- ,
- a.prototype.getClassName = function() {
- return "Vector2"
- }
- ,
- a.prototype.getHashCode = function() {
- var e = this.x | 0;
- return e = e * 397 ^ (this.y | 0),
- e
- }
- ,
- a.prototype.toArray = function(e, i) {
- return i === void 0 && (i = 0),
- e[i] = this.x,
- e[i + 1] = this.y,
- this
- }
- ,
- a.prototype.fromArray = function(e, i) {
- return i === void 0 && (i = 0),
- a.FromArrayToRef(e, i, this),
- this
- }
- ,
- a.prototype.asArray = function() {
- var e = new Array;
- return this.toArray(e, 0),
- e
- }
- ,
- a.prototype.copyFrom = function(e) {
- return this.x = e.x,
- this.y = e.y,
- this
- }
- ,
- a.prototype.copyFromFloats = function(e, i) {
- return this.x = e,
- this.y = i,
- this
- }
- ,
- a.prototype.set = function(e, i) {
- return this.copyFromFloats(e, i)
- }
- ,
- a.prototype.add = function(e) {
- return new a(this.x + e.x,this.y + e.y)
- }
- ,
- a.prototype.addToRef = function(e, i) {
- return i.x = this.x + e.x,
- i.y = this.y + e.y,
- this
- }
- ,
- a.prototype.addInPlace = function(e) {
- return this.x += e.x,
- this.y += e.y,
- this
- }
- ,
- a.prototype.addVector3 = function(e) {
- return new a(this.x + e.x,this.y + e.y)
- }
- ,
- a.prototype.subtract = function(e) {
- return new a(this.x - e.x,this.y - e.y)
- }
- ,
- a.prototype.subtractToRef = function(e, i) {
- return i.x = this.x - e.x,
- i.y = this.y - e.y,
- this
- }
- ,
- a.prototype.subtractInPlace = function(e) {
- return this.x -= e.x,
- this.y -= e.y,
- this
- }
- ,
- a.prototype.multiplyInPlace = function(e) {
- return this.x *= e.x,
- this.y *= e.y,
- this
- }
- ,
- a.prototype.multiply = function(e) {
- return new a(this.x * e.x,this.y * e.y)
- }
- ,
- a.prototype.multiplyToRef = function(e, i) {
- return i.x = this.x * e.x,
- i.y = this.y * e.y,
- this
- }
- ,
- a.prototype.multiplyByFloats = function(e, i) {
- return new a(this.x * e,this.y * i)
- }
- ,
- a.prototype.divide = function(e) {
- return new a(this.x / e.x,this.y / e.y)
- }
- ,
- a.prototype.divideToRef = function(e, i) {
- return i.x = this.x / e.x,
- i.y = this.y / e.y,
- this
- }
- ,
- a.prototype.divideInPlace = function(e) {
- return this.divideToRef(e, this)
- }
- ,
- a.prototype.negate = function() {
- return new a(-this.x,-this.y)
- }
- ,
- a.prototype.negateInPlace = function() {
- return this.x *= -1,
- this.y *= -1,
- this
- }
- ,
- a.prototype.negateToRef = function(e) {
- return e.copyFromFloats(this.x * -1, this.y * -1)
- }
- ,
- a.prototype.scaleInPlace = function(e) {
- return this.x *= e,
- this.y *= e,
- this
- }
- ,
- a.prototype.scale = function(e) {
- var i = new a(0,0);
- return this.scaleToRef(e, i),
- i
- }
- ,
- a.prototype.scaleToRef = function(e, i) {
- return i.x = this.x * e,
- i.y = this.y * e,
- this
- }
- ,
- a.prototype.scaleAndAddToRef = function(e, i) {
- return i.x += this.x * e,
- i.y += this.y * e,
- this
- }
- ,
- a.prototype.equals = function(e) {
- return e && this.x === e.x && this.y === e.y
- }
- ,
- a.prototype.equalsWithEpsilon = function(e, i) {
- return i === void 0 && (i = Epsilon),
- e && Scalar.WithinEpsilon(this.x, e.x, i) && Scalar.WithinEpsilon(this.y, e.y, i)
- }
- ,
- a.prototype.floor = function() {
- return new a(Math.floor(this.x),Math.floor(this.y))
- }
- ,
- a.prototype.fract = function() {
- return new a(this.x - Math.floor(this.x),this.y - Math.floor(this.y))
- }
- ,
- a.prototype.rotateToRef = function(e, i) {
- var o = Math.cos(e)
- , s = Math.sin(e);
- return i.x = o * this.x - s * this.y,
- i.y = s * this.x + o * this.y,
- this
- }
- ,
- a.prototype.length = function() {
- return Math.sqrt(this.x * this.x + this.y * this.y)
- }
- ,
- a.prototype.lengthSquared = function() {
- return this.x * this.x + this.y * this.y
- }
- ,
- a.prototype.normalize = function() {
- return a.NormalizeToRef(this, this),
- this
- }
- ,
- a.prototype.clone = function() {
- return new a(this.x,this.y)
- }
- ,
- a.Zero = function() {
- return new a(0,0)
- }
- ,
- a.One = function() {
- return new a(1,1)
- }
- ,
- a.FromArray = function(e, i) {
- return i === void 0 && (i = 0),
- new a(e[i],e[i + 1])
- }
- ,
- a.FromArrayToRef = function(e, i, o) {
- o.x = e[i],
- o.y = e[i + 1]
- }
- ,
- a.CatmullRom = function(e, i, o, s, c) {
- var d = c * c
- , _ = c * d
- , 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) * _)
- , 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) * _);
- return new a(b,k)
- }
- ,
- a.Clamp = function(e, i, o) {
- var s = e.x;
- s = s > o.x ? o.x : s,
- s = s < i.x ? i.x : s;
- var c = e.y;
- return c = c > o.y ? o.y : c,
- c = c < i.y ? i.y : c,
- new a(s,c)
- }
- ,
- a.Hermite = function(e, i, o, s, c) {
- var d = c * c
- , _ = c * d
- , b = 2 * _ - 3 * d + 1
- , k = -2 * _ + 3 * d
- , j = _ - 2 * d + c
- , $ = _ - d
- , _e = e.x * b + o.x * k + i.x * j + s.x * $
- , et = e.y * b + o.y * k + i.y * j + s.y * $;
- return new a(_e,et)
- }
- ,
- a.Hermite1stDerivative = function(e, i, o, s, c) {
- var d = a.Zero();
- return this.Hermite1stDerivativeToRef(e, i, o, s, c, d),
- d
- }
- ,
- a.Hermite1stDerivativeToRef = function(e, i, o, s, c, d) {
- var _ = c * c;
- d.x = (_ - c) * 6 * e.x + (3 * _ - 4 * c + 1) * i.x + (-_ + c) * 6 * o.x + (3 * _ - 2 * c) * s.x,
- d.y = (_ - c) * 6 * e.y + (3 * _ - 4 * c + 1) * i.y + (-_ + c) * 6 * o.y + (3 * _ - 2 * c) * s.y
- }
- ,
- a.Lerp = function(e, i, o) {
- var s = e.x + (i.x - e.x) * o
- , c = e.y + (i.y - e.y) * o;
- return new a(s,c)
- }
- ,
- a.Dot = function(e, i) {
- return e.x * i.x + e.y * i.y
- }
- ,
- a.Normalize = function(e) {
- var i = a.Zero();
- return this.NormalizeToRef(e, i),
- i
- }
- ,
- a.NormalizeToRef = function(e, i) {
- var o = e.length();
- o !== 0 && (i.x = e.x / o,
- i.y = e.y / o)
- }
- ,
- a.Minimize = function(e, i) {
- var o = e.x < i.x ? e.x : i.x
- , s = e.y < i.y ? e.y : i.y;
- return new a(o,s)
- }
- ,
- a.Maximize = function(e, i) {
- var o = e.x > i.x ? e.x : i.x
- , s = e.y > i.y ? e.y : i.y;
- return new a(o,s)
- }
- ,
- a.Transform = function(e, i) {
- var o = a.Zero();
- return a.TransformToRef(e, i, o),
- o
- }
- ,
- a.TransformToRef = function(e, i, o) {
- var s = i.m
- , c = e.x * s[0] + e.y * s[4] + s[12]
- , d = e.x * s[1] + e.y * s[5] + s[13];
- o.x = c,
- o.y = d
- }
- ,
- a.PointInTriangle = function(e, i, o, s) {
- var c = .5 * (-o.y * s.x + i.y * (-o.x + s.x) + i.x * (o.y - s.y) + o.x * s.y)
- , d = c < 0 ? -1 : 1
- , _ = (i.y * s.x - i.x * s.y + (s.y - i.y) * e.x + (i.x - s.x) * e.y) * d
- , b = (i.x * o.y - i.y * o.x + (i.y - o.y) * e.x + (o.x - i.x) * e.y) * d;
- return _ > 0 && b > 0 && _ + b < 2 * c * d
- }
- ,
- a.Distance = function(e, i) {
- return Math.sqrt(a.DistanceSquared(e, i))
- }
- ,
- a.DistanceSquared = function(e, i) {
- var o = e.x - i.x
- , s = e.y - i.y;
- return o * o + s * s
- }
- ,
- a.Center = function(e, i) {
- return a.CenterToRef(e, i, a.Zero())
- }
- ,
- a.CenterToRef = function(e, i, o) {
- return o.copyFromFloats((e.x + i.x) / 2, (e.y + i.y) / 2)
- }
- ,
- a.DistanceOfPointFromSegment = function(e, i, o) {
- var s = a.DistanceSquared(i, o);
- if (s === 0)
- return a.Distance(e, i);
- var c = o.subtract(i)
- , d = Math.max(0, Math.min(1, a.Dot(e.subtract(i), c) / s))
- , _ = i.add(c.multiplyByFloats(d, d));
- return a.Distance(e, _)
- }
- ,
- a
- }()
- , Vector3 = function() {
- function a(e, i, o) {
- e === void 0 && (e = 0),
- i === void 0 && (i = 0),
- o === void 0 && (o = 0),
- this._isDirty = !0,
- this._x = e,
- this._y = i,
- this._z = o
- }
- return Object.defineProperty(a.prototype, "x", {
- get: function() {
- return this._x
- },
- set: function(e) {
- this._x = e,
- this._isDirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "y", {
- get: function() {
- return this._y
- },
- set: function(e) {
- this._y = e,
- this._isDirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "z", {
- get: function() {
- return this._z
- },
- set: function(e) {
- this._z = e,
- this._isDirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.toString = function() {
- return "{X: " + this._x + " Y: " + this._y + " Z: " + this._z + "}"
- }
- ,
- a.prototype.getClassName = function() {
- return "Vector3"
- }
- ,
- a.prototype.getHashCode = function() {
- var e = this._x | 0;
- return e = e * 397 ^ (this._y | 0),
- e = e * 397 ^ (this._z | 0),
- e
- }
- ,
- a.prototype.asArray = function() {
- var e = [];
- return this.toArray(e, 0),
- e
- }
- ,
- a.prototype.toArray = function(e, i) {
- return i === void 0 && (i = 0),
- e[i] = this._x,
- e[i + 1] = this._y,
- e[i + 2] = this._z,
- this
- }
- ,
- a.prototype.fromArray = function(e, i) {
- return i === void 0 && (i = 0),
- a.FromArrayToRef(e, i, this),
- this
- }
- ,
- a.prototype.toQuaternion = function() {
- return Quaternion.RotationYawPitchRoll(this._y, this._x, this._z)
- }
- ,
- a.prototype.addInPlace = function(e) {
- return this.addInPlaceFromFloats(e._x, e._y, e._z)
- }
- ,
- a.prototype.addInPlaceFromFloats = function(e, i, o) {
- return this.x += e,
- this.y += i,
- this.z += o,
- this
- }
- ,
- a.prototype.add = function(e) {
- return new a(this._x + e._x,this._y + e._y,this._z + e._z)
- }
- ,
- a.prototype.addToRef = function(e, i) {
- return i.copyFromFloats(this._x + e._x, this._y + e._y, this._z + e._z)
- }
- ,
- a.prototype.subtractInPlace = function(e) {
- return this.x -= e._x,
- this.y -= e._y,
- this.z -= e._z,
- this
- }
- ,
- a.prototype.subtract = function(e) {
- return new a(this._x - e._x,this._y - e._y,this._z - e._z)
- }
- ,
- a.prototype.subtractToRef = function(e, i) {
- return this.subtractFromFloatsToRef(e._x, e._y, e._z, i)
- }
- ,
- a.prototype.subtractFromFloats = function(e, i, o) {
- return new a(this._x - e,this._y - i,this._z - o)
- }
- ,
- a.prototype.subtractFromFloatsToRef = function(e, i, o, s) {
- return s.copyFromFloats(this._x - e, this._y - i, this._z - o)
- }
- ,
- a.prototype.negate = function() {
- return new a(-this._x,-this._y,-this._z)
- }
- ,
- a.prototype.negateInPlace = function() {
- return this.x *= -1,
- this.y *= -1,
- this.z *= -1,
- this
- }
- ,
- a.prototype.negateToRef = function(e) {
- return e.copyFromFloats(this._x * -1, this._y * -1, this._z * -1)
- }
- ,
- a.prototype.scaleInPlace = function(e) {
- return this.x *= e,
- this.y *= e,
- this.z *= e,
- this
- }
- ,
- a.prototype.scale = function(e) {
- return new a(this._x * e,this._y * e,this._z * e)
- }
- ,
- a.prototype.scaleToRef = function(e, i) {
- return i.copyFromFloats(this._x * e, this._y * e, this._z * e)
- }
- ,
- a.prototype.scaleAndAddToRef = function(e, i) {
- return i.addInPlaceFromFloats(this._x * e, this._y * e, this._z * e)
- }
- ,
- a.prototype.projectOnPlane = function(e, i) {
- var o = a.Zero();
- return this.projectOnPlaneToRef(e, i, o),
- o
- }
- ,
- a.prototype.projectOnPlaneToRef = function(e, i, o) {
- var s = e.normal
- , c = e.d
- , d = MathTmp.Vector3[0];
- this.subtractToRef(i, d),
- d.normalize();
- var _ = a.Dot(d, s)
- , b = -(a.Dot(i, s) + c) / _
- , k = d.scaleInPlace(b);
- i.addToRef(k, o)
- }
- ,
- a.prototype.equals = function(e) {
- return e && this._x === e._x && this._y === e._y && this._z === e._z
- }
- ,
- a.prototype.equalsWithEpsilon = function(e, i) {
- return i === void 0 && (i = Epsilon),
- e && Scalar.WithinEpsilon(this._x, e._x, i) && Scalar.WithinEpsilon(this._y, e._y, i) && Scalar.WithinEpsilon(this._z, e._z, i)
- }
- ,
- a.prototype.equalsToFloats = function(e, i, o) {
- return this._x === e && this._y === i && this._z === o
- }
- ,
- a.prototype.multiplyInPlace = function(e) {
- return this.x *= e._x,
- this.y *= e._y,
- this.z *= e._z,
- this
- }
- ,
- a.prototype.multiply = function(e) {
- return this.multiplyByFloats(e._x, e._y, e._z)
- }
- ,
- a.prototype.multiplyToRef = function(e, i) {
- return i.copyFromFloats(this._x * e._x, this._y * e._y, this._z * e._z)
- }
- ,
- a.prototype.multiplyByFloats = function(e, i, o) {
- return new a(this._x * e,this._y * i,this._z * o)
- }
- ,
- a.prototype.divide = function(e) {
- return new a(this._x / e._x,this._y / e._y,this._z / e._z)
- }
- ,
- a.prototype.divideToRef = function(e, i) {
- return i.copyFromFloats(this._x / e._x, this._y / e._y, this._z / e._z)
- }
- ,
- a.prototype.divideInPlace = function(e) {
- return this.divideToRef(e, this)
- }
- ,
- a.prototype.minimizeInPlace = function(e) {
- return this.minimizeInPlaceFromFloats(e._x, e._y, e._z)
- }
- ,
- a.prototype.maximizeInPlace = function(e) {
- return this.maximizeInPlaceFromFloats(e._x, e._y, e._z)
- }
- ,
- a.prototype.minimizeInPlaceFromFloats = function(e, i, o) {
- return e < this._x && (this.x = e),
- i < this._y && (this.y = i),
- o < this._z && (this.z = o),
- this
- }
- ,
- a.prototype.maximizeInPlaceFromFloats = function(e, i, o) {
- return e > this._x && (this.x = e),
- i > this._y && (this.y = i),
- o > this._z && (this.z = o),
- this
- }
- ,
- a.prototype.isNonUniformWithinEpsilon = function(e) {
- var i = Math.abs(this._x)
- , o = Math.abs(this._y);
- if (!Scalar.WithinEpsilon(i, o, e))
- return !0;
- var s = Math.abs(this._z);
- return !Scalar.WithinEpsilon(i, s, e) || !Scalar.WithinEpsilon(o, s, e)
- }
- ,
- Object.defineProperty(a.prototype, "isNonUniform", {
- get: function() {
- var e = Math.abs(this._x)
- , i = Math.abs(this._y);
- if (e !== i)
- return !0;
- var o = Math.abs(this._z);
- return e !== o
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.floor = function() {
- return new a(Math.floor(this._x),Math.floor(this._y),Math.floor(this._z))
- }
- ,
- a.prototype.fract = function() {
- return new a(this._x - Math.floor(this._x),this._y - Math.floor(this._y),this._z - Math.floor(this._z))
- }
- ,
- a.prototype.length = function() {
- return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z)
- }
- ,
- a.prototype.lengthSquared = function() {
- return this._x * this._x + this._y * this._y + this._z * this._z
- }
- ,
- a.prototype.normalize = function() {
- return this.normalizeFromLength(this.length())
- }
- ,
- a.prototype.reorderInPlace = function(e) {
- var i = this;
- return e = e.toLowerCase(),
- e === "xyz" ? this : (MathTmp.Vector3[0].copyFrom(this),
- ["x", "y", "z"].forEach(function(o, s) {
- i[o] = MathTmp.Vector3[0][e[s]]
- }),
- this)
- }
- ,
- a.prototype.rotateByQuaternionToRef = function(e, i) {
- return e.toRotationMatrix(MathTmp.Matrix[0]),
- a.TransformCoordinatesToRef(this, MathTmp.Matrix[0], i),
- i
- }
- ,
- a.prototype.rotateByQuaternionAroundPointToRef = function(e, i, o) {
- return this.subtractToRef(i, MathTmp.Vector3[0]),
- MathTmp.Vector3[0].rotateByQuaternionToRef(e, MathTmp.Vector3[0]),
- i.addToRef(MathTmp.Vector3[0], o),
- o
- }
- ,
- a.prototype.cross = function(e) {
- return a.Cross(this, e)
- }
- ,
- a.prototype.normalizeFromLength = function(e) {
- return e === 0 || e === 1 ? this : this.scaleInPlace(1 / e)
- }
- ,
- a.prototype.normalizeToNew = function() {
- var e = new a(0,0,0);
- return this.normalizeToRef(e),
- e
- }
- ,
- a.prototype.normalizeToRef = function(e) {
- var i = this.length();
- return i === 0 || i === 1 ? e.copyFromFloats(this._x, this._y, this._z) : this.scaleToRef(1 / i, e)
- }
- ,
- a.prototype.clone = function() {
- return new a(this._x,this._y,this._z)
- }
- ,
- a.prototype.copyFrom = function(e) {
- return this.copyFromFloats(e._x, e._y, e._z)
- }
- ,
- a.prototype.copyFromFloats = function(e, i, o) {
- return this.x = e,
- this.y = i,
- this.z = o,
- this
- }
- ,
- a.prototype.set = function(e, i, o) {
- return this.copyFromFloats(e, i, o)
- }
- ,
- a.prototype.setAll = function(e) {
- return this.x = this.y = this.z = e,
- this
- }
- ,
- a.GetClipFactor = function(e, i, o, s) {
- var c = a.Dot(e, o) - s
- , d = a.Dot(i, o) - s
- , _ = c / (c - d);
- return _
- }
- ,
- a.GetAngleBetweenVectors = function(e, i, o) {
- var s = e.normalizeToRef(MathTmp.Vector3[1])
- , c = i.normalizeToRef(MathTmp.Vector3[2])
- , d = a.Dot(s, c)
- , _ = Math.acos(d)
- , b = MathTmp.Vector3[3];
- return a.CrossToRef(s, c, b),
- a.Dot(b, o) > 0 ? isNaN(_) ? 0 : _ : isNaN(_) ? -Math.PI : -Math.acos(d)
- }
- ,
- a.GetAngleBetweenVectorsOnPlane = function(e, i, o) {
- MathTmp.Vector3[0].copyFrom(e);
- var s = MathTmp.Vector3[0];
- MathTmp.Vector3[1].copyFrom(i);
- var c = MathTmp.Vector3[1];
- MathTmp.Vector3[2].copyFrom(o);
- var d = MathTmp.Vector3[2]
- , _ = MathTmp.Vector3[3]
- , b = MathTmp.Vector3[4];
- s.normalize(),
- c.normalize(),
- d.normalize(),
- a.CrossToRef(d, s, _),
- a.CrossToRef(_, d, b);
- var k = Math.atan2(a.Dot(c, _), a.Dot(c, b));
- return Scalar.NormalizeRadians(k)
- }
- ,
- a.SlerpToRef = function(e, i, o, s) {
- o = Scalar.Clamp(o, 0, 1);
- var c = MathTmp.Vector3[0], d = MathTmp.Vector3[1], _, b;
- c.copyFrom(e),
- _ = c.length(),
- c.normalizeFromLength(_),
- d.copyFrom(i),
- b = d.length(),
- d.normalizeFromLength(b);
- var k = a.Dot(c, d), j, $;
- if (k < 1 - Epsilon) {
- var _e = Math.acos(k)
- , et = 1 / Math.sin(_e);
- j = Math.sin((1 - o) * _e) * et,
- $ = Math.sin(o * _e) * et
- } else
- j = 1 - o,
- $ = o;
- c.scaleInPlace(j),
- d.scaleInPlace($),
- s.copyFrom(c).addInPlace(d),
- s.scaleInPlace(Scalar.Lerp(_, b, o))
- }
- ,
- a.SmoothToRef = function(e, i, o, s, c) {
- a.SlerpToRef(e, i, s === 0 ? 1 : o / s, c)
- }
- ,
- a.FromArray = function(e, i) {
- return i === void 0 && (i = 0),
- new a(e[i],e[i + 1],e[i + 2])
- }
- ,
- a.FromFloatArray = function(e, i) {
- return a.FromArray(e, i)
- }
- ,
- a.FromArrayToRef = function(e, i, o) {
- o.x = e[i],
- o.y = e[i + 1],
- o.z = e[i + 2]
- }
- ,
- a.FromFloatArrayToRef = function(e, i, o) {
- return a.FromArrayToRef(e, i, o)
- }
- ,
- a.FromFloatsToRef = function(e, i, o, s) {
- s.copyFromFloats(e, i, o)
- }
- ,
- a.Zero = function() {
- return new a(0,0,0)
- }
- ,
- a.One = function() {
- return new a(1,1,1)
- }
- ,
- a.Up = function() {
- return new a(0,1,0)
- }
- ,
- Object.defineProperty(a, "UpReadOnly", {
- get: function() {
- return a._UpReadOnly
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "RightReadOnly", {
- get: function() {
- return a._RightReadOnly
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "LeftHandedForwardReadOnly", {
- get: function() {
- return a._LeftHandedForwardReadOnly
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "RightHandedForwardReadOnly", {
- get: function() {
- return a._RightHandedForwardReadOnly
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "ZeroReadOnly", {
- get: function() {
- return a._ZeroReadOnly
- },
- enumerable: !1,
- configurable: !0
- }),
- a.Down = function() {
- return new a(0,-1,0)
- }
- ,
- a.Forward = function(e) {
- return e === void 0 && (e = !1),
- new a(0,0,e ? -1 : 1)
- }
- ,
- a.Backward = function(e) {
- return e === void 0 && (e = !1),
- new a(0,0,e ? 1 : -1)
- }
- ,
- a.Right = function() {
- return new a(1,0,0)
- }
- ,
- a.Left = function() {
- return new a(-1,0,0)
- }
- ,
- a.TransformCoordinates = function(e, i) {
- var o = a.Zero();
- return a.TransformCoordinatesToRef(e, i, o),
- o
- }
- ,
- a.TransformCoordinatesToRef = function(e, i, o) {
- a.TransformCoordinatesFromFloatsToRef(e._x, e._y, e._z, i, o)
- }
- ,
- a.TransformCoordinatesFromFloatsToRef = function(e, i, o, s, c) {
- var d = s.m
- , _ = e * d[0] + i * d[4] + o * d[8] + d[12]
- , b = e * d[1] + i * d[5] + o * d[9] + d[13]
- , k = e * d[2] + i * d[6] + o * d[10] + d[14]
- , j = 1 / (e * d[3] + i * d[7] + o * d[11] + d[15]);
- c.x = _ * j,
- c.y = b * j,
- c.z = k * j
- }
- ,
- a.TransformNormal = function(e, i) {
- var o = a.Zero();
- return a.TransformNormalToRef(e, i, o),
- o
- }
- ,
- a.TransformNormalToRef = function(e, i, o) {
- this.TransformNormalFromFloatsToRef(e._x, e._y, e._z, i, o)
- }
- ,
- a.TransformNormalFromFloatsToRef = function(e, i, o, s, c) {
- var d = s.m;
- c.x = e * d[0] + i * d[4] + o * d[8],
- c.y = e * d[1] + i * d[5] + o * d[9],
- c.z = e * d[2] + i * d[6] + o * d[10]
- }
- ,
- a.CatmullRom = function(e, i, o, s, c) {
- var d = c * c
- , _ = c * d
- , 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) * _)
- , 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) * _)
- , 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) * _);
- return new a(b,k,j)
- }
- ,
- a.Clamp = function(e, i, o) {
- var s = new a;
- return a.ClampToRef(e, i, o, s),
- s
- }
- ,
- a.ClampToRef = function(e, i, o, s) {
- var c = e._x;
- c = c > o._x ? o._x : c,
- c = c < i._x ? i._x : c;
- var d = e._y;
- d = d > o._y ? o._y : d,
- d = d < i._y ? i._y : d;
- var _ = e._z;
- _ = _ > o._z ? o._z : _,
- _ = _ < i._z ? i._z : _,
- s.copyFromFloats(c, d, _)
- }
- ,
- a.CheckExtends = function(e, i, o) {
- i.minimizeInPlace(e),
- o.maximizeInPlace(e)
- }
- ,
- a.Hermite = function(e, i, o, s, c) {
- var d = c * c
- , _ = c * d
- , b = 2 * _ - 3 * d + 1
- , k = -2 * _ + 3 * d
- , j = _ - 2 * d + c
- , $ = _ - d
- , _e = e._x * b + o._x * k + i._x * j + s._x * $
- , et = e._y * b + o._y * k + i._y * j + s._y * $
- , tt = e._z * b + o._z * k + i._z * j + s._z * $;
- return new a(_e,et,tt)
- }
- ,
- a.Hermite1stDerivative = function(e, i, o, s, c) {
- var d = a.Zero();
- return this.Hermite1stDerivativeToRef(e, i, o, s, c, d),
- d
- }
- ,
- a.Hermite1stDerivativeToRef = function(e, i, o, s, c, d) {
- var _ = c * c;
- d.x = (_ - c) * 6 * e.x + (3 * _ - 4 * c + 1) * i.x + (-_ + c) * 6 * o.x + (3 * _ - 2 * c) * s.x,
- d.y = (_ - c) * 6 * e.y + (3 * _ - 4 * c + 1) * i.y + (-_ + c) * 6 * o.y + (3 * _ - 2 * c) * s.y,
- d.z = (_ - c) * 6 * e.z + (3 * _ - 4 * c + 1) * i.z + (-_ + c) * 6 * o.z + (3 * _ - 2 * c) * s.z
- }
- ,
- a.Lerp = function(e, i, o) {
- var s = new a(0,0,0);
- return a.LerpToRef(e, i, o, s),
- s
- }
- ,
- a.LerpToRef = function(e, i, o, s) {
- s.x = e._x + (i._x - e._x) * o,
- s.y = e._y + (i._y - e._y) * o,
- s.z = e._z + (i._z - e._z) * o
- }
- ,
- a.Dot = function(e, i) {
- return e._x * i._x + e._y * i._y + e._z * i._z
- }
- ,
- a.Cross = function(e, i) {
- var o = a.Zero();
- return a.CrossToRef(e, i, o),
- o
- }
- ,
- a.CrossToRef = function(e, i, o) {
- var s = e._y * i._z - e._z * i._y
- , c = e._z * i._x - e._x * i._z
- , d = e._x * i._y - e._y * i._x;
- o.copyFromFloats(s, c, d)
- }
- ,
- a.Normalize = function(e) {
- var i = a.Zero();
- return a.NormalizeToRef(e, i),
- i
- }
- ,
- a.NormalizeToRef = function(e, i) {
- e.normalizeToRef(i)
- }
- ,
- a.Project = function(e, i, o, s) {
- var c = new a;
- return a.ProjectToRef(e, i, o, s, c),
- c
- }
- ,
- a.ProjectToRef = function(e, i, o, s, c) {
- var d = s.width
- , _ = s.height
- , b = s.x
- , k = s.y
- , j = MathTmp.Matrix[1];
- Matrix.FromValuesToRef(d / 2, 0, 0, 0, 0, -_ / 2, 0, 0, 0, 0, .5, 0, b + d / 2, _ / 2 + k, .5, 1, j);
- var $ = MathTmp.Matrix[0];
- return i.multiplyToRef(o, $),
- $.multiplyToRef(j, $),
- a.TransformCoordinatesToRef(e, $, c),
- c
- }
- ,
- a._UnprojectFromInvertedMatrixToRef = function(e, i, o) {
- a.TransformCoordinatesToRef(e, i, o);
- var s = i.m
- , c = e._x * s[3] + e._y * s[7] + e._z * s[11] + s[15];
- Scalar.WithinEpsilon(c, 1) && o.scaleInPlace(1 / c)
- }
- ,
- a.UnprojectFromTransform = function(e, i, o, s, c) {
- var d = MathTmp.Matrix[0];
- s.multiplyToRef(c, d),
- d.invert(),
- e.x = e._x / i * 2 - 1,
- e.y = -(e._y / o * 2 - 1);
- var _ = new a;
- return a._UnprojectFromInvertedMatrixToRef(e, d, _),
- _
- }
- ,
- a.Unproject = function(e, i, o, s, c, d) {
- var _ = a.Zero();
- return a.UnprojectToRef(e, i, o, s, c, d, _),
- _
- }
- ,
- a.UnprojectToRef = function(e, i, o, s, c, d, _) {
- a.UnprojectFloatsToRef(e._x, e._y, e._z, i, o, s, c, d, _)
- }
- ,
- a.UnprojectFloatsToRef = function(e, i, o, s, c, d, _, b, k) {
- var j = MathTmp.Matrix[0];
- d.multiplyToRef(_, j),
- j.multiplyToRef(b, j),
- j.invert();
- var $ = MathTmp.Vector3[0];
- $.x = e / s * 2 - 1,
- $.y = -(i / c * 2 - 1),
- $.z = 2 * o - 1,
- a._UnprojectFromInvertedMatrixToRef($, j, k)
- }
- ,
- a.Minimize = function(e, i) {
- var o = e.clone();
- return o.minimizeInPlace(i),
- o
- }
- ,
- a.Maximize = function(e, i) {
- var o = e.clone();
- return o.maximizeInPlace(i),
- o
- }
- ,
- a.Distance = function(e, i) {
- return Math.sqrt(a.DistanceSquared(e, i))
- }
- ,
- a.DistanceSquared = function(e, i) {
- var o = e._x - i._x
- , s = e._y - i._y
- , c = e._z - i._z;
- return o * o + s * s + c * c
- }
- ,
- a.ProjectOnTriangleToRef = function(e, i, o, s, c) {
- var d = MathTmp.Vector3[0]
- , _ = MathTmp.Vector3[1]
- , b = MathTmp.Vector3[2]
- , k = MathTmp.Vector3[3]
- , j = MathTmp.Vector3[4];
- o.subtractToRef(i, d),
- s.subtractToRef(i, _),
- s.subtractToRef(o, b);
- var $ = d.length()
- , _e = _.length()
- , et = b.length();
- if ($ < Epsilon || _e < Epsilon || et < Epsilon)
- return c.copyFrom(i),
- a.Distance(e, i);
- e.subtractToRef(i, j),
- a.CrossToRef(d, _, k);
- var tt = k.length();
- if (tt < Epsilon)
- return c.copyFrom(i),
- a.Distance(e, i);
- k.normalizeFromLength(tt);
- var rt = j.length();
- if (rt < Epsilon)
- return c.copyFrom(i),
- 0;
- j.normalizeFromLength(rt);
- var it = a.Dot(k, j)
- , nt = MathTmp.Vector3[5]
- , ot = MathTmp.Vector3[6];
- nt.copyFrom(k).scaleInPlace(-rt * it),
- ot.copyFrom(e).addInPlace(nt);
- var at = MathTmp.Vector3[4]
- , st = MathTmp.Vector3[5]
- , ut = MathTmp.Vector3[7]
- , ct = MathTmp.Vector3[8];
- at.copyFrom(d).scaleInPlace(1 / $),
- ct.copyFrom(_).scaleInPlace(1 / _e),
- at.addInPlace(ct).scaleInPlace(-1),
- st.copyFrom(d).scaleInPlace(-1 / $),
- ct.copyFrom(b).scaleInPlace(1 / et),
- st.addInPlace(ct).scaleInPlace(-1),
- ut.copyFrom(b).scaleInPlace(-1 / et),
- ct.copyFrom(_).scaleInPlace(-1 / _e),
- ut.addInPlace(ct).scaleInPlace(-1);
- var lt = MathTmp.Vector3[9], ft, ht, pt, dt;
- lt.copyFrom(ot).subtractInPlace(i),
- a.CrossToRef(at, lt, ct),
- ft = a.Dot(ct, k),
- ht = ft,
- lt.copyFrom(ot).subtractInPlace(o),
- a.CrossToRef(st, lt, ct),
- ft = a.Dot(ct, k),
- pt = ft,
- lt.copyFrom(ot).subtractInPlace(s),
- a.CrossToRef(ut, lt, ct),
- ft = a.Dot(ct, k),
- dt = ft;
- var _t = MathTmp.Vector3[10], mt, vt;
- ht > 0 && pt < 0 ? (_t.copyFrom(d),
- mt = i,
- vt = o) : pt > 0 && dt < 0 ? (_t.copyFrom(b),
- mt = o,
- vt = s) : (_t.copyFrom(_).scaleInPlace(-1),
- mt = s,
- vt = i);
- var yt = MathTmp.Vector3[9]
- , Et = MathTmp.Vector3[4];
- mt.subtractToRef(ot, ct),
- vt.subtractToRef(ot, yt),
- a.CrossToRef(ct, yt, Et);
- var At = a.Dot(Et, k) < 0;
- if (!At)
- return c.copyFrom(ot),
- Math.abs(rt * it);
- var gt = MathTmp.Vector3[5];
- a.CrossToRef(_t, Et, gt),
- gt.normalize();
- var St = MathTmp.Vector3[9];
- St.copyFrom(mt).subtractInPlace(ot);
- var xt = St.length();
- if (xt < Epsilon)
- return c.copyFrom(mt),
- a.Distance(e, mt);
- St.normalizeFromLength(xt);
- var bt = a.Dot(gt, St)
- , Rt = MathTmp.Vector3[7];
- Rt.copyFrom(ot).addInPlace(gt.scaleInPlace(xt * bt)),
- ct.copyFrom(Rt).subtractInPlace(mt),
- rt = _t.length(),
- _t.normalizeFromLength(rt);
- var Mt = a.Dot(ct, _t) / Math.max(rt, Epsilon);
- return Mt = Scalar.Clamp(Mt, 0, 1),
- Rt.copyFrom(mt).addInPlace(_t.scaleInPlace(Mt * rt)),
- c.copyFrom(Rt),
- a.Distance(e, Rt)
- }
- ,
- a.Center = function(e, i) {
- return a.CenterToRef(e, i, a.Zero())
- }
- ,
- a.CenterToRef = function(e, i, o) {
- return o.copyFromFloats((e._x + i._x) / 2, (e._y + i._y) / 2, (e._z + i._z) / 2)
- }
- ,
- a.RotationFromAxis = function(e, i, o) {
- var s = a.Zero();
- return a.RotationFromAxisToRef(e, i, o, s),
- s
- }
- ,
- a.RotationFromAxisToRef = function(e, i, o, s) {
- var c = MathTmp.Quaternion[0];
- Quaternion.RotationQuaternionFromAxisToRef(e, i, o, c),
- c.toEulerAnglesToRef(s)
- }
- ,
- a._UpReadOnly = a.Up(),
- a._LeftHandedForwardReadOnly = a.Forward(!1),
- a._RightHandedForwardReadOnly = a.Forward(!0),
- a._RightReadOnly = a.Right(),
- a._ZeroReadOnly = a.Zero(),
- a
- }()
- , Vector4 = function() {
- function a(e, i, o, s) {
- this.x = e,
- this.y = i,
- this.z = o,
- this.w = s
- }
- return a.prototype.toString = function() {
- return "{X: " + this.x + " Y: " + this.y + " Z: " + this.z + " W: " + this.w + "}"
- }
- ,
- a.prototype.getClassName = function() {
- return "Vector4"
- }
- ,
- a.prototype.getHashCode = function() {
- var e = this.x | 0;
- return e = e * 397 ^ (this.y | 0),
- e = e * 397 ^ (this.z | 0),
- e = e * 397 ^ (this.w | 0),
- e
- }
- ,
- a.prototype.asArray = function() {
- var e = new Array;
- return this.toArray(e, 0),
- e
- }
- ,
- a.prototype.toArray = function(e, i) {
- return i === void 0 && (i = 0),
- e[i] = this.x,
- e[i + 1] = this.y,
- e[i + 2] = this.z,
- e[i + 3] = this.w,
- this
- }
- ,
- a.prototype.fromArray = function(e, i) {
- return i === void 0 && (i = 0),
- a.FromArrayToRef(e, i, this),
- this
- }
- ,
- a.prototype.addInPlace = function(e) {
- return this.x += e.x,
- this.y += e.y,
- this.z += e.z,
- this.w += e.w,
- this
- }
- ,
- a.prototype.add = function(e) {
- return new a(this.x + e.x,this.y + e.y,this.z + e.z,this.w + e.w)
- }
- ,
- a.prototype.addToRef = function(e, i) {
- return i.x = this.x + e.x,
- i.y = this.y + e.y,
- i.z = this.z + e.z,
- i.w = this.w + e.w,
- this
- }
- ,
- a.prototype.subtractInPlace = function(e) {
- return this.x -= e.x,
- this.y -= e.y,
- this.z -= e.z,
- this.w -= e.w,
- this
- }
- ,
- a.prototype.subtract = function(e) {
- return new a(this.x - e.x,this.y - e.y,this.z - e.z,this.w - e.w)
- }
- ,
- a.prototype.subtractToRef = function(e, i) {
- return i.x = this.x - e.x,
- i.y = this.y - e.y,
- i.z = this.z - e.z,
- i.w = this.w - e.w,
- this
- }
- ,
- a.prototype.subtractFromFloats = function(e, i, o, s) {
- return new a(this.x - e,this.y - i,this.z - o,this.w - s)
- }
- ,
- a.prototype.subtractFromFloatsToRef = function(e, i, o, s, c) {
- return c.x = this.x - e,
- c.y = this.y - i,
- c.z = this.z - o,
- c.w = this.w - s,
- this
- }
- ,
- a.prototype.negate = function() {
- return new a(-this.x,-this.y,-this.z,-this.w)
- }
- ,
- a.prototype.negateInPlace = function() {
- return this.x *= -1,
- this.y *= -1,
- this.z *= -1,
- this.w *= -1,
- this
- }
- ,
- a.prototype.negateToRef = function(e) {
- return e.copyFromFloats(this.x * -1, this.y * -1, this.z * -1, this.w * -1)
- }
- ,
- a.prototype.scaleInPlace = function(e) {
- return this.x *= e,
- this.y *= e,
- this.z *= e,
- this.w *= e,
- this
- }
- ,
- a.prototype.scale = function(e) {
- return new a(this.x * e,this.y * e,this.z * e,this.w * e)
- }
- ,
- a.prototype.scaleToRef = function(e, i) {
- return i.x = this.x * e,
- i.y = this.y * e,
- i.z = this.z * e,
- i.w = this.w * e,
- this
- }
- ,
- a.prototype.scaleAndAddToRef = function(e, i) {
- return i.x += this.x * e,
- i.y += this.y * e,
- i.z += this.z * e,
- i.w += this.w * e,
- this
- }
- ,
- a.prototype.equals = function(e) {
- return e && this.x === e.x && this.y === e.y && this.z === e.z && this.w === e.w
- }
- ,
- a.prototype.equalsWithEpsilon = function(e, i) {
- return i === void 0 && (i = Epsilon),
- 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)
- }
- ,
- a.prototype.equalsToFloats = function(e, i, o, s) {
- return this.x === e && this.y === i && this.z === o && this.w === s
- }
- ,
- a.prototype.multiplyInPlace = function(e) {
- return this.x *= e.x,
- this.y *= e.y,
- this.z *= e.z,
- this.w *= e.w,
- this
- }
- ,
- a.prototype.multiply = function(e) {
- return new a(this.x * e.x,this.y * e.y,this.z * e.z,this.w * e.w)
- }
- ,
- a.prototype.multiplyToRef = function(e, i) {
- return i.x = this.x * e.x,
- i.y = this.y * e.y,
- i.z = this.z * e.z,
- i.w = this.w * e.w,
- this
- }
- ,
- a.prototype.multiplyByFloats = function(e, i, o, s) {
- return new a(this.x * e,this.y * i,this.z * o,this.w * s)
- }
- ,
- a.prototype.divide = function(e) {
- return new a(this.x / e.x,this.y / e.y,this.z / e.z,this.w / e.w)
- }
- ,
- a.prototype.divideToRef = function(e, i) {
- return i.x = this.x / e.x,
- i.y = this.y / e.y,
- i.z = this.z / e.z,
- i.w = this.w / e.w,
- this
- }
- ,
- a.prototype.divideInPlace = function(e) {
- return this.divideToRef(e, this)
- }
- ,
- a.prototype.minimizeInPlace = function(e) {
- return e.x < this.x && (this.x = e.x),
- e.y < this.y && (this.y = e.y),
- e.z < this.z && (this.z = e.z),
- e.w < this.w && (this.w = e.w),
- this
- }
- ,
- a.prototype.maximizeInPlace = function(e) {
- return e.x > this.x && (this.x = e.x),
- e.y > this.y && (this.y = e.y),
- e.z > this.z && (this.z = e.z),
- e.w > this.w && (this.w = e.w),
- this
- }
- ,
- a.prototype.floor = function() {
- return new a(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z),Math.floor(this.w))
- }
- ,
- a.prototype.fract = function() {
- 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))
- }
- ,
- a.prototype.length = function() {
- return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w)
- }
- ,
- a.prototype.lengthSquared = function() {
- return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w
- }
- ,
- a.prototype.normalize = function() {
- var e = this.length();
- return e === 0 ? this : this.scaleInPlace(1 / e)
- }
- ,
- a.prototype.toVector3 = function() {
- return new Vector3(this.x,this.y,this.z)
- }
- ,
- a.prototype.clone = function() {
- return new a(this.x,this.y,this.z,this.w)
- }
- ,
- a.prototype.copyFrom = function(e) {
- return this.x = e.x,
- this.y = e.y,
- this.z = e.z,
- this.w = e.w,
- this
- }
- ,
- a.prototype.copyFromFloats = function(e, i, o, s) {
- return this.x = e,
- this.y = i,
- this.z = o,
- this.w = s,
- this
- }
- ,
- a.prototype.set = function(e, i, o, s) {
- return this.copyFromFloats(e, i, o, s)
- }
- ,
- a.prototype.setAll = function(e) {
- return this.x = this.y = this.z = this.w = e,
- this
- }
- ,
- a.FromArray = function(e, i) {
- return i || (i = 0),
- new a(e[i],e[i + 1],e[i + 2],e[i + 3])
- }
- ,
- a.FromArrayToRef = function(e, i, o) {
- o.x = e[i],
- o.y = e[i + 1],
- o.z = e[i + 2],
- o.w = e[i + 3]
- }
- ,
- a.FromFloatArrayToRef = function(e, i, o) {
- a.FromArrayToRef(e, i, o)
- }
- ,
- a.FromFloatsToRef = function(e, i, o, s, c) {
- c.x = e,
- c.y = i,
- c.z = o,
- c.w = s
- }
- ,
- a.Zero = function() {
- return new a(0,0,0,0)
- }
- ,
- a.One = function() {
- return new a(1,1,1,1)
- }
- ,
- a.Normalize = function(e) {
- var i = a.Zero();
- return a.NormalizeToRef(e, i),
- i
- }
- ,
- a.NormalizeToRef = function(e, i) {
- i.copyFrom(e),
- i.normalize()
- }
- ,
- a.Minimize = function(e, i) {
- var o = e.clone();
- return o.minimizeInPlace(i),
- o
- }
- ,
- a.Maximize = function(e, i) {
- var o = e.clone();
- return o.maximizeInPlace(i),
- o
- }
- ,
- a.Distance = function(e, i) {
- return Math.sqrt(a.DistanceSquared(e, i))
- }
- ,
- a.DistanceSquared = function(e, i) {
- var o = e.x - i.x
- , s = e.y - i.y
- , c = e.z - i.z
- , d = e.w - i.w;
- return o * o + s * s + c * c + d * d
- }
- ,
- a.Center = function(e, i) {
- return a.CenterToRef(e, i, a.Zero())
- }
- ,
- a.CenterToRef = function(e, i, o) {
- return o.copyFromFloats((e.x + i.x) / 2, (e.y + i.y) / 2, (e.z + i.z) / 2, (e.w + i.w) / 2)
- }
- ,
- a.TransformCoordinates = function(e, i) {
- var o = a.Zero();
- return a.TransformCoordinatesToRef(e, i, o),
- o
- }
- ,
- a.TransformCoordinatesToRef = function(e, i, o) {
- a.TransformCoordinatesFromFloatsToRef(e._x, e._y, e._z, i, o)
- }
- ,
- a.TransformCoordinatesFromFloatsToRef = function(e, i, o, s, c) {
- var d = s.m
- , _ = e * d[0] + i * d[4] + o * d[8] + d[12]
- , b = e * d[1] + i * d[5] + o * d[9] + d[13]
- , k = e * d[2] + i * d[6] + o * d[10] + d[14]
- , j = e * d[3] + i * d[7] + o * d[11] + d[15];
- c.x = _,
- c.y = b,
- c.z = k,
- c.w = j
- }
- ,
- a.TransformNormal = function(e, i) {
- var o = a.Zero();
- return a.TransformNormalToRef(e, i, o),
- o
- }
- ,
- a.TransformNormalToRef = function(e, i, o) {
- var s = i.m
- , c = e.x * s[0] + e.y * s[4] + e.z * s[8]
- , d = e.x * s[1] + e.y * s[5] + e.z * s[9]
- , _ = e.x * s[2] + e.y * s[6] + e.z * s[10];
- o.x = c,
- o.y = d,
- o.z = _,
- o.w = e.w
- }
- ,
- a.TransformNormalFromFloatsToRef = function(e, i, o, s, c, d) {
- var _ = c.m;
- d.x = e * _[0] + i * _[4] + o * _[8],
- d.y = e * _[1] + i * _[5] + o * _[9],
- d.z = e * _[2] + i * _[6] + o * _[10],
- d.w = s
- }
- ,
- a.FromVector3 = function(e, i) {
- return i === void 0 && (i = 0),
- new a(e._x,e._y,e._z,i)
- }
- ,
- a
- }()
- , Quaternion = function() {
- function a(e, i, o, s) {
- e === void 0 && (e = 0),
- i === void 0 && (i = 0),
- o === void 0 && (o = 0),
- s === void 0 && (s = 1),
- this._isDirty = !0,
- this._x = e,
- this._y = i,
- this._z = o,
- this._w = s
- }
- return Object.defineProperty(a.prototype, "x", {
- get: function() {
- return this._x
- },
- set: function(e) {
- this._x = e,
- this._isDirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "y", {
- get: function() {
- return this._y
- },
- set: function(e) {
- this._y = e,
- this._isDirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "z", {
- get: function() {
- return this._z
- },
- set: function(e) {
- this._z = e,
- this._isDirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "w", {
- get: function() {
- return this._w
- },
- set: function(e) {
- this._w = e,
- this._isDirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.toString = function() {
- return "{X: " + this._x + " Y: " + this._y + " Z: " + this._z + " W: " + this._w + "}"
- }
- ,
- a.prototype.getClassName = function() {
- return "Quaternion"
- }
- ,
- a.prototype.getHashCode = function() {
- var e = this._x | 0;
- return e = e * 397 ^ (this._y | 0),
- e = e * 397 ^ (this._z | 0),
- e = e * 397 ^ (this._w | 0),
- e
- }
- ,
- a.prototype.asArray = function() {
- return [this._x, this._y, this._z, this._w]
- }
- ,
- a.prototype.equals = function(e) {
- return e && this._x === e._x && this._y === e._y && this._z === e._z && this._w === e._w
- }
- ,
- a.prototype.equalsWithEpsilon = function(e, i) {
- return i === void 0 && (i = Epsilon),
- 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)
- }
- ,
- a.prototype.clone = function() {
- return new a(this._x,this._y,this._z,this._w)
- }
- ,
- a.prototype.copyFrom = function(e) {
- return this.x = e._x,
- this.y = e._y,
- this.z = e._z,
- this.w = e._w,
- this
- }
- ,
- a.prototype.copyFromFloats = function(e, i, o, s) {
- return this.x = e,
- this.y = i,
- this.z = o,
- this.w = s,
- this
- }
- ,
- a.prototype.set = function(e, i, o, s) {
- return this.copyFromFloats(e, i, o, s)
- }
- ,
- a.prototype.add = function(e) {
- return new a(this._x + e._x,this._y + e._y,this._z + e._z,this._w + e._w)
- }
- ,
- a.prototype.addInPlace = function(e) {
- return this._x += e._x,
- this._y += e._y,
- this._z += e._z,
- this._w += e._w,
- this
- }
- ,
- a.prototype.subtract = function(e) {
- return new a(this._x - e._x,this._y - e._y,this._z - e._z,this._w - e._w)
- }
- ,
- a.prototype.scale = function(e) {
- return new a(this._x * e,this._y * e,this._z * e,this._w * e)
- }
- ,
- a.prototype.scaleToRef = function(e, i) {
- return i.x = this._x * e,
- i.y = this._y * e,
- i.z = this._z * e,
- i.w = this._w * e,
- this
- }
- ,
- a.prototype.scaleInPlace = function(e) {
- return this.x *= e,
- this.y *= e,
- this.z *= e,
- this.w *= e,
- this
- }
- ,
- a.prototype.scaleAndAddToRef = function(e, i) {
- return i.x += this._x * e,
- i.y += this._y * e,
- i.z += this._z * e,
- i.w += this._w * e,
- this
- }
- ,
- a.prototype.multiply = function(e) {
- var i = new a(0,0,0,1);
- return this.multiplyToRef(e, i),
- i
- }
- ,
- a.prototype.multiplyToRef = function(e, i) {
- var o = this._x * e._w + this._y * e._z - this._z * e._y + this._w * e._x
- , s = -this._x * e._z + this._y * e._w + this._z * e._x + this._w * e._y
- , c = this._x * e._y - this._y * e._x + this._z * e._w + this._w * e._z
- , d = -this._x * e._x - this._y * e._y - this._z * e._z + this._w * e._w;
- return i.copyFromFloats(o, s, c, d),
- this
- }
- ,
- a.prototype.multiplyInPlace = function(e) {
- return this.multiplyToRef(e, this),
- this
- }
- ,
- a.prototype.conjugateToRef = function(e) {
- return e.copyFromFloats(-this._x, -this._y, -this._z, this._w),
- this
- }
- ,
- a.prototype.conjugateInPlace = function() {
- return this.x *= -1,
- this.y *= -1,
- this.z *= -1,
- this
- }
- ,
- a.prototype.conjugate = function() {
- var e = new a(-this._x,-this._y,-this._z,this._w);
- return e
- }
- ,
- a.prototype.length = function() {
- return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w)
- }
- ,
- a.prototype.normalize = function() {
- var e = this.length();
- if (e === 0)
- return this;
- var i = 1 / e;
- return this.x *= i,
- this.y *= i,
- this.z *= i,
- this.w *= i,
- this
- }
- ,
- a.prototype.toEulerAngles = function() {
- var e = Vector3.Zero();
- return this.toEulerAnglesToRef(e),
- e
- }
- ,
- a.prototype.toEulerAnglesToRef = function(e) {
- var i = this._z
- , o = this._x
- , s = this._y
- , c = this._w
- , d = c * c
- , _ = i * i
- , b = o * o
- , k = s * s
- , j = s * i - o * c
- , $ = .4999999;
- return j < -$ ? (e.y = 2 * Math.atan2(s, c),
- e.x = Math.PI / 2,
- e.z = 0) : j > $ ? (e.y = 2 * Math.atan2(s, c),
- e.x = -Math.PI / 2,
- e.z = 0) : (e.z = Math.atan2(2 * (o * s + i * c), -_ - b + k + d),
- e.x = Math.asin(-2 * (i * s - o * c)),
- e.y = Math.atan2(2 * (i * o + s * c), _ - b - k + d)),
- this
- }
- ,
- a.prototype.toRotationMatrix = function(e) {
- return Matrix.FromQuaternionToRef(this, e),
- this
- }
- ,
- a.prototype.fromRotationMatrix = function(e) {
- return a.FromRotationMatrixToRef(e, this),
- this
- }
- ,
- a.FromRotationMatrix = function(e) {
- var i = new a;
- return a.FromRotationMatrixToRef(e, i),
- i
- }
- ,
- a.FromRotationMatrixToRef = function(e, i) {
- 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;
- et > 0 ? (tt = .5 / Math.sqrt(et + 1),
- i.w = .25 / tt,
- i.x = ($ - k) * tt,
- i.y = (d - j) * tt,
- i.z = (_ - c) * tt) : s > b && s > _e ? (tt = 2 * Math.sqrt(1 + s - b - _e),
- i.w = ($ - k) / tt,
- i.x = .25 * tt,
- i.y = (c + _) / tt,
- i.z = (d + j) / tt) : b > _e ? (tt = 2 * Math.sqrt(1 + b - s - _e),
- i.w = (d - j) / tt,
- i.x = (c + _) / tt,
- i.y = .25 * tt,
- i.z = (k + $) / tt) : (tt = 2 * Math.sqrt(1 + _e - s - b),
- i.w = (_ - c) / tt,
- i.x = (d + j) / tt,
- i.y = (k + $) / tt,
- i.z = .25 * tt)
- }
- ,
- a.Dot = function(e, i) {
- return e._x * i._x + e._y * i._y + e._z * i._z + e._w * i._w
- }
- ,
- a.AreClose = function(e, i) {
- var o = a.Dot(e, i);
- return o >= 0
- }
- ,
- a.SmoothToRef = function(e, i, o, s, c) {
- var d = s === 0 ? 1 : o / s;
- d = Scalar.Clamp(d, 0, 1),
- a.SlerpToRef(e, i, d, c)
- }
- ,
- a.Zero = function() {
- return new a(0,0,0,0)
- }
- ,
- a.Inverse = function(e) {
- return new a(-e._x,-e._y,-e._z,e._w)
- }
- ,
- a.InverseToRef = function(e, i) {
- return i.set(-e._x, -e._y, -e._z, e._w),
- i
- }
- ,
- a.Identity = function() {
- return new a(0,0,0,1)
- }
- ,
- a.IsIdentity = function(e) {
- return e && e._x === 0 && e._y === 0 && e._z === 0 && e._w === 1
- }
- ,
- a.RotationAxis = function(e, i) {
- return a.RotationAxisToRef(e, i, new a)
- }
- ,
- a.RotationAxisToRef = function(e, i, o) {
- var s = Math.sin(i / 2);
- return e.normalize(),
- o.w = Math.cos(i / 2),
- o.x = e._x * s,
- o.y = e._y * s,
- o.z = e._z * s,
- o
- }
- ,
- a.FromArray = function(e, i) {
- return i || (i = 0),
- new a(e[i],e[i + 1],e[i + 2],e[i + 3])
- }
- ,
- a.FromArrayToRef = function(e, i, o) {
- o.x = e[i],
- o.y = e[i + 1],
- o.z = e[i + 2],
- o.w = e[i + 3]
- }
- ,
- a.FromEulerAngles = function(e, i, o) {
- var s = new a;
- return a.RotationYawPitchRollToRef(i, e, o, s),
- s
- }
- ,
- a.FromEulerAnglesToRef = function(e, i, o, s) {
- return a.RotationYawPitchRollToRef(i, e, o, s),
- s
- }
- ,
- a.FromEulerVector = function(e) {
- var i = new a;
- return a.RotationYawPitchRollToRef(e._y, e._x, e._z, i),
- i
- }
- ,
- a.FromEulerVectorToRef = function(e, i) {
- return a.RotationYawPitchRollToRef(e._y, e._x, e._z, i),
- i
- }
- ,
- a.FromUnitVectorsToRef = function(e, i, o) {
- var s = Vector3.Dot(e, i) + 1;
- 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]),
- o.set(TmpVectors.Vector3[0].x, TmpVectors.Vector3[0].y, TmpVectors.Vector3[0].z, s)),
- o.normalize()
- }
- ,
- a.RotationYawPitchRoll = function(e, i, o) {
- var s = new a;
- return a.RotationYawPitchRollToRef(e, i, o, s),
- s
- }
- ,
- a.RotationYawPitchRollToRef = function(e, i, o, s) {
- var c = o * .5
- , d = i * .5
- , _ = e * .5
- , b = Math.sin(c)
- , k = Math.cos(c)
- , j = Math.sin(d)
- , $ = Math.cos(d)
- , _e = Math.sin(_)
- , et = Math.cos(_);
- s.x = et * j * k + _e * $ * b,
- s.y = _e * $ * k - et * j * b,
- s.z = et * $ * b - _e * j * k,
- s.w = et * $ * k + _e * j * b
- }
- ,
- a.RotationAlphaBetaGamma = function(e, i, o) {
- var s = new a;
- return a.RotationAlphaBetaGammaToRef(e, i, o, s),
- s
- }
- ,
- a.RotationAlphaBetaGammaToRef = function(e, i, o, s) {
- var c = (o + e) * .5
- , d = (o - e) * .5
- , _ = i * .5;
- s.x = Math.cos(d) * Math.sin(_),
- s.y = Math.sin(d) * Math.sin(_),
- s.z = Math.sin(c) * Math.cos(_),
- s.w = Math.cos(c) * Math.cos(_)
- }
- ,
- a.RotationQuaternionFromAxis = function(e, i, o) {
- var s = new a(0,0,0,0);
- return a.RotationQuaternionFromAxisToRef(e, i, o, s),
- s
- }
- ,
- a.RotationQuaternionFromAxisToRef = function(e, i, o, s) {
- var c = MathTmp.Matrix[0];
- Matrix.FromXYZAxesToRef(e.normalize(), i.normalize(), o.normalize(), c),
- a.FromRotationMatrixToRef(c, s)
- }
- ,
- a.FromLookDirectionLH = function(e, i) {
- var o = new a;
- return a.FromLookDirectionLHToRef(e, i, o),
- o
- }
- ,
- a.FromLookDirectionLHToRef = function(e, i, o) {
- var s = MathTmp.Matrix[0];
- Matrix.LookDirectionLHToRef(e, i, s),
- a.FromRotationMatrixToRef(s, o)
- }
- ,
- a.FromLookDirectionRH = function(e, i) {
- var o = new a;
- return a.FromLookDirectionRHToRef(e, i, o),
- o
- }
- ,
- a.FromLookDirectionRHToRef = function(e, i, o) {
- var s = MathTmp.Matrix[0];
- return Matrix.LookDirectionRHToRef(e, i, s),
- a.FromRotationMatrixToRef(s, o)
- }
- ,
- a.Slerp = function(e, i, o) {
- var s = a.Identity();
- return a.SlerpToRef(e, i, o, s),
- s
- }
- ,
- a.SlerpToRef = function(e, i, o, s) {
- var c, d, _ = e._x * i._x + e._y * i._y + e._z * i._z + e._w * i._w, b = !1;
- if (_ < 0 && (b = !0,
- _ = -_),
- _ > .999999)
- d = 1 - o,
- c = b ? -o : o;
- else {
- var k = Math.acos(_)
- , j = 1 / Math.sin(k);
- d = Math.sin((1 - o) * k) * j,
- c = b ? -Math.sin(o * k) * j : Math.sin(o * k) * j
- }
- s.x = d * e._x + c * i._x,
- s.y = d * e._y + c * i._y,
- s.z = d * e._z + c * i._z,
- s.w = d * e._w + c * i._w
- }
- ,
- a.Hermite = function(e, i, o, s, c) {
- var d = c * c
- , _ = c * d
- , b = 2 * _ - 3 * d + 1
- , k = -2 * _ + 3 * d
- , j = _ - 2 * d + c
- , $ = _ - d
- , _e = e._x * b + o._x * k + i._x * j + s._x * $
- , et = e._y * b + o._y * k + i._y * j + s._y * $
- , tt = e._z * b + o._z * k + i._z * j + s._z * $
- , rt = e._w * b + o._w * k + i._w * j + s._w * $;
- return new a(_e,et,tt,rt)
- }
- ,
- a.Hermite1stDerivative = function(e, i, o, s, c) {
- var d = a.Zero();
- return this.Hermite1stDerivativeToRef(e, i, o, s, c, d),
- d
- }
- ,
- a.Hermite1stDerivativeToRef = function(e, i, o, s, c, d) {
- var _ = c * c;
- d.x = (_ - c) * 6 * e.x + (3 * _ - 4 * c + 1) * i.x + (-_ + c) * 6 * o.x + (3 * _ - 2 * c) * s.x,
- d.y = (_ - c) * 6 * e.y + (3 * _ - 4 * c + 1) * i.y + (-_ + c) * 6 * o.y + (3 * _ - 2 * c) * s.y,
- d.z = (_ - c) * 6 * e.z + (3 * _ - 4 * c + 1) * i.z + (-_ + c) * 6 * o.z + (3 * _ - 2 * c) * s.z,
- d.w = (_ - c) * 6 * e.w + (3 * _ - 4 * c + 1) * i.w + (-_ + c) * 6 * o.w + (3 * _ - 2 * c) * s.w
- }
- ,
- a
- }()
- , Matrix = function() {
- function a() {
- this._isIdentity = !1,
- this._isIdentityDirty = !0,
- this._isIdentity3x2 = !0,
- this._isIdentity3x2Dirty = !0,
- this.updateFlag = -1,
- PerformanceConfigurator.MatrixTrackPrecisionChange && PerformanceConfigurator.MatrixTrackedMatrices.push(this),
- this._m = new PerformanceConfigurator.MatrixCurrentType(16),
- this._markAsUpdated()
- }
- return Object.defineProperty(a, "Use64Bits", {
- get: function() {
- return PerformanceConfigurator.MatrixUse64Bits
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "m", {
- get: function() {
- return this._m
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._markAsUpdated = function() {
- this.updateFlag = a._updateFlagSeed++,
- this._isIdentity = !1,
- this._isIdentity3x2 = !1,
- this._isIdentityDirty = !0,
- this._isIdentity3x2Dirty = !0
- }
- ,
- a.prototype._updateIdentityStatus = function(e, i, o, s) {
- i === void 0 && (i = !1),
- o === void 0 && (o = !1),
- s === void 0 && (s = !0),
- this._isIdentity = e,
- this._isIdentity3x2 = e || o,
- this._isIdentityDirty = this._isIdentity ? !1 : i,
- this._isIdentity3x2Dirty = this._isIdentity3x2 ? !1 : s
- }
- ,
- a.prototype.isIdentity = function() {
- if (this._isIdentityDirty) {
- this._isIdentityDirty = !1;
- var e = this._m;
- 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
- }
- return this._isIdentity
- }
- ,
- a.prototype.isIdentityAs3x2 = function() {
- return this._isIdentity3x2Dirty && (this._isIdentity3x2Dirty = !1,
- 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),
- this._isIdentity3x2
- }
- ,
- a.prototype.determinant = function() {
- if (this._isIdentity === !0)
- return 1;
- var e = this._m
- , i = e[0]
- , o = e[1]
- , s = e[2]
- , c = e[3]
- , d = e[4]
- , _ = e[5]
- , b = e[6]
- , k = e[7]
- , j = e[8]
- , $ = e[9]
- , _e = e[10]
- , et = e[11]
- , tt = e[12]
- , rt = e[13]
- , it = e[14]
- , nt = e[15]
- , ot = _e * nt - it * et
- , at = $ * nt - rt * et
- , st = $ * it - rt * _e
- , ut = j * nt - tt * et
- , ct = j * it - _e * tt
- , lt = j * rt - tt * $
- , ft = +(_ * ot - b * at + k * st)
- , ht = -(d * ot - b * ut + k * ct)
- , pt = +(d * at - _ * ut + k * lt)
- , dt = -(d * st - _ * ct + b * lt);
- return i * ft + o * ht + s * pt + c * dt
- }
- ,
- a.prototype.toArray = function() {
- return this._m
- }
- ,
- a.prototype.asArray = function() {
- return this._m
- }
- ,
- a.prototype.invert = function() {
- return this.invertToRef(this),
- this
- }
- ,
- a.prototype.reset = function() {
- return a.FromValuesToRef(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, this),
- this._updateIdentityStatus(!1),
- this
- }
- ,
- a.prototype.add = function(e) {
- var i = new a;
- return this.addToRef(e, i),
- i
- }
- ,
- a.prototype.addToRef = function(e, i) {
- for (var o = this._m, s = i._m, c = e.m, d = 0; d < 16; d++)
- s[d] = o[d] + c[d];
- return i._markAsUpdated(),
- this
- }
- ,
- a.prototype.addToSelf = function(e) {
- for (var i = this._m, o = e.m, s = 0; s < 16; s++)
- i[s] += o[s];
- return this._markAsUpdated(),
- this
- }
- ,
- a.prototype.invertToRef = function(e) {
- if (this._isIdentity === !0)
- return a.IdentityToRef(e),
- this;
- var i = this._m
- , o = i[0]
- , s = i[1]
- , c = i[2]
- , d = i[3]
- , _ = i[4]
- , b = i[5]
- , k = i[6]
- , j = i[7]
- , $ = i[8]
- , _e = i[9]
- , et = i[10]
- , tt = i[11]
- , rt = i[12]
- , it = i[13]
- , nt = i[14]
- , ot = i[15]
- , at = et * ot - nt * tt
- , st = _e * ot - it * tt
- , ut = _e * nt - it * et
- , ct = $ * ot - rt * tt
- , lt = $ * nt - et * rt
- , ft = $ * it - rt * _e
- , ht = +(b * at - k * st + j * ut)
- , pt = -(_ * at - k * ct + j * lt)
- , dt = +(_ * st - b * ct + j * ft)
- , _t = -(_ * ut - b * lt + k * ft)
- , mt = o * ht + s * pt + c * dt + d * _t;
- if (mt === 0)
- return e.copyFrom(this),
- this;
- var vt = 1 / mt
- , yt = k * ot - nt * j
- , Et = b * ot - it * j
- , At = b * nt - it * k
- , gt = _ * ot - rt * j
- , St = _ * nt - rt * k
- , xt = _ * it - rt * b
- , bt = k * tt - et * j
- , Rt = b * tt - _e * j
- , Mt = b * et - _e * k
- , Pt = _ * tt - $ * j
- , It = _ * et - $ * k
- , Dt = _ * _e - $ * b
- , Ct = -(s * at - c * st + d * ut)
- , Ot = +(o * at - c * ct + d * lt)
- , wt = -(o * st - s * ct + d * ft)
- , Nt = +(o * ut - s * lt + c * ft)
- , Ft = +(s * yt - c * Et + d * At)
- , Vt = -(o * yt - c * gt + d * St)
- , Lt = +(o * Et - s * gt + d * xt)
- , kt = -(o * At - s * St + c * xt)
- , Bt = -(s * bt - c * Rt + d * Mt)
- , Ut = +(o * bt - c * Pt + d * It)
- , Gt = -(o * Rt - s * Pt + d * Dt)
- , Ht = +(o * Mt - s * It + c * Dt);
- 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),
- this
- }
- ,
- a.prototype.addAtIndex = function(e, i) {
- return this._m[e] += i,
- this._markAsUpdated(),
- this
- }
- ,
- a.prototype.multiplyAtIndex = function(e, i) {
- return this._m[e] *= i,
- this._markAsUpdated(),
- this
- }
- ,
- a.prototype.setTranslationFromFloats = function(e, i, o) {
- return this._m[12] = e,
- this._m[13] = i,
- this._m[14] = o,
- this._markAsUpdated(),
- this
- }
- ,
- a.prototype.addTranslationFromFloats = function(e, i, o) {
- return this._m[12] += e,
- this._m[13] += i,
- this._m[14] += o,
- this._markAsUpdated(),
- this
- }
- ,
- a.prototype.setTranslation = function(e) {
- return this.setTranslationFromFloats(e._x, e._y, e._z)
- }
- ,
- a.prototype.getTranslation = function() {
- return new Vector3(this._m[12],this._m[13],this._m[14])
- }
- ,
- a.prototype.getTranslationToRef = function(e) {
- return e.x = this._m[12],
- e.y = this._m[13],
- e.z = this._m[14],
- this
- }
- ,
- a.prototype.removeRotationAndScaling = function() {
- var e = this.m;
- return a.FromValuesToRef(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, e[12], e[13], e[14], e[15], this),
- this._updateIdentityStatus(e[12] === 0 && e[13] === 0 && e[14] === 0 && e[15] === 1),
- this
- }
- ,
- a.prototype.multiply = function(e) {
- var i = new a;
- return this.multiplyToRef(e, i),
- i
- }
- ,
- a.prototype.copyFrom = function(e) {
- e.copyToArray(this._m);
- var i = e;
- return this.updateFlag = i.updateFlag,
- this._updateIdentityStatus(i._isIdentity, i._isIdentityDirty, i._isIdentity3x2, i._isIdentity3x2Dirty),
- this
- }
- ,
- a.prototype.copyToArray = function(e, i) {
- i === void 0 && (i = 0);
- var o = this._m;
- return e[i] = o[0],
- e[i + 1] = o[1],
- e[i + 2] = o[2],
- e[i + 3] = o[3],
- e[i + 4] = o[4],
- e[i + 5] = o[5],
- e[i + 6] = o[6],
- e[i + 7] = o[7],
- e[i + 8] = o[8],
- e[i + 9] = o[9],
- e[i + 10] = o[10],
- e[i + 11] = o[11],
- e[i + 12] = o[12],
- e[i + 13] = o[13],
- e[i + 14] = o[14],
- e[i + 15] = o[15],
- this
- }
- ,
- a.prototype.multiplyToRef = function(e, i) {
- return this._isIdentity ? (i.copyFrom(e),
- this) : e._isIdentity ? (i.copyFrom(this),
- this) : (this.multiplyToArray(e, i._m, 0),
- i._markAsUpdated(),
- this)
- }
- ,
- a.prototype.multiplyToArray = function(e, i, o) {
- var s = this._m
- , c = e.m
- , d = s[0]
- , _ = s[1]
- , b = s[2]
- , k = s[3]
- , j = s[4]
- , $ = s[5]
- , _e = s[6]
- , et = s[7]
- , tt = s[8]
- , rt = s[9]
- , it = s[10]
- , nt = s[11]
- , ot = s[12]
- , at = s[13]
- , st = s[14]
- , ut = s[15]
- , ct = c[0]
- , lt = c[1]
- , ft = c[2]
- , ht = c[3]
- , pt = c[4]
- , dt = c[5]
- , _t = c[6]
- , mt = c[7]
- , vt = c[8]
- , yt = c[9]
- , Et = c[10]
- , At = c[11]
- , gt = c[12]
- , St = c[13]
- , xt = c[14]
- , bt = c[15];
- return i[o] = d * ct + _ * pt + b * vt + k * gt,
- i[o + 1] = d * lt + _ * dt + b * yt + k * St,
- i[o + 2] = d * ft + _ * _t + b * Et + k * xt,
- i[o + 3] = d * ht + _ * mt + b * At + k * bt,
- i[o + 4] = j * ct + $ * pt + _e * vt + et * gt,
- i[o + 5] = j * lt + $ * dt + _e * yt + et * St,
- i[o + 6] = j * ft + $ * _t + _e * Et + et * xt,
- i[o + 7] = j * ht + $ * mt + _e * At + et * bt,
- i[o + 8] = tt * ct + rt * pt + it * vt + nt * gt,
- i[o + 9] = tt * lt + rt * dt + it * yt + nt * St,
- i[o + 10] = tt * ft + rt * _t + it * Et + nt * xt,
- i[o + 11] = tt * ht + rt * mt + it * At + nt * bt,
- i[o + 12] = ot * ct + at * pt + st * vt + ut * gt,
- i[o + 13] = ot * lt + at * dt + st * yt + ut * St,
- i[o + 14] = ot * ft + at * _t + st * Et + ut * xt,
- i[o + 15] = ot * ht + at * mt + st * At + ut * bt,
- this
- }
- ,
- a.prototype.equals = function(e) {
- var i = e;
- if (!i)
- return !1;
- if ((this._isIdentity || i._isIdentity) && !this._isIdentityDirty && !i._isIdentityDirty)
- return this._isIdentity && i._isIdentity;
- var o = this.m
- , s = i.m;
- 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]
- }
- ,
- a.prototype.clone = function() {
- var e = new a;
- return e.copyFrom(this),
- e
- }
- ,
- a.prototype.getClassName = function() {
- return "Matrix"
- }
- ,
- a.prototype.getHashCode = function() {
- for (var e = this._m[0] | 0, i = 1; i < 16; i++)
- e = e * 397 ^ (this._m[i] | 0);
- return e
- }
- ,
- a.prototype.decomposeToTransformNode = function(e) {
- return e.rotationQuaternion = e.rotationQuaternion || new Quaternion,
- this.decompose(e.scaling, e.rotationQuaternion, e.position)
- }
- ,
- a.prototype.decompose = function(e, i, o, s) {
- if (this._isIdentity)
- return o && o.setAll(0),
- e && e.setAll(1),
- i && i.copyFromFloats(0, 0, 0, 1),
- !0;
- var c = this._m;
- if (o && o.copyFromFloats(c[12], c[13], c[14]),
- e = e || MathTmp.Vector3[0],
- e.x = Math.sqrt(c[0] * c[0] + c[1] * c[1] + c[2] * c[2]),
- e.y = Math.sqrt(c[4] * c[4] + c[5] * c[5] + c[6] * c[6]),
- e.z = Math.sqrt(c[8] * c[8] + c[9] * c[9] + c[10] * c[10]),
- s) {
- var d = s.scaling.x < 0 ? -1 : 1
- , _ = s.scaling.y < 0 ? -1 : 1
- , b = s.scaling.z < 0 ? -1 : 1;
- e.x *= d,
- e.y *= _,
- e.z *= b
- } else
- this.determinant() <= 0 && (e.y *= -1);
- if (e._x === 0 || e._y === 0 || e._z === 0)
- return i && i.copyFromFloats(0, 0, 0, 1),
- !1;
- if (i) {
- var k = 1 / e._x
- , j = 1 / e._y
- , $ = 1 / e._z;
- 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]),
- Quaternion.FromRotationMatrixToRef(MathTmp.Matrix[0], i)
- }
- return !0
- }
- ,
- a.prototype.getRow = function(e) {
- if (e < 0 || e > 3)
- return null;
- var i = e * 4;
- return new Vector4(this._m[i + 0],this._m[i + 1],this._m[i + 2],this._m[i + 3])
- }
- ,
- a.prototype.setRow = function(e, i) {
- return this.setRowFromFloats(e, i.x, i.y, i.z, i.w)
- }
- ,
- a.prototype.transpose = function() {
- return a.Transpose(this)
- }
- ,
- a.prototype.transposeToRef = function(e) {
- return a.TransposeToRef(this, e),
- this
- }
- ,
- a.prototype.setRowFromFloats = function(e, i, o, s, c) {
- if (e < 0 || e > 3)
- return this;
- var d = e * 4;
- return this._m[d + 0] = i,
- this._m[d + 1] = o,
- this._m[d + 2] = s,
- this._m[d + 3] = c,
- this._markAsUpdated(),
- this
- }
- ,
- a.prototype.scale = function(e) {
- var i = new a;
- return this.scaleToRef(e, i),
- i
- }
- ,
- a.prototype.scaleToRef = function(e, i) {
- for (var o = 0; o < 16; o++)
- i._m[o] = this._m[o] * e;
- return i._markAsUpdated(),
- this
- }
- ,
- a.prototype.scaleAndAddToRef = function(e, i) {
- for (var o = 0; o < 16; o++)
- i._m[o] += this._m[o] * e;
- return i._markAsUpdated(),
- this
- }
- ,
- a.prototype.toNormalMatrix = function(e) {
- var i = MathTmp.Matrix[0];
- this.invertToRef(i),
- i.transposeToRef(e);
- var o = e._m;
- 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)
- }
- ,
- a.prototype.getRotationMatrix = function() {
- var e = new a;
- return this.getRotationMatrixToRef(e),
- e
- }
- ,
- a.prototype.getRotationMatrixToRef = function(e) {
- var i = MathTmp.Vector3[0];
- if (!this.decompose(i))
- return a.IdentityToRef(e),
- this;
- var o = this._m
- , s = 1 / i._x
- , c = 1 / i._y
- , d = 1 / i._z;
- 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),
- this
- }
- ,
- a.prototype.toggleModelMatrixHandInPlace = function() {
- var e = this._m;
- e[2] *= -1,
- e[6] *= -1,
- e[8] *= -1,
- e[9] *= -1,
- e[14] *= -1,
- this._markAsUpdated()
- }
- ,
- a.prototype.toggleProjectionMatrixHandInPlace = function() {
- var e = this._m;
- e[8] *= -1,
- e[9] *= -1,
- e[10] *= -1,
- e[11] *= -1,
- this._markAsUpdated()
- }
- ,
- a.FromArray = function(e, i) {
- i === void 0 && (i = 0);
- var o = new a;
- return a.FromArrayToRef(e, i, o),
- o
- }
- ,
- a.FromArrayToRef = function(e, i, o) {
- for (var s = 0; s < 16; s++)
- o._m[s] = e[s + i];
- o._markAsUpdated()
- }
- ,
- a.FromFloat32ArrayToRefScaled = function(e, i, o, s) {
- for (var c = 0; c < 16; c++)
- s._m[c] = e[c + i] * o;
- s._markAsUpdated()
- }
- ,
- Object.defineProperty(a, "IdentityReadOnly", {
- get: function() {
- return a._identityReadOnly
- },
- enumerable: !1,
- configurable: !0
- }),
- a.FromValuesToRef = function(e, i, o, s, c, d, _, b, k, j, $, _e, et, tt, rt, it, nt) {
- var ot = nt._m;
- ot[0] = e,
- ot[1] = i,
- ot[2] = o,
- ot[3] = s,
- ot[4] = c,
- ot[5] = d,
- ot[6] = _,
- ot[7] = b,
- ot[8] = k,
- ot[9] = j,
- ot[10] = $,
- ot[11] = _e,
- ot[12] = et,
- ot[13] = tt,
- ot[14] = rt,
- ot[15] = it,
- nt._markAsUpdated()
- }
- ,
- a.FromValues = function(e, i, o, s, c, d, _, b, k, j, $, _e, et, tt, rt, it) {
- var nt = new a
- , ot = nt._m;
- return ot[0] = e,
- ot[1] = i,
- ot[2] = o,
- ot[3] = s,
- ot[4] = c,
- ot[5] = d,
- ot[6] = _,
- ot[7] = b,
- ot[8] = k,
- ot[9] = j,
- ot[10] = $,
- ot[11] = _e,
- ot[12] = et,
- ot[13] = tt,
- ot[14] = rt,
- ot[15] = it,
- nt._markAsUpdated(),
- nt
- }
- ,
- a.Compose = function(e, i, o) {
- var s = new a;
- return a.ComposeToRef(e, i, o, s),
- s
- }
- ,
- a.ComposeToRef = function(e, i, o, s) {
- var c = s._m
- , d = i._x
- , _ = i._y
- , b = i._z
- , k = i._w
- , j = d + d
- , $ = _ + _
- , _e = b + b
- , et = d * j
- , tt = d * $
- , rt = d * _e
- , it = _ * $
- , nt = _ * _e
- , ot = b * _e
- , at = k * j
- , st = k * $
- , ut = k * _e
- , ct = e._x
- , lt = e._y
- , ft = e._z;
- c[0] = (1 - (it + ot)) * ct,
- c[1] = (tt + ut) * ct,
- c[2] = (rt - st) * ct,
- c[3] = 0,
- c[4] = (tt - ut) * lt,
- c[5] = (1 - (et + ot)) * lt,
- c[6] = (nt + at) * lt,
- c[7] = 0,
- c[8] = (rt + st) * ft,
- c[9] = (nt - at) * ft,
- c[10] = (1 - (et + it)) * ft,
- c[11] = 0,
- c[12] = o._x,
- c[13] = o._y,
- c[14] = o._z,
- c[15] = 1,
- s._markAsUpdated()
- }
- ,
- a.Identity = function() {
- var e = a.FromValues(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
- return e._updateIdentityStatus(!0),
- e
- }
- ,
- a.IdentityToRef = function(e) {
- a.FromValuesToRef(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, e),
- e._updateIdentityStatus(!0)
- }
- ,
- a.Zero = function() {
- var e = a.FromValues(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
- return e._updateIdentityStatus(!1),
- e
- }
- ,
- a.RotationX = function(e) {
- var i = new a;
- return a.RotationXToRef(e, i),
- i
- }
- ,
- a.Invert = function(e) {
- var i = new a;
- return e.invertToRef(i),
- i
- }
- ,
- a.RotationXToRef = function(e, i) {
- var o = Math.sin(e)
- , s = Math.cos(e);
- a.FromValuesToRef(1, 0, 0, 0, 0, s, o, 0, 0, -o, s, 0, 0, 0, 0, 1, i),
- i._updateIdentityStatus(s === 1 && o === 0)
- }
- ,
- a.RotationY = function(e) {
- var i = new a;
- return a.RotationYToRef(e, i),
- i
- }
- ,
- a.RotationYToRef = function(e, i) {
- var o = Math.sin(e)
- , s = Math.cos(e);
- a.FromValuesToRef(s, 0, -o, 0, 0, 1, 0, 0, o, 0, s, 0, 0, 0, 0, 1, i),
- i._updateIdentityStatus(s === 1 && o === 0)
- }
- ,
- a.RotationZ = function(e) {
- var i = new a;
- return a.RotationZToRef(e, i),
- i
- }
- ,
- a.RotationZToRef = function(e, i) {
- var o = Math.sin(e)
- , s = Math.cos(e);
- a.FromValuesToRef(s, o, 0, 0, -o, s, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, i),
- i._updateIdentityStatus(s === 1 && o === 0)
- }
- ,
- a.RotationAxis = function(e, i) {
- var o = new a;
- return a.RotationAxisToRef(e, i, o),
- o
- }
- ,
- a.RotationAxisToRef = function(e, i, o) {
- var s = Math.sin(-i)
- , c = Math.cos(-i)
- , d = 1 - c;
- e.normalize();
- var _ = o._m;
- _[0] = e._x * e._x * d + c,
- _[1] = e._x * e._y * d - e._z * s,
- _[2] = e._x * e._z * d + e._y * s,
- _[3] = 0,
- _[4] = e._y * e._x * d + e._z * s,
- _[5] = e._y * e._y * d + c,
- _[6] = e._y * e._z * d - e._x * s,
- _[7] = 0,
- _[8] = e._z * e._x * d - e._y * s,
- _[9] = e._z * e._y * d + e._x * s,
- _[10] = e._z * e._z * d + c,
- _[11] = 0,
- _[12] = 0,
- _[13] = 0,
- _[14] = 0,
- _[15] = 1,
- o._markAsUpdated()
- }
- ,
- a.RotationAlignToRef = function(e, i, o) {
- var s = Vector3.Dot(i, e)
- , c = o._m;
- if (s < -1 + Epsilon)
- c[0] = -1,
- c[1] = 0,
- c[2] = 0,
- c[3] = 0,
- c[4] = 0,
- c[5] = -1,
- c[6] = 0,
- c[7] = 0,
- c[8] = 0,
- c[9] = 0,
- c[10] = 1,
- c[11] = 0;
- else {
- var d = Vector3.Cross(i, e)
- , _ = 1 / (1 + s);
- c[0] = d._x * d._x * _ + s,
- c[1] = d._y * d._x * _ - d._z,
- c[2] = d._z * d._x * _ + d._y,
- c[3] = 0,
- c[4] = d._x * d._y * _ + d._z,
- c[5] = d._y * d._y * _ + s,
- c[6] = d._z * d._y * _ - d._x,
- c[7] = 0,
- c[8] = d._x * d._z * _ - d._y,
- c[9] = d._y * d._z * _ + d._x,
- c[10] = d._z * d._z * _ + s,
- c[11] = 0
- }
- c[12] = 0,
- c[13] = 0,
- c[14] = 0,
- c[15] = 1,
- o._markAsUpdated()
- }
- ,
- a.RotationYawPitchRoll = function(e, i, o) {
- var s = new a;
- return a.RotationYawPitchRollToRef(e, i, o, s),
- s
- }
- ,
- a.RotationYawPitchRollToRef = function(e, i, o, s) {
- Quaternion.RotationYawPitchRollToRef(e, i, o, MathTmp.Quaternion[0]),
- MathTmp.Quaternion[0].toRotationMatrix(s)
- }
- ,
- a.Scaling = function(e, i, o) {
- var s = new a;
- return a.ScalingToRef(e, i, o, s),
- s
- }
- ,
- a.ScalingToRef = function(e, i, o, s) {
- a.FromValuesToRef(e, 0, 0, 0, 0, i, 0, 0, 0, 0, o, 0, 0, 0, 0, 1, s),
- s._updateIdentityStatus(e === 1 && i === 1 && o === 1)
- }
- ,
- a.Translation = function(e, i, o) {
- var s = new a;
- return a.TranslationToRef(e, i, o, s),
- s
- }
- ,
- a.TranslationToRef = function(e, i, o, s) {
- a.FromValuesToRef(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, e, i, o, 1, s),
- s._updateIdentityStatus(e === 0 && i === 0 && o === 0)
- }
- ,
- a.Lerp = function(e, i, o) {
- var s = new a;
- return a.LerpToRef(e, i, o, s),
- s
- }
- ,
- a.LerpToRef = function(e, i, o, s) {
- for (var c = s._m, d = e.m, _ = i.m, b = 0; b < 16; b++)
- c[b] = d[b] * (1 - o) + _[b] * o;
- s._markAsUpdated()
- }
- ,
- a.DecomposeLerp = function(e, i, o) {
- var s = new a;
- return a.DecomposeLerpToRef(e, i, o, s),
- s
- }
- ,
- a.DecomposeLerpToRef = function(e, i, o, s) {
- var c = MathTmp.Vector3[0]
- , d = MathTmp.Quaternion[0]
- , _ = MathTmp.Vector3[1];
- e.decompose(c, d, _);
- var b = MathTmp.Vector3[2]
- , k = MathTmp.Quaternion[1]
- , j = MathTmp.Vector3[3];
- i.decompose(b, k, j);
- var $ = MathTmp.Vector3[4];
- Vector3.LerpToRef(c, b, o, $);
- var _e = MathTmp.Quaternion[2];
- Quaternion.SlerpToRef(d, k, o, _e);
- var et = MathTmp.Vector3[5];
- Vector3.LerpToRef(_, j, o, et),
- a.ComposeToRef($, _e, et, s)
- }
- ,
- a.LookAtLH = function(e, i, o) {
- var s = new a;
- return a.LookAtLHToRef(e, i, o, s),
- s
- }
- ,
- a.LookAtLHToRef = function(e, i, o, s) {
- var c = MathTmp.Vector3[0]
- , d = MathTmp.Vector3[1]
- , _ = MathTmp.Vector3[2];
- i.subtractToRef(e, _),
- _.normalize(),
- Vector3.CrossToRef(o, _, c);
- var b = c.lengthSquared();
- b === 0 ? c.x = 1 : c.normalizeFromLength(Math.sqrt(b)),
- Vector3.CrossToRef(_, c, d),
- d.normalize();
- var k = -Vector3.Dot(c, e)
- , j = -Vector3.Dot(d, e)
- , $ = -Vector3.Dot(_, e);
- a.FromValuesToRef(c._x, d._x, _._x, 0, c._y, d._y, _._y, 0, c._z, d._z, _._z, 0, k, j, $, 1, s)
- }
- ,
- a.LookAtRH = function(e, i, o) {
- var s = new a;
- return a.LookAtRHToRef(e, i, o, s),
- s
- }
- ,
- a.LookAtRHToRef = function(e, i, o, s) {
- var c = MathTmp.Vector3[0]
- , d = MathTmp.Vector3[1]
- , _ = MathTmp.Vector3[2];
- e.subtractToRef(i, _),
- _.normalize(),
- Vector3.CrossToRef(o, _, c);
- var b = c.lengthSquared();
- b === 0 ? c.x = 1 : c.normalizeFromLength(Math.sqrt(b)),
- Vector3.CrossToRef(_, c, d),
- d.normalize();
- var k = -Vector3.Dot(c, e)
- , j = -Vector3.Dot(d, e)
- , $ = -Vector3.Dot(_, e);
- a.FromValuesToRef(c._x, d._x, _._x, 0, c._y, d._y, _._y, 0, c._z, d._z, _._z, 0, k, j, $, 1, s)
- }
- ,
- a.LookDirectionLH = function(e, i) {
- var o = new a;
- return a.LookDirectionLHToRef(e, i, o),
- o
- }
- ,
- a.LookDirectionLHToRef = function(e, i, o) {
- var s = MathTmp.Vector3[0];
- s.copyFrom(e),
- s.scaleInPlace(-1);
- var c = MathTmp.Vector3[1];
- Vector3.CrossToRef(i, s, c),
- 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)
- }
- ,
- a.LookDirectionRH = function(e, i) {
- var o = new a;
- return a.LookDirectionRHToRef(e, i, o),
- o
- }
- ,
- a.LookDirectionRHToRef = function(e, i, o) {
- var s = MathTmp.Vector3[2];
- Vector3.CrossToRef(i, e, s),
- 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)
- }
- ,
- a.OrthoLH = function(e, i, o, s, c) {
- var d = new a;
- return a.OrthoLHToRef(e, i, o, s, d, c),
- d
- }
- ,
- a.OrthoLHToRef = function(e, i, o, s, c, d) {
- var _ = o
- , b = s
- , k = 2 / e
- , j = 2 / i
- , $ = 2 / (b - _)
- , _e = -(b + _) / (b - _);
- a.FromValuesToRef(k, 0, 0, 0, 0, j, 0, 0, 0, 0, $, 0, 0, 0, _e, 1, c),
- d && c.multiplyToRef(mtxConvertNDCToHalfZRange, c),
- c._updateIdentityStatus(k === 1 && j === 1 && $ === 1 && _e === 0)
- }
- ,
- a.OrthoOffCenterLH = function(e, i, o, s, c, d, _) {
- var b = new a;
- return a.OrthoOffCenterLHToRef(e, i, o, s, c, d, b, _),
- b
- }
- ,
- a.OrthoOffCenterLHToRef = function(e, i, o, s, c, d, _, b) {
- var k = c
- , j = d
- , $ = 2 / (i - e)
- , _e = 2 / (s - o)
- , et = 2 / (j - k)
- , tt = -(j + k) / (j - k)
- , rt = (e + i) / (e - i)
- , it = (s + o) / (o - s);
- a.FromValuesToRef($, 0, 0, 0, 0, _e, 0, 0, 0, 0, et, 0, rt, it, tt, 1, _),
- b && _.multiplyToRef(mtxConvertNDCToHalfZRange, _),
- _._markAsUpdated()
- }
- ,
- a.OrthoOffCenterRH = function(e, i, o, s, c, d, _) {
- var b = new a;
- return a.OrthoOffCenterRHToRef(e, i, o, s, c, d, b, _),
- b
- }
- ,
- a.OrthoOffCenterRHToRef = function(e, i, o, s, c, d, _, b) {
- a.OrthoOffCenterLHToRef(e, i, o, s, c, d, _, b),
- _._m[10] *= -1
- }
- ,
- a.PerspectiveLH = function(e, i, o, s, c, d) {
- d === void 0 && (d = 0);
- var _ = new a
- , b = o
- , k = s
- , j = 2 * b / e
- , $ = 2 * b / i
- , _e = (k + b) / (k - b)
- , et = -2 * k * b / (k - b)
- , tt = Math.tan(d);
- return a.FromValuesToRef(j, 0, 0, 0, 0, $, 0, tt, 0, 0, _e, 1, 0, 0, et, 0, _),
- c && _.multiplyToRef(mtxConvertNDCToHalfZRange, _),
- _._updateIdentityStatus(!1),
- _
- }
- ,
- a.PerspectiveFovLH = function(e, i, o, s, c, d, _) {
- d === void 0 && (d = 0),
- _ === void 0 && (_ = !1);
- var b = new a;
- return a.PerspectiveFovLHToRef(e, i, o, s, b, !0, c, d, _),
- b
- }
- ,
- a.PerspectiveFovLHToRef = function(e, i, o, s, c, d, _, b, k) {
- d === void 0 && (d = !0),
- b === void 0 && (b = 0),
- k === void 0 && (k = !1);
- var j = o
- , $ = s
- , _e = 1 / Math.tan(e * .5)
- , et = d ? _e / i : _e
- , tt = d ? _e : _e * i
- , rt = k && j === 0 ? -1 : $ !== 0 ? ($ + j) / ($ - j) : 1
- , it = k && j === 0 ? 2 * $ : $ !== 0 ? -2 * $ * j / ($ - j) : -2 * j
- , nt = Math.tan(b);
- a.FromValuesToRef(et, 0, 0, 0, 0, tt, 0, nt, 0, 0, rt, 1, 0, 0, it, 0, c),
- _ && c.multiplyToRef(mtxConvertNDCToHalfZRange, c),
- c._updateIdentityStatus(!1)
- }
- ,
- a.PerspectiveFovReverseLHToRef = function(e, i, o, s, c, d, _, b) {
- d === void 0 && (d = !0),
- b === void 0 && (b = 0);
- var k = 1 / Math.tan(e * .5)
- , j = d ? k / i : k
- , $ = d ? k : k * i
- , _e = Math.tan(b);
- a.FromValuesToRef(j, 0, 0, 0, 0, $, 0, _e, 0, 0, -o, 1, 0, 0, 1, 0, c),
- _ && c.multiplyToRef(mtxConvertNDCToHalfZRange, c),
- c._updateIdentityStatus(!1)
- }
- ,
- a.PerspectiveFovRH = function(e, i, o, s, c, d, _) {
- d === void 0 && (d = 0),
- _ === void 0 && (_ = !1);
- var b = new a;
- return a.PerspectiveFovRHToRef(e, i, o, s, b, !0, c, d, _),
- b
- }
- ,
- a.PerspectiveFovRHToRef = function(e, i, o, s, c, d, _, b, k) {
- d === void 0 && (d = !0),
- b === void 0 && (b = 0),
- k === void 0 && (k = !1);
- var j = o
- , $ = s
- , _e = 1 / Math.tan(e * .5)
- , et = d ? _e / i : _e
- , tt = d ? _e : _e * i
- , rt = k && j === 0 ? 1 : $ !== 0 ? -($ + j) / ($ - j) : -1
- , it = k && j === 0 ? 2 * $ : $ !== 0 ? -2 * $ * j / ($ - j) : -2 * j
- , nt = Math.tan(b);
- a.FromValuesToRef(et, 0, 0, 0, 0, tt, 0, nt, 0, 0, rt, -1, 0, 0, it, 0, c),
- _ && c.multiplyToRef(mtxConvertNDCToHalfZRange, c),
- c._updateIdentityStatus(!1)
- }
- ,
- a.PerspectiveFovReverseRHToRef = function(e, i, o, s, c, d, _, b) {
- d === void 0 && (d = !0),
- b === void 0 && (b = 0);
- var k = 1 / Math.tan(e * .5)
- , j = d ? k / i : k
- , $ = d ? k : k * i
- , _e = Math.tan(b);
- a.FromValuesToRef(j, 0, 0, 0, 0, $, 0, _e, 0, 0, -o, -1, 0, 0, -1, 0, c),
- _ && c.multiplyToRef(mtxConvertNDCToHalfZRange, c),
- c._updateIdentityStatus(!1)
- }
- ,
- a.PerspectiveFovWebVRToRef = function(e, i, o, s, c, d, _) {
- c === void 0 && (c = !1),
- _ === void 0 && (_ = 0);
- var b = c ? -1 : 1
- , k = Math.tan(e.upDegrees * Math.PI / 180)
- , j = Math.tan(e.downDegrees * Math.PI / 180)
- , $ = Math.tan(e.leftDegrees * Math.PI / 180)
- , _e = Math.tan(e.rightDegrees * Math.PI / 180)
- , et = 2 / ($ + _e)
- , tt = 2 / (k + j)
- , rt = Math.tan(_)
- , it = s._m;
- it[0] = et,
- it[1] = it[2] = it[3] = it[4] = 0,
- it[5] = tt,
- it[6] = 0,
- it[7] = rt,
- it[8] = ($ - _e) * et * .5,
- it[9] = -((k - j) * tt * .5),
- it[10] = -o / (i - o),
- it[11] = 1 * b,
- it[12] = it[13] = it[15] = 0,
- it[14] = -(2 * o * i) / (o - i),
- d && s.multiplyToRef(mtxConvertNDCToHalfZRange, s),
- s._markAsUpdated()
- }
- ,
- a.GetFinalMatrix = function(e, i, o, s, c, d) {
- var _ = e.width
- , b = e.height
- , k = e.x
- , j = e.y
- , $ = a.FromValues(_ / 2, 0, 0, 0, 0, -b / 2, 0, 0, 0, 0, d - c, 0, k + _ / 2, b / 2 + j, c, 1)
- , _e = MathTmp.Matrix[0];
- return i.multiplyToRef(o, _e),
- _e.multiplyToRef(s, _e),
- _e.multiply($)
- }
- ,
- a.GetAsMatrix2x2 = function(e) {
- var i = e.m
- , o = [i[0], i[1], i[4], i[5]];
- return PerformanceConfigurator.MatrixUse64Bits ? o : new Float32Array(o)
- }
- ,
- a.GetAsMatrix3x3 = function(e) {
- var i = e.m
- , o = [i[0], i[1], i[2], i[4], i[5], i[6], i[8], i[9], i[10]];
- return PerformanceConfigurator.MatrixUse64Bits ? o : new Float32Array(o)
- }
- ,
- a.Transpose = function(e) {
- var i = new a;
- return a.TransposeToRef(e, i),
- i
- }
- ,
- a.TransposeToRef = function(e, i) {
- var o = i._m
- , s = e.m;
- o[0] = s[0],
- o[1] = s[4],
- o[2] = s[8],
- o[3] = s[12],
- o[4] = s[1],
- o[5] = s[5],
- o[6] = s[9],
- o[7] = s[13],
- o[8] = s[2],
- o[9] = s[6],
- o[10] = s[10],
- o[11] = s[14],
- o[12] = s[3],
- o[13] = s[7],
- o[14] = s[11],
- o[15] = s[15],
- i._markAsUpdated(),
- i._updateIdentityStatus(e._isIdentity, e._isIdentityDirty)
- }
- ,
- a.Reflection = function(e) {
- var i = new a;
- return a.ReflectionToRef(e, i),
- i
- }
- ,
- a.ReflectionToRef = function(e, i) {
- e.normalize();
- var o = e.normal.x
- , s = e.normal.y
- , c = e.normal.z
- , d = -2 * o
- , _ = -2 * s
- , b = -2 * c;
- 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)
- }
- ,
- a.FromXYZAxesToRef = function(e, i, o, s) {
- 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)
- }
- ,
- a.FromQuaternionToRef = function(e, i) {
- var o = e._x * e._x
- , s = e._y * e._y
- , c = e._z * e._z
- , d = e._x * e._y
- , _ = e._z * e._w
- , b = e._z * e._x
- , k = e._y * e._w
- , j = e._y * e._z
- , $ = e._x * e._w;
- i._m[0] = 1 - 2 * (s + c),
- i._m[1] = 2 * (d + _),
- i._m[2] = 2 * (b - k),
- i._m[3] = 0,
- i._m[4] = 2 * (d - _),
- i._m[5] = 1 - 2 * (c + o),
- i._m[6] = 2 * (j + $),
- i._m[7] = 0,
- i._m[8] = 2 * (b + k),
- i._m[9] = 2 * (j - $),
- i._m[10] = 1 - 2 * (s + o),
- i._m[11] = 0,
- i._m[12] = 0,
- i._m[13] = 0,
- i._m[14] = 0,
- i._m[15] = 1,
- i._markAsUpdated()
- }
- ,
- a._updateFlagSeed = 0,
- a._identityReadOnly = a.Identity(),
- a
- }()
- , MathTmp = function() {
- function a() {}
- return a.Vector3 = ArrayTools.BuildTuple(11, Vector3.Zero),
- a.Matrix = ArrayTools.BuildTuple(2, Matrix.Identity),
- a.Quaternion = ArrayTools.BuildTuple(3, Quaternion.Zero),
- a
- }()
- , TmpVectors = function() {
- function a() {}
- return a.Vector2 = ArrayTools.BuildTuple(3, Vector2.Zero),
- a.Vector3 = ArrayTools.BuildTuple(13, Vector3.Zero),
- a.Vector4 = ArrayTools.BuildTuple(3, Vector4.Zero),
- a.Quaternion = ArrayTools.BuildTuple(2, Quaternion.Zero),
- a.Matrix = ArrayTools.BuildTuple(8, Matrix.Identity),
- a
- }();
- RegisterClass("BABYLON.Vector2", Vector2);
- RegisterClass("BABYLON.Vector3", Vector3);
- RegisterClass("BABYLON.Vector4", Vector4);
- RegisterClass("BABYLON.Matrix", Matrix);
- var mtxConvertNDCToHalfZRange = Matrix.FromValues(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, .5, 0, 0, 0, .5, 1)
- , Buffer = function() {
- function a(e, i, o, s, c, d, _, b) {
- s === void 0 && (s = 0),
- c === void 0 && (c = !1),
- d === void 0 && (d = !1),
- _ === void 0 && (_ = !1),
- this._isAlreadyOwned = !1,
- e.getScene ? this._engine = e.getScene().getEngine() : this._engine = e,
- this._updatable = o,
- this._instanced = d,
- this._divisor = b || 1,
- i instanceof DataBuffer ? (this._data = null,
- this._buffer = i) : (this._data = i,
- this._buffer = null),
- this.byteStride = _ ? s : s * Float32Array.BYTES_PER_ELEMENT,
- c || this.create()
- }
- return a.prototype.createVertexBuffer = function(e, i, o, s, c, d, _) {
- d === void 0 && (d = !1);
- var b = d ? i : i * Float32Array.BYTES_PER_ELEMENT
- , k = s ? d ? s : s * Float32Array.BYTES_PER_ELEMENT : this.byteStride;
- 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 || _)
- }
- ,
- a.prototype.isUpdatable = function() {
- return this._updatable
- }
- ,
- a.prototype.getData = function() {
- return this._data
- }
- ,
- a.prototype.getBuffer = function() {
- return this._buffer
- }
- ,
- a.prototype.getStrideSize = function() {
- return this.byteStride / Float32Array.BYTES_PER_ELEMENT
- }
- ,
- a.prototype.create = function(e) {
- e === void 0 && (e = null),
- !(!e && this._buffer) && (e = e || this._data,
- e && (this._buffer ? this._updatable && (this._engine.updateDynamicVertexBuffer(this._buffer, e),
- this._data = e) : this._updatable ? (this._buffer = this._engine.createDynamicVertexBuffer(e),
- this._data = e) : this._buffer = this._engine.createVertexBuffer(e)))
- }
- ,
- a.prototype._rebuild = function() {
- this._buffer = null,
- this.create(this._data)
- }
- ,
- a.prototype.update = function(e) {
- this.create(e)
- }
- ,
- a.prototype.updateDirectly = function(e, i, o, s) {
- s === void 0 && (s = !1),
- !!this._buffer && this._updatable && (this._engine.updateDynamicVertexBuffer(this._buffer, e, s ? i : i * Float32Array.BYTES_PER_ELEMENT, o ? o * this.byteStride : void 0),
- this._data = null)
- }
- ,
- a.prototype._increaseReferences = function() {
- if (!!this._buffer) {
- if (!this._isAlreadyOwned) {
- this._isAlreadyOwned = !0;
- return
- }
- this._buffer.references++
- }
- }
- ,
- a.prototype.dispose = function() {
- !this._buffer || this._engine._releaseBuffer(this._buffer) && (this._buffer = null,
- this._data = null)
- }
- ,
- a
- }()
- , VertexBuffer = function() {
- function a(e, i, o, s, c, d, _, b, k, j, $, _e, et, tt) {
- if ($ === void 0 && ($ = !1),
- _e === void 0 && (_e = !1),
- et === void 0 && (et = 1),
- tt === void 0 && (tt = !1),
- i instanceof Buffer ? (this._buffer = i,
- this._ownsBuffer = tt) : (this._buffer = new Buffer(e,i,s,d,c,_,_e),
- this._ownsBuffer = !0),
- this.uniqueId = a._Counter++,
- this._kind = o,
- j == null) {
- var rt = this.getData();
- this.type = a.FLOAT,
- 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)
- } else
- this.type = j;
- var it = a.GetTypeByteLength(this.type);
- _e ? (this._size = k || (d ? d / it : a.DeduceStride(o)),
- this.byteStride = d || this._buffer.byteStride || this._size * it,
- this.byteOffset = b || 0) : (this._size = k || d || a.DeduceStride(o),
- this.byteStride = d ? d * it : this._buffer.byteStride || this._size * it,
- this.byteOffset = (b || 0) * it),
- this.normalized = $,
- this._instanced = _ !== void 0 ? _ : !1,
- this._instanceDivisor = _ ? et : 0,
- this._computeHashCode()
- }
- return Object.defineProperty(a.prototype, "instanceDivisor", {
- get: function() {
- return this._instanceDivisor
- },
- set: function(e) {
- this._instanceDivisor = e,
- e == 0 ? this._instanced = !1 : this._instanced = !0,
- this._computeHashCode()
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._computeHashCode = function() {
- this.hashCode = (this.type - 5120 << 0) + ((this.normalized ? 1 : 0) << 3) + (this._size << 4) + ((this._instanced ? 1 : 0) << 6) + (this.byteStride << 12)
- }
- ,
- a.prototype._rebuild = function() {
- !this._buffer || this._buffer._rebuild()
- }
- ,
- a.prototype.getKind = function() {
- return this._kind
- }
- ,
- a.prototype.isUpdatable = function() {
- return this._buffer.isUpdatable()
- }
- ,
- a.prototype.getData = function() {
- return this._buffer.getData()
- }
- ,
- a.prototype.getFloatData = function(e, i) {
- var o = this.getData();
- if (!o)
- return null;
- var s = this.getSize() * a.GetTypeByteLength(this.type)
- , c = e * this.getSize();
- if (this.type !== a.FLOAT || this.byteStride !== s) {
- var d = new Float32Array(c);
- return this.forEach(c, function($, _e) {
- return d[_e] = $
- }),
- d
- }
- if (!(o instanceof Array || o instanceof Float32Array) || this.byteOffset !== 0 || o.length !== c)
- if (o instanceof Array) {
- var _ = this.byteOffset / 4;
- return SliceTools.Slice(o, _, _ + c)
- } else {
- if (o instanceof ArrayBuffer)
- return new Float32Array(o,this.byteOffset,c);
- var _ = o.byteOffset + this.byteOffset;
- if (i) {
- var b = new Float32Array(c)
- , k = new Float32Array(o.buffer,_,c);
- return b.set(k),
- b
- }
- var j = _ % 4;
- return j && (_ = Math.max(0, _ - j)),
- new Float32Array(o.buffer,_,c)
- }
- return i ? SliceTools.Slice(o) : o
- }
- ,
- a.prototype.getBuffer = function() {
- return this._buffer.getBuffer()
- }
- ,
- a.prototype.getStrideSize = function() {
- return this.byteStride / a.GetTypeByteLength(this.type)
- }
- ,
- a.prototype.getOffset = function() {
- return this.byteOffset / a.GetTypeByteLength(this.type)
- }
- ,
- a.prototype.getSize = function(e) {
- return e === void 0 && (e = !1),
- e ? this._size * a.GetTypeByteLength(this.type) : this._size
- }
- ,
- a.prototype.getIsInstanced = function() {
- return this._instanced
- }
- ,
- a.prototype.getInstanceDivisor = function() {
- return this._instanceDivisor
- }
- ,
- a.prototype.create = function(e) {
- this._buffer.create(e)
- }
- ,
- a.prototype.update = function(e) {
- this._buffer.update(e)
- }
- ,
- a.prototype.updateDirectly = function(e, i, o) {
- o === void 0 && (o = !1),
- this._buffer.updateDirectly(e, i, void 0, o)
- }
- ,
- a.prototype.dispose = function() {
- this._ownsBuffer && this._buffer.dispose()
- }
- ,
- a.prototype.forEach = function(e, i) {
- a.ForEach(this._buffer.getData(), this.byteOffset, this.byteStride, this._size, this.type, e, this.normalized, i)
- }
- ,
- a.DeduceStride = function(e) {
- switch (e) {
- case a.UVKind:
- case a.UV2Kind:
- case a.UV3Kind:
- case a.UV4Kind:
- case a.UV5Kind:
- case a.UV6Kind:
- return 2;
- case a.NormalKind:
- case a.PositionKind:
- return 3;
- case a.ColorKind:
- case a.MatricesIndicesKind:
- case a.MatricesIndicesExtraKind:
- case a.MatricesWeightsKind:
- case a.MatricesWeightsExtraKind:
- case a.TangentKind:
- return 4;
- default:
- throw new Error("Invalid kind '" + e + "'")
- }
- }
- ,
- a.GetTypeByteLength = function(e) {
- switch (e) {
- case a.BYTE:
- case a.UNSIGNED_BYTE:
- return 1;
- case a.SHORT:
- case a.UNSIGNED_SHORT:
- return 2;
- case a.INT:
- case a.UNSIGNED_INT:
- case a.FLOAT:
- return 4;
- default:
- throw new Error("Invalid type '" + e + "'")
- }
- }
- ,
- a.ForEach = function(e, i, o, s, c, d, _, b) {
- if (e instanceof Array)
- for (var k = i / 4, j = o / 4, $ = 0; $ < d; $ += s) {
- for (var _e = 0; _e < s; _e++)
- b(e[k + _e], $ + _e);
- k += j
- }
- else
- for (var et = e instanceof ArrayBuffer ? new DataView(e) : new DataView(e.buffer,e.byteOffset,e.byteLength), tt = a.GetTypeByteLength(c), $ = 0; $ < d; $ += s) {
- for (var rt = i, _e = 0; _e < s; _e++) {
- var it = a._GetFloatValue(et, c, rt, _);
- b(it, $ + _e),
- rt += tt
- }
- i += o
- }
- }
- ,
- a._GetFloatValue = function(e, i, o, s) {
- switch (i) {
- case a.BYTE:
- {
- var c = e.getInt8(o);
- return s && (c = Math.max(c / 127, -1)),
- c
- }
- case a.UNSIGNED_BYTE:
- {
- var c = e.getUint8(o);
- return s && (c = c / 255),
- c
- }
- case a.SHORT:
- {
- var c = e.getInt16(o, !0);
- return s && (c = Math.max(c / 32767, -1)),
- c
- }
- case a.UNSIGNED_SHORT:
- {
- var c = e.getUint16(o, !0);
- return s && (c = c / 65535),
- c
- }
- case a.INT:
- return e.getInt32(o, !0);
- case a.UNSIGNED_INT:
- return e.getUint32(o, !0);
- case a.FLOAT:
- return e.getFloat32(o, !0);
- default:
- throw new Error("Invalid component type " + i)
- }
- }
- ,
- a._Counter = 0,
- a.BYTE = 5120,
- a.UNSIGNED_BYTE = 5121,
- a.SHORT = 5122,
- a.UNSIGNED_SHORT = 5123,
- a.INT = 5124,
- a.UNSIGNED_INT = 5125,
- a.FLOAT = 5126,
- a.PositionKind = "position",
- a.NormalKind = "normal",
- a.TangentKind = "tangent",
- a.UVKind = "uv",
- a.UV2Kind = "uv2",
- a.UV3Kind = "uv3",
- a.UV4Kind = "uv4",
- a.UV5Kind = "uv5",
- a.UV6Kind = "uv6",
- a.ColorKind = "color",
- a.MatricesIndicesKind = "matricesIndices",
- a.MatricesWeightsKind = "matricesWeights",
- a.MatricesIndicesExtraKind = "matricesIndicesExtra",
- a.MatricesWeightsExtraKind = "matricesWeightsExtra",
- a
- }()
- , Color3 = function() {
- function a(e, i, o) {
- e === void 0 && (e = 0),
- i === void 0 && (i = 0),
- o === void 0 && (o = 0),
- this.r = e,
- this.g = i,
- this.b = o
- }
- return a.prototype.toString = function() {
- return "{R: " + this.r + " G:" + this.g + " B:" + this.b + "}"
- }
- ,
- a.prototype.getClassName = function() {
- return "Color3"
- }
- ,
- a.prototype.getHashCode = function() {
- var e = this.r * 255 | 0;
- return e = e * 397 ^ (this.g * 255 | 0),
- e = e * 397 ^ (this.b * 255 | 0),
- e
- }
- ,
- a.prototype.toArray = function(e, i) {
- return i === void 0 && (i = 0),
- e[i] = this.r,
- e[i + 1] = this.g,
- e[i + 2] = this.b,
- this
- }
- ,
- a.prototype.fromArray = function(e, i) {
- return i === void 0 && (i = 0),
- a.FromArrayToRef(e, i, this),
- this
- }
- ,
- a.prototype.toColor4 = function(e) {
- return e === void 0 && (e = 1),
- new Color4(this.r,this.g,this.b,e)
- }
- ,
- a.prototype.asArray = function() {
- var e = new Array;
- return this.toArray(e, 0),
- e
- }
- ,
- a.prototype.toLuminance = function() {
- return this.r * .3 + this.g * .59 + this.b * .11
- }
- ,
- a.prototype.multiply = function(e) {
- return new a(this.r * e.r,this.g * e.g,this.b * e.b)
- }
- ,
- a.prototype.multiplyToRef = function(e, i) {
- return i.r = this.r * e.r,
- i.g = this.g * e.g,
- i.b = this.b * e.b,
- this
- }
- ,
- a.prototype.equals = function(e) {
- return e && this.r === e.r && this.g === e.g && this.b === e.b
- }
- ,
- a.prototype.equalsFloats = function(e, i, o) {
- return this.r === e && this.g === i && this.b === o
- }
- ,
- a.prototype.scale = function(e) {
- return new a(this.r * e,this.g * e,this.b * e)
- }
- ,
- a.prototype.scaleToRef = function(e, i) {
- return i.r = this.r * e,
- i.g = this.g * e,
- i.b = this.b * e,
- this
- }
- ,
- a.prototype.scaleAndAddToRef = function(e, i) {
- return i.r += this.r * e,
- i.g += this.g * e,
- i.b += this.b * e,
- this
- }
- ,
- a.prototype.clampToRef = function(e, i, o) {
- return e === void 0 && (e = 0),
- i === void 0 && (i = 1),
- o.r = Scalar.Clamp(this.r, e, i),
- o.g = Scalar.Clamp(this.g, e, i),
- o.b = Scalar.Clamp(this.b, e, i),
- this
- }
- ,
- a.prototype.add = function(e) {
- return new a(this.r + e.r,this.g + e.g,this.b + e.b)
- }
- ,
- a.prototype.addToRef = function(e, i) {
- return i.r = this.r + e.r,
- i.g = this.g + e.g,
- i.b = this.b + e.b,
- this
- }
- ,
- a.prototype.subtract = function(e) {
- return new a(this.r - e.r,this.g - e.g,this.b - e.b)
- }
- ,
- a.prototype.subtractToRef = function(e, i) {
- return i.r = this.r - e.r,
- i.g = this.g - e.g,
- i.b = this.b - e.b,
- this
- }
- ,
- a.prototype.clone = function() {
- return new a(this.r,this.g,this.b)
- }
- ,
- a.prototype.copyFrom = function(e) {
- return this.r = e.r,
- this.g = e.g,
- this.b = e.b,
- this
- }
- ,
- a.prototype.copyFromFloats = function(e, i, o) {
- return this.r = e,
- this.g = i,
- this.b = o,
- this
- }
- ,
- a.prototype.set = function(e, i, o) {
- return this.copyFromFloats(e, i, o)
- }
- ,
- a.prototype.toHexString = function() {
- var e = Math.round(this.r * 255)
- , i = Math.round(this.g * 255)
- , o = Math.round(this.b * 255);
- return "#" + Scalar.ToHex(e) + Scalar.ToHex(i) + Scalar.ToHex(o)
- }
- ,
- a.prototype.toLinearSpace = function() {
- var e = new a;
- return this.toLinearSpaceToRef(e),
- e
- }
- ,
- a.prototype.toHSV = function() {
- var e = new a;
- return this.toHSVToRef(e),
- e
- }
- ,
- a.prototype.toHSVToRef = function(e) {
- var i = this.r
- , o = this.g
- , s = this.b
- , c = Math.max(i, o, s)
- , d = Math.min(i, o, s)
- , _ = 0
- , b = 0
- , k = c
- , j = c - d;
- c !== 0 && (b = j / c),
- c != d && (c == i ? (_ = (o - s) / j,
- o < s && (_ += 6)) : c == o ? _ = (s - i) / j + 2 : c == s && (_ = (i - o) / j + 4),
- _ *= 60),
- e.r = _,
- e.g = b,
- e.b = k
- }
- ,
- a.prototype.toLinearSpaceToRef = function(e) {
- return e.r = Math.pow(this.r, ToLinearSpace),
- e.g = Math.pow(this.g, ToLinearSpace),
- e.b = Math.pow(this.b, ToLinearSpace),
- this
- }
- ,
- a.prototype.toGammaSpace = function() {
- var e = new a;
- return this.toGammaSpaceToRef(e),
- e
- }
- ,
- a.prototype.toGammaSpaceToRef = function(e) {
- return e.r = Math.pow(this.r, ToGammaSpace),
- e.g = Math.pow(this.g, ToGammaSpace),
- e.b = Math.pow(this.b, ToGammaSpace),
- this
- }
- ,
- a.HSVtoRGBToRef = function(e, i, o, s) {
- var c = o * i
- , d = e / 60
- , _ = c * (1 - Math.abs(d % 2 - 1))
- , b = 0
- , k = 0
- , j = 0;
- d >= 0 && d <= 1 ? (b = c,
- k = _) : d >= 1 && d <= 2 ? (b = _,
- k = c) : d >= 2 && d <= 3 ? (k = c,
- j = _) : d >= 3 && d <= 4 ? (k = _,
- j = c) : d >= 4 && d <= 5 ? (b = _,
- j = c) : d >= 5 && d <= 6 && (b = c,
- j = _);
- var $ = o - c;
- s.set(b + $, k + $, j + $)
- }
- ,
- a.FromHexString = function(e) {
- if (e.substring(0, 1) !== "#" || e.length !== 7)
- return new a(0,0,0);
- var i = parseInt(e.substring(1, 3), 16)
- , o = parseInt(e.substring(3, 5), 16)
- , s = parseInt(e.substring(5, 7), 16);
- return a.FromInts(i, o, s)
- }
- ,
- a.FromArray = function(e, i) {
- return i === void 0 && (i = 0),
- new a(e[i],e[i + 1],e[i + 2])
- }
- ,
- a.FromArrayToRef = function(e, i, o) {
- i === void 0 && (i = 0),
- o.r = e[i],
- o.g = e[i + 1],
- o.b = e[i + 2]
- }
- ,
- a.FromInts = function(e, i, o) {
- return new a(e / 255,i / 255,o / 255)
- }
- ,
- a.Lerp = function(e, i, o) {
- var s = new a(0,0,0);
- return a.LerpToRef(e, i, o, s),
- s
- }
- ,
- a.LerpToRef = function(e, i, o, s) {
- s.r = e.r + (i.r - e.r) * o,
- s.g = e.g + (i.g - e.g) * o,
- s.b = e.b + (i.b - e.b) * o
- }
- ,
- a.Hermite = function(e, i, o, s, c) {
- var d = c * c
- , _ = c * d
- , b = 2 * _ - 3 * d + 1
- , k = -2 * _ + 3 * d
- , j = _ - 2 * d + c
- , $ = _ - d
- , _e = e.r * b + o.r * k + i.r * j + s.r * $
- , et = e.g * b + o.g * k + i.g * j + s.g * $
- , tt = e.b * b + o.b * k + i.b * j + s.b * $;
- return new a(_e,et,tt)
- }
- ,
- a.Hermite1stDerivative = function(e, i, o, s, c) {
- var d = a.Black();
- return this.Hermite1stDerivativeToRef(e, i, o, s, c, d),
- d
- }
- ,
- a.Hermite1stDerivativeToRef = function(e, i, o, s, c, d) {
- var _ = c * c;
- d.r = (_ - c) * 6 * e.r + (3 * _ - 4 * c + 1) * i.r + (-_ + c) * 6 * o.r + (3 * _ - 2 * c) * s.r,
- d.g = (_ - c) * 6 * e.g + (3 * _ - 4 * c + 1) * i.g + (-_ + c) * 6 * o.g + (3 * _ - 2 * c) * s.g,
- d.b = (_ - c) * 6 * e.b + (3 * _ - 4 * c + 1) * i.b + (-_ + c) * 6 * o.b + (3 * _ - 2 * c) * s.b
- }
- ,
- a.Red = function() {
- return new a(1,0,0)
- }
- ,
- a.Green = function() {
- return new a(0,1,0)
- }
- ,
- a.Blue = function() {
- return new a(0,0,1)
- }
- ,
- a.Black = function() {
- return new a(0,0,0)
- }
- ,
- Object.defineProperty(a, "BlackReadOnly", {
- get: function() {
- return a._BlackReadOnly
- },
- enumerable: !1,
- configurable: !0
- }),
- a.White = function() {
- return new a(1,1,1)
- }
- ,
- a.Purple = function() {
- return new a(.5,0,.5)
- }
- ,
- a.Magenta = function() {
- return new a(1,0,1)
- }
- ,
- a.Yellow = function() {
- return new a(1,1,0)
- }
- ,
- a.Gray = function() {
- return new a(.5,.5,.5)
- }
- ,
- a.Teal = function() {
- return new a(0,1,1)
- }
- ,
- a.Random = function() {
- return new a(Math.random(),Math.random(),Math.random())
- }
- ,
- a._BlackReadOnly = a.Black(),
- a
- }()
- , Color4 = function() {
- function a(e, i, o, s) {
- e === void 0 && (e = 0),
- i === void 0 && (i = 0),
- o === void 0 && (o = 0),
- s === void 0 && (s = 1),
- this.r = e,
- this.g = i,
- this.b = o,
- this.a = s
- }
- return a.prototype.addInPlace = function(e) {
- return this.r += e.r,
- this.g += e.g,
- this.b += e.b,
- this.a += e.a,
- this
- }
- ,
- a.prototype.asArray = function() {
- var e = new Array;
- return this.toArray(e, 0),
- e
- }
- ,
- a.prototype.toArray = function(e, i) {
- return i === void 0 && (i = 0),
- e[i] = this.r,
- e[i + 1] = this.g,
- e[i + 2] = this.b,
- e[i + 3] = this.a,
- this
- }
- ,
- a.prototype.fromArray = function(e, i) {
- return i === void 0 && (i = 0),
- a.FromArrayToRef(e, i, this),
- this
- }
- ,
- a.prototype.equals = function(e) {
- return e && this.r === e.r && this.g === e.g && this.b === e.b && this.a === e.a
- }
- ,
- a.prototype.add = function(e) {
- return new a(this.r + e.r,this.g + e.g,this.b + e.b,this.a + e.a)
- }
- ,
- a.prototype.subtract = function(e) {
- return new a(this.r - e.r,this.g - e.g,this.b - e.b,this.a - e.a)
- }
- ,
- a.prototype.subtractToRef = function(e, i) {
- return i.r = this.r - e.r,
- i.g = this.g - e.g,
- i.b = this.b - e.b,
- i.a = this.a - e.a,
- this
- }
- ,
- a.prototype.scale = function(e) {
- return new a(this.r * e,this.g * e,this.b * e,this.a * e)
- }
- ,
- a.prototype.scaleToRef = function(e, i) {
- return i.r = this.r * e,
- i.g = this.g * e,
- i.b = this.b * e,
- i.a = this.a * e,
- this
- }
- ,
- a.prototype.scaleAndAddToRef = function(e, i) {
- return i.r += this.r * e,
- i.g += this.g * e,
- i.b += this.b * e,
- i.a += this.a * e,
- this
- }
- ,
- a.prototype.clampToRef = function(e, i, o) {
- return e === void 0 && (e = 0),
- i === void 0 && (i = 1),
- o.r = Scalar.Clamp(this.r, e, i),
- o.g = Scalar.Clamp(this.g, e, i),
- o.b = Scalar.Clamp(this.b, e, i),
- o.a = Scalar.Clamp(this.a, e, i),
- this
- }
- ,
- a.prototype.multiply = function(e) {
- return new a(this.r * e.r,this.g * e.g,this.b * e.b,this.a * e.a)
- }
- ,
- a.prototype.multiplyToRef = function(e, i) {
- return i.r = this.r * e.r,
- i.g = this.g * e.g,
- i.b = this.b * e.b,
- i.a = this.a * e.a,
- i
- }
- ,
- a.prototype.toString = function() {
- return "{R: " + this.r + " G:" + this.g + " B:" + this.b + " A:" + this.a + "}"
- }
- ,
- a.prototype.getClassName = function() {
- return "Color4"
- }
- ,
- a.prototype.getHashCode = function() {
- var e = this.r * 255 | 0;
- return e = e * 397 ^ (this.g * 255 | 0),
- e = e * 397 ^ (this.b * 255 | 0),
- e = e * 397 ^ (this.a * 255 | 0),
- e
- }
- ,
- a.prototype.clone = function() {
- return new a(this.r,this.g,this.b,this.a)
- }
- ,
- a.prototype.copyFrom = function(e) {
- return this.r = e.r,
- this.g = e.g,
- this.b = e.b,
- this.a = e.a,
- this
- }
- ,
- a.prototype.copyFromFloats = function(e, i, o, s) {
- return this.r = e,
- this.g = i,
- this.b = o,
- this.a = s,
- this
- }
- ,
- a.prototype.set = function(e, i, o, s) {
- return this.copyFromFloats(e, i, o, s)
- }
- ,
- a.prototype.toHexString = function(e) {
- e === void 0 && (e = !1);
- var i = Math.round(this.r * 255)
- , o = Math.round(this.g * 255)
- , s = Math.round(this.b * 255);
- if (e)
- return "#" + Scalar.ToHex(i) + Scalar.ToHex(o) + Scalar.ToHex(s);
- var c = Math.round(this.a * 255);
- return "#" + Scalar.ToHex(i) + Scalar.ToHex(o) + Scalar.ToHex(s) + Scalar.ToHex(c)
- }
- ,
- a.prototype.toLinearSpace = function() {
- var e = new a;
- return this.toLinearSpaceToRef(e),
- e
- }
- ,
- a.prototype.toLinearSpaceToRef = function(e) {
- return e.r = Math.pow(this.r, ToLinearSpace),
- e.g = Math.pow(this.g, ToLinearSpace),
- e.b = Math.pow(this.b, ToLinearSpace),
- e.a = this.a,
- this
- }
- ,
- a.prototype.toGammaSpace = function() {
- var e = new a;
- return this.toGammaSpaceToRef(e),
- e
- }
- ,
- a.prototype.toGammaSpaceToRef = function(e) {
- return e.r = Math.pow(this.r, ToGammaSpace),
- e.g = Math.pow(this.g, ToGammaSpace),
- e.b = Math.pow(this.b, ToGammaSpace),
- e.a = this.a,
- this
- }
- ,
- a.FromHexString = function(e) {
- if (e.substring(0, 1) !== "#" || e.length !== 9 && e.length !== 7)
- return new a(0,0,0,0);
- var i = parseInt(e.substring(1, 3), 16)
- , o = parseInt(e.substring(3, 5), 16)
- , s = parseInt(e.substring(5, 7), 16)
- , c = e.length === 9 ? parseInt(e.substring(7, 9), 16) : 255;
- return a.FromInts(i, o, s, c)
- }
- ,
- a.Lerp = function(e, i, o) {
- var s = new a(0,0,0,0);
- return a.LerpToRef(e, i, o, s),
- s
- }
- ,
- a.LerpToRef = function(e, i, o, s) {
- s.r = e.r + (i.r - e.r) * o,
- s.g = e.g + (i.g - e.g) * o,
- s.b = e.b + (i.b - e.b) * o,
- s.a = e.a + (i.a - e.a) * o
- }
- ,
- a.Hermite = function(e, i, o, s, c) {
- var d = c * c
- , _ = c * d
- , b = 2 * _ - 3 * d + 1
- , k = -2 * _ + 3 * d
- , j = _ - 2 * d + c
- , $ = _ - d
- , _e = e.r * b + o.r * k + i.r * j + s.r * $
- , et = e.g * b + o.g * k + i.g * j + s.g * $
- , tt = e.b * b + o.b * k + i.b * j + s.b * $
- , rt = e.a * b + o.a * k + i.a * j + s.a * $;
- return new a(_e,et,tt,rt)
- }
- ,
- a.Hermite1stDerivative = function(e, i, o, s, c) {
- var d = new a;
- return this.Hermite1stDerivativeToRef(e, i, o, s, c, d),
- d
- }
- ,
- a.Hermite1stDerivativeToRef = function(e, i, o, s, c, d) {
- var _ = c * c;
- d.r = (_ - c) * 6 * e.r + (3 * _ - 4 * c + 1) * i.r + (-_ + c) * 6 * o.r + (3 * _ - 2 * c) * s.r,
- d.g = (_ - c) * 6 * e.g + (3 * _ - 4 * c + 1) * i.g + (-_ + c) * 6 * o.g + (3 * _ - 2 * c) * s.g,
- d.b = (_ - c) * 6 * e.b + (3 * _ - 4 * c + 1) * i.b + (-_ + c) * 6 * o.b + (3 * _ - 2 * c) * s.b,
- d.a = (_ - c) * 6 * e.a + (3 * _ - 4 * c + 1) * i.a + (-_ + c) * 6 * o.a + (3 * _ - 2 * c) * s.a
- }
- ,
- a.FromColor3 = function(e, i) {
- return i === void 0 && (i = 1),
- new a(e.r,e.g,e.b,i)
- }
- ,
- a.FromArray = function(e, i) {
- return i === void 0 && (i = 0),
- new a(e[i],e[i + 1],e[i + 2],e[i + 3])
- }
- ,
- a.FromArrayToRef = function(e, i, o) {
- i === void 0 && (i = 0),
- o.r = e[i],
- o.g = e[i + 1],
- o.b = e[i + 2],
- o.a = e[i + 3]
- }
- ,
- a.FromInts = function(e, i, o, s) {
- return new a(e / 255,i / 255,o / 255,s / 255)
- }
- ,
- a.CheckColors4 = function(e, i) {
- if (e.length === i * 3) {
- for (var o = [], s = 0; s < e.length; s += 3) {
- var c = s / 3 * 4;
- o[c] = e[s],
- o[c + 1] = e[s + 1],
- o[c + 2] = e[s + 2],
- o[c + 3] = 1
- }
- return o
- }
- return e
- }
- ,
- a
- }()
- , TmpColors = function() {
- function a() {}
- return a.Color3 = ArrayTools.BuildArray(3, Color3.Black),
- a.Color4 = ArrayTools.BuildArray(3, function() {
- return new Color4(0,0,0,0)
- }),
- a
- }();
- RegisterClass("BABYLON.Color3", Color3);
- RegisterClass("BABYLON.Color4", Color4);
- var AndOrNotEvaluator = function() {
- function a() {}
- return a.Eval = function(e, i) {
- return e.match(/\([^\(\)]*\)/g) ? e = e.replace(/\([^\(\)]*\)/g, function(o) {
- return o = o.slice(1, o.length - 1),
- a._HandleParenthesisContent(o, i)
- }) : e = a._HandleParenthesisContent(e, i),
- e === "true" ? !0 : e === "false" ? !1 : a.Eval(e, i)
- }
- ,
- a._HandleParenthesisContent = function(e, i) {
- i = i || function(j) {
- return j === "true"
- }
- ;
- var o, s = e.split("||");
- for (var c in s)
- if (s.hasOwnProperty(c)) {
- var d = a._SimplifyNegation(s[c].trim())
- , _ = d.split("&&");
- if (_.length > 1)
- for (var b = 0; b < _.length; ++b) {
- var k = a._SimplifyNegation(_[b].trim());
- if (k !== "true" && k !== "false" ? k[0] === "!" ? o = !i(k.substring(1)) : o = i(k) : o = k === "true",
- !o) {
- d = "false";
- break
- }
- }
- if (o || d === "true") {
- o = !0;
- break
- }
- d !== "true" && d !== "false" ? d[0] === "!" ? o = !i(d.substring(1)) : o = i(d) : o = d === "true"
- }
- return o ? "true" : "false"
- }
- ,
- a._SimplifyNegation = function(e) {
- return e = e.replace(/^[\s!]+/, function(i) {
- return i = i.replace(/[\s]/g, function() {
- return ""
- }),
- i.length % 2 ? "!" : ""
- }),
- e = e.trim(),
- e === "!true" ? e = "false" : e === "!false" && (e = "true"),
- e
- }
- ,
- a
- }()
- , Tags = function() {
- function a() {}
- return a.EnableFor = function(e) {
- e._tags = e._tags || {},
- e.hasTags = function() {
- return a.HasTags(e)
- }
- ,
- e.addTags = function(i) {
- return a.AddTagsTo(e, i)
- }
- ,
- e.removeTags = function(i) {
- return a.RemoveTagsFrom(e, i)
- }
- ,
- e.matchesTagsQuery = function(i) {
- return a.MatchesQuery(e, i)
- }
- }
- ,
- a.DisableFor = function(e) {
- delete e._tags,
- delete e.hasTags,
- delete e.addTags,
- delete e.removeTags,
- delete e.matchesTagsQuery
- }
- ,
- a.HasTags = function(e) {
- if (!e._tags)
- return !1;
- var i = e._tags;
- for (var o in i)
- if (i.hasOwnProperty(o))
- return !0;
- return !1
- }
- ,
- a.GetTags = function(e, i) {
- if (i === void 0 && (i = !0),
- !e._tags)
- return null;
- if (i) {
- var o = [];
- for (var s in e._tags)
- e._tags.hasOwnProperty(s) && e._tags[s] === !0 && o.push(s);
- return o.join(" ")
- } else
- return e._tags
- }
- ,
- a.AddTagsTo = function(e, i) {
- if (!!i && typeof i == "string") {
- var o = i.split(" ");
- o.forEach(function(s, c, d) {
- a._AddTagTo(e, s)
- })
- }
- }
- ,
- a._AddTagTo = function(e, i) {
- i = i.trim(),
- !(i === "" || i === "true" || i === "false") && (i.match(/[\s]/) || i.match(/^([!]|([|]|[&]){2})/) || (a.EnableFor(e),
- e._tags[i] = !0))
- }
- ,
- a.RemoveTagsFrom = function(e, i) {
- if (!!a.HasTags(e)) {
- var o = i.split(" ");
- for (var s in o)
- a._RemoveTagFrom(e, o[s])
- }
- }
- ,
- a._RemoveTagFrom = function(e, i) {
- delete e._tags[i]
- }
- ,
- a.MatchesQuery = function(e, i) {
- return i === void 0 ? !0 : i === "" ? a.HasTags(e) : AndOrNotEvaluator.Eval(i, function(o) {
- return a.HasTags(e) && e._tags[o]
- })
- }
- ,
- a
- }()
- , __decoratorInitialStore$1 = {}
- , __mergedStore$1 = {}
- , _copySource$1 = function(a, e, i) {
- var o = a();
- Tags && Tags.AddTagsTo(o, e.tags);
- var s = getMergedStore(o);
- for (var c in s) {
- var d = s[c]
- , _ = e[c]
- , b = d.type;
- if (_ != null && (c !== "uniqueId" || SerializationHelper.AllowLoadingUniqueId))
- switch (b) {
- case 0:
- case 6:
- case 11:
- o[c] = _;
- break;
- case 1:
- o[c] = i || _.isRenderTarget ? _ : _.clone();
- break;
- case 2:
- case 3:
- case 4:
- case 5:
- case 7:
- case 10:
- case 12:
- o[c] = i ? _ : _.clone();
- break
- }
- }
- return o
- };
- function getDirectStore$1(a) {
- var e = a.getClassName();
- return __decoratorInitialStore$1[e] || (__decoratorInitialStore$1[e] = {}),
- __decoratorInitialStore$1[e]
- }
- function getMergedStore(a) {
- var e = a.getClassName();
- if (__mergedStore$1[e])
- return __mergedStore$1[e];
- __mergedStore$1[e] = {};
- for (var i = __mergedStore$1[e], o = a, s = e; s; ) {
- var c = __decoratorInitialStore$1[s];
- for (var d in c)
- i[d] = c[d];
- var _ = void 0
- , b = !1;
- do {
- if (_ = Object.getPrototypeOf(o),
- !_.getClassName) {
- b = !0;
- break
- }
- if (_.getClassName() !== s)
- break;
- o = _
- } while (_);
- if (b)
- break;
- s = _.getClassName(),
- o = _
- }
- return i
- }
- function generateSerializableMember$1(a, e) {
- return function(i, o) {
- var s = getDirectStore$1(i);
- s[o] || (s[o] = {
- type: a,
- sourceName: e
- })
- }
- }
- function generateExpandMember(a, e) {
- return e === void 0 && (e = null),
- function(i, o) {
- var s = e || "_" + o;
- Object.defineProperty(i, o, {
- get: function() {
- return this[s]
- },
- set: function(c) {
- this[s] !== c && (this[s] = c,
- i[a].apply(this))
- },
- enumerable: !0,
- configurable: !0
- })
- }
- }
- function expandToProperty(a, e) {
- return e === void 0 && (e = null),
- generateExpandMember(a, e)
- }
- function serialize(a) {
- return generateSerializableMember$1(0, a)
- }
- function serializeAsTexture(a) {
- return generateSerializableMember$1(1, a)
- }
- function serializeAsColor3(a) {
- return generateSerializableMember$1(2, a)
- }
- function serializeAsFresnelParameters(a) {
- return generateSerializableMember$1(3, a)
- }
- function serializeAsVector2(a) {
- return generateSerializableMember$1(4, a)
- }
- function serializeAsVector3(a) {
- return generateSerializableMember$1(5, a)
- }
- function serializeAsMeshReference(a) {
- return generateSerializableMember$1(6, a)
- }
- function serializeAsColorCurves(a) {
- return generateSerializableMember$1(7, a)
- }
- function serializeAsColor4(a) {
- return generateSerializableMember$1(8, a)
- }
- function serializeAsImageProcessingConfiguration(a) {
- return generateSerializableMember$1(9, a)
- }
- function serializeAsQuaternion(a) {
- return generateSerializableMember$1(10, a)
- }
- function serializeAsMatrix(a) {
- return generateSerializableMember$1(12, a)
- }
- function serializeAsCameraReference(a) {
- return generateSerializableMember$1(11, a)
- }
- var SerializationHelper = function() {
- function a() {}
- return a.AppendSerializedAnimations = function(e, i) {
- if (e.animations) {
- i.animations = [];
- for (var o = 0; o < e.animations.length; o++) {
- var s = e.animations[o];
- i.animations.push(s.serialize())
- }
- }
- }
- ,
- a.Serialize = function(e, i) {
- i || (i = {}),
- Tags && (i.tags = Tags.GetTags(e));
- var o = getMergedStore(e);
- for (var s in o) {
- var c = o[s]
- , d = c.sourceName || s
- , _ = c.type
- , b = e[s];
- if (b != null && (s !== "uniqueId" || a.AllowLoadingUniqueId))
- switch (_) {
- case 0:
- i[d] = b;
- break;
- case 1:
- i[d] = b.serialize();
- break;
- case 2:
- i[d] = b.asArray();
- break;
- case 3:
- i[d] = b.serialize();
- break;
- case 4:
- i[d] = b.asArray();
- break;
- case 5:
- i[d] = b.asArray();
- break;
- case 6:
- i[d] = b.id;
- break;
- case 7:
- i[d] = b.serialize();
- break;
- case 8:
- i[d] = b.asArray();
- break;
- case 9:
- i[d] = b.serialize();
- break;
- case 10:
- i[d] = b.asArray();
- break;
- case 11:
- i[d] = b.id;
- break;
- case 12:
- i[d] = b.asArray();
- break
- }
- }
- return i
- }
- ,
- a.Parse = function(e, i, o, s) {
- s === void 0 && (s = null);
- var c = e();
- s || (s = ""),
- Tags && Tags.AddTagsTo(c, i.tags);
- var d = getMergedStore(c);
- for (var _ in d) {
- var b = d[_]
- , k = i[b.sourceName || _]
- , j = b.type;
- if (k != null && (_ !== "uniqueId" || a.AllowLoadingUniqueId)) {
- var $ = c;
- switch (j) {
- case 0:
- $[_] = k;
- break;
- case 1:
- o && ($[_] = a._TextureParser(k, o, s));
- break;
- case 2:
- $[_] = Color3.FromArray(k);
- break;
- case 3:
- $[_] = a._FresnelParametersParser(k);
- break;
- case 4:
- $[_] = Vector2.FromArray(k);
- break;
- case 5:
- $[_] = Vector3.FromArray(k);
- break;
- case 6:
- o && ($[_] = o.getLastMeshById(k));
- break;
- case 7:
- $[_] = a._ColorCurvesParser(k);
- break;
- case 8:
- $[_] = Color4.FromArray(k);
- break;
- case 9:
- $[_] = a._ImageProcessingConfigurationParser(k);
- break;
- case 10:
- $[_] = Quaternion.FromArray(k);
- break;
- case 11:
- o && ($[_] = o.getCameraById(k));
- case 12:
- $[_] = Matrix.FromArray(k);
- break
- }
- }
- }
- return c
- }
- ,
- a.Clone = function(e, i) {
- return _copySource$1(e, i, !1)
- }
- ,
- a.Instanciate = function(e, i) {
- return _copySource$1(e, i, !0)
- }
- ,
- a.AllowLoadingUniqueId = !1,
- a._ImageProcessingConfigurationParser = function(e) {
- throw _WarnImport("ImageProcessingConfiguration")
- }
- ,
- a._FresnelParametersParser = function(e) {
- throw _WarnImport("FresnelParameters")
- }
- ,
- a._ColorCurvesParser = function(e) {
- throw _WarnImport("ColorCurves")
- }
- ,
- a._TextureParser = function(e, i, o) {
- throw _WarnImport("Texture")
- }
- ,
- a
- }();
- function nativeOverride(a, e, i, o) {
- var s = i.value;
- i.value = function() {
- for (var c = [], d = 0; d < arguments.length; d++)
- c[d] = arguments[d];
- var _ = s;
- if (typeof _native != "undefined" && _native[e]) {
- var b = _native[e];
- o ? _ = function() {
- for (var k = [], j = 0; j < arguments.length; j++)
- k[j] = arguments[j];
- return o.apply(void 0, k) ? b.apply(void 0, k) : s.apply(void 0, k)
- }
- : _ = b
- }
- return a[e] = _,
- _.apply(void 0, c)
- }
- }
- nativeOverride.filter = function(a) {
- return function(e, i, o) {
- return nativeOverride(e, i, o, a)
- }
- }
- ;
- function inlineScheduler(a, e, i) {
- try {
- var o = a.next();
- o.done ? e(o) : o.value ? o.value.then(function() {
- o.value = void 0,
- e(o)
- }, i) : e(o)
- } catch (s) {
- i(s)
- }
- }
- function createYieldingScheduler(a) {
- a === void 0 && (a = 25);
- var e;
- return function(i, o, s) {
- var c = performance.now();
- e === void 0 || c - e > a ? (e = c,
- setTimeout(function() {
- inlineScheduler(i, o, s)
- }, 0)) : inlineScheduler(i, o, s)
- }
- }
- function runCoroutine(a, e, i, o, s) {
- var c = function() {
- var d, _ = function(b) {
- b.done ? i(b.value) : d === void 0 ? d = !0 : c()
- };
- do
- d = void 0,
- !s || !s.aborted ? e(a, _, o) : o(new Error("Aborted")),
- d === void 0 && (d = !1);
- while (d)
- };
- c()
- }
- function runCoroutineSync(a, e) {
- var i;
- return runCoroutine(a, inlineScheduler, function(o) {
- return i = o
- }, function(o) {
- throw o
- }, e),
- i
- }
- function runCoroutineAsync(a, e, i) {
- return new Promise(function(o, s) {
- runCoroutine(a, e, o, s, i)
- }
- )
- }
- function makeSyncFunction(a, e) {
- return function() {
- for (var i = [], o = 0; o < arguments.length; o++)
- i[o] = arguments[o];
- return runCoroutineSync(a.apply(void 0, i), e)
- }
- }
- var VertexData = function() {
- function a() {
- this._applyTo = makeSyncFunction(this._applyToCoroutine.bind(this))
- }
- return a.prototype.set = function(e, i) {
- switch (e.length || Logger$2.Warn("Setting vertex data kind '" + i + "' with an empty array"),
- i) {
- case VertexBuffer.PositionKind:
- this.positions = e;
- break;
- case VertexBuffer.NormalKind:
- this.normals = e;
- break;
- case VertexBuffer.TangentKind:
- this.tangents = e;
- break;
- case VertexBuffer.UVKind:
- this.uvs = e;
- break;
- case VertexBuffer.UV2Kind:
- this.uvs2 = e;
- break;
- case VertexBuffer.UV3Kind:
- this.uvs3 = e;
- break;
- case VertexBuffer.UV4Kind:
- this.uvs4 = e;
- break;
- case VertexBuffer.UV5Kind:
- this.uvs5 = e;
- break;
- case VertexBuffer.UV6Kind:
- this.uvs6 = e;
- break;
- case VertexBuffer.ColorKind:
- this.colors = e;
- break;
- case VertexBuffer.MatricesIndicesKind:
- this.matricesIndices = e;
- break;
- case VertexBuffer.MatricesWeightsKind:
- this.matricesWeights = e;
- break;
- case VertexBuffer.MatricesIndicesExtraKind:
- this.matricesIndicesExtra = e;
- break;
- case VertexBuffer.MatricesWeightsExtraKind:
- this.matricesWeightsExtra = e;
- break
- }
- }
- ,
- a.prototype.applyToMesh = function(e, i) {
- return this._applyTo(e, i, !1),
- this
- }
- ,
- a.prototype.applyToGeometry = function(e, i) {
- return this._applyTo(e, i, !1),
- this
- }
- ,
- a.prototype.updateMesh = function(e) {
- return this._update(e),
- this
- }
- ,
- a.prototype.updateGeometry = function(e) {
- return this._update(e),
- this
- }
- ,
- a.prototype._applyToCoroutine = function(e, i, o) {
- return i === void 0 && (i = !1),
- __generator(this, function(s) {
- switch (s.label) {
- case 0:
- return this.positions ? (e.setVerticesData(VertexBuffer.PositionKind, this.positions, i),
- o ? [4] : [3, 2]) : [3, 2];
- case 1:
- s.sent(),
- s.label = 2;
- case 2:
- return this.normals ? (e.setVerticesData(VertexBuffer.NormalKind, this.normals, i),
- o ? [4] : [3, 4]) : [3, 4];
- case 3:
- s.sent(),
- s.label = 4;
- case 4:
- return this.tangents ? (e.setVerticesData(VertexBuffer.TangentKind, this.tangents, i),
- o ? [4] : [3, 6]) : [3, 6];
- case 5:
- s.sent(),
- s.label = 6;
- case 6:
- return this.uvs ? (e.setVerticesData(VertexBuffer.UVKind, this.uvs, i),
- o ? [4] : [3, 8]) : [3, 8];
- case 7:
- s.sent(),
- s.label = 8;
- case 8:
- return this.uvs2 ? (e.setVerticesData(VertexBuffer.UV2Kind, this.uvs2, i),
- o ? [4] : [3, 10]) : [3, 10];
- case 9:
- s.sent(),
- s.label = 10;
- case 10:
- return this.uvs3 ? (e.setVerticesData(VertexBuffer.UV3Kind, this.uvs3, i),
- o ? [4] : [3, 12]) : [3, 12];
- case 11:
- s.sent(),
- s.label = 12;
- case 12:
- return this.uvs4 ? (e.setVerticesData(VertexBuffer.UV4Kind, this.uvs4, i),
- o ? [4] : [3, 14]) : [3, 14];
- case 13:
- s.sent(),
- s.label = 14;
- case 14:
- return this.uvs5 ? (e.setVerticesData(VertexBuffer.UV5Kind, this.uvs5, i),
- o ? [4] : [3, 16]) : [3, 16];
- case 15:
- s.sent(),
- s.label = 16;
- case 16:
- return this.uvs6 ? (e.setVerticesData(VertexBuffer.UV6Kind, this.uvs6, i),
- o ? [4] : [3, 18]) : [3, 18];
- case 17:
- s.sent(),
- s.label = 18;
- case 18:
- return this.colors ? (e.setVerticesData(VertexBuffer.ColorKind, this.colors, i),
- o ? [4] : [3, 20]) : [3, 20];
- case 19:
- s.sent(),
- s.label = 20;
- case 20:
- return this.matricesIndices ? (e.setVerticesData(VertexBuffer.MatricesIndicesKind, this.matricesIndices, i),
- o ? [4] : [3, 22]) : [3, 22];
- case 21:
- s.sent(),
- s.label = 22;
- case 22:
- return this.matricesWeights ? (e.setVerticesData(VertexBuffer.MatricesWeightsKind, this.matricesWeights, i),
- o ? [4] : [3, 24]) : [3, 24];
- case 23:
- s.sent(),
- s.label = 24;
- case 24:
- return this.matricesIndicesExtra ? (e.setVerticesData(VertexBuffer.MatricesIndicesExtraKind, this.matricesIndicesExtra, i),
- o ? [4] : [3, 26]) : [3, 26];
- case 25:
- s.sent(),
- s.label = 26;
- case 26:
- return this.matricesWeightsExtra ? (e.setVerticesData(VertexBuffer.MatricesWeightsExtraKind, this.matricesWeightsExtra, i),
- o ? [4] : [3, 28]) : [3, 28];
- case 27:
- s.sent(),
- s.label = 28;
- case 28:
- return this.indices ? (e.setIndices(this.indices, null, i),
- o ? [4] : [3, 30]) : [3, 31];
- case 29:
- s.sent(),
- s.label = 30;
- case 30:
- return [3, 32];
- case 31:
- e.setIndices([], null),
- s.label = 32;
- case 32:
- return [2, this]
- }
- })
- }
- ,
- a.prototype._update = function(e, i, o) {
- return this.positions && e.updateVerticesData(VertexBuffer.PositionKind, this.positions, i, o),
- this.normals && e.updateVerticesData(VertexBuffer.NormalKind, this.normals, i, o),
- this.tangents && e.updateVerticesData(VertexBuffer.TangentKind, this.tangents, i, o),
- this.uvs && e.updateVerticesData(VertexBuffer.UVKind, this.uvs, i, o),
- this.uvs2 && e.updateVerticesData(VertexBuffer.UV2Kind, this.uvs2, i, o),
- this.uvs3 && e.updateVerticesData(VertexBuffer.UV3Kind, this.uvs3, i, o),
- this.uvs4 && e.updateVerticesData(VertexBuffer.UV4Kind, this.uvs4, i, o),
- this.uvs5 && e.updateVerticesData(VertexBuffer.UV5Kind, this.uvs5, i, o),
- this.uvs6 && e.updateVerticesData(VertexBuffer.UV6Kind, this.uvs6, i, o),
- this.colors && e.updateVerticesData(VertexBuffer.ColorKind, this.colors, i, o),
- this.matricesIndices && e.updateVerticesData(VertexBuffer.MatricesIndicesKind, this.matricesIndices, i, o),
- this.matricesWeights && e.updateVerticesData(VertexBuffer.MatricesWeightsKind, this.matricesWeights, i, o),
- this.matricesIndicesExtra && e.updateVerticesData(VertexBuffer.MatricesIndicesExtraKind, this.matricesIndicesExtra, i, o),
- this.matricesWeightsExtra && e.updateVerticesData(VertexBuffer.MatricesWeightsExtraKind, this.matricesWeightsExtra, i, o),
- this.indices && e.setIndices(this.indices, null),
- this
- }
- ,
- a._TransformVector3Coordinates = function(e, i) {
- for (var o = TmpVectors.Vector3[0], s = TmpVectors.Vector3[1], c = 0; c < e.length; c += 3)
- Vector3.FromArrayToRef(e, c, o),
- Vector3.TransformCoordinatesToRef(o, i, s),
- e[c] = s.x,
- e[c + 1] = s.y,
- e[c + 2] = s.z
- }
- ,
- a._TransformVector3Normals = function(e, i) {
- for (var o = TmpVectors.Vector3[0], s = TmpVectors.Vector3[1], c = 0; c < e.length; c += 3)
- Vector3.FromArrayToRef(e, c, o),
- Vector3.TransformNormalToRef(o, i, s),
- e[c] = s.x,
- e[c + 1] = s.y,
- e[c + 2] = s.z
- }
- ,
- a._TransformVector4Normals = function(e, i) {
- for (var o = TmpVectors.Vector4[0], s = TmpVectors.Vector4[1], c = 0; c < e.length; c += 4)
- Vector4.FromArrayToRef(e, c, o),
- Vector4.TransformNormalToRef(o, i, s),
- e[c] = s.x,
- e[c + 1] = s.y,
- e[c + 2] = s.z,
- e[c + 3] = s.w
- }
- ,
- a._FlipFaces = function(e) {
- for (var i = 0; i < e.length; i += 3) {
- var o = e[i + 1];
- e[i + 1] = e[i + 2],
- e[i + 2] = o
- }
- }
- ,
- a.prototype.transform = function(e) {
- var i = e.determinant() < 0;
- return this.positions && a._TransformVector3Coordinates(this.positions, e),
- this.normals && a._TransformVector3Normals(this.normals, e),
- this.tangents && a._TransformVector4Normals(this.tangents, e),
- i && this.indices && a._FlipFaces(this.indices),
- this
- }
- ,
- a.prototype.merge = function(e, i) {
- return i === void 0 && (i = !1),
- runCoroutineSync(this._mergeCoroutine(e, i, !1))
- }
- ,
- a.prototype._mergeCoroutine = function(e, i, o) {
- var s, c, _e, d, _, b, k, j, $, _e, et, tt, rt, it, nt;
- return i === void 0 && (i = !1),
- __generator(this, function(ot) {
- switch (ot.label) {
- case 0:
- for (this._validate(),
- e = Array.isArray(e) ? e : [e],
- s = 0,
- c = e; s < c.length; s++)
- if (_e = c[s],
- _e._validate(),
- !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)
- throw new Error("Cannot merge vertex data that do not have the same set of attributes");
- if (d = e.reduce(function(at, st) {
- var ut, ct;
- return at + ((ct = (ut = st.indices) === null || ut === void 0 ? void 0 : ut.length) !== null && ct !== void 0 ? ct : 0)
- }, (rt = (tt = this.indices) === null || tt === void 0 ? void 0 : tt.length) !== null && rt !== void 0 ? rt : 0),
- !(d > 0))
- return [3, 4];
- _ = (nt = (it = this.indices) === null || it === void 0 ? void 0 : it.length) !== null && nt !== void 0 ? nt : 0,
- this.indices || (this.indices = new Array(d)),
- this.indices.length !== d && (Array.isArray(this.indices) ? this.indices.length = d : (b = i || this.indices instanceof Uint32Array ? new Uint32Array(d) : new Uint16Array(d),
- b.set(this.indices),
- this.indices = b)),
- k = this.positions ? this.positions.length / 3 : 0,
- j = 0,
- $ = e,
- ot.label = 1;
- case 1:
- if (!(j < $.length))
- return [3, 4];
- if (_e = $[j],
- !_e.indices)
- return [3, 3];
- for (et = 0; et < _e.indices.length; et++)
- this.indices[_ + et] = _e.indices[et] + k;
- return k += _e.positions.length / 3,
- _ += _e.indices.length,
- o ? [4] : [3, 3];
- case 2:
- ot.sent(),
- ot.label = 3;
- case 3:
- return j++,
- [3, 1];
- case 4:
- return this.positions = a._mergeElement(this.positions, e.map(function(at) {
- return at.positions
- })),
- o ? [4] : [3, 6];
- case 5:
- ot.sent(),
- ot.label = 6;
- case 6:
- return this.normals = a._mergeElement(this.normals, e.map(function(at) {
- return at.normals
- })),
- o ? [4] : [3, 8];
- case 7:
- ot.sent(),
- ot.label = 8;
- case 8:
- return this.tangents = a._mergeElement(this.tangents, e.map(function(at) {
- return at.tangents
- })),
- o ? [4] : [3, 10];
- case 9:
- ot.sent(),
- ot.label = 10;
- case 10:
- return this.uvs = a._mergeElement(this.uvs, e.map(function(at) {
- return at.uvs
- })),
- o ? [4] : [3, 12];
- case 11:
- ot.sent(),
- ot.label = 12;
- case 12:
- return this.uvs2 = a._mergeElement(this.uvs2, e.map(function(at) {
- return at.uvs2
- })),
- o ? [4] : [3, 14];
- case 13:
- ot.sent(),
- ot.label = 14;
- case 14:
- return this.uvs3 = a._mergeElement(this.uvs3, e.map(function(at) {
- return at.uvs3
- })),
- o ? [4] : [3, 16];
- case 15:
- ot.sent(),
- ot.label = 16;
- case 16:
- return this.uvs4 = a._mergeElement(this.uvs4, e.map(function(at) {
- return at.uvs4
- })),
- o ? [4] : [3, 18];
- case 17:
- ot.sent(),
- ot.label = 18;
- case 18:
- return this.uvs5 = a._mergeElement(this.uvs5, e.map(function(at) {
- return at.uvs5
- })),
- o ? [4] : [3, 20];
- case 19:
- ot.sent(),
- ot.label = 20;
- case 20:
- return this.uvs6 = a._mergeElement(this.uvs6, e.map(function(at) {
- return at.uvs6
- })),
- o ? [4] : [3, 22];
- case 21:
- ot.sent(),
- ot.label = 22;
- case 22:
- return this.colors = a._mergeElement(this.colors, e.map(function(at) {
- return at.colors
- })),
- o ? [4] : [3, 24];
- case 23:
- ot.sent(),
- ot.label = 24;
- case 24:
- return this.matricesIndices = a._mergeElement(this.matricesIndices, e.map(function(at) {
- return at.matricesIndices
- })),
- o ? [4] : [3, 26];
- case 25:
- ot.sent(),
- ot.label = 26;
- case 26:
- return this.matricesWeights = a._mergeElement(this.matricesWeights, e.map(function(at) {
- return at.matricesWeights
- })),
- o ? [4] : [3, 28];
- case 27:
- ot.sent(),
- ot.label = 28;
- case 28:
- return this.matricesIndicesExtra = a._mergeElement(this.matricesIndicesExtra, e.map(function(at) {
- return at.matricesIndicesExtra
- })),
- o ? [4] : [3, 30];
- case 29:
- ot.sent(),
- ot.label = 30;
- case 30:
- return this.matricesWeightsExtra = a._mergeElement(this.matricesWeightsExtra, e.map(function(at) {
- return at.matricesWeightsExtra
- })),
- [2, this]
- }
- })
- }
- ,
- a._mergeElement = function(e, i) {
- var o = i.filter(function(tt) {
- return tt != null
- });
- if (o.length === 0)
- return e;
- if (!e)
- return this._mergeElement(o[0], o.slice(1));
- var s = o.reduce(function(tt, rt) {
- return tt + rt.length
- }, e.length);
- if (e instanceof Float32Array) {
- var c = new Float32Array(s);
- c.set(e);
- for (var d = e.length, _ = 0, b = o; _ < b.length; _++) {
- var k = b[_];
- c.set(k, d),
- d += k.length
- }
- return c
- } else {
- for (var j = new Array(s), $ = 0; $ < e.length; $++)
- j[$] = e[$];
- for (var d = e.length, _e = 0, et = o; _e < et.length; _e++) {
- for (var k = et[_e], $ = 0; $ < k.length; $++)
- j[d + $] = k[$];
- d += k.length
- }
- return j
- }
- }
- ,
- a.prototype._validate = function() {
- if (!this.positions)
- throw new Error("Positions are required");
- var e = function(s, c) {
- var d = VertexBuffer.DeduceStride(s);
- if (c.length % d !== 0)
- throw new Error("The " + s + "s array count must be a multiple of " + d);
- return c.length / d
- }
- , i = e(VertexBuffer.PositionKind, this.positions)
- , o = function(s, c) {
- var d = e(s, c);
- if (d !== i)
- throw new Error("The " + s + "s element count (" + d + ") does not match the positions count (" + i + ")")
- };
- this.normals && o(VertexBuffer.NormalKind, this.normals),
- this.tangents && o(VertexBuffer.TangentKind, this.tangents),
- this.uvs && o(VertexBuffer.UVKind, this.uvs),
- this.uvs2 && o(VertexBuffer.UV2Kind, this.uvs2),
- this.uvs3 && o(VertexBuffer.UV3Kind, this.uvs3),
- this.uvs4 && o(VertexBuffer.UV4Kind, this.uvs4),
- this.uvs5 && o(VertexBuffer.UV5Kind, this.uvs5),
- this.uvs6 && o(VertexBuffer.UV6Kind, this.uvs6),
- this.colors && o(VertexBuffer.ColorKind, this.colors),
- this.matricesIndices && o(VertexBuffer.MatricesIndicesKind, this.matricesIndices),
- this.matricesWeights && o(VertexBuffer.MatricesWeightsKind, this.matricesWeights),
- this.matricesIndicesExtra && o(VertexBuffer.MatricesIndicesExtraKind, this.matricesIndicesExtra),
- this.matricesWeightsExtra && o(VertexBuffer.MatricesWeightsExtraKind, this.matricesWeightsExtra)
- }
- ,
- a.prototype.serialize = function() {
- var e = {};
- return this.positions && (e.positions = this.positions),
- this.normals && (e.normals = this.normals),
- this.tangents && (e.tangents = this.tangents),
- this.uvs && (e.uvs = this.uvs),
- this.uvs2 && (e.uvs2 = this.uvs2),
- this.uvs3 && (e.uvs3 = this.uvs3),
- this.uvs4 && (e.uvs4 = this.uvs4),
- this.uvs5 && (e.uvs5 = this.uvs5),
- this.uvs6 && (e.uvs6 = this.uvs6),
- this.colors && (e.colors = this.colors),
- this.matricesIndices && (e.matricesIndices = this.matricesIndices,
- e.matricesIndices._isExpanded = !0),
- this.matricesWeights && (e.matricesWeights = this.matricesWeights),
- this.matricesIndicesExtra && (e.matricesIndicesExtra = this.matricesIndicesExtra,
- e.matricesIndicesExtra._isExpanded = !0),
- this.matricesWeightsExtra && (e.matricesWeightsExtra = this.matricesWeightsExtra),
- e.indices = this.indices,
- e
- }
- ,
- a.ExtractFromMesh = function(e, i, o) {
- return a._ExtractFrom(e, i, o)
- }
- ,
- a.ExtractFromGeometry = function(e, i, o) {
- return a._ExtractFrom(e, i, o)
- }
- ,
- a._ExtractFrom = function(e, i, o) {
- var s = new a;
- return e.isVerticesDataPresent(VertexBuffer.PositionKind) && (s.positions = e.getVerticesData(VertexBuffer.PositionKind, i, o)),
- e.isVerticesDataPresent(VertexBuffer.NormalKind) && (s.normals = e.getVerticesData(VertexBuffer.NormalKind, i, o)),
- e.isVerticesDataPresent(VertexBuffer.TangentKind) && (s.tangents = e.getVerticesData(VertexBuffer.TangentKind, i, o)),
- e.isVerticesDataPresent(VertexBuffer.UVKind) && (s.uvs = e.getVerticesData(VertexBuffer.UVKind, i, o)),
- e.isVerticesDataPresent(VertexBuffer.UV2Kind) && (s.uvs2 = e.getVerticesData(VertexBuffer.UV2Kind, i, o)),
- e.isVerticesDataPresent(VertexBuffer.UV3Kind) && (s.uvs3 = e.getVerticesData(VertexBuffer.UV3Kind, i, o)),
- e.isVerticesDataPresent(VertexBuffer.UV4Kind) && (s.uvs4 = e.getVerticesData(VertexBuffer.UV4Kind, i, o)),
- e.isVerticesDataPresent(VertexBuffer.UV5Kind) && (s.uvs5 = e.getVerticesData(VertexBuffer.UV5Kind, i, o)),
- e.isVerticesDataPresent(VertexBuffer.UV6Kind) && (s.uvs6 = e.getVerticesData(VertexBuffer.UV6Kind, i, o)),
- e.isVerticesDataPresent(VertexBuffer.ColorKind) && (s.colors = e.getVerticesData(VertexBuffer.ColorKind, i, o)),
- e.isVerticesDataPresent(VertexBuffer.MatricesIndicesKind) && (s.matricesIndices = e.getVerticesData(VertexBuffer.MatricesIndicesKind, i, o)),
- e.isVerticesDataPresent(VertexBuffer.MatricesWeightsKind) && (s.matricesWeights = e.getVerticesData(VertexBuffer.MatricesWeightsKind, i, o)),
- e.isVerticesDataPresent(VertexBuffer.MatricesIndicesExtraKind) && (s.matricesIndicesExtra = e.getVerticesData(VertexBuffer.MatricesIndicesExtraKind, i, o)),
- e.isVerticesDataPresent(VertexBuffer.MatricesWeightsExtraKind) && (s.matricesWeightsExtra = e.getVerticesData(VertexBuffer.MatricesWeightsExtraKind, i, o)),
- s.indices = e.getIndices(i, o),
- s
- }
- ,
- a.CreateRibbon = function(e) {
- throw _WarnImport("ribbonBuilder")
- }
- ,
- a.CreateBox = function(e) {
- throw _WarnImport("boxBuilder")
- }
- ,
- a.CreateTiledBox = function(e) {
- throw _WarnImport("tiledBoxBuilder")
- }
- ,
- a.CreateTiledPlane = function(e) {
- throw _WarnImport("tiledPlaneBuilder")
- }
- ,
- a.CreateSphere = function(e) {
- throw _WarnImport("sphereBuilder")
- }
- ,
- a.CreateCylinder = function(e) {
- throw _WarnImport("cylinderBuilder")
- }
- ,
- a.CreateTorus = function(e) {
- throw _WarnImport("torusBuilder")
- }
- ,
- a.CreateLineSystem = function(e) {
- throw _WarnImport("linesBuilder")
- }
- ,
- a.CreateDashedLines = function(e) {
- throw _WarnImport("linesBuilder")
- }
- ,
- a.CreateGround = function(e) {
- throw _WarnImport("groundBuilder")
- }
- ,
- a.CreateTiledGround = function(e) {
- throw _WarnImport("groundBuilder")
- }
- ,
- a.CreateGroundFromHeightMap = function(e) {
- throw _WarnImport("groundBuilder")
- }
- ,
- a.CreatePlane = function(e) {
- throw _WarnImport("planeBuilder")
- }
- ,
- a.CreateDisc = function(e) {
- throw _WarnImport("discBuilder")
- }
- ,
- a.CreatePolygon = function(e, i, o, s, c, d, _) {
- throw _WarnImport("polygonBuilder")
- }
- ,
- a.CreateIcoSphere = function(e) {
- throw _WarnImport("icoSphereBuilder")
- }
- ,
- a.CreatePolyhedron = function(e) {
- throw _WarnImport("polyhedronBuilder")
- }
- ,
- a.CreateCapsule = function(e) {
- throw e === void 0 && (e = {
- orientation: Vector3.Up(),
- subdivisions: 2,
- tessellation: 16,
- height: 1,
- radius: .25,
- capSubdivisions: 6
- }),
- _WarnImport("capsuleBuilder")
- }
- ,
- a.CreateTorusKnot = function(e) {
- throw _WarnImport("torusKnotBuilder")
- }
- ,
- a.ComputeNormals = function(e, i, o, s) {
- var c = 0
- , d = 0
- , _ = 0
- , b = 0
- , k = 0
- , j = 0
- , $ = 0
- , _e = 0
- , et = 0
- , tt = 0
- , rt = 0
- , it = 0
- , nt = 0
- , ot = 0
- , at = 0
- , st = 0
- , ut = 0
- , ct = 0
- , lt = 0
- , ft = 0
- , ht = !1
- , pt = !1
- , dt = !1
- , _t = !1
- , mt = 1
- , vt = 0
- , yt = null;
- if (s && (ht = !!s.facetNormals,
- pt = !!s.facetPositions,
- dt = !!s.facetPartitioning,
- mt = s.useRightHandedSystem === !0 ? -1 : 1,
- vt = s.ratio || 0,
- _t = !!s.depthSort,
- yt = s.distanceTo,
- _t)) {
- yt === void 0 && (yt = Vector3.Zero());
- var Et = s.depthSortedFacets
- }
- var At = 0
- , gt = 0
- , St = 0
- , xt = 0;
- if (dt && s && s.bbSize) {
- var bt = 0
- , Rt = 0
- , Mt = 0
- , Pt = 0
- , It = 0
- , Dt = 0
- , Ct = 0
- , Ot = 0
- , wt = 0
- , Nt = 0
- , Ft = 0
- , Vt = 0
- , Lt = 0
- , kt = 0
- , Bt = 0
- , Ut = 0
- , Gt = s.bbSize.x > s.bbSize.y ? s.bbSize.x : s.bbSize.y;
- Gt = Gt > s.bbSize.z ? Gt : s.bbSize.z,
- At = s.subDiv.X * vt / s.bbSize.x,
- gt = s.subDiv.Y * vt / s.bbSize.y,
- St = s.subDiv.Z * vt / s.bbSize.z,
- xt = s.subDiv.max * s.subDiv.max,
- s.facetPartitioning.length = 0
- }
- for (c = 0; c < e.length; c++)
- o[c] = 0;
- var Ht = i.length / 3 | 0;
- for (c = 0; c < Ht; c++) {
- if (it = i[c * 3] * 3,
- nt = it + 1,
- ot = it + 2,
- at = i[c * 3 + 1] * 3,
- st = at + 1,
- ut = at + 2,
- ct = i[c * 3 + 2] * 3,
- lt = ct + 1,
- ft = ct + 2,
- d = e[it] - e[at],
- _ = e[nt] - e[st],
- b = e[ot] - e[ut],
- k = e[ct] - e[at],
- j = e[lt] - e[st],
- $ = e[ft] - e[ut],
- _e = mt * (_ * $ - b * j),
- et = mt * (b * k - d * $),
- tt = mt * (d * j - _ * k),
- rt = Math.sqrt(_e * _e + et * et + tt * tt),
- rt = rt === 0 ? 1 : rt,
- _e /= rt,
- et /= rt,
- tt /= rt,
- ht && s && (s.facetNormals[c].x = _e,
- s.facetNormals[c].y = et,
- s.facetNormals[c].z = tt),
- pt && s && (s.facetPositions[c].x = (e[it] + e[at] + e[ct]) / 3,
- s.facetPositions[c].y = (e[nt] + e[st] + e[lt]) / 3,
- s.facetPositions[c].z = (e[ot] + e[ut] + e[ft]) / 3),
- dt && s && (bt = Math.floor((s.facetPositions[c].x - s.bInfo.minimum.x * vt) * At),
- Rt = Math.floor((s.facetPositions[c].y - s.bInfo.minimum.y * vt) * gt),
- Mt = Math.floor((s.facetPositions[c].z - s.bInfo.minimum.z * vt) * St),
- Pt = Math.floor((e[it] - s.bInfo.minimum.x * vt) * At),
- It = Math.floor((e[nt] - s.bInfo.minimum.y * vt) * gt),
- Dt = Math.floor((e[ot] - s.bInfo.minimum.z * vt) * St),
- Ct = Math.floor((e[at] - s.bInfo.minimum.x * vt) * At),
- Ot = Math.floor((e[st] - s.bInfo.minimum.y * vt) * gt),
- wt = Math.floor((e[ut] - s.bInfo.minimum.z * vt) * St),
- Nt = Math.floor((e[ct] - s.bInfo.minimum.x * vt) * At),
- Ft = Math.floor((e[lt] - s.bInfo.minimum.y * vt) * gt),
- Vt = Math.floor((e[ft] - s.bInfo.minimum.z * vt) * St),
- kt = Pt + s.subDiv.max * It + xt * Dt,
- Bt = Ct + s.subDiv.max * Ot + xt * wt,
- Ut = Nt + s.subDiv.max * Ft + xt * Vt,
- Lt = bt + s.subDiv.max * Rt + xt * Mt,
- s.facetPartitioning[Lt] = s.facetPartitioning[Lt] ? s.facetPartitioning[Lt] : new Array,
- s.facetPartitioning[kt] = s.facetPartitioning[kt] ? s.facetPartitioning[kt] : new Array,
- s.facetPartitioning[Bt] = s.facetPartitioning[Bt] ? s.facetPartitioning[Bt] : new Array,
- s.facetPartitioning[Ut] = s.facetPartitioning[Ut] ? s.facetPartitioning[Ut] : new Array,
- s.facetPartitioning[kt].push(c),
- Bt != kt && s.facetPartitioning[Bt].push(c),
- Ut == Bt || Ut == kt || s.facetPartitioning[Ut].push(c),
- Lt == kt || Lt == Bt || Lt == Ut || s.facetPartitioning[Lt].push(c)),
- _t && s && s.facetPositions) {
- var zt = Et[c];
- zt.ind = c * 3,
- zt.sqDistance = Vector3.DistanceSquared(s.facetPositions[c], yt)
- }
- o[it] += _e,
- o[nt] += et,
- o[ot] += tt,
- o[at] += _e,
- o[st] += et,
- o[ut] += tt,
- o[ct] += _e,
- o[lt] += et,
- o[ft] += tt
- }
- for (c = 0; c < o.length / 3; c++)
- _e = o[c * 3],
- et = o[c * 3 + 1],
- tt = o[c * 3 + 2],
- rt = Math.sqrt(_e * _e + et * et + tt * tt),
- rt = rt === 0 ? 1 : rt,
- _e /= rt,
- et /= rt,
- tt /= rt,
- o[c * 3] = _e,
- o[c * 3 + 1] = et,
- o[c * 3 + 2] = tt
- }
- ,
- a._ComputeSides = function(e, i, o, s, c, d, _) {
- var b = o.length, k = s.length, j, $;
- switch (e = e || a.DEFAULTSIDE,
- e) {
- case a.FRONTSIDE:
- break;
- case a.BACKSIDE:
- var _e;
- for (j = 0; j < b; j += 3)
- _e = o[j],
- o[j] = o[j + 2],
- o[j + 2] = _e;
- for ($ = 0; $ < k; $++)
- s[$] = -s[$];
- break;
- case a.DOUBLESIDE:
- for (var et = i.length, tt = et / 3, rt = 0; rt < et; rt++)
- i[et + rt] = i[rt];
- for (j = 0; j < b; j += 3)
- o[j + b] = o[j + 2] + tt,
- o[j + 1 + b] = o[j + 1] + tt,
- o[j + 2 + b] = o[j] + tt;
- for ($ = 0; $ < k; $++)
- s[k + $] = -s[$];
- var it = c.length
- , nt = 0;
- for (nt = 0; nt < it; nt++)
- c[nt + it] = c[nt];
- for (d = d || new Vector4(0,0,1,1),
- _ = _ || new Vector4(0,0,1,1),
- nt = 0,
- j = 0; j < it / 2; j++)
- c[nt] = d.x + (d.z - d.x) * c[nt],
- c[nt + 1] = d.y + (d.w - d.y) * c[nt + 1],
- c[nt + it] = _.x + (_.z - _.x) * c[nt + it],
- c[nt + it + 1] = _.y + (_.w - _.y) * c[nt + it + 1],
- nt += 2;
- break
- }
- }
- ,
- a.ImportVertexData = function(e, i) {
- var o = new a
- , s = e.positions;
- s && o.set(s, VertexBuffer.PositionKind);
- var c = e.normals;
- c && o.set(c, VertexBuffer.NormalKind);
- var d = e.tangents;
- d && o.set(d, VertexBuffer.TangentKind);
- var _ = e.uvs;
- _ && o.set(_, VertexBuffer.UVKind);
- var b = e.uv2s;
- b && o.set(b, VertexBuffer.UV2Kind);
- var k = e.uv3s;
- k && o.set(k, VertexBuffer.UV3Kind);
- var j = e.uv4s;
- j && o.set(j, VertexBuffer.UV4Kind);
- var $ = e.uv5s;
- $ && o.set($, VertexBuffer.UV5Kind);
- var _e = e.uv6s;
- _e && o.set(_e, VertexBuffer.UV6Kind);
- var et = e.colors;
- et && o.set(Color4.CheckColors4(et, s.length / 3), VertexBuffer.ColorKind);
- var tt = e.matricesIndices;
- tt && o.set(tt, VertexBuffer.MatricesIndicesKind);
- var rt = e.matricesWeights;
- rt && o.set(rt, VertexBuffer.MatricesWeightsKind);
- var it = e.indices;
- it && (o.indices = it),
- i.setAllVerticesData(o, e.updatable)
- }
- ,
- a.FRONTSIDE = 0,
- a.BACKSIDE = 1,
- a.DOUBLESIDE = 2,
- a.DEFAULTSIDE = 0,
- __decorate([nativeOverride.filter(function() {
- for (var e = [], i = 0; i < arguments.length; i++)
- e[i] = arguments[i];
- var o = e[0];
- return !Array.isArray(o)
- })], a, "_TransformVector3Coordinates", null),
- __decorate([nativeOverride.filter(function() {
- for (var e = [], i = 0; i < arguments.length; i++)
- e[i] = arguments[i];
- var o = e[0];
- return !Array.isArray(o)
- })], a, "_TransformVector3Normals", null),
- __decorate([nativeOverride.filter(function() {
- for (var e = [], i = 0; i < arguments.length; i++)
- e[i] = arguments[i];
- var o = e[0];
- return !Array.isArray(o)
- })], a, "_TransformVector4Normals", null),
- __decorate([nativeOverride.filter(function() {
- for (var e = [], i = 0; i < arguments.length; i++)
- e[i] = arguments[i];
- var o = e[0];
- return !Array.isArray(o)
- })], a, "_FlipFaces", null),
- a
- }(), _InternalNodeDataInfo = function() {
- function a() {
- this._doNotSerialize = !1,
- this._isDisposed = !1,
- this._sceneRootNodesIndex = -1,
- this._isEnabled = !0,
- this._isParentEnabled = !0,
- this._isReady = !0,
- this._onEnabledStateChangedObservable = new Observable,
- this._onClonedObservable = new Observable
- }
- return a
- }(), Node$2 = function() {
- function a(e, i) {
- i === void 0 && (i = null),
- this._isDirty = !1,
- this._nodeDataStorage = new _InternalNodeDataInfo,
- this.state = "",
- this.metadata = null,
- this.reservedDataStore = null,
- this._parentContainer = null,
- this.animations = new Array,
- this._ranges = {},
- this.onReady = null,
- this._currentRenderId = -1,
- this._parentUpdateId = -1,
- this._childUpdateId = -1,
- this._waitingParentId = null,
- this._cache = {},
- this._parentNode = null,
- this._children = null,
- this._worldMatrix = Matrix.Identity(),
- this._worldMatrixDeterminant = 0,
- this._worldMatrixDeterminantIsDirty = !0,
- this._animationPropertiesOverride = null,
- this._isNode = !0,
- this.onDisposeObservable = new Observable,
- this._onDisposeObserver = null,
- this._behaviors = new Array,
- this.name = e,
- this.id = e,
- this._scene = i || EngineStore.LastCreatedScene,
- this.uniqueId = this._scene.getUniqueId(),
- this._initCache()
- }
- return a.AddNodeConstructor = function(e, i) {
- this._NodeConstructors[e] = i
- }
- ,
- a.Construct = function(e, i, o, s) {
- var c = this._NodeConstructors[e];
- return c ? c(i, o, s) : null
- }
- ,
- Object.defineProperty(a.prototype, "doNotSerialize", {
- get: function() {
- return this._nodeDataStorage._doNotSerialize ? !0 : this._parentNode ? this._parentNode.doNotSerialize : !1
- },
- set: function(e) {
- this._nodeDataStorage._doNotSerialize = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.isDisposed = function() {
- return this._nodeDataStorage._isDisposed
- }
- ,
- Object.defineProperty(a.prototype, "parent", {
- get: function() {
- return this._parentNode
- },
- set: function(e) {
- if (this._parentNode !== e) {
- var i = this._parentNode;
- if (this._parentNode && this._parentNode._children !== void 0 && this._parentNode._children !== null) {
- var o = this._parentNode._children.indexOf(this);
- o !== -1 && this._parentNode._children.splice(o, 1),
- !e && !this._nodeDataStorage._isDisposed && this._addToSceneRootNodes()
- }
- this._parentNode = e,
- this._parentNode && ((this._parentNode._children === void 0 || this._parentNode._children === null) && (this._parentNode._children = new Array),
- this._parentNode._children.push(this),
- i || this._removeFromSceneRootNodes()),
- this._syncParentEnabledState()
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._addToSceneRootNodes = function() {
- this._nodeDataStorage._sceneRootNodesIndex === -1 && (this._nodeDataStorage._sceneRootNodesIndex = this._scene.rootNodes.length,
- this._scene.rootNodes.push(this))
- }
- ,
- a.prototype._removeFromSceneRootNodes = function() {
- if (this._nodeDataStorage._sceneRootNodesIndex !== -1) {
- var e = this._scene.rootNodes
- , i = e.length - 1;
- e[this._nodeDataStorage._sceneRootNodesIndex] = e[i],
- e[this._nodeDataStorage._sceneRootNodesIndex]._nodeDataStorage._sceneRootNodesIndex = this._nodeDataStorage._sceneRootNodesIndex,
- this._scene.rootNodes.pop(),
- this._nodeDataStorage._sceneRootNodesIndex = -1
- }
- }
- ,
- Object.defineProperty(a.prototype, "animationPropertiesOverride", {
- get: function() {
- return this._animationPropertiesOverride ? this._animationPropertiesOverride : this._scene.animationPropertiesOverride
- },
- set: function(e) {
- this._animationPropertiesOverride = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.getClassName = function() {
- return "Node"
- }
- ,
- Object.defineProperty(a.prototype, "onDispose", {
- set: function(e) {
- this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver),
- this._onDisposeObserver = this.onDisposeObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "onEnabledStateChangedObservable", {
- get: function() {
- return this._nodeDataStorage._onEnabledStateChangedObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "onClonedObservable", {
- get: function() {
- return this._nodeDataStorage._onClonedObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.getScene = function() {
- return this._scene
- }
- ,
- a.prototype.getEngine = function() {
- return this._scene.getEngine()
- }
- ,
- a.prototype.addBehavior = function(e, i) {
- var o = this;
- i === void 0 && (i = !1);
- var s = this._behaviors.indexOf(e);
- return s !== -1 ? this : (e.init(),
- this._scene.isLoading && !i ? this._scene.onDataLoadedObservable.addOnce(function() {
- e.attach(o)
- }) : e.attach(this),
- this._behaviors.push(e),
- this)
- }
- ,
- a.prototype.removeBehavior = function(e) {
- var i = this._behaviors.indexOf(e);
- return i === -1 ? this : (this._behaviors[i].detach(),
- this._behaviors.splice(i, 1),
- this)
- }
- ,
- Object.defineProperty(a.prototype, "behaviors", {
- get: function() {
- return this._behaviors
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.getBehaviorByName = function(e) {
- for (var i = 0, o = this._behaviors; i < o.length; i++) {
- var s = o[i];
- if (s.name === e)
- return s
- }
- return null
- }
- ,
- a.prototype.getWorldMatrix = function() {
- return this._currentRenderId !== this._scene.getRenderId() && this.computeWorldMatrix(),
- this._worldMatrix
- }
- ,
- a.prototype._getWorldMatrixDeterminant = function() {
- return this._worldMatrixDeterminantIsDirty && (this._worldMatrixDeterminantIsDirty = !1,
- this._worldMatrixDeterminant = this._worldMatrix.determinant()),
- this._worldMatrixDeterminant
- }
- ,
- Object.defineProperty(a.prototype, "worldMatrixFromCache", {
- get: function() {
- return this._worldMatrix
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._initCache = function() {
- this._cache = {},
- this._cache.parent = void 0
- }
- ,
- a.prototype.updateCache = function(e) {
- !e && this.isSynchronized() || (this._cache.parent = this.parent,
- this._updateCache())
- }
- ,
- a.prototype._getActionManagerForTrigger = function(e, i) {
- return this.parent ? this.parent._getActionManagerForTrigger(e, !1) : null
- }
- ,
- a.prototype._updateCache = function(e) {}
- ,
- a.prototype._isSynchronized = function() {
- return !0
- }
- ,
- a.prototype._markSyncedWithParent = function() {
- this._parentNode && (this._parentUpdateId = this._parentNode._childUpdateId)
- }
- ,
- a.prototype.isSynchronizedWithParent = function() {
- return this._parentNode ? this._parentUpdateId !== this._parentNode._childUpdateId ? !1 : this._parentNode.isSynchronized() : !0
- }
- ,
- a.prototype.isSynchronized = function() {
- return this._cache.parent != this._parentNode ? (this._cache.parent = this._parentNode,
- !1) : this._parentNode && !this.isSynchronizedWithParent() ? !1 : this._isSynchronized()
- }
- ,
- a.prototype.isReady = function(e) {
- return this._nodeDataStorage._isReady
- }
- ,
- a.prototype.markAsDirty = function(e) {
- return this._currentRenderId = Number.MAX_VALUE,
- this._isDirty = !0,
- this
- }
- ,
- a.prototype.isEnabled = function(e) {
- return e === void 0 && (e = !0),
- e === !1 ? this._nodeDataStorage._isEnabled : this._nodeDataStorage._isEnabled ? this._nodeDataStorage._isParentEnabled : !1
- }
- ,
- a.prototype._syncParentEnabledState = function() {
- this._nodeDataStorage._isParentEnabled = this._parentNode ? this._parentNode.isEnabled() : !0,
- this._children && this._children.forEach(function(e) {
- e._syncParentEnabledState()
- })
- }
- ,
- a.prototype.setEnabled = function(e) {
- this._nodeDataStorage._isEnabled !== e && (this._nodeDataStorage._isEnabled = e,
- this._nodeDataStorage._onEnabledStateChangedObservable.notifyObservers(e),
- this._syncParentEnabledState())
- }
- ,
- a.prototype.isDescendantOf = function(e) {
- return this.parent ? this.parent === e ? !0 : this.parent.isDescendantOf(e) : !1
- }
- ,
- a.prototype._getDescendants = function(e, i, o) {
- if (i === void 0 && (i = !1),
- !!this._children)
- for (var s = 0; s < this._children.length; s++) {
- var c = this._children[s];
- (!o || o(c)) && e.push(c),
- i || c._getDescendants(e, !1, o)
- }
- }
- ,
- a.prototype.getDescendants = function(e, i) {
- var o = new Array;
- return this._getDescendants(o, e, i),
- o
- }
- ,
- a.prototype.getChildMeshes = function(e, i) {
- var o = [];
- return this._getDescendants(o, e, function(s) {
- return (!i || i(s)) && s.cullingStrategy !== void 0
- }),
- o
- }
- ,
- a.prototype.getChildren = function(e, i) {
- return i === void 0 && (i = !0),
- this.getDescendants(i, e)
- }
- ,
- a.prototype._setReady = function(e) {
- if (e !== this._nodeDataStorage._isReady) {
- if (!e) {
- this._nodeDataStorage._isReady = !1;
- return
- }
- this.onReady && this.onReady(this),
- this._nodeDataStorage._isReady = !0
- }
- }
- ,
- a.prototype.getAnimationByName = function(e) {
- for (var i = 0; i < this.animations.length; i++) {
- var o = this.animations[i];
- if (o.name === e)
- return o
- }
- return null
- }
- ,
- a.prototype.createAnimationRange = function(e, i, o) {
- if (!this._ranges[e]) {
- this._ranges[e] = a._AnimationRangeFactory(e, i, o);
- for (var s = 0, c = this.animations.length; s < c; s++)
- this.animations[s] && this.animations[s].createRange(e, i, o)
- }
- }
- ,
- a.prototype.deleteAnimationRange = function(e, i) {
- i === void 0 && (i = !0);
- for (var o = 0, s = this.animations.length; o < s; o++)
- this.animations[o] && this.animations[o].deleteRange(e, i);
- this._ranges[e] = null
- }
- ,
- a.prototype.getAnimationRange = function(e) {
- return this._ranges[e] || null
- }
- ,
- a.prototype.getAnimationRanges = function() {
- var e = [], i;
- for (i in this._ranges)
- e.push(this._ranges[i]);
- return e
- }
- ,
- a.prototype.beginAnimation = function(e, i, o, s) {
- var c = this.getAnimationRange(e);
- return c ? this._scene.beginAnimation(this, c.from, c.to, i, o, s) : null
- }
- ,
- a.prototype.serializeAnimationRanges = function() {
- var e = [];
- for (var i in this._ranges) {
- var o = this._ranges[i];
- if (!!o) {
- var s = {};
- s.name = i,
- s.from = o.from,
- s.to = o.to,
- e.push(s)
- }
- }
- return e
- }
- ,
- a.prototype.computeWorldMatrix = function(e) {
- return this._worldMatrix || (this._worldMatrix = Matrix.Identity()),
- this._worldMatrix
- }
- ,
- a.prototype.dispose = function(e, i) {
- if (i === void 0 && (i = !1),
- this._nodeDataStorage._isDisposed = !0,
- !e)
- for (var o = this.getDescendants(!0), s = 0, c = o; s < c.length; s++) {
- var d = c[s];
- d.dispose(e, i)
- }
- this.parent ? this.parent = null : this._removeFromSceneRootNodes(),
- this.onDisposeObservable.notifyObservers(this),
- this.onDisposeObservable.clear(),
- this.onEnabledStateChangedObservable.clear(),
- this.onClonedObservable.clear();
- for (var _ = 0, b = this._behaviors; _ < b.length; _++) {
- var k = b[_];
- k.detach()
- }
- this._behaviors = [],
- this.metadata = null
- }
- ,
- a.ParseAnimationRanges = function(e, i, o) {
- if (i.ranges)
- for (var s = 0; s < i.ranges.length; s++) {
- var c = i.ranges[s];
- e.createAnimationRange(c.name, c.from, c.to)
- }
- }
- ,
- a.prototype.getHierarchyBoundingVectors = function(e, i) {
- e === void 0 && (e = !0),
- i === void 0 && (i = null),
- this.getScene().incrementRenderId(),
- this.computeWorldMatrix(!0);
- var o, s, c = this;
- if (c.getBoundingInfo && c.subMeshes) {
- var d = c.getBoundingInfo();
- o = d.boundingBox.minimumWorld.clone(),
- s = d.boundingBox.maximumWorld.clone()
- } else
- o = new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
- s = new Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);
- if (e)
- for (var _ = this.getDescendants(!1), b = 0, k = _; b < k.length; b++) {
- var j = k[b]
- , $ = j;
- if ($.computeWorldMatrix(!0),
- !(i && !i($)) && !(!$.getBoundingInfo || $.getTotalVertices() === 0)) {
- var _e = $.getBoundingInfo()
- , et = _e.boundingBox
- , tt = et.minimumWorld
- , rt = et.maximumWorld;
- Vector3.CheckExtends(tt, o, s),
- Vector3.CheckExtends(rt, o, s)
- }
- }
- return {
- min: o,
- max: s
- }
- }
- ,
- a._AnimationRangeFactory = function(e, i, o) {
- throw _WarnImport("AnimationRange")
- }
- ,
- a._NodeConstructors = {},
- __decorate([serialize()], a.prototype, "name", void 0),
- __decorate([serialize()], a.prototype, "id", void 0),
- __decorate([serialize()], a.prototype, "uniqueId", void 0),
- __decorate([serialize()], a.prototype, "state", void 0),
- __decorate([serialize()], a.prototype, "metadata", void 0),
- a
- }(), Space;
- (function(a) {
- a[a.LOCAL = 0] = "LOCAL",
- a[a.WORLD = 1] = "WORLD",
- a[a.BONE = 2] = "BONE"
- }
- )(Space || (Space = {}));
- var Axis = function() {
- function a() {}
- return a.X = new Vector3(1,0,0),
- a.Y = new Vector3(0,1,0),
- a.Z = new Vector3(0,0,1),
- a
- }(), Coordinate;
- (function(a) {
- a[a.X = 0] = "X",
- a[a.Y = 1] = "Y",
- a[a.Z = 2] = "Z"
- }
- )(Coordinate || (Coordinate = {}));
- var TransformNode = function(a) {
- __extends(e, a);
- function e(i, o, s) {
- o === void 0 && (o = null),
- s === void 0 && (s = !0);
- var c = a.call(this, i, o) || this;
- return c._forward = new Vector3(0,0,1),
- c._forwardInverted = new Vector3(0,0,-1),
- c._up = new Vector3(0,1,0),
- c._right = new Vector3(1,0,0),
- c._rightInverted = new Vector3(-1,0,0),
- c._position = Vector3.Zero(),
- c._rotation = Vector3.Zero(),
- c._rotationQuaternion = null,
- c._scaling = Vector3.One(),
- c._transformToBoneReferal = null,
- c._isAbsoluteSynced = !1,
- c._billboardMode = e.BILLBOARDMODE_NONE,
- c._preserveParentRotationForBillboard = !1,
- c.scalingDeterminant = 1,
- c._infiniteDistance = !1,
- c.ignoreNonUniformScaling = !1,
- c.reIntegrateRotationIntoRotationQuaternion = !1,
- c._poseMatrix = null,
- c._localMatrix = Matrix.Zero(),
- c._usePivotMatrix = !1,
- c._absolutePosition = Vector3.Zero(),
- c._absoluteScaling = Vector3.Zero(),
- c._absoluteRotationQuaternion = Quaternion.Identity(),
- c._pivotMatrix = Matrix.Identity(),
- c._postMultiplyPivotMatrix = !1,
- c._isWorldMatrixFrozen = !1,
- c._indexInSceneTransformNodesArray = -1,
- c.onAfterWorldMatrixUpdateObservable = new Observable,
- c._nonUniformScaling = !1,
- s && c.getScene().addTransformNode(c),
- c
- }
- return Object.defineProperty(e.prototype, "billboardMode", {
- get: function() {
- return this._billboardMode
- },
- set: function(i) {
- this._billboardMode !== i && (this._billboardMode = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "preserveParentRotationForBillboard", {
- get: function() {
- return this._preserveParentRotationForBillboard
- },
- set: function(i) {
- i !== this._preserveParentRotationForBillboard && (this._preserveParentRotationForBillboard = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "infiniteDistance", {
- get: function() {
- return this._infiniteDistance
- },
- set: function(i) {
- this._infiniteDistance !== i && (this._infiniteDistance = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getClassName = function() {
- return "TransformNode"
- }
- ,
- Object.defineProperty(e.prototype, "position", {
- get: function() {
- return this._position
- },
- set: function(i) {
- this._position = i,
- this._isDirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.isUsingPivotMatrix = function() {
- return this._usePivotMatrix
- }
- ,
- Object.defineProperty(e.prototype, "rotation", {
- get: function() {
- return this._rotation
- },
- set: function(i) {
- this._rotation = i,
- this._rotationQuaternion = null,
- this._isDirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "scaling", {
- get: function() {
- return this._scaling
- },
- set: function(i) {
- this._scaling = i,
- this._isDirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "rotationQuaternion", {
- get: function() {
- return this._rotationQuaternion
- },
- set: function(i) {
- this._rotationQuaternion = i,
- i && this._rotation.setAll(0),
- this._isDirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "forward", {
- get: function() {
- return Vector3.Normalize(Vector3.TransformNormal(this.getScene().useRightHandedSystem ? this._forwardInverted : this._forward, this.getWorldMatrix()))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "up", {
- get: function() {
- return Vector3.Normalize(Vector3.TransformNormal(this._up, this.getWorldMatrix()))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "right", {
- get: function() {
- return Vector3.Normalize(Vector3.TransformNormal(this.getScene().useRightHandedSystem ? this._rightInverted : this._right, this.getWorldMatrix()))
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.updatePoseMatrix = function(i) {
- return this._poseMatrix ? (this._poseMatrix.copyFrom(i),
- this) : (this._poseMatrix = i.clone(),
- this)
- }
- ,
- e.prototype.getPoseMatrix = function() {
- return this._poseMatrix || (this._poseMatrix = Matrix.Identity()),
- this._poseMatrix
- }
- ,
- e.prototype._isSynchronized = function() {
- var i = this._cache;
- 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)
- }
- ,
- e.prototype._initCache = function() {
- a.prototype._initCache.call(this);
- var i = this._cache;
- i.localMatrixUpdated = !1,
- i.billboardMode = -1,
- i.infiniteDistance = !1
- }
- ,
- Object.defineProperty(e.prototype, "absolutePosition", {
- get: function() {
- return this.getAbsolutePosition()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "absoluteScaling", {
- get: function() {
- return this._syncAbsoluteScalingAndRotation(),
- this._absoluteScaling
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "absoluteRotationQuaternion", {
- get: function() {
- return this._syncAbsoluteScalingAndRotation(),
- this._absoluteRotationQuaternion
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.setPreTransformMatrix = function(i) {
- return this.setPivotMatrix(i, !1)
- }
- ,
- e.prototype.setPivotMatrix = function(i, o) {
- return o === void 0 && (o = !0),
- this._pivotMatrix.copyFrom(i),
- this._usePivotMatrix = !this._pivotMatrix.isIdentity(),
- this._cache.pivotMatrixUpdated = !0,
- this._postMultiplyPivotMatrix = o,
- this._postMultiplyPivotMatrix && (this._pivotMatrixInverse ? this._pivotMatrix.invertToRef(this._pivotMatrixInverse) : this._pivotMatrixInverse = Matrix.Invert(this._pivotMatrix)),
- this
- }
- ,
- e.prototype.getPivotMatrix = function() {
- return this._pivotMatrix
- }
- ,
- e.prototype.instantiateHierarchy = function(i, o, s) {
- i === void 0 && (i = null);
- var c = this.clone("Clone of " + (this.name || this.id), i || this.parent, !0);
- c && s && s(this, c);
- for (var d = 0, _ = this.getChildTransformNodes(!0); d < _.length; d++) {
- var b = _[d];
- b.instantiateHierarchy(c, o, s)
- }
- return c
- }
- ,
- e.prototype.freezeWorldMatrix = function(i, o) {
- return i === void 0 && (i = null),
- o === void 0 && (o = !1),
- i ? o ? (this._rotation.setAll(0),
- this._rotationQuaternion = this._rotationQuaternion || Quaternion.Identity(),
- i.decompose(this._scaling, this._rotationQuaternion, this._position),
- this.computeWorldMatrix(!0)) : (this._worldMatrix = i,
- this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]),
- this._afterComputeWorldMatrix()) : (this._isWorldMatrixFrozen = !1,
- this.computeWorldMatrix(!0)),
- this._isDirty = !1,
- this._isWorldMatrixFrozen = !0,
- this
- }
- ,
- e.prototype.unfreezeWorldMatrix = function() {
- return this._isWorldMatrixFrozen = !1,
- this.computeWorldMatrix(!0),
- this
- }
- ,
- Object.defineProperty(e.prototype, "isWorldMatrixFrozen", {
- get: function() {
- return this._isWorldMatrixFrozen
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getAbsolutePosition = function() {
- return this.computeWorldMatrix(),
- this._absolutePosition
- }
- ,
- e.prototype.setAbsolutePosition = function(i) {
- if (!i)
- return this;
- var o, s, c;
- if (i.x === void 0) {
- if (arguments.length < 3)
- return this;
- o = arguments[0],
- s = arguments[1],
- c = arguments[2]
- } else
- o = i.x,
- s = i.y,
- c = i.z;
- if (this.parent) {
- var d = TmpVectors.Matrix[0];
- this.parent.getWorldMatrix().invertToRef(d),
- Vector3.TransformCoordinatesFromFloatsToRef(o, s, c, d, this.position)
- } else
- this.position.x = o,
- this.position.y = s,
- this.position.z = c;
- return this._absolutePosition.copyFrom(i),
- this
- }
- ,
- e.prototype.setPositionWithLocalVector = function(i) {
- return this.computeWorldMatrix(),
- this.position = Vector3.TransformNormal(i, this._localMatrix),
- this
- }
- ,
- e.prototype.getPositionExpressedInLocalSpace = function() {
- this.computeWorldMatrix();
- var i = TmpVectors.Matrix[0];
- return this._localMatrix.invertToRef(i),
- Vector3.TransformNormal(this.position, i)
- }
- ,
- e.prototype.locallyTranslate = function(i) {
- return this.computeWorldMatrix(!0),
- this.position = Vector3.TransformCoordinates(i, this._localMatrix),
- this
- }
- ,
- e.prototype.lookAt = function(i, o, s, c, d) {
- o === void 0 && (o = 0),
- s === void 0 && (s = 0),
- c === void 0 && (c = 0),
- d === void 0 && (d = Space.LOCAL);
- var _ = e._lookAtVectorCache
- , b = d === Space.LOCAL ? this.position : this.getAbsolutePosition();
- if (i.subtractToRef(b, _),
- this.setDirection(_, o, s, c),
- d === Space.WORLD && this.parent)
- if (this.rotationQuaternion) {
- var k = TmpVectors.Matrix[0];
- this.rotationQuaternion.toRotationMatrix(k);
- var j = TmpVectors.Matrix[1];
- this.parent.getWorldMatrix().getRotationMatrixToRef(j),
- j.invert(),
- k.multiplyToRef(j, k),
- this.rotationQuaternion.fromRotationMatrix(k)
- } else {
- var $ = TmpVectors.Quaternion[0];
- Quaternion.FromEulerVectorToRef(this.rotation, $);
- var k = TmpVectors.Matrix[0];
- $.toRotationMatrix(k);
- var j = TmpVectors.Matrix[1];
- this.parent.getWorldMatrix().getRotationMatrixToRef(j),
- j.invert(),
- k.multiplyToRef(j, k),
- $.fromRotationMatrix(k),
- $.toEulerAnglesToRef(this.rotation)
- }
- return this
- }
- ,
- e.prototype.getDirection = function(i) {
- var o = Vector3.Zero();
- return this.getDirectionToRef(i, o),
- o
- }
- ,
- e.prototype.getDirectionToRef = function(i, o) {
- return Vector3.TransformNormalToRef(i, this.getWorldMatrix(), o),
- this
- }
- ,
- e.prototype.setDirection = function(i, o, s, c) {
- o === void 0 && (o = 0),
- s === void 0 && (s = 0),
- c === void 0 && (c = 0);
- var d = -Math.atan2(i.z, i.x) + Math.PI / 2
- , _ = Math.sqrt(i.x * i.x + i.z * i.z)
- , b = -Math.atan2(i.y, _);
- return this.rotationQuaternion ? Quaternion.RotationYawPitchRollToRef(d + o, b + s, c, this.rotationQuaternion) : (this.rotation.x = b + s,
- this.rotation.y = d + o,
- this.rotation.z = c),
- this
- }
- ,
- e.prototype.setPivotPoint = function(i, o) {
- o === void 0 && (o = Space.LOCAL),
- this.getScene().getRenderId() == 0 && this.computeWorldMatrix(!0);
- var s = this.getWorldMatrix();
- if (o == Space.WORLD) {
- var c = TmpVectors.Matrix[0];
- s.invertToRef(c),
- i = Vector3.TransformCoordinates(i, c)
- }
- return this.setPivotMatrix(Matrix.Translation(-i.x, -i.y, -i.z), !0)
- }
- ,
- e.prototype.getPivotPoint = function() {
- var i = Vector3.Zero();
- return this.getPivotPointToRef(i),
- i
- }
- ,
- e.prototype.getPivotPointToRef = function(i) {
- return i.x = -this._pivotMatrix.m[12],
- i.y = -this._pivotMatrix.m[13],
- i.z = -this._pivotMatrix.m[14],
- this
- }
- ,
- e.prototype.getAbsolutePivotPoint = function() {
- var i = Vector3.Zero();
- return this.getAbsolutePivotPointToRef(i),
- i
- }
- ,
- e.prototype.getAbsolutePivotPointToRef = function(i) {
- return this.getPivotPointToRef(i),
- Vector3.TransformCoordinatesToRef(i, this.getWorldMatrix(), i),
- this
- }
- ,
- e.prototype.markAsDirty = function(i) {
- if (this._children)
- for (var o = 0, s = this._children; o < s.length; o++) {
- var c = s[o];
- c.markAsDirty(i)
- }
- return a.prototype.markAsDirty.call(this, i)
- }
- ,
- e.prototype.setParent = function(i, o) {
- if (o === void 0 && (o = !1),
- !i && !this.parent)
- return this;
- var s = TmpVectors.Quaternion[0]
- , c = TmpVectors.Vector3[0]
- , d = TmpVectors.Vector3[1]
- , _ = TmpVectors.Matrix[1];
- Matrix.IdentityToRef(_);
- var b = TmpVectors.Matrix[0];
- this.computeWorldMatrix(!0);
- var k = this.rotationQuaternion;
- return k || (k = e._TmpRotation,
- Quaternion.RotationYawPitchRollToRef(this._rotation.y, this._rotation.x, this._rotation.z, k)),
- Matrix.ComposeToRef(this.scaling, k, this.position, b),
- this.parent && b.multiplyToRef(this.parent.computeWorldMatrix(!0), b),
- i && (i.computeWorldMatrix(!0).invertToRef(_),
- b.multiplyToRef(_, b)),
- b.decompose(d, s, c, o ? this : void 0),
- this.rotationQuaternion ? this.rotationQuaternion.copyFrom(s) : s.toEulerAnglesToRef(this.rotation),
- this.scaling.copyFrom(d),
- this.position.copyFrom(c),
- this.parent = i,
- this
- }
- ,
- Object.defineProperty(e.prototype, "nonUniformScaling", {
- get: function() {
- return this._nonUniformScaling
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._updateNonUniformScalingState = function(i) {
- return this._nonUniformScaling === i ? !1 : (this._nonUniformScaling = i,
- !0)
- }
- ,
- e.prototype.attachToBone = function(i, o) {
- return this._currentParentWhenAttachingToBone = this.parent,
- this._transformToBoneReferal = o,
- this.parent = i,
- i.getSkeleton().prepare(),
- i.getWorldMatrix().determinant() < 0 && (this.scalingDeterminant *= -1),
- this
- }
- ,
- e.prototype.detachFromBone = function(i) {
- return i === void 0 && (i = !1),
- this.parent ? (this.parent.getWorldMatrix().determinant() < 0 && (this.scalingDeterminant *= -1),
- this._transformToBoneReferal = null,
- i ? this.parent = this._currentParentWhenAttachingToBone : this.parent = null,
- this) : (i && (this.parent = this._currentParentWhenAttachingToBone),
- this)
- }
- ,
- e.prototype.rotate = function(i, o, s) {
- i.normalize(),
- this.rotationQuaternion || (this.rotationQuaternion = this.rotation.toQuaternion(),
- this.rotation.setAll(0));
- var c;
- if (!s || s === Space.LOCAL)
- c = Quaternion.RotationAxisToRef(i, o, e._rotationAxisCache),
- this.rotationQuaternion.multiplyToRef(c, this.rotationQuaternion);
- else {
- if (this.parent) {
- var d = TmpVectors.Matrix[0];
- this.parent.getWorldMatrix().invertToRef(d),
- i = Vector3.TransformNormal(i, d)
- }
- c = Quaternion.RotationAxisToRef(i, o, e._rotationAxisCache),
- c.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion)
- }
- return this
- }
- ,
- e.prototype.rotateAround = function(i, o, s) {
- o.normalize(),
- this.rotationQuaternion || (this.rotationQuaternion = Quaternion.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z),
- this.rotation.setAll(0));
- var c = TmpVectors.Vector3[0]
- , d = TmpVectors.Vector3[1]
- , _ = TmpVectors.Vector3[2]
- , b = TmpVectors.Quaternion[0]
- , k = TmpVectors.Matrix[0]
- , j = TmpVectors.Matrix[1]
- , $ = TmpVectors.Matrix[2]
- , _e = TmpVectors.Matrix[3];
- return i.subtractToRef(this.position, c),
- Matrix.TranslationToRef(c.x, c.y, c.z, k),
- Matrix.TranslationToRef(-c.x, -c.y, -c.z, j),
- Matrix.RotationAxisToRef(o, s, $),
- j.multiplyToRef($, _e),
- _e.multiplyToRef(k, _e),
- _e.decompose(d, b, _),
- this.position.addInPlace(_),
- b.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion),
- this
- }
- ,
- e.prototype.translate = function(i, o, s) {
- var c = i.scale(o);
- if (!s || s === Space.LOCAL) {
- var d = this.getPositionExpressedInLocalSpace().add(c);
- this.setPositionWithLocalVector(d)
- } else
- this.setAbsolutePosition(this.getAbsolutePosition().add(c));
- return this
- }
- ,
- e.prototype.addRotation = function(i, o, s) {
- var c;
- this.rotationQuaternion ? c = this.rotationQuaternion : (c = TmpVectors.Quaternion[1],
- Quaternion.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, c));
- var d = TmpVectors.Quaternion[0];
- return Quaternion.RotationYawPitchRollToRef(o, i, s, d),
- c.multiplyInPlace(d),
- this.rotationQuaternion || c.toEulerAnglesToRef(this.rotation),
- this
- }
- ,
- e.prototype._getEffectiveParent = function() {
- return this.parent
- }
- ,
- e.prototype.computeWorldMatrix = function(i) {
- if (this._isWorldMatrixFrozen && !this._isDirty)
- return this._worldMatrix;
- var o = this.getScene().getRenderId();
- if (!this._isDirty && !i && this.isSynchronized())
- return this._currentRenderId = o,
- this._worldMatrix;
- var s = this.getScene().activeCamera
- , c = (this._billboardMode & e.BILLBOARDMODE_USE_POSITION) !== 0
- , d = this._billboardMode !== e.BILLBOARDMODE_NONE && !this.preserveParentRotationForBillboard;
- d && s && c && (this.lookAt(s.position),
- (this.billboardMode & e.BILLBOARDMODE_X) !== e.BILLBOARDMODE_X && (this.rotation.x = 0),
- (this.billboardMode & e.BILLBOARDMODE_Y) !== e.BILLBOARDMODE_Y && (this.rotation.y = 0),
- (this.billboardMode & e.BILLBOARDMODE_Z) !== e.BILLBOARDMODE_Z && (this.rotation.z = 0)),
- this._updateCache();
- var _ = this._cache;
- _.pivotMatrixUpdated = !1,
- _.billboardMode = this.billboardMode,
- _.infiniteDistance = this.infiniteDistance,
- this._currentRenderId = o,
- this._childUpdateId += 1,
- this._isDirty = !1,
- this._position._isDirty = !1,
- this._rotation._isDirty = !1,
- this._scaling._isDirty = !1;
- var b = this._getEffectiveParent()
- , k = e._TmpScaling
- , j = this._position;
- if (this._infiniteDistance && !this.parent && s) {
- var $ = s.getWorldMatrix()
- , _e = new Vector3($.m[12],$.m[13],$.m[14]);
- j = e._TmpTranslation,
- j.copyFromFloats(this._position.x + _e.x, this._position.y + _e.y, this._position.z + _e.z)
- }
- k.copyFromFloats(this._scaling.x * this.scalingDeterminant, this._scaling.y * this.scalingDeterminant, this._scaling.z * this.scalingDeterminant);
- var et;
- if (this._rotationQuaternion) {
- if (this._rotationQuaternion._isDirty = !1,
- et = this._rotationQuaternion,
- this.reIntegrateRotationIntoRotationQuaternion) {
- var tt = this.rotation.lengthSquared();
- tt && (this._rotationQuaternion.multiplyInPlace(Quaternion.RotationYawPitchRoll(this._rotation.y, this._rotation.x, this._rotation.z)),
- this._rotation.copyFromFloats(0, 0, 0))
- }
- } else
- et = e._TmpRotation,
- Quaternion.RotationYawPitchRollToRef(this._rotation.y, this._rotation.x, this._rotation.z, et);
- if (this._usePivotMatrix) {
- var rt = TmpVectors.Matrix[1];
- Matrix.ScalingToRef(k.x, k.y, k.z, rt);
- var it = TmpVectors.Matrix[0];
- et.toRotationMatrix(it),
- this._pivotMatrix.multiplyToRef(rt, TmpVectors.Matrix[4]),
- TmpVectors.Matrix[4].multiplyToRef(it, this._localMatrix),
- this._postMultiplyPivotMatrix && this._localMatrix.multiplyToRef(this._pivotMatrixInverse, this._localMatrix),
- this._localMatrix.addTranslationFromFloats(j.x, j.y, j.z)
- } else
- Matrix.ComposeToRef(k, et, j, this._localMatrix);
- if (b && b.getWorldMatrix) {
- if (i && b.computeWorldMatrix(i),
- d) {
- this._transformToBoneReferal ? b.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), TmpVectors.Matrix[7]) : TmpVectors.Matrix[7].copyFrom(b.getWorldMatrix());
- var nt = TmpVectors.Vector3[5]
- , ot = TmpVectors.Vector3[6];
- TmpVectors.Matrix[7].decompose(ot, void 0, nt),
- Matrix.ScalingToRef(ot.x, ot.y, ot.z, TmpVectors.Matrix[7]),
- TmpVectors.Matrix[7].setTranslation(nt),
- this._localMatrix.multiplyToRef(TmpVectors.Matrix[7], this._worldMatrix)
- } else
- this._transformToBoneReferal ? (this._localMatrix.multiplyToRef(b.getWorldMatrix(), TmpVectors.Matrix[6]),
- TmpVectors.Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), this._worldMatrix)) : this._localMatrix.multiplyToRef(b.getWorldMatrix(), this._worldMatrix);
- this._markSyncedWithParent()
- } else
- this._worldMatrix.copyFrom(this._localMatrix);
- if (d && s && this.billboardMode && !c) {
- var at = TmpVectors.Vector3[0];
- if (this._worldMatrix.getTranslationToRef(at),
- TmpVectors.Matrix[1].copyFrom(s.getViewMatrix()),
- TmpVectors.Matrix[1].setTranslationFromFloats(0, 0, 0),
- TmpVectors.Matrix[1].invertToRef(TmpVectors.Matrix[0]),
- (this.billboardMode & e.BILLBOARDMODE_ALL) !== e.BILLBOARDMODE_ALL) {
- TmpVectors.Matrix[0].decompose(void 0, TmpVectors.Quaternion[0], void 0);
- var st = TmpVectors.Vector3[1];
- TmpVectors.Quaternion[0].toEulerAnglesToRef(st),
- (this.billboardMode & e.BILLBOARDMODE_X) !== e.BILLBOARDMODE_X && (st.x = 0),
- (this.billboardMode & e.BILLBOARDMODE_Y) !== e.BILLBOARDMODE_Y && (st.y = 0),
- (this.billboardMode & e.BILLBOARDMODE_Z) !== e.BILLBOARDMODE_Z && (st.z = 0),
- Matrix.RotationYawPitchRollToRef(st.y, st.x, st.z, TmpVectors.Matrix[0])
- }
- this._worldMatrix.setTranslationFromFloats(0, 0, 0),
- this._worldMatrix.multiplyToRef(TmpVectors.Matrix[0], this._worldMatrix),
- this._worldMatrix.setTranslation(TmpVectors.Vector3[0])
- }
- return this.ignoreNonUniformScaling ? this._updateNonUniformScalingState(!1) : this._scaling.isNonUniformWithinEpsilon(1e-6) ? this._updateNonUniformScalingState(!0) : b && b._nonUniformScaling ? this._updateNonUniformScalingState(b._nonUniformScaling) : this._updateNonUniformScalingState(!1),
- this._afterComputeWorldMatrix(),
- this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]),
- this._isAbsoluteSynced = !1,
- this.onAfterWorldMatrixUpdateObservable.notifyObservers(this),
- this._poseMatrix || (this._poseMatrix = Matrix.Invert(this._worldMatrix)),
- this._worldMatrixDeterminantIsDirty = !0,
- this._worldMatrix
- }
- ,
- e.prototype.resetLocalMatrix = function(i) {
- if (i === void 0 && (i = !0),
- this.computeWorldMatrix(),
- i)
- for (var o = this.getChildren(), s = 0; s < o.length; ++s) {
- var c = o[s];
- if (c) {
- c.computeWorldMatrix();
- var d = TmpVectors.Matrix[0];
- c._localMatrix.multiplyToRef(this._localMatrix, d);
- var _ = TmpVectors.Quaternion[0];
- d.decompose(c.scaling, _, c.position),
- c.rotationQuaternion ? c.rotationQuaternion.copyFrom(_) : _.toEulerAnglesToRef(c.rotation)
- }
- }
- this.scaling.copyFromFloats(1, 1, 1),
- this.position.copyFromFloats(0, 0, 0),
- this.rotation.copyFromFloats(0, 0, 0),
- this.rotationQuaternion && (this.rotationQuaternion = Quaternion.Identity()),
- this._worldMatrix = Matrix.Identity()
- }
- ,
- e.prototype._afterComputeWorldMatrix = function() {}
- ,
- e.prototype.registerAfterWorldMatrixUpdate = function(i) {
- return this.onAfterWorldMatrixUpdateObservable.add(i),
- this
- }
- ,
- e.prototype.unregisterAfterWorldMatrixUpdate = function(i) {
- return this.onAfterWorldMatrixUpdateObservable.removeCallback(i),
- this
- }
- ,
- e.prototype.getPositionInCameraSpace = function(i) {
- return i === void 0 && (i = null),
- i || (i = this.getScene().activeCamera),
- Vector3.TransformCoordinates(this.getAbsolutePosition(), i.getViewMatrix())
- }
- ,
- e.prototype.getDistanceToCamera = function(i) {
- return i === void 0 && (i = null),
- i || (i = this.getScene().activeCamera),
- this.getAbsolutePosition().subtract(i.globalPosition).length()
- }
- ,
- e.prototype.clone = function(i, o, s) {
- var c = this
- , d = SerializationHelper.Clone(function() {
- return new e(i,c.getScene())
- }, this);
- if (d.name = i,
- d.id = i,
- o && (d.parent = o),
- !s)
- for (var _ = this.getDescendants(!0), b = 0; b < _.length; b++) {
- var k = _[b];
- k.clone && k.clone(i + "." + k.name, d)
- }
- return d
- }
- ,
- e.prototype.serialize = function(i) {
- var o = SerializationHelper.Serialize(this, i);
- return o.type = this.getClassName(),
- o.uniqueId = this.uniqueId,
- this.parent && (o.parentId = this.parent.uniqueId),
- o.localMatrix = this.getPivotMatrix().asArray(),
- o.isEnabled = this.isEnabled(),
- this.parent && (o.parentId = this.parent.uniqueId),
- o
- }
- ,
- e.Parse = function(i, o, s) {
- var c = SerializationHelper.Parse(function() {
- return new e(i.name,o)
- }, i, o, s);
- return i.localMatrix ? c.setPreTransformMatrix(Matrix.FromArray(i.localMatrix)) : i.pivotMatrix && c.setPivotMatrix(Matrix.FromArray(i.pivotMatrix)),
- c.setEnabled(i.isEnabled),
- i.parentId && (c._waitingParentId = i.parentId),
- c
- }
- ,
- e.prototype.getChildTransformNodes = function(i, o) {
- var s = [];
- return this._getDescendants(s, i, function(c) {
- return (!o || o(c)) && c instanceof e
- }),
- s
- }
- ,
- e.prototype.dispose = function(i, o) {
- if (o === void 0 && (o = !1),
- this.getScene().stopAnimation(this),
- this.getScene().removeTransformNode(this),
- this._parentContainer) {
- var s = this._parentContainer.transformNodes.indexOf(this);
- s > -1 && this._parentContainer.transformNodes.splice(s, 1),
- this._parentContainer = null
- }
- if (this.onAfterWorldMatrixUpdateObservable.clear(),
- i)
- for (var c = this.getChildTransformNodes(!0), d = 0, _ = c; d < _.length; d++) {
- var b = _[d];
- b.parent = null,
- b.computeWorldMatrix(!0)
- }
- a.prototype.dispose.call(this, i, o)
- }
- ,
- e.prototype.normalizeToUnitCube = function(i, o, s) {
- i === void 0 && (i = !0),
- o === void 0 && (o = !1);
- var c = null
- , d = null;
- o && (this.rotationQuaternion ? (d = this.rotationQuaternion.clone(),
- this.rotationQuaternion.copyFromFloats(0, 0, 0, 1)) : this.rotation && (c = this.rotation.clone(),
- this.rotation.copyFromFloats(0, 0, 0)));
- var _ = this.getHierarchyBoundingVectors(i, s)
- , b = _.max.subtract(_.min)
- , k = Math.max(b.x, b.y, b.z);
- if (k === 0)
- return this;
- var j = 1 / k;
- return this.scaling.scaleInPlace(j),
- o && (this.rotationQuaternion && d ? this.rotationQuaternion.copyFrom(d) : this.rotation && c && this.rotation.copyFrom(c)),
- this
- }
- ,
- e.prototype._syncAbsoluteScalingAndRotation = function() {
- this._isAbsoluteSynced || (this._worldMatrix.decompose(this._absoluteScaling, this._absoluteRotationQuaternion),
- this._isAbsoluteSynced = !0)
- }
- ,
- e.BILLBOARDMODE_NONE = 0,
- e.BILLBOARDMODE_X = 1,
- e.BILLBOARDMODE_Y = 2,
- e.BILLBOARDMODE_Z = 4,
- e.BILLBOARDMODE_ALL = 7,
- e.BILLBOARDMODE_USE_POSITION = 128,
- e._TmpRotation = Quaternion.Zero(),
- e._TmpScaling = Vector3.Zero(),
- e._TmpTranslation = Vector3.Zero(),
- e._lookAtVectorCache = new Vector3(0,0,0),
- e._rotationAxisCache = new Quaternion,
- __decorate([serializeAsVector3("position")], e.prototype, "_position", void 0),
- __decorate([serializeAsVector3("rotation")], e.prototype, "_rotation", void 0),
- __decorate([serializeAsQuaternion("rotationQuaternion")], e.prototype, "_rotationQuaternion", void 0),
- __decorate([serializeAsVector3("scaling")], e.prototype, "_scaling", void 0),
- __decorate([serialize("billboardMode")], e.prototype, "_billboardMode", void 0),
- __decorate([serialize()], e.prototype, "scalingDeterminant", void 0),
- __decorate([serialize("infiniteDistance")], e.prototype, "_infiniteDistance", void 0),
- __decorate([serialize()], e.prototype, "ignoreNonUniformScaling", void 0),
- __decorate([serialize()], e.prototype, "reIntegrateRotationIntoRotationQuaternion", void 0),
- e
- }(Node$2)
- , PickingInfo = function() {
- function a() {
- this._pickingUnavailable = !1,
- this.hit = !1,
- this.distance = 0,
- this.pickedPoint = null,
- this.pickedMesh = null,
- this.bu = 0,
- this.bv = 0,
- this.faceId = -1,
- this.subMeshFaceId = -1,
- this.subMeshId = 0,
- this.pickedSprite = null,
- this.thinInstanceIndex = -1,
- this.ray = null,
- this.originMesh = null,
- this.aimTransform = null,
- this.gripTransform = null
- }
- return a.prototype.getNormal = function(e, i) {
- if (e === void 0 && (e = !1),
- i === void 0 && (i = !0),
- !this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(VertexBuffer.NormalKind))
- return null;
- var o = this.pickedMesh.getIndices();
- if (!o)
- return null;
- var s;
- if (i) {
- var c = this.pickedMesh.getVerticesData(VertexBuffer.NormalKind)
- , d = Vector3.FromArray(c, o[this.faceId * 3] * 3)
- , _ = Vector3.FromArray(c, o[this.faceId * 3 + 1] * 3)
- , b = Vector3.FromArray(c, o[this.faceId * 3 + 2] * 3);
- d = d.scale(this.bu),
- _ = _.scale(this.bv),
- b = b.scale(1 - this.bu - this.bv),
- s = new Vector3(d.x + _.x + b.x,d.y + _.y + b.y,d.z + _.z + b.z)
- } else {
- var k = this.pickedMesh.getVerticesData(VertexBuffer.PositionKind)
- , j = Vector3.FromArray(k, o[this.faceId * 3] * 3)
- , $ = Vector3.FromArray(k, o[this.faceId * 3 + 1] * 3)
- , _e = Vector3.FromArray(k, o[this.faceId * 3 + 2] * 3)
- , et = j.subtract($)
- , tt = _e.subtract($);
- s = Vector3.Cross(et, tt)
- }
- if (e) {
- var rt = this.pickedMesh.getWorldMatrix();
- this.pickedMesh.nonUniformScaling && (TmpVectors.Matrix[0].copyFrom(rt),
- rt = TmpVectors.Matrix[0],
- rt.setTranslationFromFloats(0, 0, 0),
- rt.invert(),
- rt.transposeToRef(TmpVectors.Matrix[1]),
- rt = TmpVectors.Matrix[1]),
- s = Vector3.TransformNormal(s, rt)
- }
- return s.normalize(),
- s
- }
- ,
- a.prototype.getTextureCoordinates = function() {
- if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(VertexBuffer.UVKind))
- return null;
- var e = this.pickedMesh.getIndices();
- if (!e)
- return null;
- var i = this.pickedMesh.getVerticesData(VertexBuffer.UVKind);
- if (!i)
- return null;
- var o = Vector2.FromArray(i, e[this.faceId * 3] * 2)
- , s = Vector2.FromArray(i, e[this.faceId * 3 + 1] * 2)
- , c = Vector2.FromArray(i, e[this.faceId * 3 + 2] * 2);
- return o = o.scale(this.bu),
- s = s.scale(this.bv),
- c = c.scale(1 - this.bu - this.bv),
- new Vector2(o.x + s.x + c.x,o.y + s.y + c.y)
- }
- ,
- a
- }()
- , BoundingBox = function() {
- function a(e, i, o) {
- this.vectors = ArrayTools.BuildArray(8, Vector3.Zero),
- this.center = Vector3.Zero(),
- this.centerWorld = Vector3.Zero(),
- this.extendSize = Vector3.Zero(),
- this.extendSizeWorld = Vector3.Zero(),
- this.directions = ArrayTools.BuildArray(3, Vector3.Zero),
- this.vectorsWorld = ArrayTools.BuildArray(8, Vector3.Zero),
- this.minimumWorld = Vector3.Zero(),
- this.maximumWorld = Vector3.Zero(),
- this.minimum = Vector3.Zero(),
- this.maximum = Vector3.Zero(),
- this._drawWrapperFront = null,
- this._drawWrapperBack = null,
- this.reConstruct(e, i, o)
- }
- return a.prototype.reConstruct = function(e, i, o) {
- var s = e.x
- , c = e.y
- , d = e.z
- , _ = i.x
- , b = i.y
- , k = i.z
- , j = this.vectors;
- this.minimum.copyFromFloats(s, c, d),
- this.maximum.copyFromFloats(_, b, k),
- j[0].copyFromFloats(s, c, d),
- j[1].copyFromFloats(_, b, k),
- j[2].copyFromFloats(_, c, d),
- j[3].copyFromFloats(s, b, d),
- j[4].copyFromFloats(s, c, k),
- j[5].copyFromFloats(_, b, d),
- j[6].copyFromFloats(s, b, k),
- j[7].copyFromFloats(_, c, k),
- i.addToRef(e, this.center).scaleInPlace(.5),
- i.subtractToRef(e, this.extendSize).scaleInPlace(.5),
- this._worldMatrix = o || Matrix.IdentityReadOnly,
- this._update(this._worldMatrix)
- }
- ,
- a.prototype.scale = function(e) {
- var i = a.TmpVector3
- , o = this.maximum.subtractToRef(this.minimum, i[0])
- , s = o.length();
- o.normalizeFromLength(s);
- var c = s * e
- , d = o.scaleInPlace(c * .5)
- , _ = this.center.subtractToRef(d, i[1])
- , b = this.center.addToRef(d, i[2]);
- return this.reConstruct(_, b, this._worldMatrix),
- this
- }
- ,
- a.prototype.getWorldMatrix = function() {
- return this._worldMatrix
- }
- ,
- a.prototype._update = function(e) {
- var i = this.minimumWorld
- , o = this.maximumWorld
- , s = this.directions
- , c = this.vectorsWorld
- , d = this.vectors;
- if (e.isIdentity()) {
- i.copyFrom(this.minimum),
- o.copyFrom(this.maximum);
- for (var _ = 0; _ < 8; ++_)
- c[_].copyFrom(d[_]);
- this.extendSizeWorld.copyFrom(this.extendSize),
- this.centerWorld.copyFrom(this.center)
- } else {
- i.setAll(Number.MAX_VALUE),
- o.setAll(-Number.MAX_VALUE);
- for (var _ = 0; _ < 8; ++_) {
- var b = c[_];
- Vector3.TransformCoordinatesToRef(d[_], e, b),
- i.minimizeInPlace(b),
- o.maximizeInPlace(b)
- }
- o.subtractToRef(i, this.extendSizeWorld).scaleInPlace(.5),
- o.addToRef(i, this.centerWorld).scaleInPlace(.5)
- }
- Vector3.FromArrayToRef(e.m, 0, s[0]),
- Vector3.FromArrayToRef(e.m, 4, s[1]),
- Vector3.FromArrayToRef(e.m, 8, s[2]),
- this._worldMatrix = e
- }
- ,
- a.prototype.isInFrustum = function(e) {
- return a.IsInFrustum(this.vectorsWorld, e)
- }
- ,
- a.prototype.isCompletelyInFrustum = function(e) {
- return a.IsCompletelyInFrustum(this.vectorsWorld, e)
- }
- ,
- a.prototype.intersectsPoint = function(e) {
- var i = this.minimumWorld
- , o = this.maximumWorld
- , s = i.x
- , c = i.y
- , d = i.z
- , _ = o.x
- , b = o.y
- , k = o.z
- , j = e.x
- , $ = e.y
- , _e = e.z
- , et = -Epsilon;
- return !(_ - j < et || et > j - s || b - $ < et || et > $ - c || k - _e < et || et > _e - d)
- }
- ,
- a.prototype.intersectsSphere = function(e) {
- return a.IntersectsSphere(this.minimumWorld, this.maximumWorld, e.centerWorld, e.radiusWorld)
- }
- ,
- a.prototype.intersectsMinMax = function(e, i) {
- var o = this.minimumWorld
- , s = this.maximumWorld
- , c = o.x
- , d = o.y
- , _ = o.z
- , b = s.x
- , k = s.y
- , j = s.z
- , $ = e.x
- , _e = e.y
- , et = e.z
- , tt = i.x
- , rt = i.y
- , it = i.z;
- return !(b < $ || c > tt || k < _e || d > rt || j < et || _ > it)
- }
- ,
- a.prototype.dispose = function() {
- var e, i;
- (e = this._drawWrapperFront) === null || e === void 0 || e.dispose(),
- (i = this._drawWrapperBack) === null || i === void 0 || i.dispose()
- }
- ,
- a.Intersects = function(e, i) {
- return e.intersectsMinMax(i.minimumWorld, i.maximumWorld)
- }
- ,
- a.IntersectsSphere = function(e, i, o, s) {
- var c = a.TmpVector3[0];
- Vector3.ClampToRef(o, e, i, c);
- var d = Vector3.DistanceSquared(o, c);
- return d <= s * s
- }
- ,
- a.IsCompletelyInFrustum = function(e, i) {
- for (var o = 0; o < 6; ++o)
- for (var s = i[o], c = 0; c < 8; ++c)
- if (s.dotCoordinate(e[c]) < 0)
- return !1;
- return !0
- }
- ,
- a.IsInFrustum = function(e, i) {
- for (var o = 0; o < 6; ++o) {
- for (var s = !0, c = i[o], d = 0; d < 8; ++d)
- if (c.dotCoordinate(e[d]) >= 0) {
- s = !1;
- break
- }
- if (s)
- return !1
- }
- return !0
- }
- ,
- a.TmpVector3 = ArrayTools.BuildArray(3, Vector3.Zero),
- a
- }()
- , BoundingSphere = function() {
- function a(e, i, o) {
- this.center = Vector3.Zero(),
- this.centerWorld = Vector3.Zero(),
- this.minimum = Vector3.Zero(),
- this.maximum = Vector3.Zero(),
- this.reConstruct(e, i, o)
- }
- return a.prototype.reConstruct = function(e, i, o) {
- this.minimum.copyFrom(e),
- this.maximum.copyFrom(i);
- var s = Vector3.Distance(e, i);
- i.addToRef(e, this.center).scaleInPlace(.5),
- this.radius = s * .5,
- this._update(o || Matrix.IdentityReadOnly)
- }
- ,
- a.prototype.scale = function(e) {
- var i = this.radius * e
- , o = a.TmpVector3
- , s = o[0].setAll(i)
- , c = this.center.subtractToRef(s, o[1])
- , d = this.center.addToRef(s, o[2]);
- return this.reConstruct(c, d, this._worldMatrix),
- this
- }
- ,
- a.prototype.getWorldMatrix = function() {
- return this._worldMatrix
- }
- ,
- a.prototype._update = function(e) {
- if (e.isIdentity())
- this.centerWorld.copyFrom(this.center),
- this.radiusWorld = this.radius;
- else {
- Vector3.TransformCoordinatesToRef(this.center, e, this.centerWorld);
- var i = a.TmpVector3[0];
- Vector3.TransformNormalFromFloatsToRef(1, 1, 1, e, i),
- this.radiusWorld = Math.max(Math.abs(i.x), Math.abs(i.y), Math.abs(i.z)) * this.radius
- }
- }
- ,
- a.prototype.isInFrustum = function(e) {
- for (var i = this.centerWorld, o = this.radiusWorld, s = 0; s < 6; s++)
- if (e[s].dotCoordinate(i) <= -o)
- return !1;
- return !0
- }
- ,
- a.prototype.isCenterInFrustum = function(e) {
- for (var i = this.centerWorld, o = 0; o < 6; o++)
- if (e[o].dotCoordinate(i) < 0)
- return !1;
- return !0
- }
- ,
- a.prototype.intersectsPoint = function(e) {
- var i = Vector3.DistanceSquared(this.centerWorld, e);
- return !(this.radiusWorld * this.radiusWorld < i)
- }
- ,
- a.Intersects = function(e, i) {
- var o = Vector3.DistanceSquared(e.centerWorld, i.centerWorld)
- , s = e.radiusWorld + i.radiusWorld;
- return !(s * s < o)
- }
- ,
- a.CreateFromCenterAndRadius = function(e, i, o) {
- this.TmpVector3[0].copyFrom(e),
- this.TmpVector3[1].copyFromFloats(0, 0, i),
- this.TmpVector3[2].copyFrom(e),
- this.TmpVector3[0].addInPlace(this.TmpVector3[1]),
- this.TmpVector3[2].subtractInPlace(this.TmpVector3[1]);
- var s = new a(this.TmpVector3[0],this.TmpVector3[2]);
- return o ? s._worldMatrix = o : s._worldMatrix = Matrix.Identity(),
- s
- }
- ,
- a.TmpVector3 = ArrayTools.BuildArray(3, Vector3.Zero),
- a
- }()
- , _result0 = {
- min: 0,
- max: 0
- }
- , _result1 = {
- min: 0,
- max: 0
- }
- , computeBoxExtents = function(a, e, i) {
- var o = Vector3.Dot(e.centerWorld, a)
- , s = Math.abs(Vector3.Dot(e.directions[0], a)) * e.extendSize.x
- , c = Math.abs(Vector3.Dot(e.directions[1], a)) * e.extendSize.y
- , d = Math.abs(Vector3.Dot(e.directions[2], a)) * e.extendSize.z
- , _ = s + c + d;
- i.min = o - _,
- i.max = o + _
- }
- , axisOverlap = function(a, e, i) {
- return computeBoxExtents(a, e, _result0),
- computeBoxExtents(a, i, _result1),
- !(_result0.min > _result1.max || _result1.min > _result0.max)
- }
- , BoundingInfo = function() {
- function a(e, i, o) {
- this._isLocked = !1,
- this.boundingBox = new BoundingBox(e,i,o),
- this.boundingSphere = new BoundingSphere(e,i,o)
- }
- return a.prototype.reConstruct = function(e, i, o) {
- this.boundingBox.reConstruct(e, i, o),
- this.boundingSphere.reConstruct(e, i, o)
- }
- ,
- Object.defineProperty(a.prototype, "minimum", {
- get: function() {
- return this.boundingBox.minimum
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "maximum", {
- get: function() {
- return this.boundingBox.maximum
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "isLocked", {
- get: function() {
- return this._isLocked
- },
- set: function(e) {
- this._isLocked = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.update = function(e) {
- this._isLocked || (this.boundingBox._update(e),
- this.boundingSphere._update(e))
- }
- ,
- a.prototype.centerOn = function(e, i) {
- var o = a.TmpVector3[0].copyFrom(e).subtractInPlace(i)
- , s = a.TmpVector3[1].copyFrom(e).addInPlace(i);
- return this.boundingBox.reConstruct(o, s, this.boundingBox.getWorldMatrix()),
- this.boundingSphere.reConstruct(o, s, this.boundingBox.getWorldMatrix()),
- this
- }
- ,
- a.prototype.encapsulate = function(e) {
- var i = Vector3.Minimize(this.minimum, e)
- , o = Vector3.Maximize(this.maximum, e);
- return this.reConstruct(i, o, this.boundingBox.getWorldMatrix()),
- this
- }
- ,
- a.prototype.encapsulateBoundingInfo = function(e) {
- return this.encapsulate(e.boundingBox.centerWorld.subtract(e.boundingBox.extendSizeWorld)),
- this.encapsulate(e.boundingBox.centerWorld.add(e.boundingBox.extendSizeWorld)),
- this
- }
- ,
- a.prototype.scale = function(e) {
- return this.boundingBox.scale(e),
- this.boundingSphere.scale(e),
- this
- }
- ,
- a.prototype.isInFrustum = function(e, i) {
- i === void 0 && (i = 0);
- var o = i === 2 || i === 3;
- if (o && this.boundingSphere.isCenterInFrustum(e))
- return !0;
- if (!this.boundingSphere.isInFrustum(e))
- return !1;
- var s = i === 1 || i === 3;
- return s ? !0 : this.boundingBox.isInFrustum(e)
- }
- ,
- Object.defineProperty(a.prototype, "diagonalLength", {
- get: function() {
- var e = this.boundingBox
- , i = e.maximumWorld.subtractToRef(e.minimumWorld, a.TmpVector3[0]);
- return i.length()
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.isCompletelyInFrustum = function(e) {
- return this.boundingBox.isCompletelyInFrustum(e)
- }
- ,
- a.prototype._checkCollision = function(e) {
- return e._canDoCollision(this.boundingSphere.centerWorld, this.boundingSphere.radiusWorld, this.boundingBox.minimumWorld, this.boundingBox.maximumWorld)
- }
- ,
- a.prototype.intersectsPoint = function(e) {
- return !(!this.boundingSphere.centerWorld || !this.boundingSphere.intersectsPoint(e) || !this.boundingBox.intersectsPoint(e))
- }
- ,
- a.prototype.intersects = function(e, i) {
- if (!BoundingSphere.Intersects(this.boundingSphere, e.boundingSphere) || !BoundingBox.Intersects(this.boundingBox, e.boundingBox))
- return !1;
- if (!i)
- return !0;
- var o = this.boundingBox
- , s = e.boundingBox;
- 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))
- }
- ,
- a.TmpVector3 = ArrayTools.BuildArray(2, Vector3.Zero),
- a
- }();
- ThinEngine.prototype.createUniformBuffer = function(a) {
- var e = this._gl.createBuffer();
- if (!e)
- throw new Error("Unable to create uniform buffer");
- var i = new WebGLDataBuffer(e);
- return this.bindUniformBuffer(i),
- 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),
- this.bindUniformBuffer(null),
- i.references = 1,
- i
- }
- ;
- ThinEngine.prototype.createDynamicUniformBuffer = function(a) {
- var e = this._gl.createBuffer();
- if (!e)
- throw new Error("Unable to create dynamic uniform buffer");
- var i = new WebGLDataBuffer(e);
- return this.bindUniformBuffer(i),
- 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),
- this.bindUniformBuffer(null),
- i.references = 1,
- i
- }
- ;
- ThinEngine.prototype.updateUniformBuffer = function(a, e, i, o) {
- this.bindUniformBuffer(a),
- i === void 0 && (i = 0),
- 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)),
- this.bindUniformBuffer(null)
- }
- ;
- ThinEngine.prototype.bindUniformBuffer = function(a) {
- this._gl.bindBuffer(this._gl.UNIFORM_BUFFER, a ? a.underlyingResource : null)
- }
- ;
- ThinEngine.prototype.bindUniformBufferBase = function(a, e, i) {
- this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER, e, a ? a.underlyingResource : null)
- }
- ;
- ThinEngine.prototype.bindUniformBlock = function(a, e, i) {
- var o = a.program
- , s = this._gl.getUniformBlockIndex(o, e);
- this._gl.uniformBlockBinding(o, s, i)
- }
- ;
- var UniformBuffer = function() {
- function a(e, i, o, s) {
- this._valueCache = {},
- this._engine = e,
- this._noUBO = !e.supportsUniformBuffers,
- this._dynamic = o,
- this._name = s != null ? s : "no-name",
- this._data = i || [],
- this._uniformLocations = {},
- this._uniformSizes = {},
- this._uniformArraySizes = {},
- this._uniformLocationPointer = 0,
- this._needSync = !1,
- this._engine._features.trackUbosInFrame && (this._buffers = [],
- this._bufferIndex = -1,
- this._createBufferOnWrite = !1,
- this._currentFrameId = 0),
- this._noUBO ? (this.updateMatrix3x3 = this._updateMatrix3x3ForEffect,
- this.updateMatrix2x2 = this._updateMatrix2x2ForEffect,
- this.updateFloat = this._updateFloatForEffect,
- this.updateFloat2 = this._updateFloat2ForEffect,
- this.updateFloat3 = this._updateFloat3ForEffect,
- this.updateFloat4 = this._updateFloat4ForEffect,
- this.updateFloatArray = this._updateFloatArrayForEffect,
- this.updateArray = this._updateArrayForEffect,
- this.updateIntArray = this._updateIntArrayForEffect,
- this.updateMatrix = this._updateMatrixForEffect,
- this.updateMatrices = this._updateMatricesForEffect,
- this.updateVector3 = this._updateVector3ForEffect,
- this.updateVector4 = this._updateVector4ForEffect,
- this.updateColor3 = this._updateColor3ForEffect,
- this.updateColor4 = this._updateColor4ForEffect,
- this.updateDirectColor4 = this._updateDirectColor4ForEffect,
- this.updateInt = this._updateIntForEffect,
- this.updateInt2 = this._updateInt2ForEffect,
- this.updateInt3 = this._updateInt3ForEffect,
- this.updateInt4 = this._updateInt4ForEffect) : (this._engine._uniformBuffers.push(this),
- this.updateMatrix3x3 = this._updateMatrix3x3ForUniform,
- this.updateMatrix2x2 = this._updateMatrix2x2ForUniform,
- this.updateFloat = this._updateFloatForUniform,
- this.updateFloat2 = this._updateFloat2ForUniform,
- this.updateFloat3 = this._updateFloat3ForUniform,
- this.updateFloat4 = this._updateFloat4ForUniform,
- this.updateFloatArray = this._updateFloatArrayForUniform,
- this.updateArray = this._updateArrayForUniform,
- this.updateIntArray = this._updateIntArrayForUniform,
- this.updateMatrix = this._updateMatrixForUniform,
- this.updateMatrices = this._updateMatricesForUniform,
- this.updateVector3 = this._updateVector3ForUniform,
- this.updateVector4 = this._updateVector4ForUniform,
- this.updateColor3 = this._updateColor3ForUniform,
- this.updateColor4 = this._updateColor4ForUniform,
- this.updateDirectColor4 = this._updateDirectColor4ForUniform,
- this.updateInt = this._updateIntForUniform,
- this.updateInt2 = this._updateInt2ForUniform,
- this.updateInt3 = this._updateInt3ForUniform,
- this.updateInt4 = this._updateInt4ForUniform)
- }
- return Object.defineProperty(a.prototype, "useUbo", {
- get: function() {
- return !this._noUBO
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "isSync", {
- get: function() {
- return !this._needSync
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.isDynamic = function() {
- return this._dynamic !== void 0
- }
- ,
- a.prototype.getData = function() {
- return this._bufferData
- }
- ,
- a.prototype.getBuffer = function() {
- return this._buffer
- }
- ,
- a.prototype._fillAlignment = function(e) {
- var i;
- if (e <= 2 ? i = e : i = 4,
- this._uniformLocationPointer % i !== 0) {
- var o = this._uniformLocationPointer;
- this._uniformLocationPointer += i - this._uniformLocationPointer % i;
- for (var s = this._uniformLocationPointer - o, c = 0; c < s; c++)
- this._data.push(0)
- }
- }
- ,
- a.prototype.addUniform = function(e, i, o) {
- if (o === void 0 && (o = 0),
- !this._noUBO && this._uniformLocations[e] === void 0) {
- var s;
- if (o > 0) {
- if (i instanceof Array)
- throw "addUniform should not be use with Array in UBO: " + e;
- if (this._fillAlignment(4),
- this._uniformArraySizes[e] = {
- strideSize: i,
- arraySize: o
- },
- i == 16)
- i = i * o;
- else {
- var c = 4 - i
- , d = c * o;
- i = i * o + d
- }
- s = [];
- for (var _ = 0; _ < i; _++)
- s.push(0)
- } else {
- if (i instanceof Array)
- s = i,
- i = s.length;
- else {
- i = i,
- s = [];
- for (var _ = 0; _ < i; _++)
- s.push(0)
- }
- this._fillAlignment(i)
- }
- this._uniformSizes[e] = i,
- this._uniformLocations[e] = this._uniformLocationPointer,
- this._uniformLocationPointer += i;
- for (var _ = 0; _ < i; _++)
- this._data.push(s[_]);
- this._needSync = !0
- }
- }
- ,
- a.prototype.addMatrix = function(e, i) {
- this.addUniform(e, Array.prototype.slice.call(i.toArray()))
- }
- ,
- a.prototype.addFloat2 = function(e, i, o) {
- var s = [i, o];
- this.addUniform(e, s)
- }
- ,
- a.prototype.addFloat3 = function(e, i, o, s) {
- var c = [i, o, s];
- this.addUniform(e, c)
- }
- ,
- a.prototype.addColor3 = function(e, i) {
- var o = [i.r, i.g, i.b];
- this.addUniform(e, o)
- }
- ,
- a.prototype.addColor4 = function(e, i, o) {
- var s = [i.r, i.g, i.b, o];
- this.addUniform(e, s)
- }
- ,
- a.prototype.addVector3 = function(e, i) {
- var o = [i.x, i.y, i.z];
- this.addUniform(e, o)
- }
- ,
- a.prototype.addMatrix3x3 = function(e) {
- this.addUniform(e, 12)
- }
- ,
- a.prototype.addMatrix2x2 = function(e) {
- this.addUniform(e, 8)
- }
- ,
- a.prototype.create = function() {
- this._noUBO || this._buffer || (this._fillAlignment(4),
- this._bufferData = new Float32Array(this._data),
- this._rebuild(),
- this._needSync = !0)
- }
- ,
- a.prototype._rebuild = function() {
- this._noUBO || !this._bufferData || (this._dynamic ? this._buffer = this._engine.createDynamicUniformBuffer(this._bufferData) : this._buffer = this._engine.createUniformBuffer(this._bufferData),
- this._engine._features.trackUbosInFrame && (this._buffers.push([this._buffer, this._engine._features.checkUbosContentBeforeUpload ? this._bufferData.slice() : void 0]),
- this._bufferIndex = this._buffers.length - 1,
- this._createBufferOnWrite = !1))
- }
- ,
- Object.defineProperty(a.prototype, "_numBuffers", {
- get: function() {
- return this._buffers.length
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "_indexBuffer", {
- get: function() {
- return this._bufferIndex
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "name", {
- get: function() {
- return this._name
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._buffersEqual = function(e, i) {
- for (var o = 0; o < e.length; ++o)
- if (e[o] !== i[o])
- return !1;
- return !0
- }
- ,
- a.prototype._copyBuffer = function(e, i) {
- for (var o = 0; o < e.length; ++o)
- i[o] = e[o]
- }
- ,
- a.prototype.update = function() {
- if (this.bindUniformBuffer(),
- !this._buffer) {
- this.create();
- return
- }
- if (!this._dynamic && !this._needSync) {
- this._createBufferOnWrite = this._engine._features.trackUbosInFrame;
- return
- }
- if (this._buffers && this._buffers.length > 1 && this._buffers[this._bufferIndex][1])
- if (this._buffersEqual(this._bufferData, this._buffers[this._bufferIndex][1])) {
- this._needSync = !1,
- this._createBufferOnWrite = this._engine._features.trackUbosInFrame;
- return
- } else
- this._copyBuffer(this._bufferData, this._buffers[this._bufferIndex][1]);
- this._engine.updateUniformBuffer(this._buffer, this._bufferData),
- this._engine._features._collectUbosUpdatedInFrame && (a._updatedUbosInFrame[this._name] || (a._updatedUbosInFrame[this._name] = 0),
- a._updatedUbosInFrame[this._name]++),
- this._needSync = !1,
- this._createBufferOnWrite = this._engine._features.trackUbosInFrame
- }
- ,
- a.prototype._createNewBuffer = function() {
- this._bufferIndex + 1 < this._buffers.length ? (this._bufferIndex++,
- this._buffer = this._buffers[this._bufferIndex][0],
- this._createBufferOnWrite = !1,
- this._needSync = !0) : this._rebuild()
- }
- ,
- a.prototype._checkNewFrame = function() {
- this._engine._features.trackUbosInFrame && this._currentFrameId !== this._engine.frameId && (this._currentFrameId = this._engine.frameId,
- this._createBufferOnWrite = !1,
- this._buffers && this._buffers.length > 0 ? (this._needSync = this._bufferIndex !== 0,
- this._bufferIndex = 0,
- this._buffer = this._buffers[this._bufferIndex][0]) : this._bufferIndex = -1)
- }
- ,
- a.prototype.updateUniform = function(e, i, o) {
- this._checkNewFrame();
- var s = this._uniformLocations[e];
- if (s === void 0) {
- if (this._buffer) {
- Logger$2.Error("Cannot add an uniform after UBO has been created.");
- return
- }
- this.addUniform(e, o),
- s = this._uniformLocations[e]
- }
- if (this._buffer || this.create(),
- this._dynamic)
- for (var d = 0; d < o; d++)
- this._bufferData[s + d] = i[d];
- else {
- for (var c = !1, d = 0; d < o; d++)
- (o === 16 && !this._engine._features.uniformBufferHardCheckMatrix || this._bufferData[s + d] !== Tools.FloatRound(i[d])) && (c = !0,
- this._createBufferOnWrite && this._createNewBuffer(),
- this._bufferData[s + d] = i[d]);
- this._needSync = this._needSync || c
- }
- }
- ,
- a.prototype.updateUniformArray = function(e, i, o) {
- this._checkNewFrame();
- var s = this._uniformLocations[e];
- if (s === void 0) {
- Logger$2.Error("Cannot add an uniform Array dynamically. Please, add it using addUniform.");
- return
- }
- this._buffer || this.create();
- var c = this._uniformArraySizes[e];
- if (this._dynamic)
- for (var k = 0; k < o; k++)
- this._bufferData[s + k] = i[k];
- else {
- for (var d = !1, _ = 0, b = 0, k = 0; k < o; k++)
- if (this._bufferData[s + b * 4 + _] !== Tools.FloatRound(i[k]) && (d = !0,
- this._createBufferOnWrite && this._createNewBuffer(),
- this._bufferData[s + b * 4 + _] = i[k]),
- _++,
- _ === c.strideSize) {
- for (; _ < 4; _++)
- this._bufferData[s + b * 4 + _] = 0;
- _ = 0,
- b++
- }
- this._needSync = this._needSync || d
- }
- }
- ,
- a.prototype._cacheMatrix = function(e, i) {
- this._checkNewFrame();
- var o = this._valueCache[e]
- , s = i.updateFlag;
- return o !== void 0 && o === s ? !1 : (this._valueCache[e] = s,
- !0)
- }
- ,
- a.prototype._updateMatrix3x3ForUniform = function(e, i) {
- for (var o = 0; o < 3; o++)
- a._tempBuffer[o * 4] = i[o * 3],
- a._tempBuffer[o * 4 + 1] = i[o * 3 + 1],
- a._tempBuffer[o * 4 + 2] = i[o * 3 + 2],
- a._tempBuffer[o * 4 + 3] = 0;
- this.updateUniform(e, a._tempBuffer, 12)
- }
- ,
- a.prototype._updateMatrix3x3ForEffect = function(e, i) {
- this._currentEffect.setMatrix3x3(e, i)
- }
- ,
- a.prototype._updateMatrix2x2ForEffect = function(e, i) {
- this._currentEffect.setMatrix2x2(e, i)
- }
- ,
- a.prototype._updateMatrix2x2ForUniform = function(e, i) {
- for (var o = 0; o < 2; o++)
- a._tempBuffer[o * 4] = i[o * 2],
- a._tempBuffer[o * 4 + 1] = i[o * 2 + 1],
- a._tempBuffer[o * 4 + 2] = 0,
- a._tempBuffer[o * 4 + 3] = 0;
- this.updateUniform(e, a._tempBuffer, 8)
- }
- ,
- a.prototype._updateFloatForEffect = function(e, i) {
- this._currentEffect.setFloat(e, i)
- }
- ,
- a.prototype._updateFloatForUniform = function(e, i) {
- a._tempBuffer[0] = i,
- this.updateUniform(e, a._tempBuffer, 1)
- }
- ,
- a.prototype._updateFloat2ForEffect = function(e, i, o, s) {
- s === void 0 && (s = ""),
- this._currentEffect.setFloat2(e + s, i, o)
- }
- ,
- a.prototype._updateFloat2ForUniform = function(e, i, o) {
- a._tempBuffer[0] = i,
- a._tempBuffer[1] = o,
- this.updateUniform(e, a._tempBuffer, 2)
- }
- ,
- a.prototype._updateFloat3ForEffect = function(e, i, o, s, c) {
- c === void 0 && (c = ""),
- this._currentEffect.setFloat3(e + c, i, o, s)
- }
- ,
- a.prototype._updateFloat3ForUniform = function(e, i, o, s) {
- a._tempBuffer[0] = i,
- a._tempBuffer[1] = o,
- a._tempBuffer[2] = s,
- this.updateUniform(e, a._tempBuffer, 3)
- }
- ,
- a.prototype._updateFloat4ForEffect = function(e, i, o, s, c, d) {
- d === void 0 && (d = ""),
- this._currentEffect.setFloat4(e + d, i, o, s, c)
- }
- ,
- a.prototype._updateFloat4ForUniform = function(e, i, o, s, c) {
- a._tempBuffer[0] = i,
- a._tempBuffer[1] = o,
- a._tempBuffer[2] = s,
- a._tempBuffer[3] = c,
- this.updateUniform(e, a._tempBuffer, 4)
- }
- ,
- a.prototype._updateFloatArrayForEffect = function(e, i) {
- this._currentEffect.setFloatArray(e, i)
- }
- ,
- a.prototype._updateFloatArrayForUniform = function(e, i) {
- this.updateUniformArray(e, i, i.length)
- }
- ,
- a.prototype._updateArrayForEffect = function(e, i) {
- this._currentEffect.setArray(e, i)
- }
- ,
- a.prototype._updateArrayForUniform = function(e, i) {
- this.updateUniformArray(e, i, i.length)
- }
- ,
- a.prototype._updateIntArrayForEffect = function(e, i) {
- this._currentEffect.setIntArray(e, i)
- }
- ,
- a.prototype._updateIntArrayForUniform = function(e, i) {
- a._tempBufferInt32View.set(i),
- this.updateUniformArray(e, a._tempBuffer, i.length)
- }
- ,
- a.prototype._updateMatrixForEffect = function(e, i) {
- this._currentEffect.setMatrix(e, i)
- }
- ,
- a.prototype._updateMatrixForUniform = function(e, i) {
- this._cacheMatrix(e, i) && this.updateUniform(e, i.toArray(), 16)
- }
- ,
- a.prototype._updateMatricesForEffect = function(e, i) {
- this._currentEffect.setMatrices(e, i)
- }
- ,
- a.prototype._updateMatricesForUniform = function(e, i) {
- this.updateUniform(e, i, i.length)
- }
- ,
- a.prototype._updateVector3ForEffect = function(e, i) {
- this._currentEffect.setVector3(e, i)
- }
- ,
- a.prototype._updateVector3ForUniform = function(e, i) {
- a._tempBuffer[0] = i.x,
- a._tempBuffer[1] = i.y,
- a._tempBuffer[2] = i.z,
- this.updateUniform(e, a._tempBuffer, 3)
- }
- ,
- a.prototype._updateVector4ForEffect = function(e, i) {
- this._currentEffect.setVector4(e, i)
- }
- ,
- a.prototype._updateVector4ForUniform = function(e, i) {
- a._tempBuffer[0] = i.x,
- a._tempBuffer[1] = i.y,
- a._tempBuffer[2] = i.z,
- a._tempBuffer[3] = i.w,
- this.updateUniform(e, a._tempBuffer, 4)
- }
- ,
- a.prototype._updateColor3ForEffect = function(e, i, o) {
- o === void 0 && (o = ""),
- this._currentEffect.setColor3(e + o, i)
- }
- ,
- a.prototype._updateColor3ForUniform = function(e, i) {
- a._tempBuffer[0] = i.r,
- a._tempBuffer[1] = i.g,
- a._tempBuffer[2] = i.b,
- this.updateUniform(e, a._tempBuffer, 3)
- }
- ,
- a.prototype._updateColor4ForEffect = function(e, i, o, s) {
- s === void 0 && (s = ""),
- this._currentEffect.setColor4(e + s, i, o)
- }
- ,
- a.prototype._updateDirectColor4ForEffect = function(e, i, o) {
- o === void 0 && (o = ""),
- this._currentEffect.setDirectColor4(e + o, i)
- }
- ,
- a.prototype._updateColor4ForUniform = function(e, i, o) {
- a._tempBuffer[0] = i.r,
- a._tempBuffer[1] = i.g,
- a._tempBuffer[2] = i.b,
- a._tempBuffer[3] = o,
- this.updateUniform(e, a._tempBuffer, 4)
- }
- ,
- a.prototype._updateDirectColor4ForUniform = function(e, i) {
- a._tempBuffer[0] = i.r,
- a._tempBuffer[1] = i.g,
- a._tempBuffer[2] = i.b,
- a._tempBuffer[3] = i.a,
- this.updateUniform(e, a._tempBuffer, 4)
- }
- ,
- a.prototype._updateIntForEffect = function(e, i, o) {
- o === void 0 && (o = ""),
- this._currentEffect.setInt(e + o, i)
- }
- ,
- a.prototype._updateIntForUniform = function(e, i) {
- a._tempBufferInt32View[0] = i,
- this.updateUniform(e, a._tempBuffer, 1)
- }
- ,
- a.prototype._updateInt2ForEffect = function(e, i, o, s) {
- s === void 0 && (s = ""),
- this._currentEffect.setInt2(e + s, i, o)
- }
- ,
- a.prototype._updateInt2ForUniform = function(e, i, o) {
- a._tempBufferInt32View[0] = i,
- a._tempBufferInt32View[1] = o,
- this.updateUniform(e, a._tempBuffer, 2)
- }
- ,
- a.prototype._updateInt3ForEffect = function(e, i, o, s, c) {
- c === void 0 && (c = ""),
- this._currentEffect.setInt3(e + c, i, o, s)
- }
- ,
- a.prototype._updateInt3ForUniform = function(e, i, o, s) {
- a._tempBufferInt32View[0] = i,
- a._tempBufferInt32View[1] = o,
- a._tempBufferInt32View[2] = s,
- this.updateUniform(e, a._tempBuffer, 3)
- }
- ,
- a.prototype._updateInt4ForEffect = function(e, i, o, s, c, d) {
- d === void 0 && (d = ""),
- this._currentEffect.setInt4(e + d, i, o, s, c)
- }
- ,
- a.prototype._updateInt4ForUniform = function(e, i, o, s, c) {
- a._tempBufferInt32View[0] = i,
- a._tempBufferInt32View[1] = o,
- a._tempBufferInt32View[2] = s,
- a._tempBufferInt32View[3] = c,
- this.updateUniform(e, a._tempBuffer, 4)
- }
- ,
- a.prototype.setTexture = function(e, i) {
- this._currentEffect.setTexture(e, i)
- }
- ,
- a.prototype.updateUniformDirectly = function(e, i) {
- this.updateUniform(e, i, i.length),
- this.update()
- }
- ,
- a.prototype.bindToEffect = function(e, i) {
- this._currentEffect = e,
- this._currentEffectName = i
- }
- ,
- a.prototype.bindUniformBuffer = function() {
- !this._noUBO && this._buffer && this._currentEffect && this._currentEffect.bindUniformBuffer(this._buffer, this._currentEffectName)
- }
- ,
- a.prototype.unbindEffect = function() {
- this._currentEffect = void 0,
- this._currentEffectName = void 0
- }
- ,
- a.prototype.dispose = function() {
- if (!this._noUBO) {
- var e = this._engine._uniformBuffers
- , i = e.indexOf(this);
- if (i !== -1 && (e[i] = e[e.length - 1],
- e.pop()),
- this._engine._features.trackUbosInFrame && this._buffers)
- for (var o = 0; o < this._buffers.length; ++o) {
- var s = this._buffers[o][0];
- this._engine._releaseBuffer(s)
- }
- else
- this._buffer && this._engine._releaseBuffer(this._buffer) && (this._buffer = null)
- }
- }
- ,
- a._updatedUbosInFrame = {},
- a._MAX_UNIFORM_SIZE = 256,
- a._tempBuffer = new Float32Array(a._MAX_UNIFORM_SIZE),
- a._tempBufferInt32View = new Uint32Array(a._tempBuffer.buffer),
- a
- }()
- , _MeshCollisionData = function() {
- function a() {
- this._checkCollisions = !1,
- this._collisionMask = -1,
- this._collisionGroup = -1,
- this._surroundingMeshes = null,
- this._collider = null,
- this._oldPositionForCollisions = new Vector3(0,0,0),
- this._diffPositionForCollisions = new Vector3(0,0,0),
- this._collisionResponse = !0
- }
- return a
- }()
- , MathHelpers = function() {
- function a() {}
- return a.extractMinAndMaxIndexed = function(e, i, o, s, c, d) {
- for (var _ = o; _ < o + s; _++) {
- var b = i[_] * 3
- , k = e[b]
- , j = e[b + 1]
- , $ = e[b + 2];
- c.minimizeInPlaceFromFloats(k, j, $),
- d.maximizeInPlaceFromFloats(k, j, $)
- }
- }
- ,
- a.extractMinAndMax = function(e, i, o, s, c, d) {
- for (var _ = i, b = i * s; _ < i + o; _++,
- b += s) {
- var k = e[b]
- , j = e[b + 1]
- , $ = e[b + 2];
- c.minimizeInPlaceFromFloats(k, j, $),
- d.maximizeInPlaceFromFloats(k, j, $)
- }
- }
- ,
- __decorate([nativeOverride.filter(function() {
- for (var e = [], i = 0; i < arguments.length; i++)
- e[i] = arguments[i];
- var o = e[0]
- , s = e[1];
- return !Array.isArray(o) && !Array.isArray(s)
- })], a, "extractMinAndMaxIndexed", null),
- __decorate([nativeOverride.filter(function() {
- for (var e = [], i = 0; i < arguments.length; i++)
- e[i] = arguments[i];
- var o = e[0];
- return !Array.isArray(o)
- })], a, "extractMinAndMax", null),
- a
- }();
- function extractMinAndMaxIndexed(a, e, i, o, s) {
- s === void 0 && (s = null);
- var c = new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)
- , d = new Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);
- return MathHelpers.extractMinAndMaxIndexed(a, e, i, o, c, d),
- s && (c.x -= c.x * s.x + s.y,
- c.y -= c.y * s.x + s.y,
- c.z -= c.z * s.x + s.y,
- d.x += d.x * s.x + s.y,
- d.y += d.y * s.x + s.y,
- d.z += d.z * s.x + s.y),
- {
- minimum: c,
- maximum: d
- }
- }
- function extractMinAndMax(a, e, i, o, s) {
- o === void 0 && (o = null);
- var c = new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)
- , d = new Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);
- return s || (s = 3),
- MathHelpers.extractMinAndMax(a, e, i, s, c, d),
- o && (c.x -= c.x * o.x + o.y,
- c.y -= c.y * o.x + o.y,
- c.z -= c.z * o.x + o.y,
- d.x += d.x * o.x + o.y,
- d.y += d.y * o.x + o.y,
- d.z += d.z * o.x + o.y),
- {
- minimum: c,
- maximum: d
- }
- }
- var _FacetDataStorage = function() {
- function a() {
- this.facetNb = 0,
- this.partitioningSubdivisions = 10,
- this.partitioningBBoxRatio = 1.01,
- this.facetDataEnabled = !1,
- this.facetParameters = {},
- this.bbSize = Vector3.Zero(),
- this.subDiv = {
- max: 1,
- X: 1,
- Y: 1,
- Z: 1
- },
- this.facetDepthSort = !1,
- this.facetDepthSortEnabled = !1
- }
- return a
- }()
- , _InternalAbstractMeshDataInfo = function() {
- function a() {
- this._hasVertexAlpha = !1,
- this._useVertexColors = !0,
- this._numBoneInfluencers = 4,
- this._applyFog = !0,
- this._receiveShadows = !1,
- this._facetData = new _FacetDataStorage,
- this._visibility = 1,
- this._skeleton = null,
- this._layerMask = 268435455,
- this._computeBonesUsingShaders = !0,
- this._isActive = !1,
- this._onlyForInstances = !1,
- this._isActiveIntermediate = !1,
- this._onlyForInstancesIntermediate = !1,
- this._actAsRegularMesh = !1,
- this._currentLOD = null,
- this._currentLODIsUpToDate = !1,
- this._collisionRetryCount = 3,
- this._morphTargetManager = null,
- this._renderingGroupId = 0,
- this._bakedVertexAnimationManager = null,
- this._material = null,
- this._positions = null,
- this._meshCollisionData = new _MeshCollisionData
- }
- return a
- }()
- , AbstractMesh = function(a) {
- __extends(e, a);
- function e(i, o) {
- o === void 0 && (o = null);
- var s = a.call(this, i, o, !1) || this;
- return s._internalAbstractMeshDataInfo = new _InternalAbstractMeshDataInfo,
- s.cullingStrategy = e.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY,
- s.onCollideObservable = new Observable,
- s.onCollisionPositionChangeObservable = new Observable,
- s.onMaterialChangedObservable = new Observable,
- s.definedFacingForward = !0,
- s._occlusionQuery = null,
- s._renderingGroup = null,
- s.alphaIndex = Number.MAX_VALUE,
- s.isVisible = !0,
- s.isPickable = !0,
- s.isNearPickable = !1,
- s.isNearGrabbable = !1,
- s.showSubMeshesBoundingBox = !1,
- s.isBlocker = !1,
- s.enablePointerMoveEvents = !1,
- s.outlineColor = Color3.Red(),
- s.outlineWidth = .02,
- s.overlayColor = Color3.Red(),
- s.overlayAlpha = .5,
- s.useOctreeForRenderingSelection = !0,
- s.useOctreeForPicking = !0,
- s.useOctreeForCollisions = !0,
- s.alwaysSelectAsActiveMesh = !1,
- s.doNotSyncBoundingInfo = !1,
- s.actionManager = null,
- s.ellipsoid = new Vector3(.5,1,.5),
- s.ellipsoidOffset = new Vector3(0,0,0),
- s.edgesWidth = 1,
- s.edgesColor = new Color4(1,0,0,1),
- s._edgesRenderer = null,
- s._masterMesh = null,
- s._boundingInfo = null,
- s._boundingInfoIsDirty = !0,
- s._renderId = 0,
- s._intersectionsInProgress = new Array,
- s._unIndexed = !1,
- s._lightSources = new Array,
- s._waitingData = {
- lods: null,
- actions: null,
- freezeWorldMatrix: null
- },
- s._bonesTransformMatrices = null,
- s._transformMatrixTexture = null,
- s.onRebuildObservable = new Observable,
- s._onCollisionPositionChange = function(c, d, _) {
- _ === void 0 && (_ = null),
- d.subtractToRef(s._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions, s._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),
- s._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions.length() > Engine.CollisionsEpsilon && s.position.addInPlace(s._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),
- _ && s.onCollideObservable.notifyObservers(_),
- s.onCollisionPositionChangeObservable.notifyObservers(s.position)
- }
- ,
- s.getScene().addMesh(s),
- s._resyncLightSources(),
- s._uniformBuffer = new UniformBuffer(s.getScene().getEngine(),void 0,void 0,i),
- s._buildUniformLayout(),
- s
- }
- return Object.defineProperty(e, "BILLBOARDMODE_NONE", {
- get: function() {
- return TransformNode.BILLBOARDMODE_NONE
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "BILLBOARDMODE_X", {
- get: function() {
- return TransformNode.BILLBOARDMODE_X
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "BILLBOARDMODE_Y", {
- get: function() {
- return TransformNode.BILLBOARDMODE_Y
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "BILLBOARDMODE_Z", {
- get: function() {
- return TransformNode.BILLBOARDMODE_Z
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "BILLBOARDMODE_ALL", {
- get: function() {
- return TransformNode.BILLBOARDMODE_ALL
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "BILLBOARDMODE_USE_POSITION", {
- get: function() {
- return TransformNode.BILLBOARDMODE_USE_POSITION
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "facetNb", {
- get: function() {
- return this._internalAbstractMeshDataInfo._facetData.facetNb
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "partitioningSubdivisions", {
- get: function() {
- return this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions
- },
- set: function(i) {
- this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "partitioningBBoxRatio", {
- get: function() {
- return this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio
- },
- set: function(i) {
- this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "mustDepthSortFacets", {
- get: function() {
- return this._internalAbstractMeshDataInfo._facetData.facetDepthSort
- },
- set: function(i) {
- this._internalAbstractMeshDataInfo._facetData.facetDepthSort = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "facetDepthSortFrom", {
- get: function() {
- return this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom
- },
- set: function(i) {
- this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "collisionRetryCount", {
- get: function() {
- return this._internalAbstractMeshDataInfo._collisionRetryCount
- },
- set: function(i) {
- this._internalAbstractMeshDataInfo._collisionRetryCount = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isFacetDataEnabled", {
- get: function() {
- return this._internalAbstractMeshDataInfo._facetData.facetDataEnabled
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "morphTargetManager", {
- get: function() {
- return this._internalAbstractMeshDataInfo._morphTargetManager
- },
- set: function(i) {
- this._internalAbstractMeshDataInfo._morphTargetManager !== i && (this._internalAbstractMeshDataInfo._morphTargetManager = i,
- this._syncGeometryWithMorphTargetManager())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "bakedVertexAnimationManager", {
- get: function() {
- return this._internalAbstractMeshDataInfo._bakedVertexAnimationManager
- },
- set: function(i) {
- this._internalAbstractMeshDataInfo._bakedVertexAnimationManager !== i && (this._internalAbstractMeshDataInfo._bakedVertexAnimationManager = i,
- this._markSubMeshesAsAttributesDirty())
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._syncGeometryWithMorphTargetManager = function() {}
- ,
- e.prototype._updateNonUniformScalingState = function(i) {
- return a.prototype._updateNonUniformScalingState.call(this, i) ? (this._markSubMeshesAsMiscDirty(),
- !0) : !1
- }
- ,
- Object.defineProperty(e.prototype, "onCollide", {
- set: function(i) {
- this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver && this.onCollideObservable.remove(this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver),
- this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver = this.onCollideObservable.add(i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "onCollisionPositionChange", {
- set: function(i) {
- this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver && this.onCollisionPositionChangeObservable.remove(this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver),
- this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver = this.onCollisionPositionChangeObservable.add(i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "visibility", {
- get: function() {
- return this._internalAbstractMeshDataInfo._visibility
- },
- set: function(i) {
- if (this._internalAbstractMeshDataInfo._visibility !== i) {
- var o = this._internalAbstractMeshDataInfo._visibility;
- this._internalAbstractMeshDataInfo._visibility = i,
- (o === 1 && i !== 1 || o !== 1 && i === 1) && this._markSubMeshesAsMiscDirty()
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "renderingGroupId", {
- get: function() {
- return this._internalAbstractMeshDataInfo._renderingGroupId
- },
- set: function(i) {
- this._internalAbstractMeshDataInfo._renderingGroupId = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "material", {
- get: function() {
- return this._internalAbstractMeshDataInfo._material
- },
- set: function(i) {
- this._internalAbstractMeshDataInfo._material !== i && (this._internalAbstractMeshDataInfo._material && this._internalAbstractMeshDataInfo._material.meshMap && (this._internalAbstractMeshDataInfo._material.meshMap[this.uniqueId] = void 0),
- this._internalAbstractMeshDataInfo._material = i,
- i && i.meshMap && (i.meshMap[this.uniqueId] = this),
- this.onMaterialChangedObservable.hasObservers() && this.onMaterialChangedObservable.notifyObservers(this),
- this.subMeshes && (this.resetDrawCache(),
- this._unBindEffect()))
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getMaterialForRenderPass = function(i) {
- var o;
- return (o = this._internalAbstractMeshDataInfo._materialForRenderPass) === null || o === void 0 ? void 0 : o[i]
- }
- ,
- e.prototype.setMaterialForRenderPass = function(i, o) {
- this._internalAbstractMeshDataInfo._materialForRenderPass || (this._internalAbstractMeshDataInfo._materialForRenderPass = []),
- this._internalAbstractMeshDataInfo._materialForRenderPass[i] = o
- }
- ,
- Object.defineProperty(e.prototype, "receiveShadows", {
- get: function() {
- return this._internalAbstractMeshDataInfo._receiveShadows
- },
- set: function(i) {
- this._internalAbstractMeshDataInfo._receiveShadows !== i && (this._internalAbstractMeshDataInfo._receiveShadows = i,
- this._markSubMeshesAsLightDirty())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "hasVertexAlpha", {
- get: function() {
- return this._internalAbstractMeshDataInfo._hasVertexAlpha
- },
- set: function(i) {
- this._internalAbstractMeshDataInfo._hasVertexAlpha !== i && (this._internalAbstractMeshDataInfo._hasVertexAlpha = i,
- this._markSubMeshesAsAttributesDirty(),
- this._markSubMeshesAsMiscDirty())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "useVertexColors", {
- get: function() {
- return this._internalAbstractMeshDataInfo._useVertexColors
- },
- set: function(i) {
- this._internalAbstractMeshDataInfo._useVertexColors !== i && (this._internalAbstractMeshDataInfo._useVertexColors = i,
- this._markSubMeshesAsAttributesDirty())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "computeBonesUsingShaders", {
- get: function() {
- return this._internalAbstractMeshDataInfo._computeBonesUsingShaders
- },
- set: function(i) {
- this._internalAbstractMeshDataInfo._computeBonesUsingShaders !== i && (this._internalAbstractMeshDataInfo._computeBonesUsingShaders = i,
- this._markSubMeshesAsAttributesDirty())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "numBoneInfluencers", {
- get: function() {
- return this._internalAbstractMeshDataInfo._numBoneInfluencers
- },
- set: function(i) {
- this._internalAbstractMeshDataInfo._numBoneInfluencers !== i && (this._internalAbstractMeshDataInfo._numBoneInfluencers = i,
- this._markSubMeshesAsAttributesDirty())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "applyFog", {
- get: function() {
- return this._internalAbstractMeshDataInfo._applyFog
- },
- set: function(i) {
- this._internalAbstractMeshDataInfo._applyFog !== i && (this._internalAbstractMeshDataInfo._applyFog = i,
- this._markSubMeshesAsMiscDirty())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "layerMask", {
- get: function() {
- return this._internalAbstractMeshDataInfo._layerMask
- },
- set: function(i) {
- i !== this._internalAbstractMeshDataInfo._layerMask && (this._internalAbstractMeshDataInfo._layerMask = i,
- this._resyncLightSources())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "collisionMask", {
- get: function() {
- return this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask
- },
- set: function(i) {
- this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask = isNaN(i) ? -1 : i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "collisionResponse", {
- get: function() {
- return this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse
- },
- set: function(i) {
- this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "collisionGroup", {
- get: function() {
- return this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup
- },
- set: function(i) {
- this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup = isNaN(i) ? -1 : i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "surroundingMeshes", {
- get: function() {
- return this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes
- },
- set: function(i) {
- this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "lightSources", {
- get: function() {
- return this._lightSources
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "_positions", {
- get: function() {
- return null
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "skeleton", {
- get: function() {
- return this._internalAbstractMeshDataInfo._skeleton
- },
- set: function(i) {
- var o = this._internalAbstractMeshDataInfo._skeleton;
- o && o.needInitialSkinMatrix && o._unregisterMeshWithPoseMatrix(this),
- i && i.needInitialSkinMatrix && i._registerMeshWithPoseMatrix(this),
- this._internalAbstractMeshDataInfo._skeleton = i,
- this._internalAbstractMeshDataInfo._skeleton || (this._bonesTransformMatrices = null),
- this._markSubMeshesAsAttributesDirty()
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildUniformLayout = function() {
- this._uniformBuffer.addUniform("world", 16),
- this._uniformBuffer.addUniform("visibility", 1),
- this._uniformBuffer.create()
- }
- ,
- e.prototype.transferToEffect = function(i) {
- var o = this._uniformBuffer;
- o.updateMatrix("world", i),
- o.updateFloat("visibility", this._internalAbstractMeshDataInfo._visibility),
- o.update()
- }
- ,
- e.prototype.getMeshUniformBuffer = function() {
- return this._uniformBuffer
- }
- ,
- e.prototype.getClassName = function() {
- return "AbstractMesh"
- }
- ,
- e.prototype.toString = function(i) {
- var o = "Name: " + this.name + ", isInstance: " + (this.getClassName() !== "InstancedMesh" ? "YES" : "NO");
- o += ", # of submeshes: " + (this.subMeshes ? this.subMeshes.length : 0);
- var s = this._internalAbstractMeshDataInfo._skeleton;
- return s && (o += ", skeleton: " + s.name),
- i && (o += ", billboard mode: " + ["NONE", "X", "Y", null, "Z", null, null, "ALL"][this.billboardMode],
- o += ", freeze wrld mat: " + (this._isWorldMatrixFrozen || this._waitingData.freezeWorldMatrix ? "YES" : "NO")),
- o
- }
- ,
- e.prototype._getEffectiveParent = function() {
- return this._masterMesh && this.billboardMode !== TransformNode.BILLBOARDMODE_NONE ? this._masterMesh : a.prototype._getEffectiveParent.call(this)
- }
- ,
- e.prototype._getActionManagerForTrigger = function(i, o) {
- if (o === void 0 && (o = !0),
- this.actionManager && (o || this.actionManager.isRecursive))
- if (i) {
- if (this.actionManager.hasSpecificTrigger(i))
- return this.actionManager
- } else
- return this.actionManager;
- return this.parent ? this.parent._getActionManagerForTrigger(i, !1) : null
- }
- ,
- e.prototype._rebuild = function(i) {
- if (this.onRebuildObservable.notifyObservers(this),
- this._occlusionQuery !== null && (this._occlusionQuery = null),
- !!this.subMeshes)
- for (var o = 0, s = this.subMeshes; o < s.length; o++) {
- var c = s[o];
- c._rebuild()
- }
- }
- ,
- e.prototype._resyncLightSources = function() {
- this._lightSources.length = 0;
- for (var i = 0, o = this.getScene().lights; i < o.length; i++) {
- var s = o[i];
- !s.isEnabled() || s.canAffectMesh(this) && this._lightSources.push(s)
- }
- this._markSubMeshesAsLightDirty()
- }
- ,
- e.prototype._resyncLightSource = function(i) {
- var o = i.isEnabled() && i.canAffectMesh(this)
- , s = this._lightSources.indexOf(i)
- , c = !1;
- if (s === -1) {
- if (!o)
- return;
- this._lightSources.push(i)
- } else {
- if (o)
- return;
- c = !0,
- this._lightSources.splice(s, 1)
- }
- this._markSubMeshesAsLightDirty(c)
- }
- ,
- e.prototype._unBindEffect = function() {
- for (var i = 0, o = this.subMeshes; i < o.length; i++) {
- var s = o[i];
- s.setEffect(null)
- }
- }
- ,
- e.prototype._removeLightSource = function(i, o) {
- var s = this._lightSources.indexOf(i);
- s !== -1 && (this._lightSources.splice(s, 1),
- this._markSubMeshesAsLightDirty(o))
- }
- ,
- e.prototype._markSubMeshesAsDirty = function(i) {
- if (!!this.subMeshes)
- for (var o = 0, s = this.subMeshes; o < s.length; o++)
- for (var c = s[o], d = 0; d < c._drawWrappers.length; ++d) {
- var _ = c._drawWrappers[d];
- !_ || !_.defines || !_.defines.markAllAsDirty || i(_.defines)
- }
- }
- ,
- e.prototype._markSubMeshesAsLightDirty = function(i) {
- i === void 0 && (i = !1),
- this._markSubMeshesAsDirty(function(o) {
- return o.markAsLightDirty(i)
- })
- }
- ,
- e.prototype._markSubMeshesAsAttributesDirty = function() {
- this._markSubMeshesAsDirty(function(i) {
- return i.markAsAttributesDirty()
- })
- }
- ,
- e.prototype._markSubMeshesAsMiscDirty = function() {
- this._markSubMeshesAsDirty(function(i) {
- return i.markAsMiscDirty()
- })
- }
- ,
- e.prototype.markAsDirty = function(i) {
- return this._currentRenderId = Number.MAX_VALUE,
- this._isDirty = !0,
- this
- }
- ,
- e.prototype.resetDrawCache = function() {
- if (!!this.subMeshes)
- for (var i = 0, o = this.subMeshes; i < o.length; i++) {
- var s = o[i];
- s.resetDrawCache()
- }
- }
- ,
- Object.defineProperty(e.prototype, "scaling", {
- get: function() {
- return this._scaling
- },
- set: function(i) {
- this._scaling = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isBlocked", {
- get: function() {
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getLOD = function(i) {
- return this
- }
- ,
- e.prototype.getTotalVertices = function() {
- return 0
- }
- ,
- e.prototype.getTotalIndices = function() {
- return 0
- }
- ,
- e.prototype.getIndices = function() {
- return null
- }
- ,
- e.prototype.getVerticesData = function(i) {
- return null
- }
- ,
- e.prototype.setVerticesData = function(i, o, s, c) {
- return this
- }
- ,
- e.prototype.updateVerticesData = function(i, o, s, c) {
- return this
- }
- ,
- e.prototype.setIndices = function(i, o) {
- return this
- }
- ,
- e.prototype.isVerticesDataPresent = function(i) {
- return !1
- }
- ,
- e.prototype.getBoundingInfo = function() {
- return this._masterMesh ? this._masterMesh.getBoundingInfo() : (this._boundingInfoIsDirty && (this._boundingInfoIsDirty = !1,
- this._updateBoundingInfo()),
- this._boundingInfo)
- }
- ,
- e.prototype.setBoundingInfo = function(i) {
- return this._boundingInfo = i,
- this
- }
- ,
- Object.defineProperty(e.prototype, "hasBoundingInfo", {
- get: function() {
- return this._boundingInfo !== null
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.buildBoundingInfo = function(i, o, s) {
- return this._boundingInfo = new BoundingInfo(i,o,s),
- this._boundingInfo
- }
- ,
- e.prototype.normalizeToUnitCube = function(i, o, s) {
- return i === void 0 && (i = !0),
- o === void 0 && (o = !1),
- a.prototype.normalizeToUnitCube.call(this, i, o, s)
- }
- ,
- Object.defineProperty(e.prototype, "useBones", {
- get: function() {
- return this.skeleton && this.getScene().skeletonsEnabled && this.isVerticesDataPresent(VertexBuffer.MatricesIndicesKind) && this.isVerticesDataPresent(VertexBuffer.MatricesWeightsKind)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._preActivate = function() {}
- ,
- e.prototype._preActivateForIntermediateRendering = function(i) {}
- ,
- e.prototype._activate = function(i, o) {
- return this._renderId = i,
- !0
- }
- ,
- e.prototype._postActivate = function() {}
- ,
- e.prototype._freeze = function() {}
- ,
- e.prototype._unFreeze = function() {}
- ,
- e.prototype.getWorldMatrix = function() {
- return this._masterMesh && this.billboardMode === TransformNode.BILLBOARDMODE_NONE ? this._masterMesh.getWorldMatrix() : a.prototype.getWorldMatrix.call(this)
- }
- ,
- e.prototype._getWorldMatrixDeterminant = function() {
- return this._masterMesh ? this._masterMesh._getWorldMatrixDeterminant() : a.prototype._getWorldMatrixDeterminant.call(this)
- }
- ,
- Object.defineProperty(e.prototype, "isAnInstance", {
- get: function() {
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "hasInstances", {
- get: function() {
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "hasThinInstances", {
- get: function() {
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.movePOV = function(i, o, s) {
- return this.position.addInPlace(this.calcMovePOV(i, o, s)),
- this
- }
- ,
- e.prototype.calcMovePOV = function(i, o, s) {
- var c = new Matrix
- , d = this.rotationQuaternion ? this.rotationQuaternion : Quaternion.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
- d.toRotationMatrix(c);
- var _ = Vector3.Zero()
- , b = this.definedFacingForward ? -1 : 1;
- return Vector3.TransformCoordinatesFromFloatsToRef(i * b, o, s * b, c, _),
- _
- }
- ,
- e.prototype.rotatePOV = function(i, o, s) {
- return this.rotation.addInPlace(this.calcRotatePOV(i, o, s)),
- this
- }
- ,
- e.prototype.calcRotatePOV = function(i, o, s) {
- var c = this.definedFacingForward ? 1 : -1;
- return new Vector3(i * c,o,s * c)
- }
- ,
- e.prototype.refreshBoundingInfo = function(i, o) {
- return i === void 0 && (i = !1),
- o === void 0 && (o = !1),
- this._boundingInfo && this._boundingInfo.isLocked ? this : (this._refreshBoundingInfo(this._getPositionData(i, o), null),
- this)
- }
- ,
- e.prototype._refreshBoundingInfo = function(i, o) {
- if (i) {
- var s = extractMinAndMax(i, 0, this.getTotalVertices(), o);
- this._boundingInfo ? this._boundingInfo.reConstruct(s.minimum, s.maximum) : this._boundingInfo = new BoundingInfo(s.minimum,s.maximum)
- }
- if (this.subMeshes)
- for (var c = 0; c < this.subMeshes.length; c++)
- this.subMeshes[c].refreshBoundingInfo(i);
- this._updateBoundingInfo()
- }
- ,
- e.prototype._getPositionData = function(i, o) {
- var s, c = this.getVerticesData(VertexBuffer.PositionKind);
- if (this._internalAbstractMeshDataInfo._positions && (this._internalAbstractMeshDataInfo._positions = null),
- c && (i && this.skeleton || o && this.morphTargetManager) && (c = Tools.Slice(c),
- this._generatePointsArray(),
- this._positions)) {
- var d = this._positions;
- this._internalAbstractMeshDataInfo._positions = new Array(d.length);
- for (var _ = 0; _ < d.length; _++)
- this._internalAbstractMeshDataInfo._positions[_] = ((s = d[_]) === null || s === void 0 ? void 0 : s.clone()) || new Vector3
- }
- if (c && o && this.morphTargetManager)
- for (var b = 0, k = 0, j = 0; j < c.length; j++) {
- for (var $ = 0; $ < this.morphTargetManager.numTargets; $++) {
- var _e = this.morphTargetManager.getTarget($)
- , et = _e.influence;
- if (et > 0) {
- var tt = _e.getPositions();
- tt && (c[j] += (tt[j] - c[j]) * et)
- }
- }
- if (b++,
- this._positions && b === 3) {
- b = 0;
- var rt = k * 3;
- this._positions[k++].copyFromFloats(c[rt], c[rt + 1], c[rt + 2])
- }
- }
- if (c && i && this.skeleton) {
- var it = this.getVerticesData(VertexBuffer.MatricesIndicesKind)
- , nt = this.getVerticesData(VertexBuffer.MatricesWeightsKind);
- if (nt && it) {
- var ot = this.numBoneInfluencers > 4
- , at = ot ? this.getVerticesData(VertexBuffer.MatricesIndicesExtraKind) : null
- , st = ot ? this.getVerticesData(VertexBuffer.MatricesWeightsExtraKind) : null;
- this.skeleton.prepare();
- 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,
- ht += 4) {
- lt.reset();
- var dt, _t;
- for (dt = 0; dt < 4; dt++)
- _t = nt[ht + dt],
- _t > 0 && (Matrix.FromFloat32ArrayToRefScaled(ut, Math.floor(it[ht + dt] * 16), _t, ft),
- lt.addToSelf(ft));
- if (ot)
- for (dt = 0; dt < 4; dt++)
- _t = st[ht + dt],
- _t > 0 && (Matrix.FromFloat32ArrayToRefScaled(ut, Math.floor(at[ht + dt] * 16), _t, ft),
- lt.addToSelf(ft));
- Vector3.TransformCoordinatesFromFloatsToRef(c[pt], c[pt + 1], c[pt + 2], lt, ct),
- ct.toArray(c, pt),
- this._positions && this._positions[pt / 3].copyFrom(ct)
- }
- }
- }
- return c
- }
- ,
- e.prototype._updateBoundingInfo = function() {
- var i = this._effectiveMesh;
- return this._boundingInfo ? this._boundingInfo.update(i.worldMatrixFromCache) : this._boundingInfo = new BoundingInfo(this.position,this.position,i.worldMatrixFromCache),
- this._updateSubMeshesBoundingInfo(i.worldMatrixFromCache),
- this
- }
- ,
- e.prototype._updateSubMeshesBoundingInfo = function(i) {
- if (!this.subMeshes)
- return this;
- for (var o = this.subMeshes.length, s = 0; s < o; s++) {
- var c = this.subMeshes[s];
- (o > 1 || !c.IsGlobal) && c.updateBoundingInfo(i)
- }
- return this
- }
- ,
- e.prototype._afterComputeWorldMatrix = function() {
- this.doNotSyncBoundingInfo || (this._boundingInfoIsDirty = !0)
- }
- ,
- Object.defineProperty(e.prototype, "_effectiveMesh", {
- get: function() {
- return this.skeleton && this.skeleton.overrideMesh || this
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.isInFrustum = function(i) {
- return this.getBoundingInfo().isInFrustum(i, this.cullingStrategy)
- }
- ,
- e.prototype.isCompletelyInFrustum = function(i) {
- return this.getBoundingInfo().isCompletelyInFrustum(i)
- }
- ,
- e.prototype.intersectsMesh = function(i, o, s) {
- o === void 0 && (o = !1);
- var c = this.getBoundingInfo()
- , d = i.getBoundingInfo();
- if (c.intersects(d, o))
- return !0;
- if (s)
- for (var _ = 0, b = this.getChildMeshes(); _ < b.length; _++) {
- var k = b[_];
- if (k.intersectsMesh(i, o, !0))
- return !0
- }
- return !1
- }
- ,
- e.prototype.intersectsPoint = function(i) {
- return this.getBoundingInfo().intersectsPoint(i)
- }
- ,
- Object.defineProperty(e.prototype, "checkCollisions", {
- get: function() {
- return this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions
- },
- set: function(i) {
- this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "collider", {
- get: function() {
- return this._internalAbstractMeshDataInfo._meshCollisionData._collider
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.moveWithCollisions = function(i) {
- var o = this.getAbsolutePosition();
- o.addToRef(this.ellipsoidOffset, this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions);
- var s = this.getScene().collisionCoordinator;
- return this._internalAbstractMeshDataInfo._meshCollisionData._collider || (this._internalAbstractMeshDataInfo._meshCollisionData._collider = s.createCollider()),
- this._internalAbstractMeshDataInfo._meshCollisionData._collider._radius = this.ellipsoid,
- s.getNewPosition(this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions, i, this._internalAbstractMeshDataInfo._meshCollisionData._collider, this.collisionRetryCount, this, this._onCollisionPositionChange, this.uniqueId),
- this
- }
- ,
- e.prototype._collideForSubMesh = function(i, o, s) {
- if (this._generatePointsArray(),
- !this._positions)
- return this;
- if (!i._lastColliderWorldVertices || !i._lastColliderTransformMatrix.equals(o)) {
- i._lastColliderTransformMatrix = o.clone(),
- i._lastColliderWorldVertices = [],
- i._trianglePlanes = [];
- for (var c = i.verticesStart, d = i.verticesStart + i.verticesCount, _ = c; _ < d; _++)
- i._lastColliderWorldVertices.push(Vector3.TransformCoordinates(this._positions[_], o))
- }
- return s._collide(i._trianglePlanes, i._lastColliderWorldVertices, this.getIndices(), i.indexStart, i.indexStart + i.indexCount, i.verticesStart, !!i.getMaterial(), this),
- this
- }
- ,
- e.prototype._processCollisionsForSubMeshes = function(i, o) {
- for (var s = this._scene.getCollidingSubMeshCandidates(this, i), c = s.length, d = 0; d < c; d++) {
- var _ = s.data[d];
- c > 1 && !_._checkCollision(i) || this._collideForSubMesh(_, o, i)
- }
- return this
- }
- ,
- e.prototype._checkCollision = function(i) {
- if (!this.getBoundingInfo()._checkCollision(i))
- return this;
- var o = TmpVectors.Matrix[0]
- , s = TmpVectors.Matrix[1];
- return Matrix.ScalingToRef(1 / i._radius.x, 1 / i._radius.y, 1 / i._radius.z, o),
- this.worldMatrixFromCache.multiplyToRef(o, s),
- this._processCollisionsForSubMeshes(i, s),
- this
- }
- ,
- e.prototype._generatePointsArray = function() {
- return !1
- }
- ,
- e.prototype.intersects = function(i, o, s, c, d, _) {
- c === void 0 && (c = !1),
- _ === void 0 && (_ = !1);
- var b = new PickingInfo
- , k = this.getClassName() === "InstancedLinesMesh" || this.getClassName() === "LinesMesh" ? this.intersectionThreshold : 0
- , j = this.getBoundingInfo();
- if (!this.subMeshes || !_ && (!i.intersectsSphere(j.boundingSphere, k) || !i.intersectsBox(j.boundingBox, k)))
- return b;
- if (c)
- return b.hit = !_,
- b.pickedMesh = _ ? null : this,
- b.distance = _ ? 0 : Vector3.Distance(i.origin, j.boundingSphere.center),
- b.subMeshId = 0,
- b;
- if (!this._generatePointsArray())
- return b;
- for (var $ = null, _e = this._scene.getIntersectingSubMeshCandidates(this, i), et = _e.length, tt = !1, rt = 0; rt < et; rt++) {
- var it = _e.data[rt]
- , nt = it.getMaterial();
- if (!!nt && (nt.fillMode == 7 || nt.fillMode == 0 || nt.fillMode == 1 || nt.fillMode == 2)) {
- tt = !0;
- break
- }
- }
- if (!tt)
- return b.hit = !0,
- b.pickedMesh = this,
- b.distance = Vector3.Distance(i.origin, j.boundingSphere.center),
- b.subMeshId = -1,
- b;
- for (var rt = 0; rt < et; rt++) {
- var it = _e.data[rt];
- if (!(et > 1 && !it.canIntersects(i))) {
- var ot = it.intersects(i, this._positions, this.getIndices(), o, s);
- if (ot && (o || !$ || ot.distance < $.distance) && ($ = ot,
- $.subMeshId = rt,
- o))
- break
- }
- }
- if ($) {
- var at = d != null ? d : this.skeleton && this.skeleton.overrideMesh ? this.skeleton.overrideMesh.getWorldMatrix() : this.getWorldMatrix()
- , st = TmpVectors.Vector3[0]
- , ut = TmpVectors.Vector3[1];
- Vector3.TransformCoordinatesToRef(i.origin, at, st),
- i.direction.scaleToRef($.distance, ut);
- var ct = Vector3.TransformNormal(ut, at)
- , lt = ct.addInPlace(st);
- return b.hit = !0,
- b.distance = Vector3.Distance(st, lt),
- b.pickedPoint = lt,
- b.pickedMesh = this,
- b.bu = $.bu || 0,
- b.bv = $.bv || 0,
- b.subMeshFaceId = $.faceId,
- b.faceId = $.faceId + _e.data[$.subMeshId].indexStart / (this.getClassName().indexOf("LinesMesh") !== -1 ? 2 : 3),
- b.subMeshId = $.subMeshId,
- b
- }
- return b
- }
- ,
- e.prototype.clone = function(i, o, s) {
- return null
- }
- ,
- e.prototype.releaseSubMeshes = function() {
- if (this.subMeshes)
- for (; this.subMeshes.length; )
- this.subMeshes[0].dispose();
- else
- this.subMeshes = new Array;
- return this
- }
- ,
- e.prototype.dispose = function(i, o) {
- var s = this;
- o === void 0 && (o = !1);
- var c;
- for (this._scene.useMaterialMeshMap && this._internalAbstractMeshDataInfo._material && this._internalAbstractMeshDataInfo._material.meshMap && (this._internalAbstractMeshDataInfo._material.meshMap[this.uniqueId] = void 0),
- this.getScene().freeActiveMeshes(),
- this.getScene().freeRenderingGroups(),
- this.actionManager !== void 0 && this.actionManager !== null && (this.actionManager.dispose(),
- this.actionManager = null),
- this._internalAbstractMeshDataInfo._skeleton = null,
- this._transformMatrixTexture && (this._transformMatrixTexture.dispose(),
- this._transformMatrixTexture = null),
- c = 0; c < this._intersectionsInProgress.length; c++) {
- var d = this._intersectionsInProgress[c]
- , _ = d._intersectionsInProgress.indexOf(this);
- d._intersectionsInProgress.splice(_, 1)
- }
- this._intersectionsInProgress = [];
- var b = this.getScene().lights;
- b.forEach(function($) {
- var _e = $.includedOnlyMeshes.indexOf(s);
- _e !== -1 && $.includedOnlyMeshes.splice(_e, 1),
- _e = $.excludedMeshes.indexOf(s),
- _e !== -1 && $.excludedMeshes.splice(_e, 1);
- var et = $.getShadowGenerator();
- if (et) {
- var tt = et.getShadowMap();
- tt && tt.renderList && (_e = tt.renderList.indexOf(s),
- _e !== -1 && tt.renderList.splice(_e, 1))
- }
- }),
- (this.getClassName() !== "InstancedMesh" || this.getClassName() !== "InstancedLinesMesh") && this.releaseSubMeshes();
- var k = this.getScene().getEngine();
- if (this._occlusionQuery !== null && (this.isOcclusionQueryInProgress = !1,
- k.deleteQuery(this._occlusionQuery),
- this._occlusionQuery = null),
- k.wipeCaches(),
- this.getScene().removeMesh(this),
- this._parentContainer) {
- var j = this._parentContainer.meshes.indexOf(this);
- j > -1 && this._parentContainer.meshes.splice(j, 1),
- this._parentContainer = null
- }
- if (o && this.material && (this.material.getClassName() === "MultiMaterial" ? this.material.dispose(!1, !0, !0) : this.material.dispose(!1, !0)),
- !i)
- for (c = 0; c < this.getScene().particleSystems.length; c++)
- this.getScene().particleSystems[c].emitter === this && (this.getScene().particleSystems[c].dispose(),
- c--);
- this._internalAbstractMeshDataInfo._facetData.facetDataEnabled && this.disableFacetData(),
- this._uniformBuffer.dispose(),
- this.onAfterWorldMatrixUpdateObservable.clear(),
- this.onCollideObservable.clear(),
- this.onCollisionPositionChangeObservable.clear(),
- this.onRebuildObservable.clear(),
- a.prototype.dispose.call(this, i, o)
- }
- ,
- e.prototype.addChild = function(i, o) {
- return o === void 0 && (o = !1),
- i.setParent(this, o),
- this
- }
- ,
- e.prototype.removeChild = function(i, o) {
- return o === void 0 && (o = !1),
- i.setParent(null, o),
- this
- }
- ,
- e.prototype._initFacetData = function() {
- var i = this._internalAbstractMeshDataInfo._facetData;
- i.facetNormals || (i.facetNormals = new Array),
- i.facetPositions || (i.facetPositions = new Array),
- i.facetPartitioning || (i.facetPartitioning = new Array),
- i.facetNb = this.getIndices().length / 3 | 0,
- i.partitioningSubdivisions = i.partitioningSubdivisions ? i.partitioningSubdivisions : 10,
- i.partitioningBBoxRatio = i.partitioningBBoxRatio ? i.partitioningBBoxRatio : 1.01;
- for (var o = 0; o < i.facetNb; o++)
- i.facetNormals[o] = Vector3.Zero(),
- i.facetPositions[o] = Vector3.Zero();
- return i.facetDataEnabled = !0,
- this
- }
- ,
- e.prototype.updateFacetData = function() {
- var i = this._internalAbstractMeshDataInfo._facetData;
- i.facetDataEnabled || this._initFacetData();
- var o = this.getVerticesData(VertexBuffer.PositionKind)
- , s = this.getIndices()
- , c = this.getVerticesData(VertexBuffer.NormalKind)
- , d = this.getBoundingInfo();
- if (i.facetDepthSort && !i.facetDepthSortEnabled) {
- if (i.facetDepthSortEnabled = !0,
- s instanceof Uint16Array)
- i.depthSortedIndices = new Uint16Array(s);
- else if (s instanceof Uint32Array)
- i.depthSortedIndices = new Uint32Array(s);
- else {
- for (var _ = !1, b = 0; b < s.length; b++)
- if (s[b] > 65535) {
- _ = !0;
- break
- }
- _ ? i.depthSortedIndices = new Uint32Array(s) : i.depthSortedIndices = new Uint16Array(s)
- }
- if (i.facetDepthSortFunction = function(rt, it) {
- return it.sqDistance - rt.sqDistance
- }
- ,
- !i.facetDepthSortFrom) {
- var k = this.getScene().activeCamera;
- i.facetDepthSortFrom = k ? k.position : Vector3.Zero()
- }
- i.depthSortedFacets = [];
- for (var j = 0; j < i.facetNb; j++) {
- var $ = {
- ind: j * 3,
- sqDistance: 0
- };
- i.depthSortedFacets.push($)
- }
- i.invertedMatrix = Matrix.Identity(),
- i.facetDepthSortOrigin = Vector3.Zero()
- }
- i.bbSize.x = d.maximum.x - d.minimum.x > Epsilon ? d.maximum.x - d.minimum.x : Epsilon,
- i.bbSize.y = d.maximum.y - d.minimum.y > Epsilon ? d.maximum.y - d.minimum.y : Epsilon,
- i.bbSize.z = d.maximum.z - d.minimum.z > Epsilon ? d.maximum.z - d.minimum.z : Epsilon;
- var _e = i.bbSize.x > i.bbSize.y ? i.bbSize.x : i.bbSize.y;
- if (_e = _e > i.bbSize.z ? _e : i.bbSize.z,
- i.subDiv.max = i.partitioningSubdivisions,
- i.subDiv.X = Math.floor(i.subDiv.max * i.bbSize.x / _e),
- i.subDiv.Y = Math.floor(i.subDiv.max * i.bbSize.y / _e),
- i.subDiv.Z = Math.floor(i.subDiv.max * i.bbSize.z / _e),
- i.subDiv.X = i.subDiv.X < 1 ? 1 : i.subDiv.X,
- i.subDiv.Y = i.subDiv.Y < 1 ? 1 : i.subDiv.Y,
- i.subDiv.Z = i.subDiv.Z < 1 ? 1 : i.subDiv.Z,
- i.facetParameters.facetNormals = this.getFacetLocalNormals(),
- i.facetParameters.facetPositions = this.getFacetLocalPositions(),
- i.facetParameters.facetPartitioning = this.getFacetLocalPartitioning(),
- i.facetParameters.bInfo = d,
- i.facetParameters.bbSize = i.bbSize,
- i.facetParameters.subDiv = i.subDiv,
- i.facetParameters.ratio = this.partitioningBBoxRatio,
- i.facetParameters.depthSort = i.facetDepthSort,
- i.facetDepthSort && i.facetDepthSortEnabled && (this.computeWorldMatrix(!0),
- this._worldMatrix.invertToRef(i.invertedMatrix),
- Vector3.TransformCoordinatesToRef(i.facetDepthSortFrom, i.invertedMatrix, i.facetDepthSortOrigin),
- i.facetParameters.distanceTo = i.facetDepthSortOrigin),
- i.facetParameters.depthSortedFacets = i.depthSortedFacets,
- c && VertexData.ComputeNormals(o, s, c, i.facetParameters),
- i.facetDepthSort && i.facetDepthSortEnabled) {
- i.depthSortedFacets.sort(i.facetDepthSortFunction);
- for (var et = i.depthSortedIndices.length / 3 | 0, j = 0; j < et; j++) {
- var tt = i.depthSortedFacets[j].ind;
- i.depthSortedIndices[j * 3] = s[tt],
- i.depthSortedIndices[j * 3 + 1] = s[tt + 1],
- i.depthSortedIndices[j * 3 + 2] = s[tt + 2]
- }
- this.updateIndices(i.depthSortedIndices, void 0, !0)
- }
- return this
- }
- ,
- e.prototype.getFacetLocalNormals = function() {
- var i = this._internalAbstractMeshDataInfo._facetData;
- return i.facetNormals || this.updateFacetData(),
- i.facetNormals
- }
- ,
- e.prototype.getFacetLocalPositions = function() {
- var i = this._internalAbstractMeshDataInfo._facetData;
- return i.facetPositions || this.updateFacetData(),
- i.facetPositions
- }
- ,
- e.prototype.getFacetLocalPartitioning = function() {
- var i = this._internalAbstractMeshDataInfo._facetData;
- return i.facetPartitioning || this.updateFacetData(),
- i.facetPartitioning
- }
- ,
- e.prototype.getFacetPosition = function(i) {
- var o = Vector3.Zero();
- return this.getFacetPositionToRef(i, o),
- o
- }
- ,
- e.prototype.getFacetPositionToRef = function(i, o) {
- var s = this.getFacetLocalPositions()[i]
- , c = this.getWorldMatrix();
- return Vector3.TransformCoordinatesToRef(s, c, o),
- this
- }
- ,
- e.prototype.getFacetNormal = function(i) {
- var o = Vector3.Zero();
- return this.getFacetNormalToRef(i, o),
- o
- }
- ,
- e.prototype.getFacetNormalToRef = function(i, o) {
- var s = this.getFacetLocalNormals()[i];
- return Vector3.TransformNormalToRef(s, this.getWorldMatrix(), o),
- this
- }
- ,
- e.prototype.getFacetsAtLocalCoordinates = function(i, o, s) {
- var c = this.getBoundingInfo()
- , d = this._internalAbstractMeshDataInfo._facetData
- , _ = Math.floor((i - c.minimum.x * d.partitioningBBoxRatio) * d.subDiv.X * d.partitioningBBoxRatio / d.bbSize.x)
- , b = Math.floor((o - c.minimum.y * d.partitioningBBoxRatio) * d.subDiv.Y * d.partitioningBBoxRatio / d.bbSize.y)
- , k = Math.floor((s - c.minimum.z * d.partitioningBBoxRatio) * d.subDiv.Z * d.partitioningBBoxRatio / d.bbSize.z);
- 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]
- }
- ,
- e.prototype.getClosestFacetAtCoordinates = function(i, o, s, c, d, _) {
- d === void 0 && (d = !1),
- _ === void 0 && (_ = !0);
- var b = this.getWorldMatrix()
- , k = TmpVectors.Matrix[5];
- b.invertToRef(k);
- var j = TmpVectors.Vector3[8];
- Vector3.TransformCoordinatesFromFloatsToRef(i, o, s, k, j);
- var $ = this.getClosestFacetAtLocalCoordinates(j.x, j.y, j.z, c, d, _);
- return c && Vector3.TransformCoordinatesFromFloatsToRef(c.x, c.y, c.z, b, c),
- $
- }
- ,
- e.prototype.getClosestFacetAtLocalCoordinates = function(i, o, s, c, d, _) {
- d === void 0 && (d = !1),
- _ === void 0 && (_ = !0);
- var b = null
- , k = 0
- , j = 0
- , $ = 0
- , _e = 0
- , et = 0
- , tt = 0
- , rt = 0
- , it = 0
- , nt = this.getFacetLocalPositions()
- , ot = this.getFacetLocalNormals()
- , at = this.getFacetsAtLocalCoordinates(i, o, s);
- if (!at)
- return null;
- for (var st = Number.MAX_VALUE, ut = st, ct, lt, ft, ht = 0; ht < at.length; ht++)
- ct = at[ht],
- lt = ot[ct],
- ft = nt[ct],
- _e = (i - ft.x) * lt.x + (o - ft.y) * lt.y + (s - ft.z) * lt.z,
- (!d || d && _ && _e >= 0 || d && !_ && _e <= 0) && (_e = lt.x * ft.x + lt.y * ft.y + lt.z * ft.z,
- et = -(lt.x * i + lt.y * o + lt.z * s - _e) / (lt.x * lt.x + lt.y * lt.y + lt.z * lt.z),
- tt = i + lt.x * et,
- rt = o + lt.y * et,
- it = s + lt.z * et,
- k = tt - i,
- j = rt - o,
- $ = it - s,
- ut = k * k + j * j + $ * $,
- ut < st && (st = ut,
- b = ct,
- c && (c.x = tt,
- c.y = rt,
- c.z = it)));
- return b
- }
- ,
- e.prototype.getFacetDataParameters = function() {
- return this._internalAbstractMeshDataInfo._facetData.facetParameters
- }
- ,
- e.prototype.disableFacetData = function() {
- var i = this._internalAbstractMeshDataInfo._facetData;
- return i.facetDataEnabled && (i.facetDataEnabled = !1,
- i.facetPositions = new Array,
- i.facetNormals = new Array,
- i.facetPartitioning = new Array,
- i.facetParameters = null,
- i.depthSortedIndices = new Uint32Array(0)),
- this
- }
- ,
- e.prototype.updateIndices = function(i, o, s) {
- return this
- }
- ,
- e.prototype.createNormals = function(i) {
- var o = this.getVerticesData(VertexBuffer.PositionKind), s = this.getIndices(), c;
- return this.isVerticesDataPresent(VertexBuffer.NormalKind) ? c = this.getVerticesData(VertexBuffer.NormalKind) : c = [],
- VertexData.ComputeNormals(o, s, c, {
- useRightHandedSystem: this.getScene().useRightHandedSystem
- }),
- this.setVerticesData(VertexBuffer.NormalKind, c, i),
- this
- }
- ,
- e.prototype.alignWithNormal = function(i, o) {
- o || (o = Axis.Y);
- var s = TmpVectors.Vector3[0]
- , c = TmpVectors.Vector3[1];
- return Vector3.CrossToRef(o, i, c),
- Vector3.CrossToRef(i, c, s),
- this.rotationQuaternion ? Quaternion.RotationQuaternionFromAxisToRef(s, i, c, this.rotationQuaternion) : Vector3.RotationFromAxisToRef(s, i, c, this.rotation),
- this
- }
- ,
- e.prototype._checkOcclusionQuery = function() {
- return !1
- }
- ,
- e.prototype.disableEdgesRendering = function() {
- throw _WarnImport("EdgesRenderer")
- }
- ,
- e.prototype.enableEdgesRendering = function(i, o, s) {
- throw _WarnImport("EdgesRenderer")
- }
- ,
- e.prototype.getConnectedParticleSystems = function() {
- var i = this;
- return this._scene.particleSystems.filter(function(o) {
- return o.emitter === i
- })
- }
- ,
- e.OCCLUSION_TYPE_NONE = 0,
- e.OCCLUSION_TYPE_OPTIMISTIC = 1,
- e.OCCLUSION_TYPE_STRICT = 2,
- e.OCCLUSION_ALGORITHM_TYPE_ACCURATE = 0,
- e.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE = 1,
- e.CULLINGSTRATEGY_STANDARD = 0,
- e.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = 1,
- e.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = 2,
- e.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = 3,
- e
- }(TransformNode);
- RegisterClass("BABYLON.AbstractMesh", AbstractMesh);
- var _TimeToken = function() {
- function a() {
- this._timeElapsedQueryEnded = !1
- }
- return a
- }()
- , _OcclusionDataStorage = function() {
- function a() {
- this.occlusionInternalRetryCounter = 0,
- this.isOcclusionQueryInProgress = !1,
- this.isOccluded = !1,
- this.occlusionRetryCount = -1,
- this.occlusionType = AbstractMesh.OCCLUSION_TYPE_NONE,
- this.occlusionQueryAlgorithmType = AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE
- }
- return a
- }();
- Engine.prototype.createQuery = function() {
- return this._gl.createQuery()
- }
- ;
- Engine.prototype.deleteQuery = function(a) {
- return this._gl.deleteQuery(a),
- this
- }
- ;
- Engine.prototype.isQueryResultAvailable = function(a) {
- return this._gl.getQueryParameter(a, this._gl.QUERY_RESULT_AVAILABLE)
- }
- ;
- Engine.prototype.getQueryResult = function(a) {
- return this._gl.getQueryParameter(a, this._gl.QUERY_RESULT)
- }
- ;
- Engine.prototype.beginOcclusionQuery = function(a, e) {
- var i = this._getGlAlgorithmType(a);
- return this._gl.beginQuery(i, e),
- !0
- }
- ;
- Engine.prototype.endOcclusionQuery = function(a) {
- var e = this._getGlAlgorithmType(a);
- return this._gl.endQuery(e),
- this
- }
- ;
- Engine.prototype._createTimeQuery = function() {
- var a = this.getCaps().timerQuery;
- return a.createQueryEXT ? a.createQueryEXT() : this.createQuery()
- }
- ;
- Engine.prototype._deleteTimeQuery = function(a) {
- var e = this.getCaps().timerQuery;
- if (e.deleteQueryEXT) {
- e.deleteQueryEXT(a);
- return
- }
- this.deleteQuery(a)
- }
- ;
- Engine.prototype._getTimeQueryResult = function(a) {
- var e = this.getCaps().timerQuery;
- return e.getQueryObjectEXT ? e.getQueryObjectEXT(a, e.QUERY_RESULT_EXT) : this.getQueryResult(a)
- }
- ;
- Engine.prototype._getTimeQueryAvailability = function(a) {
- var e = this.getCaps().timerQuery;
- return e.getQueryObjectEXT ? e.getQueryObjectEXT(a, e.QUERY_RESULT_AVAILABLE_EXT) : this.isQueryResultAvailable(a)
- }
- ;
- Engine.prototype.startTimeQuery = function() {
- var a = this.getCaps()
- , e = a.timerQuery;
- if (!e)
- return null;
- var i = new _TimeToken;
- if (this._gl.getParameter(e.GPU_DISJOINT_EXT),
- a.canUseTimestampForTimerQuery)
- i._startTimeQuery = this._createTimeQuery(),
- e.queryCounterEXT(i._startTimeQuery, e.TIMESTAMP_EXT);
- else {
- if (this._currentNonTimestampToken)
- return this._currentNonTimestampToken;
- i._timeElapsedQuery = this._createTimeQuery(),
- e.beginQueryEXT ? e.beginQueryEXT(e.TIME_ELAPSED_EXT, i._timeElapsedQuery) : this._gl.beginQuery(e.TIME_ELAPSED_EXT, i._timeElapsedQuery),
- this._currentNonTimestampToken = i
- }
- return i
- }
- ;
- Engine.prototype.endTimeQuery = function(a) {
- var e = this.getCaps()
- , i = e.timerQuery;
- if (!i || !a)
- return -1;
- if (e.canUseTimestampForTimerQuery) {
- if (!a._startTimeQuery)
- return -1;
- a._endTimeQuery || (a._endTimeQuery = this._createTimeQuery(),
- i.queryCounterEXT(a._endTimeQuery, i.TIMESTAMP_EXT))
- } else if (!a._timeElapsedQueryEnded) {
- if (!a._timeElapsedQuery)
- return -1;
- i.endQueryEXT ? i.endQueryEXT(i.TIME_ELAPSED_EXT) : this._gl.endQuery(i.TIME_ELAPSED_EXT),
- a._timeElapsedQueryEnded = !0
- }
- var o = this._gl.getParameter(i.GPU_DISJOINT_EXT)
- , s = !1;
- if (a._endTimeQuery ? s = this._getTimeQueryAvailability(a._endTimeQuery) : a._timeElapsedQuery && (s = this._getTimeQueryAvailability(a._timeElapsedQuery)),
- s && !o) {
- var c = 0;
- if (e.canUseTimestampForTimerQuery) {
- if (!a._startTimeQuery || !a._endTimeQuery)
- return -1;
- var d = this._getTimeQueryResult(a._startTimeQuery)
- , _ = this._getTimeQueryResult(a._endTimeQuery);
- c = _ - d,
- this._deleteTimeQuery(a._startTimeQuery),
- this._deleteTimeQuery(a._endTimeQuery),
- a._startTimeQuery = null,
- a._endTimeQuery = null
- } else {
- if (!a._timeElapsedQuery)
- return -1;
- c = this._getTimeQueryResult(a._timeElapsedQuery),
- this._deleteTimeQuery(a._timeElapsedQuery),
- a._timeElapsedQuery = null,
- a._timeElapsedQueryEnded = !1,
- this._currentNonTimestampToken = null
- }
- return c
- }
- return -1
- }
- ;
- Engine.prototype._captureGPUFrameTime = !1;
- Engine.prototype._gpuFrameTime = new PerfCounter;
- Engine.prototype.getGPUFrameTimeCounter = function() {
- return this._gpuFrameTime
- }
- ;
- Engine.prototype.captureGPUFrameTime = function(a) {
- var e = this;
- a !== this._captureGPUFrameTime && (this._captureGPUFrameTime = a,
- a ? (this._onBeginFrameObserver = this.onBeginFrameObservable.add(function() {
- e._gpuFrameTimeToken || (e._gpuFrameTimeToken = e.startTimeQuery())
- }),
- this._onEndFrameObserver = this.onEndFrameObservable.add(function() {
- if (!!e._gpuFrameTimeToken) {
- var i = e.endTimeQuery(e._gpuFrameTimeToken);
- i > -1 && (e._gpuFrameTimeToken = null,
- e._gpuFrameTime.fetchNewFrame(),
- e._gpuFrameTime.addCount(i, !0))
- }
- })) : (this.onBeginFrameObservable.remove(this._onBeginFrameObserver),
- this._onBeginFrameObserver = null,
- this.onEndFrameObservable.remove(this._onEndFrameObserver),
- this._onEndFrameObserver = null))
- }
- ;
- Engine.prototype._getGlAlgorithmType = function(a) {
- return a === AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE ? this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE : this._gl.ANY_SAMPLES_PASSED
- }
- ;
- Object.defineProperty(AbstractMesh.prototype, "isOcclusionQueryInProgress", {
- get: function() {
- return this._occlusionDataStorage.isOcclusionQueryInProgress
- },
- set: function(a) {
- this._occlusionDataStorage.isOcclusionQueryInProgress = a
- },
- enumerable: !1,
- configurable: !0
- });
- Object.defineProperty(AbstractMesh.prototype, "_occlusionDataStorage", {
- get: function() {
- return this.__occlusionDataStorage || (this.__occlusionDataStorage = new _OcclusionDataStorage),
- this.__occlusionDataStorage
- },
- enumerable: !1,
- configurable: !0
- });
- Object.defineProperty(AbstractMesh.prototype, "isOccluded", {
- get: function() {
- return this._occlusionDataStorage.isOccluded
- },
- set: function(a) {
- this._occlusionDataStorage.isOccluded = a
- },
- enumerable: !0,
- configurable: !0
- });
- Object.defineProperty(AbstractMesh.prototype, "occlusionQueryAlgorithmType", {
- get: function() {
- return this._occlusionDataStorage.occlusionQueryAlgorithmType
- },
- set: function(a) {
- this._occlusionDataStorage.occlusionQueryAlgorithmType = a
- },
- enumerable: !0,
- configurable: !0
- });
- Object.defineProperty(AbstractMesh.prototype, "occlusionType", {
- get: function() {
- return this._occlusionDataStorage.occlusionType
- },
- set: function(a) {
- this._occlusionDataStorage.occlusionType = a
- },
- enumerable: !0,
- configurable: !0
- });
- Object.defineProperty(AbstractMesh.prototype, "occlusionRetryCount", {
- get: function() {
- return this._occlusionDataStorage.occlusionRetryCount
- },
- set: function(a) {
- this._occlusionDataStorage.occlusionRetryCount = a
- },
- enumerable: !0,
- configurable: !0
- });
- AbstractMesh.prototype._checkOcclusionQuery = function() {
- var a = this._occlusionDataStorage;
- if (a.occlusionType === AbstractMesh.OCCLUSION_TYPE_NONE)
- return a.isOccluded = !1,
- !1;
- var e = this.getEngine();
- if (!e.getCaps().supportOcclusionQuery || !e.isQueryResultAvailable)
- return a.isOccluded = !1,
- !1;
- if (this.isOcclusionQueryInProgress && this._occlusionQuery) {
- var i = e.isQueryResultAvailable(this._occlusionQuery);
- if (i) {
- var o = e.getQueryResult(this._occlusionQuery);
- a.isOcclusionQueryInProgress = !1,
- a.occlusionInternalRetryCounter = 0,
- a.isOccluded = !(o > 0)
- } else if (a.occlusionInternalRetryCounter++,
- a.occlusionRetryCount !== -1 && a.occlusionInternalRetryCounter > a.occlusionRetryCount)
- a.isOcclusionQueryInProgress = !1,
- a.occlusionInternalRetryCounter = 0,
- a.isOccluded = a.occlusionType === AbstractMesh.OCCLUSION_TYPE_OPTIMISTIC ? !1 : a.isOccluded;
- else
- return a.occlusionType === AbstractMesh.OCCLUSION_TYPE_OPTIMISTIC ? !1 : a.isOccluded
- }
- var s = this.getScene();
- if (s.getBoundingBoxRenderer) {
- var c = s.getBoundingBoxRenderer();
- this._occlusionQuery === null && (this._occlusionQuery = e.createQuery()),
- e.beginOcclusionQuery(a.occlusionQueryAlgorithmType, this._occlusionQuery) && (c.renderOcclusionBoundingBox(this),
- e.endOcclusionQuery(a.occlusionQueryAlgorithmType),
- this._occlusionDataStorage.isOcclusionQueryInProgress = !0)
- }
- return a.isOccluded
- }
- ;
- Engine.prototype.createTransformFeedback = function() {
- return this._gl.createTransformFeedback()
- }
- ;
- Engine.prototype.deleteTransformFeedback = function(a) {
- this._gl.deleteTransformFeedback(a)
- }
- ;
- Engine.prototype.bindTransformFeedback = function(a) {
- this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK, a)
- }
- ;
- Engine.prototype.beginTransformFeedback = function(a) {
- a === void 0 && (a = !0),
- this._gl.beginTransformFeedback(a ? this._gl.POINTS : this._gl.TRIANGLES)
- }
- ;
- Engine.prototype.endTransformFeedback = function() {
- this._gl.endTransformFeedback()
- }
- ;
- Engine.prototype.setTranformFeedbackVaryings = function(a, e) {
- this._gl.transformFeedbackVaryings(a, e, this._gl.INTERLEAVED_ATTRIBS)
- }
- ;
- Engine.prototype.bindTransformFeedbackBuffer = function(a) {
- this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER, 0, a ? a.underlyingResource : null)
- }
- ;
- var SmartArray = function() {
- function a(e) {
- this.length = 0,
- this.data = new Array(e),
- this._id = a._GlobalId++
- }
- return a.prototype.push = function(e) {
- this.data[this.length++] = e,
- this.length > this.data.length && (this.data.length *= 2)
- }
- ,
- a.prototype.forEach = function(e) {
- for (var i = 0; i < this.length; i++)
- e(this.data[i])
- }
- ,
- a.prototype.sort = function(e) {
- this.data.sort(e)
- }
- ,
- a.prototype.reset = function() {
- this.length = 0
- }
- ,
- a.prototype.dispose = function() {
- this.reset(),
- this.data && (this.data.length = 0,
- this.data = [])
- }
- ,
- a.prototype.concat = function(e) {
- if (e.length !== 0) {
- this.length + e.length > this.data.length && (this.data.length = (this.length + e.length) * 2);
- for (var i = 0; i < e.length; i++)
- this.data[this.length++] = (e.data || e)[i]
- }
- }
- ,
- a.prototype.indexOf = function(e) {
- var i = this.data.indexOf(e);
- return i >= this.length ? -1 : i
- }
- ,
- a.prototype.contains = function(e) {
- return this.indexOf(e) !== -1
- }
- ,
- a._GlobalId = 0,
- a
- }()
- , SmartArrayNoDuplicate = function(a) {
- __extends(e, a);
- function e() {
- var i = a !== null && a.apply(this, arguments) || this;
- return i._duplicateId = 0,
- i
- }
- return e.prototype.push = function(i) {
- a.prototype.push.call(this, i),
- i.__smartArrayFlags || (i.__smartArrayFlags = {}),
- i.__smartArrayFlags[this._id] = this._duplicateId
- }
- ,
- e.prototype.pushNoDuplicate = function(i) {
- return i.__smartArrayFlags && i.__smartArrayFlags[this._id] === this._duplicateId ? !1 : (this.push(i),
- !0)
- }
- ,
- e.prototype.reset = function() {
- a.prototype.reset.call(this),
- this._duplicateId++
- }
- ,
- e.prototype.concatWithNoDuplicate = function(i) {
- if (i.length !== 0) {
- this.length + i.length > this.data.length && (this.data.length = (this.length + i.length) * 2);
- for (var o = 0; o < i.length; o++) {
- var s = (i.data || i)[o];
- this.pushNoDuplicate(s)
- }
- }
- }
- ,
- e
- }(SmartArray)
- , Viewport = function() {
- function a(e, i, o, s) {
- this.x = e,
- this.y = i,
- this.width = o,
- this.height = s
- }
- return a.prototype.toGlobal = function(e, i) {
- return new a(this.x * e,this.y * i,this.width * e,this.height * i)
- }
- ,
- a.prototype.toGlobalToRef = function(e, i, o) {
- return o.x = this.x * e,
- o.y = this.y * i,
- o.width = this.width * e,
- o.height = this.height * i,
- this
- }
- ,
- a.prototype.clone = function() {
- return new a(this.x,this.y,this.width,this.height)
- }
- ,
- a
- }()
- , Plane = function() {
- function a(e, i, o, s) {
- this.normal = new Vector3(e,i,o),
- this.d = s
- }
- return a.prototype.asArray = function() {
- return [this.normal.x, this.normal.y, this.normal.z, this.d]
- }
- ,
- a.prototype.clone = function() {
- return new a(this.normal.x,this.normal.y,this.normal.z,this.d)
- }
- ,
- a.prototype.getClassName = function() {
- return "Plane"
- }
- ,
- a.prototype.getHashCode = function() {
- var e = this.normal.getHashCode();
- return e = e * 397 ^ (this.d | 0),
- e
- }
- ,
- a.prototype.normalize = function() {
- var e = Math.sqrt(this.normal.x * this.normal.x + this.normal.y * this.normal.y + this.normal.z * this.normal.z)
- , i = 0;
- return e !== 0 && (i = 1 / e),
- this.normal.x *= i,
- this.normal.y *= i,
- this.normal.z *= i,
- this.d *= i,
- this
- }
- ,
- a.prototype.transform = function(e) {
- var i = a._TmpMatrix;
- e.invertToRef(i);
- var o = i.m
- , s = this.normal.x
- , c = this.normal.y
- , d = this.normal.z
- , _ = this.d
- , b = s * o[0] + c * o[1] + d * o[2] + _ * o[3]
- , k = s * o[4] + c * o[5] + d * o[6] + _ * o[7]
- , j = s * o[8] + c * o[9] + d * o[10] + _ * o[11]
- , $ = s * o[12] + c * o[13] + d * o[14] + _ * o[15];
- return new a(b,k,j,$)
- }
- ,
- a.prototype.dotCoordinate = function(e) {
- return this.normal.x * e.x + this.normal.y * e.y + this.normal.z * e.z + this.d
- }
- ,
- a.prototype.copyFromPoints = function(e, i, o) {
- 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;
- return et !== 0 ? tt = 1 / et : tt = 0,
- this.normal.x = j * tt,
- this.normal.y = $ * tt,
- this.normal.z = _e * tt,
- this.d = -(this.normal.x * e.x + this.normal.y * e.y + this.normal.z * e.z),
- this
- }
- ,
- a.prototype.isFrontFacingTo = function(e, i) {
- var o = Vector3.Dot(this.normal, e);
- return o <= i
- }
- ,
- a.prototype.signedDistanceTo = function(e) {
- return Vector3.Dot(e, this.normal) + this.d
- }
- ,
- a.FromArray = function(e) {
- return new a(e[0],e[1],e[2],e[3])
- }
- ,
- a.FromPoints = function(e, i, o) {
- var s = new a(0,0,0,0);
- return s.copyFromPoints(e, i, o),
- s
- }
- ,
- a.FromPositionAndNormal = function(e, i) {
- var o = new a(0,0,0,0);
- return i.normalize(),
- o.normal = i,
- o.d = -(i.x * e.x + i.y * e.y + i.z * e.z),
- o
- }
- ,
- a.SignedDistanceToPlaneFromPositionAndNormal = function(e, i, o) {
- var s = -(i.x * e.x + i.y * e.y + i.z * e.z);
- return Vector3.Dot(o, i) + s
- }
- ,
- a._TmpMatrix = Matrix.Identity(),
- a
- }()
- , Frustum = function() {
- function a() {}
- return a.GetPlanes = function(e) {
- for (var i = [], o = 0; o < 6; o++)
- i.push(new Plane(0,0,0,0));
- return a.GetPlanesToRef(e, i),
- i
- }
- ,
- a.GetNearPlaneToRef = function(e, i) {
- var o = e.m;
- i.normal.x = o[3] + o[2],
- i.normal.y = o[7] + o[6],
- i.normal.z = o[11] + o[10],
- i.d = o[15] + o[14],
- i.normalize()
- }
- ,
- a.GetFarPlaneToRef = function(e, i) {
- var o = e.m;
- i.normal.x = o[3] - o[2],
- i.normal.y = o[7] - o[6],
- i.normal.z = o[11] - o[10],
- i.d = o[15] - o[14],
- i.normalize()
- }
- ,
- a.GetLeftPlaneToRef = function(e, i) {
- var o = e.m;
- i.normal.x = o[3] + o[0],
- i.normal.y = o[7] + o[4],
- i.normal.z = o[11] + o[8],
- i.d = o[15] + o[12],
- i.normalize()
- }
- ,
- a.GetRightPlaneToRef = function(e, i) {
- var o = e.m;
- i.normal.x = o[3] - o[0],
- i.normal.y = o[7] - o[4],
- i.normal.z = o[11] - o[8],
- i.d = o[15] - o[12],
- i.normalize()
- }
- ,
- a.GetTopPlaneToRef = function(e, i) {
- var o = e.m;
- i.normal.x = o[3] - o[1],
- i.normal.y = o[7] - o[5],
- i.normal.z = o[11] - o[9],
- i.d = o[15] - o[13],
- i.normalize()
- }
- ,
- a.GetBottomPlaneToRef = function(e, i) {
- var o = e.m;
- i.normal.x = o[3] + o[1],
- i.normal.y = o[7] + o[5],
- i.normal.z = o[11] + o[9],
- i.d = o[15] + o[13],
- i.normalize()
- }
- ,
- a.GetPlanesToRef = function(e, i) {
- a.GetNearPlaneToRef(e, i[0]),
- a.GetFarPlaneToRef(e, i[1]),
- a.GetLeftPlaneToRef(e, i[2]),
- a.GetRightPlaneToRef(e, i[3]),
- a.GetTopPlaneToRef(e, i[4]),
- a.GetBottomPlaneToRef(e, i[5])
- }
- ,
- a
- }()
- , Camera$1 = function(a) {
- __extends(e, a);
- function e(i, o, s, c) {
- c === void 0 && (c = !0);
- var d = a.call(this, i, s) || this;
- return d._position = Vector3.Zero(),
- d._upVector = Vector3.Up(),
- d.orthoLeft = null,
- d.orthoRight = null,
- d.orthoBottom = null,
- d.orthoTop = null,
- d.fov = .8,
- d.projectionPlaneTilt = 0,
- d.minZ = 1,
- d.maxZ = 1e4,
- d.inertia = .9,
- d.mode = e.PERSPECTIVE_CAMERA,
- d.isIntermediate = !1,
- d.viewport = new Viewport(0,0,1,1),
- d.layerMask = 268435455,
- d.fovMode = e.FOVMODE_VERTICAL_FIXED,
- d.cameraRigMode = e.RIG_MODE_NONE,
- d.customRenderTargets = new Array,
- d.outputRenderTarget = null,
- d.onViewMatrixChangedObservable = new Observable,
- d.onProjectionMatrixChangedObservable = new Observable,
- d.onAfterCheckInputsObservable = new Observable,
- d.onRestoreStateObservable = new Observable,
- d.isRigCamera = !1,
- d._rigCameras = new Array,
- d._webvrViewMatrix = Matrix.Identity(),
- d._skipRendering = !1,
- d._projectionMatrix = new Matrix,
- d._postProcesses = new Array,
- d._activeMeshes = new SmartArray(256),
- d._globalPosition = Vector3.Zero(),
- d._computedViewMatrix = Matrix.Identity(),
- d._doNotComputeProjectionMatrix = !1,
- d._transformMatrix = Matrix.Zero(),
- d._refreshFrustumPlanes = !0,
- d._absoluteRotation = Quaternion.Identity(),
- d._isCamera = !0,
- d._isLeftCamera = !1,
- d._isRightCamera = !1,
- d.getScene().addCamera(d),
- c && !d.getScene().activeCamera && (d.getScene().activeCamera = d),
- d.position = o,
- d.renderPassId = d.getScene().getEngine().createRenderPassId("Camera " + i),
- d
- }
- return Object.defineProperty(e.prototype, "position", {
- get: function() {
- return this._position
- },
- set: function(i) {
- this._position = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "upVector", {
- get: function() {
- return this._upVector
- },
- set: function(i) {
- this._upVector = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "screenArea", {
- get: function() {
- var i, o, s, c, d = 0, _ = 0;
- if (this.mode === e.PERSPECTIVE_CAMERA)
- this.fovMode === e.FOVMODE_VERTICAL_FIXED ? (_ = this.minZ * 2 * Math.tan(this.fov / 2),
- d = this.getEngine().getAspectRatio(this) * _) : (d = this.minZ * 2 * Math.tan(this.fov / 2),
- _ = d / this.getEngine().getAspectRatio(this));
- else {
- var b = this.getEngine().getRenderWidth() / 2
- , k = this.getEngine().getRenderHeight() / 2;
- d = ((i = this.orthoRight) !== null && i !== void 0 ? i : b) - ((o = this.orthoLeft) !== null && o !== void 0 ? o : -b),
- _ = ((s = this.orthoTop) !== null && s !== void 0 ? s : k) - ((c = this.orthoBottom) !== null && c !== void 0 ? c : -k)
- }
- return d * _
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.storeState = function() {
- return this._stateStored = !0,
- this._storedFov = this.fov,
- this
- }
- ,
- e.prototype._restoreStateValues = function() {
- return this._stateStored ? (this.fov = this._storedFov,
- !0) : !1
- }
- ,
- e.prototype.restoreState = function() {
- return this._restoreStateValues() ? (this.onRestoreStateObservable.notifyObservers(this),
- !0) : !1
- }
- ,
- e.prototype.getClassName = function() {
- return "Camera"
- }
- ,
- e.prototype.toString = function(i) {
- var o = "Name: " + this.name;
- if (o += ", type: " + this.getClassName(),
- this.animations)
- for (var s = 0; s < this.animations.length; s++)
- o += ", animation[0]: " + this.animations[s].toString(i);
- return o
- }
- ,
- e.prototype.applyVerticalCorrection = function() {
- var i = this.absoluteRotation.toEulerAngles();
- this.projectionPlaneTilt = this._scene.useRightHandedSystem ? -i.x : i.x
- }
- ,
- Object.defineProperty(e.prototype, "globalPosition", {
- get: function() {
- return this._globalPosition
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getActiveMeshes = function() {
- return this._activeMeshes
- }
- ,
- e.prototype.isActiveMesh = function(i) {
- return this._activeMeshes.indexOf(i) !== -1
- }
- ,
- e.prototype.isReady = function(i) {
- if (i === void 0 && (i = !1),
- i)
- for (var o = 0, s = this._postProcesses; o < s.length; o++) {
- var c = s[o];
- if (c && !c.isReady())
- return !1
- }
- return a.prototype.isReady.call(this, i)
- }
- ,
- e.prototype._initCache = function() {
- a.prototype._initCache.call(this),
- this._cache.position = new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
- this._cache.upVector = new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
- this._cache.mode = void 0,
- this._cache.minZ = void 0,
- this._cache.maxZ = void 0,
- this._cache.fov = void 0,
- this._cache.fovMode = void 0,
- this._cache.aspectRatio = void 0,
- this._cache.orthoLeft = void 0,
- this._cache.orthoRight = void 0,
- this._cache.orthoBottom = void 0,
- this._cache.orthoTop = void 0,
- this._cache.renderWidth = void 0,
- this._cache.renderHeight = void 0
- }
- ,
- e.prototype._updateCache = function(i) {
- i || a.prototype._updateCache.call(this),
- this._cache.position.copyFrom(this.position),
- this._cache.upVector.copyFrom(this.upVector)
- }
- ,
- e.prototype._isSynchronized = function() {
- return this._isSynchronizedViewMatrix() && this._isSynchronizedProjectionMatrix()
- }
- ,
- e.prototype._isSynchronizedViewMatrix = function() {
- return a.prototype._isSynchronized.call(this) ? this._cache.position.equals(this.position) && this._cache.upVector.equals(this.upVector) && this.isSynchronizedWithParent() : !1
- }
- ,
- e.prototype._isSynchronizedProjectionMatrix = function() {
- var i = this._cache.mode === this.mode && this._cache.minZ === this.minZ && this._cache.maxZ === this.maxZ;
- if (!i)
- return !1;
- var o = this.getEngine();
- 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(),
- i
- }
- ,
- e.prototype.attachControl = function(i, o) {}
- ,
- e.prototype.detachControl = function(i) {}
- ,
- e.prototype.update = function() {
- this._checkInputs(),
- this.cameraRigMode !== e.RIG_MODE_NONE && this._updateRigCameras()
- }
- ,
- e.prototype._checkInputs = function() {
- this.onAfterCheckInputsObservable.notifyObservers(this)
- }
- ,
- Object.defineProperty(e.prototype, "rigCameras", {
- get: function() {
- return this._rigCameras
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "rigPostProcess", {
- get: function() {
- return this._rigPostProcess
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._getFirstPostProcess = function() {
- for (var i = 0; i < this._postProcesses.length; i++)
- if (this._postProcesses[i] !== null)
- return this._postProcesses[i];
- return null
- }
- ,
- e.prototype._cascadePostProcessesToRigCams = function() {
- var i = this._getFirstPostProcess();
- i && i.markTextureDirty();
- for (var o = 0, s = this._rigCameras.length; o < s; o++) {
- var c = this._rigCameras[o]
- , d = c._rigPostProcess;
- if (d) {
- var _ = d.getEffectName() === "pass";
- _ && (c.isIntermediate = this._postProcesses.length === 0),
- c._postProcesses = this._postProcesses.slice(0).concat(d),
- d.markTextureDirty()
- } else
- c._postProcesses = this._postProcesses.slice(0)
- }
- }
- ,
- e.prototype.attachPostProcess = function(i, o) {
- return o === void 0 && (o = null),
- !i.isReusable() && this._postProcesses.indexOf(i) > -1 ? (Logger$2.Error("You're trying to reuse a post process not defined as reusable."),
- 0) : (o == null || o < 0 ? this._postProcesses.push(i) : this._postProcesses[o] === null ? this._postProcesses[o] = i : this._postProcesses.splice(o, 0, i),
- this._cascadePostProcessesToRigCams(),
- this._scene.prePassRenderer && this._scene.prePassRenderer.markAsDirty(),
- this._postProcesses.indexOf(i))
- }
- ,
- e.prototype.detachPostProcess = function(i) {
- var o = this._postProcesses.indexOf(i);
- o !== -1 && (this._postProcesses[o] = null),
- this._scene.prePassRenderer && this._scene.prePassRenderer.markAsDirty(),
- this._cascadePostProcessesToRigCams()
- }
- ,
- e.prototype.getWorldMatrix = function() {
- return this._isSynchronizedViewMatrix() ? this._worldMatrix : (this.getViewMatrix(),
- this._worldMatrix)
- }
- ,
- e.prototype._getViewMatrix = function() {
- return Matrix.Identity()
- }
- ,
- e.prototype.getViewMatrix = function(i) {
- return !i && this._isSynchronizedViewMatrix() ? this._computedViewMatrix : (this.updateCache(),
- this._computedViewMatrix = this._getViewMatrix(),
- this._currentRenderId = this.getScene().getRenderId(),
- this._childUpdateId++,
- this._refreshFrustumPlanes = !0,
- this._cameraRigParams && this._cameraRigParams.vrPreViewMatrix && this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix, this._computedViewMatrix),
- this.parent && this.parent.onViewMatrixChangedObservable && this.parent.onViewMatrixChangedObservable.notifyObservers(this.parent),
- this.onViewMatrixChangedObservable.notifyObservers(this),
- this._computedViewMatrix.invertToRef(this._worldMatrix),
- this._computedViewMatrix)
- }
- ,
- e.prototype.freezeProjectionMatrix = function(i) {
- this._doNotComputeProjectionMatrix = !0,
- i !== void 0 && (this._projectionMatrix = i)
- }
- ,
- e.prototype.unfreezeProjectionMatrix = function() {
- this._doNotComputeProjectionMatrix = !1
- }
- ,
- e.prototype.getProjectionMatrix = function(i) {
- var o, s, c, d, _, b, k, j;
- if (this._doNotComputeProjectionMatrix || !i && this._isSynchronizedProjectionMatrix())
- return this._projectionMatrix;
- this._cache.mode = this.mode,
- this._cache.minZ = this.minZ,
- this._cache.maxZ = this.maxZ,
- this._refreshFrustumPlanes = !0;
- var $ = this.getEngine()
- , _e = this.getScene();
- if (this.mode === e.PERSPECTIVE_CAMERA) {
- this._cache.fov = this.fov,
- this._cache.fovMode = this.fovMode,
- this._cache.aspectRatio = $.getAspectRatio(this),
- this._cache.projectionPlaneTilt = this.projectionPlaneTilt,
- this.minZ <= 0 && (this.minZ = .1);
- var et = $.useReverseDepthBuffer
- , tt = void 0;
- _e.useRightHandedSystem ? tt = Matrix.PerspectiveFovRHToRef : tt = Matrix.PerspectiveFovLHToRef,
- 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)
- } else {
- var rt = $.getRenderWidth() / 2
- , it = $.getRenderHeight() / 2;
- _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),
- this._cache.orthoLeft = this.orthoLeft,
- this._cache.orthoRight = this.orthoRight,
- this._cache.orthoBottom = this.orthoBottom,
- this._cache.orthoTop = this.orthoTop,
- this._cache.renderWidth = $.getRenderWidth(),
- this._cache.renderHeight = $.getRenderHeight()
- }
- return this.onProjectionMatrixChangedObservable.notifyObservers(this),
- this._projectionMatrix
- }
- ,
- e.prototype.getTransformationMatrix = function() {
- return this._computedViewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix),
- this._transformMatrix
- }
- ,
- e.prototype._updateFrustumPlanes = function() {
- !this._refreshFrustumPlanes || (this.getTransformationMatrix(),
- this._frustumPlanes ? Frustum.GetPlanesToRef(this._transformMatrix, this._frustumPlanes) : this._frustumPlanes = Frustum.GetPlanes(this._transformMatrix),
- this._refreshFrustumPlanes = !1)
- }
- ,
- e.prototype.isInFrustum = function(i, o) {
- if (o === void 0 && (o = !1),
- this._updateFrustumPlanes(),
- o && this.rigCameras.length > 0) {
- var s = !1;
- return this.rigCameras.forEach(function(c) {
- c._updateFrustumPlanes(),
- s = s || i.isInFrustum(c._frustumPlanes)
- }),
- s
- } else
- return i.isInFrustum(this._frustumPlanes)
- }
- ,
- e.prototype.isCompletelyInFrustum = function(i) {
- return this._updateFrustumPlanes(),
- i.isCompletelyInFrustum(this._frustumPlanes)
- }
- ,
- e.prototype.getForwardRay = function(i, o, s) {
- throw _WarnImport("Ray")
- }
- ,
- e.prototype.getForwardRayToRef = function(i, o, s, c) {
- throw _WarnImport("Ray")
- }
- ,
- e.prototype.dispose = function(i, o) {
- for (o === void 0 && (o = !1),
- this.onViewMatrixChangedObservable.clear(),
- this.onProjectionMatrixChangedObservable.clear(),
- this.onAfterCheckInputsObservable.clear(),
- this.onRestoreStateObservable.clear(),
- this.inputs && this.inputs.clear(),
- this.getScene().stopAnimation(this),
- this.getScene().removeCamera(this); this._rigCameras.length > 0; ) {
- var s = this._rigCameras.pop();
- s && s.dispose()
- }
- if (this._parentContainer) {
- var c = this._parentContainer.cameras.indexOf(this);
- c > -1 && this._parentContainer.cameras.splice(c, 1),
- this._parentContainer = null
- }
- if (this._rigPostProcess)
- this._rigPostProcess.dispose(this),
- this._rigPostProcess = null,
- this._postProcesses = [];
- else if (this.cameraRigMode !== e.RIG_MODE_NONE)
- this._rigPostProcess = null,
- this._postProcesses = [];
- else
- for (var _ = this._postProcesses.length; --_ >= 0; ) {
- var d = this._postProcesses[_];
- d && d.dispose(this)
- }
- for (var _ = this.customRenderTargets.length; --_ >= 0; )
- this.customRenderTargets[_].dispose();
- this.customRenderTargets = [],
- this._activeMeshes.dispose(),
- this.getScene().getEngine().releaseRenderPassId(this.renderPassId),
- a.prototype.dispose.call(this, i, o)
- }
- ,
- Object.defineProperty(e.prototype, "isLeftCamera", {
- get: function() {
- return this._isLeftCamera
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isRightCamera", {
- get: function() {
- return this._isRightCamera
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "leftCamera", {
- get: function() {
- return this._rigCameras.length < 1 ? null : this._rigCameras[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "rightCamera", {
- get: function() {
- return this._rigCameras.length < 2 ? null : this._rigCameras[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getLeftTarget = function() {
- return this._rigCameras.length < 1 ? null : this._rigCameras[0].getTarget()
- }
- ,
- e.prototype.getRightTarget = function() {
- return this._rigCameras.length < 2 ? null : this._rigCameras[1].getTarget()
- }
- ,
- e.prototype.setCameraRigMode = function(i, o) {
- if (this.cameraRigMode !== i) {
- for (; this._rigCameras.length > 0; ) {
- var s = this._rigCameras.pop();
- s && s.dispose()
- }
- if (this.cameraRigMode = i,
- this._cameraRigParams = {},
- this._cameraRigParams.interaxialDistance = o.interaxialDistance || .0637,
- this._cameraRigParams.stereoHalfAngle = Tools.ToRadians(this._cameraRigParams.interaxialDistance / .0637),
- this.cameraRigMode !== e.RIG_MODE_NONE) {
- var c = this.createRigCamera(this.name + "_L", 0);
- c && (c._isLeftCamera = !0);
- var d = this.createRigCamera(this.name + "_R", 1);
- d && (d._isRightCamera = !0),
- c && d && (this._rigCameras.push(c),
- this._rigCameras.push(d))
- }
- this._setRigMode(o),
- this._cascadePostProcessesToRigCams(),
- this.update()
- }
- }
- ,
- e.prototype._setRigMode = function(i) {}
- ,
- e.prototype._getVRProjectionMatrix = function() {
- return Matrix.PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov, this._cameraRigParams.vrMetrics.aspectRatio, this.minZ, this.maxZ, this._cameraRigParams.vrWorkMatrix, !0, this.getEngine().isNDCHalfZRange),
- this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix, this._projectionMatrix),
- this._projectionMatrix
- }
- ,
- e.prototype._updateCameraRotationMatrix = function() {}
- ,
- e.prototype._updateWebVRCameraRotationMatrix = function() {}
- ,
- e.prototype._getWebVRProjectionMatrix = function() {
- return Matrix.Identity()
- }
- ,
- e.prototype._getWebVRViewMatrix = function() {
- return Matrix.Identity()
- }
- ,
- e.prototype.setCameraRigParameter = function(i, o) {
- this._cameraRigParams || (this._cameraRigParams = {}),
- this._cameraRigParams[i] = o,
- i === "interaxialDistance" && (this._cameraRigParams.stereoHalfAngle = Tools.ToRadians(o / .0637))
- }
- ,
- e.prototype.createRigCamera = function(i, o) {
- return null
- }
- ,
- e.prototype._updateRigCameras = function() {
- for (var i = 0; i < this._rigCameras.length; i++)
- this._rigCameras[i].minZ = this.minZ,
- this._rigCameras[i].maxZ = this.maxZ,
- this._rigCameras[i].fov = this.fov,
- this._rigCameras[i].upVector.copyFrom(this.upVector);
- this.cameraRigMode === e.RIG_MODE_STEREOSCOPIC_ANAGLYPH && (this._rigCameras[0].viewport = this._rigCameras[1].viewport = this.viewport)
- }
- ,
- e.prototype._setupInputs = function() {}
- ,
- e.prototype.serialize = function() {
- var i = SerializationHelper.Serialize(this);
- return i.uniqueId = this.uniqueId,
- i.type = this.getClassName(),
- this.parent && (i.parentId = this.parent.uniqueId),
- this.inputs && this.inputs.serialize(i),
- SerializationHelper.AppendSerializedAnimations(this, i),
- i.ranges = this.serializeAnimationRanges(),
- i.isEnabled = this.isEnabled(),
- i
- }
- ,
- e.prototype.clone = function(i) {
- var o = SerializationHelper.Clone(e.GetConstructorFromName(this.getClassName(), i, this.getScene(), this.interaxialDistance, this.isStereoscopicSideBySide), this);
- return o.name = i,
- this.onClonedObservable.notifyObservers(o),
- o
- }
- ,
- e.prototype.getDirection = function(i) {
- var o = Vector3.Zero();
- return this.getDirectionToRef(i, o),
- o
- }
- ,
- Object.defineProperty(e.prototype, "absoluteRotation", {
- get: function() {
- return this.getWorldMatrix().decompose(void 0, this._absoluteRotation),
- this._absoluteRotation
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getDirectionToRef = function(i, o) {
- Vector3.TransformNormalToRef(i, this.getWorldMatrix(), o)
- }
- ,
- e.GetConstructorFromName = function(i, o, s, c, d) {
- c === void 0 && (c = 0),
- d === void 0 && (d = !0);
- var _ = Node$2.Construct(i, o, s, {
- interaxial_distance: c,
- isStereoscopicSideBySide: d
- });
- return _ || function() {
- return e._createDefaultParsedCamera(o, s)
- }
- }
- ,
- e.prototype.computeWorldMatrix = function() {
- return this.getWorldMatrix()
- }
- ,
- e.Parse = function(i, o) {
- var s = i.type
- , c = e.GetConstructorFromName(s, i.name, o, i.interaxial_distance, i.isStereoscopicSideBySide)
- , d = SerializationHelper.Parse(c, i, o);
- if (i.parentId && (d._waitingParentId = i.parentId),
- d.inputs && (d.inputs.parse(i),
- d._setupInputs()),
- i.upVector && (d.upVector = Vector3.FromArray(i.upVector)),
- d.setPosition && (d.position.copyFromFloats(0, 0, 0),
- d.setPosition(Vector3.FromArray(i.position))),
- i.target && d.setTarget && d.setTarget(Vector3.FromArray(i.target)),
- i.cameraRigMode) {
- var _ = i.interaxial_distance ? {
- interaxialDistance: i.interaxial_distance
- } : {};
- d.setCameraRigMode(i.cameraRigMode, _)
- }
- if (i.animations) {
- for (var b = 0; b < i.animations.length; b++) {
- var k = i.animations[b]
- , j = GetClass("BABYLON.Animation");
- j && d.animations.push(j.Parse(k))
- }
- Node$2.ParseAnimationRanges(d, i, o)
- }
- return i.autoAnimate && o.beginAnimation(d, i.autoAnimateFrom, i.autoAnimateTo, i.autoAnimateLoop, i.autoAnimateSpeed || 1),
- i.isEnabled !== void 0 && d.setEnabled(i.isEnabled),
- d
- }
- ,
- e._createDefaultParsedCamera = function(i, o) {
- throw _WarnImport("UniversalCamera")
- }
- ,
- e.PERSPECTIVE_CAMERA = 0,
- e.ORTHOGRAPHIC_CAMERA = 1,
- e.FOVMODE_VERTICAL_FIXED = 0,
- e.FOVMODE_HORIZONTAL_FIXED = 1,
- e.RIG_MODE_NONE = 0,
- e.RIG_MODE_STEREOSCOPIC_ANAGLYPH = 10,
- e.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL = 11,
- e.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED = 12,
- e.RIG_MODE_STEREOSCOPIC_OVERUNDER = 13,
- e.RIG_MODE_STEREOSCOPIC_INTERLACED = 14,
- e.RIG_MODE_VR = 20,
- e.RIG_MODE_WEBVR = 21,
- e.RIG_MODE_CUSTOM = 22,
- e.ForceAttachControlToAlwaysPreventDefault = !1,
- __decorate([serializeAsVector3("position")], e.prototype, "_position", void 0),
- __decorate([serializeAsVector3("upVector")], e.prototype, "_upVector", void 0),
- __decorate([serialize()], e.prototype, "orthoLeft", void 0),
- __decorate([serialize()], e.prototype, "orthoRight", void 0),
- __decorate([serialize()], e.prototype, "orthoBottom", void 0),
- __decorate([serialize()], e.prototype, "orthoTop", void 0),
- __decorate([serialize()], e.prototype, "fov", void 0),
- __decorate([serialize()], e.prototype, "projectionPlaneTilt", void 0),
- __decorate([serialize()], e.prototype, "minZ", void 0),
- __decorate([serialize()], e.prototype, "maxZ", void 0),
- __decorate([serialize()], e.prototype, "inertia", void 0),
- __decorate([serialize()], e.prototype, "mode", void 0),
- __decorate([serialize()], e.prototype, "layerMask", void 0),
- __decorate([serialize()], e.prototype, "fovMode", void 0),
- __decorate([serialize()], e.prototype, "cameraRigMode", void 0),
- __decorate([serialize()], e.prototype, "interaxialDistance", void 0),
- __decorate([serialize()], e.prototype, "isStereoscopicSideBySide", void 0),
- e
- }(Node$2)
- , StringDictionary = function() {
- function a() {
- this._count = 0,
- this._data = {}
- }
- return a.prototype.copyFrom = function(e) {
- var i = this;
- this.clear(),
- e.forEach(function(o, s) {
- return i.add(o, s)
- })
- }
- ,
- a.prototype.get = function(e) {
- var i = this._data[e];
- if (i !== void 0)
- return i
- }
- ,
- a.prototype.getOrAddWithFactory = function(e, i) {
- var o = this.get(e);
- return o !== void 0 || (o = i(e),
- o && this.add(e, o)),
- o
- }
- ,
- a.prototype.getOrAdd = function(e, i) {
- var o = this.get(e);
- return o !== void 0 ? o : (this.add(e, i),
- i)
- }
- ,
- a.prototype.contains = function(e) {
- return this._data[e] !== void 0
- }
- ,
- a.prototype.add = function(e, i) {
- return this._data[e] !== void 0 ? !1 : (this._data[e] = i,
- ++this._count,
- !0)
- }
- ,
- a.prototype.set = function(e, i) {
- return this._data[e] === void 0 ? !1 : (this._data[e] = i,
- !0)
- }
- ,
- a.prototype.getAndRemove = function(e) {
- var i = this.get(e);
- return i !== void 0 ? (delete this._data[e],
- --this._count,
- i) : null
- }
- ,
- a.prototype.remove = function(e) {
- return this.contains(e) ? (delete this._data[e],
- --this._count,
- !0) : !1
- }
- ,
- a.prototype.clear = function() {
- this._data = {},
- this._count = 0
- }
- ,
- Object.defineProperty(a.prototype, "count", {
- get: function() {
- return this._count
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.forEach = function(e) {
- for (var i in this._data) {
- var o = this._data[i];
- e(i, o)
- }
- }
- ,
- a.prototype.first = function(e) {
- for (var i in this._data) {
- var o = this._data[i]
- , s = e(i, o);
- if (s)
- return s
- }
- return null
- }
- ,
- a
- }()
- , AbstractScene = function() {
- function a() {
- this.rootNodes = new Array,
- this.cameras = new Array,
- this.lights = new Array,
- this.meshes = new Array,
- this.skeletons = new Array,
- this.particleSystems = new Array,
- this.animations = [],
- this.animationGroups = new Array,
- this.multiMaterials = new Array,
- this.materials = new Array,
- this.morphTargetManagers = new Array,
- this.geometries = new Array,
- this.transformNodes = new Array,
- this.actionManagers = new Array,
- this.textures = new Array,
- this._environmentTexture = null,
- this.postProcesses = new Array
- }
- return a.AddParser = function(e, i) {
- this._BabylonFileParsers[e] = i
- }
- ,
- a.GetParser = function(e) {
- return this._BabylonFileParsers[e] ? this._BabylonFileParsers[e] : null
- }
- ,
- a.AddIndividualParser = function(e, i) {
- this._IndividualBabylonFileParsers[e] = i
- }
- ,
- a.GetIndividualParser = function(e) {
- return this._IndividualBabylonFileParsers[e] ? this._IndividualBabylonFileParsers[e] : null
- }
- ,
- a.Parse = function(e, i, o, s) {
- for (var c in this._BabylonFileParsers)
- this._BabylonFileParsers.hasOwnProperty(c) && this._BabylonFileParsers[c](e, i, o, s)
- }
- ,
- Object.defineProperty(a.prototype, "environmentTexture", {
- get: function() {
- return this._environmentTexture
- },
- set: function(e) {
- this._environmentTexture = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.getNodes = function() {
- var e = new Array;
- return e = e.concat(this.meshes),
- e = e.concat(this.lights),
- e = e.concat(this.cameras),
- e = e.concat(this.transformNodes),
- this.skeletons.forEach(function(i) {
- return e = e.concat(i.bones)
- }),
- e
- }
- ,
- a._BabylonFileParsers = {},
- a._IndividualBabylonFileParsers = {},
- a
- }()
- , MaterialDefines = function() {
- function a() {
- this._isDirty = !0,
- this._areLightsDirty = !0,
- this._areLightsDisposed = !1,
- this._areAttributesDirty = !0,
- this._areTexturesDirty = !0,
- this._areFresnelDirty = !0,
- this._areMiscDirty = !0,
- this._arePrePassDirty = !0,
- this._areImageProcessingDirty = !0,
- this._normals = !1,
- this._uvs = !1,
- this._needNormals = !1,
- this._needUVs = !1
- }
- return Object.defineProperty(a.prototype, "isDirty", {
- get: function() {
- return this._isDirty
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.markAsProcessed = function() {
- this._isDirty = !1,
- this._areAttributesDirty = !1,
- this._areTexturesDirty = !1,
- this._areFresnelDirty = !1,
- this._areLightsDirty = !1,
- this._areLightsDisposed = !1,
- this._areMiscDirty = !1,
- this._arePrePassDirty = !1,
- this._areImageProcessingDirty = !1
- }
- ,
- a.prototype.markAsUnprocessed = function() {
- this._isDirty = !0
- }
- ,
- a.prototype.markAllAsDirty = function() {
- this._areTexturesDirty = !0,
- this._areAttributesDirty = !0,
- this._areLightsDirty = !0,
- this._areFresnelDirty = !0,
- this._areMiscDirty = !0,
- this._areImageProcessingDirty = !0,
- this._isDirty = !0
- }
- ,
- a.prototype.markAsImageProcessingDirty = function() {
- this._areImageProcessingDirty = !0,
- this._isDirty = !0
- }
- ,
- a.prototype.markAsLightDirty = function(e) {
- e === void 0 && (e = !1),
- this._areLightsDirty = !0,
- this._areLightsDisposed = this._areLightsDisposed || e,
- this._isDirty = !0
- }
- ,
- a.prototype.markAsAttributesDirty = function() {
- this._areAttributesDirty = !0,
- this._isDirty = !0
- }
- ,
- a.prototype.markAsTexturesDirty = function() {
- this._areTexturesDirty = !0,
- this._isDirty = !0
- }
- ,
- a.prototype.markAsFresnelDirty = function() {
- this._areFresnelDirty = !0,
- this._isDirty = !0
- }
- ,
- a.prototype.markAsMiscDirty = function() {
- this._areMiscDirty = !0,
- this._isDirty = !0
- }
- ,
- a.prototype.markAsPrePassDirty = function() {
- this._arePrePassDirty = !0,
- this._isDirty = !0
- }
- ,
- a.prototype.rebuild = function() {
- this._keys = [];
- for (var e = 0, i = Object.keys(this); e < i.length; e++) {
- var o = i[e];
- o[0] !== "_" && this._keys.push(o)
- }
- }
- ,
- a.prototype.isEqual = function(e) {
- if (this._keys.length !== e._keys.length)
- return !1;
- for (var i = 0; i < this._keys.length; i++) {
- var o = this._keys[i];
- if (this[o] !== e[o])
- return !1
- }
- return !0
- }
- ,
- a.prototype.cloneTo = function(e) {
- this._keys.length !== e._keys.length && (e._keys = this._keys.slice(0));
- for (var i = 0; i < this._keys.length; i++) {
- var o = this._keys[i];
- e[o] = this[o]
- }
- }
- ,
- a.prototype.reset = function() {
- for (var e = 0; e < this._keys.length; e++) {
- var i = this._keys[e]
- , o = typeof this[i];
- switch (o) {
- case "number":
- this[i] = 0;
- break;
- case "string":
- this[i] = "";
- break;
- default:
- this[i] = !1;
- break
- }
- }
- }
- ,
- a.prototype.toString = function() {
- for (var e = "", i = 0; i < this._keys.length; i++) {
- var o = this._keys[i]
- , s = this[o]
- , c = typeof s;
- switch (c) {
- case "number":
- case "string":
- e += "#define " + o + " " + s + `
- `;
- break;
- default:
- s && (e += "#define " + o + `
- `);
- break
- }
- }
- return e
- }
- ,
- a
- }()
- , ColorCurves = function() {
- function a() {
- this._dirty = !0,
- this._tempColor = new Color4(0,0,0,0),
- this._globalCurve = new Color4(0,0,0,0),
- this._highlightsCurve = new Color4(0,0,0,0),
- this._midtonesCurve = new Color4(0,0,0,0),
- this._shadowsCurve = new Color4(0,0,0,0),
- this._positiveCurve = new Color4(0,0,0,0),
- this._negativeCurve = new Color4(0,0,0,0),
- this._globalHue = 30,
- this._globalDensity = 0,
- this._globalSaturation = 0,
- this._globalExposure = 0,
- this._highlightsHue = 30,
- this._highlightsDensity = 0,
- this._highlightsSaturation = 0,
- this._highlightsExposure = 0,
- this._midtonesHue = 30,
- this._midtonesDensity = 0,
- this._midtonesSaturation = 0,
- this._midtonesExposure = 0,
- this._shadowsHue = 30,
- this._shadowsDensity = 0,
- this._shadowsSaturation = 0,
- this._shadowsExposure = 0
- }
- return Object.defineProperty(a.prototype, "globalHue", {
- get: function() {
- return this._globalHue
- },
- set: function(e) {
- this._globalHue = e,
- this._dirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "globalDensity", {
- get: function() {
- return this._globalDensity
- },
- set: function(e) {
- this._globalDensity = e,
- this._dirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "globalSaturation", {
- get: function() {
- return this._globalSaturation
- },
- set: function(e) {
- this._globalSaturation = e,
- this._dirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "globalExposure", {
- get: function() {
- return this._globalExposure
- },
- set: function(e) {
- this._globalExposure = e,
- this._dirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "highlightsHue", {
- get: function() {
- return this._highlightsHue
- },
- set: function(e) {
- this._highlightsHue = e,
- this._dirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "highlightsDensity", {
- get: function() {
- return this._highlightsDensity
- },
- set: function(e) {
- this._highlightsDensity = e,
- this._dirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "highlightsSaturation", {
- get: function() {
- return this._highlightsSaturation
- },
- set: function(e) {
- this._highlightsSaturation = e,
- this._dirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "highlightsExposure", {
- get: function() {
- return this._highlightsExposure
- },
- set: function(e) {
- this._highlightsExposure = e,
- this._dirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "midtonesHue", {
- get: function() {
- return this._midtonesHue
- },
- set: function(e) {
- this._midtonesHue = e,
- this._dirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "midtonesDensity", {
- get: function() {
- return this._midtonesDensity
- },
- set: function(e) {
- this._midtonesDensity = e,
- this._dirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "midtonesSaturation", {
- get: function() {
- return this._midtonesSaturation
- },
- set: function(e) {
- this._midtonesSaturation = e,
- this._dirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "midtonesExposure", {
- get: function() {
- return this._midtonesExposure
- },
- set: function(e) {
- this._midtonesExposure = e,
- this._dirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "shadowsHue", {
- get: function() {
- return this._shadowsHue
- },
- set: function(e) {
- this._shadowsHue = e,
- this._dirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "shadowsDensity", {
- get: function() {
- return this._shadowsDensity
- },
- set: function(e) {
- this._shadowsDensity = e,
- this._dirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "shadowsSaturation", {
- get: function() {
- return this._shadowsSaturation
- },
- set: function(e) {
- this._shadowsSaturation = e,
- this._dirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "shadowsExposure", {
- get: function() {
- return this._shadowsExposure
- },
- set: function(e) {
- this._shadowsExposure = e,
- this._dirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.getClassName = function() {
- return "ColorCurves"
- }
- ,
- a.Bind = function(e, i, o, s, c) {
- o === void 0 && (o = "vCameraColorCurvePositive"),
- s === void 0 && (s = "vCameraColorCurveNeutral"),
- c === void 0 && (c = "vCameraColorCurveNegative"),
- e._dirty && (e._dirty = !1,
- e.getColorGradingDataToRef(e._globalHue, e._globalDensity, e._globalSaturation, e._globalExposure, e._globalCurve),
- e.getColorGradingDataToRef(e._highlightsHue, e._highlightsDensity, e._highlightsSaturation, e._highlightsExposure, e._tempColor),
- e._tempColor.multiplyToRef(e._globalCurve, e._highlightsCurve),
- e.getColorGradingDataToRef(e._midtonesHue, e._midtonesDensity, e._midtonesSaturation, e._midtonesExposure, e._tempColor),
- e._tempColor.multiplyToRef(e._globalCurve, e._midtonesCurve),
- e.getColorGradingDataToRef(e._shadowsHue, e._shadowsDensity, e._shadowsSaturation, e._shadowsExposure, e._tempColor),
- e._tempColor.multiplyToRef(e._globalCurve, e._shadowsCurve),
- e._highlightsCurve.subtractToRef(e._midtonesCurve, e._positiveCurve),
- e._midtonesCurve.subtractToRef(e._shadowsCurve, e._negativeCurve)),
- i && (i.setFloat4(o, e._positiveCurve.r, e._positiveCurve.g, e._positiveCurve.b, e._positiveCurve.a),
- i.setFloat4(s, e._midtonesCurve.r, e._midtonesCurve.g, e._midtonesCurve.b, e._midtonesCurve.a),
- i.setFloat4(c, e._negativeCurve.r, e._negativeCurve.g, e._negativeCurve.b, e._negativeCurve.a))
- }
- ,
- a.PrepareUniforms = function(e) {
- e.push("vCameraColorCurveNeutral", "vCameraColorCurvePositive", "vCameraColorCurveNegative")
- }
- ,
- a.prototype.getColorGradingDataToRef = function(e, i, o, s, c) {
- e != null && (e = a.clamp(e, 0, 360),
- i = a.clamp(i, -100, 100),
- o = a.clamp(o, -100, 100),
- s = a.clamp(s, -100, 100),
- i = a.applyColorGradingSliderNonlinear(i),
- i *= .5,
- s = a.applyColorGradingSliderNonlinear(s),
- i < 0 && (i *= -1,
- e = (e + 180) % 360),
- a.fromHSBToRef(e, i, 50 + .25 * s, c),
- c.scaleToRef(2, c),
- c.a = 1 + .01 * o)
- }
- ,
- a.applyColorGradingSliderNonlinear = function(e) {
- e /= 100;
- var i = Math.abs(e);
- return i = Math.pow(i, 2),
- e < 0 && (i *= -1),
- i *= 100,
- i
- }
- ,
- a.fromHSBToRef = function(e, i, o, s) {
- var c = a.clamp(e, 0, 360)
- , d = a.clamp(i / 100, 0, 1)
- , _ = a.clamp(o / 100, 0, 1);
- if (d === 0)
- s.r = _,
- s.g = _,
- s.b = _;
- else {
- c /= 60;
- var b = Math.floor(c)
- , k = c - b
- , j = _ * (1 - d)
- , $ = _ * (1 - d * k)
- , _e = _ * (1 - d * (1 - k));
- switch (b) {
- case 0:
- s.r = _,
- s.g = _e,
- s.b = j;
- break;
- case 1:
- s.r = $,
- s.g = _,
- s.b = j;
- break;
- case 2:
- s.r = j,
- s.g = _,
- s.b = _e;
- break;
- case 3:
- s.r = j,
- s.g = $,
- s.b = _;
- break;
- case 4:
- s.r = _e,
- s.g = j,
- s.b = _;
- break;
- default:
- s.r = _,
- s.g = j,
- s.b = $;
- break
- }
- }
- s.a = 1
- }
- ,
- a.clamp = function(e, i, o) {
- return Math.min(Math.max(e, i), o)
- }
- ,
- a.prototype.clone = function() {
- return SerializationHelper.Clone(function() {
- return new a
- }, this)
- }
- ,
- a.prototype.serialize = function() {
- return SerializationHelper.Serialize(this)
- }
- ,
- a.Parse = function(e) {
- return SerializationHelper.Parse(function() {
- return new a
- }, e, null, null)
- }
- ,
- __decorate([serialize()], a.prototype, "_globalHue", void 0),
- __decorate([serialize()], a.prototype, "_globalDensity", void 0),
- __decorate([serialize()], a.prototype, "_globalSaturation", void 0),
- __decorate([serialize()], a.prototype, "_globalExposure", void 0),
- __decorate([serialize()], a.prototype, "_highlightsHue", void 0),
- __decorate([serialize()], a.prototype, "_highlightsDensity", void 0),
- __decorate([serialize()], a.prototype, "_highlightsSaturation", void 0),
- __decorate([serialize()], a.prototype, "_highlightsExposure", void 0),
- __decorate([serialize()], a.prototype, "_midtonesHue", void 0),
- __decorate([serialize()], a.prototype, "_midtonesDensity", void 0),
- __decorate([serialize()], a.prototype, "_midtonesSaturation", void 0),
- __decorate([serialize()], a.prototype, "_midtonesExposure", void 0),
- a
- }();
- SerializationHelper._ColorCurvesParser = ColorCurves.Parse;
- var ImageProcessingConfigurationDefines = function(a) {
- __extends(e, a);
- function e() {
- var i = a.call(this) || this;
- return i.IMAGEPROCESSING = !1,
- i.VIGNETTE = !1,
- i.VIGNETTEBLENDMODEMULTIPLY = !1,
- i.VIGNETTEBLENDMODEOPAQUE = !1,
- i.TONEMAPPING = !1,
- i.TONEMAPPING_ACES = !1,
- i.CONTRAST = !1,
- i.COLORCURVES = !1,
- i.COLORGRADING = !1,
- i.COLORGRADING3D = !1,
- i.SAMPLER3DGREENDEPTH = !1,
- i.SAMPLER3DBGRMAP = !1,
- i.IMAGEPROCESSINGPOSTPROCESS = !1,
- i.EXPOSURE = !1,
- i.SKIPFINALCOLORCLAMP = !1,
- i.rebuild(),
- i
- }
- return e
- }(MaterialDefines)
- , ImageProcessingConfiguration = function() {
- function a() {
- this.colorCurves = new ColorCurves,
- this._colorCurvesEnabled = !1,
- this._colorGradingEnabled = !1,
- this._colorGradingWithGreenDepth = !0,
- this._colorGradingBGR = !0,
- this._exposure = 1,
- this._toneMappingEnabled = !1,
- this._toneMappingType = a.TONEMAPPING_STANDARD,
- this._contrast = 1,
- this.vignetteStretch = 0,
- this.vignetteCentreX = 0,
- this.vignetteCentreY = 0,
- this.vignetteWeight = 1.5,
- this.vignetteColor = new Color4(0,0,0,0),
- this.vignetteCameraFov = .5,
- this._vignetteBlendMode = a.VIGNETTEMODE_MULTIPLY,
- this._vignetteEnabled = !1,
- this._skipFinalColorClamp = !1,
- this._applyByPostProcess = !1,
- this._isEnabled = !0,
- this.onUpdateParameters = new Observable
- }
- return Object.defineProperty(a.prototype, "colorCurvesEnabled", {
- get: function() {
- return this._colorCurvesEnabled
- },
- set: function(e) {
- this._colorCurvesEnabled !== e && (this._colorCurvesEnabled = e,
- this._updateParameters())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "colorGradingTexture", {
- get: function() {
- return this._colorGradingTexture
- },
- set: function(e) {
- this._colorGradingTexture !== e && (this._colorGradingTexture = e,
- this._updateParameters())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "colorGradingEnabled", {
- get: function() {
- return this._colorGradingEnabled
- },
- set: function(e) {
- this._colorGradingEnabled !== e && (this._colorGradingEnabled = e,
- this._updateParameters())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "colorGradingWithGreenDepth", {
- get: function() {
- return this._colorGradingWithGreenDepth
- },
- set: function(e) {
- this._colorGradingWithGreenDepth !== e && (this._colorGradingWithGreenDepth = e,
- this._updateParameters())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "colorGradingBGR", {
- get: function() {
- return this._colorGradingBGR
- },
- set: function(e) {
- this._colorGradingBGR !== e && (this._colorGradingBGR = e,
- this._updateParameters())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "exposure", {
- get: function() {
- return this._exposure
- },
- set: function(e) {
- this._exposure !== e && (this._exposure = e,
- this._updateParameters())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "toneMappingEnabled", {
- get: function() {
- return this._toneMappingEnabled
- },
- set: function(e) {
- this._toneMappingEnabled !== e && (this._toneMappingEnabled = e,
- this._updateParameters())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "toneMappingType", {
- get: function() {
- return this._toneMappingType
- },
- set: function(e) {
- this._toneMappingType !== e && (this._toneMappingType = e,
- this._updateParameters())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "contrast", {
- get: function() {
- return this._contrast
- },
- set: function(e) {
- this._contrast !== e && (this._contrast = e,
- this._updateParameters())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "vignetteBlendMode", {
- get: function() {
- return this._vignetteBlendMode
- },
- set: function(e) {
- this._vignetteBlendMode !== e && (this._vignetteBlendMode = e,
- this._updateParameters())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "vignetteEnabled", {
- get: function() {
- return this._vignetteEnabled
- },
- set: function(e) {
- this._vignetteEnabled !== e && (this._vignetteEnabled = e,
- this._updateParameters())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "skipFinalColorClamp", {
- get: function() {
- return this._skipFinalColorClamp
- },
- set: function(e) {
- this._skipFinalColorClamp !== e && (this._skipFinalColorClamp = e,
- this._updateParameters())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "applyByPostProcess", {
- get: function() {
- return this._applyByPostProcess
- },
- set: function(e) {
- this._applyByPostProcess !== e && (this._applyByPostProcess = e,
- this._updateParameters())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "isEnabled", {
- get: function() {
- return this._isEnabled
- },
- set: function(e) {
- this._isEnabled !== e && (this._isEnabled = e,
- this._updateParameters())
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._updateParameters = function() {
- this.onUpdateParameters.notifyObservers(this)
- }
- ,
- a.prototype.getClassName = function() {
- return "ImageProcessingConfiguration"
- }
- ,
- a.PrepareUniforms = function(e, i) {
- i.EXPOSURE && e.push("exposureLinear"),
- i.CONTRAST && e.push("contrast"),
- i.COLORGRADING && e.push("colorTransformSettings"),
- i.VIGNETTE && (e.push("vInverseScreenSize"),
- e.push("vignetteSettings1"),
- e.push("vignetteSettings2")),
- i.COLORCURVES && ColorCurves.PrepareUniforms(e)
- }
- ,
- a.PrepareSamplers = function(e, i) {
- i.COLORGRADING && e.push("txColorTransform")
- }
- ,
- a.prototype.prepareDefines = function(e, i) {
- if (i === void 0 && (i = !1),
- i !== this.applyByPostProcess || !this._isEnabled) {
- e.VIGNETTE = !1,
- e.TONEMAPPING = !1,
- e.TONEMAPPING_ACES = !1,
- e.CONTRAST = !1,
- e.EXPOSURE = !1,
- e.COLORCURVES = !1,
- e.COLORGRADING = !1,
- e.COLORGRADING3D = !1,
- e.IMAGEPROCESSING = !1,
- e.SKIPFINALCOLORCLAMP = this.skipFinalColorClamp,
- e.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess && this._isEnabled;
- return
- }
- switch (e.VIGNETTE = this.vignetteEnabled,
- e.VIGNETTEBLENDMODEMULTIPLY = this.vignetteBlendMode === a._VIGNETTEMODE_MULTIPLY,
- e.VIGNETTEBLENDMODEOPAQUE = !e.VIGNETTEBLENDMODEMULTIPLY,
- e.TONEMAPPING = this.toneMappingEnabled,
- this._toneMappingType) {
- case a.TONEMAPPING_ACES:
- e.TONEMAPPING_ACES = !0;
- break;
- default:
- e.TONEMAPPING_ACES = !1;
- break
- }
- e.CONTRAST = this.contrast !== 1,
- e.EXPOSURE = this.exposure !== 1,
- e.COLORCURVES = this.colorCurvesEnabled && !!this.colorCurves,
- e.COLORGRADING = this.colorGradingEnabled && !!this.colorGradingTexture,
- e.COLORGRADING ? e.COLORGRADING3D = this.colorGradingTexture.is3D : e.COLORGRADING3D = !1,
- e.SAMPLER3DGREENDEPTH = this.colorGradingWithGreenDepth,
- e.SAMPLER3DBGRMAP = this.colorGradingBGR,
- e.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess,
- e.SKIPFINALCOLORCLAMP = this.skipFinalColorClamp,
- e.IMAGEPROCESSING = e.VIGNETTE || e.TONEMAPPING || e.CONTRAST || e.EXPOSURE || e.COLORCURVES || e.COLORGRADING
- }
- ,
- a.prototype.isReady = function() {
- return !this.colorGradingEnabled || !this.colorGradingTexture || this.colorGradingTexture.isReady()
- }
- ,
- a.prototype.bind = function(e, i) {
- if (this._colorCurvesEnabled && this.colorCurves && ColorCurves.Bind(this.colorCurves, e),
- this._vignetteEnabled) {
- var o = 1 / e.getEngine().getRenderWidth()
- , s = 1 / e.getEngine().getRenderHeight();
- e.setFloat2("vInverseScreenSize", o, s);
- var c = i != null ? i : s / o
- , d = Math.tan(this.vignetteCameraFov * .5)
- , _ = d * c
- , b = Math.sqrt(_ * d);
- _ = Tools.Mix(_, b, this.vignetteStretch),
- d = Tools.Mix(d, b, this.vignetteStretch),
- e.setFloat4("vignetteSettings1", _, d, -_ * this.vignetteCentreX, -d * this.vignetteCentreY);
- var k = -2 * this.vignetteWeight;
- e.setFloat4("vignetteSettings2", this.vignetteColor.r, this.vignetteColor.g, this.vignetteColor.b, k)
- }
- if (e.setFloat("exposureLinear", this.exposure),
- e.setFloat("contrast", this.contrast),
- this.colorGradingTexture) {
- e.setTexture("txColorTransform", this.colorGradingTexture);
- var j = this.colorGradingTexture.getSize().height;
- e.setFloat4("colorTransformSettings", (j - 1) / j, .5 / j, j, this.colorGradingTexture.level)
- }
- }
- ,
- a.prototype.clone = function() {
- return SerializationHelper.Clone(function() {
- return new a
- }, this)
- }
- ,
- a.prototype.serialize = function() {
- return SerializationHelper.Serialize(this)
- }
- ,
- a.Parse = function(e) {
- return SerializationHelper.Parse(function() {
- return new a
- }, e, null, null)
- }
- ,
- Object.defineProperty(a, "VIGNETTEMODE_MULTIPLY", {
- get: function() {
- return this._VIGNETTEMODE_MULTIPLY
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "VIGNETTEMODE_OPAQUE", {
- get: function() {
- return this._VIGNETTEMODE_OPAQUE
- },
- enumerable: !1,
- configurable: !0
- }),
- a.TONEMAPPING_STANDARD = 0,
- a.TONEMAPPING_ACES = 1,
- a._VIGNETTEMODE_MULTIPLY = 0,
- a._VIGNETTEMODE_OPAQUE = 1,
- __decorate([serializeAsColorCurves()], a.prototype, "colorCurves", void 0),
- __decorate([serialize()], a.prototype, "_colorCurvesEnabled", void 0),
- __decorate([serializeAsTexture("colorGradingTexture")], a.prototype, "_colorGradingTexture", void 0),
- __decorate([serialize()], a.prototype, "_colorGradingEnabled", void 0),
- __decorate([serialize()], a.prototype, "_colorGradingWithGreenDepth", void 0),
- __decorate([serialize()], a.prototype, "_colorGradingBGR", void 0),
- __decorate([serialize()], a.prototype, "_exposure", void 0),
- __decorate([serialize()], a.prototype, "_toneMappingEnabled", void 0),
- __decorate([serialize()], a.prototype, "_toneMappingType", void 0),
- __decorate([serialize()], a.prototype, "_contrast", void 0),
- __decorate([serialize()], a.prototype, "vignetteStretch", void 0),
- __decorate([serialize()], a.prototype, "vignetteCentreX", void 0),
- __decorate([serialize()], a.prototype, "vignetteCentreY", void 0),
- __decorate([serialize()], a.prototype, "vignetteWeight", void 0),
- __decorate([serializeAsColor4()], a.prototype, "vignetteColor", void 0),
- __decorate([serialize()], a.prototype, "vignetteCameraFov", void 0),
- __decorate([serialize()], a.prototype, "_vignetteBlendMode", void 0),
- __decorate([serialize()], a.prototype, "_vignetteEnabled", void 0),
- __decorate([serialize()], a.prototype, "_skipFinalColorClamp", void 0),
- __decorate([serialize()], a.prototype, "_applyByPostProcess", void 0),
- __decorate([serialize()], a.prototype, "_isEnabled", void 0),
- a
- }();
- SerializationHelper._ImageProcessingConfigurationParser = ImageProcessingConfiguration.Parse;
- var ActionEvent = function() {
- function a(e, i, o, s, c, d) {
- this.source = e,
- this.pointerX = i,
- this.pointerY = o,
- this.meshUnderPointer = s,
- this.sourceEvent = c,
- this.additionalData = d
- }
- return a.CreateNew = function(e, i, o) {
- var s = e.getScene();
- return new a(e,s.pointerX,s.pointerY,s.meshUnderPointer || e,i,o)
- }
- ,
- a.CreateNewFromSprite = function(e, i, o, s) {
- return new a(e,i.pointerX,i.pointerY,i.meshUnderPointer,o,s)
- }
- ,
- a.CreateNewFromScene = function(e, i) {
- return new a(null,e.pointerX,e.pointerY,e.meshUnderPointer,i)
- }
- ,
- a.CreateNewFromPrimitive = function(e, i, o, s) {
- return new a(e,i.x,i.y,null,o,s)
- }
- ,
- a
- }(), PostProcessManager = function() {
- function a(e) {
- this._vertexBuffers = {},
- this._scene = e
- }
- return a.prototype._prepareBuffers = function() {
- if (!this._vertexBuffers[VertexBuffer.PositionKind]) {
- var e = [];
- e.push(1, 1),
- e.push(-1, 1),
- e.push(-1, -1),
- e.push(1, -1),
- this._vertexBuffers[VertexBuffer.PositionKind] = new VertexBuffer(this._scene.getEngine(),e,VertexBuffer.PositionKind,!1,!1,2),
- this._buildIndexBuffer()
- }
- }
- ,
- a.prototype._buildIndexBuffer = function() {
- var e = [];
- e.push(0),
- e.push(1),
- e.push(2),
- e.push(0),
- e.push(2),
- e.push(3),
- this._indexBuffer = this._scene.getEngine().createIndexBuffer(e)
- }
- ,
- a.prototype._rebuild = function() {
- var e = this._vertexBuffers[VertexBuffer.PositionKind];
- !e || (e._rebuild(),
- this._buildIndexBuffer())
- }
- ,
- a.prototype._prepareFrame = function(e, i) {
- e === void 0 && (e = null),
- i === void 0 && (i = null);
- var o = this._scene.activeCamera;
- return !o || (i = i || o._postProcesses.filter(function(s) {
- return s != null
- }),
- !i || i.length === 0 || !this._scene.postProcessesEnabled) ? !1 : (i[0].activate(o, e, i != null),
- !0)
- }
- ,
- a.prototype.directRender = function(e, i, o, s, c, d) {
- var _;
- i === void 0 && (i = null),
- o === void 0 && (o = !1),
- s === void 0 && (s = 0),
- c === void 0 && (c = 0),
- d === void 0 && (d = !1);
- for (var b = this._scene.getEngine(), k = 0; k < e.length; k++) {
- 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(),
- (_ = b._debugInsertMarker) === null || _ === void 0 || _.call(b, "post process " + e[k].name + " output"));
- var j = e[k]
- , $ = j.apply();
- $ && (j.onBeforeRenderObservable.notifyObservers($),
- this._prepareBuffers(),
- b.bindBuffers(this._vertexBuffers, this._indexBuffer, $),
- b.drawElementsType(0, 0, 6),
- j.onAfterRenderObservable.notifyObservers($))
- }
- b.setDepthBuffer(!0),
- b.setDepthWrite(!0)
- }
- ,
- a.prototype._finalizeFrame = function(e, i, o, s, c) {
- var d;
- c === void 0 && (c = !1);
- var _ = this._scene.activeCamera;
- if (!!_ && (s = s || _._postProcesses.filter(function(et) {
- return et != null
- }),
- !(s.length === 0 || !this._scene.postProcessesEnabled))) {
- for (var b = this._scene.getEngine(), k = 0, j = s.length; k < j; k++) {
- var $ = s[k];
- 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),
- $._outputTexture = i) : (b.restoreDefaultFramebuffer(),
- $._outputTexture = null),
- (d = b._debugInsertMarker) === null || d === void 0 || d.call(b, "post process " + s[k].name + " output")),
- e)
- break;
- var _e = $.apply();
- _e && ($.onBeforeRenderObservable.notifyObservers(_e),
- this._prepareBuffers(),
- b.bindBuffers(this._vertexBuffers, this._indexBuffer, _e),
- b.drawElementsType(0, 0, 6),
- $.onAfterRenderObservable.notifyObservers(_e))
- }
- b.setDepthBuffer(!0),
- b.setDepthWrite(!0),
- b.setAlphaMode(0)
- }
- }
- ,
- a.prototype.dispose = function() {
- var e = this._vertexBuffers[VertexBuffer.PositionKind];
- e && (e.dispose(),
- this._vertexBuffers[VertexBuffer.PositionKind] = null),
- this._indexBuffer && (this._scene.getEngine()._releaseBuffer(this._indexBuffer),
- this._indexBuffer = null)
- }
- ,
- a
- }(), RenderingGroup = function() {
- function a(e, i, o, s, c) {
- o === void 0 && (o = null),
- s === void 0 && (s = null),
- c === void 0 && (c = null),
- this.index = e,
- this._opaqueSubMeshes = new SmartArray(256),
- this._transparentSubMeshes = new SmartArray(256),
- this._alphaTestSubMeshes = new SmartArray(256),
- this._depthOnlySubMeshes = new SmartArray(256),
- this._particleSystems = new SmartArray(256),
- this._spriteManagers = new SmartArray(256),
- this._edgesRenderers = new SmartArrayNoDuplicate(16),
- this._scene = i,
- this.opaqueSortCompareFn = o,
- this.alphaTestSortCompareFn = s,
- this.transparentSortCompareFn = c
- }
- return Object.defineProperty(a.prototype, "opaqueSortCompareFn", {
- set: function(e) {
- this._opaqueSortCompareFn = e,
- e ? this._renderOpaque = this.renderOpaqueSorted : this._renderOpaque = a.renderUnsorted
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "alphaTestSortCompareFn", {
- set: function(e) {
- this._alphaTestSortCompareFn = e,
- e ? this._renderAlphaTest = this.renderAlphaTestSorted : this._renderAlphaTest = a.renderUnsorted
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "transparentSortCompareFn", {
- set: function(e) {
- e ? this._transparentSortCompareFn = e : this._transparentSortCompareFn = a.defaultTransparentSortCompare,
- this._renderTransparent = this.renderTransparentSorted
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.render = function(e, i, o, s) {
- if (e) {
- e(this._opaqueSubMeshes, this._alphaTestSubMeshes, this._transparentSubMeshes, this._depthOnlySubMeshes);
- return
- }
- var c = this._scene.getEngine();
- this._depthOnlySubMeshes.length !== 0 && (c.setColorWrite(!1),
- this._renderAlphaTest(this._depthOnlySubMeshes),
- c.setColorWrite(!0)),
- this._opaqueSubMeshes.length !== 0 && this._renderOpaque(this._opaqueSubMeshes),
- this._alphaTestSubMeshes.length !== 0 && this._renderAlphaTest(this._alphaTestSubMeshes);
- var d = c.getStencilBuffer();
- if (c.setStencilBuffer(!1),
- i && this._renderSprites(),
- o && this._renderParticles(s),
- this.onBeforeTransparentRendering && this.onBeforeTransparentRendering(),
- (this._transparentSubMeshes.length !== 0 || this._scene.useOrderIndependentTransparency) && (c.setStencilBuffer(d),
- this._scene.useOrderIndependentTransparency ? this._scene.depthPeelingRenderer.render(this._transparentSubMeshes) : this._renderTransparent(this._transparentSubMeshes),
- c.setAlphaMode(0)),
- c.setStencilBuffer(!1),
- this._edgesRenderers.length) {
- for (var _ = 0; _ < this._edgesRenderers.length; _++)
- this._edgesRenderers.data[_].render();
- c.setAlphaMode(0)
- }
- c.setStencilBuffer(d)
- }
- ,
- a.prototype.renderOpaqueSorted = function(e) {
- return a.renderSorted(e, this._opaqueSortCompareFn, this._scene.activeCamera, !1)
- }
- ,
- a.prototype.renderAlphaTestSorted = function(e) {
- return a.renderSorted(e, this._alphaTestSortCompareFn, this._scene.activeCamera, !1)
- }
- ,
- a.prototype.renderTransparentSorted = function(e) {
- return a.renderSorted(e, this._transparentSortCompareFn, this._scene.activeCamera, !0)
- }
- ,
- a.renderSorted = function(e, i, o, s) {
- for (var c = 0, d, _ = o ? o.globalPosition : a._zeroVector; c < e.length; c++)
- d = e.data[c],
- d._alphaIndex = d.getMesh().alphaIndex,
- d._distanceToCamera = Vector3.Distance(d.getBoundingInfo().boundingSphere.centerWorld, _);
- var b = e.data.slice(0, e.length);
- for (i && b.sort(i),
- c = 0; c < b.length; c++) {
- if (d = b[c],
- s) {
- var k = d.getMaterial();
- if (k && k.needDepthPrePass) {
- var j = k.getScene().getEngine();
- j.setColorWrite(!1),
- j.setAlphaMode(0),
- d.render(!1),
- j.setColorWrite(!0)
- }
- }
- d.render(s)
- }
- }
- ,
- a.renderUnsorted = function(e) {
- for (var i = 0; i < e.length; i++) {
- var o = e.data[i];
- o.render(!1)
- }
- }
- ,
- a.defaultTransparentSortCompare = function(e, i) {
- return e._alphaIndex > i._alphaIndex ? 1 : e._alphaIndex < i._alphaIndex ? -1 : a.backToFrontSortCompare(e, i)
- }
- ,
- a.backToFrontSortCompare = function(e, i) {
- return e._distanceToCamera < i._distanceToCamera ? 1 : e._distanceToCamera > i._distanceToCamera ? -1 : 0
- }
- ,
- a.frontToBackSortCompare = function(e, i) {
- return e._distanceToCamera < i._distanceToCamera ? -1 : e._distanceToCamera > i._distanceToCamera ? 1 : 0
- }
- ,
- a.prototype.prepare = function() {
- this._opaqueSubMeshes.reset(),
- this._transparentSubMeshes.reset(),
- this._alphaTestSubMeshes.reset(),
- this._depthOnlySubMeshes.reset(),
- this._particleSystems.reset(),
- this._spriteManagers.reset(),
- this._edgesRenderers.reset()
- }
- ,
- a.prototype.dispose = function() {
- this._opaqueSubMeshes.dispose(),
- this._transparentSubMeshes.dispose(),
- this._alphaTestSubMeshes.dispose(),
- this._depthOnlySubMeshes.dispose(),
- this._particleSystems.dispose(),
- this._spriteManagers.dispose(),
- this._edgesRenderers.dispose()
- }
- ,
- a.prototype.dispatch = function(e, i, o) {
- i === void 0 && (i = e.getMesh()),
- o === void 0 && (o = e.getMaterial()),
- o != null && (o.needAlphaBlendingForMesh(i) ? this._transparentSubMeshes.push(e) : o.needAlphaTesting() ? (o.needDepthPrePass && this._depthOnlySubMeshes.push(e),
- this._alphaTestSubMeshes.push(e)) : (o.needDepthPrePass && this._depthOnlySubMeshes.push(e),
- this._opaqueSubMeshes.push(e)),
- i._renderingGroup = this,
- i._edgesRenderer && i._edgesRenderer.isEnabled && this._edgesRenderers.pushNoDuplicate(i._edgesRenderer))
- }
- ,
- a.prototype.dispatchSprites = function(e) {
- this._spriteManagers.push(e)
- }
- ,
- a.prototype.dispatchParticles = function(e) {
- this._particleSystems.push(e)
- }
- ,
- a.prototype._renderParticles = function(e) {
- if (this._particleSystems.length !== 0) {
- var i = this._scene.activeCamera;
- this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);
- for (var o = 0; o < this._particleSystems.length; o++) {
- var s = this._particleSystems.data[o];
- if ((i && i.layerMask & s.layerMask) !== 0) {
- var c = s.emitter;
- (!c.position || !e || e.indexOf(c) !== -1) && this._scene._activeParticles.addCount(s.render(), !1)
- }
- }
- this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene)
- }
- }
- ,
- a.prototype._renderSprites = function() {
- if (!(!this._scene.spritesEnabled || this._spriteManagers.length === 0)) {
- var e = this._scene.activeCamera;
- this._scene.onBeforeSpritesRenderingObservable.notifyObservers(this._scene);
- for (var i = 0; i < this._spriteManagers.length; i++) {
- var o = this._spriteManagers.data[i];
- (e && e.layerMask & o.layerMask) !== 0 && o.render()
- }
- this._scene.onAfterSpritesRenderingObservable.notifyObservers(this._scene)
- }
- }
- ,
- a._zeroVector = Vector3.Zero(),
- a
- }(), RenderingGroupInfo = function() {
- function a() {}
- return a
- }(), RenderingManager = function() {
- function a(e) {
- this._useSceneAutoClearSetup = !1,
- this._renderingGroups = new Array,
- this._autoClearDepthStencil = {},
- this._customOpaqueSortCompareFn = {},
- this._customAlphaTestSortCompareFn = {},
- this._customTransparentSortCompareFn = {},
- this._renderingGroupInfo = new RenderingGroupInfo,
- this._scene = e;
- for (var i = a.MIN_RENDERINGGROUPS; i < a.MAX_RENDERINGGROUPS; i++)
- this._autoClearDepthStencil[i] = {
- autoClear: !0,
- depth: !0,
- stencil: !0
- }
- }
- return a.prototype._clearDepthStencilBuffer = function(e, i) {
- e === void 0 && (e = !0),
- i === void 0 && (i = !0),
- !this._depthStencilBufferAlreadyCleaned && (this._scene.getEngine().clear(null, !1, e, i),
- this._depthStencilBufferAlreadyCleaned = !0)
- }
- ,
- a.prototype.render = function(e, i, o, s) {
- var c = this._renderingGroupInfo;
- if (c.scene = this._scene,
- c.camera = this._scene.activeCamera,
- this._scene.spriteManagers && s)
- for (var d = 0; d < this._scene.spriteManagers.length; d++) {
- var _ = this._scene.spriteManagers[d];
- this.dispatchSprites(_)
- }
- for (var d = a.MIN_RENDERINGGROUPS; d < a.MAX_RENDERINGGROUPS; d++) {
- this._depthStencilBufferAlreadyCleaned = d === a.MIN_RENDERINGGROUPS;
- var b = this._renderingGroups[d];
- if (!!b) {
- var k = Math.pow(2, d);
- if (c.renderingGroupId = d,
- this._scene.onBeforeRenderingGroupObservable.notifyObservers(c, k),
- a.AUTOCLEAR) {
- var j = this._useSceneAutoClearSetup ? this._scene.getAutoClearDepthStencilSetup(d) : this._autoClearDepthStencil[d];
- j && j.autoClear && this._clearDepthStencilBuffer(j.depth, j.stencil)
- }
- for (var $ = 0, _e = this._scene._beforeRenderingGroupDrawStage; $ < _e.length; $++) {
- var et = _e[$];
- et.action(d)
- }
- b.render(e, s, o, i);
- for (var tt = 0, rt = this._scene._afterRenderingGroupDrawStage; tt < rt.length; tt++) {
- var et = rt[tt];
- et.action(d)
- }
- this._scene.onAfterRenderingGroupObservable.notifyObservers(c, k)
- }
- }
- }
- ,
- a.prototype.reset = function() {
- for (var e = a.MIN_RENDERINGGROUPS; e < a.MAX_RENDERINGGROUPS; e++) {
- var i = this._renderingGroups[e];
- i && i.prepare()
- }
- }
- ,
- a.prototype.dispose = function() {
- this.freeRenderingGroups(),
- this._renderingGroups.length = 0,
- this._renderingGroupInfo = null
- }
- ,
- a.prototype.freeRenderingGroups = function() {
- for (var e = a.MIN_RENDERINGGROUPS; e < a.MAX_RENDERINGGROUPS; e++) {
- var i = this._renderingGroups[e];
- i && i.dispose()
- }
- }
- ,
- a.prototype._prepareRenderingGroup = function(e) {
- this._renderingGroups[e] === void 0 && (this._renderingGroups[e] = new RenderingGroup(e,this._scene,this._customOpaqueSortCompareFn[e],this._customAlphaTestSortCompareFn[e],this._customTransparentSortCompareFn[e]))
- }
- ,
- a.prototype.dispatchSprites = function(e) {
- var i = e.renderingGroupId || 0;
- this._prepareRenderingGroup(i),
- this._renderingGroups[i].dispatchSprites(e)
- }
- ,
- a.prototype.dispatchParticles = function(e) {
- var i = e.renderingGroupId || 0;
- this._prepareRenderingGroup(i),
- this._renderingGroups[i].dispatchParticles(e)
- }
- ,
- a.prototype.dispatch = function(e, i, o) {
- i === void 0 && (i = e.getMesh());
- var s = i.renderingGroupId || 0;
- this._prepareRenderingGroup(s),
- this._renderingGroups[s].dispatch(e, i, o)
- }
- ,
- a.prototype.setRenderingOrder = function(e, i, o, s) {
- if (i === void 0 && (i = null),
- o === void 0 && (o = null),
- s === void 0 && (s = null),
- this._customOpaqueSortCompareFn[e] = i,
- this._customAlphaTestSortCompareFn[e] = o,
- this._customTransparentSortCompareFn[e] = s,
- this._renderingGroups[e]) {
- var c = this._renderingGroups[e];
- c.opaqueSortCompareFn = this._customOpaqueSortCompareFn[e],
- c.alphaTestSortCompareFn = this._customAlphaTestSortCompareFn[e],
- c.transparentSortCompareFn = this._customTransparentSortCompareFn[e]
- }
- }
- ,
- a.prototype.setRenderingAutoClearDepthStencil = function(e, i, o, s) {
- o === void 0 && (o = !0),
- s === void 0 && (s = !0),
- this._autoClearDepthStencil[e] = {
- autoClear: i,
- depth: o,
- stencil: s
- }
- }
- ,
- a.prototype.getAutoClearDepthStencilSetup = function(e) {
- return this._autoClearDepthStencil[e]
- }
- ,
- a.MAX_RENDERINGGROUPS = 4,
- a.MIN_RENDERINGGROUPS = 0,
- a.AUTOCLEAR = !0,
- a
- }(), SceneComponentConstants = function() {
- function a() {}
- return a.NAME_EFFECTLAYER = "EffectLayer",
- a.NAME_LAYER = "Layer",
- a.NAME_LENSFLARESYSTEM = "LensFlareSystem",
- a.NAME_BOUNDINGBOXRENDERER = "BoundingBoxRenderer",
- a.NAME_PARTICLESYSTEM = "ParticleSystem",
- a.NAME_GAMEPAD = "Gamepad",
- a.NAME_SIMPLIFICATIONQUEUE = "SimplificationQueue",
- a.NAME_GEOMETRYBUFFERRENDERER = "GeometryBufferRenderer",
- a.NAME_PREPASSRENDERER = "PrePassRenderer",
- a.NAME_DEPTHRENDERER = "DepthRenderer",
- a.NAME_DEPTHPEELINGRENDERER = "DepthPeelingRenderer",
- a.NAME_POSTPROCESSRENDERPIPELINEMANAGER = "PostProcessRenderPipelineManager",
- a.NAME_SPRITE = "Sprite",
- a.NAME_SUBSURFACE = "SubSurface",
- a.NAME_OUTLINERENDERER = "Outline",
- a.NAME_PROCEDURALTEXTURE = "ProceduralTexture",
- a.NAME_SHADOWGENERATOR = "ShadowGenerator",
- a.NAME_OCTREE = "Octree",
- a.NAME_PHYSICSENGINE = "PhysicsEngine",
- a.NAME_AUDIO = "Audio",
- a.STEP_ISREADYFORMESH_EFFECTLAYER = 0,
- a.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER = 0,
- a.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER = 0,
- a.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER = 0,
- a.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER = 1,
- a.STEP_BEFORECAMERADRAW_PREPASS = 0,
- a.STEP_BEFORECAMERADRAW_EFFECTLAYER = 1,
- a.STEP_BEFORECAMERADRAW_LAYER = 2,
- a.STEP_BEFORERENDERTARGETDRAW_PREPASS = 0,
- a.STEP_BEFORERENDERTARGETDRAW_LAYER = 1,
- a.STEP_BEFORERENDERINGMESH_PREPASS = 0,
- a.STEP_BEFORERENDERINGMESH_OUTLINE = 1,
- a.STEP_AFTERRENDERINGMESH_PREPASS = 0,
- a.STEP_AFTERRENDERINGMESH_OUTLINE = 1,
- a.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW = 0,
- a.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER = 1,
- a.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE = 0,
- a.STEP_BEFORECAMERAUPDATE_GAMEPAD = 1,
- a.STEP_BEFORECLEAR_PROCEDURALTEXTURE = 0,
- a.STEP_AFTERRENDERTARGETDRAW_PREPASS = 0,
- a.STEP_AFTERRENDERTARGETDRAW_LAYER = 1,
- a.STEP_AFTERCAMERADRAW_PREPASS = 0,
- a.STEP_AFTERCAMERADRAW_EFFECTLAYER = 1,
- a.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM = 2,
- a.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW = 3,
- a.STEP_AFTERCAMERADRAW_LAYER = 4,
- a.STEP_AFTERRENDER_AUDIO = 0,
- a.STEP_GATHERRENDERTARGETS_DEPTHRENDERER = 0,
- a.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER = 1,
- a.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR = 2,
- a.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER = 3,
- a.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER = 0,
- a.STEP_BEFORECLEARSTAGE_PREPASS = 0,
- a.STEP_BEFORERENDERTARGETCLEARSTAGE_PREPASS = 0,
- a.STEP_POINTERMOVE_SPRITE = 0,
- a.STEP_POINTERDOWN_SPRITE = 0,
- a.STEP_POINTERUP_SPRITE = 0,
- a
- }(), Stage = function(a) {
- __extends(e, a);
- function e(i) {
- return a.apply(this, i) || this
- }
- return e.Create = function() {
- return Object.create(e.prototype)
- }
- ,
- e.prototype.registerStep = function(i, o, s) {
- for (var c = 0, d = Number.MAX_VALUE; c < this.length; c++) {
- var _ = this[c];
- if (d = _.index,
- i < d)
- break
- }
- this.splice(c, 0, {
- index: i,
- component: o,
- action: s.bind(o)
- })
- }
- ,
- e.prototype.clear = function() {
- this.length = 0
- }
- ,
- e
- }(Array), PointerEventTypes = function() {
- function a() {}
- return a.POINTERDOWN = 1,
- a.POINTERUP = 2,
- a.POINTERMOVE = 4,
- a.POINTERWHEEL = 8,
- a.POINTERPICK = 16,
- a.POINTERTAP = 32,
- a.POINTERDOUBLETAP = 64,
- a
- }(), PointerInfoBase = function() {
- function a(e, i) {
- this.type = e,
- this.event = i
- }
- return a
- }(), PointerInfoPre = function(a) {
- __extends(e, a);
- function e(i, o, s, c) {
- var d = a.call(this, i, o) || this;
- return d.ray = null,
- d.skipOnPointerObservable = !1,
- d.localPosition = new Vector2(s,c),
- d
- }
- return e
- }(PointerInfoBase), PointerInfo = function(a) {
- __extends(e, a);
- function e(i, o, s) {
- var c = a.call(this, i, o) || this;
- return c.pickInfo = s,
- c
- }
- return e
- }(PointerInfoBase), AbstractActionManager = function() {
- function a() {
- this.hoverCursor = "",
- this.actions = new Array,
- this.isRecursive = !1
- }
- return Object.defineProperty(a, "HasTriggers", {
- get: function() {
- for (var e in a.Triggers)
- if (a.Triggers.hasOwnProperty(e))
- return !0;
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "HasPickTriggers", {
- get: function() {
- for (var e in a.Triggers)
- if (a.Triggers.hasOwnProperty(e)) {
- var i = parseInt(e);
- if (i >= 1 && i <= 7)
- return !0
- }
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- a.HasSpecificTrigger = function(e) {
- for (var i in a.Triggers)
- if (a.Triggers.hasOwnProperty(i)) {
- var o = parseInt(i);
- if (o === e)
- return !0
- }
- return !1
- }
- ,
- a.Triggers = {},
- a
- }(), KeyboardEventTypes = function() {
- function a() {}
- return a.KEYDOWN = 1,
- a.KEYUP = 2,
- a
- }(), KeyboardInfo = function() {
- function a(e, i) {
- this.type = e,
- this.event = i
- }
- return a
- }(), KeyboardInfoPre = function(a) {
- __extends(e, a);
- function e(i, o) {
- var s = a.call(this, i, o) || this;
- return s.type = i,
- s.event = o,
- s.skipOnPointerObservable = !1,
- s
- }
- return e
- }(KeyboardInfo), DeviceType;
- (function(a) {
- a[a.Generic = 0] = "Generic",
- a[a.Keyboard = 1] = "Keyboard",
- a[a.Mouse = 2] = "Mouse",
- a[a.Touch = 3] = "Touch",
- a[a.DualShock = 4] = "DualShock",
- a[a.Xbox = 5] = "Xbox",
- a[a.Switch = 6] = "Switch"
- }
- )(DeviceType || (DeviceType = {}));
- var PointerInput;
- (function(a) {
- a[a.Horizontal = 0] = "Horizontal",
- a[a.Vertical = 1] = "Vertical",
- a[a.LeftClick = 2] = "LeftClick",
- a[a.MiddleClick = 3] = "MiddleClick",
- a[a.RightClick = 4] = "RightClick",
- a[a.BrowserBack = 5] = "BrowserBack",
- a[a.BrowserForward = 6] = "BrowserForward",
- a[a.MouseWheelX = 7] = "MouseWheelX",
- a[a.MouseWheelY = 8] = "MouseWheelY",
- a[a.MouseWheelZ = 9] = "MouseWheelZ",
- a[a.DeltaHorizontal = 10] = "DeltaHorizontal",
- a[a.DeltaVertical = 11] = "DeltaVertical"
- }
- )(PointerInput || (PointerInput = {}));
- var DualShockInput;
- (function(a) {
- a[a.Cross = 0] = "Cross",
- a[a.Circle = 1] = "Circle",
- a[a.Square = 2] = "Square",
- a[a.Triangle = 3] = "Triangle",
- a[a.L1 = 4] = "L1",
- a[a.R1 = 5] = "R1",
- a[a.L2 = 6] = "L2",
- a[a.R2 = 7] = "R2",
- a[a.Share = 8] = "Share",
- a[a.Options = 9] = "Options",
- a[a.L3 = 10] = "L3",
- a[a.R3 = 11] = "R3",
- a[a.DPadUp = 12] = "DPadUp",
- a[a.DPadDown = 13] = "DPadDown",
- a[a.DPadLeft = 14] = "DPadLeft",
- a[a.DPadRight = 15] = "DPadRight",
- a[a.Home = 16] = "Home",
- a[a.TouchPad = 17] = "TouchPad",
- a[a.LStickXAxis = 18] = "LStickXAxis",
- a[a.LStickYAxis = 19] = "LStickYAxis",
- a[a.RStickXAxis = 20] = "RStickXAxis",
- a[a.RStickYAxis = 21] = "RStickYAxis"
- }
- )(DualShockInput || (DualShockInput = {}));
- var XboxInput;
- (function(a) {
- a[a.A = 0] = "A",
- a[a.B = 1] = "B",
- a[a.X = 2] = "X",
- a[a.Y = 3] = "Y",
- a[a.LB = 4] = "LB",
- a[a.RB = 5] = "RB",
- a[a.LT = 6] = "LT",
- a[a.RT = 7] = "RT",
- a[a.Back = 8] = "Back",
- a[a.Start = 9] = "Start",
- a[a.LS = 10] = "LS",
- a[a.RS = 11] = "RS",
- a[a.DPadUp = 12] = "DPadUp",
- a[a.DPadDown = 13] = "DPadDown",
- a[a.DPadLeft = 14] = "DPadLeft",
- a[a.DPadRight = 15] = "DPadRight",
- a[a.Home = 16] = "Home",
- a[a.LStickXAxis = 17] = "LStickXAxis",
- a[a.LStickYAxis = 18] = "LStickYAxis",
- a[a.RStickXAxis = 19] = "RStickXAxis",
- a[a.RStickYAxis = 20] = "RStickYAxis"
- }
- )(XboxInput || (XboxInput = {}));
- var SwitchInput;
- (function(a) {
- a[a.B = 0] = "B",
- a[a.A = 1] = "A",
- a[a.Y = 2] = "Y",
- a[a.X = 3] = "X",
- a[a.L = 4] = "L",
- a[a.R = 5] = "R",
- a[a.ZL = 6] = "ZL",
- a[a.ZR = 7] = "ZR",
- a[a.Minus = 8] = "Minus",
- a[a.Plus = 9] = "Plus",
- a[a.LS = 10] = "LS",
- a[a.RS = 11] = "RS",
- a[a.DPadUp = 12] = "DPadUp",
- a[a.DPadDown = 13] = "DPadDown",
- a[a.DPadLeft = 14] = "DPadLeft",
- a[a.DPadRight = 15] = "DPadRight",
- a[a.Home = 16] = "Home",
- a[a.Capture = 17] = "Capture",
- a[a.LStickXAxis = 18] = "LStickXAxis",
- a[a.LStickYAxis = 19] = "LStickYAxis",
- a[a.RStickXAxis = 20] = "RStickXAxis",
- a[a.RStickYAxis = 21] = "RStickYAxis"
- }
- )(SwitchInput || (SwitchInput = {}));
- var DeviceInputEventType;
- (function(a) {
- a[a.PointerMove = 0] = "PointerMove",
- a[a.PointerDown = 1] = "PointerDown",
- a[a.PointerUp = 2] = "PointerUp"
- }
- )(DeviceInputEventType || (DeviceInputEventType = {}));
- var EventConstants = function() {
- function a() {}
- return a.DOM_DELTA_PIXEL = 0,
- a.DOM_DELTA_LINE = 1,
- a.DOM_DELTA_PAGE = 2,
- a
- }()
- , DeviceEventFactory = function() {
- function a() {}
- return a.CreateDeviceEvent = function(e, i, o, s, c, d) {
- switch (e) {
- case DeviceType.Keyboard:
- return this._createKeyboardEvent(o, s, c, d);
- case DeviceType.Mouse:
- if (o === PointerInput.MouseWheelX || o === PointerInput.MouseWheelY || o === PointerInput.MouseWheelZ)
- return this._createWheelEvent(e, i, o, s, c, d);
- case DeviceType.Touch:
- return this._createPointerEvent(e, i, o, s, c, d);
- default:
- throw "Unable to generate event for device " + DeviceType[e]
- }
- }
- ,
- a._createPointerEvent = function(e, i, o, s, c, d) {
- var _ = this._createMouseEvent(e, i, o, s, c, d);
- return _.pointerId = e === DeviceType.Mouse ? 1 : i,
- 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",
- _.button = o - 2),
- _
- }
- ,
- a._createWheelEvent = function(e, i, o, s, c, d) {
- var _ = this._createMouseEvent(e, i, o, s, c, d);
- return _.type = "wheel",
- _.deltaMode = EventConstants.DOM_DELTA_PIXEL,
- _.deltaX = o === PointerInput.MouseWheelX ? s : c.pollInput(e, i, PointerInput.MouseWheelX),
- _.deltaY = o === PointerInput.MouseWheelY ? s : c.pollInput(e, i, PointerInput.MouseWheelY),
- _.deltaZ = o === PointerInput.MouseWheelZ ? s : c.pollInput(e, i, PointerInput.MouseWheelZ),
- _
- }
- ,
- a._createMouseEvent = function(e, i, o, s, c, d) {
- var _ = this._createEvent(d)
- , b = c.pollInput(e, i, PointerInput.Horizontal)
- , k = c.pollInput(e, i, PointerInput.Vertical)
- , j = o === PointerInput.DeltaHorizontal ? s : 0
- , $ = o === PointerInput.DeltaVertical ? s : 0
- , _e = o === PointerInput.DeltaHorizontal && d ? j - d.getBoundingClientRect().x : 0
- , et = o === PointerInput.DeltaVertical && d ? $ - d.getBoundingClientRect().y : 0;
- return this._checkNonCharacterKeys(_, c),
- _.clientX = b,
- _.clientY = k,
- _.movementX = j,
- _.movementY = $,
- _.offsetX = _e,
- _.offsetY = et,
- _.x = b,
- _.y = k,
- _
- }
- ,
- a._createKeyboardEvent = function(e, i, o, s) {
- var c = this._createEvent(s);
- return this._checkNonCharacterKeys(c, o),
- c.type = i === 1 ? "keydown" : "keyup",
- c.key = String.fromCharCode(e),
- c.keyCode = e,
- c
- }
- ,
- a._checkNonCharacterKeys = function(e, i) {
- var o = i.isDeviceAvailable(DeviceType.Keyboard)
- , s = o && i.pollInput(DeviceType.Keyboard, 0, 18) === 1
- , c = o && i.pollInput(DeviceType.Keyboard, 0, 17) === 1
- , d = o && (i.pollInput(DeviceType.Keyboard, 0, 91) === 1 || i.pollInput(DeviceType.Keyboard, 0, 92) === 1 || i.pollInput(DeviceType.Keyboard, 0, 93) === 1)
- , _ = o && i.pollInput(DeviceType.Keyboard, 0, 16) === 1;
- e.altKey = s,
- e.ctrlKey = c,
- e.metaKey = d,
- e.shiftKey = _
- }
- ,
- a._createEvent = function(e) {
- var i = {};
- return i.preventDefault = function() {}
- ,
- i.target = e,
- i
- }
- ,
- a
- }()
- , NativeDeviceInputSystemImpl = function() {
- function a(e) {
- var i = this;
- this.onDeviceConnected = function(o, s) {}
- ,
- this.onDeviceDisconnected = function(o, s) {}
- ,
- this.onInputChanged = function(o) {}
- ,
- this._nativeInput = e || this._createDummyNativeInput(),
- this._nativeInput.onDeviceConnected = function(o, s) {
- i.onDeviceConnected(o, s)
- }
- ,
- this._nativeInput.onDeviceDisconnected = function(o, s) {
- i.onDeviceDisconnected(o, s)
- }
- ,
- this._nativeInput.onInputChanged = function(o, s, c, d, _, b) {
- var k = DeviceEventFactory.CreateDeviceEvent(o, s, c, _, i)
- , j = k;
- j.deviceType = o,
- j.deviceSlot = s,
- j.inputIndex = c,
- j.previousState = d,
- j.currentState = _,
- i.onInputChanged(j)
- }
- }
- return a.prototype.configureEvents = function() {}
- ,
- a.prototype.pollInput = function(e, i, o) {
- return this._nativeInput.pollInput(e, i, o)
- }
- ,
- a.prototype.isDeviceAvailable = function(e) {
- return e === DeviceType.Mouse || e === DeviceType.Touch
- }
- ,
- a.prototype.dispose = function() {
- this.onDeviceConnected = function() {}
- ,
- this.onDeviceDisconnected = function() {}
- ,
- this.onInputChanged = function() {}
- }
- ,
- a.prototype._createDummyNativeInput = function() {
- var e = {
- onDeviceConnected: function(i, o) {},
- onDeviceDisconnected: function(i, o) {},
- onInputChanged: function(i, o, s, c, d, _) {},
- pollInput: function() {
- return 0
- },
- isDeviceAvailable: function() {
- return !1
- },
- dispose: function() {}
- };
- return e
- }
- ,
- a
- }()
- , WebDeviceInputSystemImpl = function() {
- function a(e) {
- this._inputs = [],
- this._keyboardActive = !1,
- this._pointerActive = !1,
- this._usingSafari = Tools.IsSafari(),
- this._keyboardDownEvent = function(i) {}
- ,
- this._keyboardUpEvent = function(i) {}
- ,
- this._keyboardBlurEvent = function(i) {}
- ,
- this._pointerMoveEvent = function(i) {}
- ,
- this._pointerDownEvent = function(i) {}
- ,
- this._pointerUpEvent = function(i) {}
- ,
- this._pointerWheelEvent = function(i) {}
- ,
- this._pointerBlurEvent = function(i) {}
- ,
- this._mouseId = -1,
- this._isUsingFirefox = navigator && navigator.userAgent && navigator.userAgent.indexOf("Firefox") !== -1,
- this._activeTouchIds = [],
- this._rollingTouchId = 0,
- this._pointerInputClearObserver = null,
- this._gamepadConnectedEvent = function(i) {}
- ,
- this._gamepadDisconnectedEvent = function(i) {}
- ,
- this._eventPrefix = Tools.GetPointerPrefix(e),
- this._engine = e,
- this.onDeviceConnected = function(i, o) {}
- ,
- this.onDeviceDisconnected = function(i, o) {}
- ,
- this.onInputChanged = function(i) {}
- ,
- this.configureEvents()
- }
- return Object.defineProperty(a.prototype, "onDeviceConnected", {
- get: function() {
- return this._onDeviceConnected
- },
- set: function(e) {
- this._onDeviceConnected = e;
- for (var i = 0; i < this._inputs.length; i++) {
- var o = this._inputs[i];
- if (o)
- for (var s in o) {
- var c = +s;
- this._inputs[i][c] && this._onDeviceConnected(i, c)
- }
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.configureEvents = function() {
- var e = this._engine.getInputElement();
- e && this._elementToAttachTo !== e && (this._elementToAttachTo && this._removeEvents(),
- this._elementToAttachTo = e,
- this._elementToAttachTo.tabIndex = this._elementToAttachTo.tabIndex !== -1 ? this._elementToAttachTo.tabIndex : this._engine.canvasTabIndex,
- this._handleKeyActions(),
- this._handlePointerActions(),
- this._handleGamepadActions(),
- this._checkForConnectedDevices())
- }
- ,
- a.prototype.pollInput = function(e, i, o) {
- var s = this._inputs[e][i];
- if (!s)
- throw "Unable to find device " + DeviceType[e];
- e >= DeviceType.Xbox && e <= DeviceType.Switch && navigator.getGamepads && this._updateDevice(e, i, o);
- var c = s[o];
- if (c === void 0)
- throw "Unable to find input " + o + " for device " + DeviceType[e] + " in slot " + i;
- return c
- }
- ,
- a.prototype.isDeviceAvailable = function(e) {
- return this._inputs[e] !== void 0
- }
- ,
- a.prototype.dispose = function() {
- this.onDeviceConnected = function() {}
- ,
- this.onDeviceDisconnected = function() {}
- ,
- this.onInputChanged = function() {}
- ,
- this._elementToAttachTo && (this._removeEvents(),
- window.removeEventListener("gamepadconnected", this._gamepadConnectedEvent),
- window.removeEventListener("gamepaddisconnected", this._gamepadDisconnectedEvent))
- }
- ,
- a.prototype._checkForConnectedDevices = function() {
- if (navigator.getGamepads)
- for (var e = navigator.getGamepads(), i = 0, o = e; i < o.length; i++) {
- var s = o[i];
- s && this._addGamePad(s)
- }
- matchMedia("(pointer:fine)").matches && this._addPointerDevice(DeviceType.Mouse, 0, 0, 0)
- }
- ,
- a.prototype._addGamePad = function(e) {
- var i = this._getGamepadDeviceType(e.id)
- , o = e.index;
- this._registerDevice(i, o, e.buttons.length + e.axes.length),
- this._gamepads = this._gamepads || new Array(e.index + 1),
- this._gamepads[o] = i
- }
- ,
- a.prototype._addPointerDevice = function(e, i, o, s) {
- this._pointerActive = !0,
- this._registerDevice(e, i, a.MAX_POINTER_INPUTS);
- var c = this._inputs[e][i];
- c[0] = o,
- c[1] = s
- }
- ,
- a.prototype._registerDevice = function(e, i, o) {
- if (i === void 0)
- throw "Unable to register device " + DeviceType[e] + " to undefined slot.";
- if (this._inputs[e] || (this._inputs[e] = {}),
- !this._inputs[e][i]) {
- for (var s = new Array(o), c = 0; c < o; c++)
- s[c] = 0;
- this._inputs[e][i] = s,
- this.onDeviceConnected(e, i)
- }
- }
- ,
- a.prototype._unregisterDevice = function(e, i) {
- this._inputs[e][i] && (delete this._inputs[e][i],
- this.onDeviceDisconnected(e, i))
- }
- ,
- a.prototype._handleKeyActions = function() {
- var e = this;
- this._keyboardDownEvent = function(i) {
- e._keyboardActive || (e._keyboardActive = !0,
- e._registerDevice(DeviceType.Keyboard, 0, a.MAX_KEYCODES));
- var o = e._inputs[DeviceType.Keyboard][0];
- if (o) {
- o[i.keyCode] = 1;
- var s = i;
- s.deviceType = DeviceType.Keyboard,
- s.deviceSlot = 0,
- s.inputIndex = i.keyCode,
- s.previousState = 0,
- s.currentState = o[i.keyCode],
- e.onInputChanged(s)
- }
- }
- ,
- this._keyboardUpEvent = function(i) {
- e._keyboardActive || (e._keyboardActive = !0,
- e._registerDevice(DeviceType.Keyboard, 0, a.MAX_KEYCODES));
- var o = e._inputs[DeviceType.Keyboard][0];
- if (o) {
- o[i.keyCode] = 0;
- var s = i;
- s.deviceType = DeviceType.Keyboard,
- s.deviceSlot = 0,
- s.inputIndex = i.keyCode,
- s.previousState = 1,
- s.currentState = o[i.keyCode],
- e.onInputChanged(s)
- }
- }
- ,
- this._keyboardBlurEvent = function(i) {
- if (e._keyboardActive) {
- for (var o = e._inputs[DeviceType.Keyboard][0], s = 0; s < o.length; s++)
- if (o[s] !== 0) {
- o[s] = 0;
- var c = DeviceEventFactory.CreateDeviceEvent(DeviceType.Keyboard, 0, s, 1, e, e._elementToAttachTo)
- , d = c;
- d.deviceType = DeviceType.Keyboard,
- d.deviceSlot = 0,
- d.inputIndex = s,
- d.currentState = 0,
- d.previousState = 1,
- e.onInputChanged(d)
- }
- }
- }
- ,
- this._elementToAttachTo.addEventListener("keydown", this._keyboardDownEvent),
- this._elementToAttachTo.addEventListener("keyup", this._keyboardUpEvent),
- this._elementToAttachTo.addEventListener("blur", this._keyboardBlurEvent)
- }
- ,
- a.prototype._handlePointerActions = function() {
- var e = this;
- this._pointerMoveEvent = function(c) {
- var d = e._getPointerType(c)
- , _ = d === DeviceType.Mouse ? 0 : e._activeTouchIds.indexOf(c.pointerId);
- e._inputs[d] || (e._inputs[d] = {}),
- e._inputs[d][_] || e._addPointerDevice(d, _, c.clientX, c.clientY);
- var b = e._inputs[d][_];
- if (b) {
- var k = b[PointerInput.Horizontal]
- , j = b[PointerInput.Vertical]
- , $ = b[PointerInput.DeltaHorizontal]
- , _e = b[PointerInput.DeltaVertical];
- b[PointerInput.Horizontal] = c.clientX,
- b[PointerInput.Vertical] = c.clientY,
- b[PointerInput.DeltaHorizontal] = c.movementX,
- b[PointerInput.DeltaVertical] = c.movementY;
- var et = c;
- et.deviceType = d,
- et.deviceSlot = _,
- k !== c.clientX && (et.inputIndex = PointerInput.Horizontal,
- et.previousState = k,
- et.currentState = b[PointerInput.Horizontal],
- e.onInputChanged(et)),
- j !== c.clientY && (et.inputIndex = PointerInput.Vertical,
- et.previousState = j,
- et.currentState = b[PointerInput.Vertical],
- e.onInputChanged(et)),
- b[PointerInput.DeltaHorizontal] !== 0 && (et.inputIndex = PointerInput.DeltaHorizontal,
- et.previousState = $,
- et.currentState = b[PointerInput.DeltaHorizontal],
- e.onInputChanged(et)),
- b[PointerInput.DeltaVertical] !== 0 && (et.inputIndex = PointerInput.DeltaVertical,
- et.previousState = _e,
- et.currentState = b[PointerInput.DeltaVertical],
- e.onInputChanged(et)),
- !e._usingSafari && c.button !== -1 && (et.inputIndex = c.button + 2,
- et.previousState = b[c.button + 2],
- b[c.button + 2] = b[c.button + 2] ? 0 : 1,
- et.currentState = b[c.button + 2],
- e.onInputChanged(et))
- }
- }
- ,
- this._pointerDownEvent = function(c) {
- var d = e._getPointerType(c)
- , _ = d === DeviceType.Mouse ? 0 : c.pointerId;
- d === DeviceType.Touch && (_ = e._rollingTouchId++,
- e._activeTouchIds[_] = c.pointerId),
- e._inputs[d] || (e._inputs[d] = {}),
- e._inputs[d][_] || e._addPointerDevice(d, _, c.clientX, c.clientY);
- var b = e._inputs[d][_];
- if (b) {
- var k = b[PointerInput.Horizontal]
- , j = b[PointerInput.Vertical]
- , $ = b[c.button + 2];
- if (d === DeviceType.Mouse) {
- if (e._mouseId === -1 && (c.pointerId === void 0 ? e._mouseId = e._isUsingFirefox ? 0 : 1 : e._mouseId = c.pointerId),
- !document.pointerLockElement && e._elementToAttachTo.hasPointerCapture)
- try {
- e._elementToAttachTo.setPointerCapture(e._mouseId)
- } catch {}
- } else if (c.pointerId && !document.pointerLockElement && e._elementToAttachTo.hasPointerCapture)
- try {
- e._elementToAttachTo.setPointerCapture(c.pointerId)
- } catch {}
- b[PointerInput.Horizontal] = c.clientX,
- b[PointerInput.Vertical] = c.clientY,
- b[c.button + 2] = 1;
- var _e = c;
- _e.deviceType = d,
- _e.deviceSlot = _,
- k !== c.clientX && (_e.inputIndex = PointerInput.Horizontal,
- _e.previousState = k,
- _e.currentState = b[PointerInput.Horizontal],
- e.onInputChanged(_e)),
- j !== c.clientY && (_e.inputIndex = PointerInput.Vertical,
- _e.previousState = j,
- _e.currentState = b[PointerInput.Vertical],
- e.onInputChanged(_e)),
- _e.inputIndex = c.button + 2,
- _e.previousState = $,
- _e.currentState = b[c.button + 2],
- e.onInputChanged(_e)
- }
- }
- ,
- this._pointerUpEvent = function(c) {
- 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];
- if (et && et[c.button + 2] !== 0) {
- var tt = et[PointerInput.Horizontal]
- , rt = et[PointerInput.Vertical]
- , it = et[c.button + 2];
- et[PointerInput.Horizontal] = c.clientX,
- et[PointerInput.Vertical] = c.clientY,
- et[c.button + 2] = 0;
- var nt = c;
- if (nt.deviceType = $,
- nt.deviceSlot = _e,
- tt !== c.clientX && (nt.inputIndex = PointerInput.Horizontal,
- nt.previousState = tt,
- nt.currentState = et[PointerInput.Horizontal],
- e.onInputChanged(nt)),
- rt !== c.clientY && (nt.inputIndex = PointerInput.Vertical,
- nt.previousState = rt,
- nt.currentState = et[PointerInput.Vertical],
- e.onInputChanged(nt)),
- nt.inputIndex = c.button + 2,
- nt.previousState = it,
- nt.currentState = et[c.button + 2],
- $ === 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),
- e.onInputChanged(nt),
- $ !== DeviceType.Mouse) {
- var ot = e._activeTouchIds.indexOf(c.pointerId);
- delete e._activeTouchIds[ot],
- e._unregisterDevice($, _e)
- }
- }
- }
- ,
- this._wheelEventName = "onwheel"in document.createElement("div") ? "wheel" : document.onmousewheel !== void 0 ? "mousewheel" : "DOMMouseScroll";
- var i = !1
- , o = function() {};
- try {
- var s = {
- passive: {
- get: function() {
- i = !0
- }
- }
- };
- this._elementToAttachTo.addEventListener("test", o, s),
- this._elementToAttachTo.removeEventListener("test", o, s)
- } catch {}
- this._pointerBlurEvent = function(c) {
- var d, _, b, k, j;
- if (e.isDeviceAvailable(DeviceType.Mouse)) {
- var $ = e._inputs[DeviceType.Mouse][0];
- e._mouseId >= 0 && ((_ = (d = e._elementToAttachTo).hasPointerCapture) === null || _ === void 0 ? void 0 : _.call(d, e._mouseId)) && e._elementToAttachTo.releasePointerCapture(e._mouseId);
- for (var _e = 0; _e <= PointerInput.BrowserForward; _e++)
- if ($[_e + 2] === 1) {
- $[_e + 2] = 0;
- var et = DeviceEventFactory.CreateDeviceEvent(DeviceType.Mouse, 0, _e + 2, 1, e, e._elementToAttachTo)
- , tt = et;
- tt.deviceType = DeviceType.Mouse,
- tt.deviceSlot = 0,
- tt.inputIndex = _e + 2,
- tt.currentState = $[_e + 2],
- tt.previousState = 1,
- e.onInputChanged(tt)
- }
- }
- if (e.isDeviceAvailable(DeviceType.Touch)) {
- var $ = e._inputs[DeviceType.Touch];
- for (var rt in Object.keys(e._activeTouchIds)) {
- var it = +rt
- , nt = e._activeTouchIds[it];
- if (!((k = (b = e._elementToAttachTo).hasPointerCapture) === null || k === void 0) && k.call(b, nt) && e._elementToAttachTo.releasePointerCapture(nt),
- ((j = $[it]) === null || j === void 0 ? void 0 : j[PointerInput.LeftClick]) === 1) {
- $[it][PointerInput.LeftClick] = 0;
- var ot = DeviceEventFactory.CreateDeviceEvent(DeviceType.Touch, nt, PointerInput.LeftClick, 1, e, e._elementToAttachTo)
- , tt = ot;
- tt.deviceType = DeviceType.Mouse,
- tt.deviceSlot = it,
- tt.inputIndex = PointerInput.LeftClick,
- tt.currentState = $[it][PointerInput.LeftClick],
- tt.previousState = 1,
- e.onInputChanged(tt),
- e._unregisterDevice(DeviceType.Touch, it)
- }
- }
- for (; e._activeTouchIds.pop() !== void 0; )
- ;
- }
- }
- ,
- this._pointerWheelEvent = function(c) {
- var d = DeviceType.Mouse
- , _ = 0;
- e._inputs[d] || (e._inputs[d] = []),
- e._inputs[d][_] || (e._pointerActive = !0,
- e._registerDevice(d, _, a.MAX_POINTER_INPUTS));
- var b = e._inputs[d][_];
- if (b) {
- var k = b[PointerInput.MouseWheelX]
- , j = b[PointerInput.MouseWheelY]
- , $ = b[PointerInput.MouseWheelZ];
- b[PointerInput.MouseWheelX] = c.deltaX || 0,
- b[PointerInput.MouseWheelY] = c.deltaY || c.wheelDelta || 0,
- b[PointerInput.MouseWheelZ] = c.deltaZ || 0;
- var _e = c;
- _e.deviceType = d,
- _e.deviceSlot = _,
- b[PointerInput.MouseWheelX] !== 0 && (_e.inputIndex = PointerInput.MouseWheelX,
- _e.previousState = k,
- _e.currentState = b[PointerInput.MouseWheelX],
- e.onInputChanged(_e)),
- b[PointerInput.MouseWheelY] !== 0 && (_e.inputIndex = PointerInput.MouseWheelY,
- _e.previousState = j,
- _e.currentState = b[PointerInput.MouseWheelY],
- e.onInputChanged(_e)),
- b[PointerInput.MouseWheelZ] !== 0 && (_e.inputIndex = PointerInput.MouseWheelZ,
- _e.previousState = $,
- _e.currentState = b[PointerInput.MouseWheelZ],
- e.onInputChanged(_e))
- }
- }
- ,
- this._elementToAttachTo.addEventListener(this._eventPrefix + "move", this._pointerMoveEvent),
- this._elementToAttachTo.addEventListener(this._eventPrefix + "down", this._pointerDownEvent),
- this._elementToAttachTo.addEventListener(this._eventPrefix + "up", this._pointerUpEvent),
- this._elementToAttachTo.addEventListener("blur", this._pointerBlurEvent),
- this._elementToAttachTo.addEventListener(this._wheelEventName, this._pointerWheelEvent, i ? {
- passive: !1
- } : !1),
- this._pointerInputClearObserver = this._engine.onEndFrameObservable.add(function() {
- if (e.isDeviceAvailable(DeviceType.Mouse)) {
- var c = e._inputs[DeviceType.Mouse][0];
- c[PointerInput.MouseWheelX] = 0,
- c[PointerInput.MouseWheelY] = 0,
- c[PointerInput.MouseWheelZ] = 0,
- c[PointerInput.DeltaHorizontal] = 0,
- c[PointerInput.DeltaVertical] = 0
- }
- })
- }
- ,
- a.prototype._handleGamepadActions = function() {
- var e = this;
- this._gamepadConnectedEvent = function(i) {
- e._addGamePad(i.gamepad)
- }
- ,
- this._gamepadDisconnectedEvent = function(i) {
- if (e._gamepads) {
- var o = e._getGamepadDeviceType(i.gamepad.id)
- , s = i.gamepad.index;
- e._unregisterDevice(o, s),
- delete e._gamepads[s]
- }
- }
- ,
- window.addEventListener("gamepadconnected", this._gamepadConnectedEvent),
- window.addEventListener("gamepaddisconnected", this._gamepadDisconnectedEvent)
- }
- ,
- a.prototype._updateDevice = function(e, i, o) {
- var s = navigator.getGamepads()[i];
- if (s && e === this._gamepads[i]) {
- var c = this._inputs[e][i];
- o >= s.buttons.length ? c[o] = s.axes[o - s.buttons.length].valueOf() : c[o] = s.buttons[o].value
- }
- }
- ,
- a.prototype._getGamepadDeviceType = function(e) {
- 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
- }
- ,
- a.prototype._getPointerType = function(e) {
- var i = DeviceType.Mouse;
- return (e.pointerType === "touch" || e.pointerType === "pen" || e.touches) && (i = DeviceType.Touch),
- i
- }
- ,
- a.prototype._removeEvents = function() {
- this._elementToAttachTo.removeEventListener("blur", this._keyboardBlurEvent),
- this._elementToAttachTo.removeEventListener("blur", this._pointerBlurEvent),
- this._keyboardActive && (this._elementToAttachTo.removeEventListener("keydown", this._keyboardDownEvent),
- this._elementToAttachTo.removeEventListener("keyup", this._keyboardUpEvent)),
- this._pointerActive && (this._elementToAttachTo.removeEventListener(this._eventPrefix + "move", this._pointerMoveEvent),
- this._elementToAttachTo.removeEventListener(this._eventPrefix + "down", this._pointerDownEvent),
- this._elementToAttachTo.removeEventListener(this._eventPrefix + "up", this._pointerUpEvent),
- this._elementToAttachTo.removeEventListener(this._wheelEventName, this._pointerWheelEvent),
- this._pointerInputClearObserver && this._engine.onEndFrameObservable.remove(this._pointerInputClearObserver))
- }
- ,
- a.MAX_KEYCODES = 255,
- a.MAX_POINTER_INPUTS = Object.keys(PointerInput).length / 2,
- a
- }()
- , DeviceInputSystem = function() {
- function a(e) {
- var i = this;
- this._deviceInputSystem = e,
- this.onDeviceConnectedObservable = new Observable,
- this.onDeviceDisconnectedObservable = new Observable,
- this.onInputChangedObservable = new Observable,
- this._deviceInputSystem.onDeviceConnected = function(o, s) {
- i.onDeviceConnectedObservable.notifyObservers({
- deviceType: o,
- deviceSlot: s
- })
- }
- ,
- this._deviceInputSystem.onDeviceDisconnected = function(o, s) {
- i.onDeviceDisconnectedObservable.notifyObservers({
- deviceType: o,
- deviceSlot: s
- })
- }
- ,
- this._deviceInputSystem.onInputChanged = function(o) {
- i.onInputChangedObservable.notifyObservers(o)
- }
- }
- return a._Create = function(e) {
- if (!e.deviceInputSystem) {
- var i = void 0;
- typeof _native != "undefined" ? i = _native.DeviceInputSystem ? new NativeDeviceInputSystemImpl(new _native.DeviceInputSystem) : new NativeDeviceInputSystemImpl : i = new WebDeviceInputSystemImpl(e),
- i && (e.deviceInputSystem = new a(i))
- }
- return e.deviceInputSystem
- }
- ,
- a.prototype.configureEvents = function() {
- this._deviceInputSystem.configureEvents()
- }
- ,
- a.prototype.pollInput = function(e, i, o) {
- return this._deviceInputSystem.pollInput(e, i, o)
- }
- ,
- a.prototype.isDeviceAvailable = function(e) {
- return this._deviceInputSystem.isDeviceAvailable(e)
- }
- ,
- a.prototype.dispose = function() {
- this.onDeviceConnectedObservable.clear(),
- this.onDeviceDisconnectedObservable.clear(),
- this.onInputChangedObservable.clear(),
- this._deviceInputSystem.dispose()
- }
- ,
- a
- }()
- , _ClickInfo = function() {
- function a() {
- this._singleClick = !1,
- this._doubleClick = !1,
- this._hasSwiped = !1,
- this._ignore = !1
- }
- return Object.defineProperty(a.prototype, "singleClick", {
- get: function() {
- return this._singleClick
- },
- set: function(e) {
- this._singleClick = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "doubleClick", {
- get: function() {
- return this._doubleClick
- },
- set: function(e) {
- this._doubleClick = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "hasSwiped", {
- get: function() {
- return this._hasSwiped
- },
- set: function(e) {
- this._hasSwiped = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "ignore", {
- get: function() {
- return this._ignore
- },
- set: function(e) {
- this._ignore = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a
- }()
- , InputManager = function() {
- function a(e) {
- this._alreadyAttached = !1,
- this._meshPickProceed = !1,
- this._currentPickResult = null,
- this._previousPickResult = null,
- this._totalPointersPressed = 0,
- this._doubleClickOccured = !1,
- this._pointerX = 0,
- this._pointerY = 0,
- this._startingPointerPosition = new Vector2(0,0),
- this._previousStartingPointerPosition = new Vector2(0,0),
- this._startingPointerTime = 0,
- this._previousStartingPointerTime = 0,
- this._pointerCaptures = {},
- this._meshUnderPointerId = {},
- this._scene = e
- }
- return Object.defineProperty(a.prototype, "meshUnderPointer", {
- get: function() {
- return this._pointerOverMesh
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.getMeshUnderPointerByPointerId = function(e) {
- return this._meshUnderPointerId[e] || null
- }
- ,
- Object.defineProperty(a.prototype, "unTranslatedPointer", {
- get: function() {
- return new Vector2(this._unTranslatedPointerX,this._unTranslatedPointerY)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "pointerX", {
- get: function() {
- return this._pointerX
- },
- set: function(e) {
- this._pointerX = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "pointerY", {
- get: function() {
- return this._pointerY
- },
- set: function(e) {
- this._pointerY = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._updatePointerPosition = function(e) {
- var i = this._scene.getEngine().getInputElementClientRect();
- !i || (this._pointerX = e.clientX - i.left,
- this._pointerY = e.clientY - i.top,
- this._unTranslatedPointerX = this._pointerX,
- this._unTranslatedPointerY = this._pointerY)
- }
- ,
- a.prototype._processPointerMove = function(e, i) {
- var o = this._scene
- , s = o.getEngine()
- , c = s.getInputElement();
- c && (c.tabIndex = s.canvasTabIndex,
- o.doNotHandleCursors || (c.style.cursor = o.defaultCursor));
- var d = !!(e && e.hit && e.pickedMesh);
- d ? (o.setPointerOverMesh(e.pickedMesh, i.pointerId, e),
- 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);
- for (var _ = 0, b = o._pointerMoveStage; _ < b.length; _++) {
- var k = b[_];
- e = k.action(this._unTranslatedPointerX, this._unTranslatedPointerY, e, d, c)
- }
- if (e) {
- var j = i.type === "wheel" || i.type === "mousewheel" || i.type === "DOMMouseScroll" ? PointerEventTypes.POINTERWHEEL : PointerEventTypes.POINTERMOVE;
- if (o.onPointerMove && o.onPointerMove(i, e, j),
- o.onPointerObservable.hasObservers()) {
- var $ = new PointerInfo(j,i,e);
- this._setRayOnPointerInfo($),
- o.onPointerObservable.notifyObservers($, j)
- }
- }
- }
- ,
- a.prototype._setRayOnPointerInfo = function(e) {
- var i = this._scene;
- e.pickInfo && !e.pickInfo._pickingUnavailable && (e.pickInfo.ray || (e.pickInfo.ray = i.createPickingRay(e.event.offsetX, e.event.offsetY, Matrix.Identity(), i.activeCamera)))
- }
- ,
- a.prototype._checkPrePointerObservable = function(e, i, o) {
- var s = this._scene
- , c = new PointerInfoPre(o,i,this._unTranslatedPointerX,this._unTranslatedPointerY);
- return e && (c.ray = e.ray,
- e.originMesh && (c.nearInteractionPickingInfo = e)),
- s.onPrePointerObservable.notifyObservers(c, o),
- !!c.skipOnPointerObservable
- }
- ,
- a.prototype.simulatePointerMove = function(e, i) {
- var o = new PointerEvent("pointermove",i);
- this._checkPrePointerObservable(e, o, PointerEventTypes.POINTERMOVE) || this._processPointerMove(e, o)
- }
- ,
- a.prototype.simulatePointerDown = function(e, i) {
- var o = new PointerEvent("pointerdown",i);
- this._checkPrePointerObservable(e, o, PointerEventTypes.POINTERDOWN) || this._processPointerDown(e, o)
- }
- ,
- a.prototype._processPointerDown = function(e, i) {
- var o = this
- , s = this._scene;
- if (e && e.hit && e.pickedMesh) {
- this._pickedDownMesh = e.pickedMesh;
- var c = e.pickedMesh._getActionManagerForTrigger();
- if (c) {
- if (c.hasPickTriggers)
- switch (c.processTrigger(5, ActionEvent.CreateNew(e.pickedMesh, i)),
- i.button) {
- case 0:
- c.processTrigger(2, ActionEvent.CreateNew(e.pickedMesh, i));
- break;
- case 1:
- c.processTrigger(4, ActionEvent.CreateNew(e.pickedMesh, i));
- break;
- case 2:
- c.processTrigger(3, ActionEvent.CreateNew(e.pickedMesh, i));
- break
- }
- c.hasSpecificTrigger(8) && window.setTimeout(function() {
- var $ = s.pick(o._unTranslatedPointerX, o._unTranslatedPointerY, function(_e) {
- return _e.isPickable && _e.isVisible && _e.isReady() && _e.actionManager && _e.actionManager.hasSpecificTrigger(8) && _e === o._pickedDownMesh
- }, !1, s.cameraToUseForPointers);
- $ && $.hit && $.pickedMesh && c && o._totalPointersPressed !== 0 && Date.now() - o._startingPointerTime > a.LongPressDelay && !o._isPointerSwiping() && (o._startingPointerTime = 0,
- c.processTrigger(8, ActionEvent.CreateNew($.pickedMesh, i)))
- }, a.LongPressDelay)
- }
- } else
- for (var d = 0, _ = s._pointerDownStage; d < _.length; d++) {
- var b = _[d];
- e = b.action(this._unTranslatedPointerX, this._unTranslatedPointerY, e, i)
- }
- if (e) {
- var k = PointerEventTypes.POINTERDOWN;
- if (s.onPointerDown && s.onPointerDown(i, e, k),
- s.onPointerObservable.hasObservers()) {
- var j = new PointerInfo(k,i,e);
- this._setRayOnPointerInfo(j),
- s.onPointerObservable.notifyObservers(j, k)
- }
- }
- }
- ,
- a.prototype._isPointerSwiping = function() {
- return Math.abs(this._startingPointerPosition.x - this._pointerX) > a.DragMovementThreshold || Math.abs(this._startingPointerPosition.y - this._pointerY) > a.DragMovementThreshold
- }
- ,
- a.prototype.simulatePointerUp = function(e, i, o) {
- var s = new PointerEvent("pointerup",i)
- , c = new _ClickInfo;
- o ? c.doubleClick = !0 : c.singleClick = !0,
- !this._checkPrePointerObservable(e, s, PointerEventTypes.POINTERUP) && this._processPointerUp(e, s, c)
- }
- ,
- a.prototype._processPointerUp = function(e, i, o) {
- var s = this._scene;
- if (e && e && e.pickedMesh) {
- if (this._pickedUpMesh = e.pickedMesh,
- this._pickedDownMesh === this._pickedUpMesh && (s.onPointerPick && s.onPointerPick(i, e),
- o.singleClick && !o.ignore && s.onPointerObservable.hasObservers())) {
- var c = PointerEventTypes.POINTERPICK
- , d = new PointerInfo(c,i,e);
- this._setRayOnPointerInfo(d),
- s.onPointerObservable.notifyObservers(d, c)
- }
- var _ = e.pickedMesh._getActionManagerForTrigger();
- if (_ && !o.ignore) {
- _.processTrigger(7, ActionEvent.CreateNew(e.pickedMesh, i, e)),
- !o.hasSwiped && o.singleClick && _.processTrigger(1, ActionEvent.CreateNew(e.pickedMesh, i, e));
- var b = e.pickedMesh._getActionManagerForTrigger(6);
- o.doubleClick && b && b.processTrigger(6, ActionEvent.CreateNew(e.pickedMesh, i, e))
- }
- } else if (!o.ignore)
- for (var k = 0, j = s._pointerUpStage; k < j.length; k++) {
- var $ = j[k];
- e = $.action(this._unTranslatedPointerX, this._unTranslatedPointerY, e, i)
- }
- if (this._pickedDownMesh && this._pickedDownMesh !== this._pickedUpMesh) {
- var _e = this._pickedDownMesh._getActionManagerForTrigger(16);
- _e && _e.processTrigger(16, ActionEvent.CreateNew(this._pickedDownMesh, i))
- }
- var et = 0;
- if (s.onPointerObservable.hasObservers()) {
- 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),
- et)) {
- var d = new PointerInfo(et,i,e);
- this._setRayOnPointerInfo(d),
- s.onPointerObservable.notifyObservers(d, et)
- }
- if (!o.ignore) {
- et = PointerEventTypes.POINTERUP;
- var d = new PointerInfo(et,i,e);
- this._setRayOnPointerInfo(d),
- s.onPointerObservable.notifyObservers(d, et)
- }
- }
- s.onPointerUp && !o.ignore && s.onPointerUp(i, e, et)
- }
- ,
- a.prototype.isPointerCaptured = function(e) {
- return e === void 0 && (e = 0),
- this._pointerCaptures[e]
- }
- ,
- a.prototype.attachControl = function(e, i, o, s) {
- var c = this;
- e === void 0 && (e = !0),
- i === void 0 && (i = !0),
- o === void 0 && (o = !0),
- s === void 0 && (s = null);
- var d = this._scene
- , _ = d.getEngine();
- s || (s = _.getInputElement()),
- this._alreadyAttached && this.detachControl(),
- s && (this._alreadyAttachedTo = s),
- this._deviceInputSystem ? this._deviceInputSystem.configureEvents() : this._deviceInputSystem = DeviceInputSystem._Create(_),
- this._initActionManager = function(b, k) {
- if (!c._meshPickProceed) {
- var j = d.pick(c._unTranslatedPointerX, c._unTranslatedPointerY, d.pointerDownPredicate, !1, d.cameraToUseForPointers);
- c._currentPickResult = j,
- j && (b = j.hit && j.pickedMesh ? j.pickedMesh._getActionManagerForTrigger() : null),
- c._meshPickProceed = !0
- }
- return b
- }
- ,
- this._delayedSimpleClick = function(b, k, j) {
- (Date.now() - c._previousStartingPointerTime > a.DoubleClickDelay && !c._doubleClickOccured || b !== c._previousButtonPressed) && (c._doubleClickOccured = !1,
- k.singleClick = !0,
- k.ignore = !1,
- j(k, c._currentPickResult))
- }
- ,
- this._initClickEvent = function(b, k, j, $) {
- var _e = new _ClickInfo;
- c._currentPickResult = null;
- var et = null
- , 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);
- !tt && AbstractActionManager && (et = c._initActionManager(et, _e),
- et && (tt = et.hasPickTriggers));
- var rt = !1;
- if (tt) {
- var it = j.button;
- if (_e.hasSwiped = c._isPointerSwiping(),
- !_e.hasSwiped) {
- var nt = !a.ExclusiveDoubleClickMode;
- nt || (nt = !b.hasSpecificMask(PointerEventTypes.POINTERDOUBLETAP) && !k.hasSpecificMask(PointerEventTypes.POINTERDOUBLETAP),
- nt && !AbstractActionManager.HasSpecificTrigger(6) && (et = c._initActionManager(et, _e),
- et && (nt = !et.hasSpecificTrigger(6)))),
- nt ? (Date.now() - c._previousStartingPointerTime > a.DoubleClickDelay || it !== c._previousButtonPressed) && (_e.singleClick = !0,
- $(_e, c._currentPickResult),
- rt = !0) : (c._previousDelayedSimpleClickTimeout = c._delayedSimpleClickTimeout,
- c._delayedSimpleClickTimeout = window.setTimeout(c._delayedSimpleClick.bind(c, it, _e, $), a.DoubleClickDelay));
- var ot = b.hasSpecificMask(PointerEventTypes.POINTERDOUBLETAP) || k.hasSpecificMask(PointerEventTypes.POINTERDOUBLETAP);
- !ot && AbstractActionManager.HasSpecificTrigger(6) && (et = c._initActionManager(et, _e),
- et && (ot = et.hasSpecificTrigger(6))),
- ot && (it === c._previousButtonPressed && Date.now() - c._previousStartingPointerTime < a.DoubleClickDelay && !c._doubleClickOccured ? (!_e.hasSwiped && !c._isPointerSwiping() ? (c._previousStartingPointerTime = 0,
- c._doubleClickOccured = !0,
- _e.doubleClick = !0,
- _e.ignore = !1,
- a.ExclusiveDoubleClickMode && c._previousDelayedSimpleClickTimeout && clearTimeout(c._previousDelayedSimpleClickTimeout),
- c._previousDelayedSimpleClickTimeout = c._delayedSimpleClickTimeout,
- $(_e, c._currentPickResult)) : (c._doubleClickOccured = !1,
- c._previousStartingPointerTime = c._startingPointerTime,
- c._previousStartingPointerPosition.x = c._startingPointerPosition.x,
- c._previousStartingPointerPosition.y = c._startingPointerPosition.y,
- c._previousButtonPressed = it,
- a.ExclusiveDoubleClickMode ? (c._previousDelayedSimpleClickTimeout && clearTimeout(c._previousDelayedSimpleClickTimeout),
- c._previousDelayedSimpleClickTimeout = c._delayedSimpleClickTimeout,
- $(_e, c._previousPickResult)) : $(_e, c._currentPickResult)),
- rt = !0) : (c._doubleClickOccured = !1,
- c._previousStartingPointerTime = c._startingPointerTime,
- c._previousStartingPointerPosition.x = c._startingPointerPosition.x,
- c._previousStartingPointerPosition.y = c._startingPointerPosition.y,
- c._previousButtonPressed = it))
- }
- }
- rt || $(_e, c._currentPickResult)
- }
- ,
- this._onPointerMove = function(b) {
- if (b.pointerId === void 0 && (b.pointerId = 0),
- c._updatePointerPosition(b),
- !c._checkPrePointerObservable(null, b, b.type === "wheel" || b.type === "mousewheel" || b.type === "DOMMouseScroll" ? PointerEventTypes.POINTERWHEEL : PointerEventTypes.POINTERMOVE) && !(!d.cameraToUseForPointers && !d.activeCamera)) {
- if (d.skipPointerMovePicking) {
- c._processPointerMove(new PickingInfo, b);
- return
- }
- d.pointerMovePredicate || (d.pointerMovePredicate = function(j) {
- return j.isPickable && j.isVisible && j.isReady() && j.isEnabled() && (j.enablePointerMoveEvents || d.constantlyUpdateMeshUnderPointer || j._getActionManagerForTrigger() !== null) && (!d.cameraToUseForPointers || (d.cameraToUseForPointers.layerMask & j.layerMask) !== 0)
- }
- );
- var k = d.pick(c._unTranslatedPointerX, c._unTranslatedPointerY, d.pointerMovePredicate, !1, d.cameraToUseForPointers, d.pointerMoveTrianglePredicate);
- c._processPointerMove(k, b)
- }
- }
- ,
- this._onPointerDown = function(b) {
- if (c._totalPointersPressed++,
- c._pickedDownMesh = null,
- c._meshPickProceed = !1,
- b.pointerId === void 0 && (b.pointerId = 0),
- c._updatePointerPosition(b),
- d.preventDefaultOnPointerDown && s && (b.preventDefault(),
- s.focus()),
- c._startingPointerPosition.x = c._pointerX,
- c._startingPointerPosition.y = c._pointerY,
- c._startingPointerTime = Date.now(),
- !c._checkPrePointerObservable(null, b, PointerEventTypes.POINTERDOWN) && !(!d.cameraToUseForPointers && !d.activeCamera)) {
- c._pointerCaptures[b.pointerId] = !0,
- d.pointerDownPredicate || (d.pointerDownPredicate = function(j) {
- return j.isPickable && j.isVisible && j.isReady() && j.isEnabled() && (!d.cameraToUseForPointers || (d.cameraToUseForPointers.layerMask & j.layerMask) !== 0)
- }
- ),
- c._pickedDownMesh = null;
- var k = d.pick(c._unTranslatedPointerX, c._unTranslatedPointerY, d.pointerDownPredicate, !1, d.cameraToUseForPointers);
- c._processPointerDown(k, b)
- }
- }
- ,
- this._onPointerUp = function(b) {
- c._totalPointersPressed !== 0 && (c._totalPointersPressed--,
- c._pickedUpMesh = null,
- c._meshPickProceed = !1,
- b.pointerId === void 0 && (b.pointerId = 0),
- c._updatePointerPosition(b),
- d.preventDefaultOnPointerUp && s && (b.preventDefault(),
- s.focus()),
- c._initClickEvent(d.onPrePointerObservable, d.onPointerObservable, b, function(k, j) {
- 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,
- !(!d.cameraToUseForPointers && !d.activeCamera) && (d.pointerUpPredicate || (d.pointerUpPredicate = function($) {
- return $.isPickable && $.isVisible && $.isReady() && $.isEnabled() && (!d.cameraToUseForPointers || (d.cameraToUseForPointers.layerMask & $.layerMask) !== 0)
- }
- ),
- !c._meshPickProceed && (AbstractActionManager && AbstractActionManager.HasTriggers || d.onPointerObservable.hasObservers()) && c._initActionManager(null, k),
- j || (j = c._currentPickResult),
- c._processPointerUp(j, b, k),
- c._previousPickResult = c._currentPickResult))
- }))
- }
- ,
- this._onKeyDown = function(b) {
- var k = KeyboardEventTypes.KEYDOWN;
- if (d.onPreKeyboardObservable.hasObservers()) {
- var j = new KeyboardInfoPre(k,b);
- if (d.onPreKeyboardObservable.notifyObservers(j, k),
- j.skipOnPointerObservable)
- return
- }
- if (d.onKeyboardObservable.hasObservers()) {
- var j = new KeyboardInfo(k,b);
- d.onKeyboardObservable.notifyObservers(j, k)
- }
- d.actionManager && d.actionManager.processTrigger(14, ActionEvent.CreateNewFromScene(d, b))
- }
- ,
- this._onKeyUp = function(b) {
- var k = KeyboardEventTypes.KEYUP;
- if (d.onPreKeyboardObservable.hasObservers()) {
- var j = new KeyboardInfoPre(k,b);
- if (d.onPreKeyboardObservable.notifyObservers(j, k),
- j.skipOnPointerObservable)
- return
- }
- if (d.onKeyboardObservable.hasObservers()) {
- var j = new KeyboardInfo(k,b);
- d.onKeyboardObservable.notifyObservers(j, k)
- }
- d.actionManager && d.actionManager.processTrigger(15, ActionEvent.CreateNewFromScene(d, b))
- }
- ,
- this._onInputObserver = this._deviceInputSystem.onInputChangedObservable.add(function(b) {
- var k = b;
- b.deviceType === DeviceType.Keyboard && (b.currentState === 1 && c._onKeyDown(k),
- b.currentState === 0 && c._onKeyUp(k)),
- (b.deviceType === DeviceType.Mouse || b.deviceType === DeviceType.Touch) && (i && b.inputIndex >= PointerInput.LeftClick && b.inputIndex <= PointerInput.RightClick && b.currentState === 1 && c._onPointerDown(k),
- e && b.inputIndex >= PointerInput.LeftClick && b.inputIndex <= PointerInput.RightClick && b.currentState === 0 && c._onPointerUp(k),
- 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))
- }),
- this._alreadyAttached = !0
- }
- ,
- a.prototype.detachControl = function() {
- this._alreadyAttached && (this._deviceInputSystem.onInputChangedObservable.remove(this._onInputObserver),
- this._alreadyAttachedTo && !this._scene.doNotHandleCursors && (this._alreadyAttachedTo.style.cursor = this._scene.defaultCursor),
- this._alreadyAttached = !1)
- }
- ,
- a.prototype.setPointerOverMesh = function(e, i, o) {
- if (i === void 0 && (i = 0),
- this._meshUnderPointerId[i] !== e) {
- var s = this._meshUnderPointerId[i], c;
- s && (c = s._getActionManagerForTrigger(10),
- c && c.processTrigger(10, ActionEvent.CreateNew(s, void 0, {
- pointerId: i
- }))),
- e ? (this._meshUnderPointerId[i] = e,
- this._pointerOverMesh = e,
- c = e._getActionManagerForTrigger(9),
- c && c.processTrigger(9, ActionEvent.CreateNew(e, void 0, {
- pointerId: i,
- pickResult: o
- }))) : (delete this._meshUnderPointerId[i],
- this._pointerOverMesh = null)
- }
- }
- ,
- a.prototype.getPointerOverMesh = function() {
- return this._pointerOverMesh
- }
- ,
- a.prototype._invalidateMesh = function(e) {
- this._pointerOverMesh === e && (this._pointerOverMesh = null),
- this._pickedDownMesh === e && (this._pickedDownMesh = null),
- this._pickedUpMesh === e && (this._pickedUpMesh = null);
- for (var i in this._meshUnderPointerId)
- this._meshUnderPointerId[i] === e && delete this._meshUnderPointerId[i]
- }
- ,
- a.DragMovementThreshold = 10,
- a.LongPressDelay = 500,
- a.DoubleClickDelay = 300,
- a.ExclusiveDoubleClickMode = !1,
- a
- }()
- , UniqueIdGenerator = function() {
- function a() {}
- return Object.defineProperty(a, "UniqueId", {
- get: function() {
- var e = this._UniqueIdCounter;
- return this._UniqueIdCounter++,
- e
- },
- enumerable: !1,
- configurable: !0
- }),
- a._UniqueIdCounter = 0,
- a
- }()
- , LightConstants = function() {
- function a() {}
- return a.CompareLightsPriority = function(e, i) {
- return e.shadowEnabled !== i.shadowEnabled ? (i.shadowEnabled ? 1 : 0) - (e.shadowEnabled ? 1 : 0) : i.renderPriority - e.renderPriority
- }
- ,
- a.FALLOFF_DEFAULT = 0,
- a.FALLOFF_PHYSICAL = 1,
- a.FALLOFF_GLTF = 2,
- a.FALLOFF_STANDARD = 3,
- a.LIGHTMAP_DEFAULT = 0,
- a.LIGHTMAP_SPECULAR = 1,
- a.LIGHTMAP_SHADOWSONLY = 2,
- a.INTENSITYMODE_AUTOMATIC = 0,
- a.INTENSITYMODE_LUMINOUSPOWER = 1,
- a.INTENSITYMODE_LUMINOUSINTENSITY = 2,
- a.INTENSITYMODE_ILLUMINANCE = 3,
- a.INTENSITYMODE_LUMINANCE = 4,
- a.LIGHTTYPEID_POINTLIGHT = 0,
- a.LIGHTTYPEID_DIRECTIONALLIGHT = 1,
- a.LIGHTTYPEID_SPOTLIGHT = 2,
- a.LIGHTTYPEID_HEMISPHERICLIGHT = 3,
- a
- }()
- , ComputePressureObserverWrapper = function() {
- function a(e, i) {
- a.IsAvailable && (this._observer = new window.ComputePressureObserver(e,i))
- }
- return Object.defineProperty(a, "IsAvailable", {
- get: function() {
- return IsWindowObjectExist() && "ComputePressureObserver"in window
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.observe = function() {
- var e, i;
- !((e = this._observer) === null || e === void 0) && e.observe && ((i = this._observer) === null || i === void 0 || i.observe())
- }
- ,
- a.prototype.unobserve = function() {
- var e, i;
- !((e = this._observer) === null || e === void 0) && e.unobserve && ((i = this._observer) === null || i === void 0 || i.unobserve())
- }
- ,
- a
- }()
- , _injectLTSScene = function(a) {
- a.prototype.setActiveCameraByID = function(e) {
- return this.setActiveCameraById(e)
- }
- ,
- a.prototype.getLastMaterialByID = function(e) {
- return this.getLastMaterialById(e)
- }
- ,
- a.prototype.getMaterialByID = function(e) {
- return this.getMaterialById(e)
- }
- ,
- a.prototype.getTextureByUniqueID = function(e) {
- return this.getTextureByUniqueId(e)
- }
- ,
- a.prototype.getCameraByID = function(e) {
- return this.getCameraById(e)
- }
- ,
- a.prototype.getCameraByUniqueID = function(e) {
- return this.getCameraByUniqueId(e)
- }
- ,
- a.prototype.getBoneByID = function(e) {
- return this.getBoneById(e)
- }
- ,
- a.prototype.getLightByID = function(e) {
- return this.getLightById(e)
- }
- ,
- a.prototype.getLightByUniqueID = function(e) {
- return this.getLightByUniqueId(e)
- }
- ,
- a.prototype.getParticleSystemByID = function(e) {
- return this.getParticleSystemById(e)
- }
- ,
- a.prototype.getGeometryByID = function(e) {
- return this.getGeometryById(e)
- }
- ,
- a.prototype.getMeshByID = function(e) {
- return this.getMeshById(e)
- }
- ,
- a.prototype.getMeshesByID = function(e) {
- return this.getMeshesById(e)
- }
- ,
- a.prototype.getTransformNodeByID = function(e) {
- return this.getTransformNodeById(e)
- }
- ,
- a.prototype.getTransformNodeByUniqueID = function(e) {
- return this.getTransformNodeByUniqueId(e)
- }
- ,
- a.prototype.getTransformNodesByID = function(e) {
- return this.getTransformNodesById(e)
- }
- ,
- a.prototype.getMeshByUniqueID = function(e) {
- return this.getMeshByUniqueId(e)
- }
- ,
- a.prototype.getLastMeshByID = function(e) {
- return this.getLastMeshById(e)
- }
- ,
- a.prototype.getLastEntryByID = function(e) {
- return this.getLastEntryById(e)
- }
- ,
- a.prototype.getNodeByID = function(e) {
- return this.getNodeById(e)
- }
- ,
- a.prototype.getLastSkeletonByID = function(e) {
- return this.getLastSkeletonById(e)
- }
- }
- , Scene = function(a) {
- __extends(e, a);
- function e(i, o) {
- var s = a.call(this) || this;
- s._inputManager = new InputManager(s),
- s.cameraToUseForPointers = null,
- s._isScene = !0,
- s._blockEntityCollection = !1,
- s.autoClear = !0,
- s.autoClearDepthAndStencil = !0,
- s.clearColor = new Color4(.2,.2,.3,1),
- s.ambientColor = new Color3(0,0,0),
- s._environmentIntensity = 1,
- s._forceWireframe = !1,
- s._skipFrustumClipping = !1,
- s._forcePointsCloud = !1,
- s.animationsEnabled = !0,
- s._animationPropertiesOverride = null,
- s.useConstantAnimationDeltaTime = !1,
- s.constantlyUpdateMeshUnderPointer = !1,
- s.hoverCursor = "pointer",
- s.defaultCursor = "",
- s.doNotHandleCursors = !1,
- s.preventDefaultOnPointerDown = !0,
- s.preventDefaultOnPointerUp = !0,
- s.metadata = null,
- s.reservedDataStore = null,
- s.disableOfflineSupportExceptionRules = new Array,
- s.onDisposeObservable = new Observable,
- s._onDisposeObserver = null,
- s.onBeforeRenderObservable = new Observable,
- s._onBeforeRenderObserver = null,
- s.onAfterRenderObservable = new Observable,
- s.onBeforeRunRegisterBeforeRenderObservable = new Observable,
- s.onAfterRunRegisterBeforeRenderObservable = new Observable,
- s.onBeforeRunRegisterAfterRenderObservable = new Observable,
- s.onAfterRunRegisterAfterRenderObservable = new Observable,
- s.onBeforeRTT1Observable = new Observable,
- s.onAfterRTT1Observable = new Observable,
- s.onAfterRenderCameraObservable = new Observable,
- s._onAfterRenderObserver = null,
- s.onBeforeAnimationsObservable = new Observable,
- s.onAfterAnimationsObservable = new Observable,
- s.onBeforeDrawPhaseObservable = new Observable,
- s.onAfterDrawPhaseObservable = new Observable,
- s.onReadyObservable = new Observable,
- s.onBeforeCameraRenderObservable = new Observable,
- s._onBeforeCameraRenderObserver = null,
- s.onAfterCameraRenderObservable = new Observable,
- s._onAfterCameraRenderObserver = null,
- s.onBeforeActiveMeshesEvaluationObservable = new Observable,
- s.onAfterActiveMeshesEvaluationObservable = new Observable,
- s.onBeforeParticlesRenderingObservable = new Observable,
- s.onAfterParticlesRenderingObservable = new Observable,
- s.onDataLoadedObservable = new Observable,
- s.onNewCameraAddedObservable = new Observable,
- s.onCameraRemovedObservable = new Observable,
- s.onNewLightAddedObservable = new Observable,
- s.onLightRemovedObservable = new Observable,
- s.onNewGeometryAddedObservable = new Observable,
- s.onGeometryRemovedObservable = new Observable,
- s.onNewTransformNodeAddedObservable = new Observable,
- s.onTransformNodeRemovedObservable = new Observable,
- s.onNewMeshAddedObservable = new Observable,
- s.onMeshRemovedObservable = new Observable,
- s.onNewSkeletonAddedObservable = new Observable,
- s.onSkeletonRemovedObservable = new Observable,
- s.onNewMaterialAddedObservable = new Observable,
- s.onNewMultiMaterialAddedObservable = new Observable,
- s.onMaterialRemovedObservable = new Observable,
- s.onMultiMaterialRemovedObservable = new Observable,
- s.onNewTextureAddedObservable = new Observable,
- s.onTextureRemovedObservable = new Observable,
- s.onBeforeRenderTargetsRenderObservable = new Observable,
- s.onAfterRenderTargetsRenderObservable = new Observable,
- s.onBeforeStepObservable = new Observable,
- s.onAfterStepObservable = new Observable,
- s.onActiveCameraChanged = new Observable,
- s.onBeforeRenderingGroupObservable = new Observable,
- s.onAfterRenderingGroupObservable = new Observable,
- s.onMeshImportedObservable = new Observable,
- s.onAnimationFileImportedObservable = new Observable,
- s._registeredForLateAnimationBindings = new SmartArrayNoDuplicate(256),
- s.skipPointerMovePicking = !1,
- s.onPrePointerObservable = new Observable,
- s.onPointerObservable = new Observable,
- s.onPreKeyboardObservable = new Observable,
- s.onKeyboardObservable = new Observable,
- s._useRightHandedSystem = !1,
- s._timeAccumulator = 0,
- s._currentStepId = 0,
- s._currentInternalStep = 0,
- s._fogEnabled = !0,
- s._fogMode = e.FOGMODE_NONE,
- s.fogColor = new Color3(.2,.2,.3),
- s.fogDensity = .1,
- s.fogStart = 0,
- s.fogEnd = 1e3,
- s.needsPreviousWorldMatrices = !1,
- s._shadowsEnabled = !0,
- s._lightsEnabled = !0,
- s.activeCameras = new Array,
- s._texturesEnabled = !0,
- s.physicsEnabled = !0,
- s.particlesEnabled = !0,
- s.spritesEnabled = !0,
- s._skeletonsEnabled = !0,
- s.lensFlaresEnabled = !0,
- s.collisionsEnabled = !0,
- s.gravity = new Vector3(0,-9.807,0),
- s.postProcessesEnabled = !0,
- s.renderTargetsEnabled = !0,
- s.dumpNextRenderTargets = !1,
- s.customRenderTargets = new Array,
- s.importedMeshesFiles = new Array,
- s.probesEnabled = !0,
- s._meshesForIntersections = new SmartArrayNoDuplicate(256),
- s.proceduralTexturesEnabled = !0,
- s._totalVertices = new PerfCounter,
- s._activeIndices = new PerfCounter,
- s._activeParticles = new PerfCounter,
- s._activeBones = new PerfCounter,
- s._animationTime = 0,
- s.animationTimeScale = 1,
- s._renderId = 0,
- s._frameId = 0,
- s._executeWhenReadyTimeoutId = -1,
- s._intermediateRendering = !1,
- s._defaultFrameBufferCleared = !1,
- s._viewUpdateFlag = -1,
- s._projectionUpdateFlag = -1,
- s._toBeDisposed = new Array(256),
- s._activeRequests = new Array,
- s._pendingData = new Array,
- s._isDisposed = !1,
- s.dispatchAllSubMeshesOfActiveMeshes = !1,
- s._activeMeshes = new SmartArray(256),
- s._processedMaterials = new SmartArray(256),
- s._renderTargets = new SmartArrayNoDuplicate(256),
- s._activeParticleSystems = new SmartArray(256),
- s._activeSkeletons = new SmartArrayNoDuplicate(32),
- s._softwareSkinnedMeshes = new SmartArrayNoDuplicate(32),
- s._activeAnimatables = new Array,
- s._transformMatrix = Matrix.Zero(),
- s.requireLightSorting = !1,
- s._components = [],
- s._serializableComponents = [],
- s._transientComponents = [],
- s._beforeCameraUpdateStage = Stage.Create(),
- s._beforeClearStage = Stage.Create(),
- s._beforeRenderTargetClearStage = Stage.Create(),
- s._gatherRenderTargetsStage = Stage.Create(),
- s._gatherActiveCameraRenderTargetsStage = Stage.Create(),
- s._isReadyForMeshStage = Stage.Create(),
- s._beforeEvaluateActiveMeshStage = Stage.Create(),
- s._evaluateSubMeshStage = Stage.Create(),
- s._preActiveMeshStage = Stage.Create(),
- s._cameraDrawRenderTargetStage = Stage.Create(),
- s._beforeCameraDrawStage = Stage.Create(),
- s._beforeRenderTargetDrawStage = Stage.Create(),
- s._beforeRenderingGroupDrawStage = Stage.Create(),
- s._beforeRenderingMeshStage = Stage.Create(),
- s._afterRenderingMeshStage = Stage.Create(),
- s._afterRenderingGroupDrawStage = Stage.Create(),
- s._afterCameraDrawStage = Stage.Create(),
- s._afterRenderTargetDrawStage = Stage.Create(),
- s._afterRenderStage = Stage.Create(),
- s._pointerMoveStage = Stage.Create(),
- s._pointerDownStage = Stage.Create(),
- s._pointerUpStage = Stage.Create(),
- s.geometriesByUniqueId = null,
- s._defaultMeshCandidates = {
- data: [],
- length: 0
- },
- s._defaultSubMeshCandidates = {
- data: [],
- length: 0
- },
- s._preventFreeActiveMeshesAndRenderingGroups = !1,
- s._activeMeshesFrozen = !1,
- s._skipEvaluateActiveMeshesCompletely = !1,
- s._allowPostProcessClearColor = !0,
- s.getDeterministicFrameTime = function() {
- return s._engine.getTimeStep()
- }
- ,
- s._blockMaterialDirtyMechanism = !1,
- s._perfCollector = null,
- s.onComputePressureChanged = new Observable;
- var c = __assign({
- useGeometryUniqueIdsMap: !0,
- useMaterialMeshMap: !0,
- useClonedMeshMap: !0,
- virtual: !1
- }, o);
- return s._engine = i || EngineStore.LastCreatedEngine,
- c.virtual ? s._engine._virtualScenes.push(s) : (EngineStore._LastCreatedScene = s,
- s._engine.scenes.push(s)),
- s._uid = null,
- s._renderingManager = new RenderingManager(s),
- PostProcessManager && (s.postProcessManager = new PostProcessManager(s)),
- IsWindowObjectExist() && s.attachControl(),
- s._createUbo(),
- ImageProcessingConfiguration && (s._imageProcessingConfiguration = new ImageProcessingConfiguration),
- s.setDefaultCandidateProviders(),
- c.useGeometryUniqueIdsMap && (s.geometriesByUniqueId = {}),
- s.useMaterialMeshMap = c.useMaterialMeshMap,
- s.useClonedMeshMap = c.useClonedMeshMap,
- (!o || !o.virtual) && s._engine.onNewSceneAddedObservable.notifyObservers(s),
- ComputePressureObserverWrapper.IsAvailable && (s._computePressureObserver = new ComputePressureObserverWrapper(function(d) {
- s.onComputePressureChanged.notifyObservers(d)
- }
- ,{
- cpuUtilizationThresholds: [.25, .5, .75, .9],
- cpuSpeedThresholds: [.5]
- }),
- s._computePressureObserver.observe()),
- s
- }
- return e.DefaultMaterialFactory = function(i) {
- throw _WarnImport("StandardMaterial")
- }
- ,
- e.CollisionCoordinatorFactory = function() {
- throw _WarnImport("DefaultCollisionCoordinator")
- }
- ,
- Object.defineProperty(e.prototype, "environmentTexture", {
- get: function() {
- return this._environmentTexture
- },
- set: function(i) {
- this._environmentTexture !== i && (this._environmentTexture = i,
- this.markAllMaterialsAsDirty(1))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "environmentIntensity", {
- get: function() {
- return this._environmentIntensity
- },
- set: function(i) {
- this._environmentIntensity !== i && (this._environmentIntensity = i,
- this.markAllMaterialsAsDirty(1))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "imageProcessingConfiguration", {
- get: function() {
- return this._imageProcessingConfiguration
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "forceWireframe", {
- get: function() {
- return this._forceWireframe
- },
- set: function(i) {
- this._forceWireframe !== i && (this._forceWireframe = i,
- this.markAllMaterialsAsDirty(16))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "skipFrustumClipping", {
- get: function() {
- return this._skipFrustumClipping
- },
- set: function(i) {
- this._skipFrustumClipping !== i && (this._skipFrustumClipping = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "forcePointsCloud", {
- get: function() {
- return this._forcePointsCloud
- },
- set: function(i) {
- this._forcePointsCloud !== i && (this._forcePointsCloud = i,
- this.markAllMaterialsAsDirty(16))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "animationPropertiesOverride", {
- get: function() {
- return this._animationPropertiesOverride
- },
- set: function(i) {
- this._animationPropertiesOverride = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "onDispose", {
- set: function(i) {
- this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver),
- this._onDisposeObserver = this.onDisposeObservable.add(i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "beforeRender", {
- set: function(i) {
- this._onBeforeRenderObserver && this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),
- i && (this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(i))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "afterRender", {
- set: function(i) {
- this._onAfterRenderObserver && this.onAfterRenderObservable.remove(this._onAfterRenderObserver),
- i && (this._onAfterRenderObserver = this.onAfterRenderObservable.add(i))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "beforeCameraRender", {
- set: function(i) {
- this._onBeforeCameraRenderObserver && this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),
- this._onBeforeCameraRenderObserver = this.onBeforeCameraRenderObservable.add(i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "afterCameraRender", {
- set: function(i) {
- this._onAfterCameraRenderObserver && this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),
- this._onAfterCameraRenderObserver = this.onAfterCameraRenderObservable.add(i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "unTranslatedPointer", {
- get: function() {
- return this._inputManager.unTranslatedPointer
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "DragMovementThreshold", {
- get: function() {
- return InputManager.DragMovementThreshold
- },
- set: function(i) {
- InputManager.DragMovementThreshold = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "LongPressDelay", {
- get: function() {
- return InputManager.LongPressDelay
- },
- set: function(i) {
- InputManager.LongPressDelay = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "DoubleClickDelay", {
- get: function() {
- return InputManager.DoubleClickDelay
- },
- set: function(i) {
- InputManager.DoubleClickDelay = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "ExclusiveDoubleClickMode", {
- get: function() {
- return InputManager.ExclusiveDoubleClickMode
- },
- set: function(i) {
- InputManager.ExclusiveDoubleClickMode = i
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.bindEyePosition = function(i, o, s) {
- var c;
- o === void 0 && (o = "vEyePosition"),
- s === void 0 && (s = !1);
- var d = this._forcedViewPosition ? this._forcedViewPosition : this._mirroredCameraPosition ? this._mirroredCameraPosition : (c = this.activeCamera.globalPosition) !== null && c !== void 0 ? c : this.activeCamera.devicePosition
- , _ = this.useRightHandedSystem === (this._mirroredCameraPosition != null);
- return TmpVectors.Vector4[0].set(d.x, d.y, d.z, _ ? -1 : 1),
- i && (s ? i.setFloat3(o, TmpVectors.Vector4[0].x, TmpVectors.Vector4[0].y, TmpVectors.Vector4[0].z) : i.setVector4(o, TmpVectors.Vector4[0])),
- TmpVectors.Vector4[0]
- }
- ,
- e.prototype.finalizeSceneUbo = function() {
- var i = this.getSceneUniformBuffer()
- , o = this.bindEyePosition(null);
- return i.updateFloat4("vEyePosition", o.x, o.y, o.z, o.w),
- i.update(),
- i
- }
- ,
- Object.defineProperty(e.prototype, "useRightHandedSystem", {
- get: function() {
- return this._useRightHandedSystem
- },
- set: function(i) {
- this._useRightHandedSystem !== i && (this._useRightHandedSystem = i,
- this.markAllMaterialsAsDirty(16))
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.setStepId = function(i) {
- this._currentStepId = i
- }
- ,
- e.prototype.getStepId = function() {
- return this._currentStepId
- }
- ,
- e.prototype.getInternalStep = function() {
- return this._currentInternalStep
- }
- ,
- Object.defineProperty(e.prototype, "fogEnabled", {
- get: function() {
- return this._fogEnabled
- },
- set: function(i) {
- this._fogEnabled !== i && (this._fogEnabled = i,
- this.markAllMaterialsAsDirty(16))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "fogMode", {
- get: function() {
- return this._fogMode
- },
- set: function(i) {
- this._fogMode !== i && (this._fogMode = i,
- this.markAllMaterialsAsDirty(16))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "prePass", {
- get: function() {
- return !!this.prePassRenderer && this.prePassRenderer.defaultRT.enabled
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "shadowsEnabled", {
- get: function() {
- return this._shadowsEnabled
- },
- set: function(i) {
- this._shadowsEnabled !== i && (this._shadowsEnabled = i,
- this.markAllMaterialsAsDirty(2))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "lightsEnabled", {
- get: function() {
- return this._lightsEnabled
- },
- set: function(i) {
- this._lightsEnabled !== i && (this._lightsEnabled = i,
- this.markAllMaterialsAsDirty(2))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "activeCamera", {
- get: function() {
- return this._activeCamera
- },
- set: function(i) {
- i !== this._activeCamera && (this._activeCamera = i,
- this.onActiveCameraChanged.notifyObservers(this))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "defaultMaterial", {
- get: function() {
- return this._defaultMaterial || (this._defaultMaterial = e.DefaultMaterialFactory(this)),
- this._defaultMaterial
- },
- set: function(i) {
- this._defaultMaterial = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "texturesEnabled", {
- get: function() {
- return this._texturesEnabled
- },
- set: function(i) {
- this._texturesEnabled !== i && (this._texturesEnabled = i,
- this.markAllMaterialsAsDirty(1))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "skeletonsEnabled", {
- get: function() {
- return this._skeletonsEnabled
- },
- set: function(i) {
- this._skeletonsEnabled !== i && (this._skeletonsEnabled = i,
- this.markAllMaterialsAsDirty(8))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "collisionCoordinator", {
- get: function() {
- return this._collisionCoordinator || (this._collisionCoordinator = e.CollisionCoordinatorFactory(),
- this._collisionCoordinator.init(this)),
- this._collisionCoordinator
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "frustumPlanes", {
- get: function() {
- return this._frustumPlanes
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._registerTransientComponents = function() {
- if (this._transientComponents.length > 0) {
- for (var i = 0, o = this._transientComponents; i < o.length; i++) {
- var s = o[i];
- s.register()
- }
- this._transientComponents = []
- }
- }
- ,
- e.prototype._addComponent = function(i) {
- this._components.push(i),
- this._transientComponents.push(i);
- var o = i;
- o.addFromContainer && o.serialize && this._serializableComponents.push(o)
- }
- ,
- e.prototype._getComponent = function(i) {
- for (var o = 0, s = this._components; o < s.length; o++) {
- var c = s[o];
- if (c.name === i)
- return c
- }
- return null
- }
- ,
- e.prototype.getClassName = function() {
- return "Scene"
- }
- ,
- e.prototype._getDefaultMeshCandidates = function() {
- return this._defaultMeshCandidates.data = this.meshes,
- this._defaultMeshCandidates.length = this.meshes.length,
- this._defaultMeshCandidates
- }
- ,
- e.prototype._getDefaultSubMeshCandidates = function(i) {
- return this._defaultSubMeshCandidates.data = i.subMeshes,
- this._defaultSubMeshCandidates.length = i.subMeshes.length,
- this._defaultSubMeshCandidates
- }
- ,
- e.prototype.setDefaultCandidateProviders = function() {
- this.getActiveMeshCandidates = this._getDefaultMeshCandidates.bind(this),
- this.getActiveSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this),
- this.getIntersectingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this),
- this.getCollidingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this)
- }
- ,
- Object.defineProperty(e.prototype, "meshUnderPointer", {
- get: function() {
- return this._inputManager.meshUnderPointer
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "pointerX", {
- get: function() {
- return this._inputManager.pointerX
- },
- set: function(i) {
- this._inputManager.pointerX = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "pointerY", {
- get: function() {
- return this._inputManager.pointerY
- },
- set: function(i) {
- this._inputManager.pointerY = i
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getCachedMaterial = function() {
- return this._cachedMaterial
- }
- ,
- e.prototype.getCachedEffect = function() {
- return this._cachedEffect
- }
- ,
- e.prototype.getCachedVisibility = function() {
- return this._cachedVisibility
- }
- ,
- e.prototype.isCachedMaterialInvalid = function(i, o, s) {
- return s === void 0 && (s = 1),
- this._cachedEffect !== o || this._cachedMaterial !== i || this._cachedVisibility !== s
- }
- ,
- e.prototype.getEngine = function() {
- return this._engine
- }
- ,
- e.prototype.getTotalVertices = function() {
- return this._totalVertices.current
- }
- ,
- Object.defineProperty(e.prototype, "totalVerticesPerfCounter", {
- get: function() {
- return this._totalVertices
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getActiveIndices = function() {
- return this._activeIndices.current
- }
- ,
- Object.defineProperty(e.prototype, "totalActiveIndicesPerfCounter", {
- get: function() {
- return this._activeIndices
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getActiveParticles = function() {
- return this._activeParticles.current
- }
- ,
- Object.defineProperty(e.prototype, "activeParticlesPerfCounter", {
- get: function() {
- return this._activeParticles
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getActiveBones = function() {
- return this._activeBones.current
- }
- ,
- Object.defineProperty(e.prototype, "activeBonesPerfCounter", {
- get: function() {
- return this._activeBones
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getActiveMeshes = function() {
- return this._activeMeshes
- }
- ,
- e.prototype.getAnimationRatio = function() {
- return this._animationRatio !== void 0 ? this._animationRatio : 1
- }
- ,
- e.prototype.getRenderId = function() {
- return this._renderId
- }
- ,
- e.prototype.getFrameId = function() {
- return this._frameId
- }
- ,
- e.prototype.incrementRenderId = function() {
- this._renderId++
- }
- ,
- e.prototype._createUbo = function() {
- this.setSceneUniformBuffer(this.createSceneUniformBuffer())
- }
- ,
- e.prototype.simulatePointerMove = function(i, o) {
- return this._inputManager.simulatePointerMove(i, o),
- this
- }
- ,
- e.prototype.simulatePointerDown = function(i, o) {
- return this._inputManager.simulatePointerDown(i, o),
- this
- }
- ,
- e.prototype.simulatePointerUp = function(i, o, s) {
- return this._inputManager.simulatePointerUp(i, o, s),
- this
- }
- ,
- e.prototype.isPointerCaptured = function(i) {
- return i === void 0 && (i = 0),
- this._inputManager.isPointerCaptured(i)
- }
- ,
- e.prototype.attachControl = function(i, o, s) {
- i === void 0 && (i = !0),
- o === void 0 && (o = !0),
- s === void 0 && (s = !0),
- this._inputManager.attachControl(i, o, s)
- }
- ,
- e.prototype.detachControl = function() {
- this._inputManager.detachControl()
- }
- ,
- e.prototype.isReady = function(i) {
- if (i === void 0 && (i = !0),
- this._isDisposed)
- return !1;
- var o, s = this.getEngine();
- if (!s.areAllEffectsReady() || this._pendingData.length > 0)
- return !1;
- for (i && (this._processedMaterials.reset(),
- this._renderTargets.reset()),
- o = 0; o < this.meshes.length; o++) {
- var c = this.meshes[o];
- if (!!c.isEnabled() && !(!c.subMeshes || c.subMeshes.length === 0)) {
- if (!c.isReady(!0))
- return !1;
- for (var d = c.hasThinInstances || c.getClassName() === "InstancedMesh" || c.getClassName() === "InstancedLinesMesh" || s.getCaps().instancedArrays && c.instances.length > 0, _ = 0, b = this._isReadyForMeshStage; _ < b.length; _++) {
- var k = b[_];
- if (!k.action(c, d))
- return !1
- }
- if (!!i) {
- var j = c.material || this.defaultMaterial;
- if (j)
- if (j._storeEffectOnSubMeshes)
- for (var $ = 0, _e = c.subMeshes; $ < _e.length; $++) {
- var et = _e[$]
- , tt = et.getMaterial();
- tt && tt.hasRenderTargetTextures && tt.getRenderTargetTextures != null && this._processedMaterials.indexOf(tt) === -1 && (this._processedMaterials.push(tt),
- this._renderTargets.concatWithNoDuplicate(tt.getRenderTargetTextures()))
- }
- else
- j.hasRenderTargetTextures && j.getRenderTargetTextures != null && this._processedMaterials.indexOf(j) === -1 && (this._processedMaterials.push(j),
- this._renderTargets.concatWithNoDuplicate(j.getRenderTargetTextures()))
- }
- }
- }
- if (i)
- for (o = 0; o < this._renderTargets.length; ++o) {
- var rt = this._renderTargets.data[o];
- if (!rt.isReadyForRendering())
- return !1
- }
- for (o = 0; o < this.geometries.length; o++) {
- var it = this.geometries[o];
- if (it.delayLoadState === 2)
- return !1
- }
- if (this.activeCameras && this.activeCameras.length > 0)
- for (var nt = 0, ot = this.activeCameras; nt < ot.length; nt++) {
- var at = ot[nt];
- if (!at.isReady(!0))
- return !1
- }
- else if (this.activeCamera && !this.activeCamera.isReady(!0))
- return !1;
- for (var st = 0, ut = this.particleSystems; st < ut.length; st++) {
- var ct = ut[st];
- if (!ct.isReady())
- return !1
- }
- return !0
- }
- ,
- e.prototype.resetCachedMaterial = function() {
- this._cachedMaterial = null,
- this._cachedEffect = null,
- this._cachedVisibility = null
- }
- ,
- e.prototype.registerBeforeRender = function(i) {
- this.onBeforeRenderObservable.add(i)
- }
- ,
- e.prototype.unregisterBeforeRender = function(i) {
- this.onBeforeRenderObservable.removeCallback(i)
- }
- ,
- e.prototype.registerAfterRender = function(i) {
- this.onAfterRenderObservable.add(i)
- }
- ,
- e.prototype.unregisterAfterRender = function(i) {
- this.onAfterRenderObservable.removeCallback(i)
- }
- ,
- e.prototype._executeOnceBeforeRender = function(i) {
- var o = this
- , s = function() {
- i(),
- setTimeout(function() {
- o.unregisterBeforeRender(s)
- })
- };
- this.registerBeforeRender(s)
- }
- ,
- e.prototype.executeOnceBeforeRender = function(i, o) {
- var s = this;
- o !== void 0 ? setTimeout(function() {
- s._executeOnceBeforeRender(i)
- }, o) : this._executeOnceBeforeRender(i)
- }
- ,
- e.prototype._addPendingData = function(i) {
- this._pendingData.push(i)
- }
- ,
- e.prototype._removePendingData = function(i) {
- var o = this.isLoading
- , s = this._pendingData.indexOf(i);
- s !== -1 && this._pendingData.splice(s, 1),
- o && !this.isLoading && this.onDataLoadedObservable.notifyObservers(this)
- }
- ,
- e.prototype.getWaitingItemsCount = function() {
- return this._pendingData.length
- }
- ,
- Object.defineProperty(e.prototype, "isLoading", {
- get: function() {
- return this._pendingData.length > 0
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.executeWhenReady = function(i, o) {
- var s = this;
- o === void 0 && (o = !1),
- this.onReadyObservable.add(i),
- this._executeWhenReadyTimeoutId === -1 && (this._executeWhenReadyTimeoutId = setTimeout(function() {
- s._checkIsReady(o)
- }, 150))
- }
- ,
- e.prototype.whenReadyAsync = function(i) {
- var o = this;
- return i === void 0 && (i = !1),
- new Promise(function(s) {
- o.executeWhenReady(function() {
- s()
- }, i)
- }
- )
- }
- ,
- e.prototype._checkIsReady = function(i) {
- var o = this;
- if (i === void 0 && (i = !1),
- this._registerTransientComponents(),
- this.isReady(i)) {
- this.onReadyObservable.notifyObservers(this),
- this.onReadyObservable.clear(),
- this._executeWhenReadyTimeoutId = -1;
- return
- }
- if (this._isDisposed) {
- this.onReadyObservable.clear(),
- this._executeWhenReadyTimeoutId = -1;
- return
- }
- this._executeWhenReadyTimeoutId = setTimeout(function() {
- o._checkIsReady(i)
- }, 150)
- }
- ,
- Object.defineProperty(e.prototype, "animatables", {
- get: function() {
- return this._activeAnimatables
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.resetLastAnimationTimeFrame = function() {
- this._animationTimeLast = PrecisionDate.Now
- }
- ,
- e.prototype.getViewMatrix = function() {
- return this._viewMatrix
- }
- ,
- e.prototype.getProjectionMatrix = function() {
- return this._projectionMatrix
- }
- ,
- e.prototype.getTransformMatrix = function() {
- return this._transformMatrix
- }
- ,
- e.prototype.setTransformMatrix = function(i, o, s, c) {
- this._viewUpdateFlag === i.updateFlag && this._projectionUpdateFlag === o.updateFlag || (this._viewUpdateFlag = i.updateFlag,
- this._projectionUpdateFlag = o.updateFlag,
- this._viewMatrix = i,
- this._projectionMatrix = o,
- this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix),
- this._frustumPlanes ? Frustum.GetPlanesToRef(this._transformMatrix, this._frustumPlanes) : this._frustumPlanes = Frustum.GetPlanes(this._transformMatrix),
- this._multiviewSceneUbo && this._multiviewSceneUbo.useUbo ? this._updateMultiviewUbo(s, c) : this._sceneUbo.useUbo && (this._sceneUbo.updateMatrix("viewProjection", this._transformMatrix),
- this._sceneUbo.updateMatrix("view", this._viewMatrix),
- this._sceneUbo.updateMatrix("projection", this._projectionMatrix)))
- }
- ,
- e.prototype.getSceneUniformBuffer = function() {
- return this._multiviewSceneUbo ? this._multiviewSceneUbo : this._sceneUbo
- }
- ,
- e.prototype.createSceneUniformBuffer = function(i) {
- var o = new UniformBuffer(this._engine,void 0,!1,i != null ? i : "scene");
- return o.addUniform("viewProjection", 16),
- o.addUniform("view", 16),
- o.addUniform("projection", 16),
- o.addUniform("vEyePosition", 4),
- o
- }
- ,
- e.prototype.setSceneUniformBuffer = function(i) {
- this._sceneUbo = i,
- this._viewUpdateFlag = -1,
- this._projectionUpdateFlag = -1
- }
- ,
- e.prototype.getUniqueId = function() {
- return UniqueIdGenerator.UniqueId
- }
- ,
- e.prototype.addMesh = function(i, o) {
- var s = this;
- o === void 0 && (o = !1),
- !this._blockEntityCollection && (this.meshes.push(i),
- i._resyncLightSources(),
- i.parent || i._addToSceneRootNodes(),
- this.onNewMeshAddedObservable.notifyObservers(i),
- o && i.getChildMeshes().forEach(function(c) {
- s.addMesh(c)
- }))
- }
- ,
- e.prototype.removeMesh = function(i, o) {
- var s = this;
- o === void 0 && (o = !1);
- var c = this.meshes.indexOf(i);
- return c !== -1 && (this.meshes[c] = this.meshes[this.meshes.length - 1],
- this.meshes.pop(),
- i.parent || i._removeFromSceneRootNodes()),
- this._inputManager._invalidateMesh(i),
- this.onMeshRemovedObservable.notifyObservers(i),
- o && i.getChildMeshes().forEach(function(d) {
- s.removeMesh(d)
- }),
- c
- }
- ,
- e.prototype.addTransformNode = function(i) {
- this._blockEntityCollection || (i._indexInSceneTransformNodesArray = this.transformNodes.length,
- this.transformNodes.push(i),
- i.parent || i._addToSceneRootNodes(),
- this.onNewTransformNodeAddedObservable.notifyObservers(i))
- }
- ,
- e.prototype.removeTransformNode = function(i) {
- var o = i._indexInSceneTransformNodesArray;
- if (o !== -1) {
- if (o !== this.transformNodes.length - 1) {
- var s = this.transformNodes[this.transformNodes.length - 1];
- this.transformNodes[o] = s,
- s._indexInSceneTransformNodesArray = o
- }
- i._indexInSceneTransformNodesArray = -1,
- this.transformNodes.pop(),
- i.parent || i._removeFromSceneRootNodes()
- }
- return this.onTransformNodeRemovedObservable.notifyObservers(i),
- o
- }
- ,
- e.prototype.removeSkeleton = function(i) {
- var o = this.skeletons.indexOf(i);
- return o !== -1 && (this.skeletons.splice(o, 1),
- this.onSkeletonRemovedObservable.notifyObservers(i)),
- o
- }
- ,
- e.prototype.removeMorphTargetManager = function(i) {
- var o = this.morphTargetManagers.indexOf(i);
- return o !== -1 && this.morphTargetManagers.splice(o, 1),
- o
- }
- ,
- e.prototype.removeLight = function(i) {
- var o = this.lights.indexOf(i);
- if (o !== -1) {
- for (var s = 0, c = this.meshes; s < c.length; s++) {
- var d = c[s];
- d._removeLightSource(i, !1)
- }
- this.lights.splice(o, 1),
- this.sortLightsByPriority(),
- i.parent || i._removeFromSceneRootNodes()
- }
- return this.onLightRemovedObservable.notifyObservers(i),
- o
- }
- ,
- e.prototype.removeCamera = function(i) {
- var o = this.cameras.indexOf(i);
- if (o !== -1 && (this.cameras.splice(o, 1),
- i.parent || i._removeFromSceneRootNodes()),
- this.activeCameras) {
- var s = this.activeCameras.indexOf(i);
- s !== -1 && this.activeCameras.splice(s, 1)
- }
- return this.activeCamera === i && (this.cameras.length > 0 ? this.activeCamera = this.cameras[0] : this.activeCamera = null),
- this.onCameraRemovedObservable.notifyObservers(i),
- o
- }
- ,
- e.prototype.removeParticleSystem = function(i) {
- var o = this.particleSystems.indexOf(i);
- return o !== -1 && this.particleSystems.splice(o, 1),
- o
- }
- ,
- e.prototype.removeAnimation = function(i) {
- var o = this.animations.indexOf(i);
- return o !== -1 && this.animations.splice(o, 1),
- o
- }
- ,
- e.prototype.stopAnimation = function(i, o, s) {}
- ,
- e.prototype.removeAnimationGroup = function(i) {
- var o = this.animationGroups.indexOf(i);
- return o !== -1 && this.animationGroups.splice(o, 1),
- o
- }
- ,
- e.prototype.removeMultiMaterial = function(i) {
- var o = this.multiMaterials.indexOf(i);
- return o !== -1 && this.multiMaterials.splice(o, 1),
- this.onMultiMaterialRemovedObservable.notifyObservers(i),
- o
- }
- ,
- e.prototype.removeMaterial = function(i) {
- var o = i._indexInSceneMaterialArray;
- if (o !== -1 && o < this.materials.length) {
- if (o !== this.materials.length - 1) {
- var s = this.materials[this.materials.length - 1];
- this.materials[o] = s,
- s._indexInSceneMaterialArray = o
- }
- i._indexInSceneMaterialArray = -1,
- this.materials.pop()
- }
- return this.onMaterialRemovedObservable.notifyObservers(i),
- o
- }
- ,
- e.prototype.removeActionManager = function(i) {
- var o = this.actionManagers.indexOf(i);
- return o !== -1 && this.actionManagers.splice(o, 1),
- o
- }
- ,
- e.prototype.removeTexture = function(i) {
- var o = this.textures.indexOf(i);
- return o !== -1 && this.textures.splice(o, 1),
- this.onTextureRemovedObservable.notifyObservers(i),
- o
- }
- ,
- e.prototype.addLight = function(i) {
- if (!this._blockEntityCollection) {
- this.lights.push(i),
- this.sortLightsByPriority(),
- i.parent || i._addToSceneRootNodes();
- for (var o = 0, s = this.meshes; o < s.length; o++) {
- var c = s[o];
- c.lightSources.indexOf(i) === -1 && (c.lightSources.push(i),
- c._resyncLightSources())
- }
- this.onNewLightAddedObservable.notifyObservers(i)
- }
- }
- ,
- e.prototype.sortLightsByPriority = function() {
- this.requireLightSorting && this.lights.sort(LightConstants.CompareLightsPriority)
- }
- ,
- e.prototype.addCamera = function(i) {
- this._blockEntityCollection || (this.cameras.push(i),
- this.onNewCameraAddedObservable.notifyObservers(i),
- i.parent || i._addToSceneRootNodes())
- }
- ,
- e.prototype.addSkeleton = function(i) {
- this._blockEntityCollection || (this.skeletons.push(i),
- this.onNewSkeletonAddedObservable.notifyObservers(i))
- }
- ,
- e.prototype.addParticleSystem = function(i) {
- this._blockEntityCollection || this.particleSystems.push(i)
- }
- ,
- e.prototype.addAnimation = function(i) {
- this._blockEntityCollection || this.animations.push(i)
- }
- ,
- e.prototype.addAnimationGroup = function(i) {
- this._blockEntityCollection || this.animationGroups.push(i)
- }
- ,
- e.prototype.addMultiMaterial = function(i) {
- this._blockEntityCollection || (this.multiMaterials.push(i),
- this.onNewMultiMaterialAddedObservable.notifyObservers(i))
- }
- ,
- e.prototype.addMaterial = function(i) {
- this._blockEntityCollection || (i._indexInSceneMaterialArray = this.materials.length,
- this.materials.push(i),
- this.onNewMaterialAddedObservable.notifyObservers(i))
- }
- ,
- e.prototype.addMorphTargetManager = function(i) {
- this._blockEntityCollection || this.morphTargetManagers.push(i)
- }
- ,
- e.prototype.addGeometry = function(i) {
- this._blockEntityCollection || (this.geometriesByUniqueId && (this.geometriesByUniqueId[i.uniqueId] = this.geometries.length),
- this.geometries.push(i))
- }
- ,
- e.prototype.addActionManager = function(i) {
- this.actionManagers.push(i)
- }
- ,
- e.prototype.addTexture = function(i) {
- this._blockEntityCollection || (this.textures.push(i),
- this.onNewTextureAddedObservable.notifyObservers(i))
- }
- ,
- e.prototype.switchActiveCamera = function(i, o) {
- o === void 0 && (o = !0);
- var s = this._engine.getInputElement();
- !s || (this.activeCamera && this.activeCamera.detachControl(),
- this.activeCamera = i,
- o && i.attachControl())
- }
- ,
- e.prototype.setActiveCameraById = function(i) {
- var o = this.getCameraById(i);
- return o ? (this.activeCamera = o,
- o) : null
- }
- ,
- e.prototype.setActiveCameraByName = function(i) {
- var o = this.getCameraByName(i);
- return o ? (this.activeCamera = o,
- o) : null
- }
- ,
- e.prototype.getAnimationGroupByName = function(i) {
- for (var o = 0; o < this.animationGroups.length; o++)
- if (this.animationGroups[o].name === i)
- return this.animationGroups[o];
- return null
- }
- ,
- e.prototype.getMaterialByUniqueID = function(i) {
- for (var o = 0; o < this.materials.length; o++)
- if (this.materials[o].uniqueId === i)
- return this.materials[o];
- return null
- }
- ,
- e.prototype.getMaterialById = function(i) {
- for (var o = 0; o < this.materials.length; o++)
- if (this.materials[o].id === i)
- return this.materials[o];
- return null
- }
- ,
- e.prototype.getLastMaterialById = function(i) {
- for (var o = this.materials.length - 1; o >= 0; o--)
- if (this.materials[o].id === i)
- return this.materials[o];
- return null
- }
- ,
- e.prototype.getMaterialByName = function(i) {
- for (var o = 0; o < this.materials.length; o++)
- if (this.materials[o].name === i)
- return this.materials[o];
- return null
- }
- ,
- e.prototype.getTextureByUniqueId = function(i) {
- for (var o = 0; o < this.textures.length; o++)
- if (this.textures[o].uniqueId === i)
- return this.textures[o];
- return null
- }
- ,
- e.prototype.getTextureByName = function(i) {
- for (var o = 0; o < this.textures.length; o++)
- if (this.textures[o].name === i)
- return this.textures[o];
- return null
- }
- ,
- e.prototype.getCameraById = function(i) {
- for (var o = 0; o < this.cameras.length; o++)
- if (this.cameras[o].id === i)
- return this.cameras[o];
- return null
- }
- ,
- e.prototype.getCameraByUniqueId = function(i) {
- for (var o = 0; o < this.cameras.length; o++)
- if (this.cameras[o].uniqueId === i)
- return this.cameras[o];
- return null
- }
- ,
- e.prototype.getCameraByName = function(i) {
- for (var o = 0; o < this.cameras.length; o++)
- if (this.cameras[o].name === i)
- return this.cameras[o];
- return null
- }
- ,
- e.prototype.getBoneById = function(i) {
- for (var o = 0; o < this.skeletons.length; o++)
- for (var s = this.skeletons[o], c = 0; c < s.bones.length; c++)
- if (s.bones[c].id === i)
- return s.bones[c];
- return null
- }
- ,
- e.prototype.getBoneByName = function(i) {
- for (var o = 0; o < this.skeletons.length; o++)
- for (var s = this.skeletons[o], c = 0; c < s.bones.length; c++)
- if (s.bones[c].name === i)
- return s.bones[c];
- return null
- }
- ,
- e.prototype.getLightByName = function(i) {
- for (var o = 0; o < this.lights.length; o++)
- if (this.lights[o].name === i)
- return this.lights[o];
- return null
- }
- ,
- e.prototype.getLightById = function(i) {
- for (var o = 0; o < this.lights.length; o++)
- if (this.lights[o].id === i)
- return this.lights[o];
- return null
- }
- ,
- e.prototype.getLightByUniqueId = function(i) {
- for (var o = 0; o < this.lights.length; o++)
- if (this.lights[o].uniqueId === i)
- return this.lights[o];
- return null
- }
- ,
- e.prototype.getParticleSystemById = function(i) {
- for (var o = 0; o < this.particleSystems.length; o++)
- if (this.particleSystems[o].id === i)
- return this.particleSystems[o];
- return null
- }
- ,
- e.prototype.getGeometryById = function(i) {
- for (var o = 0; o < this.geometries.length; o++)
- if (this.geometries[o].id === i)
- return this.geometries[o];
- return null
- }
- ,
- e.prototype._getGeometryByUniqueId = function(i) {
- if (this.geometriesByUniqueId) {
- var o = this.geometriesByUniqueId[i];
- if (o !== void 0)
- return this.geometries[o]
- } else
- for (var s = 0; s < this.geometries.length; s++)
- if (this.geometries[s].uniqueId === i)
- return this.geometries[s];
- return null
- }
- ,
- e.prototype.pushGeometry = function(i, o) {
- return !o && this._getGeometryByUniqueId(i.uniqueId) ? !1 : (this.addGeometry(i),
- this.onNewGeometryAddedObservable.notifyObservers(i),
- !0)
- }
- ,
- e.prototype.removeGeometry = function(i) {
- var o;
- if (this.geometriesByUniqueId) {
- if (o = this.geometriesByUniqueId[i.uniqueId],
- o === void 0)
- return !1
- } else if (o = this.geometries.indexOf(i),
- o < 0)
- return !1;
- if (o !== this.geometries.length - 1) {
- var s = this.geometries[this.geometries.length - 1];
- s && (this.geometries[o] = s,
- this.geometriesByUniqueId && (this.geometriesByUniqueId[s.uniqueId] = o,
- this.geometriesByUniqueId[i.uniqueId] = void 0))
- }
- return this.geometries.pop(),
- this.onGeometryRemovedObservable.notifyObservers(i),
- !0
- }
- ,
- e.prototype.getGeometries = function() {
- return this.geometries
- }
- ,
- e.prototype.getMeshById = function(i) {
- for (var o = 0; o < this.meshes.length; o++)
- if (this.meshes[o].id === i)
- return this.meshes[o];
- return null
- }
- ,
- e.prototype.getMeshesById = function(i) {
- return this.meshes.filter(function(o) {
- return o.id === i
- })
- }
- ,
- e.prototype.getTransformNodeById = function(i) {
- for (var o = 0; o < this.transformNodes.length; o++)
- if (this.transformNodes[o].id === i)
- return this.transformNodes[o];
- return null
- }
- ,
- e.prototype.getTransformNodeByUniqueId = function(i) {
- for (var o = 0; o < this.transformNodes.length; o++)
- if (this.transformNodes[o].uniqueId === i)
- return this.transformNodes[o];
- return null
- }
- ,
- e.prototype.getTransformNodesById = function(i) {
- return this.transformNodes.filter(function(o) {
- return o.id === i
- })
- }
- ,
- e.prototype.getMeshByUniqueId = function(i) {
- for (var o = 0; o < this.meshes.length; o++)
- if (this.meshes[o].uniqueId === i)
- return this.meshes[o];
- return null
- }
- ,
- e.prototype.getLastMeshById = function(i) {
- for (var o = this.meshes.length - 1; o >= 0; o--)
- if (this.meshes[o].id === i)
- return this.meshes[o];
- return null
- }
- ,
- e.prototype.getLastEntryById = function(i) {
- var o;
- for (o = this.meshes.length - 1; o >= 0; o--)
- if (this.meshes[o].id === i)
- return this.meshes[o];
- for (o = this.transformNodes.length - 1; o >= 0; o--)
- if (this.transformNodes[o].id === i)
- return this.transformNodes[o];
- for (o = this.cameras.length - 1; o >= 0; o--)
- if (this.cameras[o].id === i)
- return this.cameras[o];
- for (o = this.lights.length - 1; o >= 0; o--)
- if (this.lights[o].id === i)
- return this.lights[o];
- return null
- }
- ,
- e.prototype.getNodeById = function(i) {
- var o = this.getMeshById(i);
- if (o)
- return o;
- var s = this.getTransformNodeById(i);
- if (s)
- return s;
- var c = this.getLightById(i);
- if (c)
- return c;
- var d = this.getCameraById(i);
- if (d)
- return d;
- var _ = this.getBoneById(i);
- return _ || null
- }
- ,
- e.prototype.getNodeByName = function(i) {
- var o = this.getMeshByName(i);
- if (o)
- return o;
- var s = this.getTransformNodeByName(i);
- if (s)
- return s;
- var c = this.getLightByName(i);
- if (c)
- return c;
- var d = this.getCameraByName(i);
- if (d)
- return d;
- var _ = this.getBoneByName(i);
- return _ || null
- }
- ,
- e.prototype.getMeshByName = function(i) {
- for (var o = 0; o < this.meshes.length; o++)
- if (this.meshes[o].name === i)
- return this.meshes[o];
- return null
- }
- ,
- e.prototype.getTransformNodeByName = function(i) {
- for (var o = 0; o < this.transformNodes.length; o++)
- if (this.transformNodes[o].name === i)
- return this.transformNodes[o];
- return null
- }
- ,
- e.prototype.getLastSkeletonById = function(i) {
- for (var o = this.skeletons.length - 1; o >= 0; o--)
- if (this.skeletons[o].id === i)
- return this.skeletons[o];
- return null
- }
- ,
- e.prototype.getSkeletonByUniqueId = function(i) {
- for (var o = 0; o < this.skeletons.length; o++)
- if (this.skeletons[o].uniqueId === i)
- return this.skeletons[o];
- return null
- }
- ,
- e.prototype.getSkeletonById = function(i) {
- for (var o = 0; o < this.skeletons.length; o++)
- if (this.skeletons[o].id === i)
- return this.skeletons[o];
- return null
- }
- ,
- e.prototype.getSkeletonByName = function(i) {
- for (var o = 0; o < this.skeletons.length; o++)
- if (this.skeletons[o].name === i)
- return this.skeletons[o];
- return null
- }
- ,
- e.prototype.getMorphTargetManagerById = function(i) {
- for (var o = 0; o < this.morphTargetManagers.length; o++)
- if (this.morphTargetManagers[o].uniqueId === i)
- return this.morphTargetManagers[o];
- return null
- }
- ,
- e.prototype.getMorphTargetById = function(i) {
- for (var o = 0; o < this.morphTargetManagers.length; ++o)
- for (var s = this.morphTargetManagers[o], c = 0; c < s.numTargets; ++c) {
- var d = s.getTarget(c);
- if (d.id === i)
- return d
- }
- return null
- }
- ,
- e.prototype.getMorphTargetByName = function(i) {
- for (var o = 0; o < this.morphTargetManagers.length; ++o)
- for (var s = this.morphTargetManagers[o], c = 0; c < s.numTargets; ++c) {
- var d = s.getTarget(c);
- if (d.name === i)
- return d
- }
- return null
- }
- ,
- e.prototype.getPostProcessByName = function(i) {
- for (var o = 0; o < this.postProcesses.length; ++o) {
- var s = this.postProcesses[o];
- if (s.name === i)
- return s
- }
- return null
- }
- ,
- e.prototype.isActiveMesh = function(i) {
- return this._activeMeshes.indexOf(i) !== -1
- }
- ,
- Object.defineProperty(e.prototype, "uid", {
- get: function() {
- return this._uid || (this._uid = Tools.RandomId()),
- this._uid
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.addExternalData = function(i, o) {
- return this._externalData || (this._externalData = new StringDictionary),
- this._externalData.add(i, o)
- }
- ,
- e.prototype.getExternalData = function(i) {
- return this._externalData ? this._externalData.get(i) : null
- }
- ,
- e.prototype.getOrAddExternalDataWithFactory = function(i, o) {
- return this._externalData || (this._externalData = new StringDictionary),
- this._externalData.getOrAddWithFactory(i, o)
- }
- ,
- e.prototype.removeExternalData = function(i) {
- return this._externalData.remove(i)
- }
- ,
- e.prototype._evaluateSubMesh = function(i, o, s) {
- if (s.hasInstances || s.isAnInstance || this.dispatchAllSubMeshesOfActiveMeshes || this._skipFrustumClipping || o.alwaysSelectAsActiveMesh || o.subMeshes.length === 1 || i.isInFrustum(this._frustumPlanes)) {
- for (var c = 0, d = this._evaluateSubMeshStage; c < d.length; c++) {
- var _ = d[c];
- _.action(o, i)
- }
- var b = i.getMaterial();
- b != null && (b.hasRenderTargetTextures && b.getRenderTargetTextures != null && this._processedMaterials.indexOf(b) === -1 && (this._processedMaterials.push(b),
- this._renderTargets.concatWithNoDuplicate(b.getRenderTargetTextures())),
- this._renderingManager.dispatch(i, o, b))
- }
- }
- ,
- e.prototype.freeProcessedMaterials = function() {
- this._processedMaterials.dispose()
- }
- ,
- Object.defineProperty(e.prototype, "blockfreeActiveMeshesAndRenderingGroups", {
- get: function() {
- return this._preventFreeActiveMeshesAndRenderingGroups
- },
- set: function(i) {
- this._preventFreeActiveMeshesAndRenderingGroups !== i && (i && (this.freeActiveMeshes(),
- this.freeRenderingGroups()),
- this._preventFreeActiveMeshesAndRenderingGroups = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.freeActiveMeshes = function() {
- if (!this.blockfreeActiveMeshesAndRenderingGroups && (this._activeMeshes.dispose(),
- this.activeCamera && this.activeCamera._activeMeshes && this.activeCamera._activeMeshes.dispose(),
- this.activeCameras))
- for (var i = 0; i < this.activeCameras.length; i++) {
- var o = this.activeCameras[i];
- o && o._activeMeshes && o._activeMeshes.dispose()
- }
- }
- ,
- e.prototype.freeRenderingGroups = function() {
- if (!this.blockfreeActiveMeshesAndRenderingGroups && (this._renderingManager && this._renderingManager.freeRenderingGroups(),
- this.textures))
- for (var i = 0; i < this.textures.length; i++) {
- var o = this.textures[i];
- o && o.renderList && o.freeRenderingGroups()
- }
- }
- ,
- e.prototype._isInIntermediateRendering = function() {
- return this._intermediateRendering
- }
- ,
- e.prototype.freezeActiveMeshes = function(i, o, s, c) {
- var d = this;
- return i === void 0 && (i = !1),
- c === void 0 && (c = !0),
- this.executeWhenReady(function() {
- if (!d.activeCamera) {
- s && s("No active camera found");
- return
- }
- if (d._frustumPlanes || d.setTransformMatrix(d.activeCamera.getViewMatrix(), d.activeCamera.getProjectionMatrix()),
- d._evaluateActiveMeshes(),
- d._activeMeshesFrozen = !0,
- d._skipEvaluateActiveMeshesCompletely = i,
- c)
- for (var _ = 0; _ < d._activeMeshes.length; _++)
- d._activeMeshes.data[_]._freeze();
- o && o()
- }),
- this
- }
- ,
- e.prototype.unfreezeActiveMeshes = function() {
- for (var i = 0; i < this.meshes.length; i++) {
- var o = this.meshes[i];
- o._internalAbstractMeshDataInfo && (o._internalAbstractMeshDataInfo._isActive = !1)
- }
- for (var i = 0; i < this._activeMeshes.length; i++)
- this._activeMeshes.data[i]._unFreeze();
- return this._activeMeshesFrozen = !1,
- this
- }
- ,
- e.prototype._evaluateActiveMeshes = function() {
- var i;
- if (this._engine.snapshotRendering && this._engine.snapshotRenderingMode === 1) {
- this._activeMeshes.length > 0 && ((i = this.activeCamera) === null || i === void 0 || i._activeMeshes.reset(),
- this._activeMeshes.reset(),
- this._renderingManager.reset(),
- this._processedMaterials.reset(),
- this._activeParticleSystems.reset(),
- this._activeSkeletons.reset(),
- this._softwareSkinnedMeshes.reset());
- return
- }
- if (this._activeMeshesFrozen && this._activeMeshes.length) {
- if (!this._skipEvaluateActiveMeshesCompletely)
- for (var o = this._activeMeshes.length, s = 0; s < o; s++) {
- var c = this._activeMeshes.data[s];
- c.computeWorldMatrix()
- }
- if (this._activeParticleSystems)
- for (var d = this._activeParticleSystems.length, s = 0; s < d; s++)
- this._activeParticleSystems.data[s].animate();
- return
- }
- if (!!this.activeCamera) {
- this.onBeforeActiveMeshesEvaluationObservable.notifyObservers(this),
- this.activeCamera._activeMeshes.reset(),
- this._activeMeshes.reset(),
- this._renderingManager.reset(),
- this._processedMaterials.reset(),
- this._activeParticleSystems.reset(),
- this._activeSkeletons.reset(),
- this._softwareSkinnedMeshes.reset();
- for (var _ = 0, b = this._beforeEvaluateActiveMeshStage; _ < b.length; _++) {
- var k = b[_];
- k.action()
- }
- for (var j = this.getActiveMeshCandidates(), $ = j.length, s = 0; s < $; s++) {
- var c = j.data[s];
- if (c._internalAbstractMeshDataInfo._currentLODIsUpToDate = !1,
- !c.isBlocked && (this._totalVertices.addCount(c.getTotalVertices(), !1),
- !(!c.isReady() || !c.isEnabled() || c.scaling.lengthSquared() === 0))) {
- c.computeWorldMatrix(),
- c.actionManager && c.actionManager.hasSpecificTriggers2(12, 13) && this._meshesForIntersections.pushNoDuplicate(c);
- var _e = this.customLODSelector ? this.customLODSelector(c, this.activeCamera) : c.getLOD(this.activeCamera);
- if (c._internalAbstractMeshDataInfo._currentLOD = _e,
- c._internalAbstractMeshDataInfo._currentLODIsUpToDate = !0,
- _e != null && (_e !== c && _e.billboardMode !== 0 && _e.computeWorldMatrix(),
- c._preActivate(),
- c.isVisible && c.visibility > 0 && (c.layerMask & this.activeCamera.layerMask) !== 0 && (this._skipFrustumClipping || c.alwaysSelectAsActiveMesh || c.isInFrustum(this._frustumPlanes)))) {
- this._activeMeshes.push(c),
- this.activeCamera._activeMeshes.push(c),
- _e !== c && _e._activate(this._renderId, !1);
- for (var et = 0, tt = this._preActiveMeshStage; et < tt.length; et++) {
- var k = tt[et];
- k.action(c)
- }
- c._activate(this._renderId, !1) && (c.isAnInstance ? c._internalAbstractMeshDataInfo._actAsRegularMesh && (_e = c) : _e._internalAbstractMeshDataInfo._onlyForInstances = !1,
- _e._internalAbstractMeshDataInfo._isActive = !0,
- this._activeMesh(c, _e)),
- c._postActivate()
- }
- }
- }
- if (this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this),
- this.particlesEnabled) {
- this.onBeforeParticlesRenderingObservable.notifyObservers(this);
- for (var rt = 0; rt < this.particleSystems.length; rt++) {
- var it = this.particleSystems[rt];
- if (!(!it.isStarted() || !it.emitter)) {
- var nt = it.emitter;
- (!nt.position || nt.isEnabled()) && (this._activeParticleSystems.push(it),
- it.animate(),
- this._renderingManager.dispatchParticles(it))
- }
- }
- this.onAfterParticlesRenderingObservable.notifyObservers(this)
- }
- }
- }
- ,
- e.prototype._activeMesh = function(i, o) {
- if (this._skeletonsEnabled && o.skeleton !== null && o.skeleton !== void 0 && (this._activeSkeletons.pushNoDuplicate(o.skeleton) && o.skeleton.prepare(),
- o.computeBonesUsingShaders || this._softwareSkinnedMeshes.pushNoDuplicate(o)),
- o != null && o.subMeshes !== void 0 && o.subMeshes !== null && o.subMeshes.length > 0)
- for (var s = this.getActiveSubMeshCandidates(o), c = s.length, d = 0; d < c; d++) {
- var _ = s.data[d];
- this._evaluateSubMesh(_, o, i)
- }
- }
- ,
- e.prototype.updateTransformMatrix = function(i) {
- !this.activeCamera || this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(i))
- }
- ,
- e.prototype._bindFrameBuffer = function(i, o) {
- o === void 0 && (o = !0),
- i && i._multiviewTexture ? i._multiviewTexture._bindFrameBuffer() : i && i.outputRenderTarget ? i.outputRenderTarget._bindFrameBuffer() : this._engine._currentFrameBufferIsDefaultFrameBuffer() || this._engine.restoreDefaultFramebuffer(),
- o && this._clearFrameBuffer(i)
- }
- ,
- e.prototype._clearFrameBuffer = function(i) {
- if (!(i && i._multiviewTexture))
- if (i && i.outputRenderTarget) {
- var o = i.outputRenderTarget;
- o.onClearObservable.hasObservers() ? o.onClearObservable.notifyObservers(this._engine) : o.skipInitialClear || (this._engine.clear(o.clearColor || this.clearColor, !o._cleared, !0, !0),
- o._cleared = !0)
- } else
- this._defaultFrameBufferCleared ? this._engine.clear(null, !1, !0, !0) : (this._defaultFrameBufferCleared = !0,
- this._clear())
- }
- ,
- e.prototype._renderForCamera = function(i, o, s) {
- var c, d, _;
- if (s === void 0 && (s = !0),
- !(i && i._skipRendering)) {
- var b = this._engine;
- if (this._activeCamera = i,
- !this.activeCamera)
- throw new Error("Active camera not set");
- b.setViewport(this.activeCamera.viewport),
- this.resetCachedMaterial(),
- this._renderId++,
- !this.prePass && s && this._bindFrameBuffer(this._activeCamera);
- var k = this.getEngine().getCaps().multiview && i.outputRenderTarget && i.outputRenderTarget.getViewCount() > 1;
- k ? this.setTransformMatrix(i._rigCameras[0].getViewMatrix(), i._rigCameras[0].getProjectionMatrix(), i._rigCameras[1].getViewMatrix(), i._rigCameras[1].getProjectionMatrix()) : this.updateTransformMatrix(),
- this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera),
- this._evaluateActiveMeshes();
- for (var j = 0; j < this._softwareSkinnedMeshes.length; j++) {
- var $ = this._softwareSkinnedMeshes.data[j];
- $.applySkeleton($.skeleton)
- }
- this.onBeforeRenderTargetsRenderObservable.notifyObservers(this),
- i.customRenderTargets && i.customRenderTargets.length > 0 && this._renderTargets.concatWithNoDuplicate(i.customRenderTargets),
- o && o.customRenderTargets && o.customRenderTargets.length > 0 && this._renderTargets.concatWithNoDuplicate(o.customRenderTargets),
- this.environmentTexture && this.environmentTexture.isRenderTarget && this._renderTargets.pushNoDuplicate(this.environmentTexture);
- for (var _e = 0, et = this._gatherActiveCameraRenderTargetsStage; _e < et.length; _e++) {
- var tt = et[_e];
- tt.action(this._renderTargets)
- }
- var rt = !1;
- if (this.renderTargetsEnabled) {
- if (this._intermediateRendering = !0,
- this._renderTargets.length > 0) {
- Tools.StartPerformanceCounter("Render targets", this._renderTargets.length > 0);
- for (var it = 0; it < this._renderTargets.length; it++) {
- var nt = this._renderTargets.data[it];
- if (nt._shouldRender()) {
- this._renderId++;
- var ot = nt.activeCamera && nt.activeCamera !== this.activeCamera;
- nt.render(ot, this.dumpNextRenderTargets),
- rt = !0
- }
- }
- Tools.EndPerformanceCounter("Render targets", this._renderTargets.length > 0),
- this._renderId++
- }
- for (var at = 0, st = this._cameraDrawRenderTargetStage; at < st.length; at++) {
- var tt = st[at];
- rt = tt.action(this.activeCamera) || rt
- }
- this._intermediateRendering = !1
- }
- 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,
- rt && !this.prePass && this._bindFrameBuffer(this._activeCamera, !1),
- this.onAfterRenderTargetsRenderObservable.notifyObservers(this),
- this.postProcessManager && !i._multiviewTexture && !this.prePass && this.postProcessManager._prepareFrame();
- for (var ut = 0, ct = this._beforeCameraDrawStage; ut < ct.length; ut++) {
- var tt = ct[ut];
- tt.action(this.activeCamera)
- }
- this.onBeforeDrawPhaseObservable.notifyObservers(this),
- b.snapshotRendering && b.snapshotRenderingMode === 1 && this.finalizeSceneUbo(),
- this._renderingManager.render(null, null, !0, !0),
- this.onAfterDrawPhaseObservable.notifyObservers(this);
- for (var lt = 0, ft = this._afterCameraDrawStage; lt < ft.length; lt++) {
- var tt = ft[lt];
- tt.action(this.activeCamera)
- }
- if (this.postProcessManager && !i._multiviewTexture) {
- var ht = i.outputRenderTarget ? i.outputRenderTarget.renderTarget : void 0;
- this.postProcessManager._finalizeFrame(i.isIntermediate, ht)
- }
- this._renderTargets.reset(),
- this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera)
- }
- }
- ,
- e.prototype._processSubCameras = function(i, o) {
- if (o === void 0 && (o = !0),
- i.cameraRigMode === 0 || i.outputRenderTarget && i.outputRenderTarget.getViewCount() > 1 && this.getEngine().getCaps().multiview) {
- this._renderForCamera(i, void 0, o),
- this.onAfterRenderCameraObservable.notifyObservers(i);
- return
- }
- if (i._useMultiviewToSingleView)
- this._renderMultiviewToSingleView(i);
- else {
- this.onBeforeCameraRenderObservable.notifyObservers(i);
- for (var s = 0; s < i._rigCameras.length; s++)
- this._renderForCamera(i._rigCameras[s], i)
- }
- this._activeCamera = i,
- this.setTransformMatrix(this._activeCamera.getViewMatrix(), this._activeCamera.getProjectionMatrix()),
- this.onAfterRenderCameraObservable.notifyObservers(i)
- }
- ,
- e.prototype._checkIntersections = function() {
- for (var i = 0; i < this._meshesForIntersections.length; i++) {
- var o = this._meshesForIntersections.data[i];
- if (!!o.actionManager)
- for (var s = 0; o.actionManager && s < o.actionManager.actions.length; s++) {
- var c = o.actionManager.actions[s];
- if (c.trigger === 12 || c.trigger === 13) {
- var d = c.getTriggerParameter()
- , _ = d.mesh ? d.mesh : d
- , b = _.intersectsMesh(o, d.usePreciseIntersection)
- , k = o._intersectionsInProgress.indexOf(_);
- b && k === -1 ? c.trigger === 12 ? (c._executeCurrent(ActionEvent.CreateNew(o, void 0, _)),
- o._intersectionsInProgress.push(_)) : c.trigger === 13 && o._intersectionsInProgress.push(_) : !b && k > -1 && (c.trigger === 13 && c._executeCurrent(ActionEvent.CreateNew(o, void 0, _)),
- (!o.actionManager.hasSpecificTrigger(13, function(j) {
- var $ = j.mesh ? j.mesh : j;
- return _ === $
- }) || c.trigger === 13) && o._intersectionsInProgress.splice(k, 1))
- }
- }
- }
- }
- ,
- e.prototype._advancePhysicsEngineStep = function(i) {}
- ,
- e.prototype._animate = function() {}
- ,
- e.prototype.animate = function() {
- if (this._engine.isDeterministicLockStep()) {
- var i = Math.max(e.MinDeltaTime, Math.min(this._engine.getDeltaTime(), e.MaxDeltaTime)) + this._timeAccumulator
- , o = this._engine.getTimeStep()
- , s = 1e3 / o / 1e3
- , c = 0
- , d = this._engine.getLockstepMaxSteps()
- , _ = Math.floor(i / o);
- for (_ = Math.min(_, d); i > 0 && c < _; )
- this.onBeforeStepObservable.notifyObservers(this),
- this._animationRatio = o * s,
- this._animate(),
- this.onAfterAnimationsObservable.notifyObservers(this),
- this.physicsEnabled && this._advancePhysicsEngineStep(o),
- this.onAfterStepObservable.notifyObservers(this),
- this._currentStepId++,
- c++,
- i -= o;
- this._timeAccumulator = i < 0 ? 0 : i
- } else {
- var i = this.useConstantAnimationDeltaTime ? 16 : Math.max(e.MinDeltaTime, Math.min(this._engine.getDeltaTime(), e.MaxDeltaTime));
- this._animationRatio = i * (60 / 1e3),
- this._animate(),
- this.onAfterAnimationsObservable.notifyObservers(this),
- this.physicsEnabled && this._advancePhysicsEngineStep(i)
- }
- }
- ,
- e.prototype._clear = function() {
- (this.autoClearDepthAndStencil || this.autoClear) && this._engine.clear(this.clearColor, this.autoClear || this.forceWireframe || this.forcePointsCloud, this.autoClearDepthAndStencil, this.autoClearDepthAndStencil)
- }
- ,
- e.prototype.checkCameraRenderTarget = function(i) {
- var o;
- if ((i == null ? void 0 : i.outputRenderTarget) && !(i != null && i.isRigCamera) && (i.outputRenderTarget._cleared = !1),
- !((o = i == null ? void 0 : i.rigCameras) === null || o === void 0) && o.length)
- for (var s = 0; s < i.rigCameras.length; ++s) {
- var c = i.rigCameras[s].outputRenderTarget;
- c && (c._cleared = !1)
- }
- }
- ,
- e.prototype.resetDrawCache = function() {
- if (!!this.meshes)
- for (var i = 0, o = this.meshes; i < o.length; i++) {
- var s = o[i];
- s.resetDrawCache()
- }
- }
- ,
- e.prototype.render = function(i, o) {
- var s, c, d;
- if (i === void 0 && (i = !0),
- o === void 0 && (o = !1),
- !this.isDisposed) {
- this.onReadyObservable.hasObservers() && this._executeWhenReadyTimeoutId === -1 && this._checkIsReady(),
- this._frameId++,
- this._defaultFrameBufferCleared = !1,
- this.checkCameraRenderTarget(this.activeCamera),
- !((s = this.activeCameras) === null || s === void 0) && s.length && this.activeCameras.forEach(this.checkCameraRenderTarget),
- this._registerTransientComponents(),
- this._activeParticles.fetchNewFrame(),
- this._totalVertices.fetchNewFrame(),
- this._activeIndices.fetchNewFrame(),
- this._activeBones.fetchNewFrame(),
- this._meshesForIntersections.reset(),
- this.resetCachedMaterial(),
- this.onBeforeAnimationsObservable.notifyObservers(this),
- this.actionManager && this.actionManager.processTrigger(11),
- o || this.animate();
- for (var _ = 0, b = this._beforeCameraUpdateStage; _ < b.length; _++) {
- var k = b[_];
- k.action()
- }
- if (i) {
- if (this.activeCameras && this.activeCameras.length > 0)
- for (var j = 0; j < this.activeCameras.length; j++) {
- var $ = this.activeCameras[j];
- if ($.update(),
- $.cameraRigMode !== 0)
- for (var _e = 0; _e < $._rigCameras.length; _e++)
- $._rigCameras[_e].update()
- }
- else if (this.activeCamera && (this.activeCamera.update(),
- this.activeCamera.cameraRigMode !== 0))
- for (var _e = 0; _e < this.activeCamera._rigCameras.length; _e++)
- this.activeCamera._rigCameras[_e].update()
- }
- this.onBeforeRunRegisterBeforeRenderObservable.notifyObservers(this),
- this.onBeforeRenderObservable.notifyObservers(this),
- this.onAfterRunRegisterBeforeRenderObservable.notifyObservers(this),
- this.onBeforeRTT1Observable.notifyObservers(this);
- var et = this.getEngine();
- this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
- var tt = !((c = this.activeCameras) === null || c === void 0) && c.length ? this.activeCameras[0] : this.activeCamera;
- if (this.renderTargetsEnabled) {
- Tools.StartPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0),
- this._intermediateRendering = !0;
- for (var rt = 0; rt < this.customRenderTargets.length; rt++) {
- var it = this.customRenderTargets[rt];
- if (it._shouldRender()) {
- if (this._renderId++,
- this.activeCamera = it.activeCamera || this.activeCamera,
- !this.activeCamera)
- throw new Error("Active camera not set");
- et.setViewport(this.activeCamera.viewport),
- this.updateTransformMatrix(),
- it.render(tt !== this.activeCamera, this.dumpNextRenderTargets)
- }
- }
- Tools.EndPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0),
- this._intermediateRendering = !1,
- this._renderId++
- }
- this._engine.currentRenderPassId = (d = tt == null ? void 0 : tt.renderPassId) !== null && d !== void 0 ? d : 0,
- this.activeCamera = tt,
- this._activeCamera && this._activeCamera.cameraRigMode !== 22 && !this.prePass && this._bindFrameBuffer(this._activeCamera, !1),
- this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
- for (var nt = 0, ot = this._beforeClearStage; nt < ot.length; nt++) {
- var k = ot[nt];
- k.action()
- }
- this._clearFrameBuffer(this.activeCamera);
- for (var at = 0, st = this._gatherRenderTargetsStage; at < st.length; at++) {
- var k = st[at];
- k.action(this._renderTargets)
- }
- if (this.onAfterRTT1Observable.notifyObservers(this),
- this.activeCameras && this.activeCameras.length > 0)
- for (var j = 0; j < this.activeCameras.length; j++)
- this._processSubCameras(this.activeCameras[j], j > 0);
- else {
- if (!this.activeCamera)
- throw new Error("No camera defined");
- this._processSubCameras(this.activeCamera, !1)
- }
- this.onBeforeRunRegisterAfterRenderObservable.notifyObservers(this),
- this._checkIntersections();
- for (var ut = 0, ct = this._afterRenderStage; ut < ct.length; ut++) {
- var k = ct[ut];
- k.action()
- }
- if (this.afterRender && this.afterRender(),
- this.onAfterRenderObservable.notifyObservers(this),
- this.onAfterRunRegisterAfterRenderObservable.notifyObservers(this),
- this._toBeDisposed.length) {
- for (var _e = 0; _e < this._toBeDisposed.length; _e++) {
- var lt = this._toBeDisposed[_e];
- lt && lt.dispose()
- }
- this._toBeDisposed = []
- }
- this.dumpNextRenderTargets && (this.dumpNextRenderTargets = !1),
- this._activeBones.addCount(0, !0),
- this._activeIndices.addCount(0, !0),
- this._activeParticles.addCount(0, !0),
- this._engine.restoreDefaultFramebuffer()
- }
- }
- ,
- e.prototype.freezeMaterials = function() {
- for (var i = 0; i < this.materials.length; i++)
- this.materials[i].freeze()
- }
- ,
- e.prototype.unfreezeMaterials = function() {
- for (var i = 0; i < this.materials.length; i++)
- this.materials[i].unfreeze()
- }
- ,
- e.prototype.dispose = function() {
- var i;
- if (!this.isDisposed) {
- this.beforeRender = null,
- this.afterRender = null,
- this.metadata = null,
- this.skeletons = [],
- this.morphTargetManagers = [],
- this._transientComponents = [],
- this._isReadyForMeshStage.clear(),
- this._beforeEvaluateActiveMeshStage.clear(),
- this._evaluateSubMeshStage.clear(),
- this._preActiveMeshStage.clear(),
- this._cameraDrawRenderTargetStage.clear(),
- this._beforeCameraDrawStage.clear(),
- this._beforeRenderTargetDrawStage.clear(),
- this._beforeRenderingGroupDrawStage.clear(),
- this._beforeRenderingMeshStage.clear(),
- this._afterRenderingMeshStage.clear(),
- this._afterRenderingGroupDrawStage.clear(),
- this._afterCameraDrawStage.clear(),
- this._afterRenderTargetDrawStage.clear(),
- this._afterRenderStage.clear(),
- this._beforeCameraUpdateStage.clear(),
- this._beforeClearStage.clear(),
- this._gatherRenderTargetsStage.clear(),
- this._gatherActiveCameraRenderTargetsStage.clear(),
- this._pointerMoveStage.clear(),
- this._pointerDownStage.clear(),
- this._pointerUpStage.clear();
- for (var o = 0, s = this._components; o < s.length; o++) {
- var c = s[o];
- c.dispose()
- }
- this.importedMeshesFiles = new Array,
- this.stopAllAnimations && this.stopAllAnimations(),
- this.resetCachedMaterial(),
- this.activeCamera && (this.activeCamera._activeMeshes.dispose(),
- this.activeCamera = null),
- this._activeMeshes.dispose(),
- this._renderingManager.dispose(),
- this._processedMaterials.dispose(),
- this._activeParticleSystems.dispose(),
- this._activeSkeletons.dispose(),
- this._softwareSkinnedMeshes.dispose(),
- this._renderTargets.dispose(),
- this._registeredForLateAnimationBindings.dispose(),
- this._meshesForIntersections.dispose(),
- this._toBeDisposed = [];
- for (var d = 0, _ = this._activeRequests; d < _.length; d++) {
- var b = _[d];
- b.abort()
- }
- this.onBeforeRunRegisterBeforeRenderObservable.clear(),
- this.onAfterRunRegisterBeforeRenderObservable.clear(),
- this.onBeforeRTT1Observable.clear(),
- this.onAfterRTT1Observable.clear(),
- this.onBeforeRunRegisterAfterRenderObservable.clear(),
- this.onAfterRunRegisterAfterRenderObservable.clear(),
- this.onDisposeObservable.notifyObservers(this),
- this.onDisposeObservable.clear(),
- this.onBeforeRenderObservable.clear(),
- this.onAfterRenderObservable.clear(),
- this.onBeforeRenderTargetsRenderObservable.clear(),
- this.onAfterRenderTargetsRenderObservable.clear(),
- this.onAfterStepObservable.clear(),
- this.onBeforeStepObservable.clear(),
- this.onBeforeActiveMeshesEvaluationObservable.clear(),
- this.onAfterActiveMeshesEvaluationObservable.clear(),
- this.onBeforeParticlesRenderingObservable.clear(),
- this.onAfterParticlesRenderingObservable.clear(),
- this.onBeforeDrawPhaseObservable.clear(),
- this.onAfterDrawPhaseObservable.clear(),
- this.onBeforeAnimationsObservable.clear(),
- this.onAfterAnimationsObservable.clear(),
- this.onDataLoadedObservable.clear(),
- this.onBeforeRenderingGroupObservable.clear(),
- this.onAfterRenderingGroupObservable.clear(),
- this.onMeshImportedObservable.clear(),
- this.onBeforeCameraRenderObservable.clear(),
- this.onAfterCameraRenderObservable.clear(),
- this.onReadyObservable.clear(),
- this.onNewCameraAddedObservable.clear(),
- this.onCameraRemovedObservable.clear(),
- this.onNewLightAddedObservable.clear(),
- this.onLightRemovedObservable.clear(),
- this.onNewGeometryAddedObservable.clear(),
- this.onGeometryRemovedObservable.clear(),
- this.onNewTransformNodeAddedObservable.clear(),
- this.onTransformNodeRemovedObservable.clear(),
- this.onNewMeshAddedObservable.clear(),
- this.onMeshRemovedObservable.clear(),
- this.onNewSkeletonAddedObservable.clear(),
- this.onSkeletonRemovedObservable.clear(),
- this.onNewMaterialAddedObservable.clear(),
- this.onNewMultiMaterialAddedObservable.clear(),
- this.onMaterialRemovedObservable.clear(),
- this.onMultiMaterialRemovedObservable.clear(),
- this.onNewTextureAddedObservable.clear(),
- this.onTextureRemovedObservable.clear(),
- this.onPrePointerObservable.clear(),
- this.onPointerObservable.clear(),
- this.onPreKeyboardObservable.clear(),
- this.onKeyboardObservable.clear(),
- this.onActiveCameraChanged.clear(),
- this.onComputePressureChanged.clear(),
- (i = this._computePressureObserver) === null || i === void 0 || i.unobserve(),
- this._computePressureObserver = void 0,
- this.detachControl();
- var k = this._engine.getInputElement();
- if (k) {
- var j;
- for (j = 0; j < this.cameras.length; j++)
- this.cameras[j].detachControl()
- }
- for (; this.animationGroups.length; )
- this.animationGroups[0].dispose();
- for (; this.lights.length; )
- this.lights[0].dispose();
- for (; this.meshes.length; )
- this.meshes[0].dispose(!0);
- for (; this.transformNodes.length; )
- this.transformNodes[0].dispose(!0);
- for (; this.cameras.length; )
- this.cameras[0].dispose();
- for (this._defaultMaterial && this._defaultMaterial.dispose(); this.multiMaterials.length; )
- this.multiMaterials[0].dispose();
- for (; this.materials.length; )
- this.materials[0].dispose();
- for (; this.particleSystems.length; )
- this.particleSystems[0].dispose();
- for (; this.postProcesses.length; )
- this.postProcesses[0].dispose();
- for (; this.textures.length; )
- this.textures[0].dispose();
- for (; this.morphTargetManagers.length; )
- this.morphTargetManagers[0].dispose();
- this._sceneUbo.dispose(),
- this._multiviewSceneUbo && this._multiviewSceneUbo.dispose(),
- this.postProcessManager.dispose(),
- j = this._engine.scenes.indexOf(this),
- j > -1 && this._engine.scenes.splice(j, 1),
- EngineStore._LastCreatedScene === this && (this._engine.scenes.length > 0 ? EngineStore._LastCreatedScene = this._engine.scenes[this._engine.scenes.length - 1] : EngineStore._LastCreatedScene = null),
- j = this._engine._virtualScenes.indexOf(this),
- j > -1 && this._engine._virtualScenes.splice(j, 1),
- this._engine.wipeCaches(!0),
- this._isDisposed = !0
- }
- }
- ,
- Object.defineProperty(e.prototype, "isDisposed", {
- get: function() {
- return this._isDisposed
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.clearCachedVertexData = function() {
- for (var i = 0; i < this.meshes.length; i++) {
- var o = this.meshes[i]
- , s = o.geometry;
- s && s.clearCachedData()
- }
- }
- ,
- e.prototype.cleanCachedTextureBuffer = function() {
- for (var i = 0, o = this.textures; i < o.length; i++) {
- var s = o[i]
- , c = s._buffer;
- c && (s._buffer = null)
- }
- }
- ,
- e.prototype.getWorldExtends = function(i) {
- var o = new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)
- , s = new Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);
- return i = i || function() {
- return !0
- }
- ,
- this.meshes.filter(i).forEach(function(c) {
- if (c.computeWorldMatrix(!0),
- !(!c.subMeshes || c.subMeshes.length === 0 || c.infiniteDistance)) {
- var d = c.getBoundingInfo()
- , _ = d.boundingBox.minimumWorld
- , b = d.boundingBox.maximumWorld;
- Vector3.CheckExtends(_, o, s),
- Vector3.CheckExtends(b, o, s)
- }
- }),
- {
- min: o,
- max: s
- }
- }
- ,
- e.prototype.createPickingRay = function(i, o, s, c, d) {
- throw _WarnImport("Ray")
- }
- ,
- e.prototype.createPickingRayToRef = function(i, o, s, c, d, _) {
- throw _WarnImport("Ray")
- }
- ,
- e.prototype.createPickingRayInCameraSpace = function(i, o, s) {
- throw _WarnImport("Ray")
- }
- ,
- e.prototype.createPickingRayInCameraSpaceToRef = function(i, o, s, c) {
- throw _WarnImport("Ray")
- }
- ,
- e.prototype.pick = function(i, o, s, c, d, _) {
- var b = new PickingInfo;
- return b._pickingUnavailable = !0,
- b
- }
- ,
- e.prototype.pickWithBoundingInfo = function(i, o, s, c, d) {
- var _ = new PickingInfo;
- return _._pickingUnavailable = !0,
- _
- }
- ,
- e.prototype.pickWithRay = function(i, o, s, c) {
- throw _WarnImport("Ray")
- }
- ,
- e.prototype.multiPick = function(i, o, s, c, d) {
- throw _WarnImport("Ray")
- }
- ,
- e.prototype.multiPickWithRay = function(i, o, s) {
- throw _WarnImport("Ray")
- }
- ,
- e.prototype.setPointerOverMesh = function(i, o, s) {
- this._inputManager.setPointerOverMesh(i, o, s)
- }
- ,
- e.prototype.getPointerOverMesh = function() {
- return this._inputManager.getPointerOverMesh()
- }
- ,
- e.prototype._rebuildGeometries = function() {
- for (var i = 0, o = this.geometries; i < o.length; i++) {
- var s = o[i];
- s._rebuild()
- }
- for (var c = 0, d = this.meshes; c < d.length; c++) {
- var _ = d[c];
- _._rebuild()
- }
- this.postProcessManager && this.postProcessManager._rebuild();
- for (var b = 0, k = this._components; b < k.length; b++) {
- var j = k[b];
- j.rebuild()
- }
- for (var $ = 0, _e = this.particleSystems; $ < _e.length; $++) {
- var et = _e[$];
- et.rebuild()
- }
- if (this.spriteManagers)
- for (var tt = 0, rt = this.spriteManagers; tt < rt.length; tt++) {
- var it = rt[tt];
- it.rebuild()
- }
- }
- ,
- e.prototype._rebuildTextures = function() {
- for (var i = 0, o = this.textures; i < o.length; i++) {
- var s = o[i];
- s._rebuild()
- }
- this.markAllMaterialsAsDirty(1)
- }
- ,
- e.prototype._getByTags = function(i, o, s) {
- if (o === void 0)
- return i;
- var c = [];
- s = s || function(b) {}
- ;
- for (var d in i) {
- var _ = i[d];
- Tags && Tags.MatchesQuery(_, o) && (c.push(_),
- s(_))
- }
- return c
- }
- ,
- e.prototype.getMeshesByTags = function(i, o) {
- return this._getByTags(this.meshes, i, o)
- }
- ,
- e.prototype.getCamerasByTags = function(i, o) {
- return this._getByTags(this.cameras, i, o)
- }
- ,
- e.prototype.getLightsByTags = function(i, o) {
- return this._getByTags(this.lights, i, o)
- }
- ,
- e.prototype.getMaterialByTags = function(i, o) {
- return this._getByTags(this.materials, i, o).concat(this._getByTags(this.multiMaterials, i, o))
- }
- ,
- e.prototype.getTransformNodesByTags = function(i, o) {
- return this._getByTags(this.transformNodes, i, o)
- }
- ,
- e.prototype.setRenderingOrder = function(i, o, s, c) {
- o === void 0 && (o = null),
- s === void 0 && (s = null),
- c === void 0 && (c = null),
- this._renderingManager.setRenderingOrder(i, o, s, c)
- }
- ,
- e.prototype.setRenderingAutoClearDepthStencil = function(i, o, s, c) {
- s === void 0 && (s = !0),
- c === void 0 && (c = !0),
- this._renderingManager.setRenderingAutoClearDepthStencil(i, o, s, c)
- }
- ,
- e.prototype.getAutoClearDepthStencilSetup = function(i) {
- return this._renderingManager.getAutoClearDepthStencilSetup(i)
- }
- ,
- Object.defineProperty(e.prototype, "blockMaterialDirtyMechanism", {
- get: function() {
- return this._blockMaterialDirtyMechanism
- },
- set: function(i) {
- this._blockMaterialDirtyMechanism !== i && (this._blockMaterialDirtyMechanism = i,
- i || this.markAllMaterialsAsDirty(63))
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.markAllMaterialsAsDirty = function(i, o) {
- if (!this._blockMaterialDirtyMechanism)
- for (var s = 0, c = this.materials; s < c.length; s++) {
- var d = c[s];
- o && !o(d) || d.markAsDirty(i)
- }
- }
- ,
- e.prototype._loadFile = function(i, o, s, c, d, _, b) {
- var k = this
- , j = LoadFile(i, o, s, c ? this.offlineProvider : void 0, d, _, b);
- return this._activeRequests.push(j),
- j.onCompleteObservable.add(function($) {
- k._activeRequests.splice(k._activeRequests.indexOf($), 1)
- }),
- j
- }
- ,
- e.prototype._loadFileAsync = function(i, o, s, c, d) {
- var _ = this;
- return new Promise(function(b, k) {
- _._loadFile(i, function(j) {
- b(j)
- }, o, s, c, function(j, $) {
- k($)
- }, d)
- }
- )
- }
- ,
- e.prototype._requestFile = function(i, o, s, c, d, _, b) {
- var k = this
- , j = RequestFile(i, o, s, c ? this.offlineProvider : void 0, d, _, b);
- return this._activeRequests.push(j),
- j.onCompleteObservable.add(function($) {
- k._activeRequests.splice(k._activeRequests.indexOf($), 1)
- }),
- j
- }
- ,
- e.prototype._requestFileAsync = function(i, o, s, c, d) {
- var _ = this;
- return new Promise(function(b, k) {
- _._requestFile(i, function(j) {
- b(j)
- }, o, s, c, function(j) {
- k(j)
- }, d)
- }
- )
- }
- ,
- e.prototype._readFile = function(i, o, s, c, d) {
- var _ = this
- , b = ReadFile(i, o, s, c, d);
- return this._activeRequests.push(b),
- b.onCompleteObservable.add(function(k) {
- _._activeRequests.splice(_._activeRequests.indexOf(k), 1)
- }),
- b
- }
- ,
- e.prototype._readFileAsync = function(i, o, s) {
- var c = this;
- return new Promise(function(d, _) {
- c._readFile(i, function(b) {
- d(b)
- }, o, s, function(b) {
- _(b)
- })
- }
- )
- }
- ,
- e.prototype.getPerfCollector = function() {
- throw _WarnImport("performanceViewerSceneExtension")
- }
- ,
- e.FOGMODE_NONE = 0,
- e.FOGMODE_EXP = 1,
- e.FOGMODE_EXP2 = 2,
- e.FOGMODE_LINEAR = 3,
- e.MinDeltaTime = 1,
- e.MaxDeltaTime = 1e3,
- e
- }(AbstractScene);
- _injectLTSScene(Scene);
- var Size = function() {
- function a(e, i) {
- this.width = e,
- this.height = i
- }
- return a.prototype.toString = function() {
- return "{W: " + this.width + ", H: " + this.height + "}"
- }
- ,
- a.prototype.getClassName = function() {
- return "Size"
- }
- ,
- a.prototype.getHashCode = function() {
- var e = this.width | 0;
- return e = e * 397 ^ (this.height | 0),
- e
- }
- ,
- a.prototype.copyFrom = function(e) {
- this.width = e.width,
- this.height = e.height
- }
- ,
- a.prototype.copyFromFloats = function(e, i) {
- return this.width = e,
- this.height = i,
- this
- }
- ,
- a.prototype.set = function(e, i) {
- return this.copyFromFloats(e, i)
- }
- ,
- a.prototype.multiplyByFloats = function(e, i) {
- return new a(this.width * e,this.height * i)
- }
- ,
- a.prototype.clone = function() {
- return new a(this.width,this.height)
- }
- ,
- a.prototype.equals = function(e) {
- return e ? this.width === e.width && this.height === e.height : !1
- }
- ,
- Object.defineProperty(a.prototype, "surface", {
- get: function() {
- return this.width * this.height
- },
- enumerable: !1,
- configurable: !0
- }),
- a.Zero = function() {
- return new a(0,0)
- }
- ,
- a.prototype.add = function(e) {
- var i = new a(this.width + e.width,this.height + e.height);
- return i
- }
- ,
- a.prototype.subtract = function(e) {
- var i = new a(this.width - e.width,this.height - e.height);
- return i
- }
- ,
- a.Lerp = function(e, i, o) {
- var s = e.width + (i.width - e.width) * o
- , c = e.height + (i.height - e.height) * o;
- return new a(s,c)
- }
- ,
- a
- }()
- , ThinTexture = function() {
- function a(e) {
- this._wrapU = 1,
- this._wrapV = 1,
- this.wrapR = 1,
- this.anisotropicFilteringLevel = 4,
- this.delayLoadState = 0,
- this._texture = null,
- this._engine = null,
- this._cachedSize = Size.Zero(),
- this._cachedBaseSize = Size.Zero(),
- this._initialSamplingMode = 2,
- this._texture = e,
- this._texture && (this._engine = this._texture.getEngine())
- }
- return Object.defineProperty(a.prototype, "wrapU", {
- get: function() {
- return this._wrapU
- },
- set: function(e) {
- this._wrapU = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "wrapV", {
- get: function() {
- return this._wrapV
- },
- set: function(e) {
- this._wrapV = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "coordinatesMode", {
- get: function() {
- return 0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "isCube", {
- get: function() {
- return this._texture ? this._texture.isCube : !1
- },
- set: function(e) {
- !this._texture || (this._texture.isCube = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "is3D", {
- get: function() {
- return this._texture ? this._texture.is3D : !1
- },
- set: function(e) {
- !this._texture || (this._texture.is3D = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "is2DArray", {
- get: function() {
- return this._texture ? this._texture.is2DArray : !1
- },
- set: function(e) {
- !this._texture || (this._texture.is2DArray = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.getClassName = function() {
- return "ThinTexture"
- }
- ,
- a.prototype.isReady = function() {
- return this.delayLoadState === 4 ? (this.delayLoad(),
- !1) : this._texture ? this._texture.isReady : !1
- }
- ,
- a.prototype.delayLoad = function() {}
- ,
- a.prototype.getInternalTexture = function() {
- return this._texture
- }
- ,
- a.prototype.getSize = function() {
- if (this._texture) {
- if (this._texture.width)
- return this._cachedSize.width = this._texture.width,
- this._cachedSize.height = this._texture.height,
- this._cachedSize;
- if (this._texture._size)
- return this._cachedSize.width = this._texture._size,
- this._cachedSize.height = this._texture._size,
- this._cachedSize
- }
- return this._cachedSize
- }
- ,
- a.prototype.getBaseSize = function() {
- return !this.isReady() || !this._texture ? (this._cachedBaseSize.width = 0,
- this._cachedBaseSize.height = 0,
- this._cachedBaseSize) : this._texture._size ? (this._cachedBaseSize.width = this._texture._size,
- this._cachedBaseSize.height = this._texture._size,
- this._cachedBaseSize) : (this._cachedBaseSize.width = this._texture.baseWidth,
- this._cachedBaseSize.height = this._texture.baseHeight,
- this._cachedBaseSize)
- }
- ,
- Object.defineProperty(a.prototype, "samplingMode", {
- get: function() {
- return this._texture ? this._texture.samplingMode : this._initialSamplingMode
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.updateSamplingMode = function(e) {
- this._texture && this._engine && this._engine.updateTextureSamplingMode(e, this._texture)
- }
- ,
- a.prototype.releaseInternalTexture = function() {
- this._texture && (this._texture.dispose(),
- this._texture = null)
- }
- ,
- a.prototype.dispose = function() {
- this._texture && (this.releaseInternalTexture(),
- this._engine = null)
- }
- ,
- a
- }()
- , BaseTexture = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, null) || this;
- return o.metadata = null,
- o.reservedDataStore = null,
- o._hasAlpha = !1,
- o.getAlphaFromRGB = !1,
- o.level = 1,
- o.coordinatesIndex = 0,
- o._coordinatesMode = 0,
- o.wrapR = 1,
- o.anisotropicFilteringLevel = e.DEFAULT_ANISOTROPIC_FILTERING_LEVEL,
- o._isCube = !1,
- o._gammaSpace = !0,
- o.invertZ = !1,
- o.lodLevelInAlpha = !1,
- o.isRenderTarget = !1,
- o._prefiltered = !1,
- o._forceSerialize = !1,
- o.animations = new Array,
- o.onDisposeObservable = new Observable,
- o._onDisposeObserver = null,
- o._scene = null,
- o._uid = null,
- o._parentContainer = null,
- o._loadingError = !1,
- i ? e._isScene(i) ? o._scene = i : o._engine = i : o._scene = EngineStore.LastCreatedScene,
- o._scene && (o.uniqueId = o._scene.getUniqueId(),
- o._scene.addTexture(o),
- o._engine = o._scene.getEngine()),
- o._uid = null,
- o
- }
- return Object.defineProperty(e.prototype, "hasAlpha", {
- get: function() {
- return this._hasAlpha
- },
- set: function(i) {
- this._hasAlpha !== i && (this._hasAlpha = i,
- this._scene && this._scene.markAllMaterialsAsDirty(17))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "coordinatesMode", {
- get: function() {
- return this._coordinatesMode
- },
- set: function(i) {
- this._coordinatesMode !== i && (this._coordinatesMode = i,
- this._scene && this._scene.markAllMaterialsAsDirty(1))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "wrapU", {
- get: function() {
- return this._wrapU
- },
- set: function(i) {
- this._wrapU = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "wrapV", {
- get: function() {
- return this._wrapV
- },
- set: function(i) {
- this._wrapV = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isCube", {
- get: function() {
- return this._texture ? this._texture.isCube : this._isCube
- },
- set: function(i) {
- this._texture ? this._texture.isCube = i : this._isCube = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "is3D", {
- get: function() {
- return this._texture ? this._texture.is3D : !1
- },
- set: function(i) {
- !this._texture || (this._texture.is3D = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "is2DArray", {
- get: function() {
- return this._texture ? this._texture.is2DArray : !1
- },
- set: function(i) {
- !this._texture || (this._texture.is2DArray = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "gammaSpace", {
- get: function() {
- if (this._texture)
- this._texture._gammaSpace === null && (this._texture._gammaSpace = this._gammaSpace);
- else
- return this._gammaSpace;
- return this._texture._gammaSpace && !this._texture._useSRGBBuffer
- },
- set: function(i) {
- if (this._texture) {
- if (this._texture._gammaSpace === i)
- return;
- this._texture._gammaSpace = i
- } else {
- if (this._gammaSpace === i)
- return;
- this._gammaSpace = i
- }
- this._markAllSubMeshesAsTexturesDirty()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isRGBD", {
- get: function() {
- return this._texture != null && this._texture._isRGBD
- },
- set: function(i) {
- this._texture && (this._texture._isRGBD = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "noMipmap", {
- get: function() {
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "lodGenerationOffset", {
- get: function() {
- return this._texture ? this._texture._lodGenerationOffset : 0
- },
- set: function(i) {
- this._texture && (this._texture._lodGenerationOffset = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "lodGenerationScale", {
- get: function() {
- return this._texture ? this._texture._lodGenerationScale : 0
- },
- set: function(i) {
- this._texture && (this._texture._lodGenerationScale = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "linearSpecularLOD", {
- get: function() {
- return this._texture ? this._texture._linearSpecularLOD : !1
- },
- set: function(i) {
- this._texture && (this._texture._linearSpecularLOD = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "irradianceTexture", {
- get: function() {
- return this._texture ? this._texture._irradianceTexture : null
- },
- set: function(i) {
- this._texture && (this._texture._irradianceTexture = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "uid", {
- get: function() {
- return this._uid || (this._uid = RandomGUID()),
- this._uid
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.toString = function() {
- return this.name
- }
- ,
- e.prototype.getClassName = function() {
- return "BaseTexture"
- }
- ,
- Object.defineProperty(e.prototype, "onDispose", {
- set: function(i) {
- this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver),
- this._onDisposeObserver = this.onDisposeObservable.add(i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isBlocking", {
- get: function() {
- return !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "loadingError", {
- get: function() {
- return this._loadingError
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "errorObject", {
- get: function() {
- return this._errorObject
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getScene = function() {
- return this._scene
- }
- ,
- e.prototype._getEngine = function() {
- return this._engine
- }
- ,
- e.prototype.checkTransformsAreIdentical = function(i) {
- return i !== null
- }
- ,
- e.prototype.getTextureMatrix = function() {
- return Matrix.IdentityReadOnly
- }
- ,
- e.prototype.getReflectionTextureMatrix = function() {
- return Matrix.IdentityReadOnly
- }
- ,
- e.prototype.isReadyOrNotBlocking = function() {
- return !this.isBlocking || this.isReady() || this.loadingError
- }
- ,
- e.prototype.scale = function(i) {}
- ,
- Object.defineProperty(e.prototype, "canRescale", {
- get: function() {
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._getFromCache = function(i, o, s, c, d) {
- var _ = this._getEngine();
- if (!_)
- return null;
- for (var b = _._getUseSRGBBuffer(!!d, o), k = _.getLoadedTexturesCache(), j = 0; j < k.length; j++) {
- var $ = k[j];
- if ((d === void 0 || b === $._useSRGBBuffer) && (c === void 0 || c === $.invertY) && $.url === i && $.generateMipMaps === !o && (!s || s === $.samplingMode))
- return $.incrementReferences(),
- $
- }
- return null
- }
- ,
- e.prototype._rebuild = function() {}
- ,
- e.prototype.clone = function() {
- return null
- }
- ,
- Object.defineProperty(e.prototype, "textureType", {
- get: function() {
- return this._texture && this._texture.type !== void 0 ? this._texture.type : 0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "textureFormat", {
- get: function() {
- return this._texture && this._texture.format !== void 0 ? this._texture.format : 5
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._markAllSubMeshesAsTexturesDirty = function() {
- var i = this.getScene();
- !i || i.markAllMaterialsAsDirty(1)
- }
- ,
- e.prototype.readPixels = function(i, o, s, c, d) {
- if (i === void 0 && (i = 0),
- o === void 0 && (o = 0),
- s === void 0 && (s = null),
- c === void 0 && (c = !0),
- d === void 0 && (d = !1),
- !this._texture)
- return null;
- var _ = this.getSize()
- , b = _.width
- , k = _.height
- , j = this._getEngine();
- if (!j)
- return null;
- o != 0 && (b = b / Math.pow(2, o),
- k = k / Math.pow(2, o),
- b = Math.round(b),
- k = Math.round(k));
- try {
- 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)
- } catch {
- return null
- }
- }
- ,
- e.prototype._readPixelsSync = function(i, o, s, c, d) {
- if (i === void 0 && (i = 0),
- o === void 0 && (o = 0),
- s === void 0 && (s = null),
- c === void 0 && (c = !0),
- d === void 0 && (d = !1),
- !this._texture)
- return null;
- var _ = this.getSize()
- , b = _.width
- , k = _.height
- , j = this._getEngine();
- if (!j)
- return null;
- o != 0 && (b = b / Math.pow(2, o),
- k = k / Math.pow(2, o),
- b = Math.round(b),
- k = Math.round(k));
- try {
- 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)
- } catch {
- return null
- }
- }
- ,
- Object.defineProperty(e.prototype, "_lodTextureHigh", {
- get: function() {
- return this._texture ? this._texture._lodTextureHigh : null
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "_lodTextureMid", {
- get: function() {
- return this._texture ? this._texture._lodTextureMid : null
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "_lodTextureLow", {
- get: function() {
- return this._texture ? this._texture._lodTextureLow : null
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.dispose = function() {
- if (this._scene) {
- this._scene.stopAnimation && this._scene.stopAnimation(this),
- this._scene._removePendingData(this);
- var i = this._scene.textures.indexOf(this);
- if (i >= 0 && this._scene.textures.splice(i, 1),
- this._scene.onTextureRemovedObservable.notifyObservers(this),
- this._scene = null,
- this._parentContainer) {
- var o = this._parentContainer.textures.indexOf(this);
- o > -1 && this._parentContainer.textures.splice(o, 1),
- this._parentContainer = null
- }
- }
- this.onDisposeObservable.notifyObservers(this),
- this.onDisposeObservable.clear(),
- this.metadata = null,
- a.prototype.dispose.call(this)
- }
- ,
- e.prototype.serialize = function() {
- if (!this.name)
- return null;
- var i = SerializationHelper.Serialize(this);
- return SerializationHelper.AppendSerializedAnimations(this, i),
- i
- }
- ,
- e.WhenAllReady = function(i, o) {
- var s = i.length;
- if (s === 0) {
- o();
- return
- }
- for (var c = 0; c < i.length; c++) {
- var d = i[c];
- if (d.isReady())
- --s === 0 && o();
- else {
- var _ = d.onLoadObservable;
- _ && _.addOnce(function() {
- --s === 0 && o()
- })
- }
- }
- }
- ,
- e._isScene = function(i) {
- return i.getClassName() === "Scene"
- }
- ,
- e.DEFAULT_ANISOTROPIC_FILTERING_LEVEL = 4,
- __decorate([serialize()], e.prototype, "uniqueId", void 0),
- __decorate([serialize()], e.prototype, "name", void 0),
- __decorate([serialize()], e.prototype, "metadata", void 0),
- __decorate([serialize("hasAlpha")], e.prototype, "_hasAlpha", void 0),
- __decorate([serialize()], e.prototype, "getAlphaFromRGB", void 0),
- __decorate([serialize()], e.prototype, "level", void 0),
- __decorate([serialize()], e.prototype, "coordinatesIndex", void 0),
- __decorate([serialize("coordinatesMode")], e.prototype, "_coordinatesMode", void 0),
- __decorate([serialize()], e.prototype, "wrapU", null),
- __decorate([serialize()], e.prototype, "wrapV", null),
- __decorate([serialize()], e.prototype, "wrapR", void 0),
- __decorate([serialize()], e.prototype, "anisotropicFilteringLevel", void 0),
- __decorate([serialize()], e.prototype, "isCube", null),
- __decorate([serialize()], e.prototype, "is3D", null),
- __decorate([serialize()], e.prototype, "is2DArray", null),
- __decorate([serialize()], e.prototype, "gammaSpace", null),
- __decorate([serialize()], e.prototype, "invertZ", void 0),
- __decorate([serialize()], e.prototype, "lodLevelInAlpha", void 0),
- __decorate([serialize()], e.prototype, "lodGenerationOffset", null),
- __decorate([serialize()], e.prototype, "lodGenerationScale", null),
- __decorate([serialize()], e.prototype, "linearSpecularLOD", null),
- __decorate([serializeAsTexture()], e.prototype, "irradianceTexture", null),
- __decorate([serialize()], e.prototype, "isRenderTarget", void 0),
- e
- }(ThinTexture);
- function GenerateBase64StringFromPixelData(a, e, i) {
- i === void 0 && (i = !1);
- var o = e.width
- , s = e.height;
- if (a instanceof Float32Array) {
- for (var c = a.byteLength / a.BYTES_PER_ELEMENT, d = new Uint8Array(c); --c >= 0; ) {
- var _ = a[c];
- _ < 0 ? _ = 0 : _ > 1 && (_ = 1),
- d[c] = _ * 255
- }
- a = d
- }
- var b = document.createElement("canvas");
- b.width = o,
- b.height = s;
- var k = b.getContext("2d");
- if (!k)
- return null;
- var j = k.createImageData(o, s)
- , $ = j.data;
- if ($.set(a),
- k.putImageData(j, 0, 0),
- i) {
- var _e = document.createElement("canvas");
- _e.width = o,
- _e.height = s;
- var et = _e.getContext("2d");
- return et ? (et.translate(0, s),
- et.scale(1, -1),
- et.drawImage(b, 0, 0),
- _e.toDataURL("image/png")) : null
- }
- return b.toDataURL("image/png")
- }
- function GenerateBase64StringFromTexture(a, e, i) {
- e === void 0 && (e = 0),
- i === void 0 && (i = 0);
- var o = a.getInternalTexture();
- if (!o)
- return null;
- var s = a._readPixelsSync(e, i);
- return s ? GenerateBase64StringFromPixelData(s, a.getSize(), o.invertY) : null
- }
- function GenerateBase64StringFromTextureAsync(a, e, i) {
- return e === void 0 && (e = 0),
- i === void 0 && (i = 0),
- __awaiter(this, void 0, void 0, function() {
- var o, s;
- return __generator(this, function(c) {
- switch (c.label) {
- case 0:
- return o = a.getInternalTexture(),
- o ? [4, a.readPixels(e, i)] : [2, null];
- case 1:
- return s = c.sent(),
- s ? [2, GenerateBase64StringFromPixelData(s, a.getSize(), o.invertY)] : [2, null]
- }
- })
- })
- }
- var Texture = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _, b, k, j, $, _e, et, tt) {
- c === void 0 && (c = !0),
- d === void 0 && (d = e.TRILINEAR_SAMPLINGMODE),
- _ === void 0 && (_ = null),
- b === void 0 && (b = null),
- k === void 0 && (k = null),
- j === void 0 && (j = !1);
- var rt, it, nt, ot, at, st, ut, ct, lt = a.call(this, o) || this;
- lt.url = null,
- lt.uOffset = 0,
- lt.vOffset = 0,
- lt.uScale = 1,
- lt.vScale = 1,
- lt.uAng = 0,
- lt.vAng = 0,
- lt.wAng = 0,
- lt.uRotationCenter = .5,
- lt.vRotationCenter = .5,
- lt.wRotationCenter = .5,
- lt.homogeneousRotationInUVTransform = !1,
- lt.inspectableCustomProperties = null,
- lt._noMipmap = !1,
- lt._invertY = !1,
- lt._rowGenerationMatrix = null,
- lt._cachedTextureMatrix = null,
- lt._projectionModeMatrix = null,
- lt._t0 = null,
- lt._t1 = null,
- lt._t2 = null,
- lt._cachedUOffset = -1,
- lt._cachedVOffset = -1,
- lt._cachedUScale = 0,
- lt._cachedVScale = 0,
- lt._cachedUAng = -1,
- lt._cachedVAng = -1,
- lt._cachedWAng = -1,
- lt._cachedProjectionMatrixId = -1,
- lt._cachedURotationCenter = -1,
- lt._cachedVRotationCenter = -1,
- lt._cachedWRotationCenter = -1,
- lt._cachedHomogeneousRotationInUVTransform = !1,
- lt._cachedCoordinatesMode = -1,
- lt._buffer = null,
- lt._deleteBuffer = !1,
- lt._format = null,
- lt._delayedOnLoad = null,
- lt._delayedOnError = null,
- lt.onLoadObservable = new Observable,
- lt._isBlocking = !0,
- lt.name = i || "",
- lt.url = i;
- var ft, ht = !1;
- typeof s == "object" && s !== null ? (ft = (rt = s.noMipmap) !== null && rt !== void 0 ? rt : !1,
- c = (it = s.invertY) !== null && it !== void 0 ? it : !0,
- d = (nt = s.samplingMode) !== null && nt !== void 0 ? nt : e.TRILINEAR_SAMPLINGMODE,
- _ = (ot = s.onLoad) !== null && ot !== void 0 ? ot : null,
- b = (at = s.onError) !== null && at !== void 0 ? at : null,
- k = (st = s.buffer) !== null && st !== void 0 ? st : null,
- j = (ut = s.deleteBuffer) !== null && ut !== void 0 ? ut : !1,
- $ = s.format,
- _e = s.mimeType,
- et = s.loaderOptions,
- tt = s.creationFlags,
- ht = (ct = s.useSRGBBuffer) !== null && ct !== void 0 ? ct : !1) : ft = !!s,
- lt._noMipmap = ft,
- lt._invertY = c,
- lt._initialSamplingMode = d,
- lt._buffer = k,
- lt._deleteBuffer = j,
- lt._mimeType = _e,
- lt._loaderOptions = et,
- lt._creationFlags = tt,
- lt._useSRGBBuffer = ht,
- $ && (lt._format = $);
- var pt = lt.getScene()
- , dt = lt._getEngine();
- if (!dt)
- return lt;
- dt.onBeforeTextureInitObservable.notifyObservers(lt);
- var _t = function() {
- lt._texture && (lt._texture._invertVScale && (lt.vScale *= -1,
- lt.vOffset += 1),
- lt._texture._cachedWrapU !== null && (lt.wrapU = lt._texture._cachedWrapU,
- lt._texture._cachedWrapU = null),
- lt._texture._cachedWrapV !== null && (lt.wrapV = lt._texture._cachedWrapV,
- lt._texture._cachedWrapV = null),
- lt._texture._cachedWrapR !== null && (lt.wrapR = lt._texture._cachedWrapR,
- lt._texture._cachedWrapR = null)),
- lt.onLoadObservable.hasObservers() && lt.onLoadObservable.notifyObservers(lt),
- _ && _(),
- !lt.isBlocking && pt && pt.resetCachedMaterial()
- }
- , mt = function(yt, Et) {
- lt._loadingError = !0,
- lt._errorObject = {
- message: yt,
- exception: Et
- },
- b && b(yt, Et),
- e.OnTextureLoadErrorObservable.notifyObservers(lt)
- };
- if (!lt.url)
- return lt._delayedOnLoad = _t,
- lt._delayedOnError = mt,
- lt;
- if (lt._texture = lt._getFromCache(lt.url, ft, d, c, ht),
- lt._texture)
- if (lt._texture.isReady)
- TimingTools.SetImmediate(function() {
- return _t()
- });
- else {
- var vt = lt._texture.onLoadedObservable.add(_t);
- lt._texture.onErrorObservable.add(function(yt) {
- var Et;
- mt(yt.message, yt.exception),
- (Et = lt._texture) === null || Et === void 0 || Et.onLoadedObservable.remove(vt)
- })
- }
- else if (!pt || !pt.useDelayedTextureLoading) {
- try {
- lt._texture = dt.createTexture(lt.url, ft, c, pt, d, _t, mt, lt._buffer, void 0, lt._format, null, _e, et, tt, ht)
- } catch (yt) {
- throw mt("error loading", yt),
- yt
- }
- j && (lt._buffer = null)
- } else
- lt.delayLoadState = 4,
- lt._delayedOnLoad = _t,
- lt._delayedOnError = mt;
- return lt
- }
- return Object.defineProperty(e.prototype, "noMipmap", {
- get: function() {
- return this._noMipmap
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "mimeType", {
- get: function() {
- return this._mimeType
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isBlocking", {
- get: function() {
- return this._isBlocking
- },
- set: function(i) {
- this._isBlocking = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "invertY", {
- get: function() {
- return this._invertY
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.updateURL = function(i, o, s) {
- o === void 0 && (o = null),
- this.url && (this.releaseInternalTexture(),
- this.getScene().markAllMaterialsAsDirty(1)),
- (!this.name || StartsWith(this.name, "data:")) && (this.name = i),
- this.url = i,
- this._buffer = o,
- this.delayLoadState = 4,
- s && (this._delayedOnLoad = s),
- this.delayLoad()
- }
- ,
- e.prototype.delayLoad = function() {
- if (this.delayLoadState === 4) {
- var i = this.getScene();
- !i || (this.delayLoadState = 1,
- this._texture = this._getFromCache(this.url, this._noMipmap, this.samplingMode, this._invertY, this._useSRGBBuffer),
- 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),
- this._deleteBuffer && (this._buffer = null)),
- this._delayedOnLoad = null,
- this._delayedOnError = null)
- }
- }
- ,
- e.prototype._prepareRowForTextureGeneration = function(i, o, s, c) {
- i *= this._cachedUScale,
- o *= this._cachedVScale,
- i -= this.uRotationCenter * this._cachedUScale,
- o -= this.vRotationCenter * this._cachedVScale,
- s -= this.wRotationCenter,
- Vector3.TransformCoordinatesFromFloatsToRef(i, o, s, this._rowGenerationMatrix, c),
- c.x += this.uRotationCenter * this._cachedUScale + this._cachedUOffset,
- c.y += this.vRotationCenter * this._cachedVScale + this._cachedVOffset,
- c.z += this.wRotationCenter
- }
- ,
- e.prototype.checkTransformsAreIdentical = function(i) {
- 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
- }
- ,
- e.prototype.getTextureMatrix = function(i) {
- var o = this;
- if (i === void 0 && (i = 1),
- 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)
- return this._cachedTextureMatrix;
- this._cachedUOffset = this.uOffset,
- this._cachedVOffset = this.vOffset,
- this._cachedUScale = this.uScale * i,
- this._cachedVScale = this.vScale,
- this._cachedUAng = this.uAng,
- this._cachedVAng = this.vAng,
- this._cachedWAng = this.wAng,
- this._cachedURotationCenter = this.uRotationCenter,
- this._cachedVRotationCenter = this.vRotationCenter,
- this._cachedWRotationCenter = this.wRotationCenter,
- this._cachedHomogeneousRotationInUVTransform = this.homogeneousRotationInUVTransform,
- (!this._cachedTextureMatrix || !this._rowGenerationMatrix) && (this._cachedTextureMatrix = Matrix.Zero(),
- this._rowGenerationMatrix = new Matrix,
- this._t0 = Vector3.Zero(),
- this._t1 = Vector3.Zero(),
- this._t2 = Vector3.Zero()),
- Matrix.RotationYawPitchRollToRef(this.vAng, this.uAng, this.wAng, this._rowGenerationMatrix),
- this.homogeneousRotationInUVTransform ? (Matrix.TranslationToRef(-this._cachedURotationCenter, -this._cachedVRotationCenter, -this._cachedWRotationCenter, TmpVectors.Matrix[0]),
- Matrix.TranslationToRef(this._cachedURotationCenter, this._cachedVRotationCenter, this._cachedWRotationCenter, TmpVectors.Matrix[1]),
- Matrix.ScalingToRef(this._cachedUScale, this._cachedVScale, 0, TmpVectors.Matrix[2]),
- Matrix.TranslationToRef(this._cachedUOffset, this._cachedVOffset, 0, TmpVectors.Matrix[3]),
- TmpVectors.Matrix[0].multiplyToRef(this._rowGenerationMatrix, this._cachedTextureMatrix),
- this._cachedTextureMatrix.multiplyToRef(TmpVectors.Matrix[1], this._cachedTextureMatrix),
- this._cachedTextureMatrix.multiplyToRef(TmpVectors.Matrix[2], this._cachedTextureMatrix),
- this._cachedTextureMatrix.multiplyToRef(TmpVectors.Matrix[3], this._cachedTextureMatrix),
- this._cachedTextureMatrix.setRowFromFloats(2, this._cachedTextureMatrix.m[12], this._cachedTextureMatrix.m[13], this._cachedTextureMatrix.m[14], 1)) : (this._prepareRowForTextureGeneration(0, 0, 0, this._t0),
- this._prepareRowForTextureGeneration(1, 0, 0, this._t1),
- this._prepareRowForTextureGeneration(0, 1, 0, this._t2),
- this._t1.subtractInPlace(this._t0),
- this._t2.subtractInPlace(this._t0),
- 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));
- var s = this.getScene();
- return s ? (s.markAllMaterialsAsDirty(1, function(c) {
- return c.hasTexture(o)
- }),
- this._cachedTextureMatrix) : this._cachedTextureMatrix
- }
- ,
- e.prototype.getReflectionTextureMatrix = function() {
- var i = this
- , o = this.getScene();
- if (!o)
- return this._cachedTextureMatrix;
- if (this.uOffset === this._cachedUOffset && this.vOffset === this._cachedVOffset && this.uScale === this._cachedUScale && this.vScale === this._cachedVScale && this.coordinatesMode === this._cachedCoordinatesMode)
- if (this.coordinatesMode === e.PROJECTION_MODE) {
- if (this._cachedProjectionMatrixId === o.getProjectionMatrix().updateFlag)
- return this._cachedTextureMatrix
- } else
- return this._cachedTextureMatrix;
- this._cachedTextureMatrix || (this._cachedTextureMatrix = Matrix.Zero()),
- this._projectionModeMatrix || (this._projectionModeMatrix = Matrix.Zero());
- var s = this._cachedCoordinatesMode !== this.coordinatesMode;
- switch (this._cachedUOffset = this.uOffset,
- this._cachedVOffset = this.vOffset,
- this._cachedUScale = this.uScale,
- this._cachedVScale = this.vScale,
- this._cachedCoordinatesMode = this.coordinatesMode,
- this.coordinatesMode) {
- case e.PLANAR_MODE:
- Matrix.IdentityToRef(this._cachedTextureMatrix),
- this._cachedTextureMatrix[0] = this.uScale,
- this._cachedTextureMatrix[5] = this.vScale,
- this._cachedTextureMatrix[12] = this.uOffset,
- this._cachedTextureMatrix[13] = this.vOffset;
- break;
- case e.PROJECTION_MODE:
- Matrix.FromValuesToRef(.5, 0, 0, 0, 0, -.5, 0, 0, 0, 0, 0, 0, .5, .5, 1, 1, this._projectionModeMatrix);
- var c = o.getProjectionMatrix();
- this._cachedProjectionMatrixId = c.updateFlag,
- c.multiplyToRef(this._projectionModeMatrix, this._cachedTextureMatrix);
- break;
- default:
- Matrix.IdentityToRef(this._cachedTextureMatrix);
- break
- }
- return s && o.markAllMaterialsAsDirty(1, function(d) {
- return d.getActiveTextures().indexOf(i) !== -1
- }),
- this._cachedTextureMatrix
- }
- ,
- e.prototype.clone = function() {
- var i = this
- , o = {
- noMipmap: this._noMipmap,
- invertY: this._invertY,
- samplingMode: this.samplingMode,
- onLoad: void 0,
- onError: void 0,
- buffer: this._texture ? this._texture._buffer : void 0,
- deleteBuffer: this._deleteBuffer,
- format: this.textureFormat,
- mimeType: this.mimeType,
- loaderOptions: this._loaderOptions,
- creationFlags: this._creationFlags,
- useSRGBBuffer: this._useSRGBBuffer
- };
- return SerializationHelper.Clone(function() {
- return new e(i._texture ? i._texture.url : null,i.getScene(),o)
- }, this)
- }
- ,
- e.prototype.serialize = function() {
- var i = this.name;
- e.SerializeBuffers || StartsWith(this.name, "data:") && (this.name = ""),
- StartsWith(this.name, "data:") && this.url === this.name && (this.url = "");
- var o = a.prototype.serialize.call(this);
- return o ? ((e.SerializeBuffers || e.ForceSerializeBuffers) && (typeof this._buffer == "string" && this._buffer.substr(0, 5) === "data:" ? (o.base64String = this._buffer,
- 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))),
- o.invertY = this._invertY,
- o.samplingMode = this.samplingMode,
- o._creationFlags = this._creationFlags,
- o._useSRGBBuffer = this._useSRGBBuffer,
- this.name = i,
- o) : null
- }
- ,
- e.prototype.getClassName = function() {
- return "Texture"
- }
- ,
- e.prototype.dispose = function() {
- a.prototype.dispose.call(this),
- this.onLoadObservable.clear(),
- this._delayedOnLoad = null,
- this._delayedOnError = null
- }
- ,
- e.Parse = function(i, o, s) {
- if (i.customType) {
- var c = InstantiationTools.Instantiate(i.customType)
- , d = c.Parse(i, o, s);
- return i.samplingMode && d.updateSamplingMode && d._samplingMode && d._samplingMode !== i.samplingMode && d.updateSamplingMode(i.samplingMode),
- d
- }
- if (i.isCube && !i.isRenderTarget)
- return e._CubeTextureParser(i, o, s);
- if (!i.name && !i.isRenderTarget)
- return null;
- var _ = function() {
- if (b && b._texture && (b._texture._cachedWrapU = null,
- b._texture._cachedWrapV = null,
- b._texture._cachedWrapR = null),
- i.samplingMode) {
- var k = i.samplingMode;
- b && b.samplingMode !== k && b.updateSamplingMode(k)
- }
- if (b && i.animations)
- for (var j = 0; j < i.animations.length; j++) {
- var $ = i.animations[j]
- , _e = GetClass("BABYLON.Animation");
- _e && b.animations.push(_e.Parse($))
- }
- }
- , b = SerializationHelper.Parse(function() {
- var k, j, $, _e = !0;
- if (i.noMipmap && (_e = !1),
- i.mirrorPlane) {
- var et = e._CreateMirror(i.name, i.renderTargetSize, o, _e);
- return et._waitingRenderList = i.renderList,
- et.mirrorPlane = Plane.FromArray(i.mirrorPlane),
- _(),
- et
- } else if (i.isRenderTarget) {
- var tt = null;
- if (i.isCube) {
- if (o.reflectionProbes)
- for (var rt = 0; rt < o.reflectionProbes.length; rt++) {
- var it = o.reflectionProbes[rt];
- if (it.name === i.name)
- return it.cubeTexture
- }
- } else
- tt = e._CreateRenderTargetTexture(i.name, i.renderTargetSize, o, _e, (k = i._creationFlags) !== null && k !== void 0 ? k : 0),
- tt._waitingRenderList = i.renderList;
- return _(),
- tt
- } else {
- var nt;
- if (i.base64String)
- 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);
- else {
- var ot = void 0;
- i.name && i.name.indexOf("://") > 0 ? ot = i.name : ot = s + i.name,
- (StartsWith(i.url, "data:") || e.UseSerializedUrlIfAny && i.url) && (ot = i.url),
- nt = new e(ot,o,!_e,i.invertY,i.samplingMode,_)
- }
- return nt
- }
- }, i, o);
- return b
- }
- ,
- e.CreateFromBase64String = function(i, o, s, c, d, _, b, k, j, $) {
- return _ === void 0 && (_ = e.TRILINEAR_SAMPLINGMODE),
- b === void 0 && (b = null),
- k === void 0 && (k = null),
- j === void 0 && (j = 5),
- new e("data:" + o,s,c,d,_,b,k,i,!1,j,void 0,void 0,$)
- }
- ,
- e.LoadFromDataString = function(i, o, s, c, d, _, b, k, j, $, _e) {
- return c === void 0 && (c = !1),
- _ === void 0 && (_ = !0),
- b === void 0 && (b = e.TRILINEAR_SAMPLINGMODE),
- k === void 0 && (k = null),
- j === void 0 && (j = null),
- $ === void 0 && ($ = 5),
- i.substr(0, 5) !== "data:" && (i = "data:" + i),
- new e(i,s,d,_,b,k,j,o,c,$,void 0,void 0,_e)
- }
- ,
- e.SerializeBuffers = !0,
- e.ForceSerializeBuffers = !1,
- e.OnTextureLoadErrorObservable = new Observable,
- e._CubeTextureParser = function(i, o, s) {
- throw _WarnImport("CubeTexture")
- }
- ,
- e._CreateMirror = function(i, o, s, c) {
- throw _WarnImport("MirrorTexture")
- }
- ,
- e._CreateRenderTargetTexture = function(i, o, s, c, d) {
- throw _WarnImport("RenderTargetTexture")
- }
- ,
- e.NEAREST_SAMPLINGMODE = 1,
- e.NEAREST_NEAREST_MIPLINEAR = 8,
- e.BILINEAR_SAMPLINGMODE = 2,
- e.LINEAR_LINEAR_MIPNEAREST = 11,
- e.TRILINEAR_SAMPLINGMODE = 3,
- e.LINEAR_LINEAR_MIPLINEAR = 3,
- e.NEAREST_NEAREST_MIPNEAREST = 4,
- e.NEAREST_LINEAR_MIPNEAREST = 5,
- e.NEAREST_LINEAR_MIPLINEAR = 6,
- e.NEAREST_LINEAR = 7,
- e.NEAREST_NEAREST = 1,
- e.LINEAR_NEAREST_MIPNEAREST = 9,
- e.LINEAR_NEAREST_MIPLINEAR = 10,
- e.LINEAR_LINEAR = 2,
- e.LINEAR_NEAREST = 12,
- e.EXPLICIT_MODE = 0,
- e.SPHERICAL_MODE = 1,
- e.PLANAR_MODE = 2,
- e.CUBIC_MODE = 3,
- e.PROJECTION_MODE = 4,
- e.SKYBOX_MODE = 5,
- e.INVCUBIC_MODE = 6,
- e.EQUIRECTANGULAR_MODE = 7,
- e.FIXED_EQUIRECTANGULAR_MODE = 8,
- e.FIXED_EQUIRECTANGULAR_MIRRORED_MODE = 9,
- e.CLAMP_ADDRESSMODE = 0,
- e.WRAP_ADDRESSMODE = 1,
- e.MIRROR_ADDRESSMODE = 2,
- e.UseSerializedUrlIfAny = !1,
- __decorate([serialize()], e.prototype, "url", void 0),
- __decorate([serialize()], e.prototype, "uOffset", void 0),
- __decorate([serialize()], e.prototype, "vOffset", void 0),
- __decorate([serialize()], e.prototype, "uScale", void 0),
- __decorate([serialize()], e.prototype, "vScale", void 0),
- __decorate([serialize()], e.prototype, "uAng", void 0),
- __decorate([serialize()], e.prototype, "vAng", void 0),
- __decorate([serialize()], e.prototype, "wAng", void 0),
- __decorate([serialize()], e.prototype, "uRotationCenter", void 0),
- __decorate([serialize()], e.prototype, "vRotationCenter", void 0),
- __decorate([serialize()], e.prototype, "wRotationCenter", void 0),
- __decorate([serialize()], e.prototype, "homogeneousRotationInUVTransform", void 0),
- __decorate([serialize()], e.prototype, "isBlocking", null),
- e
- }(BaseTexture);
- RegisterClass("BABYLON.Texture", Texture);
- SerializationHelper._TextureParser = Texture.Parse;
- var WebGLRenderTargetWrapper = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d) {
- var _ = a.call(this, i, o, s, c) || this;
- return _._framebuffer = null,
- _._depthStencilBuffer = null,
- _._MSAAFramebuffer = null,
- _._colorTextureArray = null,
- _._depthStencilTextureArray = null,
- _._context = d,
- _
- }
- return e.prototype._cloneRenderTargetWrapper = function() {
- var i = null;
- return this._colorTextureArray && this._depthStencilTextureArray ? (i = this._engine.createMultiviewRenderTargetTexture(this.width, this.height),
- i.texture.isReady = !0) : i = a.prototype._cloneRenderTargetWrapper.call(this),
- i
- }
- ,
- e.prototype._swapRenderTargetWrapper = function(i) {
- a.prototype._swapRenderTargetWrapper.call(this, i),
- i._framebuffer = this._framebuffer,
- i._depthStencilBuffer = this._depthStencilBuffer,
- i._MSAAFramebuffer = this._MSAAFramebuffer,
- i._colorTextureArray = this._colorTextureArray,
- i._depthStencilTextureArray = this._depthStencilTextureArray,
- this._framebuffer = this._depthStencilBuffer = this._MSAAFramebuffer = this._colorTextureArray = this._depthStencilTextureArray = null
- }
- ,
- e.prototype._shareDepth = function(i) {
- a.prototype._shareDepth.call(this, i);
- var o = this._context
- , s = this._depthStencilBuffer
- , c = i._framebuffer;
- i._depthStencilBuffer && o.deleteRenderbuffer(i._depthStencilBuffer),
- i._depthStencilBuffer = this._depthStencilBuffer,
- this._engine._bindUnboundFramebuffer(c),
- o.framebufferRenderbuffer(o.FRAMEBUFFER, o.DEPTH_ATTACHMENT, o.RENDERBUFFER, s),
- this._engine._bindUnboundFramebuffer(null)
- }
- ,
- e.prototype._bindTextureRenderTarget = function(i, o, s, c) {
- if (o === void 0 && (o = 0),
- s === void 0 && (s = -1),
- c === void 0 && (c = 0),
- !!i._hardwareTexture) {
- var d = this._context
- , _ = this._framebuffer
- , b = this._engine._currentFramebuffer;
- this._engine._bindUnboundFramebuffer(_);
- var k = d[this._engine.webGLVersion > 1 ? "COLOR_ATTACHMENT" + o : "COLOR_ATTACHMENT" + o + "_WEBGL"]
- , j = s !== -1 ? d.TEXTURE_CUBE_MAP_POSITIVE_X + s : d.TEXTURE_2D;
- d.framebufferTexture2D(d.FRAMEBUFFER, k, j, i._hardwareTexture.underlyingResource, c),
- this._engine._bindUnboundFramebuffer(b)
- }
- }
- ,
- e.prototype.setTexture = function(i, o, s) {
- o === void 0 && (o = 0),
- s === void 0 && (s = !0),
- a.prototype.setTexture.call(this, i, o, s),
- this._bindTextureRenderTarget(i, o)
- }
- ,
- e.prototype.dispose = function(i) {
- i === void 0 && (i = !1);
- var o = this._context;
- i || (this._colorTextureArray && (this._context.deleteTexture(this._colorTextureArray),
- this._colorTextureArray = null),
- this._depthStencilTextureArray && (this._context.deleteTexture(this._depthStencilTextureArray),
- this._depthStencilTextureArray = null)),
- this._framebuffer && (o.deleteFramebuffer(this._framebuffer),
- this._framebuffer = null),
- this._depthStencilBuffer && (o.deleteRenderbuffer(this._depthStencilBuffer),
- this._depthStencilBuffer = null),
- this._MSAAFramebuffer && (o.deleteFramebuffer(this._MSAAFramebuffer),
- this._MSAAFramebuffer = null),
- a.prototype.dispose.call(this, i)
- }
- ,
- e
- }(RenderTargetWrapper);
- ThinEngine.prototype._createHardwareRenderTargetWrapper = function(a, e, i) {
- var o = new WebGLRenderTargetWrapper(a,e,i,this,this._gl);
- return this._renderTargetWrapperCache.push(o),
- o
- }
- ;
- ThinEngine.prototype.createRenderTargetTexture = function(a, e) {
- var i = this._createHardwareRenderTargetWrapper(!1, !1, a)
- , o = {};
- e !== void 0 && typeof e == "object" ? (o.generateDepthBuffer = !!e.generateDepthBuffer,
- o.generateStencilBuffer = !!e.generateStencilBuffer) : (o.generateDepthBuffer = !0,
- o.generateStencilBuffer = !1);
- var s = this._createInternalTexture(a, e, !0, InternalTextureSource.RenderTarget)
- , c = a.width || a
- , d = a.height || a
- , _ = this._currentFramebuffer
- , b = this._gl
- , k = b.createFramebuffer();
- return this._bindUnboundFramebuffer(k),
- i._depthStencilBuffer = this._setupFramebufferDepthAttachments(!!o.generateStencilBuffer, o.generateDepthBuffer, c, d),
- s.is2DArray || b.framebufferTexture2D(b.FRAMEBUFFER, b.COLOR_ATTACHMENT0, b.TEXTURE_2D, s._hardwareTexture.underlyingResource, 0),
- this._bindUnboundFramebuffer(_),
- i._framebuffer = k,
- i._generateDepthBuffer = o.generateDepthBuffer,
- i._generateStencilBuffer = !!o.generateStencilBuffer,
- i.setTextures(s),
- i
- }
- ;
- ThinEngine.prototype.createDepthStencilTexture = function(a, e, i) {
- if (e.isCube) {
- var o = a.width || a;
- return this._createDepthStencilCubeTexture(o, e, i)
- } else
- return this._createDepthStencilTexture(a, e, i)
- }
- ;
- ThinEngine.prototype._createDepthStencilTexture = function(a, e, i) {
- var o = this._gl
- , s = a.layers || 0
- , c = s !== 0 ? o.TEXTURE_2D_ARRAY : o.TEXTURE_2D
- , d = new InternalTexture(this,InternalTextureSource.DepthStencil);
- if (!this._caps.depthTextureExtension)
- return Logger$2.Error("Depth texture is not supported by your browser or hardware."),
- d;
- var _ = __assign({
- bilinearFiltering: !1,
- comparisonFunction: 0,
- generateStencil: !1
- }, e);
- this._bindTextureDirectly(c, d, !0),
- this._setupDepthStencilTexture(d, a, _.generateStencil, _.comparisonFunction === 0 ? !1 : _.bilinearFiltering, _.comparisonFunction),
- i._depthStencilTexture = d,
- i._depthStencilTextureWithStencil = _.generateStencil;
- var b = _.generateStencil ? o.UNSIGNED_INT_24_8 : o.UNSIGNED_INT
- , k = _.generateStencil ? o.DEPTH_STENCIL : o.DEPTH_COMPONENT
- , j = k;
- return this.webGLVersion > 1 && (j = _.generateStencil ? o.DEPTH24_STENCIL8 : o.DEPTH_COMPONENT24),
- 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),
- this._bindTextureDirectly(c, null),
- this._internalTexturesCache.push(d),
- d
- }
- ;
- ThinEngine.prototype.updateRenderTargetTextureSampleCount = function(a, e) {
- if (this.webGLVersion < 2 || !a || !a.texture)
- return 1;
- if (a.samples === e)
- return e;
- var i = this._gl;
- e = Math.min(e, this.getCaps().maxMSAASamples),
- a._depthStencilBuffer && (i.deleteRenderbuffer(a._depthStencilBuffer),
- a._depthStencilBuffer = null),
- a._MSAAFramebuffer && (i.deleteFramebuffer(a._MSAAFramebuffer),
- a._MSAAFramebuffer = null);
- var o = a.texture._hardwareTexture;
- if (o._MSAARenderBuffer && (i.deleteRenderbuffer(o._MSAARenderBuffer),
- o._MSAARenderBuffer = null),
- e > 1 && i.renderbufferStorageMultisample) {
- var s = i.createFramebuffer();
- if (!s)
- throw new Error("Unable to create multi sampled framebuffer");
- a._MSAAFramebuffer = s,
- this._bindUnboundFramebuffer(a._MSAAFramebuffer);
- var c = this._createRenderBuffer(a.texture.width, a.texture.height, e, -1, this._getRGBAMultiSampleBufferFormat(a.texture.type), i.COLOR_ATTACHMENT0, !1);
- if (!c)
- throw new Error("Unable to create multi sampled framebuffer");
- o._MSAARenderBuffer = c
- } else
- this._bindUnboundFramebuffer(a._framebuffer);
- return a.texture.samples = e,
- a._depthStencilBuffer = this._setupFramebufferDepthAttachments(a._generateStencilBuffer, a._generateDepthBuffer, a.texture.width, a.texture.height, e),
- this._bindUnboundFramebuffer(null),
- e
- }
- ;
- ThinEngine.prototype.createRenderTargetCubeTexture = function(a, e) {
- var i = this._createHardwareRenderTargetWrapper(!1, !0, a)
- , o = __assign({
- generateMipMaps: !0,
- generateDepthBuffer: !0,
- generateStencilBuffer: !1,
- type: 0,
- samplingMode: 3,
- format: 5
- }, e);
- o.generateStencilBuffer = o.generateDepthBuffer && o.generateStencilBuffer,
- (o.type === 1 && !this._caps.textureFloatLinearFiltering || o.type === 2 && !this._caps.textureHalfFloatLinearFiltering) && (o.samplingMode = 1);
- var s = this._gl
- , c = new InternalTexture(this,InternalTextureSource.RenderTarget);
- this._bindTextureDirectly(s.TEXTURE_CUBE_MAP, c, !0);
- var d = this._getSamplingParameters(o.samplingMode, o.generateMipMaps);
- o.type === 1 && !this._caps.textureFloat && (o.type = 0,
- Logger$2.Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type")),
- s.texParameteri(s.TEXTURE_CUBE_MAP, s.TEXTURE_MAG_FILTER, d.mag),
- s.texParameteri(s.TEXTURE_CUBE_MAP, s.TEXTURE_MIN_FILTER, d.min),
- s.texParameteri(s.TEXTURE_CUBE_MAP, s.TEXTURE_WRAP_S, s.CLAMP_TO_EDGE),
- s.texParameteri(s.TEXTURE_CUBE_MAP, s.TEXTURE_WRAP_T, s.CLAMP_TO_EDGE);
- for (var _ = 0; _ < 6; _++)
- 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);
- var b = s.createFramebuffer();
- return this._bindUnboundFramebuffer(b),
- i._depthStencilBuffer = this._setupFramebufferDepthAttachments(o.generateStencilBuffer, o.generateDepthBuffer, a, a),
- o.generateMipMaps && s.generateMipmap(s.TEXTURE_CUBE_MAP),
- this._bindTextureDirectly(s.TEXTURE_CUBE_MAP, null),
- this._bindUnboundFramebuffer(null),
- i._framebuffer = b,
- i._generateDepthBuffer = o.generateDepthBuffer,
- i._generateStencilBuffer = o.generateStencilBuffer,
- c.width = a,
- c.height = a,
- c.isReady = !0,
- c.isCube = !0,
- c.samples = 1,
- c.generateMipMaps = o.generateMipMaps,
- c.samplingMode = o.samplingMode,
- c.type = o.type,
- c.format = o.format,
- this._internalTexturesCache.push(c),
- i.setTextures(c),
- i
- }
- ;
- var RenderTargetTexture = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _, b, k, j, $, _e, et, tt, rt, it) {
- d === void 0 && (d = !0),
- _ === void 0 && (_ = 0),
- b === void 0 && (b = !1),
- k === void 0 && (k = Texture.TRILINEAR_SAMPLINGMODE),
- j === void 0 && (j = !0),
- $ === void 0 && ($ = !1),
- _e === void 0 && (_e = !1),
- et === void 0 && (et = 5),
- tt === void 0 && (tt = !1);
- var nt, ot = a.call(this, null, s, !c, void 0, k, void 0, void 0, void 0, void 0, et) || this;
- if (ot.renderParticles = !0,
- ot.renderSprites = !1,
- ot.ignoreCameraViewport = !1,
- ot.onBeforeBindObservable = new Observable,
- ot.onAfterUnbindObservable = new Observable,
- ot.onBeforeRenderObservable = new Observable,
- ot.onAfterRenderObservable = new Observable,
- ot.onClearObservable = new Observable,
- ot.onResizeObservable = new Observable,
- ot._cleared = !1,
- ot.skipInitialClear = !1,
- ot._currentRefreshId = -1,
- ot._refreshRate = 1,
- ot._samples = 1,
- ot._canRescale = !0,
- ot._renderTarget = null,
- ot.boundingBoxPosition = Vector3.Zero(),
- s = ot.getScene(),
- !s)
- return ot;
- var at = ot.getScene().getEngine();
- return ot._coordinatesMode = Texture.PROJECTION_MODE,
- ot.renderList = new Array,
- ot.name = i,
- ot.isRenderTarget = !0,
- ot._initialSizeParameter = o,
- ot._renderPassIds = [],
- ot.__isCube = b,
- ot._processSizeParameter(o),
- ot.renderPassId = ot._renderPassIds[0],
- ot._resizeObserver = at.onResizeObservable.add(function() {}),
- ot._generateMipMaps = !!c,
- ot._doNotChangeAspectRatio = d,
- ot._renderingManager = new RenderingManager(s),
- ot._renderingManager._useSceneAutoClearSetup = !0,
- _e || (ot._renderTargetOptions = {
- generateMipMaps: c,
- type: _,
- format: (nt = ot._format) !== null && nt !== void 0 ? nt : void 0,
- samplingMode: ot.samplingMode,
- generateDepthBuffer: j,
- generateStencilBuffer: $,
- samples: rt,
- creationFlags: it
- },
- ot.samplingMode === Texture.NEAREST_SAMPLINGMODE && (ot.wrapU = Texture.CLAMP_ADDRESSMODE,
- ot.wrapV = Texture.CLAMP_ADDRESSMODE),
- tt || (b ? (ot._renderTarget = s.getEngine().createRenderTargetCubeTexture(ot.getRenderSize(), ot._renderTargetOptions),
- ot.coordinatesMode = Texture.INVCUBIC_MODE,
- ot._textureMatrix = Matrix.Identity()) : ot._renderTarget = s.getEngine().createRenderTargetTexture(ot._size, ot._renderTargetOptions),
- ot._texture = ot._renderTarget.texture,
- rt !== void 0 && (ot.samples = rt))),
- ot
- }
- return Object.defineProperty(e.prototype, "renderList", {
- get: function() {
- return this._renderList
- },
- set: function(i) {
- this._renderList = i,
- this._renderList && this._hookArray(this._renderList)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._hookArray = function(i) {
- var o = this
- , s = i.push;
- i.push = function() {
- for (var d, _ = [], b = 0; b < arguments.length; b++)
- _[b] = arguments[b];
- var k = i.length === 0
- , j = s.apply(i, _);
- return k && ((d = o.getScene()) === null || d === void 0 || d.meshes.forEach(function($) {
- $._markSubMeshesAsLightDirty()
- })),
- j
- }
- ;
- var c = i.splice;
- i.splice = function(d, _) {
- var b, k = c.apply(i, [d, _]);
- return i.length === 0 && ((b = o.getScene()) === null || b === void 0 || b.meshes.forEach(function(j) {
- j._markSubMeshesAsLightDirty()
- })),
- k
- }
- }
- ,
- Object.defineProperty(e.prototype, "postProcesses", {
- get: function() {
- return this._postProcesses
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "_prePassEnabled", {
- get: function() {
- return !!this._prePassRenderTarget && this._prePassRenderTarget.enabled
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "onAfterUnbind", {
- set: function(i) {
- this._onAfterUnbindObserver && this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),
- this._onAfterUnbindObserver = this.onAfterUnbindObservable.add(i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "onBeforeRender", {
- set: function(i) {
- this._onBeforeRenderObserver && this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),
- this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "onAfterRender", {
- set: function(i) {
- this._onAfterRenderObserver && this.onAfterRenderObservable.remove(this._onAfterRenderObserver),
- this._onAfterRenderObserver = this.onAfterRenderObservable.add(i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "onClear", {
- set: function(i) {
- this._onClearObserver && this.onClearObservable.remove(this._onClearObserver),
- this._onClearObserver = this.onClearObservable.add(i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "renderPassIds", {
- get: function() {
- return this._renderPassIds
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.setMaterialForRendering = function(i, o) {
- var s;
- Array.isArray(i) ? s = i : s = [i];
- for (var c = 0; c < s.length; ++c)
- for (var d = 0; d < this._renderPassIds.length; ++d)
- s[c].setMaterialForRenderPass(this._renderPassIds[d], o !== void 0 ? Array.isArray(o) ? o[d] : o : void 0)
- }
- ,
- Object.defineProperty(e.prototype, "renderTargetOptions", {
- get: function() {
- return this._renderTargetOptions
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "renderTarget", {
- get: function() {
- return this._renderTarget
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._onRatioRescale = function() {
- this._sizeRatio && this.resize(this._initialSizeParameter)
- }
- ,
- Object.defineProperty(e.prototype, "boundingBoxSize", {
- get: function() {
- return this._boundingBoxSize
- },
- set: function(i) {
- if (!(this._boundingBoxSize && this._boundingBoxSize.equals(i))) {
- this._boundingBoxSize = i;
- var o = this.getScene();
- o && o.markAllMaterialsAsDirty(1)
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "depthStencilTexture", {
- get: function() {
- var i, o;
- return (o = (i = this._renderTarget) === null || i === void 0 ? void 0 : i._depthStencilTexture) !== null && o !== void 0 ? o : null
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.createDepthStencilTexture = function(i, o, s, c) {
- var d;
- i === void 0 && (i = 0),
- o === void 0 && (o = !0),
- s === void 0 && (s = !1),
- c === void 0 && (c = 1),
- (d = this._renderTarget) === null || d === void 0 || d.createDepthStencilTexture(i, o, s, c)
- }
- ,
- e.prototype._releaseRenderPassId = function() {
- if (this._scene)
- for (var i = this._scene.getEngine(), o = 0; o < this._renderPassIds.length; ++o)
- i.releaseRenderPassId(this._renderPassIds[o]);
- this._renderPassIds = []
- }
- ,
- e.prototype._createRenderPassId = function() {
- this._releaseRenderPassId();
- for (var i = this._scene.getEngine(), o = this.__isCube ? 6 : this.getRenderLayers() || 1, s = 0; s < o; ++s)
- this._renderPassIds[s] = i.createRenderPassId("RenderTargetTexture - " + this.name + "#" + s)
- }
- ,
- e.prototype._processSizeParameter = function(i) {
- if (i.ratio) {
- this._sizeRatio = i.ratio;
- var o = this._getEngine();
- this._size = {
- width: this._bestReflectionRenderTargetDimension(o.getRenderWidth(), this._sizeRatio),
- height: this._bestReflectionRenderTargetDimension(o.getRenderHeight(), this._sizeRatio)
- }
- } else
- this._size = i;
- this._createRenderPassId()
- }
- ,
- Object.defineProperty(e.prototype, "samples", {
- get: function() {
- var i, o;
- return (o = (i = this._renderTarget) === null || i === void 0 ? void 0 : i.samples) !== null && o !== void 0 ? o : this._samples
- },
- set: function(i) {
- this._renderTarget && (this._samples = this._renderTarget.setSamples(i))
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.resetRefreshCounter = function() {
- this._currentRefreshId = -1
- }
- ,
- Object.defineProperty(e.prototype, "refreshRate", {
- get: function() {
- return this._refreshRate
- },
- set: function(i) {
- this._refreshRate = i,
- this.resetRefreshCounter()
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.addPostProcess = function(i) {
- if (!this._postProcessManager) {
- var o = this.getScene();
- if (!o)
- return;
- this._postProcessManager = new PostProcessManager(o),
- this._postProcesses = new Array
- }
- this._postProcesses.push(i),
- this._postProcesses[0].autoClear = !1
- }
- ,
- e.prototype.clearPostProcesses = function(i) {
- if (i === void 0 && (i = !1),
- !!this._postProcesses) {
- if (i)
- for (var o = 0, s = this._postProcesses; o < s.length; o++) {
- var c = s[o];
- c.dispose()
- }
- this._postProcesses = []
- }
- }
- ,
- e.prototype.removePostProcess = function(i) {
- if (!!this._postProcesses) {
- var o = this._postProcesses.indexOf(i);
- o !== -1 && (this._postProcesses.splice(o, 1),
- this._postProcesses.length > 0 && (this._postProcesses[0].autoClear = !1))
- }
- }
- ,
- e.prototype._shouldRender = function() {
- return this._currentRefreshId === -1 ? (this._currentRefreshId = 1,
- !0) : this.refreshRate === this._currentRefreshId ? (this._currentRefreshId = 1,
- !0) : (this._currentRefreshId++,
- !1)
- }
- ,
- e.prototype.getRenderSize = function() {
- return this.getRenderWidth()
- }
- ,
- e.prototype.getRenderWidth = function() {
- return this._size.width ? this._size.width : this._size
- }
- ,
- e.prototype.getRenderHeight = function() {
- return this._size.width ? this._size.height : this._size
- }
- ,
- e.prototype.getRenderLayers = function() {
- var i = this._size.layers;
- return i || 0
- }
- ,
- e.prototype.disableRescaling = function() {
- this._canRescale = !1
- }
- ,
- Object.defineProperty(e.prototype, "canRescale", {
- get: function() {
- return this._canRescale
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.scale = function(i) {
- var o = Math.max(1, this.getRenderSize() * i);
- this.resize(o)
- }
- ,
- e.prototype.getReflectionTextureMatrix = function() {
- return this.isCube ? this._textureMatrix : a.prototype.getReflectionTextureMatrix.call(this)
- }
- ,
- e.prototype.resize = function(i) {
- var o, s = this.isCube;
- (o = this._renderTarget) === null || o === void 0 || o.dispose(),
- this._renderTarget = null;
- var c = this.getScene();
- !c || (this._processSizeParameter(i),
- s ? this._renderTarget = c.getEngine().createRenderTargetCubeTexture(this.getRenderSize(), this._renderTargetOptions) : this._renderTarget = c.getEngine().createRenderTargetTexture(this._size, this._renderTargetOptions),
- this._texture = this._renderTarget.texture,
- this._renderTargetOptions.samples !== void 0 && (this.samples = this._renderTargetOptions.samples),
- this.onResizeObservable.hasObservers() && this.onResizeObservable.notifyObservers(this))
- }
- ,
- e.prototype.render = function(i, o) {
- i === void 0 && (i = !1),
- o === void 0 && (o = !1),
- this._render(i, o)
- }
- ,
- e.prototype.isReadyForRendering = function() {
- return this._render(!1, !1, !0)
- }
- ,
- e.prototype._render = function(i, o, s) {
- var c;
- i === void 0 && (i = !1),
- o === void 0 && (o = !1),
- s === void 0 && (s = !1);
- var d = this.getScene();
- if (!d)
- return s;
- var _ = d.getEngine();
- if (this.useCameraPostProcesses !== void 0 && (i = this.useCameraPostProcesses),
- this._waitingRenderList) {
- this.renderList = [];
- for (var b = 0; b < this._waitingRenderList.length; b++) {
- var k = this._waitingRenderList[b]
- , j = d.getMeshById(k);
- j && this.renderList.push(j)
- }
- this._waitingRenderList = void 0
- }
- if (this.renderListPredicate) {
- this.renderList ? this.renderList.length = 0 : this.renderList = [];
- var d = this.getScene();
- if (!d)
- return s;
- for (var $ = d.meshes, b = 0; b < $.length; b++) {
- var _e = $[b];
- this.renderListPredicate(_e) && this.renderList.push(_e)
- }
- }
- var et = _.currentRenderPassId;
- this.onBeforeBindObservable.notifyObservers(this);
- var tt = (c = this.activeCamera) !== null && c !== void 0 ? c : d.activeCamera;
- tt && (tt !== d.activeCamera && d.setTransformMatrix(tt.getViewMatrix(), tt.getProjectionMatrix(!0)),
- _.setViewport(tt.viewport, this.getRenderWidth(), this.getRenderHeight())),
- this._defaultRenderListPrepared = !1;
- var rt = s;
- if (s) {
- d.getViewMatrix() || d.updateTransformMatrix();
- for (var ot = this.is2DArray ? this.getRenderLayers() : this.isCube ? 6 : 1, it = 0; it < ot && rt; it++) {
- var at = null
- , st = this.renderList ? this.renderList : d.getActiveMeshes().data
- , ut = this.renderList ? this.renderList.length : d.getActiveMeshes().length;
- _.currentRenderPassId = this._renderPassIds[it],
- this.onBeforeRenderObservable.notifyObservers(it),
- this.getCustomRenderList && (at = this.getCustomRenderList(it, st, ut)),
- at || (at = st),
- this._doNotChangeAspectRatio || d.updateTransformMatrix(!0);
- for (var ct = 0; ct < at.length && rt; ++ct) {
- var lt = at[ct];
- if (!(!lt.isEnabled() || lt.isBlocked || !lt.isVisible || !lt.subMeshes)) {
- if (this.customIsReadyFunction) {
- if (!this.customIsReadyFunction(lt, this.refreshRate)) {
- rt = !1;
- break
- }
- } else if (!lt.isReady(!0)) {
- rt = !1;
- break
- }
- }
- }
- this.onAfterRenderObservable.notifyObservers(it)
- }
- } else if (this.is2DArray)
- for (var it = 0; it < this.getRenderLayers(); it++)
- this.renderToTarget(0, i, o, it, tt),
- d.incrementRenderId(),
- d.resetCachedMaterial();
- else if (this.isCube)
- for (var nt = 0; nt < 6; nt++)
- this.renderToTarget(nt, i, o, void 0, tt),
- d.incrementRenderId(),
- d.resetCachedMaterial();
- else
- this.renderToTarget(0, i, o, void 0, tt);
- return this.onAfterUnbindObservable.notifyObservers(this),
- _.currentRenderPassId = et,
- d.activeCamera && ((d.getEngine().scenes.length > 1 || this.activeCamera && this.activeCamera !== d.activeCamera) && d.setTransformMatrix(d.activeCamera.getViewMatrix(), d.activeCamera.getProjectionMatrix(!0)),
- _.setViewport(d.activeCamera.viewport)),
- d.resetCachedMaterial(),
- rt
- }
- ,
- e.prototype._bestReflectionRenderTargetDimension = function(i, o) {
- var s = 128
- , c = i * o
- , d = Engine.NearestPOT(c + s * s / (s + c));
- return Math.min(Engine.FloorPOT(i), d)
- }
- ,
- e.prototype._prepareRenderingManager = function(i, o, s, c) {
- var d = this.getScene();
- if (!!d) {
- this._renderingManager.reset();
- for (var _ = d.getRenderId(), b = 0; b < o; b++) {
- var k = i[b];
- if (k && !k.isBlocked) {
- if (this.customIsReadyFunction) {
- if (!this.customIsReadyFunction(k, this.refreshRate)) {
- this.resetRefreshCounter();
- continue
- }
- } else if (!k.isReady(this.refreshRate === 0)) {
- this.resetRefreshCounter();
- continue
- }
- if (!k._internalAbstractMeshDataInfo._currentLODIsUpToDate && d.activeCamera && (k._internalAbstractMeshDataInfo._currentLOD = d.customLODSelector ? d.customLODSelector(k, this.activeCamera || d.activeCamera) : k.getLOD(this.activeCamera || d.activeCamera),
- k._internalAbstractMeshDataInfo._currentLODIsUpToDate = !0),
- !k._internalAbstractMeshDataInfo._currentLOD)
- continue;
- var j = k._internalAbstractMeshDataInfo._currentLOD;
- j._preActivateForIntermediateRendering(_);
- var $ = void 0;
- if (c && s ? $ = (k.layerMask & s.layerMask) === 0 : $ = !1,
- k.isEnabled() && k.isVisible && k.subMeshes && !$ && (j !== k && j._activate(_, !0),
- k._activate(_, !0) && k.subMeshes.length)) {
- k.isAnInstance ? k._internalAbstractMeshDataInfo._actAsRegularMesh && (j = k) : j._internalAbstractMeshDataInfo._onlyForInstancesIntermediate = !1,
- j._internalAbstractMeshDataInfo._isActiveIntermediate = !0;
- for (var _e = 0; _e < j.subMeshes.length; _e++) {
- var et = j.subMeshes[_e];
- this._renderingManager.dispatch(et, j)
- }
- }
- }
- }
- for (var tt = 0; tt < d.particleSystems.length; tt++) {
- var rt = d.particleSystems[tt]
- , it = rt.emitter;
- !rt.isStarted() || !it || !it.position || !it.isEnabled() || i.indexOf(it) >= 0 && this._renderingManager.dispatchParticles(rt)
- }
- }
- }
- ,
- e.prototype._bindFrameBuffer = function(i, o) {
- i === void 0 && (i = 0),
- o === void 0 && (o = 0);
- var s = this.getScene();
- if (!!s) {
- var c = s.getEngine();
- this._renderTarget && c.bindFramebuffer(this._renderTarget, this.isCube ? i : void 0, void 0, void 0, this.ignoreCameraViewport, 0, o)
- }
- }
- ,
- e.prototype.unbindFrameBuffer = function(i, o) {
- var s = this;
- !this._renderTarget || i.unBindFramebuffer(this._renderTarget, this.isCube, function() {
- s.onAfterRenderObservable.notifyObservers(o)
- })
- }
- ,
- e.prototype._prepareFrame = function(i, o, s, c) {
- this._postProcessManager ? this._prePassEnabled || this._postProcessManager._prepareFrame(this._texture, this._postProcesses) : (!c || !i.postProcessManager._prepareFrame(this._texture)) && this._bindFrameBuffer(o, s)
- }
- ,
- e.prototype.renderToTarget = function(i, o, s, c, d) {
- var _, b, k, j;
- c === void 0 && (c = 0),
- d === void 0 && (d = null);
- var $ = this.getScene();
- if (!!$) {
- var _e = $.getEngine();
- if (!!this._texture) {
- (_ = _e._debugPushGroup) === null || _ === void 0 || _.call(_e, "render to face #" + i + " layer #" + c, 1),
- this._prepareFrame($, i, c, o),
- this.is2DArray ? (_e.currentRenderPassId = this._renderPassIds[c],
- this.onBeforeRenderObservable.notifyObservers(c)) : (_e.currentRenderPassId = this._renderPassIds[i],
- this.onBeforeRenderObservable.notifyObservers(i));
- var et = _e.snapshotRendering && _e.snapshotRenderingMode === 1;
- if (et)
- this.onClearObservable.hasObservers() ? this.onClearObservable.notifyObservers(_e) : this.skipInitialClear || _e.clear(this.clearColor || $.clearColor, !0, !0, !0);
- else {
- var tt = null
- , rt = this.renderList ? this.renderList : $.getActiveMeshes().data
- , it = this.renderList ? this.renderList.length : $.getActiveMeshes().length;
- this.getCustomRenderList && (tt = this.getCustomRenderList(this.is2DArray ? c : i, rt, it)),
- tt ? this._prepareRenderingManager(tt, tt.length, d, !1) : (this._defaultRenderListPrepared || (this._prepareRenderingManager(rt, it, d, !this.renderList),
- this._defaultRenderListPrepared = !0),
- tt = rt);
- for (var nt = 0, ot = $._beforeRenderTargetClearStage; nt < ot.length; nt++) {
- var at = ot[nt];
- at.action(this, i, c)
- }
- this.onClearObservable.hasObservers() ? this.onClearObservable.notifyObservers(_e) : this.skipInitialClear || _e.clear(this.clearColor || $.clearColor, !0, !0, !0),
- this._doNotChangeAspectRatio || $.updateTransformMatrix(!0);
- for (var st = 0, ut = $._beforeRenderTargetDrawStage; st < ut.length; st++) {
- var at = ut[st];
- at.action(this, i, c)
- }
- this._renderingManager.render(this.customRenderFunction, tt, this.renderParticles, this.renderSprites);
- for (var ct = 0, lt = $._afterRenderTargetDrawStage; ct < lt.length; ct++) {
- var at = lt[ct];
- at.action(this, i, c)
- }
- var ft = this._texture.generateMipMaps;
- this._texture.generateMipMaps = !1,
- 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),
- this._texture.generateMipMaps = ft,
- this._doNotChangeAspectRatio || $.updateTransformMatrix(!0),
- s && Tools.DumpFramebuffer(this.getRenderWidth(), this.getRenderHeight(), _e)
- }
- this.unbindFrameBuffer(_e, i),
- this.isCube && i === 5 && _e.generateMipMapsForCubemap(this._texture),
- (j = _e._debugPopGroup) === null || j === void 0 || j.call(_e, 1)
- }
- }
- }
- ,
- e.prototype.setRenderingOrder = function(i, o, s, c) {
- o === void 0 && (o = null),
- s === void 0 && (s = null),
- c === void 0 && (c = null),
- this._renderingManager.setRenderingOrder(i, o, s, c)
- }
- ,
- e.prototype.setRenderingAutoClearDepthStencil = function(i, o) {
- this._renderingManager.setRenderingAutoClearDepthStencil(i, o),
- this._renderingManager._useSceneAutoClearSetup = !1
- }
- ,
- e.prototype.clone = function() {
- var i = this.getSize()
- , 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);
- return o.hasAlpha = this.hasAlpha,
- o.level = this.level,
- o.coordinatesMode = this.coordinatesMode,
- this.renderList && (o.renderList = this.renderList.slice(0)),
- o
- }
- ,
- e.prototype.serialize = function() {
- if (!this.name)
- return null;
- var i = a.prototype.serialize.call(this);
- if (i.renderTargetSize = this.getRenderSize(),
- i.renderList = [],
- this.renderList)
- for (var o = 0; o < this.renderList.length; o++)
- i.renderList.push(this.renderList[o].id);
- return i
- }
- ,
- e.prototype.disposeFramebufferObjects = function() {
- var i;
- (i = this._renderTarget) === null || i === void 0 || i.dispose(!0)
- }
- ,
- e.prototype.releaseInternalTexture = function() {
- var i;
- (i = this._renderTarget) === null || i === void 0 || i.releaseTextures(),
- this._texture = null
- }
- ,
- e.prototype.dispose = function() {
- var i;
- this.onResizeObservable.clear(),
- this.onClearObservable.clear(),
- this.onAfterRenderObservable.clear(),
- this.onAfterUnbindObservable.clear(),
- this.onBeforeBindObservable.clear(),
- this.onBeforeRenderObservable.clear(),
- this._postProcessManager && (this._postProcessManager.dispose(),
- this._postProcessManager = null),
- this._prePassRenderTarget && this._prePassRenderTarget.dispose(),
- this._releaseRenderPassId(),
- this.clearPostProcesses(!0),
- this._resizeObserver && (this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver),
- this._resizeObserver = null),
- this.renderList = null;
- var o = this.getScene();
- if (!!o) {
- var s = o.customRenderTargets.indexOf(this);
- s >= 0 && o.customRenderTargets.splice(s, 1);
- for (var c = 0, d = o.cameras; c < d.length; c++) {
- var _ = d[c];
- s = _.customRenderTargets.indexOf(this),
- s >= 0 && _.customRenderTargets.splice(s, 1)
- }
- (i = this._renderTarget) === null || i === void 0 || i.dispose(),
- this._renderTarget = null,
- this._texture = null,
- a.prototype.dispose.call(this)
- }
- }
- ,
- e.prototype._rebuild = function() {
- this.refreshRate === e.REFRESHRATE_RENDER_ONCE && (this.refreshRate = e.REFRESHRATE_RENDER_ONCE),
- this._postProcessManager && this._postProcessManager._rebuild()
- }
- ,
- e.prototype.freeRenderingGroups = function() {
- this._renderingManager && this._renderingManager.freeRenderingGroups()
- }
- ,
- e.prototype.getViewCount = function() {
- return 1
- }
- ,
- e.REFRESHRATE_RENDER_ONCE = 0,
- e.REFRESHRATE_RENDER_ONEVERYFRAME = 1,
- e.REFRESHRATE_RENDER_ONEVERYTWOFRAMES = 2,
- e
- }(Texture);
- Texture._CreateRenderTargetTexture = function(a, e, i, o, s) {
- return new RenderTargetTexture(a,e,i,o)
- }
- ;
- var MultiviewRenderTarget = function(a) {
- __extends(e, a);
- function e(i, o) {
- o === void 0 && (o = 512);
- var s = a.call(this, "multiview rtt", o, i, !1, !0, 0, !1, void 0, !1, !1, !0, void 0, !0) || this
- , c = i.getEngine().createMultiviewRenderTargetTexture(s.getRenderWidth(), s.getRenderHeight());
- return s._texture = c.texture,
- s._texture.isMultiview = !0,
- s._texture.format = 5,
- s.samples = s._getEngine().getCaps().maxSamples || s.samples,
- s
- }
- return e.prototype._bindFrameBuffer = function(i) {
- !this._renderTarget || this.getScene().getEngine().bindMultiviewFramebuffer(this._renderTarget)
- }
- ,
- e.prototype.getViewCount = function() {
- return 2
- }
- ,
- e
- }(RenderTargetTexture);
- Engine.prototype.createMultiviewRenderTargetTexture = function(a, e) {
- var i = this._gl;
- if (!this.getCaps().multiview)
- throw "Multiview is not supported";
- var o = this._createHardwareRenderTargetWrapper(!1, !1, {
- width: a,
- height: e
- });
- o._framebuffer = i.createFramebuffer();
- var s = new InternalTexture(this,InternalTextureSource.Unknown,!0);
- return s.width = a,
- s.height = e,
- o._colorTextureArray = i.createTexture(),
- i.bindTexture(i.TEXTURE_2D_ARRAY, o._colorTextureArray),
- i.texStorage3D(i.TEXTURE_2D_ARRAY, 1, i.RGBA8, a, e, 2),
- o._depthStencilTextureArray = i.createTexture(),
- i.bindTexture(i.TEXTURE_2D_ARRAY, o._depthStencilTextureArray),
- i.texStorage3D(i.TEXTURE_2D_ARRAY, 1, i.DEPTH32F_STENCIL8, a, e, 2),
- s.isReady = !0,
- o.setTextures(s),
- o
- }
- ;
- Engine.prototype.bindMultiviewFramebuffer = function(a) {
- var e = a
- , i = this._gl
- , o = this.getCaps().oculusMultiview || this.getCaps().multiview;
- if (this.bindFramebuffer(e, void 0, void 0, void 0, !0),
- i.bindFramebuffer(i.DRAW_FRAMEBUFFER, e._framebuffer),
- e._colorTextureArray && e._depthStencilTextureArray)
- this.getCaps().oculusMultiview ? (o.framebufferTextureMultisampleMultiviewOVR(i.DRAW_FRAMEBUFFER, i.COLOR_ATTACHMENT0, e._colorTextureArray, 0, e.samples, 0, 2),
- 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),
- o.framebufferTextureMultiviewOVR(i.DRAW_FRAMEBUFFER, i.DEPTH_STENCIL_ATTACHMENT, e._depthStencilTextureArray, 0, 0, 2));
- else
- throw "Invalid multiview frame buffer"
- }
- ;
- Camera$1.prototype._useMultiviewToSingleView = !1;
- Camera$1.prototype._multiviewTexture = null;
- Camera$1.prototype._resizeOrCreateMultiviewTexture = function(a, e) {
- this._multiviewTexture ? (this._multiviewTexture.getRenderWidth() != a || this._multiviewTexture.getRenderHeight() != e) && (this._multiviewTexture.dispose(),
- this._multiviewTexture = new MultiviewRenderTarget(this.getScene(),{
- width: a,
- height: e
- })) : this._multiviewTexture = new MultiviewRenderTarget(this.getScene(),{
- width: a,
- height: e
- })
- }
- ;
- function createMultiviewUbo(a, e) {
- var i = new UniformBuffer(a,void 0,!0,e);
- return i.addUniform("viewProjection", 16),
- i.addUniform("viewProjectionR", 16),
- i.addUniform("view", 16),
- i.addUniform("projection", 16),
- i.addUniform("viewPosition", 4),
- i
- }
- var currentCreateSceneUniformBuffer = Scene.prototype.createSceneUniformBuffer;
- Scene.prototype._transformMatrixR = Matrix.Zero();
- Scene.prototype._multiviewSceneUbo = null;
- Scene.prototype._createMultiviewUbo = function() {
- this._multiviewSceneUbo = createMultiviewUbo(this.getEngine(), "scene_multiview")
- }
- ;
- Scene.prototype.createSceneUniformBuffer = function(a) {
- return this._multiviewSceneUbo ? createMultiviewUbo(this.getEngine(), a) : currentCreateSceneUniformBuffer.bind(this)(a)
- }
- ;
- Scene.prototype._updateMultiviewUbo = function(a, e) {
- a && e && a.multiplyToRef(e, this._transformMatrixR),
- a && e && (a.multiplyToRef(e, TmpVectors.Matrix[0]),
- Frustum.GetRightPlaneToRef(TmpVectors.Matrix[0], this._frustumPlanes[3])),
- this._multiviewSceneUbo && (this._multiviewSceneUbo.updateMatrix("viewProjection", this.getTransformMatrix()),
- this._multiviewSceneUbo.updateMatrix("viewProjectionR", this._transformMatrixR),
- this._multiviewSceneUbo.updateMatrix("view", this._viewMatrix),
- this._multiviewSceneUbo.updateMatrix("projection", this._projectionMatrix))
- }
- ;
- Scene.prototype._renderMultiviewToSingleView = function(a) {
- 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)),
- this._multiviewSceneUbo || this._createMultiviewUbo(),
- a.outputRenderTarget = a._multiviewTexture,
- this._renderForCamera(a),
- a.outputRenderTarget = null;
- for (var e = 0; e < a._rigCameras.length; e++) {
- var i = this.getEngine();
- this._activeCamera = a._rigCameras[e],
- i.setViewport(this._activeCamera.viewport),
- this.postProcessManager && (this.postProcessManager._prepareFrame(),
- this.postProcessManager._finalizeFrame(this._activeCamera.isIntermediate))
- }
- }
- ;
- ThinEngine.prototype.updateRawTexture = function(a, e, i, o, s, c) {
- if (s === void 0 && (s = null),
- c === void 0 && (c = 0),
- !!a) {
- var d = this._getRGBABufferInternalSizedFormat(c, i)
- , _ = this._getInternalFormat(i)
- , b = this._getWebGLTextureType(c);
- this._bindTextureDirectly(this._gl.TEXTURE_2D, a, !0),
- this._unpackFlipY(o === void 0 ? !0 : !!o),
- this._doNotHandleContextLost || (a._bufferView = e,
- a.format = i,
- a.type = c,
- a.invertY = o,
- a._compression = s),
- a.width % 4 !== 0 && this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1),
- 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),
- a.generateMipMaps && this._gl.generateMipmap(this._gl.TEXTURE_2D),
- this._bindTextureDirectly(this._gl.TEXTURE_2D, null),
- a.isReady = !0
- }
- }
- ;
- ThinEngine.prototype.createRawTexture = function(a, e, i, o, s, c, d, _, b, k) {
- _ === void 0 && (_ = null),
- b === void 0 && (b = 0);
- var j = new InternalTexture(this,InternalTextureSource.Raw);
- j.baseWidth = e,
- j.baseHeight = i,
- j.width = e,
- j.height = i,
- j.format = o,
- j.generateMipMaps = s,
- j.samplingMode = d,
- j.invertY = c,
- j._compression = _,
- j.type = b,
- this._doNotHandleContextLost || (j._bufferView = a),
- this.updateRawTexture(j, a, o, c, _, b),
- this._bindTextureDirectly(this._gl.TEXTURE_2D, j, !0);
- var $ = this._getSamplingParameters(d, s);
- return this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, $.mag),
- this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, $.min),
- s && this._gl.generateMipmap(this._gl.TEXTURE_2D),
- this._bindTextureDirectly(this._gl.TEXTURE_2D, null),
- this._internalTexturesCache.push(j),
- j
- }
- ;
- ThinEngine.prototype.createRawCubeTexture = function(a, e, i, o, s, c, d, _) {
- _ === void 0 && (_ = null);
- var b = this._gl
- , k = new InternalTexture(this,InternalTextureSource.CubeRaw);
- k.isCube = !0,
- k.format = i,
- k.type = o,
- this._doNotHandleContextLost || (k._bufferViewArray = a);
- var j = this._getWebGLTextureType(o)
- , $ = this._getInternalFormat(i);
- $ === b.RGB && ($ = b.RGBA),
- j === b.FLOAT && !this._caps.textureFloatLinearFiltering ? (s = !1,
- d = 1,
- 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,
- d = 1,
- 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,
- Logger$2.Warn("Render to float textures is not supported. Mipmap generation forced to false.")) : j === b.HALF_FLOAT && !this._caps.colorBufferFloat && (s = !1,
- Logger$2.Warn("Render to half float textures is not supported. Mipmap generation forced to false."));
- var _e = e
- , et = _e;
- k.width = _e,
- k.height = et;
- var tt = !this.needPOTTextures || Tools.IsExponentOfTwo(k.width) && Tools.IsExponentOfTwo(k.height);
- tt || (s = !1),
- a && this.updateRawCubeTexture(k, a, i, o, c, _),
- this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, k, !0),
- a && s && this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
- var rt = this._getSamplingParameters(d, s);
- return b.texParameteri(b.TEXTURE_CUBE_MAP, b.TEXTURE_MAG_FILTER, rt.mag),
- b.texParameteri(b.TEXTURE_CUBE_MAP, b.TEXTURE_MIN_FILTER, rt.min),
- b.texParameteri(b.TEXTURE_CUBE_MAP, b.TEXTURE_WRAP_S, b.CLAMP_TO_EDGE),
- b.texParameteri(b.TEXTURE_CUBE_MAP, b.TEXTURE_WRAP_T, b.CLAMP_TO_EDGE),
- this._bindTextureDirectly(b.TEXTURE_CUBE_MAP, null),
- k.generateMipMaps = s,
- k.samplingMode = d,
- k
- }
- ;
- ThinEngine.prototype.updateRawCubeTexture = function(a, e, i, o, s, c, d) {
- c === void 0 && (c = null),
- d === void 0 && (d = 0),
- a._bufferViewArray = e,
- a.format = i,
- a.type = o,
- a.invertY = s,
- a._compression = c;
- var _ = this._gl
- , b = this._getWebGLTextureType(o)
- , k = this._getInternalFormat(i)
- , j = this._getRGBABufferInternalSizedFormat(o)
- , $ = !1;
- k === _.RGB && (k = _.RGBA,
- $ = !0),
- this._bindTextureDirectly(_.TEXTURE_CUBE_MAP, a, !0),
- this._unpackFlipY(s === void 0 ? !0 : !!s),
- a.width % 4 !== 0 && _.pixelStorei(_.UNPACK_ALIGNMENT, 1);
- for (var _e = 0; _e < 6; _e++) {
- var et = e[_e];
- 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)),
- _.texImage2D(_.TEXTURE_CUBE_MAP_POSITIVE_X + _e, d, j, a.width, a.height, 0, k, b, et))
- }
- var tt = !this.needPOTTextures || Tools.IsExponentOfTwo(a.width) && Tools.IsExponentOfTwo(a.height);
- tt && a.generateMipMaps && d === 0 && this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP),
- this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null),
- a.isReady = !0
- }
- ;
- ThinEngine.prototype.createRawCubeTextureFromUrl = function(a, e, i, o, s, c, d, _, b, k, j, $) {
- var _e = this;
- b === void 0 && (b = null),
- k === void 0 && (k = null),
- j === void 0 && (j = 3),
- $ === void 0 && ($ = !1);
- var et = this._gl
- , tt = this.createRawCubeTexture(null, i, o, s, !c, $, j, null);
- e == null || e._addPendingData(tt),
- tt.url = a,
- this._internalTexturesCache.push(tt);
- var rt = function(nt, ot) {
- e == null || e._removePendingData(tt),
- k && nt && k(nt.status + " " + nt.statusText, ot)
- }
- , it = function(nt) {
- var ot = tt.width
- , at = d(nt);
- if (!!at) {
- if (_) {
- var st = _e._getWebGLTextureType(s)
- , ut = _e._getInternalFormat(o)
- , ct = _e._getRGBABufferInternalSizedFormat(s)
- , lt = !1;
- ut === et.RGB && (ut = et.RGBA,
- lt = !0),
- _e._bindTextureDirectly(et.TEXTURE_CUBE_MAP, tt, !0),
- _e._unpackFlipY(!1);
- for (var ft = _(at), ht = 0; ht < ft.length; ht++)
- for (var pt = ot >> ht, dt = 0; dt < 6; dt++) {
- var _t = ft[ht][dt];
- lt && (_t = _convertRGBtoRGBATextureData$1(_t, pt, pt, s)),
- et.texImage2D(dt, ht, ct, pt, pt, 0, ut, st, _t)
- }
- _e._bindTextureDirectly(et.TEXTURE_CUBE_MAP, null)
- } else
- _e.updateRawCubeTexture(tt, at, o, s, $);
- tt.isReady = !0,
- e == null || e._removePendingData(tt),
- b && b()
- }
- };
- return this._loadFile(a, function(nt) {
- it(nt)
- }, void 0, e == null ? void 0 : e.offlineProvider, !0, rt),
- tt
- }
- ;
- function _convertRGBtoRGBATextureData$1(a, e, i, o) {
- var s, c = 1;
- o === 1 ? s = new Float32Array(e * i * 4) : o === 2 ? (s = new Uint16Array(e * i * 4),
- c = 15360) : o === 7 ? s = new Uint32Array(e * i * 4) : s = new Uint8Array(e * i * 4);
- for (var d = 0; d < e; d++)
- for (var _ = 0; _ < i; _++) {
- var b = (_ * e + d) * 3
- , k = (_ * e + d) * 4;
- s[k + 0] = a[b + 0],
- s[k + 1] = a[b + 1],
- s[k + 2] = a[b + 2],
- s[k + 3] = c
- }
- return s
- }
- function _makeCreateRawTextureFunction(a) {
- return function(e, i, o, s, c, d, _, b, k, j) {
- k === void 0 && (k = null),
- j === void 0 && (j = 0);
- var $ = a ? this._gl.TEXTURE_3D : this._gl.TEXTURE_2D_ARRAY
- , _e = a ? InternalTextureSource.Raw3D : InternalTextureSource.Raw2DArray
- , et = new InternalTexture(this,_e);
- et.baseWidth = i,
- et.baseHeight = o,
- et.baseDepth = s,
- et.width = i,
- et.height = o,
- et.depth = s,
- et.format = c,
- et.type = j,
- et.generateMipMaps = d,
- et.samplingMode = b,
- a ? et.is3D = !0 : et.is2DArray = !0,
- this._doNotHandleContextLost || (et._bufferView = e),
- a ? this.updateRawTexture3D(et, e, c, _, k, j) : this.updateRawTexture2DArray(et, e, c, _, k, j),
- this._bindTextureDirectly($, et, !0);
- var tt = this._getSamplingParameters(b, d);
- return this._gl.texParameteri($, this._gl.TEXTURE_MAG_FILTER, tt.mag),
- this._gl.texParameteri($, this._gl.TEXTURE_MIN_FILTER, tt.min),
- d && this._gl.generateMipmap($),
- this._bindTextureDirectly($, null),
- this._internalTexturesCache.push(et),
- et
- }
- }
- ThinEngine.prototype.createRawTexture2DArray = _makeCreateRawTextureFunction(!1);
- ThinEngine.prototype.createRawTexture3D = _makeCreateRawTextureFunction(!0);
- function _makeUpdateRawTextureFunction(a) {
- return function(e, i, o, s, c, d) {
- c === void 0 && (c = null),
- d === void 0 && (d = 0);
- var _ = a ? this._gl.TEXTURE_3D : this._gl.TEXTURE_2D_ARRAY
- , b = this._getWebGLTextureType(d)
- , k = this._getInternalFormat(o)
- , j = this._getRGBABufferInternalSizedFormat(d, o);
- this._bindTextureDirectly(_, e, !0),
- this._unpackFlipY(s === void 0 ? !0 : !!s),
- this._doNotHandleContextLost || (e._bufferView = i,
- e.format = o,
- e.invertY = s,
- e._compression = c),
- e.width % 4 !== 0 && this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1),
- 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),
- e.generateMipMaps && this._gl.generateMipmap(_),
- this._bindTextureDirectly(_, null),
- e.isReady = !0
- }
- }
- ThinEngine.prototype.updateRawTexture2DArray = _makeUpdateRawTextureFunction(!1);
- ThinEngine.prototype.updateRawTexture3D = _makeUpdateRawTextureFunction(!0);
- ThinEngine.prototype.createDynamicTexture = function(a, e, i, o) {
- var s = new InternalTexture(this,InternalTextureSource.Dynamic);
- return s.baseWidth = a,
- s.baseHeight = e,
- i && (a = this.needPOTTextures ? ThinEngine.GetExponentOfTwo(a, this._caps.maxTextureSize) : a,
- e = this.needPOTTextures ? ThinEngine.GetExponentOfTwo(e, this._caps.maxTextureSize) : e),
- s.width = a,
- s.height = e,
- s.isReady = !1,
- s.generateMipMaps = i,
- s.samplingMode = o,
- this.updateTextureSamplingMode(o, s),
- this._internalTexturesCache.push(s),
- s
- }
- ;
- ThinEngine.prototype.updateDynamicTexture = function(a, e, i, o, s, c, d) {
- if (o === void 0 && (o = !1),
- c === void 0 && (c = !1),
- !!a) {
- var _ = this._gl
- , b = _.TEXTURE_2D
- , k = this._bindTextureDirectly(b, a, !0, c);
- this._unpackFlipY(i === void 0 ? a.invertY : i),
- o && _.pixelStorei(_.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1);
- var j = this._getWebGLTextureType(a.type)
- , $ = this._getInternalFormat(s || a.format)
- , _e = this._getRGBABufferInternalSizedFormat(a.type, $);
- _.texImage2D(b, 0, _e, $, j, e),
- a.generateMipMaps && _.generateMipmap(b),
- k || this._bindTextureDirectly(b, null),
- o && _.pixelStorei(_.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0),
- a.isReady = !0
- }
- }
- ;
- ThinEngine.prototype.createExternalTexture = function(a) {
- return null
- }
- ;
- ThinEngine.prototype.setExternalTexture = function(a, e) {
- throw new Error("setExternalTexture: This engine does not support external textures!")
- }
- ;
- ThinEngine.prototype.updateVideoTexture = function(a, e, i) {
- if (!(!a || a._isDisabled)) {
- var o = this._bindTextureDirectly(this._gl.TEXTURE_2D, a, !0);
- this._unpackFlipY(!i);
- try {
- if (this._videoTextureSupported === void 0 && (this._gl.getError(),
- this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, e),
- this._gl.getError() !== 0 ? this._videoTextureSupported = !1 : this._videoTextureSupported = !0),
- this._videoTextureSupported)
- this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, e);
- else {
- if (!a._workingCanvas) {
- a._workingCanvas = this.createCanvas(a.width, a.height);
- var s = a._workingCanvas.getContext("2d");
- if (!s)
- throw new Error("Unable to get 2d context");
- a._workingContext = s,
- a._workingCanvas.width = a.width,
- a._workingCanvas.height = a.height
- }
- a._workingContext.clearRect(0, 0, a.width, a.height),
- a._workingContext.drawImage(e, 0, 0, e.videoWidth, e.videoHeight, 0, 0, a.width, a.height),
- this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, a._workingCanvas)
- }
- a.generateMipMaps && this._gl.generateMipmap(this._gl.TEXTURE_2D),
- o || this._bindTextureDirectly(this._gl.TEXTURE_2D, null),
- a.isReady = !0
- } catch {
- a._isDisabled = !0
- }
- }
- }
- ;
- ThinEngine.prototype.restoreSingleAttachment = function() {
- var a = this._gl;
- this.bindAttachments([a.BACK])
- }
- ;
- ThinEngine.prototype.restoreSingleAttachmentForRenderTarget = function() {
- var a = this._gl;
- this.bindAttachments([a.COLOR_ATTACHMENT0])
- }
- ;
- ThinEngine.prototype.buildTextureLayout = function(a) {
- for (var e = this._gl, i = [], o = 0; o < a.length; o++)
- a[o] ? i.push(e["COLOR_ATTACHMENT" + o]) : i.push(e.NONE);
- return i
- }
- ;
- ThinEngine.prototype.bindAttachments = function(a) {
- var e = this._gl;
- e.drawBuffers(a)
- }
- ;
- ThinEngine.prototype.unBindMultiColorAttachmentFramebuffer = function(a, e, i) {
- e === void 0 && (e = !1),
- this._currentRenderTarget = null;
- var o = this._gl
- , s = a._attachments
- , c = s.length;
- if (a._MSAAFramebuffer) {
- o.bindFramebuffer(o.READ_FRAMEBUFFER, a._MSAAFramebuffer),
- o.bindFramebuffer(o.DRAW_FRAMEBUFFER, a._framebuffer);
- for (var d = 0; d < c; d++) {
- for (var _ = a.textures[d], b = 0; b < c; b++)
- s[b] = o.NONE;
- s[d] = o[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + d : "COLOR_ATTACHMENT" + d + "_WEBGL"],
- o.readBuffer(s[d]),
- o.drawBuffers(s),
- o.blitFramebuffer(0, 0, _.width, _.height, 0, 0, _.width, _.height, o.COLOR_BUFFER_BIT, o.NEAREST)
- }
- for (var d = 0; d < c; d++)
- s[d] = o[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + d : "COLOR_ATTACHMENT" + d + "_WEBGL"];
- o.drawBuffers(s)
- }
- for (var d = 0; d < c; d++) {
- var _ = a.textures[d];
- _.generateMipMaps && !e && !_.isCube && (this._bindTextureDirectly(o.TEXTURE_2D, _, !0),
- o.generateMipmap(o.TEXTURE_2D),
- this._bindTextureDirectly(o.TEXTURE_2D, null))
- }
- i && (a._MSAAFramebuffer && this._bindUnboundFramebuffer(a._framebuffer),
- i()),
- this._bindUnboundFramebuffer(null)
- }
- ;
- ThinEngine.prototype.createMultipleRenderTarget = function(a, e, i) {
- i === void 0 && (i = !0);
- var o = !1
- , s = !0
- , c = !1
- , d = !1
- , _ = 15
- , b = 1
- , k = 0
- , j = 3
- , $ = new Array
- , _e = new Array
- , et = this._createHardwareRenderTargetWrapper(!0, !1, a);
- e !== void 0 && (o = e.generateMipMaps === void 0 ? !1 : e.generateMipMaps,
- s = e.generateDepthBuffer === void 0 ? !0 : e.generateDepthBuffer,
- c = e.generateStencilBuffer === void 0 ? !1 : e.generateStencilBuffer,
- d = e.generateDepthTexture === void 0 ? !1 : e.generateDepthTexture,
- b = e.textureCount || 1,
- e.types && ($ = e.types),
- e.samplingModes && (_e = e.samplingModes),
- this.webGLVersion > 1 && (e.depthTextureFormat === 13 || e.depthTextureFormat === 16 || e.depthTextureFormat === 14) && (_ = e.depthTextureFormat));
- var tt = this._gl
- , rt = tt.createFramebuffer();
- this._bindUnboundFramebuffer(rt);
- var it = a.width || a
- , nt = a.height || a
- , ot = []
- , at = []
- , st = this.webGLVersion > 1 && d && e.depthTextureFormat === 13
- , ut = this._setupFramebufferDepthAttachments(!st && c, !d && s, it, nt);
- et._framebuffer = rt,
- et._depthStencilBuffer = ut,
- et._generateDepthBuffer = !d && s,
- et._generateStencilBuffer = !st && c,
- et._attachments = at;
- for (var ct = 0; ct < b; ct++) {
- var lt = _e[ct] || j
- , ft = $[ct] || k;
- (ft === 1 && !this._caps.textureFloatLinearFiltering || ft === 2 && !this._caps.textureHalfFloatLinearFiltering) && (lt = 1);
- var ht = this._getSamplingParameters(lt, o);
- ft === 1 && !this._caps.textureFloat && (ft = 0,
- Logger$2.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type"));
- var pt = new InternalTexture(this,InternalTextureSource.MultiRenderTarget)
- , dt = tt[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + ct : "COLOR_ATTACHMENT" + ct + "_WEBGL"];
- ot.push(pt),
- at.push(dt),
- tt.activeTexture(tt["TEXTURE" + ct]),
- tt.bindTexture(tt.TEXTURE_2D, pt._hardwareTexture.underlyingResource),
- tt.texParameteri(tt.TEXTURE_2D, tt.TEXTURE_MAG_FILTER, ht.mag),
- tt.texParameteri(tt.TEXTURE_2D, tt.TEXTURE_MIN_FILTER, ht.min),
- tt.texParameteri(tt.TEXTURE_2D, tt.TEXTURE_WRAP_S, tt.CLAMP_TO_EDGE),
- tt.texParameteri(tt.TEXTURE_2D, tt.TEXTURE_WRAP_T, tt.CLAMP_TO_EDGE),
- tt.texImage2D(tt.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(ft), it, nt, 0, tt.RGBA, this._getWebGLTextureType(ft), null),
- tt.framebufferTexture2D(tt.DRAW_FRAMEBUFFER, dt, tt.TEXTURE_2D, pt._hardwareTexture.underlyingResource, 0),
- o && this._gl.generateMipmap(this._gl.TEXTURE_2D),
- this._bindTextureDirectly(tt.TEXTURE_2D, null),
- pt.baseWidth = it,
- pt.baseHeight = nt,
- pt.width = it,
- pt.height = nt,
- pt.isReady = !0,
- pt.samples = 1,
- pt.generateMipMaps = o,
- pt.samplingMode = lt,
- pt.type = ft,
- this._internalTexturesCache.push(pt)
- }
- if (d && this._caps.depthTextureExtension) {
- var _t = new InternalTexture(this,InternalTextureSource.Depth)
- , mt = 5
- , vt = tt.DEPTH_COMPONENT16
- , yt = tt.DEPTH_COMPONENT
- , Et = tt.UNSIGNED_SHORT
- , At = tt.DEPTH_ATTACHMENT;
- this.webGLVersion < 2 ? vt = tt.DEPTH_COMPONENT : _ === 14 ? (mt = 1,
- Et = tt.FLOAT,
- vt = tt.DEPTH_COMPONENT32F) : _ === 16 ? (mt = 0,
- Et = tt.UNSIGNED_INT,
- vt = tt.DEPTH_COMPONENT24,
- At = tt.DEPTH_ATTACHMENT) : _ === 13 && (mt = 12,
- Et = tt.UNSIGNED_INT_24_8,
- vt = tt.DEPTH24_STENCIL8,
- yt = tt.DEPTH_STENCIL,
- At = tt.DEPTH_STENCIL_ATTACHMENT),
- tt.activeTexture(tt.TEXTURE0),
- tt.bindTexture(tt.TEXTURE_2D, _t._hardwareTexture.underlyingResource),
- tt.texParameteri(tt.TEXTURE_2D, tt.TEXTURE_MAG_FILTER, tt.NEAREST),
- tt.texParameteri(tt.TEXTURE_2D, tt.TEXTURE_MIN_FILTER, tt.NEAREST),
- tt.texParameteri(tt.TEXTURE_2D, tt.TEXTURE_WRAP_S, tt.CLAMP_TO_EDGE),
- tt.texParameteri(tt.TEXTURE_2D, tt.TEXTURE_WRAP_T, tt.CLAMP_TO_EDGE),
- tt.texImage2D(tt.TEXTURE_2D, 0, vt, it, nt, 0, yt, Et, null),
- tt.framebufferTexture2D(tt.FRAMEBUFFER, At, tt.TEXTURE_2D, _t._hardwareTexture.underlyingResource, 0),
- _t.baseWidth = it,
- _t.baseHeight = nt,
- _t.width = it,
- _t.height = nt,
- _t.isReady = !0,
- _t.samples = 1,
- _t.generateMipMaps = o,
- _t.samplingMode = 1,
- _t.format = _,
- _t.type = mt,
- ot.push(_t),
- this._internalTexturesCache.push(_t)
- }
- return et.setTextures(ot),
- i && tt.drawBuffers(at),
- this._bindUnboundFramebuffer(null),
- this.resetTextureCache(),
- et
- }
- ;
- ThinEngine.prototype.updateMultipleRenderTargetTextureSampleCount = function(a, e, i) {
- if (i === void 0 && (i = !0),
- this.webGLVersion < 2 || !a || !a.texture)
- return 1;
- if (a.samples === e)
- return e;
- var o = a._attachments.length;
- if (o === 0)
- return 1;
- var s = this._gl;
- e = Math.min(e, this.getCaps().maxMSAASamples),
- a._depthStencilBuffer && (s.deleteRenderbuffer(a._depthStencilBuffer),
- a._depthStencilBuffer = null),
- a._MSAAFramebuffer && (s.deleteFramebuffer(a._MSAAFramebuffer),
- a._MSAAFramebuffer = null);
- for (var c = 0; c < o; c++) {
- var d = a.textures[c]._hardwareTexture;
- d != null && d._MSAARenderBuffer && (s.deleteRenderbuffer(d._MSAARenderBuffer),
- d._MSAARenderBuffer = null)
- }
- if (e > 1 && s.renderbufferStorageMultisample) {
- var _ = s.createFramebuffer();
- if (!_)
- throw new Error("Unable to create multi sampled framebuffer");
- a._MSAAFramebuffer = _,
- this._bindUnboundFramebuffer(_);
- for (var b = [], c = 0; c < o; c++) {
- var k = a.textures[c]
- , d = k._hardwareTexture
- , j = s[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + c : "COLOR_ATTACHMENT" + c + "_WEBGL"]
- , $ = this._createRenderBuffer(k.width, k.height, e, -1, this._getRGBAMultiSampleBufferFormat(k.type), j);
- if (!$)
- throw new Error("Unable to create multi sampled framebuffer");
- d._MSAARenderBuffer = $,
- k.samples = e,
- b.push(j)
- }
- i && s.drawBuffers(b)
- } else
- this._bindUnboundFramebuffer(a._framebuffer);
- return a._depthStencilBuffer = this._setupFramebufferDepthAttachments(a._generateStencilBuffer, a._generateDepthBuffer, a.texture.width, a.texture.height, e),
- this._bindUnboundFramebuffer(null),
- e
- }
- ;
- ThinEngine.prototype._createDepthStencilCubeTexture = function(a, e, i) {
- var o = new InternalTexture(this,InternalTextureSource.DepthStencil);
- if (o.isCube = !0,
- this.webGLVersion === 1)
- return Logger$2.Error("Depth cube texture is not supported by WebGL 1."),
- o;
- var s = __assign({
- bilinearFiltering: !1,
- comparisonFunction: 0,
- generateStencil: !1
- }, e)
- , c = this._gl;
- this._bindTextureDirectly(c.TEXTURE_CUBE_MAP, o, !0),
- this._setupDepthStencilTexture(o, a, s.generateStencil, s.bilinearFiltering, s.comparisonFunction),
- i._depthStencilTexture = o,
- i._depthStencilTextureWithStencil = s.generateStencil;
- for (var d = 0; d < 6; d++)
- 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);
- return this._bindTextureDirectly(c.TEXTURE_CUBE_MAP, null),
- this._internalTexturesCache.push(o),
- o
- }
- ;
- ThinEngine.prototype._partialLoadFile = function(a, e, i, o, s) {
- s === void 0 && (s = null);
- var c = function(_) {
- i[e] = _,
- i._internalCount++,
- i._internalCount === 6 && o(i)
- }
- , d = function(_, b) {
- s && _ && s(_.status + " " + _.statusText, b)
- };
- this._loadFile(a, c, void 0, void 0, !0, d)
- }
- ;
- ThinEngine.prototype._cascadeLoadFiles = function(a, e, i, o) {
- o === void 0 && (o = null);
- var s = [];
- s._internalCount = 0;
- for (var c = 0; c < 6; c++)
- this._partialLoadFile(i[c], c, s, e, o)
- }
- ;
- ThinEngine.prototype._cascadeLoadImgs = function(a, e, i, o, s, c) {
- s === void 0 && (s = null);
- var d = [];
- d._internalCount = 0;
- for (var _ = 0; _ < 6; _++)
- this._partialLoadImg(o[_], _, d, a, e, i, s, c)
- }
- ;
- ThinEngine.prototype._partialLoadImg = function(a, e, i, o, s, c, d, _) {
- d === void 0 && (d = null);
- var b = RandomGUID()
- , k = function($) {
- i[e] = $,
- i._internalCount++,
- o && o._removePendingData(b),
- i._internalCount === 6 && c && c(s, i)
- }
- , j = function($, _e) {
- o && o._removePendingData(b),
- d && d($, _e)
- };
- LoadImage(a, k, j, o ? o.offlineProvider : null, _),
- o && o._addPendingData(b)
- }
- ;
- ThinEngine.prototype._setCubeMapTextureParams = function(a, e) {
- var i = this._gl;
- i.texParameteri(i.TEXTURE_CUBE_MAP, i.TEXTURE_MAG_FILTER, i.LINEAR),
- i.texParameteri(i.TEXTURE_CUBE_MAP, i.TEXTURE_MIN_FILTER, e ? i.LINEAR_MIPMAP_LINEAR : i.LINEAR),
- i.texParameteri(i.TEXTURE_CUBE_MAP, i.TEXTURE_WRAP_S, i.CLAMP_TO_EDGE),
- i.texParameteri(i.TEXTURE_CUBE_MAP, i.TEXTURE_WRAP_T, i.CLAMP_TO_EDGE),
- a.samplingMode = e ? 3 : 2,
- this._bindTextureDirectly(i.TEXTURE_CUBE_MAP, null)
- }
- ;
- ThinEngine.prototype.createCubeTextureBase = function(a, e, i, o, s, c, d, _, b, k, j, $, _e, et, tt) {
- var rt = this;
- s === void 0 && (s = null),
- c === void 0 && (c = null),
- _ === void 0 && (_ = null),
- b === void 0 && (b = !1),
- k === void 0 && (k = 0),
- j === void 0 && (j = 0),
- $ === void 0 && ($ = null),
- _e === void 0 && (_e = null),
- et === void 0 && (et = null),
- tt === void 0 && (tt = !1);
- var it = $ || new InternalTexture(this,InternalTextureSource.Cube);
- it.isCube = !0,
- it.url = a,
- it.generateMipMaps = !o,
- it._lodGenerationScale = k,
- it._lodGenerationOffset = j,
- it._useSRGBBuffer = !!tt && this._caps.supportSRGBBuffers && (this.webGLVersion > 1 || this.isWebGPU || !!o),
- this._doNotHandleContextLost || (it._extension = _,
- it._files = i);
- var nt = a;
- this._transformTextureUrl && !$ && (a = this._transformTextureUrl(a));
- for (var ot = a.lastIndexOf("."), at = _ || (ot > -1 ? a.substring(ot).toLowerCase() : ""), st = null, ut = 0, ct = ThinEngine._TextureLoaders; ut < ct.length; ut++) {
- var lt = ct[ut];
- if (lt.canLoad(at)) {
- st = lt;
- break
- }
- }
- var ft = function(pt, dt) {
- a === nt ? c && pt && c(pt.status + " " + pt.statusText, dt) : (Logger$2.Warn("Failed to load " + a + ", falling back to the " + nt),
- rt.createCubeTextureBase(nt, e, i, !!o, s, c, d, _, b, k, j, it, _e, et, tt))
- };
- if (st) {
- var ht = function(pt) {
- _e && _e(it, pt),
- st.loadCubeData(pt, it, b, s, c)
- };
- i && i.length === 6 ? st.supportCascades ? this._cascadeLoadFiles(e, function(pt) {
- return ht(pt.map(function(dt) {
- return new Uint8Array(dt)
- }))
- }, i, c) : c ? c("Textures type does not support cascades.") : Logger$2.Warn("Texture loader does not support cascades.") : this._loadFile(a, function(pt) {
- return ht(new Uint8Array(pt))
- }, void 0, void 0, !0, ft)
- } else {
- if (!i)
- throw new Error("Cannot load cubemap because files were not defined");
- this._cascadeLoadImgs(e, it, function(pt, dt) {
- et && et(pt, dt)
- }, i, c)
- }
- return this._internalTexturesCache.push(it),
- it
- }
- ;
- ThinEngine.prototype.createCubeTexture = function(a, e, i, o, s, c, d, _, b, k, j, $, _e, et) {
- var tt = this;
- s === void 0 && (s = null),
- c === void 0 && (c = null),
- _ === void 0 && (_ = null),
- b === void 0 && (b = !1),
- k === void 0 && (k = 0),
- j === void 0 && (j = 0),
- $ === void 0 && ($ = null),
- et === void 0 && (et = !1);
- var rt = this._gl;
- return this.createCubeTextureBase(a, e, i, !!o, s, c, d, _, b, k, j, $, function(it, nt) {
- return tt._bindTextureDirectly(rt.TEXTURE_CUBE_MAP, it, !0)
- }, function(it, nt) {
- var ot = tt.needPOTTextures ? ThinEngine.GetExponentOfTwo(nt[0].width, tt._caps.maxCubemapTextureSize) : nt[0].width
- , at = ot
- , 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];
- tt._bindTextureDirectly(rt.TEXTURE_CUBE_MAP, it, !0),
- tt._unpackFlipY(!1);
- var ut = d ? tt._getInternalFormat(d, it._useSRGBBuffer) : it._useSRGBBuffer ? rt.SRGB8_ALPHA8 : rt.RGBA
- , ct = d ? tt._getInternalFormat(d) : rt.RGBA;
- it._useSRGBBuffer && tt.webGLVersion === 1 && (ct = ut);
- for (var lt = 0; lt < st.length; lt++)
- if (nt[lt].width !== ot || nt[lt].height !== at) {
- if (tt._prepareWorkingCanvas(),
- !tt._workingCanvas || !tt._workingContext) {
- Logger$2.Warn("Cannot create canvas to resize texture.");
- return
- }
- tt._workingCanvas.width = ot,
- tt._workingCanvas.height = at,
- tt._workingContext.drawImage(nt[lt], 0, 0, nt[lt].width, nt[lt].height, 0, 0, ot, at),
- rt.texImage2D(st[lt], 0, ut, ct, rt.UNSIGNED_BYTE, tt._workingCanvas)
- } else
- rt.texImage2D(st[lt], 0, ut, ct, rt.UNSIGNED_BYTE, nt[lt]);
- o || rt.generateMipmap(rt.TEXTURE_CUBE_MAP),
- tt._setCubeMapTextureParams(it, !o),
- it.width = ot,
- it.height = at,
- it.isReady = !0,
- d && (it.format = d),
- it.onLoadedObservable.notifyObservers(it),
- it.onLoadedObservable.clear(),
- s && s()
- }, !!et)
- }
- ;
- ThinEngine.prototype.setTextureSampler = function(a, e) {
- throw new Error("setTextureSampler: This engine does not support separate texture sampler objects!")
- }
- ;
- Object.defineProperty(Engine.prototype, "isInVRExclusivePointerMode", {
- get: function() {
- return this._vrExclusivePointerMode
- },
- enumerable: !0,
- configurable: !0
- });
- Engine.prototype._prepareVRComponent = function() {
- this._vrSupported = !1,
- this._vrExclusivePointerMode = !1,
- this.onVRDisplayChangedObservable = new Observable,
- this.onVRRequestPresentComplete = new Observable,
- this.onVRRequestPresentStart = new Observable
- }
- ;
- Engine.prototype.isVRDevicePresent = function() {
- return !!this._vrDisplay
- }
- ;
- Engine.prototype.getVRDevice = function() {
- return this._vrDisplay
- }
- ;
- Engine.prototype.initWebVR = function() {
- return this.initWebVRAsync(),
- this.onVRDisplayChangedObservable
- }
- ;
- Engine.prototype.initWebVRAsync = function() {
- var a = this
- , e = function() {
- var o = {
- vrDisplay: a._vrDisplay,
- vrSupported: a._vrSupported
- };
- a.onVRDisplayChangedObservable.notifyObservers(o),
- a._webVRInitPromise = new Promise(function(s) {
- s(o)
- }
- )
- };
- if (!this._onVrDisplayConnect) {
- this._onVrDisplayConnect = function(o) {
- a._vrDisplay = o.display,
- e()
- }
- ,
- this._onVrDisplayDisconnect = function() {
- a._vrDisplay.cancelAnimationFrame(a._frameHandler),
- a._vrDisplay = void 0,
- a._frameHandler = Engine.QueueNewFrame(a._boundRenderFunction),
- e()
- }
- ,
- this._onVrDisplayPresentChange = function() {
- a._vrExclusivePointerMode = a._vrDisplay && a._vrDisplay.isPresenting
- }
- ;
- var i = this.getHostWindow();
- i && (i.addEventListener("vrdisplayconnect", this._onVrDisplayConnect),
- i.addEventListener("vrdisplaydisconnect", this._onVrDisplayDisconnect),
- i.addEventListener("vrdisplaypresentchange", this._onVrDisplayPresentChange))
- }
- return this._webVRInitPromise = this._webVRInitPromise || this._getVRDisplaysAsync(),
- this._webVRInitPromise.then(e),
- this._webVRInitPromise
- }
- ;
- Engine.prototype._getVRDisplaysAsync = function() {
- var a = this;
- return new Promise(function(e) {
- navigator.getVRDisplays ? navigator.getVRDisplays().then(function(i) {
- a._vrSupported = !0,
- a._vrDisplay = i[0],
- e({
- vrDisplay: a._vrDisplay,
- vrSupported: a._vrSupported
- })
- }) : (a._vrDisplay = void 0,
- a._vrSupported = !1,
- e({
- vrDisplay: a._vrDisplay,
- vrSupported: a._vrSupported
- }))
- }
- )
- }
- ;
- Engine.prototype.enableVR = function(a) {
- var e = this;
- if (this._vrDisplay && !this._vrDisplay.isPresenting) {
- var i = function() {
- e.onVRRequestPresentComplete.notifyObservers(!0),
- e._onVRFullScreenTriggered()
- }
- , o = function() {
- e.onVRRequestPresentComplete.notifyObservers(!1)
- };
- this.onVRRequestPresentStart.notifyObservers(this);
- var s = {
- highRefreshRate: this.vrPresentationAttributes ? this.vrPresentationAttributes.highRefreshRate : !1,
- foveationLevel: this.vrPresentationAttributes ? this.vrPresentationAttributes.foveationLevel : 1,
- multiview: (this.getCaps().multiview || this.getCaps().oculusMultiview) && a.useMultiview
- };
- this._vrDisplay.requestPresent([__assign({
- source: this.getRenderingCanvas(),
- attributes: s
- }, s)]).then(i).catch(o)
- }
- }
- ;
- Engine.prototype._onVRFullScreenTriggered = function() {
- if (this._vrDisplay && this._vrDisplay.isPresenting) {
- this._oldSize = new Size(this.getRenderWidth(),this.getRenderHeight()),
- this._oldHardwareScaleFactor = this.getHardwareScalingLevel();
- var a = this._vrDisplay.getEyeParameters("left");
- this.setHardwareScalingLevel(1),
- this.setSize(a.renderWidth * 2, a.renderHeight)
- } else
- this.setHardwareScalingLevel(this._oldHardwareScaleFactor),
- this.setSize(this._oldSize.width, this._oldSize.height)
- }
- ;
- Engine.prototype.disableVR = function() {
- var a = this;
- this._vrDisplay && this._vrDisplay.isPresenting && this._vrDisplay.exitPresent().then(function() {
- return a._onVRFullScreenTriggered()
- }).catch(function() {
- return a._onVRFullScreenTriggered()
- }),
- IsWindowObjectExist() && (window.removeEventListener("vrdisplaypointerrestricted", this._onVRDisplayPointerRestricted),
- window.removeEventListener("vrdisplaypointerunrestricted", this._onVRDisplayPointerUnrestricted),
- this._onVrDisplayConnect && (window.removeEventListener("vrdisplayconnect", this._onVrDisplayConnect),
- this._onVrDisplayDisconnect && window.removeEventListener("vrdisplaydisconnect", this._onVrDisplayDisconnect),
- this._onVrDisplayPresentChange && window.removeEventListener("vrdisplaypresentchange", this._onVrDisplayPresentChange),
- this._onVrDisplayConnect = null,
- this._onVrDisplayDisconnect = null))
- }
- ;
- Engine.prototype._connectVREvents = function(a, e) {
- var i = this;
- if (this._onVRDisplayPointerRestricted = function() {
- a && a.requestPointerLock()
- }
- ,
- this._onVRDisplayPointerUnrestricted = function() {
- if (!e) {
- var s = i.getHostWindow();
- s.document && s.document.exitPointerLock && s.document.exitPointerLock();
- return
- }
- !e.exitPointerLock || e.exitPointerLock()
- }
- ,
- IsWindowObjectExist()) {
- var o = this.getHostWindow();
- o.addEventListener("vrdisplaypointerrestricted", this._onVRDisplayPointerRestricted, !1),
- o.addEventListener("vrdisplaypointerunrestricted", this._onVRDisplayPointerUnrestricted, !1)
- }
- }
- ;
- Engine.prototype._submitVRFrame = function() {
- if (this._vrDisplay && this._vrDisplay.isPresenting)
- try {
- this._vrDisplay.submitFrame()
- } catch (a) {
- Tools.Warn("webVR submitFrame has had an unexpected failure: " + a)
- }
- }
- ;
- Engine.prototype.isVRPresenting = function() {
- return this._vrDisplay && this._vrDisplay.isPresenting
- }
- ;
- Engine.prototype._requestVRFrame = function() {
- this._frameHandler = Engine.QueueNewFrame(this._boundRenderFunction, this._vrDisplay)
- }
- ;
- Engine.prototype.getInputElement = function() {
- return this.inputElement || this.getRenderingCanvas()
- }
- ;
- Engine.prototype.registerView = function(a, e, i) {
- var o = this;
- this.views || (this.views = []);
- for (var s = 0, c = this.views; s < c.length; s++) {
- var d = c[s];
- if (d.target === a)
- return d
- }
- var _ = this.getRenderingCanvas();
- _ && (a.width = _.width,
- a.height = _.height);
- var b = {
- target: a,
- camera: e,
- clearBeforeCopy: i,
- enabled: !0
- };
- return this.views.push(b),
- e && e.onDisposeObservable.add(function() {
- o.unRegisterView(a)
- }),
- b
- }
- ;
- Engine.prototype.unRegisterView = function(a) {
- if (!this.views)
- return this;
- for (var e = 0, i = this.views; e < i.length; e++) {
- var o = i[e];
- if (o.target === a) {
- var s = this.views.indexOf(o);
- s !== -1 && this.views.splice(s, 1);
- break
- }
- }
- return this
- }
- ;
- Engine.prototype._renderViews = function() {
- if (!this.views)
- return !1;
- var a = this.getRenderingCanvas();
- if (!a)
- return !1;
- for (var e = 0, i = this.views; e < i.length; e++) {
- var o = i[e];
- if (!!o.enabled) {
- var s = o.target
- , c = s.getContext("2d");
- if (!!c) {
- var d = o.camera
- , _ = null
- , b = null;
- if (d) {
- if (b = d.getScene(),
- b.activeCameras && b.activeCameras.length)
- continue;
- this.activeView = o,
- _ = b.activeCamera,
- b.activeCamera = d
- }
- if (o.customResize)
- o.customResize(s);
- else {
- var k = Math.floor(s.clientWidth / this._hardwareScalingLevel)
- , j = Math.floor(s.clientHeight / this._hardwareScalingLevel)
- , $ = k !== s.width || a.width !== s.width || j !== s.height || a.height !== s.height;
- s.clientWidth && s.clientHeight && $ && (s.width = k,
- s.height = j,
- this.setSize(k, j))
- }
- if (!a.width || !a.height)
- return !1;
- this._renderFrame(),
- this.flushFramebuffer(),
- o.clearBeforeCopy && c.clearRect(0, 0, a.width, a.height),
- c.drawImage(a, 0, 0),
- _ && b && (b.activeCamera = _)
- }
- }
- }
- return this.activeView = null,
- !0
- }
- ;
- var ComputeBindingType;
- (function(a) {
- a[a.Texture = 0] = "Texture",
- a[a.StorageTexture = 1] = "StorageTexture",
- a[a.UniformBuffer = 2] = "UniformBuffer",
- a[a.StorageBuffer = 3] = "StorageBuffer",
- a[a.TextureWithoutSampler = 4] = "TextureWithoutSampler",
- a[a.Sampler = 5] = "Sampler"
- }
- )(ComputeBindingType || (ComputeBindingType = {}));
- ThinEngine.prototype.createComputeEffect = function(a, e) {
- throw new Error("createComputeEffect: This engine does not support compute shaders!")
- }
- ;
- ThinEngine.prototype.createComputePipelineContext = function() {
- throw new Error("createComputePipelineContext: This engine does not support compute shaders!")
- }
- ;
- ThinEngine.prototype.createComputeContext = function() {}
- ;
- ThinEngine.prototype.computeDispatch = function(a, e, i, o, s, c, d) {
- throw new Error("computeDispatch: This engine does not support compute shaders!")
- }
- ;
- ThinEngine.prototype.areAllComputeEffectsReady = function() {
- return !0
- }
- ;
- ThinEngine.prototype.releaseComputeEffects = function() {}
- ;
- ThinEngine.prototype._prepareComputePipelineContext = function(a, e, i, o, s) {}
- ;
- ThinEngine.prototype._rebuildComputeEffects = function() {}
- ;
- ThinEngine.prototype._executeWhenComputeStateIsCompiled = function(a, e) {
- e()
- }
- ;
- ThinEngine.prototype._releaseComputeEffect = function(a) {}
- ;
- ThinEngine.prototype._deleteComputePipelineContext = function(a) {}
- ;
- ThinEngine.prototype.createStorageBuffer = function(a, e) {
- throw new Error("createStorageBuffer: Unsupported method in this engine!")
- }
- ;
- ThinEngine.prototype.updateStorageBuffer = function(a, e, i, o) {}
- ;
- ThinEngine.prototype.readFromStorageBuffer = function(a, e, i, o) {
- throw new Error("readFromStorageBuffer: Unsupported method in this engine!")
- }
- ;
- ThinEngine.prototype.setStorageBuffer = function(a, e) {
- throw new Error("setStorageBuffer: Unsupported method in this engine!")
- }
- ;
- function transformTextureUrl(a) {
- var e = function(c) {
- var d = "\\b" + c + "\\b";
- return a && (a === c || a.match(new RegExp(d,"g")))
- };
- if (this._excludedCompressedTextures && this._excludedCompressedTextures.some(e))
- return a;
- var i = a.lastIndexOf(".")
- , o = a.lastIndexOf("?")
- , s = o > -1 ? a.substring(o, a.length) : "";
- return (i > -1 ? a.substring(0, i) : a) + this._textureFormatInUse + s
- }
- Object.defineProperty(Engine.prototype, "texturesSupported", {
- get: function() {
- var a = new Array;
- return this._caps.astc && a.push("-astc.ktx"),
- this._caps.s3tc && a.push("-dxt.ktx"),
- this._caps.pvrtc && a.push("-pvrtc.ktx"),
- this._caps.etc2 && a.push("-etc2.ktx"),
- this._caps.etc1 && a.push("-etc1.ktx"),
- a
- },
- enumerable: !0,
- configurable: !0
- });
- Object.defineProperty(Engine.prototype, "textureFormatInUse", {
- get: function() {
- return this._textureFormatInUse || null
- },
- enumerable: !0,
- configurable: !0
- });
- Engine.prototype.setCompressedTextureExclusions = function(a) {
- this._excludedCompressedTextures = a
- }
- ;
- Engine.prototype.setTextureFormatToUse = function(a) {
- for (var e = this.texturesSupported, i = 0, o = e.length; i < o; i++)
- for (var s = 0, c = a.length; s < c; s++)
- if (e[i] === a[s].toLowerCase())
- return this._transformTextureUrl = transformTextureUrl.bind(this),
- this._textureFormatInUse = e[i];
- return this._textureFormatInUse = "",
- this._transformTextureUrl = null,
- null
- }
- ;
- var NativeDataStream = function() {
- function a() {
- var e = this
- , i = new ArrayBuffer(a.DEFAULT_BUFFER_SIZE);
- this._uint32s = new Uint32Array(i),
- this._int32s = new Int32Array(i),
- this._float32s = new Float32Array(i),
- this._length = a.DEFAULT_BUFFER_SIZE / 4,
- this._position = 0,
- this._nativeDataStream = new _native.NativeDataStream(function() {
- e._flush()
- }
- )
- }
- return a.prototype.writeUint32 = function(e) {
- this._flushIfNecessary(1),
- this._uint32s[this._position++] = e
- }
- ,
- a.prototype.writeInt32 = function(e) {
- this._flushIfNecessary(1),
- this._int32s[this._position++] = e
- }
- ,
- a.prototype.writeFloat32 = function(e) {
- this._flushIfNecessary(1),
- this._float32s[this._position++] = e
- }
- ,
- a.prototype.writeUint32Array = function(e) {
- this._flushIfNecessary(1 + e.length),
- this._uint32s[this._position++] = e.length,
- this._uint32s.set(e, this._position),
- this._position += e.length
- }
- ,
- a.prototype.writeInt32Array = function(e) {
- this._flushIfNecessary(1 + e.length),
- this._uint32s[this._position++] = e.length,
- this._int32s.set(e, this._position),
- this._position += e.length
- }
- ,
- a.prototype.writeFloat32Array = function(e) {
- this._flushIfNecessary(1 + e.length),
- this._uint32s[this._position++] = e.length,
- this._float32s.set(e, this._position),
- this._position += e.length
- }
- ,
- a.prototype.writeNativeData = function(e) {
- this._flushIfNecessary(e.length),
- this._uint32s.set(e, this._position),
- this._position += e.length
- }
- ,
- a.prototype.writeBoolean = function(e) {
- this.writeUint32(e ? 1 : 0)
- }
- ,
- a.prototype._flushIfNecessary = function(e) {
- this._position + e > this._length && this._flush()
- }
- ,
- a.prototype._flush = function() {
- this._nativeDataStream.writeBuffer(this._uint32s.buffer, this._position),
- this._position = 0
- }
- ,
- a.DEFAULT_BUFFER_SIZE = 65536,
- a
- }(), Orientation;
- (function(a) {
- a[a.CW = 0] = "CW",
- a[a.CCW = 1] = "CCW"
- }
- )(Orientation || (Orientation = {}));
- var BezierCurve = function() {
- function a() {}
- return a.Interpolate = function(e, i, o, s, c) {
- for (var d = 1 - 3 * s + 3 * i, _ = 3 * s - 6 * i, b = 3 * i, k = e, j = 0; j < 5; j++) {
- var $ = k * k
- , _e = $ * k
- , et = d * _e + _ * $ + b * k
- , tt = 1 / (3 * d * $ + 2 * _ * k + b);
- k -= (et - e) * tt,
- k = Math.min(1, Math.max(0, k))
- }
- return 3 * Math.pow(1 - k, 2) * k * o + 3 * (1 - k) * Math.pow(k, 2) * c + Math.pow(k, 3)
- }
- ,
- a
- }()
- , Angle = function() {
- function a(e) {
- this._radians = e,
- this._radians < 0 && (this._radians += 2 * Math.PI)
- }
- return a.prototype.degrees = function() {
- return this._radians * 180 / Math.PI
- }
- ,
- a.prototype.radians = function() {
- return this._radians
- }
- ,
- a.BetweenTwoPoints = function(e, i) {
- var o = i.subtract(e)
- , s = Math.atan2(o.y, o.x);
- return new a(s)
- }
- ,
- a.FromRadians = function(e) {
- return new a(e)
- }
- ,
- a.FromDegrees = function(e) {
- return new a(e * Math.PI / 180)
- }
- ,
- a
- }()
- , Arc2 = function() {
- function a(e, i, o) {
- this.startPoint = e,
- this.midPoint = i,
- this.endPoint = o;
- var s = Math.pow(i.x, 2) + Math.pow(i.y, 2)
- , c = (Math.pow(e.x, 2) + Math.pow(e.y, 2) - s) / 2
- , d = (s - Math.pow(o.x, 2) - Math.pow(o.y, 2)) / 2
- , _ = (e.x - i.x) * (i.y - o.y) - (i.x - o.x) * (e.y - i.y);
- this.centerPoint = new Vector2((c * (i.y - o.y) - d * (e.y - i.y)) / _,((e.x - i.x) * d - (i.x - o.x) * c) / _),
- this.radius = this.centerPoint.subtract(this.startPoint).length(),
- this.startAngle = Angle.BetweenTwoPoints(this.centerPoint, this.startPoint);
- var b = this.startAngle.degrees()
- , k = Angle.BetweenTwoPoints(this.centerPoint, this.midPoint).degrees()
- , j = Angle.BetweenTwoPoints(this.centerPoint, this.endPoint).degrees();
- k - b > 180 && (k -= 360),
- k - b < -180 && (k += 360),
- j - k > 180 && (j -= 360),
- j - k < -180 && (j += 360),
- this.orientation = k - b < 0 ? Orientation.CW : Orientation.CCW,
- this.angle = Angle.FromDegrees(this.orientation === Orientation.CW ? b - j : j - b)
- }
- return a
- }()
- , Path2 = function() {
- function a(e, i) {
- this._points = new Array,
- this._length = 0,
- this.closed = !1,
- this._points.push(new Vector2(e,i))
- }
- return a.prototype.addLineTo = function(e, i) {
- if (this.closed)
- return this;
- var o = new Vector2(e,i)
- , s = this._points[this._points.length - 1];
- return this._points.push(o),
- this._length += o.subtract(s).length(),
- this
- }
- ,
- a.prototype.addArcTo = function(e, i, o, s, c) {
- if (c === void 0 && (c = 36),
- this.closed)
- return this;
- var d = this._points[this._points.length - 1]
- , _ = new Vector2(e,i)
- , b = new Vector2(o,s)
- , k = new Arc2(d,_,b)
- , j = k.angle.radians() / c;
- k.orientation === Orientation.CW && (j *= -1);
- for (var $ = k.startAngle.radians() + j, _e = 0; _e < c; _e++) {
- var et = Math.cos($) * k.radius + k.centerPoint.x
- , tt = Math.sin($) * k.radius + k.centerPoint.y;
- this.addLineTo(et, tt),
- $ += j
- }
- return this
- }
- ,
- a.prototype.close = function() {
- return this.closed = !0,
- this
- }
- ,
- a.prototype.length = function() {
- var e = this._length;
- if (this.closed) {
- var i = this._points[this._points.length - 1]
- , o = this._points[0];
- e += o.subtract(i).length()
- }
- return e
- }
- ,
- a.prototype.getPoints = function() {
- return this._points
- }
- ,
- a.prototype.getPointAtLengthPosition = function(e) {
- if (e < 0 || e > 1)
- return Vector2.Zero();
- for (var i = e * this.length(), o = 0, s = 0; s < this._points.length; s++) {
- var c = (s + 1) % this._points.length
- , d = this._points[s]
- , _ = this._points[c]
- , b = _.subtract(d)
- , k = b.length() + o;
- if (i >= o && i <= k) {
- var j = b.normalize()
- , $ = i - o;
- return new Vector2(d.x + j.x * $,d.y + j.y * $)
- }
- o = k
- }
- return Vector2.Zero()
- }
- ,
- a.StartingAt = function(e, i) {
- return new a(e,i)
- }
- ,
- a
- }()
- , Path3D = function() {
- function a(e, i, o, s) {
- i === void 0 && (i = null),
- s === void 0 && (s = !1),
- this.path = e,
- this._curve = new Array,
- this._distances = new Array,
- this._tangents = new Array,
- this._normals = new Array,
- this._binormals = new Array,
- this._pointAtData = {
- id: 0,
- point: Vector3.Zero(),
- previousPointArrayIndex: 0,
- position: 0,
- subPosition: 0,
- interpolateReady: !1,
- interpolationMatrix: Matrix.Identity()
- };
- for (var c = 0; c < e.length; c++)
- this._curve[c] = e[c].clone();
- this._raw = o || !1,
- this._alignTangentsWithPath = s,
- this._compute(i, s)
- }
- return a.prototype.getCurve = function() {
- return this._curve
- }
- ,
- a.prototype.getPoints = function() {
- return this._curve
- }
- ,
- a.prototype.length = function() {
- return this._distances[this._distances.length - 1]
- }
- ,
- a.prototype.getTangents = function() {
- return this._tangents
- }
- ,
- a.prototype.getNormals = function() {
- return this._normals
- }
- ,
- a.prototype.getBinormals = function() {
- return this._binormals
- }
- ,
- a.prototype.getDistances = function() {
- return this._distances
- }
- ,
- a.prototype.getPointAt = function(e) {
- return this._updatePointAtData(e).point
- }
- ,
- a.prototype.getTangentAt = function(e, i) {
- return i === void 0 && (i = !1),
- this._updatePointAtData(e, i),
- i ? Vector3.TransformCoordinates(Vector3.Forward(), this._pointAtData.interpolationMatrix) : this._tangents[this._pointAtData.previousPointArrayIndex]
- }
- ,
- a.prototype.getNormalAt = function(e, i) {
- return i === void 0 && (i = !1),
- this._updatePointAtData(e, i),
- i ? Vector3.TransformCoordinates(Vector3.Right(), this._pointAtData.interpolationMatrix) : this._normals[this._pointAtData.previousPointArrayIndex]
- }
- ,
- a.prototype.getBinormalAt = function(e, i) {
- return i === void 0 && (i = !1),
- this._updatePointAtData(e, i),
- i ? Vector3.TransformCoordinates(Vector3.UpReadOnly, this._pointAtData.interpolationMatrix) : this._binormals[this._pointAtData.previousPointArrayIndex]
- }
- ,
- a.prototype.getDistanceAt = function(e) {
- return this.length() * e
- }
- ,
- a.prototype.getPreviousPointIndexAt = function(e) {
- return this._updatePointAtData(e),
- this._pointAtData.previousPointArrayIndex
- }
- ,
- a.prototype.getSubPositionAt = function(e) {
- return this._updatePointAtData(e),
- this._pointAtData.subPosition
- }
- ,
- a.prototype.getClosestPositionTo = function(e) {
- for (var i = Number.MAX_VALUE, o = 0, s = 0; s < this._curve.length - 1; s++) {
- var c = this._curve[s + 0]
- , d = this._curve[s + 1].subtract(c).normalize()
- , _ = this._distances[s + 1] - this._distances[s + 0]
- , b = Math.min(Math.max(Vector3.Dot(d, e.subtract(c).normalize()), 0) * Vector3.Distance(c, e) / _, 1)
- , k = Vector3.Distance(c.add(d.scale(b * _)), e);
- k < i && (i = k,
- o = (this._distances[s + 0] + _ * b) / this.length())
- }
- return o
- }
- ,
- a.prototype.slice = function(e, i) {
- if (e === void 0 && (e = 0),
- i === void 0 && (i = 1),
- e < 0 && (e = 1 - e * -1 % 1),
- i < 0 && (i = 1 - i * -1 % 1),
- e > i) {
- var o = e;
- e = i,
- i = o
- }
- var s = this.getCurve()
- , c = this.getPointAt(e)
- , d = this.getPreviousPointIndexAt(e)
- , _ = this.getPointAt(i)
- , b = this.getPreviousPointIndexAt(i) + 1
- , k = [];
- return e !== 0 && (d++,
- k.push(c)),
- k.push.apply(k, s.slice(d, b)),
- (i !== 1 || e === 1) && k.push(_),
- new a(k,this.getNormalAt(e),this._raw,this._alignTangentsWithPath)
- }
- ,
- a.prototype.update = function(e, i, o) {
- i === void 0 && (i = null),
- o === void 0 && (o = !1);
- for (var s = 0; s < e.length; s++)
- this._curve[s].x = e[s].x,
- this._curve[s].y = e[s].y,
- this._curve[s].z = e[s].z;
- return this._compute(i, o),
- this
- }
- ,
- a.prototype._compute = function(e, i) {
- i === void 0 && (i = !1);
- var o = this._curve.length;
- if (!(o < 2)) {
- this._tangents[0] = this._getFirstNonNullVector(0),
- this._raw || this._tangents[0].normalize(),
- this._tangents[o - 1] = this._curve[o - 1].subtract(this._curve[o - 2]),
- this._raw || this._tangents[o - 1].normalize();
- var s = this._tangents[0]
- , c = this._normalVector(s, e);
- this._normals[0] = c,
- this._raw || this._normals[0].normalize(),
- this._binormals[0] = Vector3.Cross(s, this._normals[0]),
- this._raw || this._binormals[0].normalize(),
- this._distances[0] = 0;
- for (var d, _, b, k, j, $ = 1; $ < o; $++)
- d = this._getLastNonNullVector($),
- $ < o - 1 && (_ = this._getFirstNonNullVector($),
- this._tangents[$] = i ? _ : d.add(_),
- this._tangents[$].normalize()),
- this._distances[$] = this._distances[$ - 1] + this._curve[$].subtract(this._curve[$ - 1]).length(),
- b = this._tangents[$],
- j = this._binormals[$ - 1],
- this._normals[$] = Vector3.Cross(j, b),
- this._raw || (this._normals[$].length() === 0 ? (k = this._normals[$ - 1],
- this._normals[$] = k.clone()) : this._normals[$].normalize()),
- this._binormals[$] = Vector3.Cross(b, this._normals[$]),
- this._raw || this._binormals[$].normalize();
- this._pointAtData.id = NaN
- }
- }
- ,
- a.prototype._getFirstNonNullVector = function(e) {
- for (var i = 1, o = this._curve[e + i].subtract(this._curve[e]); o.length() === 0 && e + i + 1 < this._curve.length; )
- i++,
- o = this._curve[e + i].subtract(this._curve[e]);
- return o
- }
- ,
- a.prototype._getLastNonNullVector = function(e) {
- for (var i = 1, o = this._curve[e].subtract(this._curve[e - i]); o.length() === 0 && e > i + 1; )
- i++,
- o = this._curve[e].subtract(this._curve[e - i]);
- return o
- }
- ,
- a.prototype._normalVector = function(e, i) {
- var o, s = e.length();
- if (s === 0 && (s = 1),
- i == null) {
- var c;
- 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),
- o = Vector3.Cross(e, c)
- } else
- o = Vector3.Cross(e, i),
- Vector3.CrossToRef(o, e, o);
- return o.normalize(),
- o
- }
- ,
- a.prototype._updatePointAtData = function(e, i) {
- if (i === void 0 && (i = !1),
- this._pointAtData.id === e)
- return this._pointAtData.interpolateReady || this._updateInterpolationMatrix(),
- this._pointAtData;
- this._pointAtData.id = e;
- var o = this.getPoints();
- if (e <= 0)
- return this._setPointAtData(0, 0, o[0], 0, i);
- if (e >= 1)
- return this._setPointAtData(1, 1, o[o.length - 1], o.length - 1, i);
- for (var s = o[0], c, d = 0, _ = e * this.length(), b = 1; b < o.length; b++) {
- c = o[b];
- var k = Vector3.Distance(s, c);
- if (d += k,
- d === _)
- return this._setPointAtData(e, 1, c, b, i);
- if (d > _) {
- var j = d - _
- , $ = j / k
- , _e = s.subtract(c)
- , et = c.add(_e.scaleInPlace($));
- return this._setPointAtData(e, 1 - $, et, b - 1, i)
- }
- s = c
- }
- return this._pointAtData
- }
- ,
- a.prototype._setPointAtData = function(e, i, o, s, c) {
- return this._pointAtData.point = o,
- this._pointAtData.position = e,
- this._pointAtData.subPosition = i,
- this._pointAtData.previousPointArrayIndex = s,
- this._pointAtData.interpolateReady = c,
- c && this._updateInterpolationMatrix(),
- this._pointAtData
- }
- ,
- a.prototype._updateInterpolationMatrix = function() {
- this._pointAtData.interpolationMatrix = Matrix.Identity();
- var e = this._pointAtData.previousPointArrayIndex;
- if (e !== this._tangents.length - 1) {
- var i = e + 1
- , o = this._tangents[e].clone()
- , s = this._normals[e].clone()
- , c = this._binormals[e].clone()
- , d = this._tangents[i].clone()
- , _ = this._normals[i].clone()
- , b = this._binormals[i].clone()
- , k = Quaternion.RotationQuaternionFromAxis(s, c, o)
- , j = Quaternion.RotationQuaternionFromAxis(_, b, d)
- , $ = Quaternion.Slerp(k, j, this._pointAtData.subPosition);
- $.toRotationMatrix(this._pointAtData.interpolationMatrix)
- }
- }
- ,
- a
- }()
- , Curve3 = function() {
- function a(e) {
- this._length = 0,
- this._points = e,
- this._length = this._computeLength(e)
- }
- return a.CreateQuadraticBezier = function(e, i, o, s) {
- s = s > 2 ? s : 3;
- for (var c = new Array, d = function(b, k, j, $) {
- var _e = (1 - b) * (1 - b) * k + 2 * b * (1 - b) * j + b * b * $;
- return _e
- }, _ = 0; _ <= s; _++)
- 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)));
- return new a(c)
- }
- ,
- a.CreateCubicBezier = function(e, i, o, s, c) {
- c = c > 3 ? c : 4;
- for (var d = new Array, _ = function(k, j, $, _e, et) {
- 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;
- return tt
- }, b = 0; b <= c; b++)
- 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)));
- return new a(d)
- }
- ,
- a.CreateHermiteSpline = function(e, i, o, s, c) {
- for (var d = new Array, _ = 1 / c, b = 0; b <= c; b++)
- d.push(Vector3.Hermite(e, i, o, s, b * _));
- return new a(d)
- }
- ,
- a.CreateCatmullRomSpline = function(e, i, o) {
- var s = new Array
- , c = 1 / i
- , d = 0;
- if (o) {
- for (var _ = e.length, b = 0; b < _; b++) {
- d = 0;
- for (var k = 0; k < i; k++)
- s.push(Vector3.CatmullRom(e[b % _], e[(b + 1) % _], e[(b + 2) % _], e[(b + 3) % _], d)),
- d += c
- }
- s.push(s[0])
- } else {
- var j = new Array;
- j.push(e[0].clone()),
- Array.prototype.push.apply(j, e),
- j.push(e[e.length - 1].clone());
- for (var b = 0; b < j.length - 3; b++) {
- d = 0;
- for (var k = 0; k < i; k++)
- s.push(Vector3.CatmullRom(j[b], j[b + 1], j[b + 2], j[b + 3], d)),
- d += c
- }
- b--,
- s.push(Vector3.CatmullRom(j[b], j[b + 1], j[b + 2], j[b + 3], d))
- }
- return new a(s)
- }
- ,
- a.prototype.getPoints = function() {
- return this._points
- }
- ,
- a.prototype.length = function() {
- return this._length
- }
- ,
- a.prototype.continue = function(e) {
- for (var i = this._points[this._points.length - 1], o = this._points.slice(), s = e.getPoints(), c = 1; c < s.length; c++)
- o.push(s[c].subtract(s[0]).add(i));
- var d = new a(o);
- return d
- }
- ,
- a.prototype._computeLength = function(e) {
- for (var i = 0, o = 1; o < e.length; o++)
- i += e[o].subtract(e[o - 1]).length();
- return i
- }
- ,
- a
- }()
- , PositionNormalTextureVertex = function() {
- function a(e, i, o) {
- e === void 0 && (e = Vector3.Zero()),
- i === void 0 && (i = Vector3.Up()),
- o === void 0 && (o = Vector2.Zero()),
- this.position = e,
- this.normal = i,
- this.uv = o
- }
- return a.prototype.clone = function() {
- return new a(this.position.clone(),this.normal.clone(),this.uv.clone())
- }
- ,
- a
- }()
- , 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))]
- , SH3ylmBasisTrigonometricTerms = [function(a) {
- return 1
- }
- , function(a) {
- return a.y
- }
- , function(a) {
- return a.z
- }
- , function(a) {
- return a.x
- }
- , function(a) {
- return a.x * a.y
- }
- , function(a) {
- return a.y * a.z
- }
- , function(a) {
- return 3 * a.z * a.z - 1
- }
- , function(a) {
- return a.x * a.z
- }
- , function(a) {
- return a.x * a.x - a.y * a.y
- }
- ]
- , applySH3 = function(a, e) {
- return SH3ylmBasisConstants[a] * SH3ylmBasisTrigonometricTerms[a](e)
- }
- , 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]
- , SphericalHarmonics = function() {
- function a() {
- this.preScaled = !1,
- this.l00 = Vector3.Zero(),
- this.l1_1 = Vector3.Zero(),
- this.l10 = Vector3.Zero(),
- this.l11 = Vector3.Zero(),
- this.l2_2 = Vector3.Zero(),
- this.l2_1 = Vector3.Zero(),
- this.l20 = Vector3.Zero(),
- this.l21 = Vector3.Zero(),
- this.l22 = Vector3.Zero()
- }
- return a.prototype.addLight = function(e, i, o) {
- TmpVectors.Vector3[0].set(i.r, i.g, i.b);
- var s = TmpVectors.Vector3[0]
- , c = TmpVectors.Vector3[1];
- s.scaleToRef(o, c),
- c.scaleToRef(applySH3(0, e), TmpVectors.Vector3[2]),
- this.l00.addInPlace(TmpVectors.Vector3[2]),
- c.scaleToRef(applySH3(1, e), TmpVectors.Vector3[2]),
- this.l1_1.addInPlace(TmpVectors.Vector3[2]),
- c.scaleToRef(applySH3(2, e), TmpVectors.Vector3[2]),
- this.l10.addInPlace(TmpVectors.Vector3[2]),
- c.scaleToRef(applySH3(3, e), TmpVectors.Vector3[2]),
- this.l11.addInPlace(TmpVectors.Vector3[2]),
- c.scaleToRef(applySH3(4, e), TmpVectors.Vector3[2]),
- this.l2_2.addInPlace(TmpVectors.Vector3[2]),
- c.scaleToRef(applySH3(5, e), TmpVectors.Vector3[2]),
- this.l2_1.addInPlace(TmpVectors.Vector3[2]),
- c.scaleToRef(applySH3(6, e), TmpVectors.Vector3[2]),
- this.l20.addInPlace(TmpVectors.Vector3[2]),
- c.scaleToRef(applySH3(7, e), TmpVectors.Vector3[2]),
- this.l21.addInPlace(TmpVectors.Vector3[2]),
- c.scaleToRef(applySH3(8, e), TmpVectors.Vector3[2]),
- this.l22.addInPlace(TmpVectors.Vector3[2])
- }
- ,
- a.prototype.scaleInPlace = function(e) {
- this.l00.scaleInPlace(e),
- this.l1_1.scaleInPlace(e),
- this.l10.scaleInPlace(e),
- this.l11.scaleInPlace(e),
- this.l2_2.scaleInPlace(e),
- this.l2_1.scaleInPlace(e),
- this.l20.scaleInPlace(e),
- this.l21.scaleInPlace(e),
- this.l22.scaleInPlace(e)
- }
- ,
- a.prototype.convertIncidentRadianceToIrradiance = function() {
- this.l00.scaleInPlace(SHCosKernelConvolution[0]),
- this.l1_1.scaleInPlace(SHCosKernelConvolution[1]),
- this.l10.scaleInPlace(SHCosKernelConvolution[2]),
- this.l11.scaleInPlace(SHCosKernelConvolution[3]),
- this.l2_2.scaleInPlace(SHCosKernelConvolution[4]),
- this.l2_1.scaleInPlace(SHCosKernelConvolution[5]),
- this.l20.scaleInPlace(SHCosKernelConvolution[6]),
- this.l21.scaleInPlace(SHCosKernelConvolution[7]),
- this.l22.scaleInPlace(SHCosKernelConvolution[8])
- }
- ,
- a.prototype.convertIrradianceToLambertianRadiance = function() {
- this.scaleInPlace(1 / Math.PI)
- }
- ,
- a.prototype.preScaleForRendering = function() {
- this.preScaled = !0,
- this.l00.scaleInPlace(SH3ylmBasisConstants[0]),
- this.l1_1.scaleInPlace(SH3ylmBasisConstants[1]),
- this.l10.scaleInPlace(SH3ylmBasisConstants[2]),
- this.l11.scaleInPlace(SH3ylmBasisConstants[3]),
- this.l2_2.scaleInPlace(SH3ylmBasisConstants[4]),
- this.l2_1.scaleInPlace(SH3ylmBasisConstants[5]),
- this.l20.scaleInPlace(SH3ylmBasisConstants[6]),
- this.l21.scaleInPlace(SH3ylmBasisConstants[7]),
- this.l22.scaleInPlace(SH3ylmBasisConstants[8])
- }
- ,
- a.prototype.updateFromArray = function(e) {
- return Vector3.FromArrayToRef(e[0], 0, this.l00),
- Vector3.FromArrayToRef(e[1], 0, this.l1_1),
- Vector3.FromArrayToRef(e[2], 0, this.l10),
- Vector3.FromArrayToRef(e[3], 0, this.l11),
- Vector3.FromArrayToRef(e[4], 0, this.l2_2),
- Vector3.FromArrayToRef(e[5], 0, this.l2_1),
- Vector3.FromArrayToRef(e[6], 0, this.l20),
- Vector3.FromArrayToRef(e[7], 0, this.l21),
- Vector3.FromArrayToRef(e[8], 0, this.l22),
- this
- }
- ,
- a.prototype.updateFromFloatsArray = function(e) {
- return Vector3.FromFloatsToRef(e[0], e[1], e[2], this.l00),
- Vector3.FromFloatsToRef(e[3], e[4], e[5], this.l1_1),
- Vector3.FromFloatsToRef(e[6], e[7], e[8], this.l10),
- Vector3.FromFloatsToRef(e[9], e[10], e[11], this.l11),
- Vector3.FromFloatsToRef(e[12], e[13], e[14], this.l2_2),
- Vector3.FromFloatsToRef(e[15], e[16], e[17], this.l2_1),
- Vector3.FromFloatsToRef(e[18], e[19], e[20], this.l20),
- Vector3.FromFloatsToRef(e[21], e[22], e[23], this.l21),
- Vector3.FromFloatsToRef(e[24], e[25], e[26], this.l22),
- this
- }
- ,
- a.FromArray = function(e) {
- var i = new a;
- return i.updateFromArray(e)
- }
- ,
- a.FromPolynomial = function(e) {
- var i = new a;
- return i.l00 = e.xx.scale(.376127).add(e.yy.scale(.376127)).add(e.zz.scale(.376126)),
- i.l1_1 = e.y.scale(.977204),
- i.l10 = e.z.scale(.977204),
- i.l11 = e.x.scale(.977204),
- i.l2_2 = e.xy.scale(1.16538),
- i.l2_1 = e.yz.scale(1.16538),
- i.l20 = e.zz.scale(1.34567).subtract(e.xx.scale(.672834)).subtract(e.yy.scale(.672834)),
- i.l21 = e.zx.scale(1.16538),
- i.l22 = e.xx.scale(1.16538).subtract(e.yy.scale(1.16538)),
- i.l1_1.scaleInPlace(-1),
- i.l11.scaleInPlace(-1),
- i.l2_1.scaleInPlace(-1),
- i.l21.scaleInPlace(-1),
- i.scaleInPlace(Math.PI),
- i
- }
- ,
- a
- }()
- , SphericalPolynomial = function() {
- function a() {
- this.x = Vector3.Zero(),
- this.y = Vector3.Zero(),
- this.z = Vector3.Zero(),
- this.xx = Vector3.Zero(),
- this.yy = Vector3.Zero(),
- this.zz = Vector3.Zero(),
- this.xy = Vector3.Zero(),
- this.yz = Vector3.Zero(),
- this.zx = Vector3.Zero()
- }
- return Object.defineProperty(a.prototype, "preScaledHarmonics", {
- get: function() {
- return this._harmonics || (this._harmonics = SphericalHarmonics.FromPolynomial(this)),
- this._harmonics.preScaled || this._harmonics.preScaleForRendering(),
- this._harmonics
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.addAmbient = function(e) {
- TmpVectors.Vector3[0].copyFromFloats(e.r, e.g, e.b);
- var i = TmpVectors.Vector3[0];
- this.xx.addInPlace(i),
- this.yy.addInPlace(i),
- this.zz.addInPlace(i)
- }
- ,
- a.prototype.scaleInPlace = function(e) {
- this.x.scaleInPlace(e),
- this.y.scaleInPlace(e),
- this.z.scaleInPlace(e),
- this.xx.scaleInPlace(e),
- this.yy.scaleInPlace(e),
- this.zz.scaleInPlace(e),
- this.yz.scaleInPlace(e),
- this.zx.scaleInPlace(e),
- this.xy.scaleInPlace(e)
- }
- ,
- a.prototype.updateFromHarmonics = function(e) {
- return this._harmonics = e,
- this.x.copyFrom(e.l11),
- this.x.scaleInPlace(1.02333).scaleInPlace(-1),
- this.y.copyFrom(e.l1_1),
- this.y.scaleInPlace(1.02333).scaleInPlace(-1),
- this.z.copyFrom(e.l10),
- this.z.scaleInPlace(1.02333),
- this.xx.copyFrom(e.l00),
- TmpVectors.Vector3[0].copyFrom(e.l20).scaleInPlace(.247708),
- TmpVectors.Vector3[1].copyFrom(e.l22).scaleInPlace(.429043),
- this.xx.scaleInPlace(.886277).subtractInPlace(TmpVectors.Vector3[0]).addInPlace(TmpVectors.Vector3[1]),
- this.yy.copyFrom(e.l00),
- this.yy.scaleInPlace(.886277).subtractInPlace(TmpVectors.Vector3[0]).subtractInPlace(TmpVectors.Vector3[1]),
- this.zz.copyFrom(e.l00),
- TmpVectors.Vector3[0].copyFrom(e.l20).scaleInPlace(.495417),
- this.zz.scaleInPlace(.886277).addInPlace(TmpVectors.Vector3[0]),
- this.yz.copyFrom(e.l2_1),
- this.yz.scaleInPlace(.858086).scaleInPlace(-1),
- this.zx.copyFrom(e.l21),
- this.zx.scaleInPlace(.858086).scaleInPlace(-1),
- this.xy.copyFrom(e.l2_2),
- this.xy.scaleInPlace(.858086),
- this.scaleInPlace(1 / Math.PI),
- this
- }
- ,
- a.FromHarmonics = function(e) {
- var i = new a;
- return i.updateFromHarmonics(e)
- }
- ,
- a.FromArray = function(e) {
- var i = new a;
- return Vector3.FromArrayToRef(e[0], 0, i.x),
- Vector3.FromArrayToRef(e[1], 0, i.y),
- Vector3.FromArrayToRef(e[2], 0, i.z),
- Vector3.FromArrayToRef(e[3], 0, i.xx),
- Vector3.FromArrayToRef(e[4], 0, i.yy),
- Vector3.FromArrayToRef(e[5], 0, i.zz),
- Vector3.FromArrayToRef(e[6], 0, i.yz),
- Vector3.FromArrayToRef(e[7], 0, i.zx),
- Vector3.FromArrayToRef(e[8], 0, i.xy),
- i
- }
- ,
- a
- }()
- , name$2$ = "postprocessVertexShader"
- , shader$2$ = `
- attribute vec2 position;
- uniform vec2 scale;
- varying vec2 vUV;
- const vec2 madd=vec2(0.5,0.5);
- void main(void) {
- vUV=(position*madd+madd)*scale;
- gl_Position=vec4(position,0.0,1.0);
- }`;
- ShaderStore.ShadersStore[name$2$] = shader$2$;
- var PostProcess = function() {
- function a(e, i, o, s, c, d, _, b, k, j, $, _e, et, tt, rt) {
- _ === void 0 && (_ = 1),
- j === void 0 && (j = null),
- $ === void 0 && ($ = 0),
- _e === void 0 && (_e = "postprocess"),
- tt === void 0 && (tt = !1),
- rt === void 0 && (rt = 5),
- this._parentContainer = null,
- this.width = -1,
- this.height = -1,
- this.nodeMaterialSource = null,
- this._outputTexture = null,
- this.autoClear = !0,
- this.alphaMode = 0,
- this.animations = new Array,
- this.enablePixelPerfectMode = !1,
- this.forceFullscreenViewport = !0,
- this.scaleMode = 1,
- this.alwaysForcePOT = !1,
- this._samples = 1,
- this.adaptScaleToCurrentViewport = !1,
- this._reusable = !1,
- this._renderId = 0,
- this.externalTextureSamplerBinding = !1,
- this._textures = new SmartArray(2),
- this._textureCache = [],
- this._currentRenderTextureInd = 0,
- this._scaleRatio = new Vector2(1,1),
- this._texelSize = Vector2.Zero(),
- this.onActivateObservable = new Observable,
- this.onSizeChangedObservable = new Observable,
- this.onApplyObservable = new Observable,
- this.onBeforeRenderObservable = new Observable,
- this.onAfterRenderObservable = new Observable,
- this.name = e,
- d != null ? (this._camera = d,
- this._scene = d.getScene(),
- d.attachPostProcess(this),
- this._engine = this._scene.getEngine(),
- this._scene.postProcesses.push(this),
- this.uniqueId = this._scene.getUniqueId()) : b && (this._engine = b,
- this._engine.postProcesses.push(this)),
- this._options = c,
- this.renderTargetSamplingMode = _ || 1,
- this._reusable = k || !1,
- this._textureType = $,
- this._textureFormat = rt,
- this._samplers = s || [],
- this._samplers.push("textureSampler"),
- this._fragmentUrl = i,
- this._vertexUrl = _e,
- this._parameters = o || [],
- this._parameters.push("scale"),
- this._indexParameters = et,
- this._drawWrapper = new DrawWrapper(this._engine),
- tt || this.updateEffect(j)
- }
- return Object.defineProperty(a.prototype, "samples", {
- get: function() {
- return this._samples
- },
- set: function(e) {
- var i = this;
- this._samples = Math.min(e, this._engine.getCaps().maxMSAASamples),
- this._textures.forEach(function(o) {
- o.samples !== i._samples && i._engine.updateRenderTargetTextureSampleCount(o, i._samples)
- })
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.getEffectName = function() {
- return this._fragmentUrl
- }
- ,
- Object.defineProperty(a.prototype, "onActivate", {
- set: function(e) {
- this._onActivateObserver && this.onActivateObservable.remove(this._onActivateObserver),
- e && (this._onActivateObserver = this.onActivateObservable.add(e))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "onSizeChanged", {
- set: function(e) {
- this._onSizeChangedObserver && this.onSizeChangedObservable.remove(this._onSizeChangedObserver),
- this._onSizeChangedObserver = this.onSizeChangedObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "onApply", {
- set: function(e) {
- this._onApplyObserver && this.onApplyObservable.remove(this._onApplyObserver),
- this._onApplyObserver = this.onApplyObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "onBeforeRender", {
- set: function(e) {
- this._onBeforeRenderObserver && this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),
- this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "onAfterRender", {
- set: function(e) {
- this._onAfterRenderObserver && this.onAfterRenderObservable.remove(this._onAfterRenderObserver),
- this._onAfterRenderObserver = this.onAfterRenderObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "inputTexture", {
- get: function() {
- return this._textures.data[this._currentRenderTextureInd]
- },
- set: function(e) {
- this._forcedOutputTexture = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.restoreDefaultInputTexture = function() {
- this._forcedOutputTexture && (this._forcedOutputTexture = null,
- this.markTextureDirty())
- }
- ,
- a.prototype.getCamera = function() {
- return this._camera
- }
- ,
- Object.defineProperty(a.prototype, "texelSize", {
- get: function() {
- return this._shareOutputWithPostProcess ? this._shareOutputWithPostProcess.texelSize : (this._forcedOutputTexture && this._texelSize.copyFromFloats(1 / this._forcedOutputTexture.width, 1 / this._forcedOutputTexture.height),
- this._texelSize)
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.getClassName = function() {
- return "PostProcess"
- }
- ,
- a.prototype.getEngine = function() {
- return this._engine
- }
- ,
- a.prototype.getEffect = function() {
- return this._drawWrapper.effect
- }
- ,
- a.prototype.shareOutputWith = function(e) {
- return this._disposeTextures(),
- this._shareOutputWithPostProcess = e,
- this
- }
- ,
- a.prototype.useOwnOutput = function() {
- this._textures.length == 0 && (this._textures = new SmartArray(2)),
- this._shareOutputWithPostProcess = null
- }
- ,
- a.prototype.updateEffect = function(e, i, o, s, c, d, _, b) {
- e === void 0 && (e = null),
- i === void 0 && (i = null),
- o === void 0 && (o = null),
- this._postProcessDefines = e,
- this._drawWrapper.effect = this._engine.createEffect({
- vertex: _ != null ? _ : this._vertexUrl,
- fragment: b != null ? b : this._fragmentUrl
- }, ["position"], i || this._parameters, o || this._samplers, e !== null ? e : "", void 0, c, d, s || this._indexParameters)
- }
- ,
- a.prototype.isReusable = function() {
- return this._reusable
- }
- ,
- a.prototype.markTextureDirty = function() {
- this.width = -1
- }
- ,
- a.prototype._createRenderTargetTexture = function(e, i, o) {
- o === void 0 && (o = 0);
- for (var s = 0; s < this._textureCache.length; s++)
- 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)
- return this._textureCache[s].texture;
- var c = this._engine.createRenderTargetTexture(e, i);
- return this._textureCache.push({
- texture: c,
- postProcessChannel: o,
- lastUsedRenderId: -1
- }),
- c
- }
- ,
- a.prototype._flushTextureCache = function() {
- for (var e = this._renderId, i = this._textureCache.length - 1; i >= 0; i--)
- if (e - this._textureCache[i].lastUsedRenderId > 100) {
- for (var o = !1, s = 0; s < this._textures.length; s++)
- if (this._textures.data[s] === this._textureCache[i].texture) {
- o = !0;
- break
- }
- o || (this._textureCache[i].texture.dispose(),
- this._textureCache.splice(i, 1))
- }
- }
- ,
- a.prototype._resize = function(e, i, o, s, c) {
- this._textures.length > 0 && this._textures.reset(),
- this.width = e,
- this.height = i;
- for (var d = null, _ = 0; _ < o._postProcesses.length; _++)
- if (o._postProcesses[_] !== null) {
- d = o._postProcesses[_];
- break
- }
- var b = {
- width: this.width,
- height: this.height
- }
- , k = {
- generateMipMaps: s,
- generateDepthBuffer: c || d === this,
- generateStencilBuffer: (c || d === this) && this._engine.isStencilEnable,
- samplingMode: this.renderTargetSamplingMode,
- type: this._textureType,
- format: this._textureFormat
- };
- this._textures.push(this._createRenderTargetTexture(b, k, 0)),
- this._reusable && this._textures.push(this._createRenderTargetTexture(b, k, 1)),
- this._texelSize.copyFromFloats(1 / this.width, 1 / this.height),
- this.onSizeChangedObservable.notifyObservers(this)
- }
- ,
- a.prototype.activate = function(e, i, o) {
- var s = this, c, d;
- i === void 0 && (i = null),
- e = e || this._camera;
- var _ = e.getScene()
- , b = _.getEngine()
- , k = b.getCaps().maxTextureSize
- , j = (i ? i.width : this._engine.getRenderWidth(!0)) * this._options | 0
- , $ = (i ? i.height : this._engine.getRenderHeight(!0)) * this._options | 0
- , _e = e.parent;
- _e && (_e.leftCamera == e || _e.rightCamera == e) && (j /= 2);
- var et = this._options.width || j
- , tt = this._options.height || $
- , rt = this.renderTargetSamplingMode !== 7 && this.renderTargetSamplingMode !== 1 && this.renderTargetSamplingMode !== 2;
- if (!this._shareOutputWithPostProcess && !this._forcedOutputTexture) {
- if (this.adaptScaleToCurrentViewport) {
- var it = b.currentViewport;
- it && (et *= it.width,
- tt *= it.height)
- }
- (rt || this.alwaysForcePOT) && (this._options.width || (et = b.needPOTTextures ? Engine.GetExponentOfTwo(et, k, this.scaleMode) : et),
- this._options.height || (tt = b.needPOTTextures ? Engine.GetExponentOfTwo(tt, k, this.scaleMode) : tt)),
- (this.width !== et || this.height !== tt) && this._resize(et, tt, e, rt, o),
- this._textures.forEach(function(st) {
- st.samples !== s.samples && s._engine.updateRenderTargetTextureSampleCount(st, s.samples)
- }),
- this._flushTextureCache(),
- this._renderId++
- }
- var nt;
- if (this._shareOutputWithPostProcess)
- nt = this._shareOutputWithPostProcess.inputTexture;
- else if (this._forcedOutputTexture)
- nt = this._forcedOutputTexture,
- this.width = this._forcedOutputTexture.width,
- this.height = this._forcedOutputTexture.height;
- else {
- nt = this.inputTexture;
- for (var ot = void 0, at = 0; at < this._textureCache.length; at++)
- if (this._textureCache[at].texture === nt) {
- ot = this._textureCache[at];
- break
- }
- ot && (ot.lastUsedRenderId = this._renderId)
- }
- return this.enablePixelPerfectMode ? (this._scaleRatio.copyFromFloats(j / et, $ / tt),
- this._engine.bindFramebuffer(nt, 0, j, $, this.forceFullscreenViewport)) : (this._scaleRatio.copyFromFloats(1, 1),
- this._engine.bindFramebuffer(nt, 0, void 0, void 0, this.forceFullscreenViewport)),
- (d = (c = this._engine)._debugInsertMarker) === null || d === void 0 || d.call(c, "post process " + this.name + " input"),
- this.onActivateObservable.notifyObservers(e),
- this.autoClear && this.alphaMode === 0 && this._engine.clear(this.clearColor ? this.clearColor : _.clearColor, _._allowPostProcessClearColor, !0, !0),
- this._reusable && (this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2),
- nt
- }
- ,
- Object.defineProperty(a.prototype, "isSupported", {
- get: function() {
- return this._drawWrapper.effect.isSupported
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "aspectRatio", {
- get: function() {
- return this._shareOutputWithPostProcess ? this._shareOutputWithPostProcess.aspectRatio : this._forcedOutputTexture ? this._forcedOutputTexture.width / this._forcedOutputTexture.height : this.width / this.height
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.isReady = function() {
- var e, i;
- return (i = (e = this._drawWrapper.effect) === null || e === void 0 ? void 0 : e.isReady()) !== null && i !== void 0 ? i : !1
- }
- ,
- a.prototype.apply = function() {
- var e;
- if (!(!((e = this._drawWrapper.effect) === null || e === void 0) && e.isReady()))
- return null;
- this._engine.enableEffect(this._drawWrapper),
- this._engine.setState(!1),
- this._engine.setDepthBuffer(!1),
- this._engine.setDepthWrite(!1),
- this._engine.setAlphaMode(this.alphaMode),
- this.alphaConstants && this.getEngine().setAlphaConstants(this.alphaConstants.r, this.alphaConstants.g, this.alphaConstants.b, this.alphaConstants.a);
- var i;
- return this._shareOutputWithPostProcess ? i = this._shareOutputWithPostProcess.inputTexture : this._forcedOutputTexture ? i = this._forcedOutputTexture : i = this.inputTexture,
- this.externalTextureSamplerBinding || this._drawWrapper.effect._bindTexture("textureSampler", i == null ? void 0 : i.texture),
- this._drawWrapper.effect.setVector2("scale", this._scaleRatio),
- this.onApplyObservable.notifyObservers(this._drawWrapper.effect),
- this._drawWrapper.effect
- }
- ,
- a.prototype._disposeTextures = function() {
- if (this._shareOutputWithPostProcess || this._forcedOutputTexture) {
- this._disposeTextureCache();
- return
- }
- this._disposeTextureCache(),
- this._textures.dispose()
- }
- ,
- a.prototype._disposeTextureCache = function() {
- for (var e = this._textureCache.length - 1; e >= 0; e--)
- this._textureCache[e].texture.dispose();
- this._textureCache.length = 0
- }
- ,
- a.prototype.setPrePassRenderer = function(e) {
- return this._prePassEffectConfiguration ? (this._prePassEffectConfiguration = e.addEffectConfiguration(this._prePassEffectConfiguration),
- this._prePassEffectConfiguration.enabled = !0,
- !0) : !1
- }
- ,
- a.prototype.dispose = function(e) {
- e = e || this._camera,
- this._disposeTextures();
- var i;
- if (this._scene && (i = this._scene.postProcesses.indexOf(this),
- i !== -1 && this._scene.postProcesses.splice(i, 1)),
- this._parentContainer) {
- var o = this._parentContainer.postProcesses.indexOf(this);
- o > -1 && this._parentContainer.postProcesses.splice(o, 1),
- this._parentContainer = null
- }
- if (i = this._engine.postProcesses.indexOf(this),
- i !== -1 && this._engine.postProcesses.splice(i, 1),
- !!e) {
- if (e.detachPostProcess(this),
- i = e._postProcesses.indexOf(this),
- i === 0 && e._postProcesses.length > 0) {
- var s = this._camera._getFirstPostProcess();
- s && s.markTextureDirty()
- }
- this.onActivateObservable.clear(),
- this.onAfterRenderObservable.clear(),
- this.onApplyObservable.clear(),
- this.onBeforeRenderObservable.clear(),
- this.onSizeChangedObservable.clear()
- }
- }
- ,
- a.prototype.serialize = function() {
- var e = SerializationHelper.Serialize(this)
- , i = this.getCamera() || this._scene && this._scene.activeCamera;
- return e.customType = "BABYLON." + this.getClassName(),
- e.cameraId = i ? i.id : null,
- e.reusable = this._reusable,
- e.textureType = this._textureType,
- e.fragmentUrl = this._fragmentUrl,
- e.parameters = this._parameters,
- e.samplers = this._samplers,
- e.options = this._options,
- e.defines = this._postProcessDefines,
- e.textureFormat = this._textureFormat,
- e.vertexUrl = this._vertexUrl,
- e.indexParameters = this._indexParameters,
- e
- }
- ,
- a.prototype.clone = function() {
- var e = this.serialize();
- e._engine = this._engine,
- e.cameraId = null;
- var i = a.Parse(e, this._scene, "");
- return i ? (i.onActivateObservable = this.onActivateObservable.clone(),
- i.onSizeChangedObservable = this.onSizeChangedObservable.clone(),
- i.onApplyObservable = this.onApplyObservable.clone(),
- i.onBeforeRenderObservable = this.onBeforeRenderObservable.clone(),
- i.onAfterRenderObservable = this.onAfterRenderObservable.clone(),
- i._prePassEffectConfiguration = this._prePassEffectConfiguration,
- i) : null
- }
- ,
- a.Parse = function(e, i, o) {
- var s = GetClass(e.customType);
- if (!s || !s._Parse)
- return null;
- var c = i ? i.getCameraById(e.cameraId) : null;
- return s._Parse(e, c, i, o)
- }
- ,
- a._Parse = function(e, i, o, s) {
- return SerializationHelper.Parse(function() {
- 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)
- }, e, o, s)
- }
- ,
- __decorate([serialize()], a.prototype, "uniqueId", void 0),
- __decorate([serialize()], a.prototype, "name", void 0),
- __decorate([serialize()], a.prototype, "width", void 0),
- __decorate([serialize()], a.prototype, "height", void 0),
- __decorate([serialize()], a.prototype, "renderTargetSamplingMode", void 0),
- __decorate([serializeAsColor4()], a.prototype, "clearColor", void 0),
- __decorate([serialize()], a.prototype, "autoClear", void 0),
- __decorate([serialize()], a.prototype, "alphaMode", void 0),
- __decorate([serialize()], a.prototype, "alphaConstants", void 0),
- __decorate([serialize()], a.prototype, "enablePixelPerfectMode", void 0),
- __decorate([serialize()], a.prototype, "forceFullscreenViewport", void 0),
- __decorate([serialize()], a.prototype, "scaleMode", void 0),
- __decorate([serialize()], a.prototype, "alwaysForcePOT", void 0),
- __decorate([serialize("samples")], a.prototype, "_samples", void 0),
- __decorate([serialize()], a.prototype, "adaptScaleToCurrentViewport", void 0),
- a
- }();
- RegisterClass("BABYLON.PostProcess", PostProcess);
- var name$2_ = "helperFunctions"
- , shader$2_ = `const float PI=3.1415926535897932384626433832795;
- const float HALF_MIN=5.96046448e-08;
- const float LinearEncodePowerApprox=2.2;
- const float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;
- const vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);
- const float Epsilon=0.0000001;
- #define saturate(x) clamp(x,0.0,1.0)
- #define absEps(x) abs(x)+Epsilon
- #define maxEps(x) max(x,Epsilon)
- #define saturateEps(x) clamp(x,Epsilon,1.0)
- mat3 transposeMat3(mat3 inMatrix) {
- vec3 i0=inMatrix[0];
- vec3 i1=inMatrix[1];
- vec3 i2=inMatrix[2];
- mat3 outMatrix=mat3(
- vec3(i0.x,i1.x,i2.x),
- vec3(i0.y,i1.y,i2.y),
- vec3(i0.z,i1.z,i2.z)
- );
- return outMatrix;
- }
- mat3 inverseMat3(mat3 inMatrix) {
- float a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];
- float a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];
- float a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];
- float b01=a22*a11-a12*a21;
- float b11=-a22*a10+a12*a20;
- float b21=a21*a10-a11*a20;
- float det=a00*b01+a01*b11+a02*b21;
- return mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),
- b11,(a22*a00-a02*a20),(-a12*a00+a02*a10),
- b21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;
- }
- float toLinearSpace(float color)
- {
- return pow(color,LinearEncodePowerApprox);
- }
- vec3 toLinearSpace(vec3 color)
- {
- return pow(color,vec3(LinearEncodePowerApprox));
- }
- vec4 toLinearSpace(vec4 color)
- {
- return vec4(pow(color.rgb,vec3(LinearEncodePowerApprox)),color.a);
- }
- vec3 toGammaSpace(vec3 color)
- {
- return pow(color,vec3(GammaEncodePowerApprox));
- }
- vec4 toGammaSpace(vec4 color)
- {
- return vec4(pow(color.rgb,vec3(GammaEncodePowerApprox)),color.a);
- }
- float toGammaSpace(float color)
- {
- return pow(color,GammaEncodePowerApprox);
- }
- float square(float value)
- {
- return value*value;
- }
- float pow5(float value) {
- float sq=value*value;
- return sq*sq*value;
- }
- float getLuminance(vec3 color)
- {
- return clamp(dot(color,LuminanceEncodeApprox),0.,1.);
- }
- float getRand(vec2 seed) {
- return fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);
- }
- float dither(vec2 seed,float varianceAmount) {
- float rand=getRand(seed);
- float dither=mix(-varianceAmount/255.0,varianceAmount/255.0,rand);
- return dither;
- }
- const float rgbdMaxRange=255.0;
- vec4 toRGBD(vec3 color) {
- float maxRGB=maxEps(max(color.r,max(color.g,color.b)));
- float D=max(rgbdMaxRange/maxRGB,1.);
- D=clamp(floor(D)/255.0,0.,1.);
- vec3 rgb=color.rgb*D;
- rgb=toGammaSpace(rgb);
- return vec4(clamp(rgb,0.,1.),D);
- }
- vec3 fromRGBD(vec4 rgbd) {
- rgbd.rgb=toLinearSpace(rgbd.rgb);
- return rgbd.rgb/rgbd.a;
- }
- vec3 parallaxCorrectNormal( vec3 vertexPos,vec3 origVec,vec3 cubeSize,vec3 cubePos ) {
- vec3 invOrigVec=vec3(1.0,1.0,1.0)/origVec;
- vec3 halfSize=cubeSize*0.5;
- vec3 intersecAtMaxPlane=(cubePos+halfSize-vertexPos)*invOrigVec;
- vec3 intersecAtMinPlane=(cubePos-halfSize-vertexPos)*invOrigVec;
- vec3 largestIntersec=max(intersecAtMaxPlane,intersecAtMinPlane);
- float distance=min(min(largestIntersec.x,largestIntersec.y),largestIntersec.z);
- vec3 intersectPositionWS=vertexPos+origVec*distance;
- return intersectPositionWS-cubePos;
- }
- `;
- ShaderStore.IncludesShadersStore[name$2_] = shader$2_;
- var name$2Z = "rgbdDecodePixelShader"
- , shader$2Z = `
- varying vec2 vUV;
- uniform sampler2D textureSampler;
- #include<helperFunctions>
- void main(void)
- {
- gl_FragColor=vec4(fromRGBD(texture2D(textureSampler,vUV)),1.0);
- }`;
- ShaderStore.ShadersStore[name$2Z] = shader$2Z;
- var name$2Y = "passPixelShader"
- , shader$2Y = `
- varying vec2 vUV;
- uniform sampler2D textureSampler;
- void main(void)
- {
- gl_FragColor=texture2D(textureSampler,vUV);
- }`;
- ShaderStore.ShadersStore[name$2Y] = shader$2Y;
- var name$2X = "passCubePixelShader"
- , shader$2X = `
- varying vec2 vUV;
- uniform samplerCube textureSampler;
- void main(void)
- {
- vec2 uv=vUV*2.0-1.0;
- #ifdef POSITIVEX
- gl_FragColor=textureCube(textureSampler,vec3(1.001,uv.y,uv.x));
- #endif
- #ifdef NEGATIVEX
- gl_FragColor=textureCube(textureSampler,vec3(-1.001,uv.y,uv.x));
- #endif
- #ifdef POSITIVEY
- gl_FragColor=textureCube(textureSampler,vec3(uv.y,1.001,uv.x));
- #endif
- #ifdef NEGATIVEY
- gl_FragColor=textureCube(textureSampler,vec3(uv.y,-1.001,uv.x));
- #endif
- #ifdef POSITIVEZ
- gl_FragColor=textureCube(textureSampler,vec3(uv,1.001));
- #endif
- #ifdef NEGATIVEZ
- gl_FragColor=textureCube(textureSampler,vec3(uv,-1.001));
- #endif
- }`;
- ShaderStore.ShadersStore[name$2X] = shader$2X;
- var PassPostProcess = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _, b, k) {
- return s === void 0 && (s = null),
- b === void 0 && (b = 0),
- k === void 0 && (k = !1),
- a.call(this, i, "pass", null, null, o, s, c, d, _, void 0, b, void 0, null, k) || this
- }
- return e.prototype.getClassName = function() {
- return "PassPostProcess"
- }
- ,
- e._Parse = function(i, o, s, c) {
- return SerializationHelper.Parse(function() {
- return new e(i.name,i.options,o,i.renderTargetSamplingMode,i._engine,i.reusable)
- }, i, s, c)
- }
- ,
- e
- }(PostProcess);
- RegisterClass("BABYLON.PassPostProcess", PassPostProcess);
- (function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _, b, k) {
- s === void 0 && (s = null),
- b === void 0 && (b = 0),
- k === void 0 && (k = !1);
- var j = a.call(this, i, "passCube", null, null, o, s, c, d, _, "#define POSITIVEX", b, void 0, null, k) || this;
- return j._face = 0,
- j
- }
- return Object.defineProperty(e.prototype, "face", {
- get: function() {
- return this._face
- },
- set: function(i) {
- if (!(i < 0 || i > 5))
- switch (this._face = i,
- this._face) {
- case 0:
- this.updateEffect("#define POSITIVEX");
- break;
- case 1:
- this.updateEffect("#define NEGATIVEX");
- break;
- case 2:
- this.updateEffect("#define POSITIVEY");
- break;
- case 3:
- this.updateEffect("#define NEGATIVEY");
- break;
- case 4:
- this.updateEffect("#define POSITIVEZ");
- break;
- case 5:
- this.updateEffect("#define NEGATIVEZ");
- break
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getClassName = function() {
- return "PassCubePostProcess"
- }
- ,
- e._Parse = function(i, o, s, c) {
- return SerializationHelper.Parse(function() {
- return new e(i.name,i.options,o,i.renderTargetSamplingMode,i._engine,i.reusable)
- }, i, s, c)
- }
- ,
- e
- }
- )(PostProcess);
- Engine._RescalePostProcessFactory = function(a) {
- return new PassPostProcess("rescale",1,null,2,a,!1,0)
- }
- ;
- function CreateResizedCopy(a, e, i, o) {
- o === void 0 && (o = !0);
- var s = a.getScene()
- , c = s.getEngine()
- , d = new RenderTargetTexture("resized" + a.name,{
- width: e,
- height: i
- },s,!a.noMipmap,!0,a._texture.type,!1,a.samplingMode,!1);
- d.wrapU = a.wrapU,
- d.wrapV = a.wrapV,
- d.uOffset = a.uOffset,
- d.vOffset = a.vOffset,
- d.uScale = a.uScale,
- d.vScale = a.vScale,
- d.uAng = a.uAng,
- d.vAng = a.vAng,
- d.wAng = a.wAng,
- d.coordinatesIndex = a.coordinatesIndex,
- d.level = a.level,
- d.anisotropicFilteringLevel = a.anisotropicFilteringLevel,
- d._texture.isReady = !1,
- a.wrapU = Texture.CLAMP_ADDRESSMODE,
- a.wrapV = Texture.CLAMP_ADDRESSMODE;
- var _ = new PassPostProcess("pass",1,null,o ? Texture.BILINEAR_SAMPLINGMODE : Texture.NEAREST_SAMPLINGMODE,c,!1,0);
- return _.externalTextureSamplerBinding = !0,
- _.getEffect().executeWhenCompiled(function() {
- _.onApply = function(k) {
- k.setTexture("textureSampler", a)
- }
- ;
- var b = d.renderTarget;
- b && (s.postProcessManager.directRender([_], b),
- c.unBindFramebuffer(b),
- d.disposeFramebufferObjects(),
- _.dispose(),
- d.getInternalTexture().isReady = !0)
- }),
- d
- }
- function ApplyPostProcess(a, e, i, o, s, c) {
- var d = e.getEngine();
- return e.isReady = !1,
- s = s != null ? s : e.samplingMode,
- o = o != null ? o : e.type,
- c = c != null ? c : e.format,
- o === -1 && (o = 0),
- new Promise(function(_) {
- var b = new PostProcess("postprocess",a,null,null,1,null,s,d,!1,void 0,o,void 0,null,!1,c);
- b.externalTextureSamplerBinding = !0;
- var k = d.createRenderTargetTexture({
- width: e.width,
- height: e.height
- }, {
- generateDepthBuffer: !1,
- generateMipMaps: !1,
- generateStencilBuffer: !1,
- samplingMode: s,
- type: o,
- format: c
- });
- b.getEffect().executeWhenCompiled(function() {
- b.onApply = function(j) {
- j._bindTexture("textureSampler", e),
- j.setFloat2("scale", 1, 1)
- }
- ,
- i.postProcessManager.directRender([b], k, !0),
- d.restoreDefaultFramebuffer(),
- d._releaseTexture(e),
- b && b.dispose(),
- k._swapAndDie(e),
- e.type = o,
- e.format = 5,
- e.isReady = !0,
- _(e)
- })
- }
- )
- }
- var _FloatView, _Int32View;
- function ToHalfFloat(a) {
- _FloatView || (_FloatView = new Float32Array(1),
- _Int32View = new Int32Array(_FloatView.buffer)),
- _FloatView[0] = a;
- var e = _Int32View[0]
- , i = e >> 16 & 32768
- , o = e >> 12 & 2047
- , s = e >> 23 & 255;
- return s < 103 ? i : s > 142 ? (i |= 31744,
- i |= (s == 255 ? 0 : 1) && e & 8388607,
- i) : s < 113 ? (o |= 2048,
- i |= (o >> 114 - s) + (o >> 113 - s & 1),
- i) : (i |= s - 112 << 10 | o >> 1,
- i += o & 1,
- i)
- }
- function FromHalfFloat(a) {
- var e = (a & 32768) >> 15
- , i = (a & 31744) >> 10
- , o = a & 1023;
- 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))
- }
- var TextureTools = {
- CreateResizedCopy,
- ApplyPostProcess,
- ToHalfFloat,
- FromHalfFloat
- }
- , RGBDTextureTools = function() {
- function a() {}
- return a.ExpandRGBDTexture = function(e) {
- var i = e._texture;
- if (!(!i || !e.isRGBD)) {
- var o = i.getEngine()
- , s = o.getCaps()
- , c = i.isReady
- , d = !1;
- s.textureHalfFloatRender && s.textureHalfFloatLinearFiltering ? (d = !0,
- i.type = 2) : s.textureFloatRender && s.textureFloatLinearFiltering && (d = !0,
- i.type = 1),
- d && (i.isReady = !1,
- i._isRGBD = !1,
- i.invertY = !1);
- var _ = function() {
- if (d) {
- var b = new PostProcess("rgbdDecode","rgbdDecode",null,null,1,null,3,o,!1,void 0,i.type,void 0,null,!1);
- b.externalTextureSamplerBinding = !0;
- var k = o.createRenderTargetTexture(i.width, {
- generateDepthBuffer: !1,
- generateMipMaps: !1,
- generateStencilBuffer: !1,
- samplingMode: i.samplingMode,
- type: i.type,
- format: 5
- });
- b.getEffect().executeWhenCompiled(function() {
- b.onApply = function(j) {
- j._bindTexture("textureSampler", i),
- j.setFloat2("scale", 1, 1)
- }
- ,
- e.getScene().postProcessManager.directRender([b], k, !0),
- o.restoreDefaultFramebuffer(),
- o._releaseTexture(i),
- b && b.dispose(),
- k._swapAndDie(i),
- i.isReady = !0
- })
- }
- };
- c ? _() : e.onLoadObservable.addOnce(_)
- }
- }
- ,
- a.EncodeTextureToRGBD = function(e, i, o) {
- return o === void 0 && (o = 0),
- ApplyPostProcess("rgbdEncode", e, i, o, 1, 5)
- }
- ,
- a
- }()
- , FileFaceOrientation = function() {
- function a(e, i, o, s) {
- this.name = e,
- this.worldAxisForNormal = i,
- this.worldAxisForFileX = o,
- this.worldAxisForFileY = s
- }
- return a
- }()
- , CubeMapToSphericalPolynomialTools = function() {
- function a() {}
- return a.ConvertCubeMapTextureToSphericalPolynomial = function(e) {
- var i = this, o;
- if (!e.isCube)
- return null;
- (o = e.getScene()) === null || o === void 0 || o.getEngine().flushFramebuffer();
- var s = e.getSize().width, c = e.readPixels(0, void 0, void 0, !1), d = e.readPixels(1, void 0, void 0, !1), _, b;
- e.isRenderTarget ? (_ = e.readPixels(3, void 0, void 0, !1),
- b = e.readPixels(2, void 0, void 0, !1)) : (_ = e.readPixels(2, void 0, void 0, !1),
- b = e.readPixels(3, void 0, void 0, !1));
- var k = e.readPixels(4, void 0, void 0, !1)
- , j = e.readPixels(5, void 0, void 0, !1)
- , $ = e.gammaSpace
- , _e = 5
- , et = 0;
- return (e.textureType == 1 || e.textureType == 2) && (et = 1),
- new Promise(function(tt, rt) {
- Promise.all([d, c, _, b, k, j]).then(function(it) {
- var nt = it[0]
- , ot = it[1]
- , at = it[2]
- , st = it[3]
- , ut = it[4]
- , ct = it[5]
- , lt = {
- size: s,
- right: ot,
- left: nt,
- up: at,
- down: st,
- front: ut,
- back: ct,
- format: _e,
- type: et,
- gammaSpace: $
- };
- tt(i.ConvertCubeMapToSphericalPolynomial(lt))
- })
- }
- )
- }
- ,
- a.ConvertCubeMapToSphericalPolynomial = function(e) {
- for (var i = new SphericalHarmonics, o = 0, s = 2 / e.size, c = s, d = s * .5 - 1, _ = 0; _ < 6; _++)
- for (var b = this.FileFaces[_], k = e[b.name], j = d, $ = e.format === 5 ? 4 : 3, _e = 0; _e < e.size; _e++) {
- for (var et = d, tt = 0; tt < e.size; tt++) {
- var rt = b.worldAxisForFileX.scale(et).add(b.worldAxisForFileY.scale(j)).add(b.worldAxisForNormal);
- rt.normalize();
- var it = Math.pow(1 + et * et + j * j, -3 / 2)
- , nt = k[_e * e.size * $ + tt * $ + 0]
- , ot = k[_e * e.size * $ + tt * $ + 1]
- , at = k[_e * e.size * $ + tt * $ + 2];
- isNaN(nt) && (nt = 0),
- isNaN(ot) && (ot = 0),
- isNaN(at) && (at = 0),
- e.type === 0 && (nt /= 255,
- ot /= 255,
- at /= 255),
- e.gammaSpace && (nt = Math.pow(Scalar.Clamp(nt), ToLinearSpace),
- ot = Math.pow(Scalar.Clamp(ot), ToLinearSpace),
- at = Math.pow(Scalar.Clamp(at), ToLinearSpace));
- var st = 4096;
- nt = Scalar.Clamp(nt, 0, st),
- ot = Scalar.Clamp(ot, 0, st),
- at = Scalar.Clamp(at, 0, st);
- var ut = new Color3(nt,ot,at);
- i.addLight(rt, ut, it),
- o += it,
- et += s
- }
- j += c
- }
- var ct = 4 * Math.PI
- , lt = 6
- , ft = ct * lt / 6
- , ht = ft / o;
- return i.scaleInPlace(ht),
- i.convertIncidentRadianceToIrradiance(),
- i.convertIrradianceToLambertianRadiance(),
- SphericalPolynomial.FromHarmonics(i)
- }
- ,
- 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))],
- a
- }();
- BaseTexture.prototype.forceSphericalPolynomialsRecompute = function() {
- this._texture && (this._texture._sphericalPolynomial = null,
- this._texture._sphericalPolynomialPromise = null,
- this._texture._sphericalPolynomialComputed = !1)
- }
- ;
- Object.defineProperty(BaseTexture.prototype, "sphericalPolynomial", {
- get: function() {
- var a = this;
- if (this._texture) {
- if (this._texture._sphericalPolynomial || this._texture._sphericalPolynomialComputed)
- return this._texture._sphericalPolynomial;
- if (this._texture.isReady)
- return this._texture._sphericalPolynomialPromise || (this._texture._sphericalPolynomialPromise = CubeMapToSphericalPolynomialTools.ConvertCubeMapTextureToSphericalPolynomial(this),
- this._texture._sphericalPolynomialPromise === null ? this._texture._sphericalPolynomialComputed = !0 : this._texture._sphericalPolynomialPromise.then(function(e) {
- a._texture._sphericalPolynomial = e,
- a._texture._sphericalPolynomialComputed = !0
- })),
- null
- }
- return null
- },
- set: function(a) {
- this._texture && (this._texture._sphericalPolynomial = a)
- },
- enumerable: !0,
- configurable: !0
- });
- var name$2W = "rgbdEncodePixelShader"
- , shader$2W = `
- varying vec2 vUV;
- uniform sampler2D textureSampler;
- #include<helperFunctions>
- void main(void)
- {
- gl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);
- }`;
- ShaderStore.ShadersStore[name$2W] = shader$2W;
- var defaultEnvironmentTextureImageType = "image/png"
- , currentVersion = 2
- , _MagicBytes = [134, 22, 135, 150, 246, 214, 150, 54];
- function GetEnvInfo(a) {
- for (var e = new DataView(a.buffer,a.byteOffset,a.byteLength), i = 0, o = 0; o < _MagicBytes.length; o++)
- if (e.getUint8(i++) !== _MagicBytes[o])
- return Logger$2.Error("Not a babylon environment map"),
- null;
- for (var s = "", c = 0; c = e.getUint8(i++); )
- s += String.fromCharCode(c);
- var d = JSON.parse(s);
- return d = normalizeEnvInfo(d),
- d.specular && (d.specular.specularDataPosition = i,
- d.specular.lodGenerationScale = d.specular.lodGenerationScale || .8),
- d
- }
- function normalizeEnvInfo(a) {
- if (a.version > currentVersion)
- throw new Error('Unsupported babylon environment map version "' + a.version + '". Latest supported version is "' + currentVersion + '".');
- return a.version === 2 || (a = __assign(__assign({}, a), {
- version: 2,
- imageType: defaultEnvironmentTextureImageType
- })),
- a
- }
- function CreateImageDataArrayBufferViews(a, e) {
- e = normalizeEnvInfo(e);
- var i = e.specular
- , o = Scalar.Log2(e.width);
- if (o = Math.round(o) + 1,
- i.mipmaps.length !== 6 * o)
- throw new Error('Unsupported specular mipmaps number "' + i.mipmaps.length + '"');
- for (var s = new Array(o), c = 0; c < o; c++) {
- s[c] = new Array(6);
- for (var d = 0; d < 6; d++) {
- var _ = i.mipmaps[c * 6 + d];
- s[c][d] = new Uint8Array(a.buffer,a.byteOffset + i.specularDataPosition + _.position,_.length)
- }
- }
- return s
- }
- function UploadEnvLevelsAsync(a, e, i) {
- i = normalizeEnvInfo(i);
- var o = i.specular;
- if (!o)
- return Promise.resolve();
- a._lodGenerationScale = o.lodGenerationScale;
- var s = CreateImageDataArrayBufferViews(e, i);
- return UploadLevelsAsync(a, s, i.imageType)
- }
- function _OnImageReadyAsync(a, e, i, o, s, c, d, _, b, k, j) {
- return new Promise(function($, _e) {
- if (i) {
- var et = e.createTexture(null, !0, !0, null, 1, null, function(rt) {
- _e(rt)
- }, a);
- o.getEffect().executeWhenCompiled(function() {
- o.externalTextureSamplerBinding = !0,
- o.onApply = function(rt) {
- rt._bindTexture("textureSampler", et),
- rt.setFloat2("scale", 1, e._features.needsInvertingBitmap && a instanceof ImageBitmap ? -1 : 1)
- }
- ,
- e.scenes.length && (e.scenes[0].postProcessManager.directRender([o], k, !0, c, d),
- e.restoreDefaultFramebuffer(),
- et.dispose(),
- URL.revokeObjectURL(s),
- $())
- })
- } else {
- if (e._uploadImageToTexture(j, a, c, d),
- _) {
- var tt = b[d];
- tt && e._uploadImageToTexture(tt._texture, a, c, 0)
- }
- $()
- }
- }
- )
- }
- function UploadLevelsAsync(a, e, i) {
- if (i === void 0 && (i = defaultEnvironmentTextureImageType),
- !Tools.IsExponentOfTwo(a.width))
- throw new Error("Texture size must be a power of two");
- var o = Scalar.ILog2(a.width) + 1
- , s = a.getEngine()
- , c = !1
- , d = !1
- , _ = null
- , b = null
- , k = null
- , j = s.getCaps();
- if (a.format = 5,
- a.type = 0,
- a.generateMipMaps = !0,
- a._cachedAnisotropicFilteringLevel = null,
- s.updateTextureSamplingMode(3, a),
- j.textureLOD ? s._features.supportRenderAndCopyToLodForFloatTextures ? j.textureHalfFloatRender && j.textureHalfFloatLinearFiltering ? (c = !0,
- a.type = 2) : j.textureFloatRender && j.textureFloatLinearFiltering && (c = !0,
- a.type = 1) : c = !1 : (c = !1,
- d = !0,
- k = {}),
- c)
- _ = new PostProcess("rgbdDecode","rgbdDecode",null,null,1,null,3,s,!1,void 0,a.type,void 0,null,!1),
- a._isRGBD = !1,
- a.invertY = !1,
- b = s.createRenderTargetCubeTexture(a.width, {
- generateDepthBuffer: !1,
- generateMipMaps: !0,
- generateStencilBuffer: !1,
- samplingMode: 3,
- type: a.type,
- format: 5
- });
- else if (a._isRGBD = !0,
- a.invertY = !0,
- d)
- for (var $ = 3, _e = a._lodGenerationScale, et = a._lodGenerationOffset, tt = 0; tt < $; tt++) {
- var rt = tt / ($ - 1)
- , it = 1 - rt
- , nt = et
- , ot = (o - 1) * _e + et
- , at = nt + (ot - nt) * it
- , st = Math.round(Math.min(Math.max(at, 0), ot))
- , ut = new InternalTexture(s,InternalTextureSource.Temp);
- ut.isCube = !0,
- ut.invertY = !0,
- ut.generateMipMaps = !1,
- s.updateTextureSamplingMode(2, ut);
- var ct = new BaseTexture(null);
- switch (ct.isCube = !0,
- ct._texture = ut,
- k[st] = ct,
- tt) {
- case 0:
- a._lodTextureLow = ct;
- break;
- case 1:
- a._lodTextureMid = ct;
- break;
- case 2:
- a._lodTextureHigh = ct;
- break
- }
- }
- for (var lt = [], ft = function(mt) {
- for (var vt = function(Et) {
- var At = e[mt][Et]
- , gt = new Blob([At],{
- type: i
- })
- , St = URL.createObjectURL(gt)
- , xt = void 0;
- if (typeof Image == "undefined" || s._features.forceBitmapOverHTMLImageElement)
- xt = s.createImageBitmap(gt, {
- premultiplyAlpha: "none"
- }).then(function(Rt) {
- return _OnImageReadyAsync(Rt, s, c, _, St, Et, mt, d, k, b, a)
- });
- else {
- var bt = new Image;
- bt.src = St,
- xt = new Promise(function(Rt, Mt) {
- bt.onload = function() {
- _OnImageReadyAsync(bt, s, c, _, St, Et, mt, d, k, b, a).then(function() {
- return Rt()
- }).catch(function(Pt) {
- Mt(Pt)
- })
- }
- ,
- bt.onerror = function(Pt) {
- Mt(Pt)
- }
- }
- )
- }
- lt.push(xt)
- }, yt = 0; yt < 6; yt++)
- vt(yt)
- }, tt = 0; tt < e.length; tt++)
- ft(tt);
- if (e.length < o) {
- var ht = void 0
- , pt = Math.pow(2, o - 1 - e.length)
- , dt = pt * pt * 4;
- switch (a.type) {
- case 0:
- {
- ht = new Uint8Array(dt);
- break
- }
- case 2:
- {
- ht = new Uint16Array(dt);
- break
- }
- case 1:
- {
- ht = new Float32Array(dt);
- break
- }
- }
- for (var tt = e.length; tt < o; tt++)
- for (var _t = 0; _t < 6; _t++)
- s._uploadArrayBufferViewToTexture(a, ht, _t, tt)
- }
- return Promise.all(lt).then(function() {
- b && (s._releaseTexture(a),
- b._swapAndDie(a)),
- _ && _.dispose(),
- d && (a._lodTextureHigh && a._lodTextureHigh._texture && (a._lodTextureHigh._texture.isReady = !0),
- a._lodTextureMid && a._lodTextureMid._texture && (a._lodTextureMid._texture.isReady = !0),
- a._lodTextureLow && a._lodTextureLow._texture && (a._lodTextureLow._texture.isReady = !0))
- })
- }
- function UploadEnvSpherical(a, e) {
- e = normalizeEnvInfo(e);
- var i = e.irradiance;
- if (!!i) {
- var o = new SphericalPolynomial;
- Vector3.FromArrayToRef(i.x, 0, o.x),
- Vector3.FromArrayToRef(i.y, 0, o.y),
- Vector3.FromArrayToRef(i.z, 0, o.z),
- Vector3.FromArrayToRef(i.xx, 0, o.xx),
- Vector3.FromArrayToRef(i.yy, 0, o.yy),
- Vector3.FromArrayToRef(i.zz, 0, o.zz),
- Vector3.FromArrayToRef(i.yz, 0, o.yz),
- Vector3.FromArrayToRef(i.zx, 0, o.zx),
- Vector3.FromArrayToRef(i.xy, 0, o.xy),
- a._sphericalPolynomial = o
- }
- }
- function _UpdateRGBDAsync(a, e, i, o, s) {
- var c = a.getEngine().createRawCubeTexture(null, a.width, a.format, a.type, a.generateMipMaps, a.invertY, a.samplingMode, a._compression)
- , d = UploadLevelsAsync(c, e).then(function() {
- return a
- });
- return a.onRebuildCallback = function(_) {
- return {
- proxy: d,
- isReady: !0,
- isAsync: !0
- }
- }
- ,
- a._source = InternalTextureSource.CubeRawRGBD,
- a._bufferViewArrayArray = e,
- a._lodGenerationScale = o,
- a._lodGenerationOffset = s,
- a._sphericalPolynomial = i,
- UploadLevelsAsync(a, e).then(function() {
- return a.isReady = !0,
- a
- })
- }
- function ExtractBetweenMarkers(a, e, i, o) {
- for (var s = o, c = 0, d = ""; s < i.length; ) {
- var _ = i.charAt(s);
- if (d)
- _ === d ? d === '"' || d === "'" ? i.charAt(s - 1) !== "\\" && (d = "") : d = "" : d === "*/" && _ === "*" && s + 1 < i.length && (i.charAt(s + 1) === "/" && (d = ""),
- d === "" && s++);
- else
- switch (_) {
- case a:
- c++;
- break;
- case e:
- c--;
- break;
- case '"':
- case "'":
- case "`":
- d = _;
- break;
- case "/":
- if (s + 1 < i.length) {
- var b = i.charAt(s + 1);
- b === "/" ? d = `
- ` : b === "*" && (d = "*/")
- }
- break
- }
- if (s++,
- c === 0)
- break
- }
- return c === 0 ? s - 1 : -1
- }
- function SkipWhitespaces(a, e) {
- for (; e < a.length; ) {
- var i = a[e];
- if (i !== " " && i !== `
- ` && i !== "\r" && i !== " " && i !== `
- ` && i !== "\xA0")
- break;
- e++
- }
- return e
- }
- function IsIdentifierChar(a) {
- var e = a.charCodeAt(0);
- return e >= 48 && e <= 57 || e >= 65 && e <= 90 || e >= 97 && e <= 122 || e == 95
- }
- function RemoveComments(a) {
- for (var e = 0, i = "", o = !1, s = []; e < a.length; ) {
- var c = a.charAt(e);
- if (i)
- c === i ? i === '"' || i === "'" ? (a.charAt(e - 1) !== "\\" && (i = ""),
- s.push(c)) : (i = "",
- o = !1) : i === "*/" && c === "*" && e + 1 < a.length ? (a.charAt(e + 1) === "/" && (i = ""),
- i === "" && (o = !1,
- e++)) : o || s.push(c);
- else {
- switch (c) {
- case '"':
- case "'":
- case "`":
- i = c;
- break;
- case "/":
- if (e + 1 < a.length) {
- var d = a.charAt(e + 1);
- d === "/" ? (i = `
- `,
- o = !0) : d === "*" && (i = "*/",
- o = !0)
- }
- break
- }
- o || s.push(c)
- }
- e++
- }
- return s.join("")
- }
- function FindBackward(a, e, i) {
- for (; e >= 0 && a.charAt(e) !== i; )
- e--;
- return e
- }
- function EscapeRegExp(a) {
- return a.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
- }
- var ShaderCodeInliner = function() {
- function a(e, i) {
- i === void 0 && (i = 20),
- this.debug = !1,
- this._sourceCode = e,
- this._numMaxIterations = i,
- this._functionDescr = [],
- this.inlineToken = "#define inline"
- }
- return Object.defineProperty(a.prototype, "code", {
- get: function() {
- return this._sourceCode
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.processCode = function() {
- this.debug && console.log("Start inlining process (code size=" + this._sourceCode.length + ")..."),
- this._collectFunctions(),
- this._processInlining(this._numMaxIterations),
- this.debug && console.log("End of inlining process.")
- }
- ,
- a.prototype._collectFunctions = function() {
- for (var e = 0; e < this._sourceCode.length; ) {
- var i = this._sourceCode.indexOf(this.inlineToken, e);
- if (i < 0)
- break;
- var o = this._sourceCode.indexOf("(", i + this.inlineToken.length);
- if (o < 0) {
- this.debug && console.warn("Could not find the opening parenthesis after the token. startIndex=" + e),
- e = i + this.inlineToken.length;
- continue
- }
- var s = a._RegexpFindFunctionNameAndType.exec(this._sourceCode.substring(i + this.inlineToken.length, o));
- if (!s) {
- this.debug && console.warn("Could not extract the name/type of the function from: " + this._sourceCode.substring(i + this.inlineToken.length, o)),
- e = i + this.inlineToken.length;
- continue
- }
- var c = [s[3], s[4]]
- , d = c[0]
- , _ = c[1]
- , b = ExtractBetweenMarkers("(", ")", this._sourceCode, o);
- if (b < 0) {
- this.debug && console.warn("Could not extract the parameters the function '" + _ + "' (type=" + d + "). funcParamsStartIndex=" + o),
- e = i + this.inlineToken.length;
- continue
- }
- var k = this._sourceCode.substring(o + 1, b)
- , j = SkipWhitespaces(this._sourceCode, b + 1);
- if (j === this._sourceCode.length) {
- this.debug && console.warn("Could not extract the body of the function '" + _ + "' (type=" + d + "). funcParamsEndIndex=" + b),
- e = i + this.inlineToken.length;
- continue
- }
- var $ = ExtractBetweenMarkers("{", "}", this._sourceCode, j);
- if ($ < 0) {
- this.debug && console.warn("Could not extract the body of the function '" + _ + "' (type=" + d + "). funcBodyStartIndex=" + j),
- e = i + this.inlineToken.length;
- continue
- }
- for (var _e = this._sourceCode.substring(j, $ + 1), et = RemoveComments(k).split(","), tt = [], rt = 0; rt < et.length; ++rt) {
- var it = et[rt].trim()
- , nt = it.lastIndexOf(" ");
- nt >= 0 && tt.push(it.substring(nt + 1))
- }
- d !== "void" && tt.push("return"),
- this._functionDescr.push({
- name: _,
- type: d,
- parameters: tt,
- body: _e,
- callIndex: 0
- }),
- e = $ + 1;
- var ot = i > 0 ? this._sourceCode.substring(0, i) : ""
- , at = $ + 1 < this._sourceCode.length - 1 ? this._sourceCode.substring($ + 1) : "";
- this._sourceCode = ot + at,
- e -= $ + 1 - i
- }
- this.debug && console.log("Collect functions: " + this._functionDescr.length + " functions found. functionDescr=", this._functionDescr)
- }
- ,
- a.prototype._processInlining = function(e) {
- for (e === void 0 && (e = 20); e-- >= 0 && this._replaceFunctionCallsByCode(); )
- ;
- return this.debug && console.log("numMaxIterations is " + e + " after inlining process"),
- e >= 0
- }
- ,
- a.prototype._replaceFunctionCallsByCode = function() {
- for (var e = !1, i = 0, o = this._functionDescr; i < o.length; i++)
- for (var s = o[i], c = s.name, d = s.type, _ = s.parameters, b = s.body, k = 0; k < this._sourceCode.length; ) {
- var j = this._sourceCode.indexOf(c, k);
- if (j < 0)
- break;
- if (j === 0 || IsIdentifierChar(this._sourceCode.charAt(j - 1))) {
- k = j + c.length;
- continue
- }
- var $ = SkipWhitespaces(this._sourceCode, j + c.length);
- if ($ === this._sourceCode.length || this._sourceCode.charAt($) !== "(") {
- k = j + c.length;
- continue
- }
- var _e = ExtractBetweenMarkers("(", ")", this._sourceCode, $);
- if (_e < 0) {
- this.debug && console.warn("Could not extract the parameters of the function call. Function '" + c + "' (type=" + d + "). callParamsStartIndex=" + $),
- k = j + c.length;
- continue
- }
- var et = this._sourceCode.substring($ + 1, _e)
- , tt = function(ht) {
- for (var pt = [], dt = 0, _t = 0; dt < ht.length; ) {
- if (ht.charAt(dt) === "(") {
- var mt = ExtractBetweenMarkers("(", ")", ht, dt);
- if (mt < 0)
- return null;
- dt = mt
- } else
- ht.charAt(dt) === "," && (pt.push(ht.substring(_t, dt)),
- _t = dt + 1);
- dt++
- }
- return _t < dt && pt.push(ht.substring(_t, dt)),
- pt
- }
- , rt = tt(RemoveComments(et));
- if (rt === null) {
- this.debug && console.warn("Invalid function call: can't extract the parameters of the function call. Function '" + c + "' (type=" + d + "). callParamsStartIndex=" + $ + ", callParams=" + et),
- k = j + c.length;
- continue
- }
- for (var it = [], nt = 0; nt < rt.length; ++nt) {
- var ot = rt[nt].trim();
- it.push(ot)
- }
- var at = d !== "void" ? c + "_" + s.callIndex++ : null;
- if (at && it.push(at + " ="),
- it.length !== _.length) {
- 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),
- k = j + c.length;
- continue
- }
- k = _e + 1;
- var st = this._replaceNames(b, _, it)
- , ut = j > 0 ? this._sourceCode.substring(0, j) : ""
- , ct = _e + 1 < this._sourceCode.length - 1 ? this._sourceCode.substring(_e + 1) : "";
- if (at) {
- var lt = FindBackward(this._sourceCode, j - 1, `
- `);
- ut = this._sourceCode.substring(0, lt + 1);
- var ft = this._sourceCode.substring(lt + 1, j);
- this._sourceCode = ut + d + " " + at + `;
- ` + st + `
- ` + ft + at + ct,
- this.debug && console.log("Replace function call by code. Function '" + c + "' (type=" + d + "). injectDeclarationIndex=" + lt + ", call parameters=" + it)
- } else
- this._sourceCode = ut + st + ct,
- k += st.length - (_e + 1 - j),
- this.debug && console.log("Replace function call by code. Function '" + c + "' (type=" + d + "). functionCallIndex=" + j + ", call parameters=" + it);
- e = !0
- }
- return e
- }
- ,
- a.prototype._replaceNames = function(e, i, o) {
- for (var s = function(d) {
- var _ = new RegExp(EscapeRegExp(i[d]),"g")
- , b = i[d].length
- , k = o[d];
- e = e.replace(_, function(j) {
- for (var $ = [], _e = 1; _e < arguments.length; _e++)
- $[_e - 1] = arguments[_e];
- var et = $[0];
- return IsIdentifierChar(e.charAt(et - 1)) || IsIdentifierChar(e.charAt(et + b)) ? i[d] : k
- })
- }, c = 0; c < i.length; ++c)
- s(c);
- return e
- }
- ,
- a._RegexpFindFunctionNameAndType = /((\s+?)(\w+)\s+(\w+)\s*?)$/,
- a
- }()
- , NativePipelineContext = function() {
- function a(e) {
- this.isAsync = !1,
- this.isReady = !1,
- this._valueCache = {},
- this.engine = e
- }
- return a.prototype._getVertexShaderCode = function() {
- return null
- }
- ,
- a.prototype._getFragmentShaderCode = function() {
- return null
- }
- ,
- a.prototype._handlesSpectorRebuildCallback = function(e) {
- throw new Error("Not implemented")
- }
- ,
- a.prototype._fillEffectInformation = function(e, i, o, s, c, d, _, b) {
- var k = this.engine;
- if (k.supportsUniformBuffers)
- for (var j in i)
- e.bindUniformBlock(j, i[j]);
- var $ = this.engine.getUniforms(this, o);
- $.forEach(function(tt, rt) {
- s[o[rt]] = tt
- }),
- this._uniforms = s;
- var _e;
- for (_e = 0; _e < c.length; _e++) {
- var et = e.getUniform(c[_e]);
- et == null && (c.splice(_e, 1),
- _e--)
- }
- c.forEach(function(tt, rt) {
- d[tt] = rt
- }),
- b.push.apply(b, k.getAttributes(this, _))
- }
- ,
- a.prototype.dispose = function() {
- this._uniforms = {}
- }
- ,
- a.prototype._cacheMatrix = function(e, i) {
- var o = this._valueCache[e]
- , s = i.updateFlag;
- return o !== void 0 && o === s ? !1 : (this._valueCache[e] = s,
- !0)
- }
- ,
- a.prototype._cacheFloat2 = function(e, i, o) {
- var s = this._valueCache[e];
- if (!s)
- return s = [i, o],
- this._valueCache[e] = s,
- !0;
- var c = !1;
- return s[0] !== i && (s[0] = i,
- c = !0),
- s[1] !== o && (s[1] = o,
- c = !0),
- c
- }
- ,
- a.prototype._cacheFloat3 = function(e, i, o, s) {
- var c = this._valueCache[e];
- if (!c)
- return c = [i, o, s],
- this._valueCache[e] = c,
- !0;
- var d = !1;
- return c[0] !== i && (c[0] = i,
- d = !0),
- c[1] !== o && (c[1] = o,
- d = !0),
- c[2] !== s && (c[2] = s,
- d = !0),
- d
- }
- ,
- a.prototype._cacheFloat4 = function(e, i, o, s, c) {
- var d = this._valueCache[e];
- if (!d)
- return d = [i, o, s, c],
- this._valueCache[e] = d,
- !0;
- var _ = !1;
- return d[0] !== i && (d[0] = i,
- _ = !0),
- d[1] !== o && (d[1] = o,
- _ = !0),
- d[2] !== s && (d[2] = s,
- _ = !0),
- d[3] !== c && (d[3] = c,
- _ = !0),
- _
- }
- ,
- a.prototype.setInt = function(e, i) {
- var o = this._valueCache[e];
- o !== void 0 && o === i || this.engine.setInt(this._uniforms[e], i) && (this._valueCache[e] = i)
- }
- ,
- a.prototype.setInt2 = function(e, i, o) {
- this._cacheFloat2(e, i, o) && (this.engine.setInt2(this._uniforms[e], i, o) || (this._valueCache[e] = null))
- }
- ,
- a.prototype.setInt3 = function(e, i, o, s) {
- this._cacheFloat3(e, i, o, s) && (this.engine.setInt3(this._uniforms[e], i, o, s) || (this._valueCache[e] = null))
- }
- ,
- a.prototype.setInt4 = function(e, i, o, s, c) {
- this._cacheFloat4(e, i, o, s, c) && (this.engine.setInt4(this._uniforms[e], i, o, s, c) || (this._valueCache[e] = null))
- }
- ,
- a.prototype.setIntArray = function(e, i) {
- this._valueCache[e] = null,
- this.engine.setIntArray(this._uniforms[e], i)
- }
- ,
- a.prototype.setIntArray2 = function(e, i) {
- this._valueCache[e] = null,
- this.engine.setIntArray2(this._uniforms[e], i)
- }
- ,
- a.prototype.setIntArray3 = function(e, i) {
- this._valueCache[e] = null,
- this.engine.setIntArray3(this._uniforms[e], i)
- }
- ,
- a.prototype.setIntArray4 = function(e, i) {
- this._valueCache[e] = null,
- this.engine.setIntArray4(this._uniforms[e], i)
- }
- ,
- a.prototype.setFloatArray = function(e, i) {
- this._valueCache[e] = null,
- this.engine.setFloatArray(this._uniforms[e], i)
- }
- ,
- a.prototype.setFloatArray2 = function(e, i) {
- this._valueCache[e] = null,
- this.engine.setFloatArray2(this._uniforms[e], i)
- }
- ,
- a.prototype.setFloatArray3 = function(e, i) {
- this._valueCache[e] = null,
- this.engine.setFloatArray3(this._uniforms[e], i)
- }
- ,
- a.prototype.setFloatArray4 = function(e, i) {
- this._valueCache[e] = null,
- this.engine.setFloatArray4(this._uniforms[e], i)
- }
- ,
- a.prototype.setArray = function(e, i) {
- this._valueCache[e] = null,
- this.engine.setArray(this._uniforms[e], i)
- }
- ,
- a.prototype.setArray2 = function(e, i) {
- this._valueCache[e] = null,
- this.engine.setArray2(this._uniforms[e], i)
- }
- ,
- a.prototype.setArray3 = function(e, i) {
- this._valueCache[e] = null,
- this.engine.setArray3(this._uniforms[e], i)
- }
- ,
- a.prototype.setArray4 = function(e, i) {
- this._valueCache[e] = null,
- this.engine.setArray4(this._uniforms[e], i)
- }
- ,
- a.prototype.setMatrices = function(e, i) {
- !i || (this._valueCache[e] = null,
- this.engine.setMatrices(this._uniforms[e], i))
- }
- ,
- a.prototype.setMatrix = function(e, i) {
- this._cacheMatrix(e, i) && (this.engine.setMatrices(this._uniforms[e], i.toArray()) || (this._valueCache[e] = null))
- }
- ,
- a.prototype.setMatrix3x3 = function(e, i) {
- this._valueCache[e] = null,
- this.engine.setMatrix3x3(this._uniforms[e], i)
- }
- ,
- a.prototype.setMatrix2x2 = function(e, i) {
- this._valueCache[e] = null,
- this.engine.setMatrix2x2(this._uniforms[e], i)
- }
- ,
- a.prototype.setFloat = function(e, i) {
- var o = this._valueCache[e];
- o !== void 0 && o === i || this.engine.setFloat(this._uniforms[e], i) && (this._valueCache[e] = i)
- }
- ,
- a.prototype.setBool = function(e, i) {
- var o = this._valueCache[e];
- o !== void 0 && o === i || this.engine.setInt(this._uniforms[e], i ? 1 : 0) && (this._valueCache[e] = i ? 1 : 0)
- }
- ,
- a.prototype.setVector2 = function(e, i) {
- this._cacheFloat2(e, i.x, i.y) && (this.engine.setFloat2(this._uniforms[e], i.x, i.y) || (this._valueCache[e] = null))
- }
- ,
- a.prototype.setFloat2 = function(e, i, o) {
- this._cacheFloat2(e, i, o) && (this.engine.setFloat2(this._uniforms[e], i, o) || (this._valueCache[e] = null))
- }
- ,
- a.prototype.setVector3 = function(e, i) {
- 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))
- }
- ,
- a.prototype.setFloat3 = function(e, i, o, s) {
- this._cacheFloat3(e, i, o, s) && (this.engine.setFloat3(this._uniforms[e], i, o, s) || (this._valueCache[e] = null))
- }
- ,
- a.prototype.setVector4 = function(e, i) {
- 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))
- }
- ,
- a.prototype.setFloat4 = function(e, i, o, s, c) {
- this._cacheFloat4(e, i, o, s, c) && (this.engine.setFloat4(this._uniforms[e], i, o, s, c) || (this._valueCache[e] = null))
- }
- ,
- a.prototype.setColor3 = function(e, i) {
- 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))
- }
- ,
- a.prototype.setColor4 = function(e, i, o) {
- 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))
- }
- ,
- a.prototype.setDirectColor4 = function(e, i) {
- 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))
- }
- ,
- a
- }()
- , NativeRenderTargetWrapper = function(a) {
- __extends(e, a);
- function e(i, o, s, c) {
- var d = a.call(this, i, o, s, c) || this;
- return d.__framebuffer = null,
- d.__framebufferDepthStencil = null,
- d._engine = c,
- d
- }
- return Object.defineProperty(e.prototype, "_framebuffer", {
- get: function() {
- return this.__framebuffer
- },
- set: function(i) {
- this.__framebuffer && this._engine._releaseFramebufferObjects(this.__framebuffer),
- this.__framebuffer = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "_framebufferDepthStencil", {
- get: function() {
- return this.__framebufferDepthStencil
- },
- set: function(i) {
- this.__framebufferDepthStencil && this._engine._releaseFramebufferObjects(this.__framebufferDepthStencil),
- this.__framebufferDepthStencil = i
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.dispose = function(i) {
- i === void 0 && (i = !1),
- this._framebuffer = null,
- this._framebufferDepthStencil = null,
- a.prototype.dispose.call(this, i)
- }
- ,
- e
- }(RenderTargetWrapper)
- , NativeDataBuffer = function(a) {
- __extends(e, a);
- function e() {
- return a !== null && a.apply(this, arguments) || this
- }
- return e
- }(DataBuffer)
- , CommandBufferEncoder = function() {
- function a(e) {
- this._engine = e,
- this._pending = new Array,
- this._isCommandBufferScopeActive = !1,
- this._commandStream = NativeEngine._createNativeDataStream(),
- this._engine.setCommandDataStream(this._commandStream)
- }
- return a.prototype.beginCommandScope = function() {
- if (this._isCommandBufferScopeActive)
- throw new Error("Command scope already active.");
- this._isCommandBufferScopeActive = !0
- }
- ,
- a.prototype.endCommandScope = function() {
- if (!this._isCommandBufferScopeActive)
- throw new Error("Command scope is not active.");
- this._isCommandBufferScopeActive = !1,
- this._submit()
- }
- ,
- a.prototype.startEncodingCommand = function(e) {
- this._commandStream.writeNativeData(e)
- }
- ,
- a.prototype.encodeCommandArgAsUInt32 = function(e) {
- this._commandStream.writeUint32(e)
- }
- ,
- a.prototype.encodeCommandArgAsUInt32s = function(e) {
- this._commandStream.writeUint32Array(e)
- }
- ,
- a.prototype.encodeCommandArgAsInt32 = function(e) {
- this._commandStream.writeInt32(e)
- }
- ,
- a.prototype.encodeCommandArgAsInt32s = function(e) {
- this._commandStream.writeInt32Array(e)
- }
- ,
- a.prototype.encodeCommandArgAsFloat32 = function(e) {
- this._commandStream.writeFloat32(e)
- }
- ,
- a.prototype.encodeCommandArgAsFloat32s = function(e) {
- this._commandStream.writeFloat32Array(e)
- }
- ,
- a.prototype.encodeCommandArgAsNativeData = function(e) {
- this._commandStream.writeNativeData(e),
- this._pending.push(e)
- }
- ,
- a.prototype.finishEncodingCommand = function() {
- this._isCommandBufferScopeActive || this._submit()
- }
- ,
- a.prototype._submit = function() {
- this._engine.submitCommands(),
- this._pending.length = 0
- }
- ,
- a
- }()
- , NativeEngine = function(a) {
- __extends(e, a);
- function e(i) {
- i === void 0 && (i = {});
- var o = a.call(this, null, !1, void 0, i.adaptToDeviceRatio) || this;
- if (o._engine = new _native.Engine,
- o._camera = _native.Camera ? new _native.Camera : null,
- o._commandBufferEncoder = new CommandBufferEncoder(o._engine),
- o._boundBuffersVertexArray = null,
- o._currentDepthTest = _native.Engine.DEPTH_TEST_LEQUAL,
- o._stencilTest = !1,
- o._stencilMask = 255,
- o._stencilFunc = 519,
- o._stencilFuncRef = 0,
- o._stencilFuncMask = 255,
- o._stencilOpStencilFail = 7680,
- o._stencilOpDepthFail = 7680,
- o._stencilOpStencilDepthPass = 7681,
- o._zOffset = 0,
- o._zOffsetUnits = 0,
- o._depthWrite = !0,
- _native.Engine.PROTOCOL_VERSION !== e.PROTOCOL_VERSION)
- throw new Error("Protocol version mismatch: " + _native.Engine.PROTOCOL_VERSION + " (Native) !== " + e.PROTOCOL_VERSION + " (JS)");
- o._webGLVersion = 2,
- o.disableUniformBuffers = !0,
- o._caps = {
- maxTexturesImageUnits: 16,
- maxVertexTextureImageUnits: 16,
- maxCombinedTexturesImageUnits: 32,
- maxTextureSize: 512,
- maxCubemapTextureSize: 512,
- maxRenderTextureSize: 512,
- maxVertexAttribs: 16,
- maxVaryingVectors: 16,
- maxFragmentUniformVectors: 16,
- maxVertexUniformVectors: 16,
- standardDerivatives: !0,
- astc: null,
- pvrtc: null,
- etc1: null,
- etc2: null,
- bptc: null,
- maxAnisotropy: 16,
- uintIndices: !0,
- fragmentDepthSupported: !1,
- highPrecisionShaderSupported: !0,
- colorBufferFloat: !1,
- textureFloat: !0,
- textureFloatLinearFiltering: !1,
- textureFloatRender: !1,
- textureHalfFloat: !1,
- textureHalfFloatLinearFiltering: !1,
- textureHalfFloatRender: !1,
- textureLOD: !0,
- drawBuffersExtension: !1,
- depthTextureExtension: !1,
- vertexArrayObject: !0,
- instancedArrays: !1,
- supportOcclusionQuery: !1,
- canUseTimestampForTimerQuery: !1,
- blendMinMax: !1,
- maxMSAASamples: 1,
- canUseGLInstanceID: !0,
- canUseGLVertexID: !0,
- supportComputeShaders: !1,
- supportSRGBBuffers: !0
- },
- o._features = {
- forceBitmapOverHTMLImageElement: !1,
- supportRenderAndCopyToLodForFloatTextures: !1,
- supportDepthStencilTexture: !1,
- supportShadowSamplers: !1,
- uniformBufferHardCheckMatrix: !1,
- allowTexturePrefiltering: !1,
- trackUbosInFrame: !1,
- checkUbosContentBeforeUpload: !1,
- supportCSM: !1,
- basisNeedsPOT: !1,
- support3DTextures: !1,
- needTypeSuffixInShaderConstants: !1,
- supportMSAA: !1,
- supportSSAO2: !1,
- supportExtendedTextureFormats: !1,
- supportSwitchCaseInShader: !1,
- supportSyncTextureRead: !1,
- needsInvertingBitmap: !0,
- useUBOBindingCache: !0,
- needShaderCodeInlining: !0,
- needToAlwaysBindUniformBuffers: !1,
- supportRenderPasses: !0,
- _collectUbosUpdatedInFrame: !1
- },
- Tools.Log("Babylon Native (v" + Engine.Version + ") launched"),
- Tools.LoadScript = function(d, _, b, k) {
- Tools.LoadFile(d, function(j) {
- Function(j).apply(null),
- _ && _()
- }, void 0, void 0, !1, function(j, $) {
- b && b("LoadScript Error", $)
- })
- }
- ,
- typeof URL == "undefined" && (window.URL = {
- createObjectURL: function() {},
- revokeObjectURL: function() {}
- }),
- typeof Blob == "undefined" && (window.Blob = function(d) {
- return d
- }
- );
- var s = window && window.devicePixelRatio || 1;
- o._hardwareScalingLevel = i.adaptToDeviceRatio ? s : 1,
- o.resize();
- var c = o.getDepthFunction();
- return c && o.setDepthFunction(c),
- o._shaderProcessor = new WebGL2ShaderProcessor,
- o.onNewSceneAddedObservable.add(function(d) {
- var _ = d.render;
- d.render = function() {
- for (var b = [], k = 0; k < arguments.length; k++)
- b[k] = arguments[k];
- o._commandBufferEncoder.beginCommandScope(),
- _.apply(d, b),
- o._commandBufferEncoder.endCommandScope()
- }
- }),
- o
- }
- return e.prototype.getHardwareScalingLevel = function() {
- return this._engine.getHardwareScalingLevel()
- }
- ,
- e.prototype.setHardwareScalingLevel = function(i) {
- this._engine.setHardwareScalingLevel(i)
- }
- ,
- e.prototype.dispose = function() {
- a.prototype.dispose.call(this),
- this._boundBuffersVertexArray && this._deleteVertexArray(this._boundBuffersVertexArray),
- this._engine.dispose()
- }
- ,
- e._createNativeDataStream = function() {
- return new NativeDataStream
- }
- ,
- e.prototype._queueNewFrame = function(i, o) {
- return o.requestAnimationFrame && o !== window ? o.requestAnimationFrame(i) : this._engine.requestAnimationFrame(i),
- 0
- }
- ,
- e.prototype._bindUnboundFramebuffer = function(i) {
- this._currentFramebuffer !== i && (this._currentFramebuffer && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_UNBINDFRAMEBUFFER),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(this._currentFramebuffer),
- this._commandBufferEncoder.finishEncodingCommand()),
- i && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_BINDFRAMEBUFFER),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
- this._commandBufferEncoder.finishEncodingCommand()),
- this._currentFramebuffer = i)
- }
- ,
- e.prototype.getHostDocument = function() {
- return null
- }
- ,
- e.prototype.clear = function(i, o, s, c) {
- if (c === void 0 && (c = !1),
- this.useReverseDepthBuffer)
- throw new Error("reverse depth buffer is not currently implemented");
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_CLEAR),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(o && i ? 1 : 0),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(i ? i.r : 0),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(i ? i.g : 0),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(i ? i.b : 0),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(i ? i.a : 1),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(s ? 1 : 0),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(1),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(c ? 1 : 0),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(0),
- this._commandBufferEncoder.finishEncodingCommand()
- }
- ,
- e.prototype.createIndexBuffer = function(i, o) {
- var s = this._normalizeIndexData(i)
- , c = new NativeDataBuffer;
- return c.references = 1,
- c.is32Bits = s.BYTES_PER_ELEMENT === 4,
- s.byteLength && (c.nativeIndexBuffer = this._engine.createIndexBuffer(s.buffer, s.byteOffset, s.byteLength, c.is32Bits, o != null ? o : !1)),
- c
- }
- ,
- e.prototype.createVertexBuffer = function(i, o) {
- var s = ArrayBuffer.isView(i) ? i : new Float32Array(i)
- , c = new NativeDataBuffer;
- return c.references = 1,
- s.byteLength && (c.nativeVertexBuffer = this._engine.createVertexBuffer(s.buffer, s.byteOffset, s.byteLength, o != null ? o : !1)),
- c
- }
- ,
- e.prototype._recordVertexArrayObject = function(i, o, s, c) {
- s && this._engine.recordIndexBuffer(i, s.nativeIndexBuffer);
- for (var d = c.getAttributesNames(), _ = 0; _ < d.length; _++) {
- var b = c.getAttributeLocation(_);
- if (b >= 0) {
- var k = d[_]
- , j = o[k];
- if (j) {
- var $ = j.getBuffer();
- $ && this._engine.recordVertexBuffer(i, $.nativeVertexBuffer, b, j.byteOffset, j.byteStride, j.getSize(), this._getNativeAttribType(j.type), j.normalized)
- }
- }
- }
- }
- ,
- e.prototype.bindBuffers = function(i, o, s) {
- this._boundBuffersVertexArray && this._deleteVertexArray(this._boundBuffersVertexArray),
- this._boundBuffersVertexArray = this._engine.createVertexArray(),
- this._recordVertexArrayObject(this._boundBuffersVertexArray, i, o, s),
- this.bindVertexArrayObject(this._boundBuffersVertexArray)
- }
- ,
- e.prototype.recordVertexArrayObject = function(i, o, s) {
- var c = this._engine.createVertexArray();
- return this._recordVertexArrayObject(c, i, o, s),
- c
- }
- ,
- e.prototype._deleteVertexArray = function(i) {
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEVERTEXARRAY),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
- this._commandBufferEncoder.finishEncodingCommand()
- }
- ,
- e.prototype.bindVertexArrayObject = function(i) {
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_BINDVERTEXARRAY),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
- this._commandBufferEncoder.finishEncodingCommand()
- }
- ,
- e.prototype.releaseVertexArrayObject = function(i) {
- this._deleteVertexArray(i)
- }
- ,
- e.prototype.getAttributes = function(i, o) {
- var s = i;
- return this._engine.getAttributes(s.nativeProgram, o)
- }
- ,
- e.prototype.drawElementsType = function(i, o, s, c) {
- this._drawCalls.addCount(1, !1),
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DRAWINDEXED),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(i),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(o),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(s),
- this._commandBufferEncoder.finishEncodingCommand()
- }
- ,
- e.prototype.drawArraysType = function(i, o, s, c) {
- this._drawCalls.addCount(1, !1),
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DRAW),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(i),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(o),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(s),
- this._commandBufferEncoder.finishEncodingCommand()
- }
- ,
- e.prototype.createPipelineContext = function() {
- return new NativePipelineContext(this)
- }
- ,
- e.prototype.createMaterialContext = function() {}
- ,
- e.prototype.createDrawContext = function() {}
- ,
- e.prototype._preparePipelineContext = function(i, o, s, c, d, _, b, k, j) {
- var $ = i;
- c ? $.nativeProgram = this.createRawShaderProgram(i, o, s, void 0, j) : $.nativeProgram = this.createShaderProgram(i, o, s, k, void 0, j)
- }
- ,
- e.prototype._isRenderingStateCompiled = function(i) {
- return !0
- }
- ,
- e.prototype._executeWhenRenderingStateIsCompiled = function(i, o) {
- o()
- }
- ,
- e.prototype.createRawShaderProgram = function(i, o, s, c, d) {
- throw new Error("Not Supported")
- }
- ,
- e.prototype.createShaderProgram = function(i, o, s, c, d, _) {
- this.onBeforeShaderCompilationObservable.notifyObservers(this);
- var b = new ShaderCodeInliner(o);
- b.processCode(),
- o = b.code;
- var k = new ShaderCodeInliner(s);
- k.processCode(),
- s = k.code,
- o = ThinEngine._ConcatenateShader(o, c),
- s = ThinEngine._ConcatenateShader(s, c);
- var j = this._engine.createProgram(o, s);
- return this.onAfterShaderCompilationObservable.notifyObservers(this),
- j
- }
- ,
- e.prototype.inlineShaderCode = function(i) {
- var o = new ShaderCodeInliner(i);
- return o.debug = !1,
- o.processCode(),
- o.code
- }
- ,
- e.prototype._setProgram = function(i) {
- this._currentProgram !== i && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETPROGRAM),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
- this._commandBufferEncoder.finishEncodingCommand(),
- this._currentProgram = i)
- }
- ,
- e.prototype._deletePipelineContext = function(i) {
- var o = i;
- o && o.nativeProgram && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEPROGRAM),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(o.nativeProgram),
- this._commandBufferEncoder.finishEncodingCommand())
- }
- ,
- e.prototype.getUniforms = function(i, o) {
- var s = i;
- return this._engine.getUniforms(s.nativeProgram, o)
- }
- ,
- e.prototype.bindUniformBlock = function(i, o, s) {
- throw new Error("Not Implemented")
- }
- ,
- e.prototype.bindSamplers = function(i) {
- var o = i.getPipelineContext();
- this._setProgram(o.nativeProgram);
- for (var s = i.getSamplers(), c = 0; c < s.length; c++) {
- var d = i.getUniform(s[c]);
- d && (this._boundUniforms[c] = d)
- }
- this._currentEffect = null
- }
- ,
- e.prototype.setMatrix = function(i, o) {
- if (!!i) {
- var s = o.toArray();
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETMATRIX),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
- this._commandBufferEncoder.encodeCommandArgAsFloat32s(s),
- this._commandBufferEncoder.finishEncodingCommand()
- }
- }
- ,
- e.prototype.getRenderWidth = function(i) {
- return i === void 0 && (i = !1),
- !i && this._currentRenderTarget ? this._currentRenderTarget.width : this._engine.getRenderWidth()
- }
- ,
- e.prototype.getRenderHeight = function(i) {
- return i === void 0 && (i = !1),
- !i && this._currentRenderTarget ? this._currentRenderTarget.height : this._engine.getRenderHeight()
- }
- ,
- e.prototype.setViewport = function(i, o, s) {
- this._cachedViewport = i,
- this._engine.setViewPort(i.x, i.y, i.width, i.height)
- }
- ,
- e.prototype.setState = function(i, o, s, c, d, _, b) {
- var k, j;
- o === void 0 && (o = 0),
- c === void 0 && (c = !1),
- b === void 0 && (b = 0),
- this._zOffset = o,
- this._zOffsetUnits = b,
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETSTATE),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(i ? 1 : 0),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(o),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(b),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(!((j = (k = this.cullBackFaces) !== null && k !== void 0 ? k : d) !== null && j !== void 0) || j ? 1 : 0),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(c ? 1 : 0),
- this._commandBufferEncoder.finishEncodingCommand()
- }
- ,
- e.prototype.getInputElementClientRect = function() {
- var i = {
- bottom: this.getRenderHeight(),
- height: this.getRenderHeight(),
- left: 0,
- right: this.getRenderWidth(),
- top: 0,
- width: this.getRenderWidth(),
- x: 0,
- y: 0,
- toJSON: function() {}
- };
- return i
- }
- ,
- e.prototype.setZOffset = function(i) {
- i !== this._zOffset && (this._zOffset = i,
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETZOFFSET),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(this.useReverseDepthBuffer ? -i : i),
- this._commandBufferEncoder.finishEncodingCommand())
- }
- ,
- e.prototype.getZOffset = function() {
- return this._zOffset
- }
- ,
- e.prototype.setZOffsetUnits = function(i) {
- i !== this._zOffsetUnits && (this._zOffsetUnits = i,
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETZOFFSETUNITS),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(this.useReverseDepthBuffer ? -i : i),
- this._commandBufferEncoder.finishEncodingCommand())
- }
- ,
- e.prototype.getZOffsetUnits = function() {
- return this._zOffsetUnits
- }
- ,
- e.prototype.setDepthBuffer = function(i) {
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETDEPTHTEST),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(i ? this._currentDepthTest : _native.Engine.DEPTH_TEST_ALWAYS),
- this._commandBufferEncoder.finishEncodingCommand()
- }
- ,
- e.prototype.getDepthWrite = function() {
- return this._depthWrite
- }
- ,
- e.prototype.getDepthFunction = function() {
- switch (this._currentDepthTest) {
- case _native.Engine.DEPTH_TEST_NEVER:
- return 512;
- case _native.Engine.DEPTH_TEST_ALWAYS:
- return 519;
- case _native.Engine.DEPTH_TEST_GREATER:
- return 516;
- case _native.Engine.DEPTH_TEST_GEQUAL:
- return 518;
- case _native.Engine.DEPTH_TEST_NOTEQUAL:
- return 517;
- case _native.Engine.DEPTH_TEST_EQUAL:
- return 514;
- case _native.Engine.DEPTH_TEST_LESS:
- return 513;
- case _native.Engine.DEPTH_TEST_LEQUAL:
- return 515
- }
- return null
- }
- ,
- e.prototype.setDepthFunction = function(i) {
- var o = 0;
- switch (i) {
- case 512:
- o = _native.Engine.DEPTH_TEST_NEVER;
- break;
- case 519:
- o = _native.Engine.DEPTH_TEST_ALWAYS;
- break;
- case 516:
- o = _native.Engine.DEPTH_TEST_GREATER;
- break;
- case 518:
- o = _native.Engine.DEPTH_TEST_GEQUAL;
- break;
- case 517:
- o = _native.Engine.DEPTH_TEST_NOTEQUAL;
- break;
- case 514:
- o = _native.Engine.DEPTH_TEST_EQUAL;
- break;
- case 513:
- o = _native.Engine.DEPTH_TEST_LESS;
- break;
- case 515:
- o = _native.Engine.DEPTH_TEST_LEQUAL;
- break
- }
- this._currentDepthTest = o,
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETDEPTHTEST),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(this._currentDepthTest),
- this._commandBufferEncoder.finishEncodingCommand()
- }
- ,
- e.prototype.setDepthWrite = function(i) {
- this._depthWrite = i,
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETDEPTHWRITE),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(Number(i)),
- this._commandBufferEncoder.finishEncodingCommand()
- }
- ,
- e.prototype.setColorWrite = function(i) {
- this._colorWrite = i,
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETCOLORWRITE),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(Number(i)),
- this._commandBufferEncoder.finishEncodingCommand()
- }
- ,
- e.prototype.getColorWrite = function() {
- return this._colorWrite
- }
- ,
- e.prototype.applyStencil = function() {
- this._setStencil(this._stencilMask, this._getStencilOpFail(this._stencilOpStencilFail), this._getStencilDepthFail(this._stencilOpDepthFail), this._getStencilDepthPass(this._stencilOpStencilDepthPass), this._getStencilFunc(this._stencilFunc), this._stencilFuncRef)
- }
- ,
- e.prototype._setStencil = function(i, o, s, c, d, _) {
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETSTENCIL),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(i),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(o),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(s),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(c),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(d),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(_),
- this._commandBufferEncoder.finishEncodingCommand()
- }
- ,
- e.prototype.setStencilBuffer = function(i) {
- this._stencilTest = i,
- 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)
- }
- ,
- e.prototype.getStencilBuffer = function() {
- return this._stencilTest
- }
- ,
- e.prototype.getStencilOperationPass = function() {
- return this._stencilOpStencilDepthPass
- }
- ,
- e.prototype.setStencilOperationPass = function(i) {
- this._stencilOpStencilDepthPass = i,
- this.applyStencil()
- }
- ,
- e.prototype.setStencilMask = function(i) {
- this._stencilMask = i,
- this.applyStencil()
- }
- ,
- e.prototype.setStencilFunction = function(i) {
- this._stencilFunc = i,
- this.applyStencil()
- }
- ,
- e.prototype.setStencilFunctionReference = function(i) {
- this._stencilFuncRef = i,
- this.applyStencil()
- }
- ,
- e.prototype.setStencilFunctionMask = function(i) {
- this._stencilFuncMask = i
- }
- ,
- e.prototype.setStencilOperationFail = function(i) {
- this._stencilOpStencilFail = i,
- this.applyStencil()
- }
- ,
- e.prototype.setStencilOperationDepthFail = function(i) {
- this._stencilOpDepthFail = i,
- this.applyStencil()
- }
- ,
- e.prototype.getStencilMask = function() {
- return this._stencilMask
- }
- ,
- e.prototype.getStencilFunction = function() {
- return this._stencilFunc
- }
- ,
- e.prototype.getStencilFunctionReference = function() {
- return this._stencilFuncRef
- }
- ,
- e.prototype.getStencilFunctionMask = function() {
- return this._stencilFuncMask
- }
- ,
- e.prototype.getStencilOperationFail = function() {
- return this._stencilOpStencilFail
- }
- ,
- e.prototype.getStencilOperationDepthFail = function() {
- return this._stencilOpDepthFail
- }
- ,
- e.prototype.setAlphaConstants = function(i, o, s, c) {
- throw new Error("Setting alpha blend constant color not yet implemented.")
- }
- ,
- e.prototype.setAlphaMode = function(i, o) {
- o === void 0 && (o = !1),
- this._alphaMode !== i && (i = this._getNativeAlphaMode(i),
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETBLENDMODE),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(i),
- this._commandBufferEncoder.finishEncodingCommand(),
- o || this.setDepthWrite(i === 0),
- this._alphaMode = i)
- }
- ,
- e.prototype.getAlphaMode = function() {
- return this._alphaMode
- }
- ,
- e.prototype.setInt = function(i, o) {
- return i ? (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETINT),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
- this._commandBufferEncoder.encodeCommandArgAsInt32(o),
- this._commandBufferEncoder.finishEncodingCommand(),
- !0) : !1
- }
- ,
- e.prototype.setIntArray = function(i, o) {
- return i ? (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETINTARRAY),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
- this._commandBufferEncoder.encodeCommandArgAsInt32s(o),
- this._commandBufferEncoder.finishEncodingCommand(),
- !0) : !1
- }
- ,
- e.prototype.setIntArray2 = function(i, o) {
- return i ? (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETINTARRAY2),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
- this._commandBufferEncoder.encodeCommandArgAsInt32s(o),
- this._commandBufferEncoder.finishEncodingCommand(),
- !0) : !1
- }
- ,
- e.prototype.setIntArray3 = function(i, o) {
- return i ? (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETINTARRAY3),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
- this._commandBufferEncoder.encodeCommandArgAsInt32s(o),
- this._commandBufferEncoder.finishEncodingCommand(),
- !0) : !1
- }
- ,
- e.prototype.setIntArray4 = function(i, o) {
- return i ? (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETINTARRAY4),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
- this._commandBufferEncoder.encodeCommandArgAsInt32s(o),
- this._commandBufferEncoder.finishEncodingCommand(),
- !0) : !1
- }
- ,
- e.prototype.setFloatArray = function(i, o) {
- return i ? (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOATARRAY),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
- this._commandBufferEncoder.encodeCommandArgAsFloat32s(o),
- this._commandBufferEncoder.finishEncodingCommand(),
- !0) : !1
- }
- ,
- e.prototype.setFloatArray2 = function(i, o) {
- return i ? (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOATARRAY2),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
- this._commandBufferEncoder.encodeCommandArgAsFloat32s(o),
- this._commandBufferEncoder.finishEncodingCommand(),
- !0) : !1
- }
- ,
- e.prototype.setFloatArray3 = function(i, o) {
- return i ? (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOATARRAY3),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
- this._commandBufferEncoder.encodeCommandArgAsFloat32s(o),
- this._commandBufferEncoder.finishEncodingCommand(),
- !0) : !1
- }
- ,
- e.prototype.setFloatArray4 = function(i, o) {
- return i ? (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOATARRAY4),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
- this._commandBufferEncoder.encodeCommandArgAsFloat32s(o),
- this._commandBufferEncoder.finishEncodingCommand(),
- !0) : !1
- }
- ,
- e.prototype.setArray = function(i, o) {
- return i ? this.setFloatArray(i, new Float32Array(o)) : !1
- }
- ,
- e.prototype.setArray2 = function(i, o) {
- return i ? (this.setFloatArray2(i, new Float32Array(o)),
- !0) : !1
- }
- ,
- e.prototype.setArray3 = function(i, o) {
- return i ? (this.setFloatArray3(i, new Float32Array(o)),
- !0) : !1
- }
- ,
- e.prototype.setArray4 = function(i, o) {
- return i ? (this.setFloatArray4(i, new Float32Array(o)),
- !0) : !1
- }
- ,
- e.prototype.setMatrices = function(i, o) {
- return i ? (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETMATRICES),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
- this._commandBufferEncoder.encodeCommandArgAsFloat32s(o),
- this._commandBufferEncoder.finishEncodingCommand(),
- !0) : !1
- }
- ,
- e.prototype.setMatrix3x3 = function(i, o) {
- return i ? (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETMATRIX3X3),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
- this._commandBufferEncoder.encodeCommandArgAsFloat32s(o),
- this._commandBufferEncoder.finishEncodingCommand(),
- !0) : !1
- }
- ,
- e.prototype.setMatrix2x2 = function(i, o) {
- return i ? (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETMATRIX2X2),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
- this._commandBufferEncoder.encodeCommandArgAsFloat32s(o),
- this._commandBufferEncoder.finishEncodingCommand(),
- !0) : !1
- }
- ,
- e.prototype.setFloat = function(i, o) {
- return i ? (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOAT),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(o),
- this._commandBufferEncoder.finishEncodingCommand(),
- !0) : !1
- }
- ,
- e.prototype.setFloat2 = function(i, o, s) {
- return i ? (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOAT2),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(o),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(s),
- this._commandBufferEncoder.finishEncodingCommand(),
- !0) : !1
- }
- ,
- e.prototype.setFloat3 = function(i, o, s, c) {
- return i ? (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOAT3),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(o),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(s),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(c),
- this._commandBufferEncoder.finishEncodingCommand(),
- !0) : !1
- }
- ,
- e.prototype.setFloat4 = function(i, o, s, c, d) {
- return i ? (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETFLOAT4),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(o),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(s),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(c),
- this._commandBufferEncoder.encodeCommandArgAsFloat32(d),
- this._commandBufferEncoder.finishEncodingCommand(),
- !0) : !1
- }
- ,
- e.prototype.setColor3 = function(i, o) {
- return i ? (this.setFloat3(i, o.r, o.g, o.b),
- !0) : !1
- }
- ,
- e.prototype.setColor4 = function(i, o, s) {
- return i ? (this.setFloat4(i, o.r, o.g, o.b, s),
- !0) : !1
- }
- ,
- e.prototype.wipeCaches = function(i) {
- this.preventCacheWipeBetweenFrames || (this.resetTextureCache(),
- this._currentEffect = null,
- i && (this._currentProgram = null,
- this._stencilStateComposer.reset(),
- this._depthCullingState.reset(),
- this._alphaState.reset()),
- this._cachedVertexBuffers = null,
- this._cachedIndexBuffer = null,
- this._cachedEffectForVertexBuffers = null)
- }
- ,
- e.prototype._createTexture = function() {
- return this._engine.createTexture()
- }
- ,
- e.prototype._deleteTexture = function(i) {
- i && this._engine.deleteTexture(i)
- }
- ,
- e.prototype.updateDynamicTexture = function(i, o, s, c, d) {
- if (!!i && !!i._hardwareTexture) {
- var _ = o.getCanvasTexture()
- , b = i._hardwareTexture.underlyingResource;
- this._engine.copyTexture(b, _),
- i.isReady = !0
- }
- }
- ,
- e.prototype.createDynamicTexture = function(i, o, s, c) {
- return i = Math.max(i, 1),
- o = Math.max(o, 1),
- this.createRawTexture(new Uint8Array(i * o * 4), i, o, 5, !1, !1, c)
- }
- ,
- e.prototype.createVideoElement = function(i) {
- return this._camera ? this._camera.createVideo(i) : null
- }
- ,
- e.prototype.updateVideoTexture = function(i, o, s) {
- if (i && i._hardwareTexture && this._camera) {
- var c = i._hardwareTexture.underlyingResource;
- this._camera.updateVideoTexture(c, o, s)
- }
- }
- ,
- e.prototype.createRawTexture = function(i, o, s, c, d, _, b, k, j) {
- k === void 0 && (k = null),
- j === void 0 && (j = 0);
- var $ = new InternalTexture(this,InternalTextureSource.Raw);
- if ($.format = c,
- $.generateMipMaps = d,
- $.samplingMode = b,
- $.invertY = _,
- $.baseWidth = o,
- $.baseHeight = s,
- $.width = $.baseWidth,
- $.height = $.baseHeight,
- $._compression = k,
- $.type = j,
- this.updateRawTexture($, i, c, _, k, j),
- $._hardwareTexture) {
- var _e = $._hardwareTexture.underlyingResource
- , et = this._getNativeSamplingMode(b);
- this._setTextureSampling(_e, et)
- }
- return this._internalTexturesCache.push($),
- $
- }
- ,
- e.prototype.updateRawTexture = function(i, o, s, c, d, _) {
- if (_ === void 0 && (_ = 0),
- !!i) {
- if (o && i._hardwareTexture) {
- var b = i._hardwareTexture.underlyingResource;
- this._engine.loadRawTexture(b, o, i.width, i.height, this._getNativeTextureFormat(s, _), i.generateMipMaps, i.invertY)
- }
- i.isReady = !0
- }
- }
- ,
- e.prototype.createTexture = function(i, o, s, c, d, _, b, k, j, $, _e, et, tt, rt, it) {
- var nt = this;
- d === void 0 && (d = 3),
- _ === void 0 && (_ = null),
- b === void 0 && (b = null),
- k === void 0 && (k = null),
- j === void 0 && (j = null),
- $ === void 0 && ($ = null),
- _e === void 0 && (_e = null),
- it === void 0 && (it = !1),
- i = i || "";
- var ot = i.substr(0, 5) === "data:"
- , at = ot && i.indexOf(";base64,") !== -1
- , st = j || new InternalTexture(this,InternalTextureSource.Url)
- , ut = i;
- this._transformTextureUrl && !at && !j && !k && (i = this._transformTextureUrl(i));
- for (var ct = i.lastIndexOf("."), lt = _e || (ct > -1 ? i.substring(ct).toLowerCase() : ""), ft = null, ht = 0, pt = Engine._TextureLoaders; ht < pt.length; ht++) {
- var dt = pt[ht];
- if (dt.canLoad(lt)) {
- ft = dt;
- break
- }
- }
- c && c._addPendingData(st),
- st.url = i,
- st.generateMipMaps = !o,
- st.samplingMode = d,
- st.invertY = s,
- st._useSRGBBuffer = this._getUseSRGBBuffer(it, o),
- this.doNotHandleContextLost || (st._buffer = k);
- var _t = null;
- _ && !j && (_t = st.onLoadedObservable.add(_)),
- j || this._internalTexturesCache.push(st);
- var mt = function(yt, Et) {
- c && c._removePendingData(st),
- i === ut ? (_t && st.onLoadedObservable.remove(_t),
- EngineStore.UseFallbackTexture && nt.createTexture(EngineStore.FallbackTexture, o, st.invertY, c, d, null, b, k, st),
- b && b((yt || "Unknown error") + (EngineStore.UseFallbackTexture ? " - Fallback texture was used" : ""), Et)) : (Logger$2.Warn("Failed to load " + i + ", falling back to " + ut),
- nt.createTexture(ut, o, st.invertY, c, d, _, b, k, st, $, _e, et, tt))
- };
- if (ft)
- throw new Error("Loading textures from IInternalTextureLoader not yet implemented.");
- var vt = function(yt) {
- if (!st._hardwareTexture) {
- c && c._removePendingData(st);
- return
- }
- var Et = st._hardwareTexture.underlyingResource;
- nt._engine.loadTexture(Et, yt, !o, s, it, function() {
- st.baseWidth = nt._engine.getTextureWidth(Et),
- st.baseHeight = nt._engine.getTextureHeight(Et),
- st.width = st.baseWidth,
- st.height = st.baseHeight,
- st.isReady = !0;
- var At = nt._getNativeSamplingMode(d);
- nt._setTextureSampling(Et, At),
- c && c._removePendingData(st),
- st.onLoadedObservable.notifyObservers(st),
- st.onLoadedObservable.clear()
- }, function() {
- throw new Error("Could not load a native texture.")
- })
- };
- if (ot && k)
- if (k instanceof ArrayBuffer)
- vt(new Uint8Array(k));
- else if (ArrayBuffer.isView(k))
- vt(k);
- else if (typeof k == "string")
- vt(new Uint8Array(Tools.DecodeBase64(k)));
- else
- throw new Error("Unsupported buffer type");
- else
- at ? vt(new Uint8Array(Tools.DecodeBase64(i))) : this._loadFile(i, function(yt) {
- return vt(new Uint8Array(yt))
- }, void 0, void 0, !0, function(yt, Et) {
- mt("Unable to load " + (yt && yt.responseURL,
- Et))
- });
- return st
- }
- ,
- e.prototype._createDepthStencilTexture = function(i, o, s) {
- var c = s
- , d = new InternalTexture(this,InternalTextureSource.DepthStencil)
- , _ = i.width || i
- , b = i.height || i
- , k = this._engine.createFrameBuffer(d._hardwareTexture.underlyingResource, _, b, _native.Engine.TEXTURE_FORMAT_RGBA8, !1, !0, !1);
- return c._framebufferDepthStencil = k,
- d
- }
- ,
- e.prototype._releaseFramebufferObjects = function(i) {
- i && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEFRAMEBUFFER),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
- this._commandBufferEncoder.finishEncodingCommand())
- }
- ,
- e.prototype.createImageBitmap = function(i, o) {
- var s = this;
- return new Promise(function(c, d) {
- if (Array.isArray(i)) {
- var _ = i;
- if (_.length) {
- var b = s._engine.createImageBitmap(_[0]);
- if (b) {
- c(b);
- return
- }
- }
- }
- d("Unsupported data for createImageBitmap.")
- }
- )
- }
- ,
- e.prototype.resizeImageBitmap = function(i, o, s) {
- return this._engine.resizeImageBitmap(i, o, s)
- }
- ,
- e.prototype.createCubeTexture = function(i, o, s, c, d, _, b, k, j, $, _e, et, tt, rt) {
- var it = this;
- d === void 0 && (d = null),
- _ === void 0 && (_ = null),
- k === void 0 && (k = null),
- $ === void 0 && ($ = 0),
- _e === void 0 && (_e = 0),
- et === void 0 && (et = null),
- rt === void 0 && (rt = !1);
- var nt = et || new InternalTexture(this,InternalTextureSource.Cube);
- nt.isCube = !0,
- nt.url = i,
- nt.generateMipMaps = !c,
- nt._lodGenerationScale = $,
- nt._lodGenerationOffset = _e,
- this._doNotHandleContextLost || (nt._extension = k,
- nt._files = s);
- var ot = i.lastIndexOf(".")
- , at = k || (ot > -1 ? i.substring(ot).toLowerCase() : "");
- if (at === ".env") {
- var st = function(lt) {
- var ft = GetEnvInfo(lt);
- nt.width = ft.width,
- nt.height = ft.width,
- UploadEnvSpherical(nt, ft);
- var ht = ft.specular;
- if (!ht)
- throw new Error("Nothing else parsed so far");
- nt._lodGenerationScale = ht.lodGenerationScale;
- var pt = CreateImageDataArrayBufferViews(lt, ft);
- nt.format = 5,
- nt.type = 0,
- nt.generateMipMaps = !0,
- nt.getEngine().updateTextureSamplingMode(Texture.TRILINEAR_SAMPLINGMODE, nt),
- nt._isRGBD = !0,
- nt.invertY = !0,
- it._engine.loadCubeTextureWithMips(nt._hardwareTexture.underlyingResource, pt, !1, rt, function() {
- nt.isReady = !0,
- d && d()
- }, function() {
- throw new Error("Could not load a native cube texture.")
- })
- };
- if (s && s.length === 6)
- throw new Error("Multi-file loading not allowed on env files.");
- var ut = function(lt, ft) {
- _ && lt && _(lt.status + " " + lt.statusText, ft)
- };
- this._loadFile(i, function(lt) {
- return st(new Uint8Array(lt))
- }, void 0, void 0, !0, ut)
- } else {
- if (!s || s.length !== 6)
- throw new Error("Cannot load cubemap because 6 files were not defined");
- var ct = [s[0], s[3], s[1], s[4], s[2], s[5]];
- Promise.all(ct.map(function(lt) {
- return Tools.LoadFileAsync(lt).then(function(ft) {
- return new Uint8Array(ft)
- })
- })).then(function(lt) {
- return new Promise(function(ft, ht) {
- it._engine.loadCubeTexture(nt._hardwareTexture.underlyingResource, lt, !c, !0, rt, ft, ht)
- }
- )
- }).then(function() {
- nt.isReady = !0,
- d && d()
- }, function(lt) {
- _ && _("Failed to load cubemap: " + lt.message, lt)
- })
- }
- return this._internalTexturesCache.push(nt),
- nt
- }
- ,
- e.prototype._createHardwareRenderTargetWrapper = function(i, o, s) {
- var c = new NativeRenderTargetWrapper(i,o,s,this);
- return this._renderTargetWrapperCache.push(c),
- c
- }
- ,
- e.prototype.createRenderTargetTexture = function(i, o) {
- var s = this._createHardwareRenderTargetWrapper(!1, !1, i)
- , c = {};
- o !== void 0 && typeof o == "object" ? (c.generateMipMaps = o.generateMipMaps,
- c.generateDepthBuffer = o.generateDepthBuffer === void 0 ? !0 : o.generateDepthBuffer,
- c.generateStencilBuffer = c.generateDepthBuffer && o.generateStencilBuffer,
- c.type = o.type === void 0 ? 0 : o.type,
- c.samplingMode = o.samplingMode === void 0 ? 3 : o.samplingMode,
- c.format = o.format === void 0 ? 5 : o.format) : (c.generateMipMaps = o,
- c.generateDepthBuffer = !0,
- c.generateStencilBuffer = !1,
- c.type = 0,
- c.samplingMode = 3,
- c.format = 5),
- (c.type === 1 && !this._caps.textureFloatLinearFiltering || c.type === 2 && !this._caps.textureHalfFloatLinearFiltering) && (c.samplingMode = 1);
- var d = new InternalTexture(this,InternalTextureSource.RenderTarget)
- , _ = i.width || i
- , b = i.height || i;
- c.type === 1 && !this._caps.textureFloat && (c.type = 0,
- Logger$2.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type"));
- var k = this._engine.createFrameBuffer(d._hardwareTexture.underlyingResource, _, b, this._getNativeTextureFormat(c.format, c.type), !!c.generateStencilBuffer, c.generateDepthBuffer, !!c.generateMipMaps);
- return s._framebuffer = k,
- s._generateDepthBuffer = c.generateDepthBuffer,
- s._generateStencilBuffer = !!c.generateStencilBuffer,
- d.baseWidth = _,
- d.baseHeight = b,
- d.width = _,
- d.height = b,
- d.isReady = !0,
- d.samples = 1,
- d.generateMipMaps = !!c.generateMipMaps,
- d.samplingMode = c.samplingMode,
- d.type = c.type,
- d.format = c.format,
- this._internalTexturesCache.push(d),
- s.setTextures(d),
- s
- }
- ,
- e.prototype.updateTextureSamplingMode = function(i, o) {
- if (o._hardwareTexture) {
- var s = this._getNativeSamplingMode(i);
- this._setTextureSampling(o._hardwareTexture.underlyingResource, s)
- }
- o.samplingMode = i
- }
- ,
- e.prototype.bindFramebuffer = function(i, o, s, c, d) {
- var _ = i;
- if (o)
- throw new Error("Cuboid frame buffers are not yet supported in NativeEngine.");
- if (s || c)
- throw new Error("Required width/height for frame buffers not yet supported in NativeEngine.");
- _._framebufferDepthStencil ? this._bindUnboundFramebuffer(_._framebufferDepthStencil) : this._bindUnboundFramebuffer(_._framebuffer)
- }
- ,
- e.prototype.unBindFramebuffer = function(i, o, s) {
- s && s(),
- this._bindUnboundFramebuffer(null)
- }
- ,
- e.prototype.createDynamicVertexBuffer = function(i) {
- return this.createVertexBuffer(i, !0)
- }
- ,
- e.prototype.updateDynamicIndexBuffer = function(i, o, s) {
- s === void 0 && (s = 0);
- var c = i
- , d = this._normalizeIndexData(o);
- c.is32Bits = d.BYTES_PER_ELEMENT === 4,
- this._engine.updateDynamicIndexBuffer(c.nativeIndexBuffer, d.buffer, d.byteOffset, d.byteLength, s)
- }
- ,
- e.prototype.updateDynamicVertexBuffer = function(i, o, s, c) {
- var d = i
- , _ = ArrayBuffer.isView(o) ? o : new Float32Array(o);
- this._engine.updateDynamicVertexBuffer(d.nativeVertexBuffer, _.buffer, _.byteOffset + (s != null ? s : 0), c != null ? c : _.byteLength)
- }
- ,
- e.prototype._setTexture = function(i, o, s, c) {
- c === void 0 && (c = !1);
- var d = this._boundUniforms[i];
- if (!d)
- return !1;
- if (!o)
- return this._boundTexturesCache[i] != null && (this._activeChannel = i,
- this._setTextureCore(d, null)),
- !1;
- if (o.video)
- this._activeChannel = i,
- o.update();
- else if (o.delayLoadState === 4)
- return o.delayLoad(),
- !1;
- var _;
- return c ? _ = o.depthStencilTexture : o.isReady() ? _ = o.getInternalTexture() : o.isCube ? _ = this.emptyCubeTexture : o.is3D ? _ = this.emptyTexture3D : o.is2DArray ? _ = this.emptyTexture2DArray : _ = this.emptyTexture,
- this._activeChannel = i,
- !_ || !_._hardwareTexture ? !1 : (this._setTextureWrapMode(_._hardwareTexture.underlyingResource, this._getAddressMode(o.wrapU), this._getAddressMode(o.wrapV), this._getAddressMode(o.wrapR)),
- this._updateAnisotropicLevel(o),
- this._setTextureCore(d, _._hardwareTexture.underlyingResource),
- !0)
- }
- ,
- e.prototype._setTextureSampling = function(i, o) {
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETTEXTURESAMPLING),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(o),
- this._commandBufferEncoder.finishEncodingCommand()
- }
- ,
- e.prototype._setTextureWrapMode = function(i, o, s, c) {
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETTEXTUREWRAPMODE),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(o),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(s),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(c),
- this._commandBufferEncoder.finishEncodingCommand()
- }
- ,
- e.prototype._setTextureCore = function(i, o) {
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETTEXTURE),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(i),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(o),
- this._commandBufferEncoder.finishEncodingCommand()
- }
- ,
- e.prototype._updateAnisotropicLevel = function(i) {
- var o = i.getInternalTexture()
- , s = i.anisotropicFilteringLevel;
- !o || !o._hardwareTexture || o._cachedAnisotropicFilteringLevel !== s && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETTEXTUREANISOTROPICLEVEL),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(o._hardwareTexture.underlyingResource),
- this._commandBufferEncoder.encodeCommandArgAsUInt32(s),
- this._commandBufferEncoder.finishEncodingCommand(),
- o._cachedAnisotropicFilteringLevel = s)
- }
- ,
- e.prototype._getAddressMode = function(i) {
- switch (i) {
- case 1:
- return _native.Engine.ADDRESS_MODE_WRAP;
- case 0:
- return _native.Engine.ADDRESS_MODE_CLAMP;
- case 2:
- return _native.Engine.ADDRESS_MODE_MIRROR;
- default:
- throw new Error("Unexpected wrap mode: " + i + ".")
- }
- }
- ,
- e.prototype._bindTexture = function(i, o) {
- var s = this._boundUniforms[i];
- if (!!s && o && o._hardwareTexture) {
- var c = o._hardwareTexture.underlyingResource;
- this._setTextureCore(s, c)
- }
- }
- ,
- e.prototype._deleteBuffer = function(i) {
- i.nativeIndexBuffer && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEINDEXBUFFER),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(i.nativeIndexBuffer),
- this._commandBufferEncoder.finishEncodingCommand(),
- delete i.nativeIndexBuffer),
- i.nativeVertexBuffer && (this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEVERTEXBUFFER),
- this._commandBufferEncoder.encodeCommandArgAsNativeData(i.nativeVertexBuffer),
- this._commandBufferEncoder.finishEncodingCommand(),
- delete i.nativeVertexBuffer)
- }
- ,
- e.prototype.createCanvas = function(i, o) {
- if (!_native.Canvas)
- throw new Error("Native Canvas plugin not available.");
- var s = new _native.Canvas;
- return s.width = i,
- s.height = o,
- s
- }
- ,
- e.prototype.createCanvasImage = function() {
- if (!_native.Canvas)
- throw new Error("Native Canvas plugin not available.");
- var i = new _native.Image;
- return i
- }
- ,
- e.prototype._uploadCompressedDataToTextureDirectly = function(i, o, s, c, d, _, b) {
- throw new Error("_uploadCompressedDataToTextureDirectly not implemented.")
- }
- ,
- e.prototype._uploadDataToTextureDirectly = function(i, o, s, c) {
- throw new Error("_uploadDataToTextureDirectly not implemented.")
- }
- ,
- e.prototype._uploadArrayBufferViewToTexture = function(i, o, s, c) {
- throw new Error("_uploadArrayBufferViewToTexture not implemented.")
- }
- ,
- e.prototype._uploadImageToTexture = function(i, o, s, c) {
- throw new Error("_uploadArrayBufferViewToTexture not implemented.")
- }
- ,
- e.prototype._getNativeSamplingMode = function(i) {
- switch (i) {
- case 1:
- return _native.Engine.TEXTURE_NEAREST_NEAREST;
- case 2:
- return _native.Engine.TEXTURE_LINEAR_LINEAR;
- case 3:
- return _native.Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR;
- case 4:
- return _native.Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST;
- case 5:
- return _native.Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST;
- case 6:
- return _native.Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR;
- case 7:
- return _native.Engine.TEXTURE_NEAREST_LINEAR;
- case 8:
- return _native.Engine.TEXTURE_NEAREST_NEAREST_MIPLINEAR;
- case 9:
- return _native.Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST;
- case 10:
- return _native.Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR;
- case 11:
- return _native.Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST;
- case 12:
- return _native.Engine.TEXTURE_LINEAR_NEAREST;
- default:
- throw new Error("Unsupported sampling mode: " + i + ".")
- }
- }
- ,
- e.prototype._getStencilFunc = function(i) {
- switch (i) {
- case 513:
- return _native.Engine.STENCIL_TEST_LESS;
- case 515:
- return _native.Engine.STENCIL_TEST_LEQUAL;
- case 514:
- return _native.Engine.STENCIL_TEST_EQUAL;
- case 518:
- return _native.Engine.STENCIL_TEST_GEQUAL;
- case 516:
- return _native.Engine.STENCIL_TEST_GREATER;
- case 517:
- return _native.Engine.STENCIL_TEST_NOTEQUAL;
- case 512:
- return _native.Engine.STENCIL_TEST_NEVER;
- case 519:
- return _native.Engine.STENCIL_TEST_ALWAYS;
- default:
- throw new Error("Unsupported stencil func mode: " + i + ".")
- }
- }
- ,
- e.prototype._getStencilOpFail = function(i) {
- switch (i) {
- case 7680:
- return _native.Engine.STENCIL_OP_FAIL_S_KEEP;
- case 0:
- return _native.Engine.STENCIL_OP_FAIL_S_ZERO;
- case 7681:
- return _native.Engine.STENCIL_OP_FAIL_S_REPLACE;
- case 7682:
- return _native.Engine.STENCIL_OP_FAIL_S_INCR;
- case 7683:
- return _native.Engine.STENCIL_OP_FAIL_S_DECR;
- case 5386:
- return _native.Engine.STENCIL_OP_FAIL_S_INVERT;
- case 34055:
- return _native.Engine.STENCIL_OP_FAIL_S_INCRSAT;
- case 34056:
- return _native.Engine.STENCIL_OP_FAIL_S_DECRSAT;
- default:
- throw new Error("Unsupported stencil OpFail mode: " + i + ".")
- }
- }
- ,
- e.prototype._getStencilDepthFail = function(i) {
- switch (i) {
- case 7680:
- return _native.Engine.STENCIL_OP_FAIL_Z_KEEP;
- case 0:
- return _native.Engine.STENCIL_OP_FAIL_Z_ZERO;
- case 7681:
- return _native.Engine.STENCIL_OP_FAIL_Z_REPLACE;
- case 7682:
- return _native.Engine.STENCIL_OP_FAIL_Z_INCR;
- case 7683:
- return _native.Engine.STENCIL_OP_FAIL_Z_DECR;
- case 5386:
- return _native.Engine.STENCIL_OP_FAIL_Z_INVERT;
- case 34055:
- return _native.Engine.STENCIL_OP_FAIL_Z_INCRSAT;
- case 34056:
- return _native.Engine.STENCIL_OP_FAIL_Z_DECRSAT;
- default:
- throw new Error("Unsupported stencil depthFail mode: " + i + ".")
- }
- }
- ,
- e.prototype._getStencilDepthPass = function(i) {
- switch (i) {
- case 7680:
- return _native.Engine.STENCIL_OP_PASS_Z_KEEP;
- case 0:
- return _native.Engine.STENCIL_OP_PASS_Z_ZERO;
- case 7681:
- return _native.Engine.STENCIL_OP_PASS_Z_REPLACE;
- case 7682:
- return _native.Engine.STENCIL_OP_PASS_Z_INCR;
- case 7683:
- return _native.Engine.STENCIL_OP_PASS_Z_DECR;
- case 5386:
- return _native.Engine.STENCIL_OP_PASS_Z_INVERT;
- case 34055:
- return _native.Engine.STENCIL_OP_PASS_Z_INCRSAT;
- case 34056:
- return _native.Engine.STENCIL_OP_PASS_Z_DECRSAT;
- default:
- throw new Error("Unsupported stencil opPass mode: " + i + ".")
- }
- }
- ,
- e.prototype._getNativeTextureFormat = function(i, o) {
- if (i == 4 && o == 0)
- return _native.Engine.TEXTURE_FORMAT_RGB8;
- if (i == 5 && o == 0)
- return _native.Engine.TEXTURE_FORMAT_RGBA8;
- if (i == 5 && o == 1)
- return _native.Engine.TEXTURE_FORMAT_RGBA32F;
- throw new Error("Unsupported texture format or type: format " + i + ", type " + o + ".")
- }
- ,
- e.prototype._getNativeAlphaMode = function(i) {
- switch (i) {
- case 0:
- return _native.Engine.ALPHA_DISABLE;
- case 1:
- return _native.Engine.ALPHA_ADD;
- case 2:
- return _native.Engine.ALPHA_COMBINE;
- case 3:
- return _native.Engine.ALPHA_SUBTRACT;
- case 4:
- return _native.Engine.ALPHA_MULTIPLY;
- case 5:
- return _native.Engine.ALPHA_MAXIMIZED;
- case 6:
- return _native.Engine.ALPHA_ONEONE;
- case 7:
- return _native.Engine.ALPHA_PREMULTIPLIED;
- case 8:
- return _native.Engine.ALPHA_PREMULTIPLIED_PORTERDUFF;
- case 9:
- return _native.Engine.ALPHA_INTERPOLATE;
- case 10:
- return _native.Engine.ALPHA_SCREENMODE;
- default:
- throw new Error("Unsupported alpha mode: " + i + ".")
- }
- }
- ,
- e.prototype._getNativeAttribType = function(i) {
- switch (i) {
- case VertexBuffer.BYTE:
- return _native.Engine.ATTRIB_TYPE_INT8;
- case VertexBuffer.UNSIGNED_BYTE:
- return _native.Engine.ATTRIB_TYPE_UINT8;
- case VertexBuffer.SHORT:
- return _native.Engine.ATTRIB_TYPE_INT16;
- case VertexBuffer.UNSIGNED_SHORT:
- return _native.Engine.ATTRIB_TYPE_UINT16;
- case VertexBuffer.FLOAT:
- return _native.Engine.ATTRIB_TYPE_FLOAT;
- default:
- throw new Error("Unsupported attribute type: " + i + ".")
- }
- }
- ,
- e.prototype.getFontOffset = function(i) {
- var o = {
- ascent: 0,
- height: 0,
- descent: 0
- };
- return o
- }
- ,
- e.PROTOCOL_VERSION = 2,
- e
- }(Engine);
- NativeEngine._createNativeDataStream = function() {
- return _native.NativeDataStream.VALIDATION_ENABLED ? new ValidatedNativeDataStream : new NativeDataStream
- }
- ;
- var ValidatedNativeDataStream = function(a) {
- __extends(e, a);
- function e() {
- return a.call(this) || this
- }
- return e.prototype.writeUint32 = function(i) {
- a.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_UINT_32),
- a.prototype.writeUint32.call(this, i)
- }
- ,
- e.prototype.writeInt32 = function(i) {
- a.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_INT_32),
- a.prototype.writeInt32.call(this, i)
- }
- ,
- e.prototype.writeFloat32 = function(i) {
- a.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_FLOAT_32),
- a.prototype.writeFloat32.call(this, i)
- }
- ,
- e.prototype.writeUint32Array = function(i) {
- a.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_UINT_32_ARRAY),
- a.prototype.writeUint32Array.call(this, i)
- }
- ,
- e.prototype.writeInt32Array = function(i) {
- a.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_INT_32_ARRAY),
- a.prototype.writeInt32Array.call(this, i)
- }
- ,
- e.prototype.writeFloat32Array = function(i) {
- a.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_FLOAT_32_ARRAY),
- a.prototype.writeFloat32Array.call(this, i)
- }
- ,
- e.prototype.writeNativeData = function(i) {
- a.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_NATIVE_DATA),
- a.prototype.writeNativeData.call(this, i)
- }
- ,
- e.prototype.writeBoolean = function(i) {
- a.prototype.writeUint32.call(this, _native.NativeDataStream.VALIDATION_BOOLEAN),
- a.prototype.writeBoolean.call(this, i)
- }
- ,
- e
- }(NativeDataStream), PowerPreference;
- (function(a) {
- a.SRGB = "srgb"
- }
- )(PowerPreference || (PowerPreference = {}));
- (function(a) {
- a.LowPower = "low-power",
- a.HighPerformance = "high-performance"
- }
- )(PowerPreference || (PowerPreference = {}));
- var FeatureName;
- (function(a) {
- a.DepthClipControl = "depth-clip-control",
- a.Depth24UnormStencil8 = "depth24unorm-stencil8",
- a.Depth32FloatStencil8 = "depth32float-stencil8",
- a.TextureCompressionBC = "texture-compression-bc",
- a.TextureCompressionETC2 = "texture-compression-etc2",
- a.TextureCompressionASTC = "texture-compression-astc",
- a.TimestampQuery = "timestamp-query",
- a.IndirectFirstInstance = "indirect-first-instance"
- }
- )(FeatureName || (FeatureName = {}));
- var BufferUsage;
- (function(a) {
- a[a.MapRead = 1] = "MapRead",
- a[a.MapWrite = 2] = "MapWrite",
- a[a.CopySrc = 4] = "CopySrc",
- a[a.CopyDst = 8] = "CopyDst",
- a[a.Index = 16] = "Index",
- a[a.Vertex = 32] = "Vertex",
- a[a.Uniform = 64] = "Uniform",
- a[a.Storage = 128] = "Storage",
- a[a.Indirect = 256] = "Indirect",
- a[a.QueryResolve = 512] = "QueryResolve"
- }
- )(BufferUsage || (BufferUsage = {}));
- var MapMode;
- (function(a) {
- a[a.Read = 1] = "Read",
- a[a.Write = 2] = "Write"
- }
- )(MapMode || (MapMode = {}));
- var TextureDimension;
- (function(a) {
- a.E1d = "1d",
- a.E2d = "2d",
- a.E3d = "3d"
- }
- )(TextureDimension || (TextureDimension = {}));
- var TextureUsage;
- (function(a) {
- a[a.CopySrc = 1] = "CopySrc",
- a[a.CopyDst = 2] = "CopyDst",
- a[a.TextureBinding = 4] = "TextureBinding",
- a[a.StorageBinding = 8] = "StorageBinding",
- a[a.RenderAttachment = 16] = "RenderAttachment"
- }
- )(TextureUsage || (TextureUsage = {}));
- var TextureViewDimension;
- (function(a) {
- a.E1d = "1d",
- a.E2d = "2d",
- a.E2dArray = "2d-array",
- a.Cube = "cube",
- a.CubeArray = "cube-array",
- a.E3d = "3d"
- }
- )(TextureViewDimension || (TextureViewDimension = {}));
- var TextureAspect;
- (function(a) {
- a.All = "all",
- a.StencilOnly = "stencil-only",
- a.DepthOnly = "depth-only"
- }
- )(TextureAspect || (TextureAspect = {}));
- var TextureFormat;
- (function(a) {
- a.R8Unorm = "r8unorm",
- a.R8Snorm = "r8snorm",
- a.R8Uint = "r8uint",
- a.R8Sint = "r8sint",
- a.R16Uint = "r16uint",
- a.R16Sint = "r16sint",
- a.R16Float = "r16float",
- a.RG8Unorm = "rg8unorm",
- a.RG8Snorm = "rg8snorm",
- a.RG8Uint = "rg8uint",
- a.RG8Sint = "rg8sint",
- a.R32Uint = "r32uint",
- a.R32Sint = "r32sint",
- a.R32Float = "r32float",
- a.RG16Uint = "rg16uint",
- a.RG16Sint = "rg16sint",
- a.RG16Float = "rg16float",
- a.RGBA8Unorm = "rgba8unorm",
- a.RGBA8UnormSRGB = "rgba8unorm-srgb",
- a.RGBA8Snorm = "rgba8snorm",
- a.RGBA8Uint = "rgba8uint",
- a.RGBA8Sint = "rgba8sint",
- a.BGRA8Unorm = "bgra8unorm",
- a.BGRA8UnormSRGB = "bgra8unorm-srgb",
- a.RGB9E5UFloat = "rgb9e5ufloat",
- a.RGB10A2Unorm = "rgb10a2unorm",
- a.RG11B10UFloat = "rg11b10ufloat",
- a.RG32Uint = "rg32uint",
- a.RG32Sint = "rg32sint",
- a.RG32Float = "rg32float",
- a.RGBA16Uint = "rgba16uint",
- a.RGBA16Sint = "rgba16sint",
- a.RGBA16Float = "rgba16float",
- a.RGBA32Uint = "rgba32uint",
- a.RGBA32Sint = "rgba32sint",
- a.RGBA32Float = "rgba32float",
- a.Stencil8 = "stencil8",
- a.Depth16Unorm = "depth16unorm",
- a.Depth24Plus = "depth24plus",
- a.Depth24PlusStencil8 = "depth24plus-stencil8",
- a.Depth32Float = "depth32float",
- a.BC1RGBAUnorm = "bc1-rgba-unorm",
- a.BC1RGBAUnormSRGB = "bc1-rgba-unorm-srgb",
- a.BC2RGBAUnorm = "bc2-rgba-unorm",
- a.BC2RGBAUnormSRGB = "bc2-rgba-unorm-srgb",
- a.BC3RGBAUnorm = "bc3-rgba-unorm",
- a.BC3RGBAUnormSRGB = "bc3-rgba-unorm-srgb",
- a.BC4RUnorm = "bc4-r-unorm",
- a.BC4RSnorm = "bc4-r-snorm",
- a.BC5RGUnorm = "bc5-rg-unorm",
- a.BC5RGSnorm = "bc5-rg-snorm",
- a.BC6HRGBUFloat = "bc6h-rgb-ufloat",
- a.BC6HRGBFloat = "bc6h-rgb-float",
- a.BC7RGBAUnorm = "bc7-rgba-unorm",
- a.BC7RGBAUnormSRGB = "bc7-rgba-unorm-srgb",
- a.ETC2RGB8Unorm = "etc2-rgb8unorm",
- a.ETC2RGB8UnormSRGB = "etc2-rgb8unorm-srgb",
- a.ETC2RGB8A1Unorm = "etc2-rgb8a1unorm",
- a.ETC2RGB8A1UnormSRGB = "etc2-rgb8a1unorm-srgb",
- a.ETC2RGBA8Unorm = "etc2-rgba8unorm",
- a.ETC2RGBA8UnormSRGB = "etc2-rgba8unorm-srgb",
- a.EACR11Unorm = "eac-r11unorm",
- a.EACR11Snorm = "eac-r11snorm",
- a.EACRG11Unorm = "eac-rg11unorm",
- a.EACRG11Snorm = "eac-rg11snorm",
- a.ASTC4x4Unorm = "astc-4x4-unorm",
- a.ASTC4x4UnormSRGB = "astc-4x4-unorm-srgb",
- a.ASTC5x4Unorm = "astc-5x4-unorm",
- a.ASTC5x4UnormSRGB = "astc-5x4-unorm-srgb",
- a.ASTC5x5Unorm = "astc-5x5-unorm",
- a.ASTC5x5UnormSRGB = "astc-5x5-unorm-srgb",
- a.ASTC6x5Unorm = "astc-6x5-unorm",
- a.ASTC6x5UnormSRGB = "astc-6x5-unorm-srgb",
- a.ASTC6x6Unorm = "astc-6x6-unorm",
- a.ASTC6x6UnormSRGB = "astc-6x6-unorm-srgb",
- a.ASTC8x5Unorm = "astc-8x5-unorm",
- a.ASTC8x5UnormSRGB = "astc-8x5-unorm-srgb",
- a.ASTC8x6Unorm = "astc-8x6-unorm",
- a.ASTC8x6UnormSRGB = "astc-8x6-unorm-srgb",
- a.ASTC8x8Unorm = "astc-8x8-unorm",
- a.ASTC8x8UnormSRGB = "astc-8x8-unorm-srgb",
- a.ASTC10x5Unorm = "astc-10x5-unorm",
- a.ASTC10x5UnormSRGB = "astc-10x5-unorm-srgb",
- a.ASTC10x6Unorm = "astc-10x6-unorm",
- a.ASTC10x6UnormSRGB = "astc-10x6-unorm-srgb",
- a.ASTC10x8Unorm = "astc-10x8-unorm",
- a.ASTC10x8UnormSRGB = "astc-10x8-unorm-srgb",
- a.ASTC10x10Unorm = "astc-10x10-unorm",
- a.ASTC10x10UnormSRGB = "astc-10x10-unorm-srgb",
- a.ASTC12x10Unorm = "astc-12x10-unorm",
- a.ASTC12x10UnormSRGB = "astc-12x10-unorm-srgb",
- a.ASTC12x12Unorm = "astc-12x12-unorm",
- a.ASTC12x12UnormSRGB = "astc-12x12-unorm-srgb",
- a.Depth24UnormStencil8 = "depth24unorm-stencil8",
- a.Depth32FloatStencil8 = "depth32float-stencil8"
- }
- )(TextureFormat || (TextureFormat = {}));
- var AddressMode;
- (function(a) {
- a.ClampToEdge = "clamp-to-edge",
- a.Repeat = "repeat",
- a.MirrorRepeat = "mirror-repeat"
- }
- )(AddressMode || (AddressMode = {}));
- var FilterMode;
- (function(a) {
- a.Nearest = "nearest",
- a.Linear = "linear"
- }
- )(FilterMode || (FilterMode = {}));
- var CompareFunction;
- (function(a) {
- a.Never = "never",
- a.Less = "less",
- a.Equal = "equal",
- a.LessEqual = "less-equal",
- a.Greater = "greater",
- a.NotEqual = "not-equal",
- a.GreaterEqual = "greater-equal",
- a.Always = "always"
- }
- )(CompareFunction || (CompareFunction = {}));
- var ShaderStage;
- (function(a) {
- a[a.Vertex = 1] = "Vertex",
- a[a.Fragment = 2] = "Fragment",
- a[a.Compute = 4] = "Compute"
- }
- )(ShaderStage || (ShaderStage = {}));
- var BufferBindingType;
- (function(a) {
- a.Uniform = "uniform",
- a.Storage = "storage",
- a.ReadOnlyStorage = "read-only-storage"
- }
- )(BufferBindingType || (BufferBindingType = {}));
- var SamplerBindingType;
- (function(a) {
- a.Filtering = "filtering",
- a.NonFiltering = "non-filtering",
- a.Comparison = "comparison"
- }
- )(SamplerBindingType || (SamplerBindingType = {}));
- var TextureSampleType;
- (function(a) {
- a.Float = "float",
- a.UnfilterableFloat = "unfilterable-float",
- a.Depth = "depth",
- a.Sint = "sint",
- a.Uint = "uint"
- }
- )(TextureSampleType || (TextureSampleType = {}));
- var StorageTextureAccess;
- (function(a) {
- a.WriteOnly = "write-only"
- }
- )(StorageTextureAccess || (StorageTextureAccess = {}));
- var CompilationMessageType;
- (function(a) {
- a.Error = "error",
- a.Warning = "warning",
- a.Info = "info"
- }
- )(CompilationMessageType || (CompilationMessageType = {}));
- var PrimitiveTopology;
- (function(a) {
- a.PointList = "point-list",
- a.LineList = "line-list",
- a.LineStrip = "line-strip",
- a.TriangleList = "triangle-list",
- a.TriangleStrip = "triangle-strip"
- }
- )(PrimitiveTopology || (PrimitiveTopology = {}));
- var FrontFace;
- (function(a) {
- a.CCW = "ccw",
- a.CW = "cw"
- }
- )(FrontFace || (FrontFace = {}));
- var CullMode;
- (function(a) {
- a.None = "none",
- a.Front = "front",
- a.Back = "back"
- }
- )(CullMode || (CullMode = {}));
- var ColorWrite;
- (function(a) {
- a[a.Red = 1] = "Red",
- a[a.Green = 2] = "Green",
- a[a.Blue = 4] = "Blue",
- a[a.Alpha = 8] = "Alpha",
- a[a.All = 15] = "All"
- }
- )(ColorWrite || (ColorWrite = {}));
- var BlendFactor;
- (function(a) {
- a.Zero = "zero",
- a.One = "one",
- a.Src = "src",
- a.OneMinusSrc = "one-minus-src",
- a.SrcAlpha = "src-alpha",
- a.OneMinusSrcAlpha = "one-minus-src-alpha",
- a.Dst = "dst",
- a.OneMinusDst = "one-minus-dst",
- a.DstAlpha = "dst-alpha",
- a.OneMinusDstAlpha = "one-minus-dst-alpha",
- a.SrcAlphaSaturated = "src-alpha-saturated",
- a.Constant = "constant",
- a.OneMinusConstant = "one-minus-constant"
- }
- )(BlendFactor || (BlendFactor = {}));
- var BlendOperation;
- (function(a) {
- a.Add = "add",
- a.Subtract = "subtract",
- a.ReverseSubtract = "reverse-subtract",
- a.Min = "min",
- a.Max = "max"
- }
- )(BlendOperation || (BlendOperation = {}));
- var StencilOperation;
- (function(a) {
- a.Keep = "keep",
- a.Zero = "zero",
- a.Replace = "replace",
- a.Invert = "invert",
- a.IncrementClamp = "increment-clamp",
- a.DecrementClamp = "decrement-clamp",
- a.IncrementWrap = "increment-wrap",
- a.DecrementWrap = "decrement-wrap"
- }
- )(StencilOperation || (StencilOperation = {}));
- var IndexFormat;
- (function(a) {
- a.Uint16 = "uint16",
- a.Uint32 = "uint32"
- }
- )(IndexFormat || (IndexFormat = {}));
- var VertexFormat;
- (function(a) {
- a.Uint8x2 = "uint8x2",
- a.Uint8x4 = "uint8x4",
- a.Sint8x2 = "sint8x2",
- a.Sint8x4 = "sint8x4",
- a.Unorm8x2 = "unorm8x2",
- a.Unorm8x4 = "unorm8x4",
- a.Snorm8x2 = "snorm8x2",
- a.Snorm8x4 = "snorm8x4",
- a.Uint16x2 = "uint16x2",
- a.Uint16x4 = "uint16x4",
- a.Sint16x2 = "sint16x2",
- a.Sint16x4 = "sint16x4",
- a.Unorm16x2 = "unorm16x2",
- a.Unorm16x4 = "unorm16x4",
- a.Snorm16x2 = "snorm16x2",
- a.Snorm16x4 = "snorm16x4",
- a.Float16x2 = "float16x2",
- a.Float16x4 = "float16x4",
- a.Float32 = "float32",
- a.Float32x2 = "float32x2",
- a.Float32x3 = "float32x3",
- a.Float32x4 = "float32x4",
- a.Uint32 = "uint32",
- a.Uint32x2 = "uint32x2",
- a.Uint32x3 = "uint32x3",
- a.Uint32x4 = "uint32x4",
- a.Sint32 = "sint32",
- a.Sint32x2 = "sint32x2",
- a.Sint32x3 = "sint32x3",
- a.Sint32x4 = "sint32x4"
- }
- )(VertexFormat || (VertexFormat = {}));
- var InputStepMode;
- (function(a) {
- a.Vertex = "vertex",
- a.Instance = "instance"
- }
- )(InputStepMode || (InputStepMode = {}));
- var ComputePassTimestampLocation;
- (function(a) {
- a.Beginning = "beginning",
- a.End = "end"
- }
- )(ComputePassTimestampLocation || (ComputePassTimestampLocation = {}));
- var RenderPassTimestampLocation;
- (function(a) {
- a.Beginning = "beginning",
- a.End = "end"
- }
- )(RenderPassTimestampLocation || (RenderPassTimestampLocation = {}));
- var LoadOp;
- (function(a) {
- a.Load = "load"
- }
- )(LoadOp || (LoadOp = {}));
- var StoreOp;
- (function(a) {
- a.Store = "store",
- a.Discard = "discard"
- }
- )(StoreOp || (StoreOp = {}));
- var QueryType;
- (function(a) {
- a.Occlusion = "occlusion",
- a.Timestamp = "timestamp"
- }
- )(QueryType || (QueryType = {}));
- var CanvasCompositingAlphaMode;
- (function(a) {
- a.Opaque = "opaque",
- a.Premultiplied = "premultiplied"
- }
- )(CanvasCompositingAlphaMode || (CanvasCompositingAlphaMode = {}));
- var DeviceLostReason;
- (function(a) {
- a.Destroyed = "destroyed"
- }
- )(DeviceLostReason || (DeviceLostReason = {}));
- var ErrorFilter;
- (function(a) {
- a.OutOfMemory = "out-of-memory",
- a.Validation = "validation"
- }
- )(ErrorFilter || (ErrorFilter = {}));
- var WebGPUShaderProcessor = function() {
- function a() {
- this.shaderLanguage = ShaderLanguage.GLSL
- }
- return a.prototype._addUniformToLeftOverUBO = function(e, i, o) {
- var s, c = 0;
- s = this._getArraySize(e, i, o),
- e = s[0],
- i = s[1],
- c = s[2];
- for (var d = 0; d < this.webgpuProcessingContext.leftOverUniforms.length; d++)
- if (this.webgpuProcessingContext.leftOverUniforms[d].name === e)
- return;
- this.webgpuProcessingContext.leftOverUniforms.push({
- name: e,
- type: i,
- length: c
- })
- }
- ,
- a.prototype._buildLeftOverUBO = function() {
- if (!this.webgpuProcessingContext.leftOverUniforms.length)
- return "";
- var e = a.LeftOvertUBOName
- , i = this.webgpuProcessingContext.availableBuffers[e];
- return i || (i = {
- binding: this.webgpuProcessingContext.getNextFreeUBOBinding()
- },
- this.webgpuProcessingContext.availableBuffers[e] = i,
- this._addBufferBindingDescription(e, i, BufferBindingType.Uniform, !0),
- this._addBufferBindingDescription(e, i, BufferBindingType.Uniform, !1)),
- this._generateLeftOverUBOCode(e, i)
- }
- ,
- a.prototype._collectBindingNames = function() {
- for (var e = 0; e < this.webgpuProcessingContext.bindGroupLayoutEntries.length; e++) {
- var i = this.webgpuProcessingContext.bindGroupLayoutEntries[e];
- if (i === void 0) {
- this.webgpuProcessingContext.bindGroupLayoutEntries[e] = [];
- continue
- }
- for (var o = 0; o < i.length; o++) {
- var s = this.webgpuProcessingContext.bindGroupLayoutEntries[e][o]
- , c = this.webgpuProcessingContext.bindGroupLayoutEntryInfo[e][s.binding].name
- , d = this.webgpuProcessingContext.bindGroupLayoutEntryInfo[e][s.binding].nameInArrayOfTexture;
- 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))
- }
- }
- }
- ,
- a.prototype._preCreateBindGroupEntries = function() {
- for (var e = this.webgpuProcessingContext.bindGroupEntries, i = 0; i < this.webgpuProcessingContext.bindGroupLayoutEntries.length; i++) {
- for (var o = this.webgpuProcessingContext.bindGroupLayoutEntries[i], s = [], c = 0; c < o.length; c++) {
- var d = this.webgpuProcessingContext.bindGroupLayoutEntries[i][c];
- d.sampler || d.texture || d.storageTexture || d.externalTexture ? s.push({
- binding: d.binding,
- resource: void 0
- }) : d.buffer && s.push({
- binding: d.binding,
- resource: {
- buffer: void 0,
- offset: 0,
- size: 0
- }
- })
- }
- e[i] = s
- }
- }
- ,
- a.prototype._addTextureBindingDescription = function(e, i, o, s, c, d) {
- var _ = i.textures[o]
- , b = _.groupIndex
- , k = _.bindingIndex;
- if (this.webgpuProcessingContext.bindGroupLayoutEntries[b] || (this.webgpuProcessingContext.bindGroupLayoutEntries[b] = [],
- this.webgpuProcessingContext.bindGroupLayoutEntryInfo[b] = []),
- !this.webgpuProcessingContext.bindGroupLayoutEntryInfo[b][k]) {
- var j = void 0;
- s === null ? j = this.webgpuProcessingContext.bindGroupLayoutEntries[b].push({
- binding: k,
- visibility: 0,
- externalTexture: {}
- }) : c ? j = this.webgpuProcessingContext.bindGroupLayoutEntries[b].push({
- binding: k,
- visibility: 0,
- storageTexture: {
- access: StorageTextureAccess.WriteOnly,
- format: c,
- viewDimension: s
- }
- }) : j = this.webgpuProcessingContext.bindGroupLayoutEntries[b].push({
- binding: k,
- visibility: 0,
- texture: {
- sampleType: i.sampleType,
- viewDimension: s,
- multisampled: !1
- }
- });
- var $ = i.isTextureArray ? e + o : e;
- this.webgpuProcessingContext.bindGroupLayoutEntryInfo[b][k] = {
- name: e,
- index: j - 1,
- nameInArrayOfTexture: $
- }
- }
- k = this.webgpuProcessingContext.bindGroupLayoutEntryInfo[b][k].index,
- d ? this.webgpuProcessingContext.bindGroupLayoutEntries[b][k].visibility |= ShaderStage.Vertex : this.webgpuProcessingContext.bindGroupLayoutEntries[b][k].visibility |= ShaderStage.Fragment
- }
- ,
- a.prototype._addSamplerBindingDescription = function(e, i, o) {
- var s = i.binding
- , c = s.groupIndex
- , d = s.bindingIndex;
- if (this.webgpuProcessingContext.bindGroupLayoutEntries[c] || (this.webgpuProcessingContext.bindGroupLayoutEntries[c] = [],
- this.webgpuProcessingContext.bindGroupLayoutEntryInfo[c] = []),
- !this.webgpuProcessingContext.bindGroupLayoutEntryInfo[c][d]) {
- var _ = this.webgpuProcessingContext.bindGroupLayoutEntries[c].push({
- binding: d,
- visibility: 0,
- sampler: {
- type: i.type
- }
- });
- this.webgpuProcessingContext.bindGroupLayoutEntryInfo[c][d] = {
- name: e,
- index: _ - 1
- }
- }
- d = this.webgpuProcessingContext.bindGroupLayoutEntryInfo[c][d].index,
- o ? this.webgpuProcessingContext.bindGroupLayoutEntries[c][d].visibility |= ShaderStage.Vertex : this.webgpuProcessingContext.bindGroupLayoutEntries[c][d].visibility |= ShaderStage.Fragment
- }
- ,
- a.prototype._addBufferBindingDescription = function(e, i, o, s) {
- var c = i.binding
- , d = c.groupIndex
- , _ = c.bindingIndex;
- if (this.webgpuProcessingContext.bindGroupLayoutEntries[d] || (this.webgpuProcessingContext.bindGroupLayoutEntries[d] = [],
- this.webgpuProcessingContext.bindGroupLayoutEntryInfo[d] = []),
- !this.webgpuProcessingContext.bindGroupLayoutEntryInfo[d][_]) {
- var b = this.webgpuProcessingContext.bindGroupLayoutEntries[d].push({
- binding: _,
- visibility: 0,
- buffer: {
- type: o
- }
- });
- this.webgpuProcessingContext.bindGroupLayoutEntryInfo[d][_] = {
- name: e,
- index: b - 1
- }
- }
- _ = this.webgpuProcessingContext.bindGroupLayoutEntryInfo[d][_].index,
- s ? this.webgpuProcessingContext.bindGroupLayoutEntries[d][_].visibility |= ShaderStage.Vertex : this.webgpuProcessingContext.bindGroupLayoutEntries[d][_].visibility |= ShaderStage.Fragment
- }
- ,
- a.AutoSamplerSuffix = "Sampler",
- a.LeftOvertUBOName = "LeftOver",
- a.UniformSizes = {
- bool: 1,
- int: 1,
- float: 1,
- vec2: 2,
- ivec2: 2,
- vec3: 3,
- ivec3: 3,
- vec4: 4,
- ivec4: 4,
- mat2: 4,
- mat3: 12,
- mat4: 16,
- i32: 1,
- u32: 1,
- f32: 1,
- mat2x2: 4,
- mat3x3: 12,
- mat4x4: 16
- },
- a._SamplerFunctionByWebGLSamplerType = {
- sampler2D: "sampler2D",
- sampler2DArray: "sampler2DArray",
- sampler2DShadow: "sampler2DShadow",
- sampler2DArrayShadow: "sampler2DArrayShadow",
- samplerCube: "samplerCube",
- sampler3D: "sampler3D"
- },
- a._TextureTypeByWebGLSamplerType = {
- sampler2D: "texture2D",
- sampler2DArray: "texture2DArray",
- sampler2DShadow: "texture2D",
- sampler2DArrayShadow: "texture2DArray",
- samplerCube: "textureCube",
- samplerCubeArray: "textureCubeArray",
- sampler3D: "texture3D"
- },
- a._GpuTextureViewDimensionByWebGPUTextureType = {
- textureCube: TextureViewDimension.Cube,
- textureCubeArray: TextureViewDimension.CubeArray,
- texture2D: TextureViewDimension.E2d,
- texture2DArray: TextureViewDimension.E2dArray,
- texture3D: TextureViewDimension.E3d
- },
- a._SamplerTypeByWebGLSamplerType = {
- sampler2DShadow: "samplerShadow",
- sampler2DArrayShadow: "samplerShadow"
- },
- a._IsComparisonSamplerByWebGPUSamplerType = {
- samplerShadow: !0,
- samplerArrayShadow: !0,
- sampler: !1
- },
- a
- }()
- , WebGPUPipelineContext = function() {
- function a(e, i) {
- this._name = "unnamed",
- this.shaderProcessingContext = e,
- this._leftOverUniformsByName = {},
- this.engine = i
- }
- return Object.defineProperty(a.prototype, "isAsync", {
- get: function() {
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "isReady", {
- get: function() {
- return !!this.stages
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._handlesSpectorRebuildCallback = function(e) {}
- ,
- a.prototype._fillEffectInformation = function(e, i, o, s, c, d, _, b) {
- var k = this.engine;
- e._fragmentSourceCode = "",
- e._vertexSourceCode = "";
- var j = this.shaderProcessingContext.availableTextures, $;
- for ($ = 0; $ < c.length; $++) {
- var _e = c[$]
- , et = j[c[$]];
- et == null || et == null ? (c.splice($, 1),
- $--) : d[_e] = $
- }
- for (var tt = 0, rt = k.getAttributes(this, _); tt < rt.length; tt++) {
- var it = rt[tt];
- b.push(it)
- }
- this.buildUniformLayout();
- var nt = []
- , ot = [];
- for ($ = 0; $ < _.length; $++) {
- var at = b[$];
- at >= 0 && (nt.push(_[$]),
- ot.push(at))
- }
- this.shaderProcessingContext.attributeNamesFromEffect = nt,
- this.shaderProcessingContext.attributeLocationsFromEffect = ot
- }
- ,
- a.prototype.buildUniformLayout = function() {
- if (!!this.shaderProcessingContext.leftOverUniforms.length) {
- this.uniformBuffer = new UniformBuffer(this.engine,void 0,void 0,"leftOver-" + this._name);
- for (var e = 0, i = this.shaderProcessingContext.leftOverUniforms; e < i.length; e++) {
- var o = i[e]
- , s = o.type.replace(/^(.*?)(<.*>)?$/, "$1")
- , c = WebGPUShaderProcessor.UniformSizes[s];
- this.uniformBuffer.addUniform(o.name, c, o.length),
- this._leftOverUniformsByName[o.name] = o.type
- }
- this.uniformBuffer.create()
- }
- }
- ,
- a.prototype.dispose = function() {
- this.uniformBuffer && this.uniformBuffer.dispose()
- }
- ,
- a.prototype.setInt = function(e, i) {
- !this.uniformBuffer || !this._leftOverUniformsByName[e] || this.uniformBuffer.updateInt(e, i)
- }
- ,
- a.prototype.setInt2 = function(e, i, o) {
- !this.uniformBuffer || !this._leftOverUniformsByName[e] || this.uniformBuffer.updateInt2(e, i, o)
- }
- ,
- a.prototype.setInt3 = function(e, i, o, s) {
- !this.uniformBuffer || !this._leftOverUniformsByName[e] || this.uniformBuffer.updateInt3(e, i, o, s)
- }
- ,
- a.prototype.setInt4 = function(e, i, o, s, c) {
- !this.uniformBuffer || !this._leftOverUniformsByName[e] || this.uniformBuffer.updateInt4(e, i, o, s, c)
- }
- ,
- a.prototype.setIntArray = function(e, i) {
- !this.uniformBuffer || !this._leftOverUniformsByName[e] || this.uniformBuffer.updateIntArray(e, i)
- }
- ,
- a.prototype.setIntArray2 = function(e, i) {
- this.setIntArray(e, i)
- }
- ,
- a.prototype.setIntArray3 = function(e, i) {
- this.setIntArray(e, i)
- }
- ,
- a.prototype.setIntArray4 = function(e, i) {
- this.setIntArray(e, i)
- }
- ,
- a.prototype.setArray = function(e, i) {
- !this.uniformBuffer || !this._leftOverUniformsByName[e] || this.uniformBuffer.updateArray(e, i)
- }
- ,
- a.prototype.setArray2 = function(e, i) {
- this.setArray(e, i)
- }
- ,
- a.prototype.setArray3 = function(e, i) {
- this.setArray(e, i)
- }
- ,
- a.prototype.setArray4 = function(e, i) {
- this.setArray(e, i)
- }
- ,
- a.prototype.setMatrices = function(e, i) {
- !this.uniformBuffer || !this._leftOverUniformsByName[e] || this.uniformBuffer.updateMatrices(e, i)
- }
- ,
- a.prototype.setMatrix = function(e, i) {
- !this.uniformBuffer || !this._leftOverUniformsByName[e] || this.uniformBuffer.updateMatrix(e, i)
- }
- ,
- a.prototype.setMatrix3x3 = function(e, i) {
- !this.uniformBuffer || !this._leftOverUniformsByName[e] || this.uniformBuffer.updateMatrix3x3(e, i)
- }
- ,
- a.prototype.setMatrix2x2 = function(e, i) {
- !this.uniformBuffer || !this._leftOverUniformsByName[e] || this.uniformBuffer.updateMatrix2x2(e, i)
- }
- ,
- a.prototype.setFloat = function(e, i) {
- !this.uniformBuffer || !this._leftOverUniformsByName[e] || this.uniformBuffer.updateFloat(e, i)
- }
- ,
- a.prototype.setVector2 = function(e, i) {
- this.setFloat2(e, i.x, i.y)
- }
- ,
- a.prototype.setFloat2 = function(e, i, o) {
- !this.uniformBuffer || !this._leftOverUniformsByName[e] || this.uniformBuffer.updateFloat2(e, i, o)
- }
- ,
- a.prototype.setVector3 = function(e, i) {
- this.setFloat3(e, i.x, i.y, i.z)
- }
- ,
- a.prototype.setFloat3 = function(e, i, o, s) {
- !this.uniformBuffer || !this._leftOverUniformsByName[e] || this.uniformBuffer.updateFloat3(e, i, o, s)
- }
- ,
- a.prototype.setVector4 = function(e, i) {
- this.setFloat4(e, i.x, i.y, i.z, i.w)
- }
- ,
- a.prototype.setFloat4 = function(e, i, o, s, c) {
- !this.uniformBuffer || !this._leftOverUniformsByName[e] || this.uniformBuffer.updateFloat4(e, i, o, s, c)
- }
- ,
- a.prototype.setColor3 = function(e, i) {
- this.setFloat3(e, i.r, i.g, i.b)
- }
- ,
- a.prototype.setColor4 = function(e, i, o) {
- this.setFloat4(e, i.r, i.g, i.b, o)
- }
- ,
- a.prototype.setDirectColor4 = function(e, i) {
- this.setFloat4(e, i.r, i.g, i.b, i.a)
- }
- ,
- a.prototype._getVertexShaderCode = function() {
- var e;
- return (e = this.sources) === null || e === void 0 ? void 0 : e.vertex
- }
- ,
- a.prototype._getFragmentShaderCode = function() {
- var e;
- return (e = this.sources) === null || e === void 0 ? void 0 : e.fragment
- }
- ,
- a
- }()
- , _maxGroups = 4
- , _maxBindingsPerGroup = 1 << 16
- , _typeToLocationSize = {
- mat2: 2,
- mat3: 3,
- mat4: 4,
- mat2x2: 2,
- mat3x3: 3,
- mat4x4: 4
- }
- , WebGPUShaderProcessingContext = function() {
- function a(e) {
- this.shaderLanguage = e,
- this._attributeNextLocation = 0,
- this._varyingNextLocation = 0,
- this.freeGroupIndex = 0,
- this.freeBindingIndex = 0,
- this.availableVaryings = {},
- this.availableAttributes = {},
- this.availableBuffers = {},
- this.availableTextures = {},
- this.availableSamplers = {},
- this.orderedAttributes = [],
- this.bindGroupLayoutEntries = [],
- this.bindGroupLayoutEntryInfo = [],
- this.bindGroupEntries = [],
- this.bufferNames = [],
- this.textureNames = [],
- this.samplerNames = [],
- this.leftOverUniforms = [],
- this._findStartingGroupBinding()
- }
- return Object.defineProperty(a, "KnownUBOs", {
- get: function() {
- return a._SimplifiedKnownBindings ? a._SimplifiedKnownUBOs : a._KnownUBOs
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._findStartingGroupBinding = function() {
- var e = a.KnownUBOs
- , i = [];
- for (var o in e) {
- var s = e[o].binding;
- s.groupIndex !== -1 && (i[s.groupIndex] === void 0 ? i[s.groupIndex] = s.bindingIndex : i[s.groupIndex] = Math.max(i[s.groupIndex], s.bindingIndex))
- }
- this.freeGroupIndex = i.length - 1,
- this.freeGroupIndex === 0 ? (this.freeGroupIndex++,
- this.freeBindingIndex = 0) : this.freeBindingIndex = i[i.length - 1] + 1
- }
- ,
- a.prototype.getAttributeNextLocation = function(e, i) {
- var o;
- i === void 0 && (i = 0);
- var s = this._attributeNextLocation;
- return this._attributeNextLocation += ((o = _typeToLocationSize[e]) !== null && o !== void 0 ? o : 1) * (i || 1),
- s
- }
- ,
- a.prototype.getVaryingNextLocation = function(e, i) {
- var o;
- i === void 0 && (i = 0);
- var s = this._varyingNextLocation;
- return this._varyingNextLocation += ((o = _typeToLocationSize[e]) !== null && o !== void 0 ? o : 1) * (i || 1),
- s
- }
- ,
- a.prototype.getNextFreeUBOBinding = function() {
- return this._getNextFreeBinding(1)
- }
- ,
- a.prototype._getNextFreeBinding = function(e) {
- if (this.freeBindingIndex > _maxBindingsPerGroup - e && (this.freeGroupIndex++,
- this.freeBindingIndex = 0),
- this.freeGroupIndex === _maxGroups)
- throw "Too many textures or UBOs have been declared and it is not supported in WebGPU.";
- var i = {
- groupIndex: this.freeGroupIndex,
- bindingIndex: this.freeBindingIndex
- };
- return this.freeBindingIndex += e,
- i
- }
- ,
- a._SimplifiedKnownBindings = !0,
- a._SimplifiedKnownUBOs = {
- Scene: {
- binding: {
- groupIndex: 0,
- bindingIndex: 0
- }
- },
- Light0: {
- binding: {
- groupIndex: -1,
- bindingIndex: -1
- }
- },
- Light1: {
- binding: {
- groupIndex: -1,
- bindingIndex: -1
- }
- },
- Light2: {
- binding: {
- groupIndex: -1,
- bindingIndex: -1
- }
- },
- Light3: {
- binding: {
- groupIndex: -1,
- bindingIndex: -1
- }
- },
- Light4: {
- binding: {
- groupIndex: -1,
- bindingIndex: -1
- }
- },
- Light5: {
- binding: {
- groupIndex: -1,
- bindingIndex: -1
- }
- },
- Light6: {
- binding: {
- groupIndex: -1,
- bindingIndex: -1
- }
- },
- Light7: {
- binding: {
- groupIndex: -1,
- bindingIndex: -1
- }
- },
- Light8: {
- binding: {
- groupIndex: -1,
- bindingIndex: -1
- }
- },
- Light9: {
- binding: {
- groupIndex: -1,
- bindingIndex: -1
- }
- },
- Light10: {
- binding: {
- groupIndex: -1,
- bindingIndex: -1
- }
- },
- Light11: {
- binding: {
- groupIndex: -1,
- bindingIndex: -1
- }
- },
- Light12: {
- binding: {
- groupIndex: -1,
- bindingIndex: -1
- }
- },
- Light13: {
- binding: {
- groupIndex: -1,
- bindingIndex: -1
- }
- },
- Light14: {
- binding: {
- groupIndex: -1,
- bindingIndex: -1
- }
- },
- Light15: {
- binding: {
- groupIndex: -1,
- bindingIndex: -1
- }
- },
- Light16: {
- binding: {
- groupIndex: -1,
- bindingIndex: -1
- }
- },
- Light17: {
- binding: {
- groupIndex: -1,
- bindingIndex: -1
- }
- },
- Light18: {
- binding: {
- groupIndex: -1,
- bindingIndex: -1
- }
- },
- Light19: {
- binding: {
- groupIndex: -1,
- bindingIndex: -1
- }
- },
- Light20: {
- binding: {
- groupIndex: -1,
- bindingIndex: -1
- }
- },
- Light21: {
- binding: {
- groupIndex: -1,
- bindingIndex: -1
- }
- },
- Light22: {
- binding: {
- groupIndex: -1,
- bindingIndex: -1
- }
- },
- Light23: {
- binding: {
- groupIndex: -1,
- bindingIndex: -1
- }
- },
- Light24: {
- binding: {
- groupIndex: -1,
- bindingIndex: -1
- }
- },
- Light25: {
- binding: {
- groupIndex: -1,
- bindingIndex: -1
- }
- },
- Light26: {
- binding: {
- groupIndex: -1,
- bindingIndex: -1
- }
- },
- Light27: {
- binding: {
- groupIndex: -1,
- bindingIndex: -1
- }
- },
- Light28: {
- binding: {
- groupIndex: -1,
- bindingIndex: -1
- }
- },
- Light29: {
- binding: {
- groupIndex: -1,
- bindingIndex: -1
- }
- },
- Light30: {
- binding: {
- groupIndex: -1,
- bindingIndex: -1
- }
- },
- Light31: {
- binding: {
- groupIndex: -1,
- bindingIndex: -1
- }
- },
- Material: {
- binding: {
- groupIndex: -1,
- bindingIndex: -1
- }
- },
- Mesh: {
- binding: {
- groupIndex: -1,
- bindingIndex: -1
- }
- }
- },
- a._KnownUBOs = {
- Scene: {
- binding: {
- groupIndex: 0,
- bindingIndex: 0
- }
- },
- Light0: {
- binding: {
- groupIndex: 1,
- bindingIndex: 0
- }
- },
- Light1: {
- binding: {
- groupIndex: 1,
- bindingIndex: 1
- }
- },
- Light2: {
- binding: {
- groupIndex: 1,
- bindingIndex: 2
- }
- },
- Light3: {
- binding: {
- groupIndex: 1,
- bindingIndex: 3
- }
- },
- Light4: {
- binding: {
- groupIndex: 1,
- bindingIndex: 4
- }
- },
- Light5: {
- binding: {
- groupIndex: 1,
- bindingIndex: 5
- }
- },
- Light6: {
- binding: {
- groupIndex: 1,
- bindingIndex: 6
- }
- },
- Light7: {
- binding: {
- groupIndex: 1,
- bindingIndex: 7
- }
- },
- Light8: {
- binding: {
- groupIndex: 1,
- bindingIndex: 8
- }
- },
- Light9: {
- binding: {
- groupIndex: 1,
- bindingIndex: 9
- }
- },
- Light10: {
- binding: {
- groupIndex: 1,
- bindingIndex: 10
- }
- },
- Light11: {
- binding: {
- groupIndex: 1,
- bindingIndex: 11
- }
- },
- Light12: {
- binding: {
- groupIndex: 1,
- bindingIndex: 12
- }
- },
- Light13: {
- binding: {
- groupIndex: 1,
- bindingIndex: 13
- }
- },
- Light14: {
- binding: {
- groupIndex: 1,
- bindingIndex: 14
- }
- },
- Light15: {
- binding: {
- groupIndex: 1,
- bindingIndex: 15
- }
- },
- Light16: {
- binding: {
- groupIndex: 1,
- bindingIndex: 16
- }
- },
- Light17: {
- binding: {
- groupIndex: 1,
- bindingIndex: 17
- }
- },
- Light18: {
- binding: {
- groupIndex: 1,
- bindingIndex: 18
- }
- },
- Light19: {
- binding: {
- groupIndex: 1,
- bindingIndex: 19
- }
- },
- Light20: {
- binding: {
- groupIndex: 1,
- bindingIndex: 20
- }
- },
- Light21: {
- binding: {
- groupIndex: 1,
- bindingIndex: 21
- }
- },
- Light22: {
- binding: {
- groupIndex: 1,
- bindingIndex: 22
- }
- },
- Light23: {
- binding: {
- groupIndex: 1,
- bindingIndex: 23
- }
- },
- Light24: {
- binding: {
- groupIndex: 1,
- bindingIndex: 24
- }
- },
- Light25: {
- binding: {
- groupIndex: 1,
- bindingIndex: 25
- }
- },
- Light26: {
- binding: {
- groupIndex: 1,
- bindingIndex: 26
- }
- },
- Light27: {
- binding: {
- groupIndex: 1,
- bindingIndex: 27
- }
- },
- Light28: {
- binding: {
- groupIndex: 1,
- bindingIndex: 28
- }
- },
- Light29: {
- binding: {
- groupIndex: 1,
- bindingIndex: 29
- }
- },
- Light30: {
- binding: {
- groupIndex: 1,
- bindingIndex: 30
- }
- },
- Light31: {
- binding: {
- groupIndex: 1,
- bindingIndex: 31
- }
- },
- Material: {
- binding: {
- groupIndex: 2,
- bindingIndex: 0
- }
- },
- Mesh: {
- binding: {
- groupIndex: 2,
- bindingIndex: 1
- }
- }
- },
- a
- }()
- , WebGPUShaderProcessorGLSL = function(a) {
- __extends(e, a);
- function e() {
- var i = a !== null && a.apply(this, arguments) || this;
- return i._missingVaryings = [],
- i._textureArrayProcessing = [],
- i.shaderLanguage = ShaderLanguage.GLSL,
- i
- }
- return e.prototype._getArraySize = function(i, o, s) {
- var c = 0
- , d = i.indexOf("[")
- , _ = i.indexOf("]");
- if (d > 0 && _ > 0) {
- var b = i.substring(d + 1, _);
- c = +b,
- isNaN(c) && (c = +s[b.trim()]),
- i = i.substr(0, d)
- }
- return [i, o, c]
- }
- ,
- e.prototype.initializeShaders = function(i) {
- this.webgpuProcessingContext = i,
- this._missingVaryings.length = 0,
- this._textureArrayProcessing.length = 0
- }
- ,
- e.prototype.varyingProcessor = function(i, o, s, c) {
- this._preProcessors = s;
- var d = /\s*varying\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/gm
- , _ = d.exec(i);
- if (_ != null) {
- var b = _[1], k = _[2], j;
- o ? (j = this.webgpuProcessingContext.availableVaryings[k],
- this._missingVaryings[j] = "",
- 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]),
- this.webgpuProcessingContext.availableVaryings[k] = j,
- this._missingVaryings[j] = "layout(location = " + j + ") in " + b + " " + k + ";"),
- i = i.replace(_[0], j === void 0 ? "" : "layout(location = " + j + ") " + (o ? "in" : "out") + " " + b + " " + k + ";")
- }
- return i
- }
- ,
- e.prototype.attributeProcessor = function(i, o, s) {
- this._preProcessors = o;
- var c = /\s*attribute\s+(\S+)\s+(\S+)\s*;/gm
- , d = c.exec(i);
- if (d != null) {
- var _ = d[1]
- , b = d[2]
- , k = this.webgpuProcessingContext.getAttributeNextLocation(_, this._getArraySize(b, _, o)[2]);
- this.webgpuProcessingContext.availableAttributes[b] = k,
- this.webgpuProcessingContext.orderedAttributes[k] = b,
- i = i.replace(d[0], "layout(location = " + k + ") in " + _ + " " + b + ";")
- }
- return i
- }
- ,
- e.prototype.uniformProcessor = function(i, o, s, c) {
- var d, _;
- this._preProcessors = s;
- var b = /\s*uniform\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/gm
- , k = b.exec(i);
- if (k != null) {
- var j = k[1]
- , $ = k[2];
- if (j.indexOf("sampler") === 0 || j.indexOf("sampler") === 1) {
- var _e = 0;
- d = this._getArraySize($, j, s),
- $ = d[0],
- j = d[1],
- _e = d[2];
- var et = this.webgpuProcessingContext.availableTextures[$];
- if (!et) {
- et = {
- autoBindSampler: !0,
- isTextureArray: _e > 0,
- isStorageTexture: !1,
- textures: [],
- sampleType: TextureSampleType.Float
- };
- for (var tt = 0; tt < (_e || 1); ++tt)
- et.textures.push(this.webgpuProcessingContext.getNextFreeUBOBinding())
- }
- var rt = (_ = WebGPUShaderProcessor._SamplerTypeByWebGLSamplerType[j]) !== null && _ !== void 0 ? _ : "sampler"
- , it = !!WebGPUShaderProcessor._IsComparisonSamplerByWebGPUSamplerType[rt]
- , nt = it ? SamplerBindingType.Comparison : SamplerBindingType.Filtering
- , ot = $ + WebGPUShaderProcessor.AutoSamplerSuffix
- , at = this.webgpuProcessingContext.availableSamplers[ot];
- at || (at = {
- binding: this.webgpuProcessingContext.getNextFreeUBOBinding(),
- type: nt
- });
- var st = j.charAt(0) === "u" ? "u" : j.charAt(0) === "i" ? "i" : "";
- st && (j = j.substr(1));
- var ut = it ? TextureSampleType.Depth : st === "u" ? TextureSampleType.Uint : st === "i" ? TextureSampleType.Sint : TextureSampleType.Float;
- et.sampleType = ut;
- var ct = _e > 0
- , lt = at.binding.groupIndex
- , ft = at.binding.bindingIndex
- , ht = WebGPUShaderProcessor._SamplerFunctionByWebGLSamplerType[j]
- , pt = WebGPUShaderProcessor._TextureTypeByWebGLSamplerType[j]
- , dt = WebGPUShaderProcessor._GpuTextureViewDimensionByWebGPUTextureType[pt];
- if (!ct)
- _e = 1,
- i = "layout(set = " + lt + ", binding = " + ft + ") uniform " + st + rt + " " + ot + `;
- layout(set = ` + et.textures[0].groupIndex + ", binding = " + et.textures[0].bindingIndex + ") uniform " + pt + " " + $ + `Texture;
- #define ` + $ + " " + st + ht + "(" + $ + "Texture, " + ot + ")";
- else {
- var _t = [];
- _t.push("layout(set = " + lt + ", binding = " + ft + ") uniform " + st + rt + " " + ot + ";"),
- i = `\r
- `;
- for (var tt = 0; tt < _e; ++tt) {
- var mt = et.textures[tt].groupIndex
- , vt = et.textures[tt].bindingIndex;
- _t.push("layout(set = " + mt + ", binding = " + vt + ") uniform " + pt + " " + $ + "Texture" + tt + ";"),
- i += (tt > 0 ? `\r
- ` : "") + "#define " + $ + tt + " " + st + ht + "(" + $ + "Texture" + tt + ", " + ot + ")"
- }
- i = _t.join(`\r
- `) + i,
- this._textureArrayProcessing.push($)
- }
- this.webgpuProcessingContext.availableTextures[$] = et,
- this.webgpuProcessingContext.availableSamplers[ot] = at,
- this._addSamplerBindingDescription(ot, at, !o);
- for (var tt = 0; tt < _e; ++tt)
- this._addTextureBindingDescription($, et, tt, dt, null, !o)
- } else
- this._addUniformToLeftOverUBO($, j, s),
- i = ""
- }
- return i
- }
- ,
- e.prototype.uniformBufferProcessor = function(i, o, s) {
- var c = /uniform\s+(\w+)/gm
- , d = c.exec(i);
- if (d != null) {
- var _ = d[1]
- , b = this.webgpuProcessingContext.availableBuffers[_];
- if (!b) {
- var k = WebGPUShaderProcessingContext.KnownUBOs[_]
- , j = void 0;
- k && k.binding.groupIndex !== -1 ? j = k.binding : j = this.webgpuProcessingContext.getNextFreeUBOBinding(),
- b = {
- binding: j
- },
- this.webgpuProcessingContext.availableBuffers[_] = b
- }
- this._addBufferBindingDescription(_, b, BufferBindingType.Uniform, !o),
- i = i.replace("uniform", "layout(set = " + b.binding.groupIndex + ", binding = " + b.binding.bindingIndex + ") uniform")
- }
- return i
- }
- ,
- e.prototype.postProcessor = function(i, o, s, c, d) {
- var _ = i.search(/#extension.+GL_EXT_draw_buffers.+require/) !== -1
- , 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;
- if (i = i.replace(b, ""),
- i = i.replace(/texture2D\s*\(/g, "texture("),
- s)
- i = i.replace(/texture2DLodEXT\s*\(/g, "textureLod("),
- i = i.replace(/textureCubeLodEXT\s*\(/g, "textureLod("),
- i = i.replace(/textureCube\s*\(/g, "texture("),
- i = i.replace(/gl_FragDepthEXT/g, "gl_FragDepth"),
- i = i.replace(/gl_FragColor/g, "glFragColor"),
- i = i.replace(/gl_FragData/g, "glFragData"),
- i = i.replace(/void\s+?main\s*\(/g, (_ ? "" : `layout(location = 0) out vec4 glFragColor;
- `) + "void main(");
- else {
- i = i.replace(/gl_InstanceID/g, "gl_InstanceIndex"),
- i = i.replace(/gl_VertexID/g, "gl_VertexIndex");
- var k = o.indexOf("#define MULTIVIEW") !== -1;
- if (k)
- return `#extension GL_OVR_multiview2 : require
- layout (num_views = 2) in;
- ` + i
- }
- if (!s) {
- var j = i.lastIndexOf("}");
- i = i.substring(0, j),
- i += `gl_Position.y *= -1.;
- `,
- d.isNDCHalfZRange || (i += `gl_Position.z = (gl_Position.z + gl_Position.w) / 2.0;
- `),
- i += "}"
- }
- return i
- }
- ,
- e.prototype._applyTextureArrayProcessing = function(i, o) {
- for (var s = new RegExp(o + "\\s*\\[(.+)?\\]","gm"), c = s.exec(i); c != null; ) {
- var d = c[1]
- , _ = +d;
- this._preProcessors && isNaN(_) && (_ = +this._preProcessors[d.trim()]),
- i = i.replace(c[0], o + _),
- c = s.exec(i)
- }
- return i
- }
- ,
- e.prototype._generateLeftOverUBOCode = function(i, o) {
- for (var s = "layout(set = " + o.binding.groupIndex + ", binding = " + o.binding.bindingIndex + ") uniform " + i + ` {
- `, c = 0, d = this.webgpuProcessingContext.leftOverUniforms; c < d.length; c++) {
- var _ = d[c];
- _.length > 0 ? s += " " + _.type + " " + _.name + "[" + _.length + `];
- ` : s += " " + _.type + " " + _.name + `;
- `
- }
- return s += `};
- `,
- s
- }
- ,
- e.prototype.finalizeShaders = function(i, o, s) {
- for (var c = 0; c < this._textureArrayProcessing.length; ++c) {
- var d = this._textureArrayProcessing[c];
- i = this._applyTextureArrayProcessing(i, d),
- o = this._applyTextureArrayProcessing(o, d)
- }
- for (var c = 0; c < this._missingVaryings.length; ++c) {
- var _ = this._missingVaryings[c];
- _ && _.length > 0 && (o = _ + `
- ` + o)
- }
- var b = this._buildLeftOverUBO();
- return i = b + i,
- o = b + o,
- this._collectBindingNames(),
- this._preCreateBindGroupEntries(),
- this._preProcessors = null,
- {
- vertexCode: i,
- fragmentCode: o
- }
- }
- ,
- e
- }(WebGPUShaderProcessor)
- , name$2V = "bonesDeclaration"
- , shader$2V = `#if NUM_BONE_INFLUENCERS>0
- attribute matricesIndices : vec4<f32>;
- attribute matricesWeights : vec4<f32>;
- #if NUM_BONE_INFLUENCERS>4
- attribute matricesIndicesExtra : vec4<f32>;
- attribute matricesWeightsExtra : vec4<f32>;
- #endif
- #ifndef BAKED_VERTEX_ANIMATION_TEXTURE
- #ifdef BONETEXTURE
- var boneSampler : texture_2d<f32>;
- uniform boneTextureWidth : f32;
- #else
- uniform mBones : array<mat4x4,BonesPerMesh>;
- #ifdef BONES_VELOCITY_ENABLED
- uniform mPreviousBones : array<mat4x4,BonesPerMesh>;
- #endif
- #endif
- #ifdef BONETEXTURE
- fn readMatrixFromRawSampler(smp : texture_2d<f32>,index : f32) -> mat4x4<f32>
- {
- let offset=i32(index)*4;
- let m0=textureLoad(smp,vec2<i32>(offset+0,0),0);
- let m1=textureLoad(smp,vec2<i32>(offset+1,0),0);
- let m2=textureLoad(smp,vec2<i32>(offset+2,0),0);
- let m3=textureLoad(smp,vec2<i32>(offset+3,0),0);
- return mat4x4<f32>(m0,m1,m2,m3);
- }
- #endif
- #endif
- #endif`;
- ShaderStore.IncludesShadersStoreWGSL[name$2V] = shader$2V;
- var name$2U = "bonesVertex"
- , shader$2U = `#ifndef BAKED_VERTEX_ANIMATION_TEXTURE
- #if NUM_BONE_INFLUENCERS>0
- var influence : mat4x4<f32>;
- #ifdef BONETEXTURE
- influence=readMatrixFromRawSampler(boneSampler,matricesIndices[0])*matricesWeights[0];
- #if NUM_BONE_INFLUENCERS>1
- influence=influence+readMatrixFromRawSampler(boneSampler,matricesIndices[1])*matricesWeights[1];
- #endif
- #if NUM_BONE_INFLUENCERS>2
- influence=influence+readMatrixFromRawSampler(boneSampler,matricesIndices[2])*matricesWeights[2];
- #endif
- #if NUM_BONE_INFLUENCERS>3
- influence=influence+readMatrixFromRawSampler(boneSampler,matricesIndices[3])*matricesWeights[3];
- #endif
- #if NUM_BONE_INFLUENCERS>4
- influence=influence+readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[0])*matricesWeightsExtra[0];
- #endif
- #if NUM_BONE_INFLUENCERS>5
- influence=influence+readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[1])*matricesWeightsExtra[1];
- #endif
- #if NUM_BONE_INFLUENCERS>6
- influence=influence+readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[2])*matricesWeightsExtra[2];
- #endif
- #if NUM_BONE_INFLUENCERS>7
- influence=influence+readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[3])*matricesWeightsExtra[3];
- #endif
- #else
- influence=uniforms.mBones[int(matricesIndices[0])]*matricesWeights[0];
- #if NUM_BONE_INFLUENCERS>1
- influence=influence+uniforms.mBones[int(matricesIndices[1])]*matricesWeights[1];
- #endif
- #if NUM_BONE_INFLUENCERS>2
- influence=influence+uniforms.mBones[int(matricesIndices[2])]*matricesWeights[2];
- #endif
- #if NUM_BONE_INFLUENCERS>3
- influence=influence+uniforms.mBones[int(matricesIndices[3])]*matricesWeights[3];
- #endif
- #if NUM_BONE_INFLUENCERS>4
- influence=influence+uniforms.mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];
- #endif
- #if NUM_BONE_INFLUENCERS>5
- influence=influence+uniforms.mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];
- #endif
- #if NUM_BONE_INFLUENCERS>6
- influence=influence+uniforms.mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];
- #endif
- #if NUM_BONE_INFLUENCERS>7
- influence=influence+uniforms.mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];
- #endif
- #endif
- finalWorld=finalWorld*influence;
- #endif
- #endif`;
- ShaderStore.IncludesShadersStoreWGSL[name$2U] = shader$2U;
- var name$2T = "bakedVertexAnimationDeclaration"
- , shader$2T = `#ifdef BAKED_VERTEX_ANIMATION_TEXTURE
- uniform bakedVertexAnimationTime: f32;
- uniform bakedVertexAnimationTextureSizeInverted: vec2<f32>;
- uniform bakedVertexAnimationSettings: vec4<f32>;
- var bakedVertexAnimationTexture : texture_2d<f32>;
- #ifdef INSTANCES
- attribute bakedVertexAnimationSettingsInstanced : vec4<f32>;
- attribute bakedVertexAnimationTimeInstanced : f32;
- #endif
- fn readMatrixFromRawSamplerVAT(smp : texture_2d<f32>,index : f32,frame : f32) -> mat4x4<f32>
- {
- let offset=i32(index)*4;
- let frameUV=i32(frame);
- let m0=textureLoad(smp,vec2<i32>(offset+0,frameUV),0);
- let m1=textureLoad(smp,vec2<i32>(offset+1,frameUV),0);
- let m2=textureLoad(smp,vec2<i32>(offset+2,frameUV),0);
- let m3=textureLoad(smp,vec2<i32>(offset+3,frameUV),0);
- return mat4x4<f32>(m0,m1,m2,m3);
- }
- #endif`;
- ShaderStore.IncludesShadersStoreWGSL[name$2T] = shader$2T;
- var name$2S = "bakedVertexAnimation"
- , shader$2S = `#ifdef BAKED_VERTEX_ANIMATION_TEXTURE
- {
- #ifdef INSTANCES
- let VATStartFrame: f32=bakedVertexAnimationSettingsInstanced.x;
- let VATEndFrame: f32=bakedVertexAnimationSettingsInstanced.y;
- let VATOffsetFrame: f32=bakedVertexAnimationSettingsInstanced.z;
- let VATSpeed: f32=bakedVertexAnimationSettingsInstanced.w;
- let time: f32=bakedVertexAnimationTimeInstanced*VATSpeed/totalFrames;
- #else
- let VATStartFrame: f32=uniforms.bakedVertexAnimationSettings.x;
- let VATEndFrame: f32=uniforms.bakedVertexAnimationSettings.y;
- let VATOffsetFrame: f32=uniforms.bakedVertexAnimationSettings.z;
- let VATSpeed: f32=uniforms.bakedVertexAnimationSettings.w;
- let time: f32=uniforms.bakedVertexAnimationTime*VATSpeed/totalFrames;
- #endif
- let totalFrames: f32=VATEndFrame-VATStartFrame+1.0;
- let frameCorrection: f32=select(1.0,0.0,time<1.0);
- let numOfFrames: f32=totalFrames-frameCorrection;
- var VATFrameNum: f32=fract(time)*numOfFrames;
- VATFrameNum=(VATFrameNum+VATOffsetFrame) % numOfFrames;
- VATFrameNum=floor(VATFrameNum);
- VATFrameNum=VATFrameNum+VATStartFrame+frameCorrection;
- var VATInfluence : mat4x4<f32>;
- VATInfluence=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[0],VATFrameNum)*matricesWeights[0];
- #if NUM_BONE_INFLUENCERS>1
- VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[1],VATFrameNum)*matricesWeights[1];
- #endif
- #if NUM_BONE_INFLUENCERS>2
- VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[2],VATFrameNum)*matricesWeights[2];
- #endif
- #if NUM_BONE_INFLUENCERS>3
- VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[3],VATFrameNum)*matricesWeights[3];
- #endif
- #if NUM_BONE_INFLUENCERS>4
- VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[0],VATFrameNum)*matricesWeightsExtra[0];
- #endif
- #if NUM_BONE_INFLUENCERS>5
- VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[1],VATFrameNum)*matricesWeightsExtra[1];
- #endif
- #if NUM_BONE_INFLUENCERS>6
- VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[2],VATFrameNum)*matricesWeightsExtra[2];
- #endif
- #if NUM_BONE_INFLUENCERS>7
- VATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[3],VATFrameNum)*matricesWeightsExtra[3];
- #endif
- finalWorld=finalWorld*VATInfluence;
- }
- #endif`;
- ShaderStore.IncludesShadersStoreWGSL[name$2S] = shader$2S;
- var name$2R = "clipPlaneFragment"
- , shader$2R = `#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)
- if (false) {}
- #endif
- #ifdef CLIPPLANE
- elseif (fClipDistance>0.0)
- {
- discard;
- }
- #endif
- #ifdef CLIPPLANE2
- elseif (fClipDistance2>0.0)
- {
- discard;
- }
- #endif
- #ifdef CLIPPLANE3
- elseif (fClipDistance3>0.0)
- {
- discard;
- }
- #endif
- #ifdef CLIPPLANE4
- elseif (fClipDistance4>0.0)
- {
- discard;
- }
- #endif
- #ifdef CLIPPLANE5
- elseif (fClipDistance5>0.0)
- {
- discard;
- }
- #endif
- #ifdef CLIPPLANE6
- elseif (fClipDistance6>0.0)
- {
- discard;
- }
- #endif`;
- ShaderStore.IncludesShadersStoreWGSL[name$2R] = shader$2R;
- var name$2Q = "clipPlaneFragmentDeclaration"
- , shader$2Q = `#ifdef CLIPPLANE
- varying fClipDistance: f32;
- #endif
- #ifdef CLIPPLANE2
- varying fClipDistance2: f32;
- #endif
- #ifdef CLIPPLANE3
- varying fClipDistance3: f32;
- #endif
- #ifdef CLIPPLANE4
- varying fClipDistance4: f32;
- #endif
- #ifdef CLIPPLANE5
- varying fClipDistance5: f32;
- #endif
- #ifdef CLIPPLANE6
- varying fClipDistance6: f32;
- #endif`;
- ShaderStore.IncludesShadersStoreWGSL[name$2Q] = shader$2Q;
- var name$2P = "clipPlaneVertex"
- , shader$2P = `#ifdef CLIPPLANE
- fClipDistance=dot(worldPos,uniforms.vClipPlane);
- #endif
- #ifdef CLIPPLANE2
- fClipDistance2=dot(worldPos,uniforms.vClipPlane2);
- #endif
- #ifdef CLIPPLANE3
- fClipDistance3=dot(worldPos,uniforms.vClipPlane3);
- #endif
- #ifdef CLIPPLANE4
- fClipDistance4=dot(worldPos,uniforms.vClipPlane4);
- #endif
- #ifdef CLIPPLANE5
- fClipDistance5=dot(worldPos,uniforms.vClipPlane5);
- #endif
- #ifdef CLIPPLANE6
- fClipDistance6=dot(worldPos,uniforms.vClipPlane6);
- #endif`;
- ShaderStore.IncludesShadersStoreWGSL[name$2P] = shader$2P;
- var name$2O = "clipPlaneVertexDeclaration"
- , shader$2O = `#ifdef CLIPPLANE
- uniform vClipPlane: vec4<f32>;
- varying fClipDistance: f32;
- #endif
- #ifdef CLIPPLANE2
- uniform vClipPlane2: vec4<f32>;
- varying fClipDistance2: f32;
- #endif
- #ifdef CLIPPLANE3
- uniform vClipPlane3: vec4<f32>;
- varying fClipDistance3: f32;
- #endif
- #ifdef CLIPPLANE4
- uniform vClipPlane4: vec4<f32>;
- varying fClipDistance4: f32;
- #endif
- #ifdef CLIPPLANE5
- uniform vClipPlane5: vec4<f32>;
- varying fClipDistance5: f32;
- #endif
- #ifdef CLIPPLANE6
- uniform vClipPlane6: vec4<f32>;
- varying fClipDistance6: f32;
- #endif`;
- ShaderStore.IncludesShadersStoreWGSL[name$2O] = shader$2O;
- var name$2N = "instancesDeclaration"
- , shader$2N = `#ifdef INSTANCES
- attribute world0 : vec4<f32>;
- attribute world1 : vec4<f32>;
- attribute world2 : vec4<f32>;
- attribute world3 : vec4<f32>;
- #if defined(THIN_INSTANCES) && !defined(WORLD_UBO)
- uniform world : mat4x4<f32>;
- #endif
- #if defined(VELOCITY) || defined(PREPASS_VELOCITY)
- attribute previousWorld0 : vec4<f32>;
- attribute previousWorld1 : vec4<f32>;
- attribute previousWorld2 : vec4<f32>;
- attribute previousWorld3 : vec4<f32>;
- #ifdef THIN_INSTANCES
- uniform previousWorld : mat4x4<f32>;
- #endif
- #endif
- #else
- #if !defined(WORLD_UBO)
- uniform world : mat4x4<f32>;
- #endif
- #if defined(VELOCITY) || defined(PREPASS_VELOCITY)
- uniform previousWorld : mat4x4<f32>;
- #endif
- #endif`;
- ShaderStore.IncludesShadersStoreWGSL[name$2N] = shader$2N;
- var name$2M = "instancesVertex"
- , shader$2M = `#ifdef INSTANCES
- var finalWorld=mat4x4<f32>(world0,world1,world2,world3);
- #if defined(PREPASS_VELOCITY) || defined(VELOCITY)
- var finalPreviousWorld=mat4x4<f32>(previousWorld0,previousWorld1,previousWorld2,previousWorld3);
- #endif
- #ifdef THIN_INSTANCES
- #if !defined(WORLD_UBO)
- finalWorld=uniforms.world*finalWorld;
- #else
- finalWorld=mesh.world*finalWorld;
- #endif
- #if defined(PREPASS_VELOCITY) || defined(VELOCITY)
- finalPreviousWorld=previousWorld*finalPreviousWorld;
- #endif
- #endif
- #else
- #if !defined(WORLD_UBO)
- var finalWorld=uniforms.world;
- #else
- var finalWorld=mesh.world;
- #endif
- #if defined(PREPASS_VELOCITY) || defined(VELOCITY)
- var finalPreviousWorld=previousWorld;
- #endif
- #endif`;
- ShaderStore.IncludesShadersStoreWGSL[name$2M] = shader$2M;
- var name$2L = "meshUboDeclaration"
- , shader$2L = `[[block]]
- struct Mesh {
- world : mat4x4<f32>;
- visibility : f32;
- };
- var<uniform> mesh : Mesh;
- #define WORLD_UBO
- `;
- ShaderStore.IncludesShadersStoreWGSL[name$2L] = shader$2L;
- var name$2K = "morphTargetsVertex"
- , shader$2K = `#ifdef MORPHTARGETS
- #ifdef MORPHTARGETS_TEXTURE
- vertexID=f32(gl_VertexID)*uniforms.morphTargetTextureInfo.x;
- positionUpdated=positionUpdated+(readVector3FromRawSampler({X},vertexID)-position)*uniforms.morphTargetInfluences[{X}];
- vertexID=vertexID+1.0;
- #ifdef MORPHTARGETS_NORMAL
- normalUpdated=normalUpdated+(readVector3FromRawSampler({X},vertexID)-normal)*uniforms.morphTargetInfluences[{X}];
- vertexID=vertexID+1.0;
- #endif
- #ifdef MORPHTARGETS_UV
- uvUpdated=uvUpdated+(readVector3FromRawSampler({X},vertexID).xy-uv)*uniforms.morphTargetInfluences[{X}];
- vertexID=vertexID+1.0;
- #endif
- #ifdef MORPHTARGETS_TANGENT
- tangentUpdated.xyz=tangentUpdated.xyz+(readVector3FromRawSampler({X},vertexID)-tangent.xyz)*uniforms.morphTargetInfluences[{X}];
- #endif
- #else
- positionUpdated=positionUpdated+(position{X}-position)*uniforms.morphTargetInfluences[{X}];
- #ifdef MORPHTARGETS_NORMAL
- normalUpdated+=(normal{X}-normal)*uniforms.morphTargetInfluences[{X}];
- #endif
- #ifdef MORPHTARGETS_TANGENT
- tangentUpdated.xyz=tangentUpdated.xyz+(tangent{X}-tangent.xyz)*uniforms.morphTargetInfluences[{X}];
- #endif
- #ifdef MORPHTARGETS_UV
- uvUpdated=uvUpdated+(uv_{X}-uv)*uniforms.morphTargetInfluences[{X}];
- #endif
- #endif
- #endif`;
- ShaderStore.IncludesShadersStoreWGSL[name$2K] = shader$2K;
- var name$2J = "morphTargetsVertexDeclaration"
- , shader$2J = `#ifdef MORPHTARGETS
- #ifndef MORPHTARGETS_TEXTURE
- attribute position{X} : vec3<f32>;
- #ifdef MORPHTARGETS_NORMAL
- attribute normal{X} : vec3<f32>;
- #endif
- #ifdef MORPHTARGETS_TANGENT
- attribute tangent{X} : vec3<f32>;
- #endif
- #ifdef MORPHTARGETS_UV
- attribute uv_{X} : vec2<f32>;
- #endif
- #endif
- #endif`;
- ShaderStore.IncludesShadersStoreWGSL[name$2J] = shader$2J;
- var name$2I = "morphTargetsVertexGlobal"
- , shader$2I = `#ifdef MORPHTARGETS
- #ifdef MORPHTARGETS_TEXTURE
- var vertexID : f32;
- #endif
- #endif`;
- ShaderStore.IncludesShadersStoreWGSL[name$2I] = shader$2I;
- var name$2H = "morphTargetsVertexGlobalDeclaration"
- , shader$2H = `#ifdef MORPHTARGETS
- uniform morphTargetInfluences : array<f32,NUM_MORPH_INFLUENCERS>;
- #ifdef MORPHTARGETS_TEXTURE
- uniform morphTargetTextureIndices : array<f32,NUM_MORPH_INFLUENCERS>;
- uniform morphTargetTextureInfo : vec3<f32>;
- var morphTargets : texture_2d_array<f32>;
- var morphTargetsSampler : sampler;
- fn readVector3FromRawSampler(targetIndex : i32,vertexIndex : f32) -> vec3<f32>
- {
- let y=floor(vertexIndex/uniforms.morphTargetTextureInfo.y);
- let x=vertexIndex-y*uniforms.morphTargetTextureInfo.y;
- let textureUV=vec2<f32>((x+0.5)/uniforms.morphTargetTextureInfo.y,(y+0.5)/uniforms.morphTargetTextureInfo.z);
- return textureSampleLevel(morphTargets,morphTargetsSampler,textureUV,i32(uniforms.morphTargetTextureIndices[targetIndex]),0.0).xyz;
- }
- #endif
- #endif`;
- ShaderStore.IncludesShadersStoreWGSL[name$2H] = shader$2H;
- var name$2G = "sceneUboDeclaration"
- , shader$2G = `[[block]]
- struct Scene {
- viewProjection : mat4x4<f32>;
- #ifdef MULTIVIEW
- viewProjectionR : mat4x4<f32>;
- #endif
- view : mat4x4<f32>;
- projection : mat4x4<f32>;
- vEyePosition : vec4<f32>;
- };
- var<uniform> scene : Scene;
- `;
- ShaderStore.IncludesShadersStoreWGSL[name$2G] = shader$2G;
- 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 = {
- texture_1d: TextureViewDimension.E1d,
- texture_2d: TextureViewDimension.E2d,
- texture_2d_array: TextureViewDimension.E2dArray,
- texture_3d: TextureViewDimension.E3d,
- texture_cube: TextureViewDimension.Cube,
- texture_cube_array: TextureViewDimension.CubeArray,
- texture_multisampled_2d: TextureViewDimension.E2d,
- texture_depth_2d: TextureViewDimension.E2d,
- texture_depth_2d_array: TextureViewDimension.E2dArray,
- texture_depth_cube: TextureViewDimension.Cube,
- texture_depth_cube_array: TextureViewDimension.CubeArray,
- texture_depth_multisampled_2d: TextureViewDimension.E2d,
- texture_storage_1d: TextureViewDimension.E1d,
- texture_storage_2d: TextureViewDimension.E2d,
- texture_storage_2d_array: TextureViewDimension.E2dArray,
- texture_storage_3d: TextureViewDimension.E3d,
- texture_external: null
- }, WebGPUShaderProcessorWGSL = function(a) {
- __extends(e, a);
- function e() {
- var i = a !== null && a.apply(this, arguments) || this;
- return i.shaderLanguage = ShaderLanguage.WGSL,
- i.uniformRegexp = /uniform\s+(\w+)\s*:\s*(.+)\s*;/,
- i.textureRegexp = /var\s+(\w+)\s*:\s*((array<\s*)?(texture_\w+)\s*(<\s*(.+)\s*>)?\s*(,\s*\w+\s*>\s*)?);/,
- i.noPrecision = !0,
- i
- }
- return e.prototype._getArraySize = function(i, o, s) {
- var c = 0
- , d = o.lastIndexOf(">");
- if (o.indexOf("array") >= 0 && d > 0) {
- for (var _ = d; _ > 0 && o.charAt(_) !== " " && o.charAt(_) !== ","; )
- _--;
- var b = o.substring(_ + 1, d);
- for (c = +b,
- isNaN(c) && (c = +s[b.trim()]); _ > 0 && (o.charAt(_) === " " || o.charAt(_) === ","); )
- _--;
- o = o.substring(o.indexOf("<") + 1, _ + 1)
- }
- return [i, o, c]
- }
- ,
- e.prototype.initializeShaders = function(i) {
- this.webgpuProcessingContext = i,
- this._attributesWGSL = [],
- this._attributesDeclWGSL = [],
- this._attributeNamesWGSL = [],
- this._varyingsWGSL = [],
- this._varyingsDeclWGSL = [],
- this._varyingNamesWGSL = []
- }
- ,
- e.prototype.preProcessShaderCode = function(i) {
- return RemoveComments(i)
- }
- ,
- e.prototype.varyingProcessor = function(i, o, s, c) {
- var d = /\s*varying\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s*:\s*(.+)\s*;/gm
- , _ = d.exec(i);
- if (_ !== null) {
- var b = _[2], k = _[1], j;
- o ? (j = this.webgpuProcessingContext.availableVaryings[k],
- 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]),
- this.webgpuProcessingContext.availableVaryings[k] = j,
- this._varyingsWGSL.push("[[location(" + j + ")]] " + k + " : " + b + ";"),
- this._varyingsDeclWGSL.push("var<private> " + k + " : " + b + ";"),
- this._varyingNamesWGSL.push(k)),
- i = ""
- }
- return i
- }
- ,
- e.prototype.attributeProcessor = function(i, o, s) {
- var c = /\s*attribute\s+(\S+)\s*:\s*(.+)\s*;/gm
- , d = c.exec(i);
- if (d !== null) {
- var _ = d[2]
- , b = d[1]
- , k = this.webgpuProcessingContext.getAttributeNextLocation(_, this._getArraySize(b, _, o)[2]);
- this.webgpuProcessingContext.availableAttributes[b] = k,
- this.webgpuProcessingContext.orderedAttributes[k] = b,
- this._attributesWGSL.push("[[location(" + k + ")]] " + b + " : " + _ + ";"),
- this._attributesDeclWGSL.push("var<private> " + b + " : " + _ + ";"),
- this._attributeNamesWGSL.push(b),
- i = ""
- }
- return i
- }
- ,
- e.prototype.uniformProcessor = function(i, o, s, c) {
- var d = this.uniformRegexp.exec(i);
- if (d !== null) {
- var _ = d[2]
- , b = d[1];
- this._addUniformToLeftOverUBO(b, _, s),
- i = ""
- }
- return i
- }
- ,
- e.prototype.textureProcessor = function(i, o, s, c) {
- var d = this.textureRegexp.exec(i);
- if (d !== null) {
- var _ = d[1]
- , b = d[2]
- , k = !!d[3]
- , j = d[4]
- , $ = j.indexOf("storage") > 0
- , _e = d[6]
- , et = $ ? _e.substring(0, _e.indexOf(",")).trim() : null
- , tt = k ? this._getArraySize(_, b, s)[2] : 0
- , rt = this.webgpuProcessingContext.availableTextures[_];
- if (rt)
- tt = rt.textures.length;
- else {
- rt = {
- isTextureArray: tt > 0,
- isStorageTexture: $,
- textures: [],
- sampleType: TextureSampleType.Float
- },
- tt = tt || 1;
- for (var it = 0; it < tt; ++it)
- rt.textures.push(this.webgpuProcessingContext.getNextFreeUBOBinding())
- }
- this.webgpuProcessingContext.availableTextures[_] = rt;
- var nt = j.indexOf("depth") > 0
- , ot = gpuTextureViewDimensionByWebGPUTextureFunction[j]
- , at = nt ? TextureSampleType.Depth : _e === "u32" ? TextureSampleType.Uint : _e === "i32" ? TextureSampleType.Sint : TextureSampleType.Float;
- if (rt.sampleType = at,
- ot === void 0)
- throw `Can't get the texture dimension corresponding to the texture function "` + j + '"!';
- for (var it = 0; it < tt; ++it) {
- var st = rt.textures[it]
- , ut = st.groupIndex
- , ct = st.bindingIndex;
- it === 0 && (i = "[[group(" + ut + "), binding(" + ct + ")]] " + i),
- this._addTextureBindingDescription(_, rt, it, ot, et, !o)
- }
- }
- return i
- }
- ,
- e.prototype.postProcessor = function(i, o, s, c, d) {
- return i
- }
- ,
- e.prototype.finalizeShaders = function(i, o, s) {
- i = this._processSamplers(i, !0),
- o = this._processSamplers(o, !1),
- i = this._processCustomBuffers(i, !0),
- o = this._processCustomBuffers(o, !1);
- var c = this._buildLeftOverUBO();
- i = c + i,
- o = c + o,
- i = i.replace(/#define /g, "//#define ");
- var d = this._varyingsDeclWGSL.join(`
- `) + `
- `
- , _ = "var<private> " + builtInName_vertex_index + ` : u32;
- var<private> ` + builtInName_instance_index + ` : u32;
- var<private> ` + builtInName_position + ` : vec4<f32>;
- `
- , b = this._attributesDeclWGSL.join(`
- `) + `
- `
- , k = `struct VertexInputs {
- [[builtin(vertex_index)]] vertexIndex : u32;
- [[builtin(instance_index)]] instanceIndex : u32;
- `;
- this._attributesWGSL.length > 0 && (k += this._attributesWGSL.join(`
- `)),
- k += `
- };
- `;
- var j = `struct FragmentInputs {
- [[builtin(position)]] position : vec4<f32>;
- `;
- this._varyingsWGSL.length > 0 && (j += this._varyingsWGSL.join(`
- `)),
- j += `
- };
- `,
- i = _ + k + b + j + d + i;
- for (var $ = ` var output : FragmentInputs;
- ` + builtInName_vertex_index + ` = input.vertexIndex;
- ` + builtInName_instance_index + ` = input.instanceIndex;
- `, _e = 0; _e < this._attributeNamesWGSL.length; ++_e) {
- var et = this._attributeNamesWGSL[_e];
- $ += " " + et + " = input." + et + `;
- `
- }
- for (var tt = " output.position = " + builtInName_position + `;
- output.position.y = -output.position.y;
- `, _e = 0; _e < this._varyingNamesWGSL.length; ++_e) {
- var rt = this._varyingNamesWGSL[_e];
- tt += " output." + rt + " = " + rt + `;
- `
- }
- tt += " return output;",
- i = this._injectStartingAndEndingCode(i, $, tt),
- o = o.replace(/#define /g, "//#define ");
- var it = "var<private> " + builtInName_position_frag + ` : vec4<f32>;
- var<private> ` + builtInName_front_facing + ` : bool;
- var<private> ` + builtInName_FragColor + ` : vec4<f32>;
- var<private> ` + builtInName_frag_depth + ` : f32;
- `
- , nt = `struct FragmentInputs {
- [[builtin(position)]] position : vec4<f32>;
- [[builtin(front_facing)]] frontFacing : bool;
- `;
- this._varyingsWGSL.length > 0 && (nt += this._varyingsWGSL.join(`
- `)),
- nt += `
- };
- `;
- for (var ot = `struct FragmentOutputs {
- [[location(0)]] color : vec4<f32>;
- `, at = !1, st = 0; !at && (st = o.indexOf(builtInName_frag_depth, st),
- !(st < 0)); ) {
- var ut = st;
- for (at = !0; st > 1 && o.charAt(st) !== `
- `; ) {
- if (o.charAt(st) === "/" && o.charAt(st - 1) === "/") {
- at = !1;
- break
- }
- st--
- }
- st = ut + 12
- }
- at && (ot += ` [[builtin(frag_depth)]] fragDepth: f32;
- `),
- ot += `};
- `,
- o = it + nt + d + ot + o;
- for (var ct = ` var output : FragmentOutputs;
- ` + builtInName_position_frag + ` = input.position;
- ` + builtInName_front_facing + ` = input.frontFacing;
- `, _e = 0; _e < this._varyingNamesWGSL.length; ++_e) {
- var lt = this._varyingNamesWGSL[_e];
- ct += " " + lt + " = input." + lt + `;
- `
- }
- var ft = " output.color = " + builtInName_FragColor + `;
- `;
- return at && (ft += " output.fragDepth = " + builtInName_frag_depth + `;
- `),
- ft += " return output;",
- o = this._injectStartingAndEndingCode(o, ct, ft),
- this._collectBindingNames(),
- this._preCreateBindGroupEntries(),
- {
- vertexCode: i,
- fragmentCode: o
- }
- }
- ,
- e.prototype._generateLeftOverUBOCode = function(i, o) {
- for (var s = "[[block]] struct " + i + ` {
- `, c = 0, d = this.webgpuProcessingContext.leftOverUniforms; c < d.length; c++) {
- var _ = d[c]
- , b = _.type.replace(/^(.*?)(<.*>)?$/, "$1")
- , k = WebGPUShaderProcessor.UniformSizes[b];
- _.length > 0 ? k <= 2 ? s += " [[align(16)]] " + _.name + " : [[stride(16)]] array<" + _.type + ", " + _.length + `>;
- ` : s += " " + _.name + " : array<" + _.type + ", " + _.length + `>;
- ` : s += " " + _.name + " : " + _.type + `;
- `
- }
- return s += `};
- `,
- s += "[[group(" + o.binding.groupIndex + "), binding(" + o.binding.bindingIndex + ")]] var<uniform> " + leftOverVarName + " : " + i + `;
- `,
- s
- }
- ,
- e.prototype._injectStartingAndEndingCode = function(i, o, s) {
- if (o) {
- var c = i.indexOf("fn main");
- if (c >= 0) {
- for (; c++ < i.length && i.charAt(c) != "{"; )
- ;
- if (c < i.length) {
- for (; c++ < i.length && i.charAt(c) != `
- `; )
- ;
- if (c < i.length) {
- var d = i.substring(0, c + 1)
- , _ = i.substring(c + 1);
- i = d + o + _
- }
- }
- }
- }
- if (s) {
- var b = i.lastIndexOf("}");
- i = i.substring(0, b),
- i += s + `
- }`
- }
- return i
- }
- ,
- e.prototype._processSamplers = function(i, o) {
- for (var s = /var\s+(\w+Sampler)\s*:\s*(sampler|sampler_comparison)\s*;/gm; ; ) {
- var c = s.exec(i);
- if (c === null)
- break;
- var d = c[1]
- , _ = c[2]
- , b = d.indexOf(WebGPUShaderProcessor.AutoSamplerSuffix) === d.length - WebGPUShaderProcessor.AutoSamplerSuffix.length ? d.substring(0, d.indexOf(WebGPUShaderProcessor.AutoSamplerSuffix)) : null
- , k = _ === "sampler_comparison" ? SamplerBindingType.Comparison : SamplerBindingType.Filtering;
- if (b) {
- var j = this.webgpuProcessingContext.availableTextures[b];
- j && (j.autoBindSampler = !0)
- }
- var $ = this.webgpuProcessingContext.availableSamplers[d];
- $ || ($ = {
- binding: this.webgpuProcessingContext.getNextFreeUBOBinding(),
- type: k
- },
- this.webgpuProcessingContext.availableSamplers[d] = $),
- this._addSamplerBindingDescription(d, $, o);
- var _e = i.substring(0, c.index)
- , et = "[[group(" + $.binding.groupIndex + "), binding(" + $.binding.bindingIndex + ")]] "
- , tt = i.substring(c.index);
- i = _e + et + tt,
- s.lastIndex += et.length
- }
- return i
- }
- ,
- e.prototype._processCustomBuffers = function(i, o) {
- for (var s = /var<\s*(uniform|storage)\s*(,\s*(read|read_write)\s*)?>\s+(\S+)\s*:\s*(\S+)\s*;/gm; ; ) {
- var c = s.exec(i);
- if (c === null)
- break;
- var d = c[1]
- , _ = c[3]
- , b = c[4]
- , k = c[5]
- , j = this.webgpuProcessingContext.availableBuffers[b];
- if (!j) {
- var $ = d === "uniform" ? WebGPUShaderProcessingContext.KnownUBOs[k] : null
- , _e = void 0;
- $ ? (b = k,
- _e = $.binding,
- _e.groupIndex === -1 && (_e = this.webgpuProcessingContext.getNextFreeUBOBinding())) : _e = this.webgpuProcessingContext.getNextFreeUBOBinding(),
- j = {
- binding: _e
- },
- this.webgpuProcessingContext.availableBuffers[b] = j
- }
- this._addBufferBindingDescription(b, this.webgpuProcessingContext.availableBuffers[b], _ === "read_write" ? BufferBindingType.Storage : d === "storage" ? BufferBindingType.ReadOnlyStorage : BufferBindingType.Uniform, o);
- var et = j.binding.groupIndex
- , tt = j.binding.bindingIndex
- , rt = i.substring(0, c.index)
- , it = "[[group(" + et + "), binding(" + tt + ")]] "
- , nt = i.substring(c.index);
- i = rt + it + nt,
- s.lastIndex += it.length
- }
- return i
- }
- ,
- e
- }(WebGPUShaderProcessor), WebGPUHardwareTexture = function() {
- function a(e) {
- e === void 0 && (e = null),
- this.format = TextureFormat.RGBA8Unorm,
- this.textureUsages = 0,
- this.textureAdditionalUsages = 0,
- this._webgpuTexture = e,
- this._webgpuMSAATexture = null,
- this.view = null
- }
- return Object.defineProperty(a.prototype, "underlyingResource", {
- get: function() {
- return this._webgpuTexture
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "msaaTexture", {
- get: function() {
- return this._webgpuMSAATexture
- },
- set: function(e) {
- this._webgpuMSAATexture = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.set = function(e) {
- this._webgpuTexture = e
- }
- ,
- a.prototype.setMSAATexture = function(e) {
- this._webgpuMSAATexture = e
- }
- ,
- a.prototype.setUsage = function(e, i, o, s, c) {
- i = e === InternalTextureSource.RenderTarget ? !1 : i,
- this.createView({
- format: this.format,
- dimension: o ? TextureViewDimension.Cube : TextureViewDimension.E2d,
- mipLevelCount: i ? Scalar.ILog2(Math.max(s, c)) + 1 : 1,
- baseArrayLayer: 0,
- baseMipLevel: 0,
- arrayLayerCount: o ? 6 : 1,
- aspect: TextureAspect.All
- })
- }
- ,
- a.prototype.createView = function(e) {
- this.view = this._webgpuTexture.createView(e)
- }
- ,
- a.prototype.reset = function() {
- this._webgpuTexture = null,
- this._webgpuMSAATexture = null,
- this.view = null
- }
- ,
- a.prototype.release = function() {
- var e, i, o;
- (e = this._webgpuTexture) === null || e === void 0 || e.destroy(),
- (i = this._webgpuMSAATexture) === null || i === void 0 || i.destroy(),
- (o = this._copyInvertYTempTexture) === null || o === void 0 || o.destroy(),
- this.reset()
- }
- ,
- a
- }(), mipmapVertexSource = `
- 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));
- 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));
- layout(location = 0) out vec2 vTex;
- void main() {
- vTex = tex[gl_VertexIndex];
- gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);
- }
- `, mipmapFragmentSource = `
- layout(set = 0, binding = 0) uniform sampler imgSampler;
- layout(set = 0, binding = 1) uniform texture2D img;
- layout(location = 0) in vec2 vTex;
- layout(location = 0) out vec4 outColor;
- void main() {
- outColor = texture(sampler2D(img, imgSampler), vTex);
- }
- `, invertYPreMultiplyAlphaVertexSource = `
- #extension GL_EXT_samplerless_texture_functions : enable
- 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));
- 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));
- layout(set = 0, binding = 0) uniform texture2D img;
- #ifdef INVERTY
- layout(location = 0) out flat ivec2 vTextureSize;
- #endif
- void main() {
- #ifdef INVERTY
- vTextureSize = textureSize(img, 0);
- #endif
- gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);
- }
- `, invertYPreMultiplyAlphaFragmentSource = `
- #extension GL_EXT_samplerless_texture_functions : enable
- layout(set = 0, binding = 0) uniform texture2D img;
- #ifdef INVERTY
- layout(location = 0) in flat ivec2 vTextureSize;
- #endif
- layout(location = 0) out vec4 outColor;
- void main() {
- #ifdef INVERTY
- vec4 color = texelFetch(img, ivec2(gl_FragCoord.x, vTextureSize.y - gl_FragCoord.y), 0);
- #else
- vec4 color = texelFetch(img, ivec2(gl_FragCoord.xy), 0);
- #endif
- #ifdef PREMULTIPLYALPHA
- color.rgb *= color.a;
- #endif
- outColor = color;
- }
- `, clearVertexSource = `
- 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));
- void main() {
- gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);
- }
- `, clearFragmentSource = `
- layout(set = 0, binding = 0) uniform Uniforms {
- uniform vec4 color;
- };
- layout(location = 0) out vec4 outColor;
- void main() {
- outColor = color;
- }
- `, PipelineType;
- (function(a) {
- a[a.MipMap = 0] = "MipMap",
- a[a.InvertYPremultiplyAlpha = 1] = "InvertYPremultiplyAlpha",
- a[a.Clear = 2] = "Clear"
- }
- )(PipelineType || (PipelineType = {}));
- var shadersForPipelineType = [{
- vertex: mipmapVertexSource,
- fragment: mipmapFragmentSource
- }, {
- vertex: invertYPreMultiplyAlphaVertexSource,
- fragment: invertYPreMultiplyAlphaFragmentSource
- }, {
- vertex: clearVertexSource,
- fragment: clearFragmentSource
- }], WebGPUTextureHelper = function() {
- function a(e, i, o, s) {
- this._pipelines = {},
- this._compiledShaders = [],
- this._deferredReleaseTextures = [],
- this._device = e,
- this._glslang = i,
- this._tintWASM = o,
- this._bufferManager = s,
- this._mipmapSampler = e.createSampler({
- minFilter: FilterMode.Linear
- }),
- this._getPipeline(TextureFormat.RGBA8Unorm)
- }
- return a.ComputeNumMipmapLevels = function(e, i) {
- return Scalar.ILog2(Math.max(e, i)) + 1
- }
- ,
- a.prototype._getPipeline = function(e, i, o) {
- i === void 0 && (i = PipelineType.MipMap);
- 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;
- this._pipelines[e] || (this._pipelines[e] = []);
- var c = this._pipelines[e][s];
- if (!c) {
- var d = `#version 450\r
- `;
- i === PipelineType.InvertYPremultiplyAlpha && (o.invertY && (d += `#define INVERTY\r
- `),
- o.premultiplyAlpha && (d += `#define PREMULTIPLYALPHA\r
- `));
- var _ = this._compiledShaders[s];
- if (!_) {
- var b = this._glslang.compileGLSL(d + shadersForPipelineType[i].vertex, "vertex")
- , k = this._glslang.compileGLSL(d + shadersForPipelineType[i].fragment, "fragment");
- this._tintWASM && (b = this._tintWASM.convertSpirV2WGSL(b),
- k = this._tintWASM.convertSpirV2WGSL(k));
- var j = this._device.createShaderModule({
- code: b
- })
- , $ = this._device.createShaderModule({
- code: k
- });
- _ = this._compiledShaders[s] = [j, $]
- }
- var _e = this._device.createRenderPipeline({
- vertex: {
- module: _[0],
- entryPoint: "main"
- },
- fragment: {
- module: _[1],
- entryPoint: "main",
- targets: [{
- format: e
- }]
- },
- primitive: {
- topology: PrimitiveTopology.TriangleStrip,
- stripIndexFormat: IndexFormat.Uint16
- }
- });
- c = this._pipelines[e][s] = [_e, _e.getBindGroupLayout(0)]
- }
- return c
- }
- ,
- a._GetTextureTypeFromFormat = function(e) {
- switch (e) {
- case TextureFormat.R8Unorm:
- case TextureFormat.R8Snorm:
- case TextureFormat.R8Uint:
- case TextureFormat.R8Sint:
- case TextureFormat.RG8Unorm:
- case TextureFormat.RG8Snorm:
- case TextureFormat.RG8Uint:
- case TextureFormat.RG8Sint:
- case TextureFormat.RGBA8Unorm:
- case TextureFormat.RGBA8UnormSRGB:
- case TextureFormat.RGBA8Snorm:
- case TextureFormat.RGBA8Uint:
- case TextureFormat.RGBA8Sint:
- case TextureFormat.BGRA8Unorm:
- case TextureFormat.BGRA8UnormSRGB:
- case TextureFormat.RGB10A2Unorm:
- case TextureFormat.RGB9E5UFloat:
- case TextureFormat.RG11B10UFloat:
- case TextureFormat.Depth24UnormStencil8:
- case TextureFormat.Depth32FloatStencil8:
- case TextureFormat.BC7RGBAUnorm:
- case TextureFormat.BC7RGBAUnormSRGB:
- case TextureFormat.BC6HRGBUFloat:
- case TextureFormat.BC6HRGBFloat:
- case TextureFormat.BC5RGUnorm:
- case TextureFormat.BC5RGSnorm:
- case TextureFormat.BC3RGBAUnorm:
- case TextureFormat.BC3RGBAUnormSRGB:
- case TextureFormat.BC2RGBAUnorm:
- case TextureFormat.BC2RGBAUnormSRGB:
- case TextureFormat.BC4RUnorm:
- case TextureFormat.BC4RSnorm:
- case TextureFormat.BC1RGBAUnorm:
- case TextureFormat.BC1RGBAUnormSRGB:
- case TextureFormat.ETC2RGB8Unorm:
- case TextureFormat.ETC2RGB8UnormSRGB:
- case TextureFormat.ETC2RGB8A1Unorm:
- case TextureFormat.ETC2RGB8A1UnormSRGB:
- case TextureFormat.ETC2RGBA8Unorm:
- case TextureFormat.ETC2RGBA8UnormSRGB:
- case TextureFormat.EACR11Unorm:
- case TextureFormat.EACR11Snorm:
- case TextureFormat.EACRG11Unorm:
- case TextureFormat.EACRG11Snorm:
- case TextureFormat.ASTC4x4Unorm:
- case TextureFormat.ASTC4x4UnormSRGB:
- case TextureFormat.ASTC5x4Unorm:
- case TextureFormat.ASTC5x4UnormSRGB:
- case TextureFormat.ASTC5x5Unorm:
- case TextureFormat.ASTC5x5UnormSRGB:
- case TextureFormat.ASTC6x5Unorm:
- case TextureFormat.ASTC6x5UnormSRGB:
- case TextureFormat.ASTC6x6Unorm:
- case TextureFormat.ASTC6x6UnormSRGB:
- case TextureFormat.ASTC8x5Unorm:
- case TextureFormat.ASTC8x5UnormSRGB:
- case TextureFormat.ASTC8x6Unorm:
- case TextureFormat.ASTC8x6UnormSRGB:
- case TextureFormat.ASTC8x8Unorm:
- case TextureFormat.ASTC8x8UnormSRGB:
- case TextureFormat.ASTC10x5Unorm:
- case TextureFormat.ASTC10x5UnormSRGB:
- case TextureFormat.ASTC10x6Unorm:
- case TextureFormat.ASTC10x6UnormSRGB:
- case TextureFormat.ASTC10x8Unorm:
- case TextureFormat.ASTC10x8UnormSRGB:
- case TextureFormat.ASTC10x10Unorm:
- case TextureFormat.ASTC10x10UnormSRGB:
- case TextureFormat.ASTC12x10Unorm:
- case TextureFormat.ASTC12x10UnormSRGB:
- case TextureFormat.ASTC12x12Unorm:
- case TextureFormat.ASTC12x12UnormSRGB:
- return 0;
- case TextureFormat.R16Uint:
- case TextureFormat.R16Sint:
- case TextureFormat.RG16Uint:
- case TextureFormat.RG16Sint:
- case TextureFormat.RGBA16Uint:
- case TextureFormat.RGBA16Sint:
- case TextureFormat.Depth16Unorm:
- return 5;
- case TextureFormat.R16Float:
- case TextureFormat.RG16Float:
- case TextureFormat.RGBA16Float:
- return 2;
- case TextureFormat.R32Uint:
- case TextureFormat.R32Sint:
- case TextureFormat.RG32Uint:
- case TextureFormat.RG32Sint:
- case TextureFormat.RGBA32Uint:
- case TextureFormat.RGBA32Sint:
- return 7;
- case TextureFormat.R32Float:
- case TextureFormat.RG32Float:
- case TextureFormat.RGBA32Float:
- case TextureFormat.Depth32Float:
- return 1;
- case TextureFormat.Stencil8:
- throw "No fixed size for Stencil8 format!";
- case TextureFormat.Depth24Plus:
- throw "No fixed size for Depth24Plus format!";
- case TextureFormat.Depth24PlusStencil8:
- throw "No fixed size for Depth24PlusStencil8 format!"
- }
- return 0
- }
- ,
- a._GetBlockInformationFromFormat = function(e) {
- switch (e) {
- case TextureFormat.R8Unorm:
- case TextureFormat.R8Snorm:
- case TextureFormat.R8Uint:
- case TextureFormat.R8Sint:
- return {
- width: 1,
- height: 1,
- length: 1
- };
- case TextureFormat.R16Uint:
- case TextureFormat.R16Sint:
- case TextureFormat.R16Float:
- case TextureFormat.RG8Unorm:
- case TextureFormat.RG8Snorm:
- case TextureFormat.RG8Uint:
- case TextureFormat.RG8Sint:
- return {
- width: 1,
- height: 1,
- length: 2
- };
- case TextureFormat.R32Uint:
- case TextureFormat.R32Sint:
- case TextureFormat.R32Float:
- case TextureFormat.RG16Uint:
- case TextureFormat.RG16Sint:
- case TextureFormat.RG16Float:
- case TextureFormat.RGBA8Unorm:
- case TextureFormat.RGBA8UnormSRGB:
- case TextureFormat.RGBA8Snorm:
- case TextureFormat.RGBA8Uint:
- case TextureFormat.RGBA8Sint:
- case TextureFormat.BGRA8Unorm:
- case TextureFormat.BGRA8UnormSRGB:
- case TextureFormat.RGB9E5UFloat:
- case TextureFormat.RGB10A2Unorm:
- case TextureFormat.RG11B10UFloat:
- return {
- width: 1,
- height: 1,
- length: 4
- };
- case TextureFormat.RG32Uint:
- case TextureFormat.RG32Sint:
- case TextureFormat.RG32Float:
- case TextureFormat.RGBA16Uint:
- case TextureFormat.RGBA16Sint:
- case TextureFormat.RGBA16Float:
- return {
- width: 1,
- height: 1,
- length: 8
- };
- case TextureFormat.RGBA32Uint:
- case TextureFormat.RGBA32Sint:
- case TextureFormat.RGBA32Float:
- return {
- width: 1,
- height: 1,
- length: 16
- };
- case TextureFormat.Stencil8:
- throw "No fixed size for Stencil8 format!";
- case TextureFormat.Depth16Unorm:
- return {
- width: 1,
- height: 1,
- length: 2
- };
- case TextureFormat.Depth24Plus:
- throw "No fixed size for Depth24Plus format!";
- case TextureFormat.Depth24PlusStencil8:
- throw "No fixed size for Depth24PlusStencil8 format!";
- case TextureFormat.Depth32Float:
- return {
- width: 1,
- height: 1,
- length: 4
- };
- case TextureFormat.Depth24UnormStencil8:
- return {
- width: 1,
- height: 1,
- length: 4
- };
- case TextureFormat.Depth32FloatStencil8:
- return {
- width: 1,
- height: 1,
- length: 5
- };
- case TextureFormat.BC7RGBAUnorm:
- case TextureFormat.BC7RGBAUnormSRGB:
- case TextureFormat.BC6HRGBUFloat:
- case TextureFormat.BC6HRGBFloat:
- case TextureFormat.BC5RGUnorm:
- case TextureFormat.BC5RGSnorm:
- case TextureFormat.BC3RGBAUnorm:
- case TextureFormat.BC3RGBAUnormSRGB:
- case TextureFormat.BC2RGBAUnorm:
- case TextureFormat.BC2RGBAUnormSRGB:
- return {
- width: 4,
- height: 4,
- length: 16
- };
- case TextureFormat.BC4RUnorm:
- case TextureFormat.BC4RSnorm:
- case TextureFormat.BC1RGBAUnorm:
- case TextureFormat.BC1RGBAUnormSRGB:
- return {
- width: 4,
- height: 4,
- length: 8
- };
- case TextureFormat.ETC2RGB8Unorm:
- case TextureFormat.ETC2RGB8UnormSRGB:
- case TextureFormat.ETC2RGB8A1Unorm:
- case TextureFormat.ETC2RGB8A1UnormSRGB:
- case TextureFormat.EACR11Unorm:
- case TextureFormat.EACR11Snorm:
- return {
- width: 4,
- height: 4,
- length: 8
- };
- case TextureFormat.ETC2RGBA8Unorm:
- case TextureFormat.ETC2RGBA8UnormSRGB:
- case TextureFormat.EACRG11Unorm:
- case TextureFormat.EACRG11Snorm:
- return {
- width: 4,
- height: 4,
- length: 16
- };
- case TextureFormat.ASTC4x4Unorm:
- case TextureFormat.ASTC4x4UnormSRGB:
- return {
- width: 4,
- height: 4,
- length: 16
- };
- case TextureFormat.ASTC5x4Unorm:
- case TextureFormat.ASTC5x4UnormSRGB:
- return {
- width: 5,
- height: 4,
- length: 16
- };
- case TextureFormat.ASTC5x5Unorm:
- case TextureFormat.ASTC5x5UnormSRGB:
- return {
- width: 5,
- height: 5,
- length: 16
- };
- case TextureFormat.ASTC6x5Unorm:
- case TextureFormat.ASTC6x5UnormSRGB:
- return {
- width: 6,
- height: 5,
- length: 16
- };
- case TextureFormat.ASTC6x6Unorm:
- case TextureFormat.ASTC6x6UnormSRGB:
- return {
- width: 6,
- height: 6,
- length: 16
- };
- case TextureFormat.ASTC8x5Unorm:
- case TextureFormat.ASTC8x5UnormSRGB:
- return {
- width: 8,
- height: 5,
- length: 16
- };
- case TextureFormat.ASTC8x6Unorm:
- case TextureFormat.ASTC8x6UnormSRGB:
- return {
- width: 8,
- height: 6,
- length: 16
- };
- case TextureFormat.ASTC8x8Unorm:
- case TextureFormat.ASTC8x8UnormSRGB:
- return {
- width: 8,
- height: 8,
- length: 16
- };
- case TextureFormat.ASTC10x5Unorm:
- case TextureFormat.ASTC10x5UnormSRGB:
- return {
- width: 10,
- height: 5,
- length: 16
- };
- case TextureFormat.ASTC10x6Unorm:
- case TextureFormat.ASTC10x6UnormSRGB:
- return {
- width: 10,
- height: 6,
- length: 16
- };
- case TextureFormat.ASTC10x8Unorm:
- case TextureFormat.ASTC10x8UnormSRGB:
- return {
- width: 10,
- height: 8,
- length: 16
- };
- case TextureFormat.ASTC10x10Unorm:
- case TextureFormat.ASTC10x10UnormSRGB:
- return {
- width: 10,
- height: 10,
- length: 16
- };
- case TextureFormat.ASTC12x10Unorm:
- case TextureFormat.ASTC12x10UnormSRGB:
- return {
- width: 12,
- height: 10,
- length: 16
- };
- case TextureFormat.ASTC12x12Unorm:
- case TextureFormat.ASTC12x12UnormSRGB:
- return {
- width: 12,
- height: 12,
- length: 16
- }
- }
- return {
- width: 1,
- height: 1,
- length: 4
- }
- }
- ,
- a._IsHardwareTexture = function(e) {
- return !!e.release
- }
- ,
- a._IsInternalTexture = function(e) {
- return !!e.dispose
- }
- ,
- a.GetCompareFunction = function(e) {
- switch (e) {
- case 519:
- return CompareFunction.Always;
- case 514:
- return CompareFunction.Equal;
- case 516:
- return CompareFunction.Greater;
- case 518:
- return CompareFunction.GreaterEqual;
- case 513:
- return CompareFunction.Less;
- case 515:
- return CompareFunction.LessEqual;
- case 512:
- return CompareFunction.Never;
- case 517:
- return CompareFunction.NotEqual;
- default:
- return CompareFunction.Less
- }
- }
- ,
- a.IsImageBitmap = function(e) {
- return e.close !== void 0
- }
- ,
- a.IsImageBitmapArray = function(e) {
- return Array.isArray(e) && e[0].close !== void 0
- }
- ,
- a.prototype.setCommandEncoder = function(e) {
- this._commandEncoderForCreation = e
- }
- ,
- a.IsCompressedFormat = function(e) {
- switch (e) {
- case TextureFormat.BC7RGBAUnormSRGB:
- case TextureFormat.BC7RGBAUnorm:
- case TextureFormat.BC6HRGBFloat:
- case TextureFormat.BC6HRGBUFloat:
- case TextureFormat.BC5RGSnorm:
- case TextureFormat.BC5RGUnorm:
- case TextureFormat.BC4RSnorm:
- case TextureFormat.BC4RUnorm:
- case TextureFormat.BC3RGBAUnormSRGB:
- case TextureFormat.BC3RGBAUnorm:
- case TextureFormat.BC2RGBAUnormSRGB:
- case TextureFormat.BC2RGBAUnorm:
- case TextureFormat.BC1RGBAUnormSRGB:
- case TextureFormat.BC1RGBAUnorm:
- case TextureFormat.ETC2RGB8Unorm:
- case TextureFormat.ETC2RGB8UnormSRGB:
- case TextureFormat.ETC2RGB8A1Unorm:
- case TextureFormat.ETC2RGB8A1UnormSRGB:
- case TextureFormat.ETC2RGBA8Unorm:
- case TextureFormat.ETC2RGBA8UnormSRGB:
- case TextureFormat.EACR11Unorm:
- case TextureFormat.EACR11Snorm:
- case TextureFormat.EACRG11Unorm:
- case TextureFormat.EACRG11Snorm:
- case TextureFormat.ASTC4x4Unorm:
- case TextureFormat.ASTC4x4UnormSRGB:
- case TextureFormat.ASTC5x4Unorm:
- case TextureFormat.ASTC5x4UnormSRGB:
- case TextureFormat.ASTC5x5Unorm:
- case TextureFormat.ASTC5x5UnormSRGB:
- case TextureFormat.ASTC6x5Unorm:
- case TextureFormat.ASTC6x5UnormSRGB:
- case TextureFormat.ASTC6x6Unorm:
- case TextureFormat.ASTC6x6UnormSRGB:
- case TextureFormat.ASTC8x5Unorm:
- case TextureFormat.ASTC8x5UnormSRGB:
- case TextureFormat.ASTC8x6Unorm:
- case TextureFormat.ASTC8x6UnormSRGB:
- case TextureFormat.ASTC8x8Unorm:
- case TextureFormat.ASTC8x8UnormSRGB:
- case TextureFormat.ASTC10x5Unorm:
- case TextureFormat.ASTC10x5UnormSRGB:
- case TextureFormat.ASTC10x6Unorm:
- case TextureFormat.ASTC10x6UnormSRGB:
- case TextureFormat.ASTC10x8Unorm:
- case TextureFormat.ASTC10x8UnormSRGB:
- case TextureFormat.ASTC10x10Unorm:
- case TextureFormat.ASTC10x10UnormSRGB:
- case TextureFormat.ASTC12x10Unorm:
- case TextureFormat.ASTC12x10UnormSRGB:
- case TextureFormat.ASTC12x12Unorm:
- case TextureFormat.ASTC12x12UnormSRGB:
- return !0
- }
- return !1
- }
- ,
- a.GetWebGPUTextureFormat = function(e, i, o) {
- switch (o === void 0 && (o = !1),
- i) {
- case 15:
- return TextureFormat.Depth16Unorm;
- case 13:
- return TextureFormat.Depth24PlusStencil8;
- case 14:
- return TextureFormat.Depth32Float;
- case 36492:
- return o ? TextureFormat.BC7RGBAUnormSRGB : TextureFormat.BC7RGBAUnorm;
- case 36495:
- return TextureFormat.BC6HRGBUFloat;
- case 36494:
- return TextureFormat.BC6HRGBFloat;
- case 33779:
- return o ? TextureFormat.BC3RGBAUnormSRGB : TextureFormat.BC3RGBAUnorm;
- case 33778:
- return o ? TextureFormat.BC2RGBAUnormSRGB : TextureFormat.BC2RGBAUnorm;
- case 33777:
- case 33776:
- return o ? TextureFormat.BC1RGBAUnormSRGB : TextureFormat.BC1RGBAUnorm;
- case 37808:
- return o ? TextureFormat.ASTC4x4UnormSRGB : TextureFormat.ASTC4x4Unorm;
- case 36196:
- return o ? TextureFormat.ETC2RGB8UnormSRGB : TextureFormat.ETC2RGB8Unorm
- }
- switch (e) {
- case 3:
- switch (i) {
- case 6:
- return TextureFormat.R8Snorm;
- case 7:
- return TextureFormat.RG8Snorm;
- case 4:
- throw "RGB format not supported in WebGPU";
- case 8:
- return TextureFormat.R8Sint;
- case 9:
- return TextureFormat.RG8Sint;
- case 10:
- throw "RGB_INTEGER format not supported in WebGPU";
- case 11:
- return TextureFormat.RGBA8Sint;
- default:
- return TextureFormat.RGBA8Snorm
- }
- case 0:
- switch (i) {
- case 6:
- return TextureFormat.R8Unorm;
- case 7:
- return TextureFormat.RG8Unorm;
- case 4:
- throw "TEXTUREFORMAT_RGB format not supported in WebGPU";
- case 5:
- return o ? TextureFormat.RGBA8UnormSRGB : TextureFormat.RGBA8Unorm;
- case 12:
- return o ? TextureFormat.BGRA8UnormSRGB : TextureFormat.BGRA8Unorm;
- case 8:
- return TextureFormat.R8Uint;
- case 9:
- return TextureFormat.RG8Uint;
- case 10:
- throw "RGB_INTEGER format not supported in WebGPU";
- case 11:
- return TextureFormat.RGBA8Uint;
- case 0:
- throw "TEXTUREFORMAT_ALPHA format not supported in WebGPU";
- case 1:
- throw "TEXTUREFORMAT_LUMINANCE format not supported in WebGPU";
- case 2:
- throw "TEXTUREFORMAT_LUMINANCE_ALPHA format not supported in WebGPU";
- default:
- return TextureFormat.RGBA8Unorm
- }
- case 4:
- switch (i) {
- case 8:
- return TextureFormat.R16Sint;
- case 9:
- return TextureFormat.RG16Sint;
- case 10:
- throw "TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";
- case 11:
- return TextureFormat.RGBA16Sint;
- default:
- return TextureFormat.RGBA16Sint
- }
- case 5:
- switch (i) {
- case 8:
- return TextureFormat.R16Uint;
- case 9:
- return TextureFormat.RG16Uint;
- case 10:
- throw "TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";
- case 11:
- return TextureFormat.RGBA16Uint;
- default:
- return TextureFormat.RGBA16Uint
- }
- case 6:
- switch (i) {
- case 8:
- return TextureFormat.R32Sint;
- case 9:
- return TextureFormat.RG32Sint;
- case 10:
- throw "TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";
- case 11:
- return TextureFormat.RGBA32Sint;
- default:
- return TextureFormat.RGBA32Sint
- }
- case 7:
- switch (i) {
- case 8:
- return TextureFormat.R32Uint;
- case 9:
- return TextureFormat.RG32Uint;
- case 10:
- throw "TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";
- case 11:
- return TextureFormat.RGBA32Uint;
- default:
- return TextureFormat.RGBA32Uint
- }
- case 1:
- switch (i) {
- case 6:
- return TextureFormat.R32Float;
- case 7:
- return TextureFormat.RG32Float;
- case 4:
- throw "TEXTUREFORMAT_RGB format not supported in WebGPU";
- case 5:
- return TextureFormat.RGBA32Float;
- default:
- return TextureFormat.RGBA32Float
- }
- case 2:
- switch (i) {
- case 6:
- return TextureFormat.R16Float;
- case 7:
- return TextureFormat.RG16Float;
- case 4:
- throw "TEXTUREFORMAT_RGB format not supported in WebGPU";
- case 5:
- return TextureFormat.RGBA16Float;
- default:
- return TextureFormat.RGBA16Float
- }
- case 10:
- throw "TEXTURETYPE_UNSIGNED_SHORT_5_6_5 format not supported in WebGPU";
- case 13:
- throw "TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV format not supported in WebGPU";
- case 14:
- throw "TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV format not supported in WebGPU";
- case 8:
- throw "TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 format not supported in WebGPU";
- case 9:
- throw "TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 format not supported in WebGPU";
- case 11:
- switch (i) {
- case 5:
- return TextureFormat.RGB10A2Unorm;
- case 11:
- throw "TEXTUREFORMAT_RGBA_INTEGER format not supported in WebGPU when type is TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV";
- default:
- return TextureFormat.RGB10A2Unorm
- }
- }
- return o ? TextureFormat.RGBA8UnormSRGB : TextureFormat.RGBA8Unorm
- }
- ,
- a.GetNumChannelsFromWebGPUTextureFormat = function(e) {
- switch (e) {
- case TextureFormat.R8Unorm:
- case TextureFormat.R8Snorm:
- case TextureFormat.R8Uint:
- case TextureFormat.R8Sint:
- case TextureFormat.BC4RUnorm:
- case TextureFormat.BC4RSnorm:
- case TextureFormat.R16Uint:
- case TextureFormat.R16Sint:
- case TextureFormat.Depth16Unorm:
- case TextureFormat.R16Float:
- case TextureFormat.R32Uint:
- case TextureFormat.R32Sint:
- case TextureFormat.R32Float:
- case TextureFormat.Depth32Float:
- case TextureFormat.Stencil8:
- case TextureFormat.Depth24Plus:
- case TextureFormat.EACR11Unorm:
- case TextureFormat.EACR11Snorm:
- return 1;
- case TextureFormat.RG8Unorm:
- case TextureFormat.RG8Snorm:
- case TextureFormat.RG8Uint:
- case TextureFormat.RG8Sint:
- case TextureFormat.Depth24UnormStencil8:
- case TextureFormat.Depth32FloatStencil8:
- case TextureFormat.BC5RGUnorm:
- case TextureFormat.BC5RGSnorm:
- case TextureFormat.RG16Uint:
- case TextureFormat.RG16Sint:
- case TextureFormat.RG16Float:
- case TextureFormat.RG32Uint:
- case TextureFormat.RG32Sint:
- case TextureFormat.RG32Float:
- case TextureFormat.Depth24PlusStencil8:
- case TextureFormat.EACRG11Unorm:
- case TextureFormat.EACRG11Snorm:
- return 2;
- case TextureFormat.RGB9E5UFloat:
- case TextureFormat.RG11B10UFloat:
- case TextureFormat.BC6HRGBUFloat:
- case TextureFormat.BC6HRGBFloat:
- case TextureFormat.ETC2RGB8Unorm:
- case TextureFormat.ETC2RGB8UnormSRGB:
- return 3;
- case TextureFormat.RGBA8Unorm:
- case TextureFormat.RGBA8UnormSRGB:
- case TextureFormat.RGBA8Snorm:
- case TextureFormat.RGBA8Uint:
- case TextureFormat.RGBA8Sint:
- case TextureFormat.BGRA8Unorm:
- case TextureFormat.BGRA8UnormSRGB:
- case TextureFormat.RGB10A2Unorm:
- case TextureFormat.BC7RGBAUnorm:
- case TextureFormat.BC7RGBAUnormSRGB:
- case TextureFormat.BC3RGBAUnorm:
- case TextureFormat.BC3RGBAUnormSRGB:
- case TextureFormat.BC2RGBAUnorm:
- case TextureFormat.BC2RGBAUnormSRGB:
- case TextureFormat.BC1RGBAUnorm:
- case TextureFormat.BC1RGBAUnormSRGB:
- case TextureFormat.RGBA16Uint:
- case TextureFormat.RGBA16Sint:
- case TextureFormat.RGBA16Float:
- case TextureFormat.RGBA32Uint:
- case TextureFormat.RGBA32Sint:
- case TextureFormat.RGBA32Float:
- case TextureFormat.ETC2RGB8A1Unorm:
- case TextureFormat.ETC2RGB8A1UnormSRGB:
- case TextureFormat.ETC2RGBA8Unorm:
- case TextureFormat.ETC2RGBA8UnormSRGB:
- case TextureFormat.ASTC4x4Unorm:
- case TextureFormat.ASTC4x4UnormSRGB:
- case TextureFormat.ASTC5x4Unorm:
- case TextureFormat.ASTC5x4UnormSRGB:
- case TextureFormat.ASTC5x5Unorm:
- case TextureFormat.ASTC5x5UnormSRGB:
- case TextureFormat.ASTC6x5Unorm:
- case TextureFormat.ASTC6x5UnormSRGB:
- case TextureFormat.ASTC6x6Unorm:
- case TextureFormat.ASTC6x6UnormSRGB:
- case TextureFormat.ASTC8x5Unorm:
- case TextureFormat.ASTC8x5UnormSRGB:
- case TextureFormat.ASTC8x6Unorm:
- case TextureFormat.ASTC8x6UnormSRGB:
- case TextureFormat.ASTC8x8Unorm:
- case TextureFormat.ASTC8x8UnormSRGB:
- case TextureFormat.ASTC10x5Unorm:
- case TextureFormat.ASTC10x5UnormSRGB:
- case TextureFormat.ASTC10x6Unorm:
- case TextureFormat.ASTC10x6UnormSRGB:
- case TextureFormat.ASTC10x8Unorm:
- case TextureFormat.ASTC10x8UnormSRGB:
- case TextureFormat.ASTC10x10Unorm:
- case TextureFormat.ASTC10x10UnormSRGB:
- case TextureFormat.ASTC12x10Unorm:
- case TextureFormat.ASTC12x10UnormSRGB:
- case TextureFormat.ASTC12x12Unorm:
- case TextureFormat.ASTC12x12UnormSRGB:
- return 4
- }
- throw "Unknown format " + e + "!"
- }
- ,
- a.prototype.invertYPreMultiplyAlpha = function(e, i, o, s, c, d, _, b, k, j, $) {
- var _e, et, tt, rt, it, nt, ot;
- c === void 0 && (c = !1),
- d === void 0 && (d = !1),
- _ === void 0 && (_ = 0),
- b === void 0 && (b = 0),
- k === void 0 && (k = 1);
- var at = j === void 0
- , st = this._getPipeline(s, PipelineType.InvertYPremultiplyAlpha, {
- invertY: c,
- premultiplyAlpha: d
- })
- , ut = st[0]
- , ct = st[1];
- _ = Math.max(_, 0),
- at && (j = this._device.createCommandEncoder({})),
- (et = (_e = j).pushDebugGroup) === null || et === void 0 || et.call(_e, "internal process texture - invertY=" + c + " premultiplyAlpha=" + d);
- var lt;
- if (a._IsHardwareTexture(e) ? (lt = e.underlyingResource,
- c && !d && k === 1 && _ === 0 || (e = void 0)) : (lt = e,
- e = void 0),
- !!lt) {
- var ft = e
- , ht = (tt = ft == null ? void 0 : ft._copyInvertYTempTexture) !== null && tt !== void 0 ? tt : this.createTexture({
- width: i,
- height: o,
- layers: 1
- }, !1, !1, !1, !1, !1, s, 1, j, TextureUsage.CopySrc | TextureUsage.RenderAttachment | TextureUsage.TextureBinding)
- , pt = (rt = ft == null ? void 0 : ft._copyInvertYRenderPassDescr) !== null && rt !== void 0 ? rt : {
- colorAttachments: [{
- view: ht.createView({
- format: s,
- dimension: TextureViewDimension.E2d,
- baseMipLevel: 0,
- mipLevelCount: 1,
- arrayLayerCount: 1,
- baseArrayLayer: 0
- }),
- loadValue: LoadOp.Load,
- storeOp: StoreOp.Store
- }]
- }
- , dt = j.beginRenderPass(pt)
- , _t = (it = ft == null ? void 0 : ft._copyInvertYBindGroupd) !== null && it !== void 0 ? it : this._device.createBindGroup({
- layout: ct,
- entries: [{
- binding: 0,
- resource: lt.createView({
- format: s,
- dimension: TextureViewDimension.E2d,
- baseMipLevel: b,
- mipLevelCount: 1,
- arrayLayerCount: k,
- baseArrayLayer: _
- })
- }]
- });
- dt.setPipeline(ut),
- dt.setBindGroup(0, _t),
- dt.draw(4, 1, 0, 0),
- dt.endPass(),
- j.copyTextureToTexture({
- texture: ht
- }, {
- texture: lt,
- mipLevel: b,
- origin: {
- x: 0,
- y: 0,
- z: _
- }
- }, {
- width: i,
- height: o,
- depthOrArrayLayers: 1
- }),
- ft ? (ft._copyInvertYTempTexture = ht,
- ft._copyInvertYRenderPassDescr = pt,
- ft._copyInvertYBindGroupd = _t) : this._deferredReleaseTextures.push([ht, null]),
- (ot = (nt = j).popDebugGroup) === null || ot === void 0 || ot.call(nt),
- at && (this._device.queue.submit([j.finish()]),
- j = null)
- }
- }
- ,
- a.prototype.copyWithInvertY = function(e, i, o, s) {
- var c, d, _, b, k = s === void 0, j = this._getPipeline(i, PipelineType.InvertYPremultiplyAlpha, {
- invertY: !0,
- premultiplyAlpha: !1
- }), $ = j[0], _e = j[1];
- k && (s = this._device.createCommandEncoder({})),
- (d = (c = s).pushDebugGroup) === null || d === void 0 || d.call(c, "internal copy texture with invertY");
- var et = s.beginRenderPass(o)
- , tt = this._device.createBindGroup({
- layout: _e,
- entries: [{
- binding: 0,
- resource: e
- }]
- });
- et.setPipeline($),
- et.setBindGroup(0, tt),
- et.draw(4, 1, 0, 0),
- et.endPass(),
- (b = (_ = s).popDebugGroup) === null || b === void 0 || b.call(_),
- k && (this._device.queue.submit([s.finish()]),
- s = null)
- }
- ,
- a.prototype.createTexture = function(e, i, o, s, c, d, _, b, k, j, $) {
- i === void 0 && (i = !1),
- o === void 0 && (o = !1),
- s === void 0 && (s = !1),
- c === void 0 && (c = !1),
- d === void 0 && (d = !1),
- _ === void 0 && (_ = TextureFormat.RGBA8Unorm),
- b === void 0 && (b = 1),
- j === void 0 && (j = -1),
- $ === void 0 && ($ = 0);
- var _e = e.layers || 1
- , et = {
- width: e.width,
- height: e.height,
- depthOrArrayLayers: _e
- }
- , tt = a.IsCompressedFormat(_)
- , rt = i ? a.ComputeNumMipmapLevels(e.width, e.height) : 1
- , it = j >= 0 ? j : TextureUsage.CopySrc | TextureUsage.CopyDst | TextureUsage.TextureBinding;
- $ |= i && !tt ? TextureUsage.CopySrc | TextureUsage.RenderAttachment : 0,
- tt || ($ |= TextureUsage.RenderAttachment | TextureUsage.CopyDst);
- var nt = this._device.createTexture({
- size: et,
- dimension: d ? TextureDimension.E3d : TextureDimension.E2d,
- format: _,
- usage: it | $,
- sampleCount: b,
- mipLevelCount: rt
- });
- return a.IsImageBitmap(e) && (this.updateTexture(e, nt, e.width, e.height, _e, _, 0, 0, s, c, 0, 0, k),
- i && o && this.generateMipmaps(nt, _, rt, 0, k)),
- nt
- }
- ,
- a.prototype.createCubeTexture = function(e, i, o, s, c, d, _, b, k, j) {
- i === void 0 && (i = !1),
- o === void 0 && (o = !1),
- s === void 0 && (s = !1),
- c === void 0 && (c = !1),
- d === void 0 && (d = TextureFormat.RGBA8Unorm),
- _ === void 0 && (_ = 1),
- k === void 0 && (k = -1),
- j === void 0 && (j = 0);
- var $ = a.IsImageBitmapArray(e) ? e[0].width : e.width
- , _e = a.IsImageBitmapArray(e) ? e[0].height : e.height
- , et = a.IsCompressedFormat(d)
- , tt = i ? a.ComputeNumMipmapLevels($, _e) : 1
- , rt = k >= 0 ? k : TextureUsage.CopySrc | TextureUsage.CopyDst | TextureUsage.TextureBinding;
- j |= i && !et ? TextureUsage.CopySrc | TextureUsage.RenderAttachment : 0,
- et || (j |= TextureUsage.RenderAttachment | TextureUsage.CopyDst);
- var it = this._device.createTexture({
- size: {
- width: $,
- height: _e,
- depthOrArrayLayers: 6
- },
- dimension: TextureDimension.E2d,
- format: d,
- usage: rt | j,
- sampleCount: _,
- mipLevelCount: tt
- });
- return a.IsImageBitmapArray(e) && (this.updateCubeTextures(e, it, $, _e, d, s, c, 0, 0, b),
- i && o && this.generateCubeMipmaps(it, d, tt, b)),
- it
- }
- ,
- a.prototype.generateCubeMipmaps = function(e, i, o, s) {
- var c, d, _, b, k = s === void 0;
- k && (s = this._device.createCommandEncoder({})),
- (d = (c = s).pushDebugGroup) === null || d === void 0 || d.call(c, "create cube mipmaps - " + o + " levels");
- for (var j = 0; j < 6; ++j)
- this.generateMipmaps(e, i, o, j, s);
- (b = (_ = s).popDebugGroup) === null || b === void 0 || b.call(_),
- k && (this._device.queue.submit([s.finish()]),
- s = null)
- }
- ,
- a.prototype.generateMipmaps = function(e, i, o, s, c) {
- var d, _, b, k, j, $, _e, et;
- s === void 0 && (s = 0);
- var tt = c === void 0
- , rt = this._getPipeline(i)
- , it = rt[0]
- , nt = rt[1];
- s = Math.max(s, 0),
- tt && (c = this._device.createCommandEncoder({})),
- (_ = (d = c).pushDebugGroup) === null || _ === void 0 || _.call(d, "create mipmaps for face #" + s + " - " + o + " levels");
- var ot;
- if (a._IsHardwareTexture(e) ? (ot = e.underlyingResource,
- e._mipmapGenRenderPassDescr = e._mipmapGenRenderPassDescr || [],
- e._mipmapGenBindGroup = e._mipmapGenBindGroup || []) : (ot = e,
- e = void 0),
- !!ot) {
- for (var at = e, st = 1; st < o; ++st) {
- 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 : {
- colorAttachments: [{
- view: ot.createView({
- format: i,
- dimension: TextureViewDimension.E2d,
- baseMipLevel: st,
- mipLevelCount: 1,
- arrayLayerCount: 1,
- baseArrayLayer: s
- }),
- loadValue: LoadOp.Load,
- storeOp: StoreOp.Store
- }]
- };
- at && (at._mipmapGenRenderPassDescr[s] = at._mipmapGenRenderPassDescr[s] || [],
- at._mipmapGenRenderPassDescr[s][st - 1] = ut);
- var ct = c.beginRenderPass(ut)
- , lt = ($ = (j = at == null ? void 0 : at._mipmapGenBindGroup[s]) === null || j === void 0 ? void 0 : j[st - 1]) !== null && $ !== void 0 ? $ : this._device.createBindGroup({
- layout: nt,
- entries: [{
- binding: 0,
- resource: this._mipmapSampler
- }, {
- binding: 1,
- resource: ot.createView({
- format: i,
- dimension: TextureViewDimension.E2d,
- baseMipLevel: st - 1,
- mipLevelCount: 1,
- arrayLayerCount: 1,
- baseArrayLayer: s
- })
- }]
- });
- at && (at._mipmapGenBindGroup[s] = at._mipmapGenBindGroup[s] || [],
- at._mipmapGenBindGroup[s][st - 1] = lt),
- ct.setPipeline(it),
- ct.setBindGroup(0, lt),
- ct.draw(4, 1, 0, 0),
- ct.endPass()
- }
- (et = (_e = c).popDebugGroup) === null || et === void 0 || et.call(_e),
- tt && (this._device.queue.submit([c.finish()]),
- c = null)
- }
- }
- ,
- a.prototype.createGPUTextureForInternalTexture = function(e, i, o, s, c) {
- e._hardwareTexture || (e._hardwareTexture = new WebGPUHardwareTexture),
- i === void 0 && (i = e.width),
- o === void 0 && (o = e.height),
- s === void 0 && (s = e.depth);
- var d = e._hardwareTexture;
- d.format = a.GetWebGPUTextureFormat(e.type, e.format, e._useSRGBBuffer),
- 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,
- d.textureAdditionalUsages = (c != null ? c : 0) & 1 ? TextureUsage.StorageBinding : 0;
- var _ = e.generateMipMaps
- , b = s || 1;
- if (e.isCube) {
- var k = this.createCubeTexture({
- width: i,
- height: o
- }, e.generateMipMaps, e.generateMipMaps, e.invertY, !1, d.format, 1, this._commandEncoderForCreation, d.textureUsages, d.textureAdditionalUsages);
- d.set(k),
- d.createView({
- format: d.format,
- dimension: TextureViewDimension.Cube,
- mipLevelCount: _ ? a.ComputeNumMipmapLevels(i, o) : 1,
- baseArrayLayer: 0,
- baseMipLevel: 0,
- arrayLayerCount: 6,
- aspect: TextureAspect.All
- })
- } else {
- var k = this.createTexture({
- width: i,
- height: o,
- layers: b
- }, e.generateMipMaps, e.generateMipMaps, e.invertY, !1, e.is3D, d.format, 1, this._commandEncoderForCreation, d.textureUsages, d.textureAdditionalUsages);
- d.set(k),
- d.createView({
- format: d.format,
- dimension: e.is2DArray ? TextureViewDimension.E2dArray : e.is3D ? TextureDimension.E3d : TextureViewDimension.E2d,
- mipLevelCount: _ ? a.ComputeNumMipmapLevels(i, o) : 1,
- baseArrayLayer: 0,
- baseMipLevel: 0,
- arrayLayerCount: e.is3D ? 1 : b,
- aspect: TextureAspect.All
- })
- }
- return e.width = e.baseWidth = i,
- e.height = e.baseHeight = o,
- e.depth = e.baseDepth = s,
- this.createMSAATexture(e, e.samples),
- d
- }
- ,
- a.prototype.createMSAATexture = function(e, i) {
- var o = e._hardwareTexture;
- if (o != null && o.msaaTexture && (this.releaseTexture(o.msaaTexture),
- o.msaaTexture = null),
- !(!o || (i != null ? i : 1) <= 1)) {
- var s = e.width
- , c = e.height
- , d = e.depth || 1;
- if (e.isCube) {
- var _ = this.createCubeTexture({
- width: s,
- height: c
- }, !1, !1, e.invertY, !1, o.format, i, this._commandEncoderForCreation, o.textureUsages, o.textureAdditionalUsages);
- o.setMSAATexture(_)
- } else {
- var _ = this.createTexture({
- width: s,
- height: c,
- layers: d
- }, !1, !1, e.invertY, !1, e.is3D, o.format, i, this._commandEncoderForCreation, o.textureUsages, o.textureAdditionalUsages);
- o.setMSAATexture(_)
- }
- }
- }
- ,
- a.prototype.updateCubeTextures = function(e, i, o, s, c, d, _, b, k, j) {
- d === void 0 && (d = !1),
- _ === void 0 && (_ = !1),
- b === void 0 && (b = 0),
- k === void 0 && (k = 0);
- for (var $ = [0, 3, 1, 4, 2, 5], _e = 0; _e < $.length; ++_e) {
- var et = e[$[_e]];
- this.updateTexture(et, i, o, s, 1, c, _e, 0, d, _, b, k, j)
- }
- }
- ,
- a.prototype.updateTexture = function(e, i, o, s, c, d, _, b, k, j, $, _e, et, tt) {
- _ === void 0 && (_ = 0),
- b === void 0 && (b = 0),
- k === void 0 && (k = !1),
- j === void 0 && (j = !1),
- $ === void 0 && ($ = 0),
- _e === void 0 && (_e = 0);
- var rt = a._IsInternalTexture(i) ? i._hardwareTexture.underlyingResource : i
- , it = a._GetBlockInformationFromFormat(d)
- , nt = a._IsInternalTexture(i) ? i._hardwareTexture : i
- , ot = {
- texture: rt,
- origin: {
- x: $,
- y: _e,
- z: Math.max(_, 0)
- },
- mipLevel: b,
- premultipliedAlpha: j
- }
- , at = {
- width: Math.ceil(o / it.width) * it.width,
- height: Math.ceil(s / it.height) * it.height,
- depthOrArrayLayers: c || 1
- };
- if (e.byteLength !== void 0) {
- e = e;
- var st = Math.ceil(o / it.width) * it.length
- , ut = Math.ceil(st / 256) * 256 === st;
- if (ut) {
- var ct = et === void 0;
- ct && (et = this._device.createCommandEncoder({}));
- var lt = this._bufferManager.createRawBuffer(e.byteLength, BufferUsage.MapWrite | BufferUsage.CopySrc, !0)
- , ft = lt.getMappedRange();
- new Uint8Array(ft).set(e),
- lt.unmap(),
- et.copyBufferToTexture({
- buffer: lt,
- offset: 0,
- bytesPerRow: st,
- rowsPerImage: s
- }, ot, at),
- ct && (this._device.queue.submit([et.finish()]),
- et = null),
- this._bufferManager.releaseBuffer(lt)
- } else
- this._device.queue.writeTexture(ot, e, {
- offset: 0,
- bytesPerRow: st,
- rowsPerImage: s
- }, at);
- (k || j) && this.invertYPreMultiplyAlpha(nt, o, s, d, k, j, _, b, c || 1, et, tt)
- } else if (e = e,
- k)
- if (ot.premultipliedAlpha = !1,
- a._IsInternalTexture(i) && $ === 0 && _e === 0 && o === i.width && s === i.height)
- this._device.queue.copyExternalImageToTexture({
- source: e
- }, ot, at),
- this.invertYPreMultiplyAlpha(nt, o, s, d, k, j, _, b, c || 1, void 0, tt);
- else {
- et = this._device.createCommandEncoder({});
- var ht = this.createTexture({
- width: o,
- height: s,
- layers: 1
- }, !1, !1, !1, !1, !1, d, 1, et, TextureUsage.CopySrc | TextureUsage.TextureBinding);
- this._deferredReleaseTextures.push([ht, null]),
- at.depthOrArrayLayers = 1,
- this._device.queue.copyExternalImageToTexture({
- source: e
- }, {
- texture: ht
- }, at),
- at.depthOrArrayLayers = c || 1,
- this.invertYPreMultiplyAlpha(ht, o, s, d, k, j, _, b, c || 1, et, tt),
- et.copyTextureToTexture({
- texture: ht
- }, ot, at),
- this._device.queue.submit([et.finish()]),
- et = null
- }
- else
- this._device.queue.copyExternalImageToTexture({
- source: e
- }, ot, at)
- }
- ,
- a.prototype.readPixels = function(e, i, o, s, c, d, _, b, k, j) {
- _ === void 0 && (_ = 0),
- b === void 0 && (b = 0),
- k === void 0 && (k = null),
- j === void 0 && (j = !1);
- var $ = a._GetBlockInformationFromFormat(d)
- , _e = Math.ceil(s / $.width) * $.length
- , et = Math.ceil(_e / 256) * 256
- , tt = et * c
- , rt = this._bufferManager.createRawBuffer(tt, BufferUsage.MapRead | BufferUsage.CopyDst)
- , it = this._device.createCommandEncoder({});
- return it.copyTextureToBuffer({
- texture: e,
- mipLevel: b,
- origin: {
- x: i,
- y: o,
- z: Math.max(_, 0)
- }
- }, {
- buffer: rt,
- offset: 0,
- bytesPerRow: et
- }, {
- width: s,
- height: c,
- depthOrArrayLayers: 1
- }),
- this._device.queue.submit([it.finish()]),
- this._bufferManager.readDataFromBuffer(rt, tt, s, c, _e, et, a._GetTextureTypeFromFormat(d), 0, k, !0, j)
- }
- ,
- a.prototype.releaseTexture = function(e) {
- if (a._IsInternalTexture(e)) {
- var i = e._hardwareTexture
- , o = e._irradianceTexture;
- this._deferredReleaseTextures.push([i, o])
- } else
- this._deferredReleaseTextures.push([e, null])
- }
- ,
- a.prototype.destroyDeferredTextures = function() {
- for (var e = 0; e < this._deferredReleaseTextures.length; ++e) {
- var i = this._deferredReleaseTextures[e]
- , o = i[0]
- , s = i[1];
- o && (a._IsHardwareTexture(o) ? o.release() : o.destroy()),
- s == null || s.dispose()
- }
- this._deferredReleaseTextures.length = 0
- }
- ,
- a
- }(), WebGPUDataBuffer = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this) || this;
- return o._buffer = i,
- o
- }
- return Object.defineProperty(e.prototype, "underlyingResource", {
- get: function() {
- return this._buffer
- },
- enumerable: !1,
- configurable: !0
- }),
- e
- }(DataBuffer), WebGPUBufferManager = function() {
- function a(e) {
- this._deferredReleaseBuffers = [],
- this._device = e
- }
- return a._IsGPUBuffer = function(e) {
- return e.underlyingResource === void 0
- }
- ,
- a.prototype.createRawBuffer = function(e, i, o) {
- o === void 0 && (o = !1);
- var s = e.byteLength !== void 0 ? e.byteLength + 3 & -4 : e + 3 & -4
- , c = {
- mappedAtCreation: o,
- size: s,
- usage: i
- };
- return this._device.createBuffer(c)
- }
- ,
- a.prototype.createBuffer = function(e, i) {
- var o = e.byteLength !== void 0
- , s = this.createRawBuffer(e, i)
- , c = new WebGPUDataBuffer(s);
- return c.references = 1,
- c.capacity = o ? e.byteLength : e,
- o && this.setSubData(c, 0, e),
- c
- }
- ,
- a.prototype.setRawData = function(e, i, o, s, c) {
- this._device.queue.writeBuffer(e, i, o.buffer, s, c)
- }
- ,
- a.prototype.setSubData = function(e, i, o, s, c) {
- s === void 0 && (s = 0),
- c === void 0 && (c = 0);
- var d = e.underlyingResource;
- c = c || o.byteLength,
- c = Math.min(c, e.capacity - i);
- var _ = o.byteOffset + s
- , b = _ + c
- , k = c + 3 & -4;
- if (k !== c) {
- var j = new Uint8Array(o.buffer.slice(_, b));
- o = new Uint8Array(k),
- o.set(j),
- s = 0,
- _ = 0,
- b = k,
- c = k
- }
- for (var $ = 1024 * 1024 * 15, _e = 0; b - (_ + _e) > $; )
- this._device.queue.writeBuffer(d, i + _e, o.buffer, _ + _e, $),
- _e += $;
- this._device.queue.writeBuffer(d, i + _e, o.buffer, _ + _e, c - _e)
- }
- ,
- a.prototype._GetHalfFloatAsFloatRGBAArrayBuffer = function(e, i, o) {
- o || (o = new Float32Array(e));
- for (var s = new Uint16Array(i); e--; )
- o[e] = FromHalfFloat(s[e]);
- return o
- }
- ,
- a.prototype.readDataFromBuffer = function(e, i, o, s, c, d, _, b, k, j, $) {
- var _e = this;
- _ === void 0 && (_ = 0),
- b === void 0 && (b = 0),
- k === void 0 && (k = null),
- j === void 0 && (j = !0),
- $ === void 0 && ($ = !1);
- var et = _ === 1 ? 2 : _ === 2 ? 1 : 0;
- return new Promise(function(tt, rt) {
- e.mapAsync(MapMode.Read, b, i).then(function() {
- var it = e.getMappedRange(b, i)
- , nt = k;
- if ($)
- nt === null ? nt = allocateAndCopyTypedBuffer(_, i, !0, it) : nt = allocateAndCopyTypedBuffer(_, nt.buffer, void 0, it);
- else if (nt === null)
- switch (et) {
- case 0:
- nt = new Uint8Array(i),
- nt.set(new Uint8Array(it));
- break;
- case 1:
- nt = _e._GetHalfFloatAsFloatRGBAArrayBuffer(i / 2, it);
- break;
- case 2:
- nt = new Float32Array(i / 4),
- nt.set(new Float32Array(it));
- break
- }
- else
- switch (et) {
- case 0:
- nt = new Uint8Array(nt.buffer),
- nt.set(new Uint8Array(it));
- break;
- case 1:
- nt = _e._GetHalfFloatAsFloatRGBAArrayBuffer(i / 2, it, k);
- break;
- case 2:
- nt = new Float32Array(nt.buffer),
- nt.set(new Float32Array(it));
- break
- }
- if (c !== d) {
- et === 1 && !$ && (c *= 2,
- d *= 2);
- for (var ot = new Uint8Array(nt.buffer), at = c, st = 0, ut = 1; ut < s; ++ut) {
- st = ut * d;
- for (var ct = 0; ct < c; ++ct)
- ot[at++] = ot[st++]
- }
- et !== 0 && !$ ? nt = new Float32Array(ot.buffer,0,at / 4) : nt = new Uint8Array(ot.buffer,0,at)
- }
- e.unmap(),
- j && _e.releaseBuffer(e),
- tt(nt)
- }, function(it) {
- return rt(it)
- })
- }
- )
- }
- ,
- a.prototype.releaseBuffer = function(e) {
- return a._IsGPUBuffer(e) ? (this._deferredReleaseBuffers.push(e),
- !0) : (e.references--,
- e.references === 0 ? (this._deferredReleaseBuffers.push(e.underlyingResource),
- !0) : !1)
- }
- ,
- a.prototype.destroyDeferredBuffers = function() {
- for (var e = 0; e < this._deferredReleaseBuffers.length; ++e)
- this._deferredReleaseBuffers[e].destroy();
- this._deferredReleaseBuffers.length = 0
- }
- ,
- a
- }(), WebGPURenderPassWrapper = function() {
- function a() {
- this.colorAttachmentGPUTextures = [],
- this.reset()
- }
- return a.prototype.reset = function(e) {
- e === void 0 && (e = !1),
- this.renderPass = null,
- e && (this.renderPassDescriptor = null,
- this.colorAttachmentViewDescriptor = null,
- this.depthAttachmentViewDescriptor = null,
- this.colorAttachmentGPUTextures = [],
- this.depthTextureFormat = void 0)
- }
- ,
- a
- }(), 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() {
- function a(e) {
- this._samplers = {},
- this._device = e,
- this.disabled = !1
- }
- return a.GetSamplerHashCode = function(e) {
- 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);
- return d
- }
- ,
- a._GetSamplerFilterDescriptor = function(e, i) {
- var o, s, c, d, _, b = e.useMipMaps;
- switch (e.samplingMode) {
- case 11:
- o = FilterMode.Linear,
- s = FilterMode.Linear,
- c = FilterMode.Nearest,
- b || (d = _ = 0);
- break;
- case 3:
- case 3:
- o = FilterMode.Linear,
- s = FilterMode.Linear,
- b ? c = FilterMode.Linear : (c = FilterMode.Nearest,
- d = _ = 0);
- break;
- case 8:
- o = FilterMode.Nearest,
- s = FilterMode.Nearest,
- b ? c = FilterMode.Linear : (c = FilterMode.Nearest,
- d = _ = 0);
- break;
- case 4:
- o = FilterMode.Nearest,
- s = FilterMode.Nearest,
- c = FilterMode.Nearest,
- b || (d = _ = 0);
- break;
- case 5:
- o = FilterMode.Nearest,
- s = FilterMode.Linear,
- c = FilterMode.Nearest,
- b || (d = _ = 0);
- break;
- case 6:
- o = FilterMode.Nearest,
- s = FilterMode.Linear,
- b ? c = FilterMode.Linear : (c = FilterMode.Nearest,
- d = _ = 0);
- break;
- case 7:
- o = FilterMode.Nearest,
- s = FilterMode.Linear,
- c = FilterMode.Nearest,
- d = _ = 0;
- break;
- case 1:
- case 1:
- o = FilterMode.Nearest,
- s = FilterMode.Nearest,
- c = FilterMode.Nearest,
- d = _ = 0;
- break;
- case 9:
- o = FilterMode.Linear,
- s = FilterMode.Nearest,
- c = FilterMode.Nearest,
- b || (d = _ = 0);
- break;
- case 10:
- o = FilterMode.Linear,
- s = FilterMode.Nearest,
- b ? c = FilterMode.Linear : (c = FilterMode.Nearest,
- d = _ = 0);
- break;
- case 2:
- case 2:
- o = FilterMode.Linear,
- s = FilterMode.Linear,
- c = FilterMode.Nearest,
- d = _ = 0;
- break;
- case 12:
- o = FilterMode.Linear,
- s = FilterMode.Nearest,
- c = FilterMode.Nearest,
- d = _ = 0;
- break;
- default:
- o = FilterMode.Nearest,
- s = FilterMode.Nearest,
- c = FilterMode.Nearest,
- d = _ = 0;
- break
- }
- return i > 1 && (d !== 0 || _ !== 0) ? {
- magFilter: FilterMode.Linear,
- minFilter: FilterMode.Linear,
- mipmapFilter: FilterMode.Linear,
- anisotropyEnabled: !0
- } : {
- magFilter: o,
- minFilter: s,
- mipmapFilter: c,
- lodMinClamp: d,
- lodMaxClamp: _
- }
- }
- ,
- a._GetWrappingMode = function(e) {
- switch (e) {
- case 1:
- return AddressMode.Repeat;
- case 0:
- return AddressMode.ClampToEdge;
- case 2:
- return AddressMode.MirrorRepeat
- }
- return AddressMode.Repeat
- }
- ,
- a._GetSamplerWrappingDescriptor = function(e) {
- return {
- addressModeU: this._GetWrappingMode(e._cachedWrapU),
- addressModeV: this._GetWrappingMode(e._cachedWrapV),
- addressModeW: this._GetWrappingMode(e._cachedWrapR)
- }
- }
- ,
- a._GetSamplerDescriptor = function(e) {
- var i = e.useMipMaps && e._cachedAnisotropicFilteringLevel && e._cachedAnisotropicFilteringLevel > 1 ? 4 : 1
- , o = this._GetSamplerFilterDescriptor(e, i);
- return __assign(__assign(__assign({}, o), this._GetSamplerWrappingDescriptor(e)), {
- compare: e._comparisonFunction ? WebGPUTextureHelper.GetCompareFunction(e._comparisonFunction) : void 0,
- maxAnisotropy: o.anisotropyEnabled ? i : 1
- })
- }
- ,
- a.prototype.getSampler = function(e, i, o) {
- if (i === void 0 && (i = !1),
- o === void 0 && (o = 0),
- this.disabled)
- return this._device.createSampler(a._GetSamplerDescriptor(e));
- i ? o = 0 : o === 0 && (o = a.GetSamplerHashCode(e));
- var s = i ? void 0 : this._samplers[o];
- return s || (s = this._device.createSampler(a._GetSamplerDescriptor(e)),
- i || (this._samplers[o] = s)),
- s
- }
- ,
- a
- }(), StatePosition;
- (function(a) {
- a[a.StencilReadMask = 0] = "StencilReadMask",
- a[a.StencilWriteMask = 1] = "StencilWriteMask",
- a[a.DepthBias = 2] = "DepthBias",
- a[a.DepthBiasSlopeScale = 3] = "DepthBiasSlopeScale",
- a[a.MRTAttachments1 = 4] = "MRTAttachments1",
- a[a.MRTAttachments2 = 5] = "MRTAttachments2",
- a[a.DepthStencilState = 6] = "DepthStencilState",
- a[a.RasterizationState = 7] = "RasterizationState",
- a[a.ColorStates = 8] = "ColorStates",
- a[a.ShaderStage = 9] = "ShaderStage",
- a[a.TextureStage = 10] = "TextureStage",
- a[a.VertexState = 11] = "VertexState",
- a[a.NumStates = 12] = "NumStates"
- }
- )(StatePosition || (StatePosition = {}));
- var textureFormatToIndex = {
- "": 0,
- r8unorm: 1,
- r8uint: 2,
- r8sint: 3,
- r16uint: 4,
- r16sint: 5,
- r16float: 6,
- rg8unorm: 7,
- rg8uint: 8,
- rg8sint: 9,
- r32uint: 10,
- r32sint: 11,
- r32float: 12,
- rg16uint: 13,
- rg16sint: 14,
- rg16float: 15,
- rgba8unorm: 16,
- "rgba8unorm-srgb": 17,
- rgba8uint: 18,
- rgba8sint: 19,
- bgra8unorm: 20,
- "bgra8unorm-srgb": 21,
- rgb10a2unorm: 22,
- rg32uint: 23,
- rg32sint: 24,
- rg32float: 25,
- rgba16uint: 26,
- rgba16sint: 27,
- rgba16float: 28,
- rgba32uint: 29,
- rgba32sint: 30,
- rgba32float: 31,
- stencil8: 32,
- depth16unorm: 33,
- depth24plus: 34,
- "depth24plus-stencil8": 35,
- depth32float: 36,
- "depth24unorm-stencil8": 37,
- "depth32float-stencil8": 38
- }
- , alphaBlendFactorToIndex = {
- 0: 1,
- 1: 2,
- 768: 3,
- 769: 4,
- 770: 5,
- 771: 6,
- 772: 7,
- 773: 8,
- 774: 9,
- 775: 10,
- 776: 11,
- 32769: 12,
- 32770: 13,
- 32771: 12,
- 32772: 13
- }
- , stencilOpToIndex = {
- 0: 0,
- 7680: 1,
- 7681: 2,
- 7682: 3,
- 7683: 4,
- 5386: 5,
- 34055: 6,
- 34056: 7
- }
- , WebGPUCacheRenderPipeline = function() {
- function a(e, i, o) {
- this._device = e,
- this._useTextureStage = o,
- this._states = new Array(30),
- this._statesLength = 0,
- this._stateDirtyLowestIndex = 0,
- this._emptyVertexBuffer = i,
- this._mrtFormats = [],
- this._parameter = {
- token: void 0,
- pipeline: null
- },
- this.disabled = !1,
- this.vertexBuffers = [],
- this._kMaxVertexBufferStride = e.limits.maxVertexBufferArrayStride || 2048,
- this.reset()
- }
- return a.prototype.reset = function() {
- this._isDirty = !0,
- this.vertexBuffers.length = 0,
- this.setAlphaToCoverage(!1),
- this.resetDepthCullingState(),
- this.setClampDepth(!1),
- this.setDepthBias(0),
- this._webgpuColorFormat = [TextureFormat.BGRA8Unorm],
- this.setColorFormat(TextureFormat.BGRA8Unorm),
- this.setMRTAttachments([], []),
- this.setAlphaBlendEnabled(!1),
- this.setAlphaBlendFactors([null, null, null, null], [null, null]),
- this.setWriteMask(15),
- this.setDepthStencilFormat(TextureFormat.Depth24PlusStencil8),
- this.setStencilEnabled(!1),
- this.resetStencilState(),
- this.setBuffers(null, null, null),
- this._setTextureState(0)
- }
- ,
- Object.defineProperty(a.prototype, "colorFormats", {
- get: function() {
- return this._mrtAttachments1 > 0 ? this._mrtFormats : this._webgpuColorFormat
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.getRenderPipeline = function(e, i, o, s) {
- if (s === void 0 && (s = 0),
- this.disabled) {
- var c = a._GetTopology(e);
- return this._setVertexState(i),
- this._parameter.pipeline = this._createRenderPipeline(i, c, o),
- a.NumCacheMiss++,
- a._NumPipelineCreationCurrentFrame++,
- this._parameter.pipeline
- }
- if (this._setShaderStage(i.uniqueId),
- this._setRasterizationState(e, o),
- this._setColorStates(),
- this._setDepthStencilState(),
- this._setVertexState(i),
- this._setTextureState(s),
- this.lastStateDirtyLowestIndex = this._stateDirtyLowestIndex,
- !this._isDirty && this._parameter.pipeline)
- return this._stateDirtyLowestIndex = this._statesLength,
- a.NumCacheHitWithoutHash++,
- this._parameter.pipeline;
- if (this._getRenderPipeline(this._parameter),
- this._isDirty = !1,
- this._stateDirtyLowestIndex = this._statesLength,
- this._parameter.pipeline)
- return a.NumCacheHitWithHash++,
- this._parameter.pipeline;
- var d = a._GetTopology(e);
- return this._parameter.pipeline = this._createRenderPipeline(i, d, o),
- this._setRenderPipeline(this._parameter),
- a.NumCacheMiss++,
- a._NumPipelineCreationCurrentFrame++,
- this._parameter.pipeline
- }
- ,
- a.prototype.endFrame = function() {
- a.NumPipelineCreationLastFrame = a._NumPipelineCreationCurrentFrame,
- a._NumPipelineCreationCurrentFrame = 0
- }
- ,
- a.prototype.setAlphaToCoverage = function(e) {
- this._alphaToCoverageEnabled = e
- }
- ,
- a.prototype.setFrontFace = function(e) {
- this._frontFace = e
- }
- ,
- a.prototype.setCullEnabled = function(e) {
- this._cullEnabled = e
- }
- ,
- a.prototype.setCullFace = function(e) {
- this._cullFace = e
- }
- ,
- a.prototype.setClampDepth = function(e) {
- this._clampDepth = e
- }
- ,
- a.prototype.resetDepthCullingState = function() {
- this.setDepthCullingState(!1, 2, 1, 0, 0, !0, !0, 519)
- }
- ,
- a.prototype.setDepthCullingState = function(e, i, o, s, c, d, _, b) {
- this._depthWriteEnabled = _,
- this._depthTestEnabled = d,
- this._depthCompare = (b != null ? b : 519) - 512,
- this._cullFace = o,
- this._cullEnabled = e,
- this._frontFace = i,
- this.setDepthBiasSlopeScale(s),
- this.setDepthBias(c)
- }
- ,
- a.prototype.setDepthBias = function(e) {
- this._depthBias !== e && (this._depthBias = e,
- this._states[StatePosition.DepthBias] = e,
- this._isDirty = !0,
- this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.DepthBias))
- }
- ,
- a.prototype.setDepthBiasSlopeScale = function(e) {
- this._depthBiasSlopeScale !== e && (this._depthBiasSlopeScale = e,
- this._states[StatePosition.DepthBiasSlopeScale] = e,
- this._isDirty = !0,
- this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.DepthBiasSlopeScale))
- }
- ,
- a.prototype.setColorFormat = function(e) {
- this._webgpuColorFormat[0] = e,
- this._colorFormat = textureFormatToIndex[e]
- }
- ,
- a.prototype.setMRTAttachments = function(e, i) {
- var o;
- if (e.length > 10)
- throw "Can't handle more than 10 attachments for a MRT in cache render pipeline!";
- this.mrtAttachments = e,
- this.mrtTextureArray = i;
- for (var s = [0, 0], c = 0, d = 0, _ = 0, b = 0; b < e.length; ++b) {
- var k = e[b];
- if (k !== 0) {
- var j = i[k - 1]
- , $ = j == null ? void 0 : j._hardwareTexture;
- this._mrtFormats[_] = (o = $ == null ? void 0 : $.format) !== null && o !== void 0 ? o : this._webgpuColorFormat[0],
- s[c] += textureFormatToIndex[this._mrtFormats[_]] << d,
- d += 6,
- _++,
- d >= 32 && (d = 0,
- c++)
- }
- }
- this._mrtFormats.length = _,
- (this._mrtAttachments1 !== s[0] || this._mrtAttachments2 !== s[1]) && (this._mrtAttachments1 = s[0],
- this._mrtAttachments2 = s[1],
- this._states[StatePosition.MRTAttachments1] = s[0],
- this._states[StatePosition.MRTAttachments2] = s[1],
- this._isDirty = !0,
- this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.MRTAttachments1))
- }
- ,
- a.prototype.setAlphaBlendEnabled = function(e) {
- this._alphaBlendEnabled = e
- }
- ,
- a.prototype.setAlphaBlendFactors = function(e, i) {
- this._alphaBlendFuncParams = e,
- this._alphaBlendEqParams = i
- }
- ,
- a.prototype.setWriteMask = function(e) {
- this._writeMask = e
- }
- ,
- a.prototype.setDepthStencilFormat = function(e) {
- this._webgpuDepthStencilFormat = e,
- this._depthStencilFormat = e === void 0 ? 0 : textureFormatToIndex[e]
- }
- ,
- a.prototype.setDepthTestEnabled = function(e) {
- this._depthTestEnabled = e
- }
- ,
- a.prototype.setDepthWriteEnabled = function(e) {
- this._depthWriteEnabled = e
- }
- ,
- a.prototype.setDepthCompare = function(e) {
- this._depthCompare = (e != null ? e : 519) - 512
- }
- ,
- a.prototype.setStencilEnabled = function(e) {
- this._stencilEnabled = e
- }
- ,
- a.prototype.setStencilCompare = function(e) {
- this._stencilFrontCompare = (e != null ? e : 519) - 512
- }
- ,
- a.prototype.setStencilDepthFailOp = function(e) {
- this._stencilFrontDepthFailOp = e === null ? 1 : stencilOpToIndex[e]
- }
- ,
- a.prototype.setStencilPassOp = function(e) {
- this._stencilFrontPassOp = e === null ? 2 : stencilOpToIndex[e]
- }
- ,
- a.prototype.setStencilFailOp = function(e) {
- this._stencilFrontFailOp = e === null ? 1 : stencilOpToIndex[e]
- }
- ,
- a.prototype.setStencilReadMask = function(e) {
- this._stencilReadMask !== e && (this._stencilReadMask = e,
- this._states[StatePosition.StencilReadMask] = e,
- this._isDirty = !0,
- this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.StencilReadMask))
- }
- ,
- a.prototype.setStencilWriteMask = function(e) {
- this._stencilWriteMask !== e && (this._stencilWriteMask = e,
- this._states[StatePosition.StencilWriteMask] = e,
- this._isDirty = !0,
- this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.StencilWriteMask))
- }
- ,
- a.prototype.resetStencilState = function() {
- this.setStencilState(!1, 519, 7680, 7681, 7680, 255, 255)
- }
- ,
- a.prototype.setStencilState = function(e, i, o, s, c, d, _) {
- this._stencilEnabled = e,
- this._stencilFrontCompare = (i != null ? i : 519) - 512,
- this._stencilFrontDepthFailOp = o === null ? 1 : stencilOpToIndex[o],
- this._stencilFrontPassOp = s === null ? 2 : stencilOpToIndex[s],
- this._stencilFrontFailOp = c === null ? 1 : stencilOpToIndex[c],
- this.setStencilReadMask(d),
- this.setStencilWriteMask(_)
- }
- ,
- a.prototype.setBuffers = function(e, i, o) {
- this._vertexBuffers = e,
- this._overrideVertexBuffers = o,
- this._indexBuffer = i
- }
- ,
- a._GetTopology = function(e) {
- switch (e) {
- case 0:
- return PrimitiveTopology.TriangleList;
- case 2:
- return PrimitiveTopology.PointList;
- case 1:
- return PrimitiveTopology.LineList;
- case 3:
- return PrimitiveTopology.PointList;
- case 4:
- return PrimitiveTopology.LineList;
- case 5:
- throw "LineLoop is an unsupported fillmode in WebGPU";
- case 6:
- return PrimitiveTopology.LineStrip;
- case 7:
- return PrimitiveTopology.TriangleStrip;
- case 8:
- throw "TriangleFan is an unsupported fillmode in WebGPU";
- default:
- return PrimitiveTopology.TriangleList
- }
- }
- ,
- a._GetAphaBlendOperation = function(e) {
- switch (e) {
- case 32774:
- return BlendOperation.Add;
- case 32778:
- return BlendOperation.Subtract;
- case 32779:
- return BlendOperation.ReverseSubtract;
- case 32775:
- return BlendOperation.Min;
- case 32776:
- return BlendOperation.Max;
- default:
- return BlendOperation.Add
- }
- }
- ,
- a._GetAphaBlendFactor = function(e) {
- switch (e) {
- case 0:
- return BlendFactor.Zero;
- case 1:
- return BlendFactor.One;
- case 768:
- return BlendFactor.Src;
- case 769:
- return BlendFactor.OneMinusSrc;
- case 770:
- return BlendFactor.SrcAlpha;
- case 771:
- return BlendFactor.OneMinusSrcAlpha;
- case 772:
- return BlendFactor.DstAlpha;
- case 773:
- return BlendFactor.OneMinusDstAlpha;
- case 774:
- return BlendFactor.Dst;
- case 775:
- return BlendFactor.OneMinusDst;
- case 776:
- return BlendFactor.SrcAlphaSaturated;
- case 32769:
- return BlendFactor.Constant;
- case 32770:
- return BlendFactor.OneMinusConstant;
- case 32771:
- return BlendFactor.Constant;
- case 32772:
- return BlendFactor.OneMinusConstant;
- default:
- return BlendFactor.One
- }
- }
- ,
- a._GetCompareFunction = function(e) {
- switch (e) {
- case 0:
- return CompareFunction.Never;
- case 1:
- return CompareFunction.Less;
- case 2:
- return CompareFunction.Equal;
- case 3:
- return CompareFunction.LessEqual;
- case 4:
- return CompareFunction.Greater;
- case 5:
- return CompareFunction.NotEqual;
- case 6:
- return CompareFunction.GreaterEqual;
- case 7:
- return CompareFunction.Always
- }
- return CompareFunction.Never
- }
- ,
- a._GetStencilOpFunction = function(e) {
- switch (e) {
- case 0:
- return StencilOperation.Zero;
- case 1:
- return StencilOperation.Keep;
- case 2:
- return StencilOperation.Replace;
- case 3:
- return StencilOperation.IncrementClamp;
- case 4:
- return StencilOperation.DecrementClamp;
- case 5:
- return StencilOperation.Invert;
- case 6:
- return StencilOperation.IncrementWrap;
- case 7:
- return StencilOperation.DecrementWrap
- }
- return StencilOperation.Keep
- }
- ,
- a._GetVertexInputDescriptorFormat = function(e) {
- var i = e.type
- , o = e.normalized
- , s = e.getSize();
- switch (i) {
- case VertexBuffer.BYTE:
- switch (s) {
- case 1:
- case 2:
- return o ? VertexFormat.Snorm8x2 : VertexFormat.Sint8x2;
- case 3:
- case 4:
- return o ? VertexFormat.Snorm8x4 : VertexFormat.Sint8x4
- }
- break;
- case VertexBuffer.UNSIGNED_BYTE:
- switch (s) {
- case 1:
- case 2:
- return o ? VertexFormat.Unorm8x2 : VertexFormat.Uint8x2;
- case 3:
- case 4:
- return o ? VertexFormat.Unorm8x4 : VertexFormat.Uint8x4
- }
- break;
- case VertexBuffer.SHORT:
- switch (s) {
- case 1:
- case 2:
- return o ? VertexFormat.Snorm16x2 : VertexFormat.Sint16x2;
- case 3:
- case 4:
- return o ? VertexFormat.Snorm16x4 : VertexFormat.Sint16x4
- }
- break;
- case VertexBuffer.UNSIGNED_SHORT:
- switch (s) {
- case 1:
- case 2:
- return o ? VertexFormat.Unorm16x2 : VertexFormat.Uint16x2;
- case 3:
- case 4:
- return o ? VertexFormat.Unorm16x4 : VertexFormat.Uint16x4
- }
- break;
- case VertexBuffer.INT:
- switch (s) {
- case 1:
- return VertexFormat.Sint32;
- case 2:
- return VertexFormat.Sint32x2;
- case 3:
- return VertexFormat.Sint32x3;
- case 4:
- return VertexFormat.Sint32x4
- }
- break;
- case VertexBuffer.UNSIGNED_INT:
- switch (s) {
- case 1:
- return VertexFormat.Uint32;
- case 2:
- return VertexFormat.Uint32x2;
- case 3:
- return VertexFormat.Uint32x3;
- case 4:
- return VertexFormat.Uint32x4
- }
- break;
- case VertexBuffer.FLOAT:
- switch (s) {
- case 1:
- return VertexFormat.Float32;
- case 2:
- return VertexFormat.Float32x2;
- case 3:
- return VertexFormat.Float32x3;
- case 4:
- return VertexFormat.Float32x4
- }
- break
- }
- throw new Error("Invalid Format '" + e.getKind() + "' - type=" + i + ", normalized=" + o + ", size=" + s)
- }
- ,
- a.prototype._getAphaBlendState = function() {
- return this._alphaBlendEnabled ? {
- srcFactor: a._GetAphaBlendFactor(this._alphaBlendFuncParams[2]),
- dstFactor: a._GetAphaBlendFactor(this._alphaBlendFuncParams[3]),
- operation: a._GetAphaBlendOperation(this._alphaBlendEqParams[1])
- } : null
- }
- ,
- a.prototype._getColorBlendState = function() {
- return this._alphaBlendEnabled ? {
- srcFactor: a._GetAphaBlendFactor(this._alphaBlendFuncParams[0]),
- dstFactor: a._GetAphaBlendFactor(this._alphaBlendFuncParams[1]),
- operation: a._GetAphaBlendOperation(this._alphaBlendEqParams[0])
- } : null
- }
- ,
- a.prototype._setShaderStage = function(e) {
- this._shaderId !== e && (this._shaderId = e,
- this._states[StatePosition.ShaderStage] = e,
- this._isDirty = !0,
- this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.ShaderStage))
- }
- ,
- a.prototype._setRasterizationState = function(e, i) {
- var o = this._frontFace
- , s = this._cullEnabled ? this._cullFace : 0
- , c = this._clampDepth ? 1 : 0
- , d = this._alphaToCoverageEnabled ? 1 : 0
- , _ = o - 1 + (s << 1) + (c << 3) + (d << 4) + (e << 5) + (i << 8);
- this._rasterizationState !== _ && (this._rasterizationState = _,
- this._states[StatePosition.RasterizationState] = this._rasterizationState,
- this._isDirty = !0,
- this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.RasterizationState))
- }
- ,
- a.prototype._setColorStates = function() {
- var e = ((this._writeMask ? 1 : 0) << 22) + (this._colorFormat << 23) + ((this._depthWriteEnabled ? 1 : 0) << 29);
- 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)),
- e !== this._colorStates && (this._colorStates = e,
- this._states[StatePosition.ColorStates] = this._colorStates,
- this._isDirty = !0,
- this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.ColorStates))
- }
- ,
- a.prototype._setDepthStencilState = function() {
- var e = this._stencilEnabled ? this._stencilFrontCompare + (this._stencilFrontDepthFailOp << 3) + (this._stencilFrontPassOp << 6) + (this._stencilFrontFailOp << 9) : 591
- , i = this._depthStencilFormat + ((this._depthTestEnabled ? this._depthCompare : 7) << 6) + (e << 10);
- this._depthStencilState !== i && (this._depthStencilState = i,
- this._states[StatePosition.DepthStencilState] = this._depthStencilState,
- this._isDirty = !0,
- this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.DepthStencilState))
- }
- ,
- a.prototype._setVertexState = function(e) {
- 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; $++) {
- var _e = b[$]
- , et = (i = this._overrideVertexBuffers && this._overrideVertexBuffers[_[$]]) !== null && i !== void 0 ? i : this._vertexBuffers[_[$]];
- et || (et = this._emptyVertexBuffer);
- var tt = (o = et.getBuffer()) === null || o === void 0 ? void 0 : o.underlyingResource;
- if (et._validOffsetRange === void 0) {
- var rt = et.byteOffset
- , it = et.getSize(!0)
- , nt = et.byteStride;
- et._validOffsetRange = rt <= this._kMaxVertexBufferStride - it && (nt === 0 || rt + it <= nt)
- }
- k && k === tt && et._validOffsetRange || (this.vertexBuffers[j++] = et,
- k = et._validOffsetRange ? tt : null);
- var ot = et.hashCode + (_e << 7);
- this._isDirty = this._isDirty || this._states[c] !== ot,
- this._states[c++] = ot
- }
- this.vertexBuffers.length = j,
- this._statesLength = c,
- this._isDirty = this._isDirty || c !== s,
- this._isDirty && (this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.VertexState))
- }
- ,
- a.prototype._setTextureState = function(e) {
- this._textureState !== e && (this._textureState = e,
- this._states[StatePosition.TextureStage] = this._textureState,
- this._isDirty = !0,
- this._stateDirtyLowestIndex = Math.min(this._stateDirtyLowestIndex, StatePosition.TextureStage))
- }
- ,
- a.prototype._createPipelineLayout = function(e) {
- if (this._useTextureStage)
- return this._createPipelineLayoutWithTextureStage(e);
- for (var i = [], o = e.shaderProcessingContext.bindGroupLayoutEntries, s = 0; s < o.length; s++) {
- var c = o[s];
- i[s] = this._device.createBindGroupLayout({
- entries: c
- })
- }
- return e.bindGroupLayouts = i,
- this._device.createPipelineLayout({
- bindGroupLayouts: i
- })
- }
- ,
- a.prototype._createPipelineLayoutWithTextureStage = function(e) {
- for (var i, o = e.shaderProcessingContext, s = o.bindGroupLayoutEntries, c = 1, d = 0; d < s.length; d++)
- for (var _ = s[d], b = 0; b < _.length; b++) {
- var k = s[d][b];
- if (k.texture) {
- var j = o.bindGroupLayoutEntryInfo[d][k.binding].name
- , $ = o.availableTextures[j]
- , _e = $.autoBindSampler ? o.availableSamplers[j + WebGPUShaderProcessor.AutoSamplerSuffix] : null
- , et = $.sampleType
- , tt = (i = _e == null ? void 0 : _e.type) !== null && i !== void 0 ? i : SamplerBindingType.Filtering;
- if (this._textureState & c && et !== TextureSampleType.Depth && ($.autoBindSampler && (tt = SamplerBindingType.NonFiltering),
- et = TextureSampleType.UnfilterableFloat),
- k.texture.sampleType = et,
- _e) {
- var rt = o.bindGroupLayoutEntryInfo[_e.binding.groupIndex][_e.binding.bindingIndex].index;
- s[_e.binding.groupIndex][rt].sampler.type = tt
- }
- c = c << 1
- }
- }
- for (var it = [], d = 0; d < s.length; ++d)
- it[d] = this._device.createBindGroupLayout({
- entries: s[d]
- });
- return e.bindGroupLayouts = it,
- this._device.createPipelineLayout({
- bindGroupLayouts: it
- })
- }
- ,
- a.prototype._getVertexInputDescriptor = function(e, i) {
- for (var o, s, c = [], d = e._pipelineContext, _ = d.shaderProcessingContext.attributeNamesFromEffect, b = d.shaderProcessingContext.attributeLocationsFromEffect, k, j, $ = 0; $ < _.length; $++) {
- var _e = b[$]
- , et = (o = this._overrideVertexBuffers && this._overrideVertexBuffers[_[$]]) !== null && o !== void 0 ? o : this._vertexBuffers[_[$]];
- et || (et = this._emptyVertexBuffer);
- var tt = (s = et.getBuffer()) === null || s === void 0 ? void 0 : s.underlyingResource
- , rt = et.byteOffset
- , it = !et._validOffsetRange;
- if (!(k && j && k === tt) || it) {
- var nt = {
- arrayStride: et.byteStride,
- stepMode: et.getIsInstanced() ? InputStepMode.Instance : InputStepMode.Vertex,
- attributes: []
- };
- c.push(nt),
- j = nt.attributes,
- it && (rt = 0,
- tt = null)
- }
- j.push({
- shaderLocation: _e,
- offset: rt,
- format: a._GetVertexInputDescriptorFormat(et)
- }),
- k = tt
- }
- return c
- }
- ,
- a.prototype._createRenderPipeline = function(e, i, o) {
- var s = e._pipelineContext
- , c = this._getVertexInputDescriptor(e, i)
- , d = this._createPipelineLayout(s)
- , _ = []
- , b = this._getAphaBlendState()
- , k = this._getColorBlendState();
- if (this._mrtAttachments1 > 0)
- for (var j = 0; j < this._mrtFormats.length; ++j) {
- var $ = {
- format: this._mrtFormats[j],
- writeMask: this._writeMask
- };
- b && k && ($.blend = {
- alpha: b,
- color: k
- }),
- _.push($)
- }
- else {
- var $ = {
- format: this._webgpuColorFormat[0],
- writeMask: this._writeMask
- };
- b && k && ($.blend = {
- alpha: b,
- color: k
- }),
- _.push($)
- }
- var _e = {
- compare: a._GetCompareFunction(this._stencilEnabled ? this._stencilFrontCompare : 7),
- depthFailOp: a._GetStencilOpFunction(this._stencilEnabled ? this._stencilFrontDepthFailOp : 1),
- failOp: a._GetStencilOpFunction(this._stencilEnabled ? this._stencilFrontFailOp : 1),
- passOp: a._GetStencilOpFunction(this._stencilEnabled ? this._stencilFrontPassOp : 1)
- }
- , et = void 0;
- return (i === PrimitiveTopology.LineStrip || i === PrimitiveTopology.TriangleStrip) && (et = !this._indexBuffer || this._indexBuffer.is32Bits ? IndexFormat.Uint32 : IndexFormat.Uint16),
- this._device.createRenderPipeline({
- layout: d,
- vertex: {
- module: s.stages.vertexStage.module,
- entryPoint: s.stages.vertexStage.entryPoint,
- buffers: c
- },
- primitive: {
- topology: i,
- stripIndexFormat: et,
- frontFace: this._frontFace === 1 ? FrontFace.CCW : FrontFace.CW,
- cullMode: this._cullEnabled ? this._cullFace === 2 ? CullMode.Front : CullMode.Back : CullMode.None
- },
- fragment: s.stages.fragmentStage ? {
- module: s.stages.fragmentStage.module,
- entryPoint: s.stages.fragmentStage.entryPoint,
- targets: _
- } : void 0,
- multisample: {
- count: o
- },
- depthStencil: this._webgpuDepthStencilFormat === void 0 ? void 0 : {
- depthWriteEnabled: this._depthWriteEnabled,
- depthCompare: this._depthTestEnabled ? a._GetCompareFunction(this._depthCompare) : CompareFunction.Always,
- format: this._webgpuDepthStencilFormat,
- stencilFront: _e,
- stencilBack: _e,
- stencilReadMask: this._stencilReadMask,
- stencilWriteMask: this._stencilWriteMask,
- depthBias: this._depthBias,
- depthBiasClamp: this._depthBiasClamp,
- depthBiasSlopeScale: this._depthBiasSlopeScale
- }
- })
- }
- ,
- a.NumCacheHitWithoutHash = 0,
- a.NumCacheHitWithHash = 0,
- a.NumCacheMiss = 0,
- a.NumPipelineCreationLastFrame = 0,
- a._NumPipelineCreationCurrentFrame = 0,
- a
- }()
- , NodeState = function() {
- function a() {
- this.values = {}
- }
- return a.prototype.count = function() {
- var e = 0
- , i = this.pipeline ? 1 : 0;
- for (var o in this.values) {
- var s = this.values[o]
- , c = s.count()
- , d = c[0]
- , _ = c[1];
- e += d,
- i += _,
- e++
- }
- return [e, i]
- }
- ,
- a
- }()
- , WebGPUCacheRenderPipelineTree = function(a) {
- __extends(e, a);
- function e(i, o, s) {
- var c = a.call(this, i, o, s) || this;
- return c._nodeStack = [],
- c._nodeStack[0] = e._Cache,
- c
- }
- return e.GetNodeCounts = function() {
- var i = e._Cache.count();
- return {
- nodeCount: i[0],
- pipelineCount: i[1]
- }
- }
- ,
- e._GetPipelines = function(i, o, s, c) {
- if (i.pipeline) {
- var d = s.slice();
- d.length = c,
- o.push(d)
- }
- for (var _ in i.values) {
- var b = i.values[_];
- s[c] = parseInt(_),
- e._GetPipelines(b, o, s, c + 1)
- }
- }
- ,
- e.GetPipelines = function() {
- var i = [];
- return e._GetPipelines(e._Cache, i, [], 0),
- i
- }
- ,
- e.prototype._getRenderPipeline = function(i) {
- for (var o = this._nodeStack[this._stateDirtyLowestIndex], s = this._stateDirtyLowestIndex; s < this._statesLength; ++s) {
- var c = o.values[this._states[s]];
- c || (c = new NodeState,
- o.values[this._states[s]] = c),
- o = c,
- this._nodeStack[s + 1] = o
- }
- i.token = o,
- i.pipeline = o.pipeline
- }
- ,
- e.prototype._setRenderPipeline = function(i) {
- i.token.pipeline = i.pipeline
- }
- ,
- e._Cache = new NodeState,
- e
- }(WebGPUCacheRenderPipeline)
- , WebGPUStencilStateComposer = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, !1) || this;
- return o._cache = i,
- o.reset(),
- o
- }
- return Object.defineProperty(e.prototype, "func", {
- get: function() {
- return this._func
- },
- set: function(i) {
- this._func !== i && (this._func = i,
- this._cache.setStencilCompare(i))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "funcMask", {
- get: function() {
- return this._funcMask
- },
- set: function(i) {
- this._funcMask !== i && (this._funcMask = i,
- this._cache.setStencilReadMask(i))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "opStencilFail", {
- get: function() {
- return this._opStencilFail
- },
- set: function(i) {
- this._opStencilFail !== i && (this._opStencilFail = i,
- this._cache.setStencilFailOp(i))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "opDepthFail", {
- get: function() {
- return this._opDepthFail
- },
- set: function(i) {
- this._opDepthFail !== i && (this._opDepthFail = i,
- this._cache.setStencilDepthFailOp(i))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "opStencilDepthPass", {
- get: function() {
- return this._opStencilDepthPass
- },
- set: function(i) {
- this._opStencilDepthPass !== i && (this._opStencilDepthPass = i,
- this._cache.setStencilPassOp(i))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "mask", {
- get: function() {
- return this._mask
- },
- set: function(i) {
- this._mask !== i && (this._mask = i,
- this._cache.setStencilWriteMask(i))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "enabled", {
- get: function() {
- return this._enabled
- },
- set: function(i) {
- this._enabled !== i && (this._enabled = i,
- this._cache.setStencilEnabled(i))
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.reset = function() {
- a.prototype.reset.call(this),
- this._cache.resetStencilState()
- }
- ,
- e.prototype.apply = function(i) {
- var o, s = (o = this.stencilMaterial) === null || o === void 0 ? void 0 : o.enabled;
- this.enabled = s ? this.stencilMaterial.enabled : this.stencilGlobal.enabled,
- this.enabled && (this.func = s ? this.stencilMaterial.func : this.stencilGlobal.func,
- this.funcRef = s ? this.stencilMaterial.funcRef : this.stencilGlobal.funcRef,
- this.funcMask = s ? this.stencilMaterial.funcMask : this.stencilGlobal.funcMask,
- this.opStencilFail = s ? this.stencilMaterial.opStencilFail : this.stencilGlobal.opStencilFail,
- this.opDepthFail = s ? this.stencilMaterial.opDepthFail : this.stencilGlobal.opDepthFail,
- this.opStencilDepthPass = s ? this.stencilMaterial.opStencilDepthPass : this.stencilGlobal.opStencilDepthPass,
- this.mask = s ? this.stencilMaterial.mask : this.stencilGlobal.mask)
- }
- ,
- e
- }(StencilStateComposer)
- , WebGPUDepthCullingState = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, !1) || this;
- return o._cache = i,
- o.reset(),
- o
- }
- return Object.defineProperty(e.prototype, "zOffset", {
- get: function() {
- return this._zOffset
- },
- set: function(i) {
- this._zOffset !== i && (this._zOffset = i,
- this._isZOffsetDirty = !0,
- this._cache.setDepthBiasSlopeScale(i))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "zOffsetUnits", {
- get: function() {
- return this._zOffsetUnits
- },
- set: function(i) {
- this._zOffsetUnits !== i && (this._zOffsetUnits = i,
- this._isZOffsetDirty = !0,
- this._cache.setDepthBias(i))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cullFace", {
- get: function() {
- return this._cullFace
- },
- set: function(i) {
- this._cullFace !== i && (this._cullFace = i,
- this._isCullFaceDirty = !0,
- this._cache.setCullFace(i != null ? i : 1))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cull", {
- get: function() {
- return this._cull
- },
- set: function(i) {
- this._cull !== i && (this._cull = i,
- this._isCullDirty = !0,
- this._cache.setCullEnabled(!!i))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "depthFunc", {
- get: function() {
- return this._depthFunc
- },
- set: function(i) {
- this._depthFunc !== i && (this._depthFunc = i,
- this._isDepthFuncDirty = !0,
- this._cache.setDepthCompare(i))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "depthMask", {
- get: function() {
- return this._depthMask
- },
- set: function(i) {
- this._depthMask !== i && (this._depthMask = i,
- this._isDepthMaskDirty = !0,
- this._cache.setDepthWriteEnabled(i))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "depthTest", {
- get: function() {
- return this._depthTest
- },
- set: function(i) {
- this._depthTest !== i && (this._depthTest = i,
- this._isDepthTestDirty = !0,
- this._cache.setDepthTestEnabled(i))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "frontFace", {
- get: function() {
- return this._frontFace
- },
- set: function(i) {
- this._frontFace !== i && (this._frontFace = i,
- this._isFrontFaceDirty = !0,
- this._cache.setFrontFace(i != null ? i : 2))
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.reset = function() {
- a.prototype.reset.call(this),
- this._cache.resetDepthCullingState()
- }
- ,
- e.prototype.apply = function(i) {}
- ,
- e
- }(DepthCullingState)
- , ExternalTexture = function() {
- function a(e) {
- this.useMipMaps = !1,
- this.type = 16,
- this._video = e,
- this.uniqueId = InternalTexture._Counter++
- }
- return a.IsExternalTexture = function(e) {
- return e.underlyingResource !== void 0
- }
- ,
- a.prototype.getClassName = function() {
- return "ExternalTexture"
- }
- ,
- Object.defineProperty(a.prototype, "underlyingResource", {
- get: function() {
- return this._video
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.isReady = function() {
- return this._video.readyState >= this._video.HAVE_CURRENT_DATA
- }
- ,
- a.prototype.dispose = function() {}
- ,
- a
- }()
- , WebGPUMaterialContext = function() {
- function a() {
- this.uniqueId = a._Counter++,
- this.updateId = 0,
- this.reset()
- }
- return Object.defineProperty(a.prototype, "forceBindGroupCreation", {
- get: function() {
- return this._numExternalTextures > 0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "hasFloatTextures", {
- get: function() {
- return this._numFloatTextures > 0
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.reset = function() {
- this.samplers = {},
- this.textures = {},
- this.isDirty = !0,
- this._numFloatTextures = 0,
- this._numExternalTextures = 0
- }
- ,
- a.prototype.setSampler = function(e, i) {
- var o = this.samplers[e]
- , s = -1;
- o ? s = o.hashCode : this.samplers[e] = o = {
- sampler: i,
- hashCode: 0
- },
- o.sampler = i,
- o.hashCode = i ? WebGPUCacheSampler.GetSamplerHashCode(i) : 0;
- var c = s !== o.hashCode;
- c && this.updateId++,
- this.isDirty || (this.isDirty = c)
- }
- ,
- a.prototype.setTexture = function(e, i) {
- var o, s, c, d = this.textures[e], _ = -1;
- d ? _ = (s = (o = d.texture) === null || o === void 0 ? void 0 : o.uniqueId) !== null && s !== void 0 ? s : -1 : this.textures[e] = d = {
- texture: i,
- isFloatTexture: !1,
- isExternalTexture: !1
- },
- d.isExternalTexture && this._numExternalTextures--,
- d.isFloatTexture && this._numFloatTextures--,
- i ? (d.isFloatTexture = i.type === 1,
- d.isExternalTexture = ExternalTexture.IsExternalTexture(i),
- d.isFloatTexture && this._numFloatTextures++,
- d.isExternalTexture && this._numExternalTextures++) : (d.isFloatTexture = !1,
- d.isExternalTexture = !1),
- d.texture = i;
- var b = _ !== ((c = i == null ? void 0 : i.uniqueId) !== null && c !== void 0 ? c : -1);
- b && this.updateId++,
- this.isDirty || (this.isDirty = b)
- }
- ,
- a._Counter = 0,
- a
- }()
- , WebGPUDrawContext = function() {
- function a(e) {
- this._bufferManager = e,
- this.uniqueId = a._Counter++,
- this._useInstancing = !1,
- this._currentInstanceCount = 0,
- this.reset()
- }
- return a.prototype.isDirty = function(e) {
- return this._isDirty || this.materialContextUpdateId !== e
- }
- ,
- a.prototype.resetIsDirty = function(e) {
- this._isDirty = !1,
- this.materialContextUpdateId = e
- }
- ,
- Object.defineProperty(a.prototype, "useInstancing", {
- get: function() {
- return this._useInstancing
- },
- set: function(e) {
- this._useInstancing !== e && (e ? (this.indirectDrawBuffer = this._bufferManager.createRawBuffer(40, BufferUsage.CopyDst | BufferUsage.Indirect),
- this._indirectDrawData = new Uint32Array(5),
- this._indirectDrawData[3] = 0,
- this._indirectDrawData[4] = 0) : (this.indirectDrawBuffer && this._bufferManager.releaseBuffer(this.indirectDrawBuffer),
- this.indirectDrawBuffer = void 0,
- this._indirectDrawData = void 0),
- this._useInstancing = e,
- this._currentInstanceCount = -1)
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.reset = function() {
- this.buffers = {},
- this._isDirty = !0,
- this.materialContextUpdateId = 0,
- this.fastBundle = void 0,
- this.bindGroups = void 0
- }
- ,
- a.prototype.setBuffer = function(e, i) {
- var o;
- this._isDirty || (this._isDirty = (i == null ? void 0 : i.uniqueId) !== ((o = this.buffers[e]) === null || o === void 0 ? void 0 : o.uniqueId)),
- this.buffers[e] = i
- }
- ,
- a.prototype.setIndirectData = function(e, i, o) {
- i === this._currentInstanceCount || !this.indirectDrawBuffer || !this._indirectDrawData || (this._currentInstanceCount = i,
- this._indirectDrawData[0] = e,
- this._indirectDrawData[1] = i,
- this._indirectDrawData[2] = o,
- this._bufferManager.setRawData(this.indirectDrawBuffer, 0, this._indirectDrawData, 0, 20))
- }
- ,
- a.prototype.dispose = function() {
- this.indirectDrawBuffer && (this._bufferManager.releaseBuffer(this.indirectDrawBuffer),
- this.indirectDrawBuffer = void 0,
- this._indirectDrawData = void 0),
- this.fastBundle = void 0,
- this.bindGroups = void 0,
- this.buffers = void 0
- }
- ,
- a._Counter = 0,
- a
- }()
- , WebGPUBindGroupCacheNode = function() {
- function a() {
- this.values = {}
- }
- return a
- }()
- , WebGPUCacheBindGroups = function() {
- function a(e, i, o) {
- this.disabled = !1,
- this._device = e,
- this._cacheSampler = i,
- this._engine = o
- }
- return Object.defineProperty(a, "Statistics", {
- get: function() {
- return {
- totalCreated: a.NumBindGroupsCreatedTotal,
- lastFrameCreated: a.NumBindGroupsCreatedLastFrame,
- lookupLastFrame: a.NumBindGroupsLookupLastFrame,
- noLookupLastFrame: a.NumBindGroupsNoLookupLastFrame
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.endFrame = function() {
- a.NumBindGroupsCreatedLastFrame = a._NumBindGroupsCreatedCurrentFrame,
- a.NumBindGroupsLookupLastFrame = a._NumBindGroupsLookupCurrentFrame,
- a.NumBindGroupsNoLookupLastFrame = a._NumBindGroupsNoLookupCurrentFrame,
- a._NumBindGroupsCreatedCurrentFrame = 0,
- a._NumBindGroupsLookupCurrentFrame = 0,
- a._NumBindGroupsNoLookupCurrentFrame = 0
- }
- ,
- a.prototype.getBindGroups = function(e, i, o) {
- var s, c, d, _, b, k, j, $, _e, et, tt = void 0, rt = a._Cache, it = this.disabled || o.forceBindGroupCreation;
- if (!it) {
- if (!i.isDirty(o.updateId) && !o.isDirty)
- return a._NumBindGroupsNoLookupCurrentFrame++,
- i.bindGroups;
- for (var nt = 0, ot = e.shaderProcessingContext.bufferNames; nt < ot.length; nt++) {
- var at = ot[nt]
- , st = (c = (s = i.buffers[at]) === null || s === void 0 ? void 0 : s.uniqueId) !== null && c !== void 0 ? c : 0
- , ut = rt.values[st];
- ut || (ut = new WebGPUBindGroupCacheNode,
- rt.values[st] = ut),
- rt = ut
- }
- for (var ct = 0, lt = e.shaderProcessingContext.samplerNames; ct < lt.length; ct++) {
- var ft = lt[ct]
- , ht = (_ = (d = o.samplers[ft]) === null || d === void 0 ? void 0 : d.hashCode) !== null && _ !== void 0 ? _ : 0
- , ut = rt.values[ht];
- ut || (ut = new WebGPUBindGroupCacheNode,
- rt.values[ht] = ut),
- rt = ut
- }
- for (var pt = 0, dt = e.shaderProcessingContext.textureNames; pt < dt.length; pt++) {
- var _t = dt[pt]
- , 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
- , ut = rt.values[mt];
- ut || (ut = new WebGPUBindGroupCacheNode,
- rt.values[mt] = ut),
- rt = ut
- }
- tt = rt.bindGroups
- }
- if (i.resetIsDirty(o.updateId),
- o.isDirty = !1,
- tt)
- return i.bindGroups = tt,
- a._NumBindGroupsLookupCurrentFrame++,
- tt;
- tt = [],
- i.bindGroups = tt,
- it || (rt.bindGroups = tt),
- a.NumBindGroupsCreatedTotal++,
- a._NumBindGroupsCreatedCurrentFrame++;
- for (var vt = e.bindGroupLayouts, yt = 0; yt < e.shaderProcessingContext.bindGroupLayoutEntries.length; yt++) {
- for (var Et = e.shaderProcessingContext.bindGroupLayoutEntries[yt], At = e.shaderProcessingContext.bindGroupEntries[yt], gt = 0; gt < Et.length; gt++) {
- var St = e.shaderProcessingContext.bindGroupLayoutEntries[yt][gt]
- , xt = e.shaderProcessingContext.bindGroupLayoutEntryInfo[yt][St.binding]
- , bt = ($ = xt.nameInArrayOfTexture) !== null && $ !== void 0 ? $ : xt.name;
- if (St.sampler) {
- var Rt = o.samplers[bt];
- if (Rt) {
- var Mt = Rt.sampler;
- if (!Mt) {
- 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) {
- return wt === "texture" ? "<no dump>" : Nt
- }) + ", materialContext.uniqueId=" + o.uniqueId, 50);
- continue
- }
- At[gt].resource = this._cacheSampler.getSampler(Mt, !1, Rt.hashCode)
- } else
- Logger$2.Error('Sampler "' + bt + '" could not be bound. entry=' + JSON.stringify(St) + ", materialContext=" + JSON.stringify(o, function(wt, Nt) {
- return wt === "texture" || wt === "sampler" ? "<no dump>" : Nt
- }), 50)
- } else if (St.texture || St.storageTexture) {
- var Rt = o.textures[bt];
- if (Rt) {
- if (this._engine.dbgSanityChecks && Rt.texture === null) {
- Logger$2.Error("Trying to bind a null texture! entry=" + JSON.stringify(St) + ", bindingInfo=" + JSON.stringify(Rt, function(Nt, Ft) {
- return Nt === "texture" ? "<no dump>" : Ft
- }) + ", materialContext.uniqueId=" + o.uniqueId, 50);
- continue
- }
- var Pt = Rt.texture._hardwareTexture;
- if (this._engine.dbgSanityChecks && (!Pt || !Pt.view)) {
- Logger$2.Error("Trying to bind a null gpu texture! entry=" + JSON.stringify(St) + ", name=" + bt + ", bindingInfo=" + JSON.stringify(Rt, function(Nt, Ft) {
- return Nt === "texture" ? "<no dump>" : Ft
- }) + ", isReady=" + ((_e = Rt.texture) === null || _e === void 0 ? void 0 : _e.isReady) + ", materialContext.uniqueId=" + o.uniqueId, 50);
- continue
- }
- At[gt].resource = Pt.view
- } else
- Logger$2.Error('Texture "' + bt + '" could not be bound. entry=' + JSON.stringify(St) + ", materialContext=" + JSON.stringify(o, function(Nt, Ft) {
- return Nt === "texture" || Nt === "sampler" ? "<no dump>" : Ft
- }), 50)
- } else if (St.externalTexture) {
- var Rt = o.textures[bt];
- if (Rt) {
- if (this._engine.dbgSanityChecks && Rt.texture === null) {
- Logger$2.Error("Trying to bind a null external texture! entry=" + JSON.stringify(St) + ", name=" + bt + ", bindingInfo=" + JSON.stringify(Rt, function(Nt, Ft) {
- return Nt === "texture" ? "<no dump>" : Ft
- }) + ", materialContext.uniqueId=" + o.uniqueId, 50);
- continue
- }
- var It = Rt.texture.underlyingResource;
- if (this._engine.dbgSanityChecks && !It) {
- Logger$2.Error("Trying to bind a null gpu external texture! entry=" + JSON.stringify(St) + ", name=" + bt + ", bindingInfo=" + JSON.stringify(Rt, function(Nt, Ft) {
- return Nt === "texture" ? "<no dump>" : Ft
- }) + ", isReady=" + ((et = Rt.texture) === null || et === void 0 ? void 0 : et.isReady) + ", materialContext.uniqueId=" + o.uniqueId, 50);
- continue
- }
- At[gt].resource = this._device.importExternalTexture({
- source: It
- })
- } else
- Logger$2.Error('Texture "' + bt + '" could not be bound. entry=' + JSON.stringify(St) + ", materialContext=" + JSON.stringify(o, function(Nt, Ft) {
- return Nt === "texture" || Nt === "sampler" ? "<no dump>" : Ft
- }), 50)
- } else if (St.buffer) {
- var Dt = i.buffers[bt];
- if (Dt) {
- var Ct = Dt.underlyingResource;
- At[gt].resource.buffer = Ct,
- At[gt].resource.size = Dt.capacity
- } else
- Logger$2.Error(`Can't find buffer "` + bt + '". entry=' + JSON.stringify(St) + ", buffers=" + JSON.stringify(i.buffers) + ", drawContext.uniqueId=" + i.uniqueId, 50)
- }
- }
- var Ot = vt[yt];
- tt[yt] = this._device.createBindGroup({
- layout: Ot,
- entries: At
- })
- }
- return tt
- }
- ,
- a.NumBindGroupsCreatedTotal = 0,
- a.NumBindGroupsCreatedLastFrame = 0,
- a.NumBindGroupsLookupLastFrame = 0,
- a.NumBindGroupsNoLookupLastFrame = 0,
- a._Cache = new WebGPUBindGroupCacheNode,
- a._NumBindGroupsCreatedCurrentFrame = 0,
- a._NumBindGroupsLookupCurrentFrame = 0,
- a._NumBindGroupsNoLookupCurrentFrame = 0,
- a
- }()
- , name$2F = "clearQuadVertexShader"
- , shader$2F = `uniform float depthValue;
- const vec2 pos[4]={
- vec2(-1.0,1.0),
- vec2(1.0,1.0),
- vec2(-1.0,-1.0),
- vec2(1.0,-1.0)
- };
- void main(void) {
- gl_Position=vec4(pos[gl_VertexID],depthValue,1.0);
- }
- `;
- ShaderStore.ShadersStore[name$2F] = shader$2F;
- var name$2E = "clearQuadPixelShader"
- , shader$2E = `uniform vec4 color;
- void main() {
- gl_FragColor=color;
- }
- `;
- ShaderStore.ShadersStore[name$2E] = shader$2E;
- var WebGPUClearQuad = function() {
- function a(e, i, o) {
- this._bindGroups = {},
- this._bundleCache = {},
- this._device = e,
- this._engine = i,
- this._cacheRenderPipeline = new WebGPUCacheRenderPipelineTree(this._device,o,!i._caps.textureFloatLinearFiltering),
- this._cacheRenderPipeline.setDepthTestEnabled(!1),
- this._cacheRenderPipeline.setStencilReadMask(255),
- this._effect = i.createEffect("clearQuad", [], ["color", "depthValue"])
- }
- return a.prototype.setDepthStencilFormat = function(e) {
- this._depthTextureFormat = e,
- this._cacheRenderPipeline.setDepthStencilFormat(e)
- }
- ,
- a.prototype.setColorFormat = function(e) {
- this._cacheRenderPipeline.setColorFormat(e)
- }
- ,
- a.prototype.setMRTAttachments = function(e, i) {
- this._cacheRenderPipeline.setMRTAttachments(e, i)
- }
- ,
- a.prototype.clear = function(e, i, o, s, c) {
- var d, _;
- c === void 0 && (c = 1);
- var b, k = null, j = 0;
- if (e)
- b = e;
- else {
- 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),
- k = this._bundleCache[j],
- k)
- return k;
- b = this._device.createRenderBundleEncoder({
- colorFormats: this._cacheRenderPipeline.colorFormats,
- depthStencilFormat: this._depthTextureFormat,
- sampleCount: c
- })
- }
- this._cacheRenderPipeline.setDepthWriteEnabled(!!o),
- this._cacheRenderPipeline.setStencilEnabled(!!s),
- this._cacheRenderPipeline.setStencilWriteMask(s ? 255 : 0),
- this._cacheRenderPipeline.setStencilCompare(s ? 519 : 512),
- this._cacheRenderPipeline.setStencilPassOp(s ? 7681 : 7680),
- this._cacheRenderPipeline.setWriteMask(i ? 15 : 0);
- var $ = this._cacheRenderPipeline.getRenderPipeline(7, this._effect, c)
- , _e = this._effect._pipelineContext;
- i && this._effect.setDirectColor4("color", i),
- this._effect.setFloat("depthValue", this._engine.useReverseDepthBuffer ? this._engine._clearReverseDepthValue : this._engine._clearDepthValue),
- (d = _e.uniformBuffer) === null || d === void 0 || d.update();
- var et = (_ = _e.uniformBuffer) === null || _ === void 0 ? void 0 : _.getBuffer()
- , tt = this._bindGroups[et.uniqueId];
- if (!tt) {
- var rt = _e.bindGroupLayouts;
- tt = this._bindGroups[et.uniqueId] = [],
- tt.push(this._device.createBindGroup({
- layout: rt[0],
- entries: []
- })),
- WebGPUShaderProcessingContext._SimplifiedKnownBindings || tt.push(this._device.createBindGroup({
- layout: rt[1],
- entries: []
- })),
- tt.push(this._device.createBindGroup({
- layout: rt[WebGPUShaderProcessingContext._SimplifiedKnownBindings ? 1 : 2],
- entries: [{
- binding: 0,
- resource: {
- buffer: et.underlyingResource,
- size: et.capacity
- }
- }]
- }))
- }
- b.setPipeline($);
- for (var it = 0; it < tt.length; ++it)
- b.setBindGroup(it, tt[it]);
- return b.draw(4, 1, 0, 0),
- e || (k = b.finish(),
- this._bundleCache[j] = k),
- k
- }
- ,
- a
- }()
- , WebGPURenderItemViewport = function() {
- function a(e, i, o, s) {
- this.x = Math.floor(e),
- this.y = Math.floor(i),
- this.w = Math.floor(o),
- this.h = Math.floor(s)
- }
- return a.prototype.run = function(e) {
- e.setViewport(this.x, this.y, this.w, this.h, 0, 1)
- }
- ,
- a.prototype.clone = function() {
- return new a(this.x,this.y,this.w,this.h)
- }
- ,
- a
- }()
- , WebGPURenderItemScissor = function() {
- function a(e, i, o, s) {
- this.x = e,
- this.y = i,
- this.w = o,
- this.h = s
- }
- return a.prototype.run = function(e) {
- e.setScissorRect(this.x, this.y, this.w, this.h)
- }
- ,
- a.prototype.clone = function() {
- return new a(this.x,this.y,this.w,this.h)
- }
- ,
- a
- }()
- , WebGPURenderItemStencilRef = function() {
- function a(e) {
- this.ref = e
- }
- return a.prototype.run = function(e) {
- e.setStencilReference(this.ref)
- }
- ,
- a.prototype.clone = function() {
- return new a(this.ref)
- }
- ,
- a
- }()
- , WebGPURenderItemBlendColor = function() {
- function a(e) {
- this.color = e
- }
- return a.prototype.run = function(e) {
- e.setBlendConstant(this.color)
- }
- ,
- a.prototype.clone = function() {
- return new a(this.color)
- }
- ,
- a
- }()
- , WebGPURenderItemBeginOcclusionQuery = function() {
- function a(e) {
- this.query = e
- }
- return a.prototype.run = function(e) {
- e.beginOcclusionQuery(this.query)
- }
- ,
- a.prototype.clone = function() {
- return new a(this.query)
- }
- ,
- a
- }()
- , WebGPURenderItemEndOcclusionQuery = function() {
- function a() {}
- return a.prototype.run = function(e) {
- e.endOcclusionQuery()
- }
- ,
- a.prototype.clone = function() {
- return new a
- }
- ,
- a
- }()
- , WebGPURenderItemBundles = function() {
- function a() {
- this.bundles = []
- }
- return a.prototype.run = function(e) {
- e.executeBundles(this.bundles)
- }
- ,
- a.prototype.clone = function() {
- var e = new a;
- return e.bundles = this.bundles,
- e
- }
- ,
- a
- }()
- , WebGPUBundleList = function() {
- function a(e) {
- this.numDrawCalls = 0,
- this._device = e,
- this._list = new Array(10),
- this._listLength = 0
- }
- return a.prototype.addBundle = function(e) {
- if (!this._currentItemIsBundle) {
- var i = new WebGPURenderItemBundles;
- this._list[this._listLength++] = i,
- this._currentBundleList = i.bundles,
- this._currentItemIsBundle = !0
- }
- e && this._currentBundleList.push(e)
- }
- ,
- a.prototype._finishBundle = function() {
- this._currentItemIsBundle && this._bundleEncoder && (this._currentBundleList.push(this._bundleEncoder.finish()),
- this._bundleEncoder = void 0,
- this._currentItemIsBundle = !1)
- }
- ,
- a.prototype.addItem = function(e) {
- this._finishBundle(),
- this._list[this._listLength++] = e,
- this._currentItemIsBundle = !1
- }
- ,
- a.prototype.getBundleEncoder = function(e, i, o) {
- return this._currentItemIsBundle || (this.addBundle(),
- this._bundleEncoder = this._device.createRenderBundleEncoder({
- colorFormats: e,
- depthStencilFormat: i,
- sampleCount: o
- })),
- this._bundleEncoder
- }
- ,
- a.prototype.close = function() {
- this._finishBundle()
- }
- ,
- a.prototype.run = function(e) {
- this.close();
- for (var i = 0; i < this._listLength; ++i)
- this._list[i].run(e)
- }
- ,
- a.prototype.reset = function() {
- this._listLength = 0,
- this._currentItemIsBundle = !1,
- this.numDrawCalls = 0
- }
- ,
- a.prototype.clone = function() {
- this.close();
- var e = new a(this._device);
- e._list = new Array(this._listLength),
- e._listLength = this._listLength,
- e.numDrawCalls = this.numDrawCalls;
- for (var i = 0; i < this._listLength; ++i)
- e._list[i] = this._list[i].clone();
- return e
- }
- ,
- a
- }()
- , WebGPUQuerySet = function() {
- function a(e, i, o, s, c) {
- c === void 0 && (c = !0),
- this._dstBuffers = [],
- this._device = o,
- this._bufferManager = s,
- this._count = e,
- this._canUseMultipleBuffers = c,
- this._querySet = o.createQuerySet({
- type: i,
- count: e
- }),
- this._queryBuffer = s.createRawBuffer(8 * e, BufferUsage.QueryResolve | BufferUsage.CopySrc),
- c || this._dstBuffers.push(this._bufferManager.createRawBuffer(8 * this._count, BufferUsage.MapRead | BufferUsage.CopyDst))
- }
- return Object.defineProperty(a.prototype, "querySet", {
- get: function() {
- return this._querySet
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._getBuffer = function(e, i) {
- if (!this._canUseMultipleBuffers && this._dstBuffers.length === 0)
- return null;
- var o = this._device.createCommandEncoder(), s;
- return this._dstBuffers.length === 0 ? s = this._bufferManager.createRawBuffer(8 * this._count, BufferUsage.MapRead | BufferUsage.CopyDst) : (s = this._dstBuffers[this._dstBuffers.length - 1],
- this._dstBuffers.length--),
- o.resolveQuerySet(this._querySet, e, i, this._queryBuffer, 0),
- o.copyBufferToBuffer(this._queryBuffer, 0, s, 0, 8 * i),
- this._device.queue.submit([o.finish()]),
- s
- }
- ,
- a.prototype.readValues = function(e, i) {
- return e === void 0 && (e = 0),
- i === void 0 && (i = 1),
- __awaiter(this, void 0, void 0, function() {
- var o, s;
- return __generator(this, function(c) {
- switch (c.label) {
- case 0:
- return o = this._getBuffer(e, i),
- o === null ? [2, null] : [4, o.mapAsync(MapMode.Read)];
- case 1:
- return c.sent(),
- s = new BigUint64Array(o.getMappedRange()).slice(),
- o.unmap(),
- this._dstBuffers[this._dstBuffers.length] = o,
- [2, s]
- }
- })
- })
- }
- ,
- a.prototype.readValue = function(e) {
- return e === void 0 && (e = 0),
- __awaiter(this, void 0, void 0, function() {
- var i, o, s;
- return __generator(this, function(c) {
- switch (c.label) {
- case 0:
- return i = this._getBuffer(e, 1),
- i === null ? [2, null] : [4, i.mapAsync(MapMode.Read)];
- case 1:
- return c.sent(),
- o = new BigUint64Array(i.getMappedRange()),
- s = Number(o[0]),
- i.unmap(),
- this._dstBuffers[this._dstBuffers.length] = i,
- [2, s]
- }
- })
- })
- }
- ,
- a.prototype.readTwoValuesAndSubtract = function(e) {
- return e === void 0 && (e = 0),
- __awaiter(this, void 0, void 0, function() {
- var i, o, s;
- return __generator(this, function(c) {
- switch (c.label) {
- case 0:
- return i = this._getBuffer(e, 2),
- i === null ? [2, null] : [4, i.mapAsync(MapMode.Read)];
- case 1:
- return c.sent(),
- o = new BigUint64Array(i.getMappedRange()),
- s = Number(o[1] - o[0]),
- i.unmap(),
- this._dstBuffers[this._dstBuffers.length] = i,
- [2, s]
- }
- })
- })
- }
- ,
- a.prototype.dispose = function() {
- this._querySet.destroy(),
- this._bufferManager.releaseBuffer(this._queryBuffer);
- for (var e = 0; e < this._dstBuffers.length; ++e)
- this._bufferManager.releaseBuffer(this._dstBuffers[e])
- }
- ,
- a
- }()
- , WebGPUTimestampQuery = function() {
- function a(e, i) {
- this._enabled = !1,
- this._gpuFrameTimeCounter = new PerfCounter,
- this._measureDurationState = 0,
- this._device = e,
- this._bufferManager = i
- }
- return Object.defineProperty(a.prototype, "gpuFrameTimeCounter", {
- get: function() {
- return this._gpuFrameTimeCounter
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "enable", {
- get: function() {
- return this._enabled
- },
- set: function(e) {
- this._enabled !== e && (this._enabled = e,
- this._measureDurationState = 0,
- e ? this._measureDuration = new WebGPUDurationMeasure(this._device,this._bufferManager) : this._measureDuration.dispose())
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.startFrame = function(e) {
- this._enabled && this._measureDurationState === 0 && (this._measureDuration.start(e),
- this._measureDurationState = 1)
- }
- ,
- a.prototype.endFrame = function(e) {
- var i = this;
- this._measureDurationState === 1 && (this._measureDurationState = 2,
- this._measureDuration.stop(e).then(function(o) {
- o !== null && o >= 0 && (i._gpuFrameTimeCounter.fetchNewFrame(),
- i._gpuFrameTimeCounter.addCount(o, !0)),
- i._measureDurationState = 0
- }))
- }
- ,
- a
- }()
- , WebGPUDurationMeasure = function() {
- function a(e, i) {
- this._querySet = new WebGPUQuerySet(2,QueryType.Timestamp,e,i)
- }
- return a.prototype.start = function(e) {
- e.writeTimestamp(this._querySet.querySet, 0)
- }
- ,
- a.prototype.stop = function(e) {
- return __awaiter(this, void 0, void 0, function() {
- return __generator(this, function(i) {
- return e.writeTimestamp(this._querySet.querySet, 1),
- [2, this._querySet.readTwoValuesAndSubtract(0)]
- })
- })
- }
- ,
- a.prototype.dispose = function() {
- this._querySet.dispose()
- }
- ,
- a
- }()
- , WebGPUOcclusionQuery = function() {
- function a(e, i, o, s, c) {
- s === void 0 && (s = 50),
- c === void 0 && (c = 100),
- this._availableIndices = [],
- this._engine = e,
- this._device = i,
- this._bufferManager = o,
- this._frameLastBuffer = -1,
- this._currentTotalIndices = 0,
- this._countIncrement = c,
- this._allocateNewIndices(s)
- }
- return Object.defineProperty(a.prototype, "querySet", {
- get: function() {
- return this._querySet.querySet
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "hasQueries", {
- get: function() {
- return this._currentTotalIndices !== this._availableIndices.length
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "canBeginQuery", {
- get: function() {
- var e = this._engine._getCurrentRenderPassIndex();
- switch (e) {
- case 0:
- return this._engine._mainRenderPassWrapper.renderPassDescriptor.occlusionQuerySet !== void 0;
- case 1:
- return this._engine._rttRenderPassWrapper.renderPassDescriptor.occlusionQuerySet !== void 0
- }
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.createQuery = function() {
- this._availableIndices.length === 0 && this._allocateNewIndices();
- var e = this._availableIndices[this._availableIndices.length - 1];
- return this._availableIndices.length--,
- e
- }
- ,
- a.prototype.deleteQuery = function(e) {
- this._availableIndices[this._availableIndices.length - 1] = e
- }
- ,
- a.prototype.isQueryResultAvailable = function(e) {
- return this._retrieveQueryBuffer(),
- !!this._lastBuffer && e < this._lastBuffer.length
- }
- ,
- a.prototype.getQueryResult = function(e) {
- var i, o;
- return Number((o = (i = this._lastBuffer) === null || i === void 0 ? void 0 : i[e]) !== null && o !== void 0 ? o : -1)
- }
- ,
- a.prototype._retrieveQueryBuffer = function() {
- var e = this;
- this._lastBuffer && this._frameLastBuffer === this._engine.frameId || this._frameLastBuffer !== this._engine.frameId && (this._frameLastBuffer = this._engine.frameId,
- this._querySet.readValues(0, this._currentTotalIndices).then(function(i) {
- e._lastBuffer = i
- }))
- }
- ,
- a.prototype._allocateNewIndices = function(e) {
- e = e != null ? e : this._countIncrement,
- this._delayQuerySetDispose();
- for (var i = 0; i < e; ++i)
- this._availableIndices.push(this._currentTotalIndices + i);
- this._currentTotalIndices += e,
- this._querySet = new WebGPUQuerySet(this._currentTotalIndices,QueryType.Occlusion,this._device,this._bufferManager,!1)
- }
- ,
- a.prototype._delayQuerySetDispose = function() {
- var e = this._querySet;
- e && setTimeout(function() {
- return e.dispose
- }, 1e3)
- }
- ,
- a.prototype.dispose = function() {
- var e;
- (e = this._querySet) === null || e === void 0 || e.dispose(),
- this._availableIndices = []
- }
- ,
- a
- }()
- , WebGPUTintWASM = function() {
- function a() {
- this._twgsl = null
- }
- return a.prototype.initTwgsl = function(e) {
- return __awaiter(this, void 0, void 0, function() {
- var i;
- return __generator(this, function(o) {
- switch (o.label) {
- case 0:
- return e = e || {},
- e = __assign(__assign({}, a._twgslDefaultOptions), e),
- e.twgsl ? (this._twgsl = e.twgsl,
- [2, Promise.resolve()]) : e.jsPath && e.wasmPath ? IsWindowObjectExist() ? [4, Tools.LoadScriptAsync(e.jsPath)] : [3, 2] : [3, 3];
- case 1:
- return o.sent(),
- [3, 3];
- case 2:
- importScripts(e.jsPath),
- o.label = 3;
- case 3:
- return self.twgsl ? (i = this,
- [4, self.twgsl(e.wasmPath)]) : [3, 5];
- case 4:
- return i._twgsl = o.sent(),
- [2, Promise.resolve()];
- case 5:
- return [2, Promise.reject("twgsl is not available.")]
- }
- })
- })
- }
- ,
- a.prototype.convertSpirV2WGSL = function(e) {
- return this._twgsl.convertSpirV2WGSL(e)
- }
- ,
- a._twgslDefaultOptions = {
- jsPath: "https://preview.babylonjs.com/twgsl/twgsl.js",
- wasmPath: "https://preview.babylonjs.com/twgsl/twgsl.wasm"
- },
- a
- }()
- , WebGPUSnapshotRendering = function() {
- function a(e, i, o, s) {
- this._record = !1,
- this._play = !1,
- this._mainPassBundleList = [],
- this._enabled = !1,
- this._engine = e,
- this._mode = i,
- this._bundleList = o,
- this._bundleListRenderTarget = s
- }
- return Object.defineProperty(a.prototype, "enabled", {
- get: function() {
- return this._enabled
- },
- set: function(e) {
- this._mainPassBundleList.length = 0,
- this._record = this._enabled = e,
- this._play = !1,
- e && (this._modeSaved = this._mode,
- this._mode = 0)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "play", {
- get: function() {
- return this._play
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "record", {
- get: function() {
- return this._record
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "mode", {
- get: function() {
- return this._mode
- },
- set: function(e) {
- this._record ? this._modeSaved = e : this._mode = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.endMainRenderPass = function() {
- this._record && this._mainPassBundleList.push(this._bundleList.clone())
- }
- ,
- a.prototype.endRenderTargetPass = function(e, i) {
- var o, s, c, d;
- if (this._play)
- (s = (o = i._bundleLists) === null || o === void 0 ? void 0 : o[i._currentLayer]) === null || s === void 0 || s.run(e),
- 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);
- else if (this._record)
- i._bundleLists || (i._bundleLists = []),
- i._bundleLists[i._currentLayer] = this._bundleListRenderTarget.clone(),
- i._bundleLists[i._currentLayer].run(e),
- this._bundleListRenderTarget.reset();
- else
- return !1;
- return !0
- }
- ,
- a.prototype.endFrame = function(e) {
- if (this._record && (this._mainPassBundleList.push(this._bundleList.clone()),
- this._record = !1,
- this._play = !0,
- this._mode = this._modeSaved),
- e !== null && this._play)
- for (var i = 0; i < this._mainPassBundleList.length; ++i)
- this._mainPassBundleList[i].run(e),
- this._mode === 1 && this._engine._reportDrawCall(this._mainPassBundleList[i].numDrawCalls)
- }
- ,
- a.prototype.reset = function() {
- this.enabled = !1,
- this.enabled = !0
- }
- ,
- a
- }()
- , WebGPUEngine = function(a) {
- __extends(e, a);
- function e(i, o) {
- o === void 0 && (o = {});
- var s, c, d, _, b = a.call(this, null) || this;
- if (b._uploadEncoderDescriptor = {
- label: "upload"
- },
- b._renderEncoderDescriptor = {
- label: "render"
- },
- b._renderTargetEncoderDescriptor = {
- label: "renderTarget"
- },
- b._clearDepthValue = 1,
- b._clearReverseDepthValue = 0,
- b._clearStencilValue = 0,
- b._defaultSampleCount = 4,
- b._glslang = null,
- b._tintWASM = null,
- b._compiledComputeEffects = {},
- b._counters = {
- numEnableEffects: 0,
- numEnableDrawWrapper: 0,
- numBundleCreationNonCompatMode: 0,
- numBundleReuseNonCompatMode: 0
- },
- b.countersLastFrame = {
- numEnableEffects: 0,
- numEnableDrawWrapper: 0,
- numBundleCreationNonCompatMode: 0,
- numBundleReuseNonCompatMode: 0
- },
- b.numMaxUncapturedErrors = 20,
- b._commandBuffers = [null, null, null],
- b._currentRenderPass = null,
- b._mainRenderPassWrapper = new WebGPURenderPassWrapper,
- b._mainRenderPassCopyWrapper = new WebGPURenderPassWrapper,
- b._rttRenderPassWrapper = new WebGPURenderPassWrapper,
- b._pendingDebugCommands = [],
- b._onAfterUnbindFrameBufferObservable = new Observable,
- b._currentOverrideVertexBuffers = null,
- b._currentIndexBuffer = null,
- b.__colorWrite = !0,
- b._forceEnableEffect = !1,
- b.dbgShowShaderCode = !1,
- b.dbgSanityChecks = !0,
- b.dbgVerboseLogsForFirstFrames = !1,
- b.dbgVerboseLogsNumFrames = 10,
- b.dbgLogIfNotDrawWrapper = !0,
- b.dbgShowEmptyEnableEffectCalls = !0,
- b._viewportsCurrent = [{
- x: 0,
- y: 0,
- w: 0,
- h: 0
- }, {
- x: 0,
- y: 0,
- w: 0,
- h: 0
- }],
- b._scissorsCurrent = [{
- x: 0,
- y: 0,
- w: 0,
- h: 0
- }, {
- x: 0,
- y: 0,
- w: 0,
- h: 0
- }],
- b._scissorCached = {
- x: 0,
- y: 0,
- z: 0,
- w: 0
- },
- b._stencilRefsCurrent = [-1, -1],
- b._blendColorsCurrent = [[null, null, null, null], [null, null, null, null]],
- b.isNDCHalfZRange = !0,
- b.hasOriginBottomLeft = !1,
- o.deviceDescriptor = o.deviceDescriptor || {},
- o.swapChainFormat = o.swapChainFormat || TextureFormat.BGRA8Unorm,
- o.antialiasing = o.antialiasing === void 0 ? !0 : o.antialiasing,
- o.stencil = (s = o.stencil) !== null && s !== void 0 ? s : !0,
- o.enableGPUDebugMarkers = (c = o.enableGPUDebugMarkers) !== null && c !== void 0 ? c : !1,
- Logger$2.Log("Babylon.js v" + Engine.Version + " - " + b.description + " engine"),
- !navigator.gpu)
- return Logger$2.Error("WebGPU is not supported by your browser."),
- b;
- b._isWebGPU = !0,
- b._shaderPlatformName = "WEBGPU",
- o.deterministicLockstep === void 0 && (o.deterministicLockstep = !1),
- o.lockstepMaxSteps === void 0 && (o.lockstepMaxSteps = 4),
- o.audioEngine === void 0 && (o.audioEngine = !0),
- b._deterministicLockstep = o.deterministicLockstep,
- b._lockstepMaxSteps = o.lockstepMaxSteps,
- b._timeStep = o.timeStep || 1 / 60,
- b._doNotHandleContextLost = !!o.doNotHandleContextLost,
- b._canvas = i,
- b._options = o,
- b.premultipliedAlpha = (d = o.premultipliedAlpha) !== null && d !== void 0 ? d : !0;
- var k = IsWindowObjectExist() && window.devicePixelRatio || 1
- , j = o.limitDeviceRatio || k
- , $ = (_ = o.adaptToDeviceRatio) !== null && _ !== void 0 ? _ : !1;
- return b._hardwareScalingLevel = $ ? 1 / Math.min(j, k) : 1,
- b._mainPassSampleCount = o.antialiasing ? b._defaultSampleCount : 1,
- b._isStencilEnable = o.stencil,
- b._sharedInit(i, !!o.doNotHandleTouchAction, o.audioEngine),
- b._shaderProcessor = new WebGPUShaderProcessorGLSL,
- b._shaderProcessorWGSL = new WebGPUShaderProcessorWGSL,
- b._invertYFinalFramebuffer = (!!b._options.forceCopyForInvertYFinalFramebuffer || !b._canvas.style) && !b._options.disableCopyForInvertYFinalFramebuffer,
- b._invertYFinalFramebuffer || b._canvas.style && (b._canvas.style.transform = "scaleY(-1)"),
- b
- }
- return Object.defineProperty(e.prototype, "snapshotRenderingMode", {
- get: function() {
- return this._snapshotRendering.mode
- },
- set: function(i) {
- this._snapshotRendering.mode = i
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.snapshotRenderingReset = function() {
- this._snapshotRendering.reset()
- }
- ,
- Object.defineProperty(e.prototype, "snapshotRendering", {
- get: function() {
- return this._snapshotRendering.enabled
- },
- set: function(i) {
- this._snapshotRendering.enabled = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "disableCacheSamplers", {
- get: function() {
- return this._cacheSampler ? this._cacheSampler.disabled : !1
- },
- set: function(i) {
- this._cacheSampler && (this._cacheSampler.disabled = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "disableCacheRenderPipelines", {
- get: function() {
- return this._cacheRenderPipeline ? this._cacheRenderPipeline.disabled : !1
- },
- set: function(i) {
- this._cacheRenderPipeline && (this._cacheRenderPipeline.disabled = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "disableCacheBindGroups", {
- get: function() {
- return this._cacheBindGroups ? this._cacheBindGroups.disabled : !1
- },
- set: function(i) {
- this._cacheBindGroups && (this._cacheBindGroups.disabled = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "IsSupportedAsync", {
- get: function() {
- return navigator.gpu ? navigator.gpu.requestAdapter().then(function(i) {
- return !!i
- }, function(i) {
- return !1
- }).catch(function(i) {
- return !1
- }) : Promise.resolve(!1)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "IsSupported", {
- get: function() {
- return Logger$2.Warn("You must call IsSupportedAsync for WebGPU!"),
- !1
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "supportsUniformBuffers", {
- get: function() {
- return !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "supportedExtensions", {
- get: function() {
- return this._adapterSupportedExtensions
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "enabledExtensions", {
- get: function() {
- return this._deviceEnabledExtensions
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "name", {
- get: function() {
- return "WebGPU"
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "description", {
- get: function() {
- var i = this.name + this.version;
- return i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "version", {
- get: function() {
- return 1
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getInfo = function() {
- return {
- vendor: "unknown vendor",
- renderer: "unknown renderer",
- version: "unknown version"
- }
- }
- ,
- Object.defineProperty(e.prototype, "compatibilityMode", {
- get: function() {
- return this._compatibilityMode
- },
- set: function(i) {
- this._compatibilityMode = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "currentSampleCount", {
- get: function() {
- return this._currentRenderTarget ? this._currentRenderTarget.samples : this._mainPassSampleCount
- },
- enumerable: !1,
- configurable: !0
- }),
- e.CreateAsync = function(i, o) {
- o === void 0 && (o = {});
- var s = new e(i,o);
- return new Promise(function(c) {
- s.initAsync(o.glslangOptions, o.twgslOptions).then(function() {
- return c(s)
- })
- }
- )
- }
- ,
- e.prototype.initAsync = function(i, o) {
- var s = this, c;
- return this._initGlslang(i != null ? i : (c = this._options) === null || c === void 0 ? void 0 : c.glslangOptions).then(function(d) {
- var _;
- return s._glslang = d,
- s._tintWASM = e.UseTWGSL ? new WebGPUTintWASM : null,
- s._tintWASM ? s._tintWASM.initTwgsl(o != null ? o : (_ = s._options) === null || _ === void 0 ? void 0 : _.twgslOptions).then(function() {
- return navigator.gpu.requestAdapter(s._options)
- }, function(b) {
- throw Logger$2.Error("Can not initialize twgsl!"),
- Logger$2.Error(b),
- Error("WebGPU initializations stopped.")
- }) : navigator.gpu.requestAdapter(s._options)
- }, function(d) {
- throw Logger$2.Error("Can not initialize glslang!"),
- Logger$2.Error(d),
- Error("WebGPU initializations stopped.")
- }).then(function(d) {
- var _;
- if (d) {
- s._adapter = d,
- s._adapterSupportedExtensions = [],
- (_ = s._adapter.features) === null || _ === void 0 || _.forEach(function(tt) {
- return s._adapterSupportedExtensions.push(tt)
- });
- var b = s._options.deviceDescriptor;
- if (b != null && b.requiredFeatures) {
- for (var k = b.requiredFeatures, j = [], $ = 0, _e = k; $ < _e.length; $++) {
- var et = _e[$];
- s._adapterSupportedExtensions.indexOf(et) !== -1 && j.push(et)
- }
- b.requiredFeatures = j
- }
- return s._adapter.requestDevice(s._options.deviceDescriptor)
- } else
- throw "Could not retrieve a WebGPU adapter (adapter is null)."
- }).then(function(d) {
- var _, b;
- s._device = d,
- s._deviceEnabledExtensions = [],
- (_ = s._device.features) === null || _ === void 0 || _.forEach(function(j) {
- return s._deviceEnabledExtensions.push(j)
- });
- var k = -1;
- s._device.addEventListener("uncapturederror", function(j) {
- ++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.")
- }),
- s._doNotHandleContextLost || (b = s._device.lost) === null || b === void 0 || b.then(function(j) {
- s._contextWasLost = !0,
- Logger$2.Warn("WebGPU context lost. " + j),
- s.onContextLostObservable.notifyObservers(s),
- s._restoreEngineAfterContextLost(s.initAsync.bind(s))
- })
- }, function(d) {
- Logger$2.Error("Could not retrieve a WebGPU device."),
- Logger$2.Error(d)
- }).then(function() {
- s._bufferManager = new WebGPUBufferManager(s._device),
- s._textureHelper = new WebGPUTextureHelper(s._device,s._glslang,s._tintWASM,s._bufferManager),
- s._cacheSampler = new WebGPUCacheSampler(s._device),
- s._cacheBindGroups = new WebGPUCacheBindGroups(s._device,s._cacheSampler,s),
- s._timestampQuery = new WebGPUTimestampQuery(s._device,s._bufferManager),
- s._occlusionQuery = s._device.createQuerySet ? new WebGPUOcclusionQuery(s,s._device,s._bufferManager) : void 0,
- s._bundleList = new WebGPUBundleList(s._device),
- s._bundleListRenderTarget = new WebGPUBundleList(s._device),
- s._snapshotRendering = new WebGPUSnapshotRendering(s,s._snapshotRenderingMode,s._bundleList,s._bundleListRenderTarget),
- s.dbgVerboseLogsForFirstFrames && s._count === void 0 && (s._count = 0,
- console.log("%c frame #" + s._count + " - begin", "background: #ffff00")),
- s._uploadEncoder = s._device.createCommandEncoder(s._uploadEncoderDescriptor),
- s._renderEncoder = s._device.createCommandEncoder(s._renderEncoderDescriptor),
- s._renderTargetEncoder = s._device.createCommandEncoder(s._renderTargetEncoderDescriptor),
- s._emptyVertexBuffer = new VertexBuffer(s,[0],"",!1,!1,1,!1,0,1),
- s._initializeLimits(),
- s._cacheRenderPipeline = new WebGPUCacheRenderPipelineTree(s._device,s._emptyVertexBuffer,!s._caps.textureFloatLinearFiltering),
- s._depthCullingState = new WebGPUDepthCullingState(s._cacheRenderPipeline),
- s._stencilStateComposer = new WebGPUStencilStateComposer(s._cacheRenderPipeline),
- s._stencilStateComposer.stencilGlobal = s._stencilState,
- s._depthCullingState.depthTest = !0,
- s._depthCullingState.depthFunc = 515,
- s._depthCullingState.depthMask = !0,
- s._textureHelper.setCommandEncoder(s._uploadEncoder),
- s._clearQuad = new WebGPUClearQuad(s._device,s,s._emptyVertexBuffer),
- s._defaultDrawContext = s.createDrawContext(),
- s._currentDrawContext = s._defaultDrawContext,
- s._defaultMaterialContext = s.createMaterialContext(),
- s._currentMaterialContext = s._defaultMaterialContext,
- s._initializeContextAndSwapChain(),
- s._initializeMainAttachments(),
- s.resize()
- }).catch(function(d) {
- Logger$2.Error("Can not create WebGPU Device and/or context."),
- Logger$2.Error(d),
- console.trace && console.trace()
- })
- }
- ,
- e.prototype._initGlslang = function(i) {
- return i = i || {},
- i = __assign(__assign({}, e._glslangDefaultOptions), i),
- i.glslang ? Promise.resolve(i.glslang) : self.glslang ? self.glslang(i.wasmPath) : i.jsPath && i.wasmPath ? IsWindowObjectExist() ? Tools.LoadScriptAsync(i.jsPath).then(function() {
- return self.glslang(i.wasmPath)
- }) : (importScripts(i.jsPath),
- self.glslang(i.wasmPath)) : Promise.reject("gslang is not available.")
- }
- ,
- e.prototype._initializeLimits = function() {
- this._caps = {
- maxTexturesImageUnits: 16,
- maxVertexTextureImageUnits: 16,
- maxCombinedTexturesImageUnits: 32,
- maxTextureSize: 8192,
- maxCubemapTextureSize: 2048,
- maxRenderTextureSize: 8192,
- maxVertexAttribs: 16,
- maxVaryingVectors: 15,
- maxFragmentUniformVectors: 1024,
- maxVertexUniformVectors: 1024,
- standardDerivatives: !0,
- astc: null,
- s3tc: this._deviceEnabledExtensions.indexOf(FeatureName.TextureCompressionBC) >= 0 ? !0 : void 0,
- pvrtc: null,
- etc1: null,
- etc2: null,
- bptc: this._deviceEnabledExtensions.indexOf(FeatureName.TextureCompressionBC) >= 0 ? !0 : void 0,
- maxAnisotropy: 4,
- uintIndices: !0,
- fragmentDepthSupported: !0,
- highPrecisionShaderSupported: !0,
- colorBufferFloat: !0,
- textureFloat: !0,
- textureFloatLinearFiltering: !1,
- textureFloatRender: !0,
- textureHalfFloat: !0,
- textureHalfFloatLinearFiltering: !0,
- textureHalfFloatRender: !0,
- textureLOD: !0,
- drawBuffersExtension: !0,
- depthTextureExtension: !0,
- vertexArrayObject: !1,
- instancedArrays: !0,
- timerQuery: typeof BigUint64Array != "undefined" && this.enabledExtensions.indexOf(FeatureName.TimestampQuery) !== -1 ? !0 : void 0,
- supportOcclusionQuery: typeof BigUint64Array != "undefined",
- canUseTimestampForTimerQuery: !0,
- multiview: !1,
- oculusMultiview: !1,
- parallelShaderCompile: void 0,
- blendMinMax: !0,
- maxMSAASamples: 4,
- canUseGLInstanceID: !0,
- canUseGLVertexID: !0,
- supportComputeShaders: !0,
- supportSRGBBuffers: !0
- },
- this._caps.parallelShaderCompile = null,
- this._features = {
- forceBitmapOverHTMLImageElement: !0,
- supportRenderAndCopyToLodForFloatTextures: !0,
- supportDepthStencilTexture: !0,
- supportShadowSamplers: !0,
- uniformBufferHardCheckMatrix: !1,
- allowTexturePrefiltering: !0,
- trackUbosInFrame: !0,
- checkUbosContentBeforeUpload: !0,
- supportCSM: !0,
- basisNeedsPOT: !1,
- support3DTextures: !0,
- needTypeSuffixInShaderConstants: !0,
- supportMSAA: !0,
- supportSSAO2: !0,
- supportExtendedTextureFormats: !0,
- supportSwitchCaseInShader: !0,
- supportSyncTextureRead: !1,
- needsInvertingBitmap: !1,
- useUBOBindingCache: !1,
- needShaderCodeInlining: !0,
- needToAlwaysBindUniformBuffers: !0,
- supportRenderPasses: !0,
- _collectUbosUpdatedInFrame: !1
- }
- }
- ,
- e.prototype._initializeContextAndSwapChain = function() {
- this._context = this._canvas.getContext("webgpu"),
- this._configureContext(this._canvas.width, this._canvas.height),
- this._colorFormat = this._options.swapChainFormat,
- this._mainRenderPassWrapper.colorAttachmentGPUTextures = [new WebGPUHardwareTexture],
- this._mainRenderPassWrapper.colorAttachmentGPUTextures[0].format = this._colorFormat,
- this._invertYFinalFramebuffer && (this._mainRenderPassCopyWrapper.colorAttachmentGPUTextures = [new WebGPUHardwareTexture],
- this._mainRenderPassCopyWrapper.colorAttachmentGPUTextures[0].format = this._colorFormat)
- }
- ,
- e.prototype._initializeMainAttachments = function() {
- var i, o;
- this._mainTextureExtends = {
- width: this.getRenderWidth(),
- height: this.getRenderHeight(),
- depthOrArrayLayers: 1
- };
- var s;
- if (this._options.antialiasing) {
- var c = {
- size: this._mainTextureExtends,
- mipLevelCount: 1,
- sampleCount: this._mainPassSampleCount,
- dimension: TextureDimension.E2d,
- format: this._options.swapChainFormat,
- usage: TextureUsage.RenderAttachment
- };
- (i = this._mainTexture) === null || i === void 0 || i.destroy(),
- this._mainTexture = this._device.createTexture(c),
- s = [{
- view: this._mainTexture.createView(),
- loadValue: new Color4(0,0,0,1),
- storeOp: StoreOp.Store
- }]
- } else
- s = [{
- view: void 0,
- loadValue: new Color4(0,0,0,1),
- storeOp: StoreOp.Store
- }];
- if (this._invertYFinalFramebuffer) {
- var d = {
- size: this._mainTextureExtends,
- mipLevelCount: 1,
- sampleCount: 1,
- dimension: TextureDimension.E2d,
- format: this._options.swapChainFormat,
- usage: TextureUsage.RenderAttachment | TextureUsage.TextureBinding
- };
- (o = this._mainTextureLastCopy) === null || o === void 0 || o.destroy(),
- this._mainTextureLastCopy = this._device.createTexture(d),
- this._options.antialiasing ? s[0].resolveTarget = this._mainTextureLastCopy.createView() : s[0].view = this._mainTextureLastCopy.createView(),
- this._mainRenderPassCopyWrapper.renderPassDescriptor = {
- colorAttachments: [{
- view: void 0,
- loadValue: new Color4(0,0,0,1),
- storeOp: StoreOp.Store
- }]
- }
- }
- this._mainRenderPassWrapper.depthTextureFormat = this.isStencilEnable ? TextureFormat.Depth24PlusStencil8 : TextureFormat.Depth32Float,
- this._setDepthTextureFormat(this._mainRenderPassWrapper);
- var _ = {
- size: this._mainTextureExtends,
- mipLevelCount: 1,
- sampleCount: this._mainPassSampleCount,
- dimension: TextureDimension.E2d,
- format: this._mainRenderPassWrapper.depthTextureFormat,
- usage: TextureUsage.RenderAttachment
- };
- this._depthTexture && this._depthTexture.destroy(),
- this._depthTexture = this._device.createTexture(_);
- var b = {
- view: this._depthTexture.createView(),
- depthLoadValue: this._clearDepthValue,
- depthStoreOp: StoreOp.Store,
- stencilLoadValue: this._clearStencilValue,
- stencilStoreOp: StoreOp.Store
- };
- this._mainRenderPassWrapper.renderPassDescriptor = {
- colorAttachments: s,
- depthStencilAttachment: b
- },
- this._mainRenderPassWrapper.renderPass !== null && this._endMainRenderPass()
- }
- ,
- e.prototype._configureContext = function(i, o) {
- this._context.configure({
- device: this._device,
- format: this._options.swapChainFormat,
- usage: TextureUsage.RenderAttachment | TextureUsage.CopySrc,
- compositingAlphaMode: this.premultipliedAlpha ? CanvasCompositingAlphaMode.Premultiplied : CanvasCompositingAlphaMode.Opaque,
- size: {
- width: i,
- height: o,
- depthOrArrayLayers: 1
- }
- })
- }
- ,
- e.prototype.setSize = function(i, o, s) {
- return s === void 0 && (s = !1),
- a.prototype.setSize.call(this, i, o, s) ? (this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0),
- (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - setSize called -", i, o)),
- this._configureContext(i, o),
- this._initializeMainAttachments(),
- this.snapshotRendering && this.snapshotRenderingReset(),
- !0) : !1
- }
- ,
- e.prototype._getShaderProcessor = function(i) {
- return i === ShaderLanguage.WGSL ? this._shaderProcessorWGSL : this._shaderProcessor
- }
- ,
- e.prototype._getShaderProcessingContext = function(i) {
- return new WebGPUShaderProcessingContext(i)
- }
- ,
- e.prototype.applyStates = function() {
- this._stencilStateComposer.apply(),
- this._cacheRenderPipeline.setAlphaBlendEnabled(this._alphaState.alphaBlend)
- }
- ,
- e.prototype.wipeCaches = function(i) {
- this.preventCacheWipeBetweenFrames && !i || (this._forceEnableEffect = !0,
- this._currentIndexBuffer = null,
- this._currentOverrideVertexBuffers = null,
- this._cacheRenderPipeline.setBuffers(null, null, null),
- i && (this._stencilStateComposer.reset(),
- this._depthCullingState.reset(),
- this._depthCullingState.depthFunc = 515,
- this._alphaState.reset(),
- this._alphaMode = 1,
- this._alphaEquation = 0,
- this._cacheRenderPipeline.setAlphaBlendFactors(this._alphaState._blendFunctionParameters, this._alphaState._blendEquationParameters),
- this._cacheRenderPipeline.setAlphaBlendEnabled(!1),
- this.setColorWrite(!0)),
- this._cachedVertexBuffers = null,
- this._cachedIndexBuffer = null,
- this._cachedEffectForVertexBuffers = null)
- }
- ,
- e.prototype.setColorWrite = function(i) {
- this.__colorWrite = i,
- this._cacheRenderPipeline.setWriteMask(i ? 15 : 0)
- }
- ,
- e.prototype.getColorWrite = function() {
- return this.__colorWrite
- }
- ,
- e.prototype._resetCurrentViewport = function(i) {
- this._viewportsCurrent[i].x = 0,
- this._viewportsCurrent[i].y = 0,
- this._viewportsCurrent[i].w = 0,
- this._viewportsCurrent[i].h = 0,
- i === 1 && (this._viewportCached.x = 0,
- this._viewportCached.y = 0,
- this._viewportCached.z = 0,
- this._viewportCached.w = 0)
- }
- ,
- e.prototype._mustUpdateViewport = function(i) {
- var o = i === this._mainRenderPassWrapper.renderPass ? 0 : 1
- , s = this._viewportCached.x
- , c = this._viewportCached.y
- , d = this._viewportCached.z
- , _ = this._viewportCached.w
- , b = this._viewportsCurrent[o].x !== s || this._viewportsCurrent[o].y !== c || this._viewportsCurrent[o].w !== d || this._viewportsCurrent[o].h !== _;
- return b && (this._viewportsCurrent[o].x = this._viewportCached.x,
- this._viewportsCurrent[o].y = this._viewportCached.y,
- this._viewportsCurrent[o].w = this._viewportCached.z,
- this._viewportsCurrent[o].h = this._viewportCached.w),
- b
- }
- ,
- e.prototype._applyViewport = function(i) {
- i.setViewport(Math.floor(this._viewportCached.x), Math.floor(this._viewportCached.y), Math.floor(this._viewportCached.z), Math.floor(this._viewportCached.w), 0, 1),
- this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0),
- (!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)))
- }
- ,
- e.prototype._viewport = function(i, o, s, c) {
- this._viewportCached.x = i,
- this._viewportCached.y = o,
- this._viewportCached.z = s,
- this._viewportCached.w = c
- }
- ,
- e.prototype._resetCurrentScissor = function(i) {
- this._scissorsCurrent[i].x = 0,
- this._scissorsCurrent[i].y = 0,
- this._scissorsCurrent[i].w = 0,
- this._scissorsCurrent[i].h = 0
- }
- ,
- e.prototype._mustUpdateScissor = function(i) {
- var o = i === this._mainRenderPassWrapper.renderPass ? 0 : 1
- , s = this._scissorCached.x
- , c = this._scissorCached.y
- , d = this._scissorCached.z
- , _ = this._scissorCached.w
- , b = this._scissorsCurrent[o].x !== s || this._scissorsCurrent[o].y !== c || this._scissorsCurrent[o].w !== d || this._scissorsCurrent[o].h !== _;
- return b && (this._scissorsCurrent[o].x = this._scissorCached.x,
- this._scissorsCurrent[o].y = this._scissorCached.y,
- this._scissorsCurrent[o].w = this._scissorCached.z,
- this._scissorsCurrent[o].h = this._scissorCached.w),
- b
- }
- ,
- e.prototype._applyScissor = function(i) {
- i.setScissorRect(this._scissorCached.x, this._scissorCached.y, this._scissorCached.z, this._scissorCached.w),
- this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0),
- (!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)))
- }
- ,
- e.prototype._scissorIsActive = function() {
- return this._scissorCached.x !== 0 || this._scissorCached.y !== 0 || this._scissorCached.z !== 0 || this._scissorCached.w !== 0
- }
- ,
- e.prototype.enableScissor = function(i, o, s, c) {
- this._scissorCached.x = i,
- this._scissorCached.y = o,
- this._scissorCached.z = s,
- this._scissorCached.w = c
- }
- ,
- e.prototype.disableScissor = function() {
- this._scissorCached.x = 0,
- this._scissorCached.y = 0,
- this._scissorCached.z = 0,
- this._scissorCached.w = 0,
- this._resetCurrentScissor(0),
- this._resetCurrentScissor(1)
- }
- ,
- e.prototype._resetCurrentStencilRef = function(i) {
- this._stencilRefsCurrent[i] = -1
- }
- ,
- e.prototype._mustUpdateStencilRef = function(i) {
- var o = i === this._mainRenderPassWrapper.renderPass ? 0 : 1
- , s = this._stencilStateComposer.funcRef !== this._stencilRefsCurrent[o];
- return s && (this._stencilRefsCurrent[o] = this._stencilStateComposer.funcRef),
- s
- }
- ,
- e.prototype._applyStencilRef = function(i) {
- var o;
- i.setStencilReference((o = this._stencilStateComposer.funcRef) !== null && o !== void 0 ? o : 0)
- }
- ,
- e.prototype._resetCurrentColorBlend = function(i) {
- this._blendColorsCurrent[i][0] = this._blendColorsCurrent[i][1] = this._blendColorsCurrent[i][2] = this._blendColorsCurrent[i][3] = null
- }
- ,
- e.prototype._mustUpdateBlendColor = function(i) {
- var o = i === this._mainRenderPassWrapper.renderPass ? 0 : 1
- , s = this._alphaState._blendConstants
- , 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];
- return c && (this._blendColorsCurrent[o][0] = s[0],
- this._blendColorsCurrent[o][1] = s[1],
- this._blendColorsCurrent[o][2] = s[2],
- this._blendColorsCurrent[o][3] = s[3]),
- c
- }
- ,
- e.prototype._applyBlendColor = function(i) {
- i.setBlendConstant(this._alphaState._blendConstants)
- }
- ,
- e.prototype.clear = function(i, o, s, c) {
- c === void 0 && (c = !1),
- i && i.a === void 0 && (i.a = 1);
- var d = this._scissorIsActive();
- this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0),
- (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - clear called - backBuffer=", o, " depth=", s, " stencil=", c, " scissor is active=", d)),
- this._currentRenderTarget ? d ? (this._rttRenderPassWrapper.renderPass || this._startRenderTargetRenderPass(this._currentRenderTarget, !1, o ? i : null, s, c),
- this.compatibilityMode ? this._applyScissor(this._currentRenderPass) : this._bundleListRenderTarget.addItem(new WebGPURenderItemScissor(this._scissorCached.x,this._scissorCached.y,this._scissorCached.z,this._scissorCached.w)),
- this._clearFullQuad(o ? i : null, s, c)) : (this._currentRenderPass && this._endRenderTargetRenderPass(),
- this._startRenderTargetRenderPass(this._currentRenderTarget, !0, o ? i : null, s, c)) : ((!this._mainRenderPassWrapper.renderPass || !d) && this._startMainRenderPass(!d, o ? i : null, s, c),
- d && (this.compatibilityMode ? this._applyScissor(this._currentRenderPass) : this._bundleList.addItem(new WebGPURenderItemScissor(this._scissorCached.x,this._scissorCached.y,this._scissorCached.z,this._scissorCached.w)),
- this._clearFullQuad(o ? i : null, s, c)))
- }
- ,
- e.prototype._clearFullQuad = function(i, o, s) {
- var c, d, _, b = this.compatibilityMode ? this._getCurrentRenderPass() : null, k = this._getCurrentRenderPassIndex(), j = k === 0 ? this._bundleList : this._bundleListRenderTarget;
- this._clearQuad.setColorFormat(this._colorFormat),
- this._clearQuad.setDepthStencilFormat(this._depthTextureFormat),
- this._clearQuad.setMRTAttachments((c = this._cacheRenderPipeline.mrtAttachments) !== null && c !== void 0 ? c : [], (d = this._cacheRenderPipeline.mrtTextureArray) !== null && d !== void 0 ? d : []),
- this.compatibilityMode ? b.setStencilReference(this._clearStencilValue) : j.addItem(new WebGPURenderItemStencilRef(this._clearStencilValue));
- var $ = this._clearQuad.clear(b, i, o, s, this.currentSampleCount);
- this.compatibilityMode ? this._applyStencilRef(b) : (j.addBundle($),
- j.addItem(new WebGPURenderItemStencilRef((_ = this._stencilStateComposer.funcRef) !== null && _ !== void 0 ? _ : 0)),
- this._reportDrawCall())
- }
- ,
- e.prototype.createVertexBuffer = function(i) {
- var o;
- i instanceof Array ? o = new Float32Array(i) : i instanceof ArrayBuffer ? o = new Uint8Array(i) : o = i;
- var s = this._bufferManager.createBuffer(o, BufferUsage.Vertex | BufferUsage.CopyDst);
- return s
- }
- ,
- e.prototype.createDynamicVertexBuffer = function(i) {
- return this.createVertexBuffer(i)
- }
- ,
- e.prototype.createIndexBuffer = function(i, o) {
- var s = !0, c;
- i instanceof Uint32Array || i instanceof Int32Array ? c = i : i instanceof Uint16Array ? (c = i,
- s = !1) : i.length > 65535 ? c = new Uint32Array(i) : (c = new Uint16Array(i),
- s = !1);
- var d = this._bufferManager.createBuffer(c, BufferUsage.Index | BufferUsage.CopyDst);
- return d.is32Bits = s,
- d
- }
- ,
- e.prototype._createBuffer = function(i, o) {
- var s;
- i instanceof Array ? s = new Float32Array(i) : i instanceof ArrayBuffer ? s = new Uint8Array(i) : s = i;
- var c = 0;
- return o & 1 && (c |= BufferUsage.CopySrc),
- o & 2 && (c |= BufferUsage.CopyDst),
- o & 4 && (c |= BufferUsage.Uniform),
- o & 8 && (c |= BufferUsage.Vertex),
- o & 16 && (c |= BufferUsage.Index),
- o & 32 && (c |= BufferUsage.Storage),
- this._bufferManager.createBuffer(s, c)
- }
- ,
- e.prototype.bindBuffersDirectly = function(i, o, s, c, d) {
- throw "Not implemented on WebGPU"
- }
- ,
- e.prototype.updateAndBindInstancesBuffer = function(i, o, s) {
- throw "Not implemented on WebGPU"
- }
- ,
- e.prototype.bindBuffers = function(i, o, s, c) {
- this._currentIndexBuffer = o,
- this._currentOverrideVertexBuffers = c != null ? c : null,
- this._cacheRenderPipeline.setBuffers(i, o, this._currentOverrideVertexBuffers)
- }
- ,
- e.prototype._releaseBuffer = function(i) {
- return this._bufferManager.releaseBuffer(i)
- }
- ,
- e.prototype.createEffect = function(i, o, s, c, d, _, b, k, j, $) {
- var _e;
- $ === void 0 && ($ = ShaderLanguage.GLSL);
- var et = i.vertexElement || i.vertex || i.vertexToken || i.vertexSource || i
- , tt = i.fragmentElement || i.fragment || i.fragmentToken || i.fragmentSource || i
- , rt = this._getGlobalDefines()
- , it = (_e = d != null ? d : o.defines) !== null && _e !== void 0 ? _e : "";
- rt && (it += `
- ` + rt);
- var nt = et + "+" + tt + "@" + it;
- if (this._compiledEffects[nt]) {
- var ot = this._compiledEffects[nt];
- return b && ot.isReady() && b(ot),
- ot
- }
- var at = new Effect(i,o,s,c,this,d,_,b,k,j,nt,$);
- return this._compiledEffects[nt] = at,
- at
- }
- ,
- e.prototype._compileRawShaderToSpirV = function(i, o) {
- return this._glslang.compileGLSL(i, o)
- }
- ,
- e.prototype._compileShaderToSpirV = function(i, o, s, c) {
- return this._compileRawShaderToSpirV(c + (s ? s + `
- ` : "") + i, o)
- }
- ,
- e.prototype._getWGSLShader = function(i, o, s, c) {
- return s ? s = "//" + s.split(`
- `).join(`
- //`) + `
- ` : s = "",
- s + i
- }
- ,
- e.prototype._createPipelineStageDescriptor = function(i, o, s) {
- return this._tintWASM && s === ShaderLanguage.GLSL && (i = this._tintWASM.convertSpirV2WGSL(i),
- o = this._tintWASM.convertSpirV2WGSL(o)),
- {
- vertexStage: {
- module: this._device.createShaderModule({
- code: i
- }),
- entryPoint: "main"
- },
- fragmentStage: {
- module: this._device.createShaderModule({
- code: o
- }),
- entryPoint: "main"
- }
- }
- }
- ,
- e.prototype._compileRawPipelineStageDescriptor = function(i, o, s) {
- var c = s === ShaderLanguage.GLSL ? this._compileRawShaderToSpirV(i, "vertex") : i
- , d = s === ShaderLanguage.GLSL ? this._compileRawShaderToSpirV(o, "fragment") : o;
- return this._createPipelineStageDescriptor(c, d, s)
- }
- ,
- e.prototype._compilePipelineStageDescriptor = function(i, o, s, c) {
- this.onBeforeShaderCompilationObservable.notifyObservers(this);
- var d = `#version 450
- `
- , _ = c === ShaderLanguage.GLSL ? this._compileShaderToSpirV(i, "vertex", s, d) : this._getWGSLShader(i, "vertex", s, d)
- , b = c === ShaderLanguage.GLSL ? this._compileShaderToSpirV(o, "fragment", s, d) : this._getWGSLShader(o, "fragment", s, d)
- , k = this._createPipelineStageDescriptor(_, b, c);
- return this.onAfterShaderCompilationObservable.notifyObservers(this),
- k
- }
- ,
- e.prototype.createRawShaderProgram = function(i, o, s, c, d) {
- throw "Not available on WebGPU"
- }
- ,
- e.prototype.createShaderProgram = function(i, o, s, c, d, _) {
- throw "Not available on WebGPU"
- }
- ,
- e.prototype.inlineShaderCode = function(i) {
- var o = new ShaderCodeInliner(i);
- return o.debug = !1,
- o.processCode(),
- o.code
- }
- ,
- e.prototype.createPipelineContext = function(i) {
- return new WebGPUPipelineContext(i,this)
- }
- ,
- e.prototype.createMaterialContext = function() {
- return new WebGPUMaterialContext
- }
- ,
- e.prototype.createDrawContext = function() {
- return new WebGPUDrawContext(this._bufferManager)
- }
- ,
- e.prototype._preparePipelineContext = function(i, o, s, c, d, _, b, k, j, $) {
- var _e = i
- , et = _e.shaderProcessingContext.shaderLanguage;
- this.dbgShowShaderCode && (console.log(k),
- console.log(o),
- console.log(s)),
- _e.sources = {
- fragment: s,
- vertex: o,
- rawVertex: d,
- rawFragment: _
- },
- c ? _e.stages = this._compileRawPipelineStageDescriptor(o, s, et) : _e.stages = this._compilePipelineStageDescriptor(o, s, k, et)
- }
- ,
- e.prototype.getAttributes = function(i, o) {
- for (var s = new Array(o.length), c = i, d = 0; d < o.length; d++) {
- var _ = o[d]
- , b = c.shaderProcessingContext.availableAttributes[_];
- b !== void 0 && (s[d] = b)
- }
- return s
- }
- ,
- e.prototype.enableEffect = function(i) {
- if (!!i) {
- var o = !0;
- if (!DrawWrapper.IsWrapper(i))
- o = i !== this._currentEffect,
- this._currentEffect = i,
- this._currentMaterialContext = this._defaultMaterialContext,
- this._currentDrawContext = this._defaultDrawContext,
- this._counters.numEnableEffects++,
- 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);
- else if (!i.effect || i.effect === this._currentEffect && i.materialContext === this._currentMaterialContext && i.drawContext === this._currentDrawContext && !this._forceEnableEffect) {
- if (!i.effect && this.dbgShowEmptyEnableEffectCalls)
- throw console.error("drawWrapper=", i),
- "Invalid call to enableEffect: the effect property is empty!";
- return
- } else if (o = i.effect !== this._currentEffect,
- this._currentEffect = i.effect,
- this._currentMaterialContext = i.materialContext,
- this._currentDrawContext = i.drawContext,
- this._counters.numEnableDrawWrapper++,
- !this._currentMaterialContext)
- throw console.error("drawWrapper=", i),
- "Invalid call to enableEffect: the materialContext property is empty!";
- this._stencilStateComposer.stencilMaterial = void 0,
- this._forceEnableEffect = o || this._forceEnableEffect ? !1 : this._forceEnableEffect,
- o && (this._currentEffect.onBind && this._currentEffect.onBind(this._currentEffect),
- this._currentEffect._onBindObservable && this._currentEffect._onBindObservable.notifyObservers(this._currentEffect))
- }
- }
- ,
- e.prototype._releaseEffect = function(i) {
- this._compiledEffects[i._key] && (delete this._compiledEffects[i._key],
- this._deletePipelineContext(i.getPipelineContext()))
- }
- ,
- e.prototype.releaseEffects = function() {
- for (var i in this._compiledEffects) {
- var o = this._compiledEffects[i].getPipelineContext();
- this._deletePipelineContext(o)
- }
- this._compiledEffects = {}
- }
- ,
- e.prototype._deletePipelineContext = function(i) {
- var o = i;
- o && i.dispose()
- }
- ,
- Object.defineProperty(e.prototype, "needPOTTextures", {
- get: function() {
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._createHardwareTexture = function() {
- return new WebGPUHardwareTexture
- }
- ,
- e.prototype._releaseTexture = function(i) {
- var o = this._internalTexturesCache.indexOf(i);
- o !== -1 && this._internalTexturesCache.splice(o, 1),
- this._textureHelper.releaseTexture(i)
- }
- ,
- e.prototype._getRGBABufferInternalSizedFormat = function(i, o) {
- return 5
- }
- ,
- e.prototype.updateTextureComparisonFunction = function(i, o) {
- i._comparisonFunction = o
- }
- ,
- e.prototype._createInternalTexture = function(i, o, s, c) {
- var d, _;
- s === void 0 && (s = !0),
- c === void 0 && (c = InternalTextureSource.Unknown);
- var b = {};
- o !== void 0 && typeof o == "object" ? (b.generateMipMaps = o.generateMipMaps,
- b.type = o.type === void 0 ? 0 : o.type,
- b.samplingMode = o.samplingMode === void 0 ? 3 : o.samplingMode,
- b.format = o.format === void 0 ? 5 : o.format,
- b.samples = (d = o.samples) !== null && d !== void 0 ? d : 1,
- b.creationFlags = (_ = o.creationFlags) !== null && _ !== void 0 ? _ : 0) : (b.generateMipMaps = o,
- b.type = 0,
- b.samplingMode = 3,
- b.format = 5,
- b.samples = 1,
- b.creationFlags = 0),
- (b.type === 1 && !this._caps.textureFloatLinearFiltering || b.type === 2 && !this._caps.textureHalfFloatLinearFiltering) && (b.samplingMode = 1),
- b.type === 1 && !this._caps.textureFloat && (b.type = 0,
- Logger$2.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE"));
- var k = new InternalTexture(this,c)
- , j = i.width || i
- , $ = i.height || i
- , _e = i.layers || 0;
- return k.baseWidth = j,
- k.baseHeight = $,
- k.width = j,
- k.height = $,
- k.depth = _e,
- k.isReady = !0,
- k.samples = b.samples,
- k.generateMipMaps = !!b.generateMipMaps,
- k.samplingMode = b.samplingMode,
- k.type = b.type,
- k.format = b.format,
- k.is2DArray = _e > 0,
- k._cachedWrapU = 0,
- k._cachedWrapV = 0,
- this._internalTexturesCache.push(k),
- s || this._textureHelper.createGPUTextureForInternalTexture(k, j, $, _e || 1, b.creationFlags),
- k
- }
- ,
- e.prototype.createTexture = function(i, o, s, c, d, _, b, k, j, $, _e, et, tt, rt, it) {
- var nt = this;
- return d === void 0 && (d = 3),
- _ === void 0 && (_ = null),
- b === void 0 && (b = null),
- k === void 0 && (k = null),
- j === void 0 && (j = null),
- $ === void 0 && ($ = null),
- _e === void 0 && (_e = null),
- this._createTextureBase(i, o, s, c, d, _, b, function(ot, at, st, ut, ct, lt, ft, ht, pt) {
- var dt, _t = ut;
- if (ot.baseWidth = _t.width,
- ot.baseHeight = _t.height,
- ot.width = _t.width,
- ot.height = _t.height,
- ot.format = $ != null ? $ : -1,
- ht(ot.width, ot.height, _t, at, ot, function() {}),
- !((dt = ot._hardwareTexture) === null || dt === void 0) && dt.underlyingResource)
- !lt && !ft && nt._generateMipmaps(ot, nt._uploadEncoder);
- else {
- var mt = nt._textureHelper.createGPUTextureForInternalTexture(ot, _t.width, _t.height, void 0, rt);
- WebGPUTextureHelper.IsImageBitmap(_t) && (nt._textureHelper.updateTexture(_t, ot, _t.width, _t.height, ot.depth, mt.format, 0, 0, ct, !1, 0, 0, nt._uploadEncoder),
- !lt && !ft && nt._generateMipmaps(ot, nt._uploadEncoder))
- }
- st && st._removePendingData(ot),
- ot.isReady = !0,
- ot.onLoadedObservable.notifyObservers(ot),
- ot.onLoadedObservable.clear()
- }, function() {
- return !1
- }, k, j, $, _e, et, tt, it)
- }
- ,
- e.prototype.generateMipMapsForCubemap = function(i, o) {
- var s;
- if (i.generateMipMaps) {
- var c = (s = i._hardwareTexture) === null || s === void 0 ? void 0 : s.underlyingResource;
- c || this._textureHelper.createGPUTextureForInternalTexture(i),
- this._generateMipmaps(i, i.source === InternalTextureSource.RenderTarget || i.source === InternalTextureSource.MultiRenderTarget ? this._renderTargetEncoder : void 0)
- }
- }
- ,
- e.prototype.updateTextureSamplingMode = function(i, o, s) {
- s === void 0 && (s = !1),
- s && (o.generateMipMaps = !0,
- this._generateMipmaps(o)),
- o.samplingMode = i
- }
- ,
- e.prototype.updateTextureWrappingMode = function(i, o, s, c) {
- s === void 0 && (s = null),
- c === void 0 && (c = null),
- o !== null && (i._cachedWrapU = o),
- s !== null && (i._cachedWrapV = s),
- (i.is2DArray || i.is3D) && c !== null && (i._cachedWrapR = c)
- }
- ,
- e.prototype.updateTextureDimensions = function(i, o, s, c) {
- if (c === void 0 && (c = 1),
- !!i._hardwareTexture && !(i.width === o && i.height === s && i.depth === c)) {
- var d = i._hardwareTexture.textureAdditionalUsages;
- i._hardwareTexture.release(),
- this._textureHelper.createGPUTextureForInternalTexture(i, o, s, c, d)
- }
- }
- ,
- e.prototype._setInternalTexture = function(i, o, s, c) {
- if (s = s != null ? s : i,
- this._currentEffect) {
- var d = this._currentEffect._pipelineContext
- , _ = d.shaderProcessingContext.availableTextures[s];
- if (this._currentMaterialContext.setTexture(i, o),
- _ && _.autoBindSampler) {
- var b = s + WebGPUShaderProcessor.AutoSamplerSuffix;
- this._currentMaterialContext.setSampler(b, o)
- }
- }
- }
- ,
- e.prototype.setTexture = function(i, o, s, c) {
- this._setTexture(i, s, !1, !1, c, c)
- }
- ,
- e.prototype.setTextureArray = function(i, o, s, c) {
- for (var d = 0; d < s.length; d++)
- this._setTexture(-1, s[d], !0, !1, c + d.toString(), c, d)
- }
- ,
- e.prototype._setTexture = function(i, o, s, c, d, _, b) {
- if (c === void 0 && (c = !1),
- d === void 0 && (d = ""),
- b === void 0 && (b = 0),
- _ = _ != null ? _ : d,
- this._currentEffect) {
- if (!o)
- return this._currentMaterialContext.setTexture(d, null),
- !1;
- if (o.video)
- o.update();
- else if (o.delayLoadState === 4)
- return o.delayLoad(),
- !1;
- var k = null;
- 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,
- k && !k.isMultiview) {
- if (k.isCube && k._cachedCoordinatesMode !== o.coordinatesMode) {
- k._cachedCoordinatesMode = o.coordinatesMode;
- var j = o.coordinatesMode !== 3 && o.coordinatesMode !== 5 ? 1 : 0;
- o.wrapU = j,
- o.wrapV = j
- }
- k._cachedWrapU = o.wrapU,
- k._cachedWrapV = o.wrapV,
- k.is3D && (k._cachedWrapR = o.wrapR),
- this._setAnisotropicLevel(0, k, o.anisotropicFilteringLevel)
- }
- this._setInternalTexture(d, k, _, b)
- } else
- this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0),
- (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - _setTexture called with a null _currentEffect! texture=", o));
- return !0
- }
- ,
- e.prototype._setAnisotropicLevel = function(i, o, s) {
- o._cachedAnisotropicFilteringLevel !== s && (o._cachedAnisotropicFilteringLevel = Math.min(s, this._caps.maxAnisotropy))
- }
- ,
- e.prototype._bindTexture = function(i, o, s) {
- i !== void 0 && this._setInternalTexture(s, o)
- }
- ,
- e.prototype.generateMipmaps = function(i) {
- this._generateMipmaps(i, this._renderTargetEncoder)
- }
- ,
- e.prototype._generateMipmaps = function(i, o) {
- var s = i._hardwareTexture;
- if (!!s) {
- o = o != null ? o : this._currentRenderTarget && !this._currentRenderPass ? this._renderTargetEncoder : this._currentRenderPass ? this._uploadEncoder : this._renderEncoder;
- var c = i._hardwareTexture.format
- , d = WebGPUTextureHelper.ComputeNumMipmapLevels(i.width, i.height);
- this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0),
- (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - generate mipmaps called - width=", i.width, "height=", i.height, "isCube=", i.isCube)),
- i.isCube ? this._textureHelper.generateCubeMipmaps(s, c, d, o) : this._textureHelper.generateMipmaps(s, c, d, 0, o)
- }
- }
- ,
- e.prototype.updateTextureData = function(i, o, s, c, d, _, b, k) {
- var j;
- b === void 0 && (b = 0),
- k === void 0 && (k = 0);
- var $ = i._hardwareTexture;
- !((j = i._hardwareTexture) === null || j === void 0) && j.underlyingResource || ($ = this._textureHelper.createGPUTextureForInternalTexture(i));
- var _e = new Uint8Array(o.buffer,o.byteOffset,o.byteLength);
- this._textureHelper.updateTexture(_e, i, d, _, i.depth, $.format, b, k, i.invertY, !1, s, c, this._uploadEncoder)
- }
- ,
- e.prototype._uploadCompressedDataToTextureDirectly = function(i, o, s, c, d, _, b) {
- var k;
- _ === void 0 && (_ = 0),
- b === void 0 && (b = 0);
- var j = i._hardwareTexture;
- !((k = i._hardwareTexture) === null || k === void 0) && k.underlyingResource || (i.format = o,
- j = this._textureHelper.createGPUTextureForInternalTexture(i, s, c));
- var $ = new Uint8Array(d.buffer,d.byteOffset,d.byteLength);
- this._textureHelper.updateTexture($, i, s, c, i.depth, j.format, _, b, !1, !1, 0, 0, this._uploadEncoder)
- }
- ,
- e.prototype._uploadDataToTextureDirectly = function(i, o, s, c, d, _) {
- var b;
- s === void 0 && (s = 0),
- c === void 0 && (c = 0),
- _ === void 0 && (_ = !1);
- var k = Math.round(Math.log(i.width) * Math.LOG2E)
- , j = Math.round(Math.log(i.height) * Math.LOG2E)
- , $ = _ ? i.width : Math.pow(2, Math.max(k - c, 0))
- , _e = _ ? i.height : Math.pow(2, Math.max(j - c, 0))
- , et = i._hardwareTexture;
- !((b = i._hardwareTexture) === null || b === void 0) && b.underlyingResource || (et = this._textureHelper.createGPUTextureForInternalTexture(i, $, _e));
- var tt = new Uint8Array(o.buffer,o.byteOffset,o.byteLength);
- this._textureHelper.updateTexture(tt, i, $, _e, i.depth, et.format, s, c, i.invertY, !1, 0, 0, this._uploadEncoder)
- }
- ,
- e.prototype._uploadArrayBufferViewToTexture = function(i, o, s, c) {
- s === void 0 && (s = 0),
- c === void 0 && (c = 0),
- this._uploadDataToTextureDirectly(i, o, s, c)
- }
- ,
- e.prototype._uploadImageToTexture = function(i, o, s, c) {
- var d;
- s === void 0 && (s = 0),
- c === void 0 && (c = 0);
- var _ = i._hardwareTexture;
- !((d = i._hardwareTexture) === null || d === void 0) && d.underlyingResource || (_ = this._textureHelper.createGPUTextureForInternalTexture(i));
- var b = o
- , k = Math.ceil(i.width / (1 << c))
- , j = Math.ceil(i.height / (1 << c));
- this._textureHelper.updateTexture(b, i, k, j, i.depth, _.format, s, c, i.invertY, !1, 0, 0, this._uploadEncoder)
- }
- ,
- e.prototype.readPixels = function(i, o, s, c, d, _) {
- _ === void 0 && (_ = !0);
- var b = this._rttRenderPassWrapper.renderPass ? this._rttRenderPassWrapper : this._mainRenderPassWrapper
- , k = b.colorAttachmentGPUTextures[0].underlyingResource
- , j = b.colorAttachmentGPUTextures[0].format;
- return k ? (_ && this.flushFramebuffer(),
- this._textureHelper.readPixels(k, i, o, s, c, j)) : Promise.resolve(new Uint8Array(0))
- }
- ,
- e.prototype.beginFrame = function() {
- a.prototype.beginFrame.call(this)
- }
- ,
- e.prototype.endFrame = function() {
- if (this._snapshotRendering.endFrame(this._mainRenderPassWrapper.renderPass),
- this._endMainRenderPass(),
- this._timestampQuery.endFrame(this._renderEncoder),
- this._invertYFinalFramebuffer && this._mainRenderPassCopyWrapper.renderPassDescriptor.colorAttachments[0].view && this._textureHelper.copyWithInvertY(this._mainTextureLastCopy.createView(), this._mainRenderPassWrapper.colorAttachmentGPUTextures[0].format, this._mainRenderPassCopyWrapper.renderPassDescriptor, this._renderEncoder),
- this.flushFramebuffer(!1),
- this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0),
- (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - counters")),
- this._textureHelper.destroyDeferredTextures(),
- this._bufferManager.destroyDeferredBuffers(),
- this._features._collectUbosUpdatedInFrame) {
- if (this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0),
- !this._count || this._count < this.dbgVerboseLogsNumFrames)) {
- var i = [];
- for (var o in UniformBuffer._updatedUbosInFrame)
- i.push(o + ":" + UniformBuffer._updatedUbosInFrame[o]);
- console.log("frame #" + this._count + " - updated ubos -", i.join(", "))
- }
- UniformBuffer._updatedUbosInFrame = {}
- }
- this.countersLastFrame.numEnableEffects = this._counters.numEnableEffects,
- this.countersLastFrame.numEnableDrawWrapper = this._counters.numEnableDrawWrapper,
- this.countersLastFrame.numBundleCreationNonCompatMode = this._counters.numBundleCreationNonCompatMode,
- this.countersLastFrame.numBundleReuseNonCompatMode = this._counters.numBundleReuseNonCompatMode,
- this._counters.numEnableEffects = 0,
- this._counters.numEnableDrawWrapper = 0,
- this._counters.numBundleCreationNonCompatMode = 0,
- this._counters.numBundleReuseNonCompatMode = 0,
- this._cacheRenderPipeline.endFrame(),
- this._cacheBindGroups.endFrame(),
- this._pendingDebugCommands.length = 0,
- a.prototype.endFrame.call(this),
- this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0),
- this._count < this.dbgVerboseLogsNumFrames && console.log("%c frame #" + this._count + " - end", "background: #ffff00"),
- this._count < this.dbgVerboseLogsNumFrames && (this._count++,
- this._count !== this.dbgVerboseLogsNumFrames && console.log("%c frame #" + this._count + " - begin", "background: #ffff00")))
- }
- ,
- e.prototype.flushFramebuffer = function(i) {
- i === void 0 && (i = !0);
- var o = !this._currentRenderPass
- , s = 0;
- this._currentRenderPass && this._currentRenderTarget && (s |= 1,
- this._endRenderTargetRenderPass()),
- this._mainRenderPassWrapper.renderPass && (s |= 2,
- this._endMainRenderPass()),
- this._commandBuffers[0] = this._uploadEncoder.finish(),
- this._commandBuffers[1] = this._renderTargetEncoder.finish(),
- this._commandBuffers[2] = this._renderEncoder.finish(),
- this._device.queue.submit(this._commandBuffers),
- this._uploadEncoder = this._device.createCommandEncoder(this._uploadEncoderDescriptor),
- this._renderEncoder = this._device.createCommandEncoder(this._renderEncoderDescriptor),
- this._renderTargetEncoder = this._device.createCommandEncoder(this._renderTargetEncoderDescriptor),
- this._timestampQuery.startFrame(this._uploadEncoder),
- this._textureHelper.setCommandEncoder(this._uploadEncoder),
- this._bundleList.reset(),
- this._bundleListRenderTarget.reset(),
- i && (s & 2 && this._startMainRenderPass(!1),
- s & 1 && this._startRenderTargetRenderPass(this._currentRenderTarget, !1, null, !1, !1),
- o && this._currentRenderTarget && (this._currentRenderPass = null))
- }
- ,
- e.prototype._currentFrameBufferIsDefaultFrameBuffer = function() {
- return this._currentRenderTarget === null
- }
- ,
- e.prototype._startRenderTargetRenderPass = function(i, o, s, c, d) {
- 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 = [];
- this.useReverseDepthBuffer && this.setDepthFunctionToGreaterOrEqual();
- var nt = o && s || LoadOp.Load
- , ot = o && c ? this.useReverseDepthBuffer ? this._clearReverseDepthValue : this._clearDepthValue : LoadOp.Load
- , at = o && d ? this._clearStencilValue : LoadOp.Load;
- if (i._attachments && i.isMulti) {
- (!this._mrtAttachments || this._mrtAttachments.length === 0) && (this._mrtAttachments = i._attachments);
- for (var st = 0; st < this._mrtAttachments.length; ++st) {
- var ut = this._mrtAttachments[st];
- if (ut !== 0) {
- var ct = i.textures[ut - 1]
- , lt = ct == null ? void 0 : ct._hardwareTexture
- , ft = lt == null ? void 0 : lt.underlyingResource;
- if (lt && ft) {
- var ht = __assign(__assign({}, this._rttRenderPassWrapper.colorAttachmentViewDescriptor), {
- format: lt.format
- })
- , pt = lt.msaaTexture
- , dt = ft.createView(ht)
- , _t = pt == null ? void 0 : pt.createView(ht);
- it.push({
- view: _t || dt,
- resolveTarget: pt ? dt : void 0,
- loadValue: nt,
- storeOp: StoreOp.Store
- })
- }
- }
- }
- this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments, i.textures)
- } else {
- var mt = i.texture
- , vt = mt._hardwareTexture
- , yt = vt.underlyingResource
- , pt = vt.msaaTexture
- , dt = yt.createView(this._rttRenderPassWrapper.colorAttachmentViewDescriptor)
- , _t = pt == null ? void 0 : pt.createView(this._rttRenderPassWrapper.colorAttachmentViewDescriptor);
- it.push({
- view: _t || dt,
- resolveTarget: pt ? dt : void 0,
- loadValue: nt,
- storeOp: StoreOp.Store
- })
- }
- if ((_ = this._debugPushGroup) === null || _ === void 0 || _.call(this, "render target pass", 1),
- this._rttRenderPassWrapper.renderPassDescriptor = {
- colorAttachments: it,
- depthStencilAttachment: j && _e ? {
- view: rt || tt,
- depthLoadValue: ot,
- depthStoreOp: StoreOp.Store,
- stencilLoadValue: i._depthStencilTextureWithStencil ? at : LoadOp.Load,
- stencilStoreOp: StoreOp.Store
- } : void 0,
- occlusionQuerySet: !((b = this._occlusionQuery) === null || b === void 0) && b.hasQueries ? this._occlusionQuery.querySet : void 0
- },
- this._rttRenderPassWrapper.renderPass = this._renderTargetEncoder.beginRenderPass(this._rttRenderPassWrapper.renderPassDescriptor),
- this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0),
- !this._count || this._count < this.dbgVerboseLogsNumFrames)) {
- var mt = i.texture;
- console.log("frame #" + this._count + " - render target begin pass - internalTexture.uniqueId=", mt.uniqueId, "width=", mt.width, "height=", mt.height, this._rttRenderPassWrapper.renderPassDescriptor)
- }
- this._currentRenderPass = this._rttRenderPassWrapper.renderPass,
- (k = this._debugFlushPendingCommands) === null || k === void 0 || k.call(this),
- this._resetCurrentViewport(1),
- this._resetCurrentScissor(1),
- this._resetCurrentStencilRef(1),
- this._resetCurrentColorBlend(1)
- }
- ,
- e.prototype._endRenderTargetRenderPass = function() {
- var i, o, s;
- if (this._currentRenderPass) {
- var c = this._currentRenderTarget.texture._hardwareTexture;
- !this._snapshotRendering.endRenderTargetPass(this._currentRenderPass, c) && !this.compatibilityMode && (this._bundleListRenderTarget.run(this._currentRenderPass),
- this._bundleListRenderTarget.reset()),
- this._currentRenderPass.endPass(),
- this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0),
- (!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)),
- (s = this._debugPopGroup) === null || s === void 0 || s.call(this, 1),
- this._resetCurrentViewport(1),
- this._resetCurrentScissor(1),
- this._resetCurrentStencilRef(1),
- this._resetCurrentColorBlend(1),
- this._currentRenderPass = null,
- this._rttRenderPassWrapper.reset()
- }
- }
- ,
- e.prototype._getCurrentRenderPass = function() {
- return this._currentRenderTarget && !this._currentRenderPass ? this._startRenderTargetRenderPass(this._currentRenderTarget, !1, null, !1, !1) : this._currentRenderPass || this._startMainRenderPass(!1),
- this._currentRenderPass
- }
- ,
- e.prototype._getCurrentRenderPassIndex = function() {
- return this._currentRenderPass === null ? -1 : this._currentRenderPass === this._mainRenderPassWrapper.renderPass ? 0 : 1
- }
- ,
- e.prototype._startMainRenderPass = function(i, o, s, c) {
- var d, _, b;
- this._mainRenderPassWrapper.renderPass && this._endMainRenderPass(),
- this.useReverseDepthBuffer && this.setDepthFunctionToGreaterOrEqual();
- var k = i && o || LoadOp.Load
- , j = i && s ? this.useReverseDepthBuffer ? this._clearReverseDepthValue : this._clearDepthValue : LoadOp.Load
- , $ = i && c ? this._clearStencilValue : LoadOp.Load;
- this._mainRenderPassWrapper.renderPassDescriptor.colorAttachments[0].loadValue = k,
- this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.depthLoadValue = j,
- this._mainRenderPassWrapper.renderPassDescriptor.depthStencilAttachment.stencilLoadValue = $,
- this._mainRenderPassWrapper.renderPassDescriptor.occlusionQuerySet = !((d = this._occlusionQuery) === null || d === void 0) && d.hasQueries ? this._occlusionQuery.querySet : void 0;
- var _e = this._invertYFinalFramebuffer ? this._mainRenderPassCopyWrapper : this._mainRenderPassWrapper;
- this._swapChainTexture = this._context.getCurrentTexture(),
- _e.colorAttachmentGPUTextures[0].set(this._swapChainTexture),
- 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(),
- this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0),
- (!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)),
- (_ = this._debugPushGroup) === null || _ === void 0 || _.call(this, "main pass", 0),
- this._currentRenderPass = this._renderEncoder.beginRenderPass(this._mainRenderPassWrapper.renderPassDescriptor),
- this._mainRenderPassWrapper.renderPass = this._currentRenderPass,
- (b = this._debugFlushPendingCommands) === null || b === void 0 || b.call(this),
- this._resetCurrentViewport(0),
- this._resetCurrentScissor(0),
- this._resetCurrentStencilRef(0),
- this._resetCurrentColorBlend(0)
- }
- ,
- e.prototype._endMainRenderPass = function() {
- var i;
- this._mainRenderPassWrapper.renderPass !== null && (this._snapshotRendering.endMainRenderPass(),
- !this.compatibilityMode && !this._snapshotRendering.play && (this._bundleList.run(this._mainRenderPassWrapper.renderPass),
- this._bundleList.reset()),
- this._mainRenderPassWrapper.renderPass.endPass(),
- this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0),
- (!this._count || this._count < this.dbgVerboseLogsNumFrames) && console.log("frame #" + this._count + " - main end pass")),
- (i = this._debugPopGroup) === null || i === void 0 || i.call(this, 0),
- this._resetCurrentViewport(0),
- this._resetCurrentScissor(0),
- this._resetCurrentStencilRef(0),
- this._resetCurrentColorBlend(0),
- this._mainRenderPassWrapper.renderPass === this._currentRenderPass && (this._currentRenderPass = null),
- this._mainRenderPassWrapper.reset(!1))
- }
- ,
- e.prototype.bindFramebuffer = function(i, o, s, c, d, _, b) {
- var k, j;
- o === void 0 && (o = 0),
- _ === void 0 && (_ = 0),
- b === void 0 && (b = 0);
- var $ = (k = i.texture) === null || k === void 0 ? void 0 : k._hardwareTexture;
- if (!$) {
- this.dbgSanityChecks && console.error("bindFramebuffer: Trying to bind a texture that does not have a hardware texture!", i, $);
- return
- }
- this._currentRenderTarget && this.unBindFramebuffer(this._currentRenderTarget),
- this._currentRenderTarget = i,
- $._currentLayer = i.isCube ? b * 6 + o : b,
- this._rttRenderPassWrapper.colorAttachmentGPUTextures[0] = $,
- this._rttRenderPassWrapper.depthTextureFormat = this._currentRenderTarget._depthStencilTexture ? WebGPUTextureHelper.GetWebGPUTextureFormat(-1, this._currentRenderTarget._depthStencilTexture.format) : void 0,
- this._setDepthTextureFormat(this._rttRenderPassWrapper),
- this._setColorFormat(this._rttRenderPassWrapper),
- this._rttRenderPassWrapper.colorAttachmentViewDescriptor = {
- format: this._colorFormat,
- dimension: TextureViewDimension.E2d,
- mipLevelCount: 1,
- baseArrayLayer: i.isCube ? b * 6 + o : b,
- baseMipLevel: _,
- arrayLayerCount: 1,
- aspect: TextureAspect.All
- },
- this._rttRenderPassWrapper.depthAttachmentViewDescriptor = {
- format: this._depthTextureFormat,
- dimension: TextureViewDimension.E2d,
- mipLevelCount: 1,
- baseArrayLayer: i.isCube ? b * 6 + o : b,
- baseMipLevel: 0,
- arrayLayerCount: 1,
- aspect: TextureAspect.All
- },
- this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0),
- (!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)),
- this._currentRenderPass = null,
- this.snapshotRendering && this.snapshotRenderingMode === 1 && this._getCurrentRenderPass(),
- this._cachedViewport && !d ? this.setViewport(this._cachedViewport, s, c) : (s || (s = i.width,
- _ && (s = s / Math.pow(2, _))),
- c || (c = i.height,
- _ && (c = c / Math.pow(2, _))),
- this._viewport(0, 0, s, c)),
- this.wipeCaches()
- }
- ,
- e.prototype.unBindFramebuffer = function(i, o, s) {
- var c, d;
- o === void 0 && (o = !1);
- var _ = this._currentRenderTarget;
- this._currentRenderTarget = null,
- s && s(),
- this._currentRenderTarget = _,
- this._currentRenderPass && this._currentRenderPass !== this._mainRenderPassWrapper.renderPass && this._endRenderTargetRenderPass(),
- ((c = i.texture) === null || c === void 0 ? void 0 : c.generateMipMaps) && !o && !i.isCube && this._generateMipmaps(i.texture),
- this._currentRenderTarget = null,
- this._onAfterUnbindFrameBufferObservable.notifyObservers(this),
- this.dbgVerboseLogsForFirstFrames && (this._count === void 0 && (this._count = 0),
- (!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)),
- this._mrtAttachments = [],
- this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments, []),
- this._currentRenderPass = this._mainRenderPassWrapper.renderPass,
- this._setDepthTextureFormat(this._mainRenderPassWrapper),
- this._setColorFormat(this._mainRenderPassWrapper)
- }
- ,
- e.prototype.restoreDefaultFramebuffer = function() {
- this._currentRenderTarget ? this.unBindFramebuffer(this._currentRenderTarget) : (this._currentRenderPass = this._mainRenderPassWrapper.renderPass,
- this._setDepthTextureFormat(this._mainRenderPassWrapper),
- this._setColorFormat(this._mainRenderPassWrapper)),
- this._currentRenderPass && this._cachedViewport && this.setViewport(this._cachedViewport),
- this.wipeCaches()
- }
- ,
- e.prototype._setColorFormat = function(i) {
- var o = i.colorAttachmentGPUTextures[0].format;
- this._cacheRenderPipeline.setColorFormat(o),
- this._colorFormat !== o && (this._colorFormat = o)
- }
- ,
- e.prototype._setDepthTextureFormat = function(i) {
- this._cacheRenderPipeline.setDepthStencilFormat(i.depthTextureFormat),
- this._depthTextureFormat !== i.depthTextureFormat && (this._depthTextureFormat = i.depthTextureFormat)
- }
- ,
- e.prototype.setDitheringState = function(i) {}
- ,
- e.prototype.setRasterizerState = function(i) {}
- ,
- e.prototype.setState = function(i, o, s, c, d, _, b) {
- var k, j;
- o === void 0 && (o = 0),
- c === void 0 && (c = !1),
- b === void 0 && (b = 0),
- (this._depthCullingState.cull !== i || s) && (this._depthCullingState.cull = i);
- var $ = !((j = (k = this.cullBackFaces) !== null && k !== void 0 ? k : d) !== null && j !== void 0) || j ? 1 : 2;
- (this._depthCullingState.cullFace !== $ || s) && (this._depthCullingState.cullFace = $),
- this.setZOffset(o),
- this.setZOffsetUnits(b);
- var _e = c ? 1 : 2;
- (this._depthCullingState.frontFace !== _e || s) && (this._depthCullingState.frontFace = _e),
- this._stencilStateComposer.stencilMaterial = _
- }
- ,
- e.prototype._applyRenderPassChanges = function(i, o) {
- 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;
- o ? (c && o.addItem(new WebGPURenderItemViewport(this._viewportCached.x,this._viewportCached.y,this._viewportCached.z,this._viewportCached.w)),
- d && o.addItem(new WebGPURenderItemScissor(this._scissorCached.x,this._scissorCached.y,this._scissorCached.z,this._scissorCached.w)),
- _ && o.addItem(new WebGPURenderItemStencilRef((s = this._stencilStateComposer.funcRef) !== null && s !== void 0 ? s : 0)),
- b && o.addItem(new WebGPURenderItemBlendColor(this._alphaState._blendConstants.slice()))) : (c && this._applyViewport(i),
- d && this._applyScissor(i),
- _ && this._applyStencilRef(i),
- b && this._applyBlendColor(i))
- }
- ,
- e.prototype._draw = function(i, o, s, c, d) {
- var _, b = this._getCurrentRenderPass(), k = this._getCurrentRenderPassIndex(), j = k === 0 ? this._bundleList : this._bundleListRenderTarget;
- this.applyStates();
- var $ = this._currentEffect._pipelineContext;
- if ($.uniformBuffer && ($.uniformBuffer.update(),
- this.bindUniformBufferBase($.uniformBuffer.getBuffer(), 0, WebGPUShaderProcessor.LeftOvertUBOName)),
- this._snapshotRendering.play) {
- this._reportDrawCall();
- return
- }
- !this.compatibilityMode && (this._currentDrawContext.isDirty(this._currentMaterialContext.updateId) || this._currentMaterialContext.isDirty || this._currentMaterialContext.forceBindGroupCreation) && (this._currentDrawContext.fastBundle = void 0);
- var _e = !this.compatibilityMode && this._currentDrawContext.fastBundle
- , et = b;
- if (_e || this._snapshotRendering.record) {
- if (this._applyRenderPassChanges(b, j),
- !this._snapshotRendering.record) {
- this._counters.numBundleReuseNonCompatMode++,
- this._currentDrawContext.indirectDrawBuffer && this._currentDrawContext.setIndirectData(c, d || 1, s),
- j.addBundle(this._currentDrawContext.fastBundle),
- this._reportDrawCall();
- return
- }
- et = j.getBundleEncoder(this._cacheRenderPipeline.colorFormats, this._depthTextureFormat, this.currentSampleCount),
- j.numDrawCalls++
- }
- var tt = 0;
- if (!this._caps.textureFloatLinearFiltering && this._currentMaterialContext.hasFloatTextures)
- for (var rt = 1, it = 0; it < $.shaderProcessingContext.textureNames.length; ++it) {
- var nt = $.shaderProcessingContext.textureNames[it]
- , ot = (_ = this._currentMaterialContext.textures[nt]) === null || _ === void 0 ? void 0 : _.texture;
- (ot == null ? void 0 : ot.type) === 1 && (tt |= rt),
- rt = rt << 1
- }
- var at = this._cacheRenderPipeline.getRenderPipeline(o, this._currentEffect, this.currentSampleCount, tt)
- , st = this._cacheBindGroups.getBindGroups($, this._currentDrawContext, this._currentMaterialContext);
- this._snapshotRendering.record || (this._applyRenderPassChanges(b, this.compatibilityMode ? null : j),
- this.compatibilityMode || (this._counters.numBundleCreationNonCompatMode++,
- et = this._device.createRenderBundleEncoder({
- colorFormats: this._cacheRenderPipeline.colorFormats,
- depthStencilFormat: this._depthTextureFormat,
- sampleCount: this.currentSampleCount
- }))),
- et.setPipeline(at),
- this._currentIndexBuffer && et.setIndexBuffer(this._currentIndexBuffer.underlyingResource, this._currentIndexBuffer.is32Bits ? IndexFormat.Uint32 : IndexFormat.Uint16, 0);
- for (var ut = this._cacheRenderPipeline.vertexBuffers, ct = 0; ct < ut.length; ct++) {
- var lt = ut[ct]
- , ft = lt.getBuffer();
- ft && et.setVertexBuffer(ct, ft.underlyingResource, lt._validOffsetRange ? 0 : lt.byteOffset)
- }
- for (var it = 0; it < st.length; it++)
- et.setBindGroup(it, st[it]);
- var ht = !this.compatibilityMode && !this._snapshotRendering.record;
- ht && this._currentDrawContext.indirectDrawBuffer ? (this._currentDrawContext.setIndirectData(c, d || 1, s),
- 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),
- ht && (this._currentDrawContext.fastBundle = et.finish(),
- j.addBundle(this._currentDrawContext.fastBundle)),
- this._reportDrawCall()
- }
- ,
- e.prototype.drawElementsType = function(i, o, s, c) {
- c === void 0 && (c = 1),
- this._draw(0, i, o, s, c)
- }
- ,
- e.prototype.drawArraysType = function(i, o, s, c) {
- c === void 0 && (c = 1),
- this._currentIndexBuffer = null,
- this._draw(1, i, o, s, c)
- }
- ,
- e.prototype.dispose = function() {
- var i, o, s;
- (i = this._mainTexture) === null || i === void 0 || i.destroy(),
- (o = this._mainTextureLastCopy) === null || o === void 0 || o.destroy(),
- (s = this._depthTexture) === null || s === void 0 || s.destroy(),
- a.prototype.dispose.call(this)
- }
- ,
- e.prototype.getRenderWidth = function(i) {
- return i === void 0 && (i = !1),
- !i && this._currentRenderTarget ? this._currentRenderTarget.width : this._canvas.width
- }
- ,
- e.prototype.getRenderHeight = function(i) {
- return i === void 0 && (i = !1),
- !i && this._currentRenderTarget ? this._currentRenderTarget.height : this._canvas.height
- }
- ,
- e.prototype.getRenderingCanvas = function() {
- return this._canvas
- }
- ,
- e.prototype.getError = function() {
- return 0
- }
- ,
- e.prototype.bindSamplers = function(i) {}
- ,
- e.prototype._bindTextureDirectly = function(i, o, s, c) {
- return !1
- }
- ,
- e.prototype.areAllEffectsReady = function() {
- return !0
- }
- ,
- e.prototype._executeWhenRenderingStateIsCompiled = function(i, o) {
- o()
- }
- ,
- e.prototype._isRenderingStateCompiled = function(i) {
- return !0
- }
- ,
- e.prototype._getUnpackAlignement = function() {
- return 1
- }
- ,
- e.prototype._unpackFlipY = function(i) {}
- ,
- e.prototype._bindUnboundFramebuffer = function(i) {
- throw "_bindUnboundFramebuffer is not implementedin WebGPU! You probably want to use restoreDefaultFramebuffer or unBindFramebuffer instead"
- }
- ,
- e.prototype._getSamplingParameters = function(i, o) {
- throw "_getSamplingParameters is not available in WebGPU"
- }
- ,
- e.prototype.getUniforms = function(i, o) {
- return []
- }
- ,
- e.prototype.setIntArray = function(i, o) {
- return !1
- }
- ,
- e.prototype.setIntArray2 = function(i, o) {
- return !1
- }
- ,
- e.prototype.setIntArray3 = function(i, o) {
- return !1
- }
- ,
- e.prototype.setIntArray4 = function(i, o) {
- return !1
- }
- ,
- e.prototype.setArray = function(i, o) {
- return !1
- }
- ,
- e.prototype.setArray2 = function(i, o) {
- return !1
- }
- ,
- e.prototype.setArray3 = function(i, o) {
- return !1
- }
- ,
- e.prototype.setArray4 = function(i, o) {
- return !1
- }
- ,
- e.prototype.setMatrices = function(i, o) {
- return !1
- }
- ,
- e.prototype.setMatrix3x3 = function(i, o) {
- return !1
- }
- ,
- e.prototype.setMatrix2x2 = function(i, o) {
- return !1
- }
- ,
- e.prototype.setFloat = function(i, o) {
- return !1
- }
- ,
- e.prototype.setFloat2 = function(i, o, s) {
- return !1
- }
- ,
- e.prototype.setFloat3 = function(i, o, s, c) {
- return !1
- }
- ,
- e.prototype.setFloat4 = function(i, o, s, c, d) {
- return !1
- }
- ,
- e._glslangDefaultOptions = {
- jsPath: "https://preview.babylonjs.com/glslang/glslang.js",
- wasmPath: "https://preview.babylonjs.com/glslang/glslang.wasm"
- },
- e.UseTWGSL = !0,
- e
- }(Engine);
- WebGPUEngine.prototype.setAlphaMode = function(a, e) {
- if (e === void 0 && (e = !1),
- !(this._alphaMode === a && (a === 0 && !this._alphaState.alphaBlend || a !== 0 && this._alphaState.alphaBlend))) {
- switch (a) {
- case 0:
- this._alphaState.alphaBlend = !1;
- break;
- case 7:
- this._alphaState.setAlphaBlendFunctionParameters(1, 771, 1, 1),
- this._alphaState.alphaBlend = !0;
- break;
- case 8:
- this._alphaState.setAlphaBlendFunctionParameters(1, 771, 1, 771),
- this._alphaState.alphaBlend = !0;
- break;
- case 2:
- this._alphaState.setAlphaBlendFunctionParameters(770, 771, 1, 1),
- this._alphaState.alphaBlend = !0;
- break;
- case 6:
- this._alphaState.setAlphaBlendFunctionParameters(1, 1, 0, 1),
- this._alphaState.alphaBlend = !0;
- break;
- case 1:
- this._alphaState.setAlphaBlendFunctionParameters(770, 1, 0, 1),
- this._alphaState.alphaBlend = !0;
- break;
- case 3:
- this._alphaState.setAlphaBlendFunctionParameters(0, 769, 1, 1),
- this._alphaState.alphaBlend = !0;
- break;
- case 4:
- this._alphaState.setAlphaBlendFunctionParameters(774, 0, 1, 1),
- this._alphaState.alphaBlend = !0;
- break;
- case 5:
- this._alphaState.setAlphaBlendFunctionParameters(770, 769, 1, 1),
- this._alphaState.alphaBlend = !0;
- break;
- case 9:
- this._alphaState.setAlphaBlendFunctionParameters(32769, 32770, 32771, 32772),
- this._alphaState.alphaBlend = !0;
- break;
- case 10:
- this._alphaState.setAlphaBlendFunctionParameters(1, 769, 1, 771),
- this._alphaState.alphaBlend = !0;
- break;
- case 11:
- this._alphaState.setAlphaBlendFunctionParameters(1, 1, 1, 1),
- this._alphaState.alphaBlend = !0;
- break;
- case 12:
- this._alphaState.setAlphaBlendFunctionParameters(772, 1, 0, 0),
- this._alphaState.alphaBlend = !0;
- break;
- case 13:
- this._alphaState.setAlphaBlendFunctionParameters(775, 769, 773, 771),
- this._alphaState.alphaBlend = !0;
- break;
- case 14:
- this._alphaState.setAlphaBlendFunctionParameters(1, 771, 1, 771),
- this._alphaState.alphaBlend = !0;
- break;
- case 15:
- this._alphaState.setAlphaBlendFunctionParameters(1, 1, 1, 0),
- this._alphaState.alphaBlend = !0;
- break;
- case 16:
- this._alphaState.setAlphaBlendFunctionParameters(775, 769, 0, 1),
- this._alphaState.alphaBlend = !0;
- break;
- case 17:
- this._alphaState.setAlphaBlendFunctionParameters(770, 771, 1, 771),
- this._alphaState.alphaBlend = !0;
- break
- }
- e || (this.setDepthWrite(a === Engine.ALPHA_DISABLE),
- this._cacheRenderPipeline.setDepthWriteEnabled(a === Engine.ALPHA_DISABLE)),
- this._alphaMode = a,
- this._cacheRenderPipeline.setAlphaBlendEnabled(this._alphaState.alphaBlend),
- this._cacheRenderPipeline.setAlphaBlendFactors(this._alphaState._blendFunctionParameters, this._alphaState._blendEquationParameters)
- }
- }
- ;
- WebGPUEngine.prototype.setAlphaEquation = function(a) {
- Engine.prototype.setAlphaEquation.call(this, a),
- this._cacheRenderPipeline.setAlphaBlendFactors(this._alphaState._blendFunctionParameters, this._alphaState._blendEquationParameters)
- }
- ;
- var ComputeEffect = function() {
- function a(e, i, o, s) {
- var c = this;
- s === void 0 && (s = "");
- var d, _;
- this.name = null,
- this.defines = "",
- this.onCompiled = null,
- this.onError = null,
- this.uniqueId = 0,
- this.onCompileObservable = new Observable,
- this.onErrorObservable = new Observable,
- this.onBindObservable = new Observable,
- this._wasPreviouslyReady = !1,
- this._isReady = !1,
- this._compilationError = "",
- this._key = "",
- this._computeSourceCodeOverride = "",
- this._pipelineContext = null,
- this._computeSourceCode = "",
- this._rawComputeSourceCode = "",
- this._shaderLanguage = ShaderLanguage.WGSL,
- this.name = e,
- this._key = s,
- this._engine = o,
- this.uniqueId = a._uniqueIdSeed++,
- this.defines = (d = i.defines) !== null && d !== void 0 ? d : "",
- this.onError = i.onError,
- this.onCompiled = i.onCompiled,
- this._entryPoint = (_ = i.entryPoint) !== null && _ !== void 0 ? _ : "main",
- this._shaderStore = ShaderStore.GetShadersStore(this._shaderLanguage),
- this._shaderRepository = ShaderStore.GetShadersRepository(this._shaderLanguage),
- this._includeShaderStore = ShaderStore.GetIncludesShadersStore(this._shaderLanguage);
- var b, k = IsWindowObjectExist() ? this._engine.getHostDocument() : null;
- e.computeSource ? b = "source:" + e.computeSource : e.computeElement ? (b = k ? k.getElementById(e.computeElement) : null,
- b || (b = e.computeElement)) : b = e.compute || e;
- var j = {
- defines: this.defines.split(`
- `),
- indexParameters: void 0,
- isFragment: !1,
- shouldUseHighPrecisionShader: !1,
- processor: null,
- supportsUniformBuffers: this._engine.supportsUniformBuffers,
- shadersRepository: this._shaderRepository,
- includesShadersStore: this._includeShaderStore,
- version: (this._engine.version * 100).toString(),
- platformName: this._engine.shaderPlatformName,
- processingContext: null,
- isNDCHalfZRange: this._engine.isNDCHalfZRange,
- useReverseDepthBuffer: this._engine.useReverseDepthBuffer
- };
- this._loadShader(b, "Compute", "", function($) {
- ShaderProcessor.Initialize(j),
- ShaderProcessor.PreProcess($, j, function(_e) {
- c._rawComputeSourceCode = $,
- i.processFinalCode && (_e = i.processFinalCode(_e));
- var et = ShaderProcessor.Finalize(_e, "", j);
- c._useFinalCode(et.vertexCode, e)
- }, c._engine)
- })
- }
- return a.prototype._useFinalCode = function(e, i) {
- if (i) {
- var o = i.computeElement || i.compute || i.spectorName || i;
- this._computeSourceCode = "//#define SHADER_NAME compute:" + o + `
- ` + e
- } else
- this._computeSourceCode = e;
- this._prepareEffect()
- }
- ,
- Object.defineProperty(a.prototype, "key", {
- get: function() {
- return this._key
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.isReady = function() {
- try {
- return this._isReadyInternal()
- } catch {
- return !1
- }
- }
- ,
- a.prototype._isReadyInternal = function() {
- return this._isReady ? !0 : this._pipelineContext ? this._pipelineContext.isReady : !1
- }
- ,
- a.prototype.getEngine = function() {
- return this._engine
- }
- ,
- a.prototype.getPipelineContext = function() {
- return this._pipelineContext
- }
- ,
- a.prototype.getCompilationError = function() {
- return this._compilationError
- }
- ,
- a.prototype.executeWhenCompiled = function(e) {
- var i = this;
- if (this.isReady()) {
- e(this);
- return
- }
- this.onCompileObservable.add(function(o) {
- e(o)
- }),
- (!this._pipelineContext || this._pipelineContext.isAsync) && setTimeout(function() {
- i._checkIsReady(null)
- }, 16)
- }
- ,
- a.prototype._checkIsReady = function(e) {
- var i = this;
- try {
- if (this._isReadyInternal())
- return
- } catch (o) {
- this._processCompilationErrors(o, e);
- return
- }
- setTimeout(function() {
- i._checkIsReady(e)
- }, 16)
- }
- ,
- a.prototype._loadShader = function(e, i, o, s) {
- if (typeof HTMLElement != "undefined" && e instanceof HTMLElement) {
- var c = GetDOMTextContent(e);
- s(c);
- return
- }
- if (e.substr(0, 7) === "source:") {
- s(e.substr(7));
- return
- }
- if (e.substr(0, 7) === "base64:") {
- var d = window.atob(e.substr(7));
- s(d);
- return
- }
- if (this._shaderStore[e + i + "Shader"]) {
- s(this._shaderStore[e + i + "Shader"]);
- return
- }
- if (o && this._shaderStore[e + o + "Shader"]) {
- s(this._shaderStore[e + o + "Shader"]);
- return
- }
- var _;
- e[0] === "." || e[0] === "/" || e.indexOf("http") > -1 ? _ = e : _ = this._shaderRepository + e,
- this._engine._loadFile(_ + "." + i.toLowerCase() + ".fx", s)
- }
- ,
- Object.defineProperty(a.prototype, "computeSourceCode", {
- get: function() {
- var e, i;
- return this._computeSourceCodeOverride ? this._computeSourceCodeOverride : (i = (e = this._pipelineContext) === null || e === void 0 ? void 0 : e._getComputeShaderCode()) !== null && i !== void 0 ? i : this._computeSourceCode
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "rawComputeSourceCode", {
- get: function() {
- return this._rawComputeSourceCode
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._prepareEffect = function() {
- var e = this
- , i = this.defines
- , o = this._pipelineContext;
- this._isReady = !1;
- try {
- var s = this._engine;
- this._pipelineContext = s.createComputePipelineContext(),
- this._pipelineContext._name = this._key,
- s._prepareComputePipelineContext(this._pipelineContext, this._computeSourceCodeOverride ? this._computeSourceCodeOverride : this._computeSourceCode, this._rawComputeSourceCode, this._computeSourceCodeOverride ? null : i, this._entryPoint),
- s._executeWhenComputeStateIsCompiled(this._pipelineContext, function() {
- e._compilationError = "",
- e._isReady = !0,
- e.onCompiled && e.onCompiled(e),
- e.onCompileObservable.notifyObservers(e),
- e.onCompileObservable.clear(),
- o && e.getEngine()._deleteComputePipelineContext(o)
- }),
- this._pipelineContext.isAsync && this._checkIsReady(o)
- } catch (c) {
- this._processCompilationErrors(c, o)
- }
- }
- ,
- a.prototype._getShaderCodeAndErrorLine = function(e, i) {
- var o = /COMPUTE SHADER ERROR: 0:(\d+?):/
- , s = null;
- if (i && e) {
- var c = i.match(o);
- if (c && c.length === 2) {
- var d = parseInt(c[1])
- , _ = e.split(`
- `, -1);
- _.length >= d && (s = "Offending line [" + d + "] in compute code: " + _[d - 1])
- }
- }
- return [e, s]
- }
- ,
- a.prototype._processCompilationErrors = function(e, i) {
- var o, s;
- if (i === void 0 && (i = null),
- this._compilationError = e.message,
- Logger$2.Error("Unable to compile compute effect:"),
- Logger$2.Error(`Defines:\r
- ` + this.defines),
- a.LogShaderCodeOnCompilationError) {
- var c = null
- , d = null;
- !((s = this._pipelineContext) === null || s === void 0) && s._getComputeShaderCode() && (o = this._getShaderCodeAndErrorLine(this._pipelineContext._getComputeShaderCode(), this._compilationError),
- d = o[0],
- c = o[1],
- d && (Logger$2.Error("Compute code:"),
- Logger$2.Error(d))),
- c && Logger$2.Error(c)
- }
- Logger$2.Error("Error: " + this._compilationError),
- i && (this._pipelineContext = i,
- this._isReady = !0,
- this.onError && this.onError(this, this._compilationError),
- this.onErrorObservable.notifyObservers(this))
- }
- ,
- a.prototype.dispose = function() {
- this._pipelineContext && this._pipelineContext.dispose(),
- this._engine._releaseComputeEffect(this)
- }
- ,
- a.RegisterShader = function(e, i) {
- ShaderStore.GetShadersStore(ShaderLanguage.WGSL)[e + "ComputeShader"] = i
- }
- ,
- a._uniqueIdSeed = 0,
- a.LogShaderCodeOnCompilationError = !0,
- a
- }()
- , WebGPUComputeContext = function() {
- function a(e, i) {
- this._device = e,
- this._cacheSampler = i,
- this.uniqueId = a._Counter++,
- this._bindGroupEntries = [],
- this.clear()
- }
- return a.prototype.getBindGroups = function(e, i, o) {
- if (!o)
- throw new Error("WebGPUComputeContext.getBindGroups: bindingsMapping is required until browsers support reflection for wgsl shaders!");
- if (this._bindGroups.length === 0) {
- var s = this._bindGroupEntries.length > 0;
- for (var c in e) {
- var d = e[c]
- , _ = o[c]
- , b = _.group
- , k = _.binding
- , j = d.type
- , $ = d.object
- , _e = d.indexInGroupEntries
- , et = this._bindGroupEntries[b];
- switch (et || (et = this._bindGroupEntries[b] = []),
- j) {
- case ComputeBindingType.Sampler:
- {
- var tt = $;
- _e !== void 0 && s ? et[_e].resource = this._cacheSampler.getSampler(tt) : (d.indexInGroupEntries = et.length,
- et.push({
- binding: k,
- resource: this._cacheSampler.getSampler(tt)
- }));
- break
- }
- case ComputeBindingType.Texture:
- case ComputeBindingType.TextureWithoutSampler:
- {
- var rt = $
- , it = rt._texture._hardwareTexture;
- _e !== void 0 && s ? (j === ComputeBindingType.Texture && (et[_e++].resource = this._cacheSampler.getSampler(rt._texture)),
- et[_e].resource = it.view) : (d.indexInGroupEntries = et.length,
- j === ComputeBindingType.Texture && et.push({
- binding: k - 1,
- resource: this._cacheSampler.getSampler(rt._texture)
- }),
- et.push({
- binding: k,
- resource: it.view
- }));
- break
- }
- case ComputeBindingType.StorageTexture:
- {
- var rt = $
- , it = rt._texture._hardwareTexture;
- (it.textureAdditionalUsages & TextureUsage.StorageBinding) === 0 && Logger$2.Error("computeDispatch: The texture (name=" + rt.name + ", uniqueId=" + rt.uniqueId + ") is not a storage texture!", 50),
- _e !== void 0 && s ? et[_e].resource = it.view : (d.indexInGroupEntries = et.length,
- et.push({
- binding: k,
- resource: it.view
- }));
- break
- }
- case ComputeBindingType.UniformBuffer:
- case ComputeBindingType.StorageBuffer:
- {
- var nt = (j === ComputeBindingType.UniformBuffer,
- $)
- , ot = nt.getBuffer()
- , at = ot.underlyingResource;
- _e !== void 0 && s ? (et[_e].resource.buffer = at,
- et[_e].resource.size = ot.capacity) : (d.indexInGroupEntries = et.length,
- et.push({
- binding: k,
- resource: {
- buffer: at,
- offset: 0,
- size: ot.capacity
- }
- }));
- break
- }
- }
- }
- for (var st = 0; st < this._bindGroupEntries.length; ++st) {
- var et = this._bindGroupEntries[st];
- if (!et) {
- this._bindGroups[st] = void 0;
- continue
- }
- this._bindGroups[st] = this._device.createBindGroup({
- layout: i.getBindGroupLayout(st),
- entries: et
- })
- }
- this._bindGroups.length = this._bindGroupEntries.length
- }
- return this._bindGroups
- }
- ,
- a.prototype.clear = function() {
- this._bindGroups = []
- }
- ,
- a._Counter = 0,
- a
- }()
- , WebGPUComputePipelineContext = function() {
- function a(e) {
- this._name = "unnamed",
- this.engine = e
- }
- return Object.defineProperty(a.prototype, "isAsync", {
- get: function() {
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "isReady", {
- get: function() {
- return !!this.stage
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._getComputeShaderCode = function() {
- var e;
- return (e = this.sources) === null || e === void 0 ? void 0 : e.compute
- }
- ,
- a.prototype.dispose = function() {}
- ,
- a
- }();
- WebGPUEngine.prototype.createComputeContext = function() {
- return new WebGPUComputeContext(this._device,this._cacheSampler)
- }
- ;
- WebGPUEngine.prototype.createComputeEffect = function(a, e) {
- var i = a.computeElement || a.compute || a.computeToken || a.computeSource || a
- , o = i + "@" + e.defines;
- if (this._compiledComputeEffects[o]) {
- var s = this._compiledComputeEffects[o];
- return e.onCompiled && s.isReady() && e.onCompiled(s),
- s
- }
- var c = new ComputeEffect(a,e,this,o);
- return this._compiledComputeEffects[o] = c,
- c
- }
- ;
- WebGPUEngine.prototype.createComputePipelineContext = function() {
- return new WebGPUComputePipelineContext(this)
- }
- ;
- WebGPUEngine.prototype.areAllComputeEffectsReady = function() {
- for (var a in this._compiledComputeEffects) {
- var e = this._compiledComputeEffects[a];
- if (!e.isReady())
- return !1
- }
- return !0
- }
- ;
- WebGPUEngine.prototype.computeDispatch = function(a, e, i, o, s, c, d) {
- var _ = this;
- if (this._currentRenderTarget) {
- this._onAfterUnbindFrameBufferObservable.addOnce(function() {
- _.computeDispatch(a, e, i, o, s, c, d)
- });
- return
- }
- var b = a._pipelineContext
- , k = e;
- b.computePipeline || (b.computePipeline = this._device.createComputePipeline({
- compute: b.stage
- }));
- var j = this._renderTargetEncoder
- , $ = j.beginComputePass();
- $.setPipeline(b.computePipeline);
- for (var _e = k.getBindGroups(i, b.computePipeline, d), et = 0; et < _e.length; ++et) {
- var tt = _e[et];
- !tt || $.setBindGroup(et, tt)
- }
- $.dispatch(o, s, c),
- $.endPass()
- }
- ;
- WebGPUEngine.prototype.releaseComputeEffects = function() {
- for (var a in this._compiledComputeEffects) {
- var e = this._compiledComputeEffects[a].getPipelineContext();
- this._deleteComputePipelineContext(e)
- }
- this._compiledComputeEffects = {}
- }
- ;
- WebGPUEngine.prototype._prepareComputePipelineContext = function(a, e, i, o, s) {
- var c = a;
- this.dbgShowShaderCode && (console.log(o),
- console.log(e)),
- c.sources = {
- compute: e,
- rawCompute: i
- },
- c.stage = this._createComputePipelineStageDescriptor(e, o, s)
- }
- ;
- WebGPUEngine.prototype._releaseComputeEffect = function(a) {
- this._compiledComputeEffects[a._key] && (delete this._compiledComputeEffects[a._key],
- this._deleteComputePipelineContext(a.getPipelineContext()))
- }
- ;
- WebGPUEngine.prototype._rebuildComputeEffects = function() {
- for (var a in this._compiledComputeEffects) {
- var e = this._compiledComputeEffects[a];
- e._pipelineContext = null,
- e._wasPreviouslyReady = !1,
- e._prepareEffect()
- }
- }
- ;
- WebGPUEngine.prototype._deleteComputePipelineContext = function(a) {
- var e = a;
- e && a.dispose()
- }
- ;
- WebGPUEngine.prototype._createComputePipelineStageDescriptor = function(a, e, i) {
- return e ? e = "//" + e.split(`
- `).join(`
- //`) + `
- ` : e = "",
- {
- module: this._device.createShaderModule({
- code: e + a
- }),
- entryPoint: i
- }
- }
- ;
- WebGPUEngine.prototype._createDepthStencilCubeTexture = function(a, e) {
- var i = new InternalTexture(this,InternalTextureSource.DepthStencil);
- i.isCube = !0;
- var o = __assign({
- bilinearFiltering: !1,
- comparisonFunction: 0,
- generateStencil: !1,
- samples: 1
- }, e);
- return i.format = o.generateStencil ? 13 : 14,
- this._setupDepthStencilTexture(i, a, o.generateStencil, o.bilinearFiltering, o.comparisonFunction, o.samples),
- this._textureHelper.createGPUTextureForInternalTexture(i),
- this._internalTexturesCache.push(i),
- i
- }
- ;
- WebGPUEngine.prototype.createCubeTexture = function(a, e, i, o, s, c, d, _, b, k, j, $, _e) {
- var et = this;
- return s === void 0 && (s = null),
- c === void 0 && (c = null),
- _ === void 0 && (_ = null),
- b === void 0 && (b = !1),
- k === void 0 && (k = 0),
- j === void 0 && (j = 0),
- $ === void 0 && ($ = null),
- _e === void 0 && (_e = !1),
- this.createCubeTextureBase(a, e, i, !!o, s, c, d, _, b, k, j, $, null, function(tt, rt) {
- var it = rt
- , nt = it[0].width
- , ot = nt;
- et._setCubeMapTextureParams(tt, !o),
- tt.format = d != null ? d : -1;
- var at = et._textureHelper.createGPUTextureForInternalTexture(tt, nt, ot);
- et._textureHelper.updateCubeTextures(it, at.underlyingResource, nt, ot, at.format, !1, !1, 0, 0, et._uploadEncoder),
- o || et._generateMipmaps(tt, et._uploadEncoder),
- tt.isReady = !0,
- tt.onLoadedObservable.notifyObservers(tt),
- tt.onLoadedObservable.clear(),
- s && s()
- }, !!_e)
- }
- ;
- WebGPUEngine.prototype._setCubeMapTextureParams = function(a, e) {
- a.samplingMode = e ? 3 : 2,
- a._cachedWrapU = 0,
- a._cachedWrapV = 0
- }
- ;
- WebGPUEngine.prototype._debugPushGroup = function(a, e) {
- if (!!this._options.enableGPUDebugMarkers)
- if (e === 0 || e === 1) {
- var i = e === 0 ? this._renderEncoder : this._renderTargetEncoder;
- i.pushDebugGroup(a)
- } else
- this._currentRenderPass ? this._currentRenderPass.pushDebugGroup(a) : this._pendingDebugCommands.push(["push", a])
- }
- ;
- WebGPUEngine.prototype._debugPopGroup = function(a) {
- if (!!this._options.enableGPUDebugMarkers)
- if (a === 0 || a === 1) {
- var e = a === 0 ? this._renderEncoder : this._renderTargetEncoder;
- e.popDebugGroup()
- } else
- this._currentRenderPass ? this._currentRenderPass.popDebugGroup() : this._pendingDebugCommands.push(["pop", null])
- }
- ;
- WebGPUEngine.prototype._debugInsertMarker = function(a, e) {
- if (!!this._options.enableGPUDebugMarkers)
- if (e === 0 || e === 1) {
- var i = e === 0 ? this._renderEncoder : this._renderTargetEncoder;
- i.insertDebugMarker(a)
- } else
- this._currentRenderPass ? this._currentRenderPass.insertDebugMarker(a) : this._pendingDebugCommands.push(["insert", a])
- }
- ;
- WebGPUEngine.prototype._debugFlushPendingCommands = function() {
- for (var a = 0; a < this._pendingDebugCommands.length; ++a) {
- var e = this._pendingDebugCommands[a]
- , i = e[0]
- , o = e[1];
- switch (i) {
- case "push":
- this._debugPushGroup(o);
- break;
- case "pop":
- this._debugPopGroup();
- break;
- case "insert":
- this._debugInsertMarker(o);
- break
- }
- }
- this._pendingDebugCommands.length = 0
- }
- ;
- WebGPUEngine.prototype.updateDynamicIndexBuffer = function(a, e, i) {
- i === void 0 && (i = 0);
- var o = a, s;
- 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),
- this._bufferManager.setSubData(o, i, s)
- }
- ;
- WebGPUEngine.prototype.updateDynamicVertexBuffer = function(a, e, i, o) {
- var s = a;
- i === void 0 && (i = 0);
- var c;
- o === void 0 ? (e instanceof Array ? c = new Float32Array(e) : e instanceof ArrayBuffer ? c = new Uint8Array(e) : c = e,
- o = c.byteLength) : e instanceof Array ? c = new Float32Array(e) : e instanceof ArrayBuffer ? c = new Uint8Array(e) : c = e,
- this._bufferManager.setSubData(s, i, c, 0, o)
- }
- ;
- WebGPUEngine.prototype.updateDynamicTexture = function(a, e, i, o, s, c, d) {
- var _;
- if (o === void 0 && (o = !1),
- !!a) {
- var b = e.width
- , k = e.height
- , j = a._hardwareTexture;
- !((_ = a._hardwareTexture) === null || _ === void 0) && _.underlyingResource || (j = this._textureHelper.createGPUTextureForInternalTexture(a, b, k)),
- this._textureHelper.updateTexture(e, a, b, k, a.depth, j.format, 0, 0, i, o, 0, 0, this._uploadEncoder, d),
- a.generateMipMaps && this._generateMipmaps(a, this._uploadEncoder),
- a.isReady = !0
- }
- }
- ;
- var WebGPUExternalTexture = function(a) {
- __extends(e, a);
- function e(i) {
- return a.call(this, i) || this
- }
- return e
- }(ExternalTexture);
- Effect.prototype.setExternalTexture = function(a, e) {
- this._engine.setExternalTexture(a, e)
- }
- ;
- WebGPUEngine.prototype.createExternalTexture = function(a) {
- var e = new WebGPUExternalTexture(a);
- return e
- }
- ;
- WebGPUEngine.prototype.setExternalTexture = function(a, e) {
- if (!e) {
- this._currentMaterialContext.setTexture(a, null);
- return
- }
- this._setInternalTexture(a, e)
- }
- ;
- WebGPUEngine.prototype.unBindMultiColorAttachmentFramebuffer = function(a, e, i) {
- e === void 0 && (e = !1),
- i && i();
- var o = a._attachments
- , s = o.length;
- this._currentRenderPass && this._currentRenderPass !== this._mainRenderPassWrapper.renderPass && this._endRenderTargetRenderPass();
- for (var c = 0; c < s; c++) {
- var d = a.textures[c];
- d.generateMipMaps && !e && !d.isCube && this._generateMipmaps(d)
- }
- this._currentRenderTarget = null,
- this._mrtAttachments = [],
- this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments, []),
- this._currentRenderPass = this._mainRenderPassWrapper.renderPass,
- this._setDepthTextureFormat(this._mainRenderPassWrapper),
- this._setColorFormat(this._mainRenderPassWrapper)
- }
- ;
- WebGPUEngine.prototype.createMultipleRenderTarget = function(a, e, i) {
- 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);
- e !== void 0 && (s = e.generateMipMaps === void 0 ? !1 : e.generateMipMaps,
- c = e.generateDepthBuffer === void 0 ? !0 : e.generateDepthBuffer,
- d = e.generateStencilBuffer === void 0 ? !1 : e.generateStencilBuffer,
- _ = e.generateDepthTexture === void 0 ? !1 : e.generateDepthTexture,
- k = e.textureCount || 1,
- b = (o = e.depthTextureFormat) !== null && o !== void 0 ? o : 15,
- e.types && (_e = e.types),
- e.samplingModes && (et = e.samplingModes));
- var rt = a.width || a
- , it = a.height || a
- , nt = null;
- (c || d || _) && (nt = tt.createDepthStencilTexture(0, !1, d, 1, b));
- var ot = []
- , at = [];
- tt._generateDepthBuffer = c,
- tt._generateStencilBuffer = d,
- tt._attachments = at;
- for (var st = 0; st < k; st++) {
- var ut = et[st] || $
- , ct = _e[st] || j;
- (ct === 1 && !this._caps.textureFloatLinearFiltering || ct === 2 && !this._caps.textureHalfFloatLinearFiltering) && (ut = 1),
- ct === 1 && !this._caps.textureFloat && (ct = 0,
- Logger$2.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type"));
- var lt = new InternalTexture(this,InternalTextureSource.MultiRenderTarget);
- ot.push(lt),
- at.push(st + 1),
- lt.baseWidth = rt,
- lt.baseHeight = it,
- lt.width = rt,
- lt.height = it,
- lt.isReady = !0,
- lt.samples = 1,
- lt.generateMipMaps = s,
- lt.samplingMode = ut,
- lt.type = ct,
- lt._cachedWrapU = 0,
- lt._cachedWrapV = 0,
- this._internalTexturesCache.push(lt),
- this._textureHelper.createGPUTextureForInternalTexture(lt)
- }
- return nt && (nt.incrementReferences(),
- ot.push(nt),
- this._internalTexturesCache.push(nt)),
- tt.setTextures(ot),
- tt
- }
- ;
- WebGPUEngine.prototype.updateMultipleRenderTargetTextureSampleCount = function(a, e) {
- if (!a || !a.textures || a.textures[0].samples === e)
- return e;
- var i = a._attachments.length;
- if (i === 0)
- return 1;
- e = Math.min(e, this.getCaps().maxMSAASamples);
- for (var o = 0; o < i; ++o) {
- var s = a.textures[o];
- this._textureHelper.createMSAATexture(s, e),
- s.samples = e
- }
- return a._depthStencilTexture && a._depthStencilTexture !== a.textures[a.textures.length - 1] && (this._textureHelper.createMSAATexture(a._depthStencilTexture, e),
- a._depthStencilTexture.samples = e),
- e
- }
- ;
- WebGPUEngine.prototype.bindAttachments = function(a) {
- a.length === 0 || !this._currentRenderTarget || (this._mrtAttachments = a)
- }
- ;
- WebGPUEngine.prototype.buildTextureLayout = function(a) {
- for (var e = [], i = 0; i < a.length; i++)
- a[i] ? e.push(i + 1) : e.push(0);
- return e
- }
- ;
- WebGPUEngine.prototype.restoreSingleAttachment = function() {}
- ;
- WebGPUEngine.prototype.getGPUFrameTimeCounter = function() {
- return this._timestampQuery.gpuFrameTimeCounter
- }
- ;
- WebGPUEngine.prototype.captureGPUFrameTime = function(a) {
- this._timestampQuery.enable = a && !!this._caps.timerQuery
- }
- ;
- WebGPUEngine.prototype.createQuery = function() {
- return this._occlusionQuery.createQuery()
- }
- ;
- WebGPUEngine.prototype.deleteQuery = function(a) {
- return this._occlusionQuery.deleteQuery(a),
- this
- }
- ;
- WebGPUEngine.prototype.isQueryResultAvailable = function(a) {
- return this._occlusionQuery.isQueryResultAvailable(a)
- }
- ;
- WebGPUEngine.prototype.getQueryResult = function(a) {
- return this._occlusionQuery.getQueryResult(a)
- }
- ;
- WebGPUEngine.prototype.beginOcclusionQuery = function(a, e) {
- var i;
- if (this.compatibilityMode) {
- if (this._occlusionQuery.canBeginQuery)
- return (i = this._currentRenderPass) === null || i === void 0 || i.beginOcclusionQuery(e),
- !0
- } else {
- var o = this._getCurrentRenderPassIndex()
- , s = o === 0 ? this._bundleList : this._bundleListRenderTarget;
- return s.addItem(new WebGPURenderItemBeginOcclusionQuery(e)),
- !0
- }
- return !1
- }
- ;
- WebGPUEngine.prototype.endOcclusionQuery = function(a) {
- var e;
- if (this.compatibilityMode)
- (e = this._currentRenderPass) === null || e === void 0 || e.endOcclusionQuery();
- else {
- var i = this._getCurrentRenderPassIndex()
- , o = i === 0 ? this._bundleList : this._bundleListRenderTarget;
- o.addItem(new WebGPURenderItemEndOcclusionQuery)
- }
- return this
- }
- ;
- WebGPUEngine.prototype.createRawTexture = function(a, e, i, o, s, c, d, _, b, k) {
- _ === void 0 && (_ = null),
- b === void 0 && (b = 0),
- k === void 0 && (k = 0);
- var j = new InternalTexture(this,InternalTextureSource.Raw);
- return j.baseWidth = e,
- j.baseHeight = i,
- j.width = e,
- j.height = i,
- j.format = o,
- j.generateMipMaps = s,
- j.samplingMode = d,
- j.invertY = c,
- j._compression = _,
- j.type = b,
- this._doNotHandleContextLost || (j._bufferView = a),
- this._textureHelper.createGPUTextureForInternalTexture(j, e, i, void 0, k),
- this.updateRawTexture(j, a, o, c, _, b),
- this._internalTexturesCache.push(j),
- j
- }
- ;
- WebGPUEngine.prototype.updateRawTexture = function(a, e, i, o, s, c) {
- if (s === void 0 && (s = null),
- c === void 0 && (c = 0),
- !!a) {
- if (this._doNotHandleContextLost || (a._bufferView = e,
- a.invertY = o,
- a._compression = s),
- e) {
- var d = a._hardwareTexture
- , _ = i === 4;
- _ && (e = _convertRGBtoRGBATextureData(e, a.width, a.height, c));
- var b = new Uint8Array(e.buffer,e.byteOffset,e.byteLength);
- this._textureHelper.updateTexture(b, a, a.width, a.height, a.depth, d.format, 0, 0, o, !1, 0, 0, this._uploadEncoder),
- a.generateMipMaps && this._generateMipmaps(a, this._uploadEncoder)
- }
- a.isReady = !0
- }
- }
- ;
- WebGPUEngine.prototype.createRawCubeTexture = function(a, e, i, o, s, c, d, _) {
- _ === void 0 && (_ = null);
- var b = new InternalTexture(this,InternalTextureSource.CubeRaw);
- return o === 1 && !this._caps.textureFloatLinearFiltering ? (s = !1,
- d = 1,
- 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,
- d = 1,
- 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,
- Logger$2.Warn("Render to float textures is not supported. Mipmap generation forced to false.")) : o === 2 && !this._caps.colorBufferFloat && (s = !1,
- Logger$2.Warn("Render to half float textures is not supported. Mipmap generation forced to false.")),
- b.isCube = !0,
- b.format = i === 4 ? 5 : i,
- b.type = o,
- b.generateMipMaps = s,
- b.width = e,
- b.height = e,
- b.samplingMode = d,
- this._doNotHandleContextLost || (b._bufferViewArray = a),
- b._cachedWrapU = 0,
- b._cachedWrapV = 0,
- this._textureHelper.createGPUTextureForInternalTexture(b),
- a && this.updateRawCubeTexture(b, a, i, o, c, _),
- b
- }
- ;
- WebGPUEngine.prototype.updateRawCubeTexture = function(a, e, i, o, s, c, d) {
- c === void 0 && (c = null),
- a._bufferViewArray = e,
- a.invertY = s,
- a._compression = c;
- for (var _ = a._hardwareTexture, b = i === 4, k = [], j = 0; j < e.length; ++j) {
- var $ = e[j];
- b && ($ = _convertRGBtoRGBATextureData(e[j], a.width, a.height, o)),
- k.push(new Uint8Array($.buffer,$.byteOffset,$.byteLength))
- }
- this._textureHelper.updateCubeTextures(k, _.underlyingResource, a.width, a.height, _.format, s, !1, 0, 0, this._uploadEncoder),
- a.generateMipMaps && this._generateMipmaps(a, this._uploadEncoder),
- a.isReady = !0
- }
- ;
- WebGPUEngine.prototype.createRawCubeTextureFromUrl = function(a, e, i, o, s, c, d, _, b, k, j, $) {
- var _e = this;
- b === void 0 && (b = null),
- k === void 0 && (k = null),
- j === void 0 && (j = 3),
- $ === void 0 && ($ = !1);
- var et = this.createRawCubeTexture(null, i, o, s, !c, $, j, null);
- e == null || e._addPendingData(et),
- et.url = a,
- this._internalTexturesCache.push(et);
- var tt = function(it, nt) {
- e == null || e._removePendingData(et),
- k && it && k(it.status + " " + it.statusText, nt)
- }
- , rt = function(it) {
- var nt = et.width
- , ot = d(it);
- if (!!ot) {
- var at = [0, 2, 4, 1, 3, 5];
- if (_)
- for (var st = o === 4, ut = _(ot), ct = et._hardwareTexture, lt = [0, 1, 2, 3, 4, 5], ft = 0; ft < ut.length; ft++) {
- for (var ht = nt >> ft, pt = [], dt = 0; dt < 6; dt++) {
- var _t = ut[ft][lt[dt]];
- st && (_t = _convertRGBtoRGBATextureData(_t, ht, ht, s)),
- pt.push(new Uint8Array(_t.buffer,_t.byteOffset,_t.byteLength))
- }
- _e._textureHelper.updateCubeTextures(pt, ct.underlyingResource, ht, ht, ct.format, $, !1, 0, 0, _e._uploadEncoder)
- }
- else {
- for (var pt = [], dt = 0; dt < 6; dt++)
- pt.push(ot[at[dt]]);
- _e.updateRawCubeTexture(et, pt, o, s, $)
- }
- et.isReady = !0,
- e == null || e._removePendingData(et),
- b && b()
- }
- };
- return this._loadFile(a, function(it) {
- rt(it)
- }, void 0, e == null ? void 0 : e.offlineProvider, !0, tt),
- et
- }
- ;
- WebGPUEngine.prototype.createRawTexture3D = function(a, e, i, o, s, c, d, _, b, k, j) {
- b === void 0 && (b = null),
- k === void 0 && (k = 0),
- j === void 0 && (j = 0);
- var $ = InternalTextureSource.Raw3D
- , _e = new InternalTexture(this,$);
- return _e.baseWidth = e,
- _e.baseHeight = i,
- _e.baseDepth = o,
- _e.width = e,
- _e.height = i,
- _e.depth = o,
- _e.format = s,
- _e.type = k,
- _e.generateMipMaps = c,
- _e.samplingMode = _,
- _e.is3D = !0,
- this._doNotHandleContextLost || (_e._bufferView = a),
- this._textureHelper.createGPUTextureForInternalTexture(_e, e, i, void 0, j),
- this.updateRawTexture3D(_e, a, s, d, b, k),
- this._internalTexturesCache.push(_e),
- _e
- }
- ;
- WebGPUEngine.prototype.updateRawTexture3D = function(a, e, i, o, s, c) {
- if (s === void 0 && (s = null),
- c === void 0 && (c = 0),
- this._doNotHandleContextLost || (a._bufferView = e,
- a.format = i,
- a.invertY = o,
- a._compression = s),
- e) {
- var d = a._hardwareTexture
- , _ = i === 4;
- _ && (e = _convertRGBtoRGBATextureData(e, a.width, a.height, c));
- var b = new Uint8Array(e.buffer,e.byteOffset,e.byteLength);
- this._textureHelper.updateTexture(b, a, a.width, a.height, a.depth, d.format, 0, 0, o, !1, 0, 0, this._uploadEncoder),
- a.generateMipMaps && this._generateMipmaps(a, this._uploadEncoder)
- }
- a.isReady = !0
- }
- ;
- WebGPUEngine.prototype.createRawTexture2DArray = function(a, e, i, o, s, c, d, _, b, k, j) {
- b === void 0 && (b = null),
- k === void 0 && (k = 0),
- j === void 0 && (j = 0);
- var $ = InternalTextureSource.Raw2DArray
- , _e = new InternalTexture(this,$);
- return _e.baseWidth = e,
- _e.baseHeight = i,
- _e.baseDepth = o,
- _e.width = e,
- _e.height = i,
- _e.depth = o,
- _e.format = s,
- _e.type = k,
- _e.generateMipMaps = c,
- _e.samplingMode = _,
- _e.is2DArray = !0,
- this._doNotHandleContextLost || (_e._bufferView = a),
- this._textureHelper.createGPUTextureForInternalTexture(_e, e, i, o, j),
- this.updateRawTexture2DArray(_e, a, s, d, b, k),
- this._internalTexturesCache.push(_e),
- _e
- }
- ;
- WebGPUEngine.prototype.updateRawTexture2DArray = function(a, e, i, o, s, c) {
- if (s === void 0 && (s = null),
- c === void 0 && (c = 0),
- this._doNotHandleContextLost || (a._bufferView = e,
- a.format = i,
- a.invertY = o,
- a._compression = s),
- e) {
- var d = a._hardwareTexture
- , _ = i === 4;
- _ && (e = _convertRGBtoRGBATextureData(e, a.width, a.height, c));
- var b = new Uint8Array(e.buffer,e.byteOffset,e.byteLength);
- this._textureHelper.updateTexture(b, a, a.width, a.height, a.depth, d.format, 0, 0, o, !1, 0, 0, this._uploadEncoder),
- a.generateMipMaps && this._generateMipmaps(a, this._uploadEncoder)
- }
- a.isReady = !0
- }
- ;
- function _convertRGBtoRGBATextureData(a, e, i, o) {
- var s, c = 1;
- o === 1 ? s = new Float32Array(e * i * 4) : o === 2 ? (s = new Uint16Array(e * i * 4),
- c = 15360) : o === 7 ? s = new Uint32Array(e * i * 4) : s = new Uint8Array(e * i * 4);
- for (var d = 0; d < e; d++)
- for (var _ = 0; _ < i; _++) {
- var b = (_ * e + d) * 3
- , k = (_ * e + d) * 4;
- s[k + 0] = a[b + 0],
- s[k + 1] = a[b + 1],
- s[k + 2] = a[b + 2],
- s[k + 3] = c
- }
- return s
- }
- WebGPUEngine.prototype._readTexturePixels = function(a, e, i, o, s, c, d, _) {
- o === void 0 && (o = -1),
- s === void 0 && (s = 0),
- c === void 0 && (c = null),
- d === void 0 && (d = !0),
- _ === void 0 && (_ = !1);
- var b = a._hardwareTexture;
- return d && this.flushFramebuffer(),
- this._textureHelper.readPixels(b.underlyingResource, 0, 0, e, i, b.format, o, s, c, _)
- }
- ;
- WebGPUEngine.prototype._readTexturePixelsSync = function(a, e, i, o, s, c, d, _) {
- throw "_readTexturePixelsSync is unsupported in WebGPU!"
- }
- ;
- WebGPUEngine.prototype._createHardwareRenderTargetWrapper = function(a, e, i) {
- var o = new RenderTargetWrapper(a,e,i,this);
- return this._renderTargetWrapperCache.push(o),
- o
- }
- ;
- WebGPUEngine.prototype.createRenderTargetTexture = function(a, e) {
- var i = this._createHardwareRenderTargetWrapper(!1, !1, a)
- , o = {};
- e !== void 0 && typeof e == "object" ? (o.generateDepthBuffer = e.generateDepthBuffer === void 0 ? !0 : e.generateDepthBuffer,
- o.generateStencilBuffer = o.generateDepthBuffer && e.generateStencilBuffer) : (o.generateDepthBuffer = !0,
- o.generateStencilBuffer = !1);
- var s = this._createInternalTexture(a, e, !0, InternalTextureSource.RenderTarget);
- return i._generateDepthBuffer = o.generateDepthBuffer,
- i._generateStencilBuffer = !!o.generateStencilBuffer,
- i.setTextures(s),
- (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),
- e !== void 0 && typeof e == "object" && e.createMipMaps && !o.generateMipMaps && (s.generateMipMaps = !0),
- this._textureHelper.createGPUTextureForInternalTexture(s, void 0, void 0, void 0, o.creationFlags),
- e !== void 0 && typeof e == "object" && e.createMipMaps && !o.generateMipMaps && (s.generateMipMaps = !1),
- i
- }
- ;
- WebGPUEngine.prototype._createDepthStencilTexture = function(a, e, i) {
- var o = new InternalTexture(this,InternalTextureSource.DepthStencil)
- , s = __assign({
- bilinearFiltering: !1,
- comparisonFunction: 0,
- generateStencil: !1,
- samples: 1,
- depthTextureFormat: 15
- }, e);
- return o.format = s.generateStencil ? 13 : s.depthTextureFormat === 15 ? 14 : s.depthTextureFormat,
- this._setupDepthStencilTexture(o, a, s.generateStencil, s.bilinearFiltering, s.comparisonFunction, s.samples),
- this._textureHelper.createGPUTextureForInternalTexture(o),
- this._internalTexturesCache.push(o),
- o
- }
- ;
- WebGPUEngine.prototype._setupDepthStencilTexture = function(a, e, i, o, s, c) {
- c === void 0 && (c = 1);
- var d = e.width || e
- , _ = e.height || e
- , b = e.layers || 0;
- a.baseWidth = d,
- a.baseHeight = _,
- a.width = d,
- a.height = _,
- a.is2DArray = b > 0,
- a.depth = b,
- a.isReady = !0,
- a.samples = c,
- a.generateMipMaps = !1,
- a.samplingMode = o ? 2 : 1,
- a.type = 1,
- a._comparisonFunction = s,
- a._cachedWrapU = 0,
- a._cachedWrapV = 0
- }
- ;
- WebGPUEngine.prototype.updateRenderTargetTextureSampleCount = function(a, e) {
- return !a || !a.texture || a.samples === e || (e = Math.min(e, this.getCaps().maxMSAASamples),
- this._textureHelper.createMSAATexture(a.texture, e),
- a._depthStencilTexture && (this._textureHelper.createMSAATexture(a._depthStencilTexture, e),
- a._depthStencilTexture.samples = e),
- a.texture.samples = e),
- e
- }
- ;
- WebGPUEngine.prototype.createRenderTargetCubeTexture = function(a, e) {
- var i = this._createHardwareRenderTargetWrapper(!1, !0, a)
- , o = __assign({
- generateMipMaps: !0,
- generateDepthBuffer: !0,
- generateStencilBuffer: !1,
- type: 0,
- samplingMode: 3,
- format: 5,
- samples: 1
- }, e);
- o.generateStencilBuffer = o.generateDepthBuffer && o.generateStencilBuffer,
- i._generateDepthBuffer = o.generateDepthBuffer,
- i._generateStencilBuffer = o.generateStencilBuffer;
- var s = new InternalTexture(this,InternalTextureSource.RenderTarget);
- return s.width = a,
- s.height = a,
- s.depth = 0,
- s.isReady = !0,
- s.isCube = !0,
- s.samples = o.samples,
- s.generateMipMaps = o.generateMipMaps,
- s.samplingMode = o.samplingMode,
- s.type = o.type,
- s.format = o.format,
- this._internalTexturesCache.push(s),
- i.setTextures(s),
- (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),
- e && e.createMipMaps && !o.generateMipMaps && (s.generateMipMaps = !0),
- this._textureHelper.createGPUTextureForInternalTexture(s),
- e && e.createMipMaps && !o.generateMipMaps && (s.generateMipMaps = !1),
- i
- }
- ;
- Effect.prototype.setTextureSampler = function(a, e) {
- this._engine.setTextureSampler(a, e)
- }
- ;
- WebGPUEngine.prototype.setTextureSampler = function(a, e) {
- var i;
- (i = this._currentMaterialContext) === null || i === void 0 || i.setSampler(a, e)
- }
- ;
- Effect.prototype.setStorageBuffer = function(a, e) {
- this._engine.setStorageBuffer(a, e)
- }
- ;
- WebGPUEngine.prototype.createStorageBuffer = function(a, e) {
- return this._createBuffer(a, e | 32)
- }
- ;
- WebGPUEngine.prototype.updateStorageBuffer = function(a, e, i, o) {
- var s = a;
- i === void 0 && (i = 0);
- var c;
- o === void 0 ? (e instanceof Array ? c = new Float32Array(e) : e instanceof ArrayBuffer ? c = new Uint8Array(e) : c = e,
- o = c.byteLength) : e instanceof Array ? c = new Float32Array(e) : e instanceof ArrayBuffer ? c = new Uint8Array(e) : c = e,
- this._bufferManager.setSubData(s, i, c, 0, o)
- }
- ;
- WebGPUEngine.prototype.readFromStorageBuffer = function(a, e, i, o) {
- var s = this;
- i = i || a.capacity;
- var c = this._bufferManager.createRawBuffer(i, BufferUsage.MapRead | BufferUsage.CopyDst);
- return this._renderTargetEncoder.copyBufferToBuffer(a.underlyingResource, e != null ? e : 0, c, 0, i),
- new Promise(function(d, _) {
- s.onEndFrameObservable.addOnce(function() {
- c.mapAsync(MapMode.Read, 0, i).then(function() {
- var b = c.getMappedRange(0, i)
- , k = o;
- if (k === void 0)
- k = new Uint8Array(i),
- k.set(new Uint8Array(b));
- else {
- var j = k.constructor;
- k = new j(k.buffer),
- k.set(new j(b))
- }
- c.unmap(),
- s._bufferManager.releaseBuffer(c),
- d(k)
- }, function(b) {
- return _(b)
- })
- })
- }
- )
- }
- ;
- WebGPUEngine.prototype.setStorageBuffer = function(a, e) {
- var i, o;
- (i = this._currentDrawContext) === null || i === void 0 || i.setBuffer(a, (o = e == null ? void 0 : e.getBuffer()) !== null && o !== void 0 ? o : null)
- }
- ;
- WebGPUEngine.prototype.createUniformBuffer = function(a) {
- var e;
- a instanceof Array ? e = new Float32Array(a) : e = a;
- var i = this._bufferManager.createBuffer(e, BufferUsage.Uniform | BufferUsage.CopyDst);
- return i
- }
- ;
- WebGPUEngine.prototype.createDynamicUniformBuffer = function(a) {
- return this.createUniformBuffer(a)
- }
- ;
- WebGPUEngine.prototype.updateUniformBuffer = function(a, e, i, o) {
- i === void 0 && (i = 0);
- var s = a, c;
- o === void 0 ? (e instanceof Float32Array ? c = e : c = new Float32Array(e),
- o = c.byteLength) : e instanceof Float32Array ? c = e : c = new Float32Array(e),
- this._bufferManager.setSubData(s, i, c, 0, o)
- }
- ;
- WebGPUEngine.prototype.bindUniformBufferBase = function(a, e, i) {
- this._currentDrawContext.setBuffer(i, a)
- }
- ;
- WebGPUEngine.prototype.bindUniformBlock = function(a, e, i) {}
- ;
- WebGPUEngine.prototype.updateVideoTexture = function(a, e, i) {
- var o = this, s;
- if (!(!a || a._isDisabled)) {
- this._videoTextureSupported === void 0 && (this._videoTextureSupported = !0);
- var c = a._hardwareTexture;
- !((s = a._hardwareTexture) === null || s === void 0) && s.underlyingResource || (c = this._textureHelper.createGPUTextureForInternalTexture(a)),
- this.createImageBitmap(e).then(function(d) {
- o._textureHelper.updateTexture(d, a, a.width, a.height, a.depth, c.format, 0, 0, !i, !1, 0, 0, o._uploadEncoder),
- a.generateMipMaps && o._generateMipmaps(a, o._uploadEncoder),
- a.isReady = !0
- }).catch(function(d) {
- a.isReady = !0
- })
- }
- }
- ;
- var SceneLoaderFlags = function() {
- function a() {}
- return Object.defineProperty(a, "ForceFullSceneLoadingForIncremental", {
- get: function() {
- return a._ForceFullSceneLoadingForIncremental
- },
- set: function(e) {
- a._ForceFullSceneLoadingForIncremental = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "ShowLoadingScreen", {
- get: function() {
- return a._ShowLoadingScreen
- },
- set: function(e) {
- a._ShowLoadingScreen = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "loggingLevel", {
- get: function() {
- return a._loggingLevel
- },
- set: function(e) {
- a._loggingLevel = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "CleanBoneMatrixWeights", {
- get: function() {
- return a._CleanBoneMatrixWeights
- },
- set: function(e) {
- a._CleanBoneMatrixWeights = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a._ForceFullSceneLoadingForIncremental = !1,
- a._ShowLoadingScreen = !0,
- a._CleanBoneMatrixWeights = !1,
- a._loggingLevel = 0,
- a
- }(), SceneLoaderAnimationGroupLoadingMode;
- (function(a) {
- a[a.Clean = 0] = "Clean",
- a[a.Stop = 1] = "Stop",
- a[a.Sync = 2] = "Sync",
- a[a.NoSync = 3] = "NoSync"
- }
- )(SceneLoaderAnimationGroupLoadingMode || (SceneLoaderAnimationGroupLoadingMode = {}));
- var SceneLoader = function() {
- function a() {}
- return Object.defineProperty(a, "ForceFullSceneLoadingForIncremental", {
- get: function() {
- return SceneLoaderFlags.ForceFullSceneLoadingForIncremental
- },
- set: function(e) {
- SceneLoaderFlags.ForceFullSceneLoadingForIncremental = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "ShowLoadingScreen", {
- get: function() {
- return SceneLoaderFlags.ShowLoadingScreen
- },
- set: function(e) {
- SceneLoaderFlags.ShowLoadingScreen = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "loggingLevel", {
- get: function() {
- return SceneLoaderFlags.loggingLevel
- },
- set: function(e) {
- SceneLoaderFlags.loggingLevel = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "CleanBoneMatrixWeights", {
- get: function() {
- return SceneLoaderFlags.CleanBoneMatrixWeights
- },
- set: function(e) {
- SceneLoaderFlags.CleanBoneMatrixWeights = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.GetDefaultPlugin = function() {
- return a._registeredPlugins[".babylon"]
- }
- ,
- a._GetPluginForExtension = function(e) {
- var i = a._registeredPlugins[e];
- 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"),
- a.GetDefaultPlugin())
- }
- ,
- a._GetPluginForDirectLoad = function(e) {
- for (var i in a._registeredPlugins) {
- var o = a._registeredPlugins[i].plugin;
- if (o.canDirectLoad && o.canDirectLoad(e))
- return a._registeredPlugins[i]
- }
- return a.GetDefaultPlugin()
- }
- ,
- a._GetPluginForFilename = function(e) {
- var i = e.indexOf("?");
- i !== -1 && (e = e.substring(0, i));
- var o = e.lastIndexOf(".")
- , s = e.substring(o, e.length).toLowerCase();
- return a._GetPluginForExtension(s)
- }
- ,
- a._GetDirectLoad = function(e) {
- return e.substr(0, 5) === "data:" ? e.substr(5) : null
- }
- ,
- a._FormatErrorMessage = function(e, i, o) {
- var s = "Unable to load from " + e.url;
- return i ? s += ": " + i : o && (s += ": " + o),
- s
- }
- ,
- a._LoadData = function(e, i, o, s, c, d, _) {
- var b = a._GetDirectLoad(e.url), k = _ ? a._GetPluginForExtension(_) : b ? a._GetPluginForDirectLoad(e.url) : a._GetPluginForFilename(e.url), j;
- if (k.plugin.createPlugin !== void 0 ? j = k.plugin.createPlugin() : j = k.plugin,
- !j)
- 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.";
- if (a.OnPluginActivatedObservable.notifyObservers(j),
- b && (j.canDirectLoad && j.canDirectLoad(e.url) || !IsBase64DataUrl(e.url))) {
- if (j.directLoad) {
- var $ = j.directLoad(i, b);
- $.then ? $.then(function(ft) {
- o(j, ft)
- }).catch(function(ft) {
- c("Error in directLoad of _loadData: " + ft, ft)
- }) : o(j, $)
- } else
- o(j, b);
- return j
- }
- var _e = k.isBinary
- , et = function(ft, ht) {
- if (i.isDisposed) {
- c("Scene has been disposed");
- return
- }
- o(j, ft, ht)
- }
- , tt = null
- , rt = !1
- , it = j.onDisposeObservable;
- it && it.add(function() {
- rt = !0,
- tt && (tt.abort(),
- tt = null),
- d()
- });
- var nt = function() {
- if (!rt) {
- var ft = function(pt, dt) {
- c(pt == null ? void 0 : pt.statusText, dt)
- }
- , ht = e.file || e.url;
- tt = j.loadFile ? j.loadFile(i, ht, et, s, _e, ft) : i._loadFile(ht, et, s, !0, _e, ft)
- }
- }
- , ot = i.getEngine()
- , at = ot.enableOfflineSupport;
- if (at) {
- for (var st = !1, ut = 0, ct = i.disableOfflineSupportExceptionRules; ut < ct.length; ut++) {
- var lt = ct[ut];
- if (lt.test(e.url)) {
- st = !0;
- break
- }
- }
- at = !st
- }
- return at && Engine.OfflineProviderFactory ? i.offlineProvider = Engine.OfflineProviderFactory(e.url, nt, ot.disableManifestCheck) : nt(),
- j
- }
- ,
- a._GetFileInfo = function(e, i) {
- var o, s, c = null;
- if (!i)
- o = e,
- s = Tools.GetFilename(e),
- e = Tools.GetFolderPath(e);
- else if (i.name) {
- var d = i;
- o = "file:" + d.name,
- s = d.name,
- c = d
- } else if (typeof i == "string" && StartsWith(i, "data:"))
- o = i,
- s = "";
- else {
- var _ = i;
- if (_.substr(0, 1) === "/")
- return Tools.Error("Wrong sceneFilename parameter"),
- null;
- o = e + _,
- s = _
- }
- return {
- url: o,
- rootUrl: e,
- name: s,
- file: c
- }
- }
- ,
- a.GetPluginForExtension = function(e) {
- return a._GetPluginForExtension(e).plugin
- }
- ,
- a.IsPluginForExtensionAvailable = function(e) {
- return !!a._registeredPlugins[e]
- }
- ,
- a.RegisterPlugin = function(e) {
- if (typeof e.extensions == "string") {
- var i = e.extensions;
- a._registeredPlugins[i.toLowerCase()] = {
- plugin: e,
- isBinary: !1
- }
- } else {
- var o = e.extensions;
- Object.keys(o).forEach(function(s) {
- a._registeredPlugins[s.toLowerCase()] = {
- plugin: e,
- isBinary: o[s].isBinary
- }
- })
- }
- }
- ,
- a.ImportMesh = function(e, i, o, s, c, d, _, b) {
- if (o === void 0 && (o = ""),
- s === void 0 && (s = EngineStore.LastCreatedScene),
- c === void 0 && (c = null),
- d === void 0 && (d = null),
- _ === void 0 && (_ = null),
- b === void 0 && (b = null),
- !s)
- return Logger$2.Error("No scene available to import mesh to"),
- null;
- var k = a._GetFileInfo(i, o);
- if (!k)
- return null;
- var j = {};
- s._addPendingData(j);
- var $ = function() {
- s._removePendingData(j)
- }
- , _e = function(rt, it) {
- var nt = a._FormatErrorMessage(k, rt, it);
- _ ? _(s, nt, new Error(nt)) : Logger$2.Error(nt),
- $()
- }
- , et = d ? function(rt) {
- try {
- d(rt)
- } catch (it) {
- _e("Error in onProgress callback: " + it, it)
- }
- }
- : void 0
- , tt = function(rt, it, nt, ot, at, st, ut) {
- if (s.importedMeshesFiles.push(k.url),
- c)
- try {
- c(rt, it, nt, ot, at, st, ut)
- } catch (ct) {
- _e("Error in onSuccess callback: " + ct, ct)
- }
- s._removePendingData(j)
- };
- return a._LoadData(k, s, function(rt, it, nt) {
- if (rt.rewriteRootURL && (k.rootUrl = rt.rewriteRootURL(k.rootUrl, nt)),
- rt.importMesh) {
- var ot = rt
- , at = new Array
- , st = new Array
- , ut = new Array;
- if (!ot.importMesh(e, s, it, k.rootUrl, at, st, ut, _e))
- return;
- s.loadingPluginName = rt.name,
- tt(at, st, ut, [], [], [], [])
- } else {
- var ct = rt;
- ct.importMeshAsync(e, s, it, k.rootUrl, et, k.name).then(function(lt) {
- s.loadingPluginName = rt.name,
- tt(lt.meshes, lt.particleSystems, lt.skeletons, lt.animationGroups, lt.transformNodes, lt.geometries, lt.lights)
- }).catch(function(lt) {
- _e(lt.message, lt)
- })
- }
- }, et, _e, $, b)
- }
- ,
- a.ImportMeshAsync = function(e, i, o, s, c, d) {
- return o === void 0 && (o = ""),
- s === void 0 && (s = EngineStore.LastCreatedScene),
- c === void 0 && (c = null),
- d === void 0 && (d = null),
- new Promise(function(_, b) {
- a.ImportMesh(e, i, o, s, function(k, j, $, _e, et, tt, rt) {
- _({
- meshes: k,
- particleSystems: j,
- skeletons: $,
- animationGroups: _e,
- transformNodes: et,
- geometries: tt,
- lights: rt
- })
- }, c, function(k, j, $) {
- b($ || new Error(j))
- }, d)
- }
- )
- }
- ,
- a.Load = function(e, i, o, s, c, d, _) {
- return i === void 0 && (i = ""),
- o === void 0 && (o = EngineStore.LastCreatedEngine),
- s === void 0 && (s = null),
- c === void 0 && (c = null),
- d === void 0 && (d = null),
- _ === void 0 && (_ = null),
- o ? a.Append(e, i, new Scene(o), s, c, d, _) : (Tools.Error("No engine available"),
- null)
- }
- ,
- a.LoadAsync = function(e, i, o, s, c) {
- return i === void 0 && (i = ""),
- o === void 0 && (o = EngineStore.LastCreatedEngine),
- s === void 0 && (s = null),
- c === void 0 && (c = null),
- new Promise(function(d, _) {
- a.Load(e, i, o, function(b) {
- d(b)
- }, s, function(b, k, j) {
- _(j || new Error(k))
- }, c)
- }
- )
- }
- ,
- a.Append = function(e, i, o, s, c, d, _) {
- var b = this;
- if (i === void 0 && (i = ""),
- o === void 0 && (o = EngineStore.LastCreatedScene),
- s === void 0 && (s = null),
- c === void 0 && (c = null),
- d === void 0 && (d = null),
- _ === void 0 && (_ = null),
- !o)
- return Logger$2.Error("No scene available to append to"),
- null;
- var k = a._GetFileInfo(e, i);
- if (!k)
- return null;
- a.ShowLoadingScreen && !this._showingLoadingScreen && (this._showingLoadingScreen = !0,
- o.getEngine().displayLoadingUI(),
- o.executeWhenReady(function() {
- o.getEngine().hideLoadingUI(),
- b._showingLoadingScreen = !1
- }));
- var j = {};
- o._addPendingData(j);
- var $ = function() {
- o._removePendingData(j)
- }
- , _e = function(rt, it) {
- var nt = a._FormatErrorMessage(k, rt, it);
- d ? d(o, nt, new Error(nt)) : Logger$2.Error(nt),
- $()
- }
- , et = c ? function(rt) {
- try {
- c(rt)
- } catch (it) {
- _e("Error in onProgress callback", it)
- }
- }
- : void 0
- , tt = function() {
- if (s)
- try {
- s(o)
- } catch (rt) {
- _e("Error in onSuccess callback", rt)
- }
- o._removePendingData(j)
- };
- return a._LoadData(k, o, function(rt, it) {
- if (rt.load) {
- var nt = rt;
- if (!nt.load(o, it, k.rootUrl, _e))
- return;
- o.loadingPluginName = rt.name,
- tt()
- } else {
- var ot = rt;
- ot.loadAsync(o, it, k.rootUrl, et, k.name).then(function() {
- o.loadingPluginName = rt.name,
- tt()
- }).catch(function(at) {
- _e(at.message, at)
- })
- }
- }, et, _e, $, _)
- }
- ,
- a.AppendAsync = function(e, i, o, s, c) {
- return i === void 0 && (i = ""),
- o === void 0 && (o = EngineStore.LastCreatedScene),
- s === void 0 && (s = null),
- c === void 0 && (c = null),
- new Promise(function(d, _) {
- a.Append(e, i, o, function(b) {
- d(b)
- }, s, function(b, k, j) {
- _(j || new Error(k))
- }, c)
- }
- )
- }
- ,
- a.LoadAssetContainer = function(e, i, o, s, c, d, _) {
- if (i === void 0 && (i = ""),
- o === void 0 && (o = EngineStore.LastCreatedScene),
- s === void 0 && (s = null),
- c === void 0 && (c = null),
- d === void 0 && (d = null),
- _ === void 0 && (_ = null),
- !o)
- return Logger$2.Error("No scene available to load asset container to"),
- null;
- var b = a._GetFileInfo(e, i);
- if (!b)
- return null;
- var k = {};
- o._addPendingData(k);
- var j = function() {
- o._removePendingData(k)
- }
- , $ = function(tt, rt) {
- var it = a._FormatErrorMessage(b, tt, rt);
- d ? d(o, it, new Error(it)) : Logger$2.Error(it),
- j()
- }
- , _e = c ? function(tt) {
- try {
- c(tt)
- } catch (rt) {
- $("Error in onProgress callback", rt)
- }
- }
- : void 0
- , et = function(tt) {
- if (s)
- try {
- s(tt)
- } catch (rt) {
- $("Error in onSuccess callback", rt)
- }
- o._removePendingData(k)
- };
- return a._LoadData(b, o, function(tt, rt) {
- if (tt.loadAssetContainer) {
- var it = tt
- , nt = it.loadAssetContainer(o, rt, b.rootUrl, $);
- if (!nt)
- return;
- o.loadingPluginName = tt.name,
- et(nt)
- } else if (tt.loadAssetContainerAsync) {
- var ot = tt;
- ot.loadAssetContainerAsync(o, rt, b.rootUrl, _e, b.name).then(function(at) {
- o.loadingPluginName = tt.name,
- et(at)
- }).catch(function(at) {
- $(at.message, at)
- })
- } else
- $("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.")
- }, _e, $, j, _)
- }
- ,
- a.LoadAssetContainerAsync = function(e, i, o, s, c) {
- return i === void 0 && (i = ""),
- o === void 0 && (o = EngineStore.LastCreatedScene),
- s === void 0 && (s = null),
- c === void 0 && (c = null),
- new Promise(function(d, _) {
- a.LoadAssetContainer(e, i, o, function(b) {
- d(b)
- }, s, function(b, k, j) {
- _(j || new Error(k))
- }, c)
- }
- )
- }
- ,
- a.ImportAnimations = function(e, i, o, s, c, d, _, b, k, j) {
- if (i === void 0 && (i = ""),
- o === void 0 && (o = EngineStore.LastCreatedScene),
- s === void 0 && (s = !0),
- c === void 0 && (c = SceneLoaderAnimationGroupLoadingMode.Clean),
- d === void 0 && (d = null),
- _ === void 0 && (_ = null),
- b === void 0 && (b = null),
- k === void 0 && (k = null),
- j === void 0 && (j = null),
- !o) {
- Logger$2.Error("No scene available to load animations to");
- return
- }
- if (s) {
- for (var $ = 0, _e = o.animatables; $ < _e.length; $++) {
- var et = _e[$];
- et.reset()
- }
- o.stopAllAnimations(),
- o.animationGroups.slice().forEach(function(nt) {
- nt.dispose()
- });
- var tt = o.getNodes();
- tt.forEach(function(nt) {
- nt.animations && (nt.animations = [])
- })
- } else
- switch (c) {
- case SceneLoaderAnimationGroupLoadingMode.Clean:
- o.animationGroups.slice().forEach(function(nt) {
- nt.dispose()
- });
- break;
- case SceneLoaderAnimationGroupLoadingMode.Stop:
- o.animationGroups.forEach(function(nt) {
- nt.stop()
- });
- break;
- case SceneLoaderAnimationGroupLoadingMode.Sync:
- o.animationGroups.forEach(function(nt) {
- nt.reset(),
- nt.restart()
- });
- break;
- case SceneLoaderAnimationGroupLoadingMode.NoSync:
- break;
- default:
- Logger$2.Error("Unknown animation group loading mode value '" + c + "'");
- return
- }
- var rt = o.animatables.length
- , it = function(nt) {
- nt.mergeAnimationsTo(o, o.animatables.slice(rt), d),
- nt.dispose(),
- o.onAnimationFileImportedObservable.notifyObservers(o),
- _ && _(o)
- };
- this.LoadAssetContainer(e, i, o, it, b, k, j)
- }
- ,
- a.ImportAnimationsAsync = function(e, i, o, s, c, d, _, b, k, j) {
- return i === void 0 && (i = ""),
- o === void 0 && (o = EngineStore.LastCreatedScene),
- s === void 0 && (s = !0),
- c === void 0 && (c = SceneLoaderAnimationGroupLoadingMode.Clean),
- d === void 0 && (d = null),
- b === void 0 && (b = null),
- j === void 0 && (j = null),
- new Promise(function($, _e) {
- a.ImportAnimations(e, i, o, s, c, d, function(et) {
- $(et)
- }, b, function(et, tt, rt) {
- _e(rt || new Error(tt))
- }, j)
- }
- )
- }
- ,
- a.NO_LOGGING = 0,
- a.MINIMAL_LOGGING = 1,
- a.SUMMARY_LOGGING = 2,
- a.DETAILED_LOGGING = 3,
- a.OnPluginActivatedObservable = new Observable,
- a._registeredPlugins = {},
- a._showingLoadingScreen = !1,
- a
- }(), AnimationKeyInterpolation;
- (function(a) {
- a[a.NONE = 0] = "NONE",
- a[a.STEP = 1] = "STEP"
- }
- )(AnimationKeyInterpolation || (AnimationKeyInterpolation = {}));
- var AnimationRange = function() {
- function a(e, i, o) {
- this.name = e,
- this.from = i,
- this.to = o
- }
- return a.prototype.clone = function() {
- return new a(this.name,this.from,this.to)
- }
- ,
- a
- }()
- , Animation = function() {
- function a(e, i, o, s, c, d) {
- this.name = e,
- this.targetProperty = i,
- this.framePerSecond = o,
- this.dataType = s,
- this.loopMode = c,
- this.enableBlending = d,
- this._runtimeAnimations = new Array,
- this._events = new Array,
- this.blendingSpeed = .01,
- this._ranges = {},
- this.targetPropertyPath = i.split("."),
- this.dataType = s,
- this.loopMode = c === void 0 ? a.ANIMATIONLOOPMODE_CYCLE : c,
- this.uniqueId = a._UniqueIdGenerator++
- }
- return a._PrepareAnimation = function(e, i, o, s, c, d, _, b) {
- var k = void 0;
- 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),
- k == null)
- return null;
- var j = new a(e,i,o,k,_)
- , $ = [{
- frame: 0,
- value: c
- }, {
- frame: s,
- value: d
- }];
- return j.setKeys($),
- b !== void 0 && j.setEasingFunction(b),
- j
- }
- ,
- a.CreateAnimation = function(e, i, o, s) {
- var c = new a(e + "Animation",e,o,i,a.ANIMATIONLOOPMODE_CONSTANT);
- return c.setEasingFunction(s),
- c
- }
- ,
- a.CreateAndStartAnimation = function(e, i, o, s, c, d, _, b, k, j, $) {
- var _e = a._PrepareAnimation(e, o, s, c, d, _, b, k);
- return !_e || (i.getScene && ($ = i.getScene()),
- !$) ? null : $.beginDirectAnimation(i, [_e], 0, c, _e.loopMode === 1, 1, j)
- }
- ,
- a.CreateAndStartHierarchyAnimation = function(e, i, o, s, c, d, _, b, k, j, $) {
- var _e = a._PrepareAnimation(e, s, c, d, _, b, k, j);
- if (!_e)
- return null;
- var et = i.getScene();
- return et.beginDirectHierarchyAnimation(i, o, [_e], 0, d, _e.loopMode === 1, 1, $)
- }
- ,
- a.CreateMergeAndStartAnimation = function(e, i, o, s, c, d, _, b, k, j) {
- var $ = a._PrepareAnimation(e, o, s, c, d, _, b, k);
- return $ ? (i.animations.push($),
- i.getScene().beginAnimation(i, 0, c, $.loopMode === 1, 1, j)) : null
- }
- ,
- a.MakeAnimationAdditive = function(e, i, o, s, c) {
- i === void 0 && (i = 0),
- s === void 0 && (s = !1);
- var d = e;
- if (s && (d = e.clone(),
- d.name = c || d.name),
- !d._keys.length)
- return d;
- i = i >= 0 ? i : 0;
- var _ = 0
- , b = d._keys[0]
- , k = d._keys.length - 1
- , j = d._keys[k]
- , $ = {
- referenceValue: b.value,
- referencePosition: TmpVectors.Vector3[0],
- referenceQuaternion: TmpVectors.Quaternion[0],
- referenceScaling: TmpVectors.Vector3[1],
- keyPosition: TmpVectors.Vector3[2],
- keyQuaternion: TmpVectors.Quaternion[1],
- keyScaling: TmpVectors.Vector3[3]
- }
- , _e = !1
- , et = b.frame
- , tt = j.frame;
- if (o) {
- var rt = d.getRange(o);
- rt && (et = rt.from,
- tt = rt.to)
- }
- var it = b.frame === et
- , nt = j.frame === tt;
- if (d._keys.length === 1) {
- var ot = d._getKeyValue(d._keys[0]);
- $.referenceValue = ot.clone ? ot.clone() : ot,
- _e = !0
- } else if (i <= b.frame) {
- var ot = d._getKeyValue(b.value);
- $.referenceValue = ot.clone ? ot.clone() : ot,
- _e = !0
- } else if (i >= j.frame) {
- var ot = d._getKeyValue(j.value);
- $.referenceValue = ot.clone ? ot.clone() : ot,
- _e = !0
- }
- for (var at = 0; !_e || !it || !nt && at < d._keys.length - 1; ) {
- var st = d._keys[at]
- , ut = d._keys[at + 1];
- if (!_e && i >= st.frame && i <= ut.frame) {
- var ot = void 0;
- if (i === st.frame)
- ot = d._getKeyValue(st.value);
- else if (i === ut.frame)
- ot = d._getKeyValue(ut.value);
- else {
- var ct = {
- key: at,
- repeatCount: 0,
- loopMode: this.ANIMATIONLOOPMODE_CONSTANT
- };
- ot = d._interpolate(i, ct)
- }
- $.referenceValue = ot.clone ? ot.clone() : ot,
- _e = !0
- }
- if (!it && et >= st.frame && et <= ut.frame) {
- if (et === st.frame)
- _ = at;
- else if (et === ut.frame)
- _ = at + 1;
- else {
- var ct = {
- key: at,
- repeatCount: 0,
- loopMode: this.ANIMATIONLOOPMODE_CONSTANT
- }
- , ot = d._interpolate(et, ct)
- , lt = {
- frame: et,
- value: ot.clone ? ot.clone() : ot
- };
- d._keys.splice(at + 1, 0, lt),
- _ = at + 1
- }
- it = !0
- }
- if (!nt && tt >= st.frame && tt <= ut.frame) {
- if (tt === st.frame)
- k = at;
- else if (tt === ut.frame)
- k = at + 1;
- else {
- var ct = {
- key: at,
- repeatCount: 0,
- loopMode: this.ANIMATIONLOOPMODE_CONSTANT
- }
- , ot = d._interpolate(tt, ct)
- , lt = {
- frame: tt,
- value: ot.clone ? ot.clone() : ot
- };
- d._keys.splice(at + 1, 0, lt),
- k = at + 1
- }
- nt = !0
- }
- at++
- }
- d.dataType === a.ANIMATIONTYPE_QUATERNION ? $.referenceValue.normalize().conjugateInPlace() : d.dataType === a.ANIMATIONTYPE_MATRIX && ($.referenceValue.decompose($.referenceScaling, $.referenceQuaternion, $.referencePosition),
- $.referenceQuaternion.normalize().conjugateInPlace());
- for (var at = _; at <= k; at++) {
- var lt = d._keys[at];
- if (!(at && d.dataType !== a.ANIMATIONTYPE_FLOAT && lt.value === b.value))
- switch (d.dataType) {
- case a.ANIMATIONTYPE_MATRIX:
- lt.value.decompose($.keyScaling, $.keyQuaternion, $.keyPosition),
- $.keyPosition.subtractInPlace($.referencePosition),
- $.keyScaling.divideInPlace($.referenceScaling),
- $.referenceQuaternion.multiplyToRef($.keyQuaternion, $.keyQuaternion),
- Matrix.ComposeToRef($.keyScaling, $.keyQuaternion, $.keyPosition, lt.value);
- break;
- case a.ANIMATIONTYPE_QUATERNION:
- $.referenceValue.multiplyToRef(lt.value, lt.value);
- break;
- case a.ANIMATIONTYPE_VECTOR2:
- case a.ANIMATIONTYPE_VECTOR3:
- case a.ANIMATIONTYPE_COLOR3:
- case a.ANIMATIONTYPE_COLOR4:
- lt.value.subtractToRef($.referenceValue, lt.value);
- break;
- case a.ANIMATIONTYPE_SIZE:
- lt.value.width -= $.referenceValue.width,
- lt.value.height -= $.referenceValue.height;
- break;
- default:
- lt.value -= $.referenceValue
- }
- }
- return d
- }
- ,
- a.TransitionTo = function(e, i, o, s, c, d, _, b) {
- if (b === void 0 && (b = null),
- _ <= 0)
- return o[e] = i,
- b && b(),
- null;
- var k = c * (_ / 1e3);
- d.setKeys([{
- frame: 0,
- value: o[e].clone ? o[e].clone() : o[e]
- }, {
- frame: k,
- value: i
- }]),
- o.animations || (o.animations = []),
- o.animations.push(d);
- var j = s.beginAnimation(o, 0, k, !1);
- return j.onAnimationEnd = b,
- j
- }
- ,
- Object.defineProperty(a.prototype, "runtimeAnimations", {
- get: function() {
- return this._runtimeAnimations
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "hasRunningRuntimeAnimations", {
- get: function() {
- for (var e = 0, i = this._runtimeAnimations; e < i.length; e++) {
- var o = i[e];
- if (!o.isStopped())
- return !0
- }
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.toString = function(e) {
- var i = "Name: " + this.name + ", property: " + this.targetProperty;
- if (i += ", datatype: " + ["Float", "Vector3", "Quaternion", "Matrix", "Color3", "Vector2"][this.dataType],
- i += ", nKeys: " + (this._keys ? this._keys.length : "none"),
- i += ", nRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none"),
- e) {
- i += ", Ranges: {";
- var o = !0;
- for (var s in this._ranges)
- o && (i += ", ",
- o = !1),
- i += s;
- i += "}"
- }
- return i
- }
- ,
- a.prototype.addEvent = function(e) {
- this._events.push(e),
- this._events.sort(function(i, o) {
- return i.frame - o.frame
- })
- }
- ,
- a.prototype.removeEvents = function(e) {
- for (var i = 0; i < this._events.length; i++)
- this._events[i].frame === e && (this._events.splice(i, 1),
- i--)
- }
- ,
- a.prototype.getEvents = function() {
- return this._events
- }
- ,
- a.prototype.createRange = function(e, i, o) {
- this._ranges[e] || (this._ranges[e] = new AnimationRange(e,i,o))
- }
- ,
- a.prototype.deleteRange = function(e, i) {
- i === void 0 && (i = !0);
- var o = this._ranges[e];
- if (!!o) {
- if (i)
- for (var s = o.from, c = o.to, d = this._keys.length - 1; d >= 0; d--)
- this._keys[d].frame >= s && this._keys[d].frame <= c && this._keys.splice(d, 1);
- this._ranges[e] = null
- }
- }
- ,
- a.prototype.getRange = function(e) {
- return this._ranges[e]
- }
- ,
- a.prototype.getKeys = function() {
- return this._keys
- }
- ,
- a.prototype.getHighestFrame = function() {
- for (var e = 0, i = 0, o = this._keys.length; i < o; i++)
- e < this._keys[i].frame && (e = this._keys[i].frame);
- return e
- }
- ,
- a.prototype.getEasingFunction = function() {
- return this._easingFunction
- }
- ,
- a.prototype.setEasingFunction = function(e) {
- this._easingFunction = e
- }
- ,
- a.prototype.floatInterpolateFunction = function(e, i, o) {
- return Scalar.Lerp(e, i, o)
- }
- ,
- a.prototype.floatInterpolateFunctionWithTangents = function(e, i, o, s, c) {
- return Scalar.Hermite(e, i, o, s, c)
- }
- ,
- a.prototype.quaternionInterpolateFunction = function(e, i, o) {
- return Quaternion.Slerp(e, i, o)
- }
- ,
- a.prototype.quaternionInterpolateFunctionWithTangents = function(e, i, o, s, c) {
- return Quaternion.Hermite(e, i, o, s, c).normalize()
- }
- ,
- a.prototype.vector3InterpolateFunction = function(e, i, o) {
- return Vector3.Lerp(e, i, o)
- }
- ,
- a.prototype.vector3InterpolateFunctionWithTangents = function(e, i, o, s, c) {
- return Vector3.Hermite(e, i, o, s, c)
- }
- ,
- a.prototype.vector2InterpolateFunction = function(e, i, o) {
- return Vector2.Lerp(e, i, o)
- }
- ,
- a.prototype.vector2InterpolateFunctionWithTangents = function(e, i, o, s, c) {
- return Vector2.Hermite(e, i, o, s, c)
- }
- ,
- a.prototype.sizeInterpolateFunction = function(e, i, o) {
- return Size.Lerp(e, i, o)
- }
- ,
- a.prototype.color3InterpolateFunction = function(e, i, o) {
- return Color3.Lerp(e, i, o)
- }
- ,
- a.prototype.color3InterpolateFunctionWithTangents = function(e, i, o, s, c) {
- return Color3.Hermite(e, i, o, s, c)
- }
- ,
- a.prototype.color4InterpolateFunction = function(e, i, o) {
- return Color4.Lerp(e, i, o)
- }
- ,
- a.prototype.color4InterpolateFunctionWithTangents = function(e, i, o, s, c) {
- return Color4.Hermite(e, i, o, s, c)
- }
- ,
- a.prototype._getKeyValue = function(e) {
- return typeof e == "function" ? e() : e
- }
- ,
- a.prototype.evaluate = function(e) {
- return this._interpolate(e, {
- key: 0,
- repeatCount: 0,
- loopMode: a.ANIMATIONLOOPMODE_CONSTANT
- })
- }
- ,
- a.prototype._interpolate = function(e, i) {
- if (i.loopMode === a.ANIMATIONLOOPMODE_CONSTANT && i.repeatCount > 0)
- return i.highLimitValue.clone ? i.highLimitValue.clone() : i.highLimitValue;
- var o = this._keys;
- if (o.length === 1)
- return this._getKeyValue(o[0].value);
- var s = i.key;
- if (o[s].frame >= e)
- for (; s - 1 >= 0 && o[s].frame >= e; )
- s--;
- for (var c = s; c < o.length - 1; c++) {
- var d = o[c + 1];
- if (d.frame >= e) {
- i.key = c;
- var _ = o[c]
- , b = this._getKeyValue(_.value)
- , k = this._getKeyValue(d.value);
- if (_.interpolation === AnimationKeyInterpolation.STEP)
- return d.frame > e ? b : k;
- var j = _.outTangent !== void 0 && d.inTangent !== void 0
- , $ = d.frame - _.frame
- , _e = (e - _.frame) / $
- , et = this.getEasingFunction();
- switch (et != null && (_e = et.ease(_e)),
- this.dataType) {
- case a.ANIMATIONTYPE_FLOAT:
- var tt = j ? this.floatInterpolateFunctionWithTangents(b, _.outTangent * $, k, d.inTangent * $, _e) : this.floatInterpolateFunction(b, k, _e);
- switch (i.loopMode) {
- case a.ANIMATIONLOOPMODE_CYCLE:
- case a.ANIMATIONLOOPMODE_CONSTANT:
- return tt;
- case a.ANIMATIONLOOPMODE_RELATIVE:
- return i.offsetValue * i.repeatCount + tt
- }
- break;
- case a.ANIMATIONTYPE_QUATERNION:
- var rt = j ? this.quaternionInterpolateFunctionWithTangents(b, _.outTangent.scale($), k, d.inTangent.scale($), _e) : this.quaternionInterpolateFunction(b, k, _e);
- switch (i.loopMode) {
- case a.ANIMATIONLOOPMODE_CYCLE:
- case a.ANIMATIONLOOPMODE_CONSTANT:
- return rt;
- case a.ANIMATIONLOOPMODE_RELATIVE:
- return rt.addInPlace(i.offsetValue.scale(i.repeatCount))
- }
- return rt;
- case a.ANIMATIONTYPE_VECTOR3:
- var it = j ? this.vector3InterpolateFunctionWithTangents(b, _.outTangent.scale($), k, d.inTangent.scale($), _e) : this.vector3InterpolateFunction(b, k, _e);
- switch (i.loopMode) {
- case a.ANIMATIONLOOPMODE_CYCLE:
- case a.ANIMATIONLOOPMODE_CONSTANT:
- return it;
- case a.ANIMATIONLOOPMODE_RELATIVE:
- return it.add(i.offsetValue.scale(i.repeatCount))
- }
- case a.ANIMATIONTYPE_VECTOR2:
- var nt = j ? this.vector2InterpolateFunctionWithTangents(b, _.outTangent.scale($), k, d.inTangent.scale($), _e) : this.vector2InterpolateFunction(b, k, _e);
- switch (i.loopMode) {
- case a.ANIMATIONLOOPMODE_CYCLE:
- case a.ANIMATIONLOOPMODE_CONSTANT:
- return nt;
- case a.ANIMATIONLOOPMODE_RELATIVE:
- return nt.add(i.offsetValue.scale(i.repeatCount))
- }
- case a.ANIMATIONTYPE_SIZE:
- switch (i.loopMode) {
- case a.ANIMATIONLOOPMODE_CYCLE:
- case a.ANIMATIONLOOPMODE_CONSTANT:
- return this.sizeInterpolateFunction(b, k, _e);
- case a.ANIMATIONLOOPMODE_RELATIVE:
- return this.sizeInterpolateFunction(b, k, _e).add(i.offsetValue.scale(i.repeatCount))
- }
- case a.ANIMATIONTYPE_COLOR3:
- var ot = j ? this.color3InterpolateFunctionWithTangents(b, _.outTangent.scale($), k, d.inTangent.scale($), _e) : this.color3InterpolateFunction(b, k, _e);
- switch (i.loopMode) {
- case a.ANIMATIONLOOPMODE_CYCLE:
- case a.ANIMATIONLOOPMODE_CONSTANT:
- return ot;
- case a.ANIMATIONLOOPMODE_RELATIVE:
- return ot.add(i.offsetValue.scale(i.repeatCount))
- }
- case a.ANIMATIONTYPE_COLOR4:
- var at = j ? this.color4InterpolateFunctionWithTangents(b, _.outTangent.scale($), k, d.inTangent.scale($), _e) : this.color4InterpolateFunction(b, k, _e);
- switch (i.loopMode) {
- case a.ANIMATIONLOOPMODE_CYCLE:
- case a.ANIMATIONLOOPMODE_CONSTANT:
- return at;
- case a.ANIMATIONLOOPMODE_RELATIVE:
- return at.add(i.offsetValue.scale(i.repeatCount))
- }
- case a.ANIMATIONTYPE_MATRIX:
- switch (i.loopMode) {
- case a.ANIMATIONLOOPMODE_CYCLE:
- case a.ANIMATIONLOOPMODE_CONSTANT:
- if (a.AllowMatricesInterpolation)
- return this.matrixInterpolateFunction(b, k, _e, i.workValue);
- case a.ANIMATIONLOOPMODE_RELATIVE:
- return b
- }
- }
- break
- }
- }
- return this._getKeyValue(o[o.length - 1].value)
- }
- ,
- a.prototype.matrixInterpolateFunction = function(e, i, o, s) {
- return a.AllowMatrixDecomposeForInterpolation ? s ? (Matrix.DecomposeLerpToRef(e, i, o, s),
- s) : Matrix.DecomposeLerp(e, i, o) : s ? (Matrix.LerpToRef(e, i, o, s),
- s) : Matrix.Lerp(e, i, o)
- }
- ,
- a.prototype.clone = function() {
- var e = new a(this.name,this.targetPropertyPath.join("."),this.framePerSecond,this.dataType,this.loopMode);
- if (e.enableBlending = this.enableBlending,
- e.blendingSpeed = this.blendingSpeed,
- this._keys && e.setKeys(this._keys),
- this._ranges) {
- e._ranges = {};
- for (var i in this._ranges) {
- var o = this._ranges[i];
- !o || (e._ranges[i] = o.clone())
- }
- }
- return e
- }
- ,
- a.prototype.setKeys = function(e) {
- this._keys = e.slice(0)
- }
- ,
- a.prototype.serialize = function() {
- var e = {};
- e.name = this.name,
- e.property = this.targetProperty,
- e.framePerSecond = this.framePerSecond,
- e.dataType = this.dataType,
- e.loopBehavior = this.loopMode,
- e.enableBlending = this.enableBlending,
- e.blendingSpeed = this.blendingSpeed;
- var i = this.dataType;
- e.keys = [];
- for (var o = this.getKeys(), s = 0; s < o.length; s++) {
- var c = o[s]
- , d = {};
- switch (d.frame = c.frame,
- i) {
- case a.ANIMATIONTYPE_FLOAT:
- d.values = [c.value],
- c.inTangent !== void 0 && d.values.push(c.inTangent),
- c.outTangent !== void 0 && (c.inTangent === void 0 && d.values.push(void 0),
- d.values.push(c.outTangent));
- break;
- case a.ANIMATIONTYPE_QUATERNION:
- case a.ANIMATIONTYPE_MATRIX:
- case a.ANIMATIONTYPE_VECTOR3:
- case a.ANIMATIONTYPE_COLOR3:
- case a.ANIMATIONTYPE_COLOR4:
- d.values = c.value.asArray(),
- c.inTangent != null && d.values.push(c.inTangent.asArray()),
- c.outTangent != null && (c.inTangent === void 0 && d.values.push(void 0),
- d.values.push(c.outTangent.asArray()));
- break
- }
- e.keys.push(d)
- }
- e.ranges = [];
- for (var _ in this._ranges) {
- var b = this._ranges[_];
- if (!!b) {
- var k = {};
- k.name = _,
- k.from = b.from,
- k.to = b.to,
- e.ranges.push(k)
- }
- }
- return e
- }
- ,
- a._UniversalLerp = function(e, i, o) {
- var s = e.constructor;
- return s.Lerp ? s.Lerp(e, i, o) : s.Slerp ? s.Slerp(e, i, o) : e.toFixed ? e * (1 - o) + o * i : i
- }
- ,
- a.Parse = function(e) {
- var i = new a(e.name,e.property,e.framePerSecond,e.dataType,e.loopBehavior), o = e.dataType, s = [], c, d;
- for (e.enableBlending && (i.enableBlending = e.enableBlending),
- e.blendingSpeed && (i.blendingSpeed = e.blendingSpeed),
- d = 0; d < e.keys.length; d++) {
- var _ = e.keys[d]
- , b = void 0
- , k = void 0;
- switch (o) {
- case a.ANIMATIONTYPE_FLOAT:
- c = _.values[0],
- _.values.length >= 1 && (b = _.values[1]),
- _.values.length >= 2 && (k = _.values[2]);
- break;
- case a.ANIMATIONTYPE_QUATERNION:
- if (c = Quaternion.FromArray(_.values),
- _.values.length >= 8) {
- var j = Quaternion.FromArray(_.values.slice(4, 8));
- j.equals(Quaternion.Zero()) || (b = j)
- }
- if (_.values.length >= 12) {
- var $ = Quaternion.FromArray(_.values.slice(8, 12));
- $.equals(Quaternion.Zero()) || (k = $)
- }
- break;
- case a.ANIMATIONTYPE_MATRIX:
- c = Matrix.FromArray(_.values);
- break;
- case a.ANIMATIONTYPE_COLOR3:
- c = Color3.FromArray(_.values),
- _.values[3] && (b = Color3.FromArray(_.values[3])),
- _.values[4] && (k = Color3.FromArray(_.values[4]));
- break;
- case a.ANIMATIONTYPE_COLOR4:
- c = Color4.FromArray(_.values),
- _.values[4] && (b = Color4.FromArray(_.values[4])),
- _.values[5] && (k = Color4.FromArray(_.values[5]));
- break;
- case a.ANIMATIONTYPE_VECTOR3:
- default:
- c = Vector3.FromArray(_.values),
- _.values[3] && (b = Vector3.FromArray(_.values[3])),
- _.values[4] && (k = Vector3.FromArray(_.values[4]));
- break
- }
- var _e = {};
- _e.frame = _.frame,
- _e.value = c,
- b != null && (_e.inTangent = b),
- k != null && (_e.outTangent = k),
- s.push(_e)
- }
- if (i.setKeys(s),
- e.ranges)
- for (d = 0; d < e.ranges.length; d++)
- c = e.ranges[d],
- i.createRange(c.name, c.from, c.to);
- return i
- }
- ,
- a.AppendSerializedAnimations = function(e, i) {
- SerializationHelper.AppendSerializedAnimations(e, i)
- }
- ,
- a.ParseFromFileAsync = function(e, i) {
- var o = this;
- return new Promise(function(s, c) {
- var d = new WebRequest;
- d.addEventListener("readystatechange", function() {
- if (d.readyState == 4)
- if (d.status == 200) {
- var _ = JSON.parse(d.responseText);
- if (_.length) {
- for (var b = new Array, k = 0, j = _; k < j.length; k++) {
- var $ = j[k];
- b.push(o.Parse($))
- }
- s(b)
- } else {
- var b = o.Parse(_);
- e && (b.name = e),
- s(b)
- }
- } else
- c("Unable to load the animation")
- }),
- d.open("GET", i),
- d.send()
- }
- )
- }
- ,
- a.CreateFromSnippetAsync = function(e) {
- var i = this;
- return new Promise(function(o, s) {
- var c = new WebRequest;
- c.addEventListener("readystatechange", function() {
- if (c.readyState == 4)
- if (c.status == 200) {
- var d = JSON.parse(JSON.parse(c.responseText).jsonPayload);
- if (d.animations) {
- for (var _ = JSON.parse(d.animations), b = new Array, k = 0, j = _.animations; k < j.length; k++) {
- var $ = j[k]
- , _e = i.Parse($);
- _e.snippetId = e,
- b.push(_e)
- }
- o(b)
- } else {
- var _ = JSON.parse(d.animation)
- , _e = i.Parse(_);
- _e.snippetId = e,
- o(_e)
- }
- } else
- s("Unable to load the snippet " + e)
- }),
- c.open("GET", i.SnippetUrl + "/" + e.replace(/#/g, "/")),
- c.send()
- }
- )
- }
- ,
- a._UniqueIdGenerator = 0,
- a.AllowMatricesInterpolation = !1,
- a.AllowMatrixDecomposeForInterpolation = !0,
- a.SnippetUrl = "https://snippet.babylonjs.com",
- a.ANIMATIONTYPE_FLOAT = 0,
- a.ANIMATIONTYPE_VECTOR3 = 1,
- a.ANIMATIONTYPE_QUATERNION = 2,
- a.ANIMATIONTYPE_MATRIX = 3,
- a.ANIMATIONTYPE_COLOR3 = 4,
- a.ANIMATIONTYPE_COLOR4 = 7,
- a.ANIMATIONTYPE_VECTOR2 = 5,
- a.ANIMATIONTYPE_SIZE = 6,
- a.ANIMATIONLOOPMODE_RELATIVE = 0,
- a.ANIMATIONLOOPMODE_CYCLE = 1,
- a.ANIMATIONLOOPMODE_CONSTANT = 2,
- a
- }();
- RegisterClass("BABYLON.Animation", Animation);
- Node$2._AnimationRangeFactory = function(a, e, i) {
- return new AnimationRange(a,e,i)
- }
- ;
- var _staticOffsetValueQuaternion = Object.freeze(new Quaternion(0,0,0,0))
- , _staticOffsetValueVector3 = Object.freeze(Vector3.Zero())
- , _staticOffsetValueVector2 = Object.freeze(Vector2.Zero())
- , _staticOffsetValueSize = Object.freeze(Size.Zero())
- , _staticOffsetValueColor3 = Object.freeze(Color3.Black())
- , RuntimeAnimation = function() {
- function a(e, i, o, s) {
- var c = this;
- if (this._events = new Array,
- this._currentFrame = 0,
- this._originalValue = new Array,
- this._originalBlendValue = null,
- this._offsetsCache = {},
- this._highLimitsCache = {},
- this._stopped = !1,
- this._blendingFactor = 0,
- this._currentValue = null,
- this._currentActiveTarget = null,
- this._directTarget = null,
- this._targetPath = "",
- this._weight = 1,
- this._ratioOffset = 0,
- this._previousDelay = 0,
- this._previousRatio = 0,
- this._targetIsArray = !1,
- this._animation = i,
- this._target = e,
- this._scene = o,
- this._host = s,
- this._activeTargets = [],
- i._runtimeAnimations.push(this),
- this._animationState = {
- key: 0,
- repeatCount: 0,
- loopMode: this._getCorrectLoopMode()
- },
- this._animation.dataType === Animation.ANIMATIONTYPE_MATRIX && (this._animationState.workValue = Matrix.Zero()),
- this._keys = this._animation.getKeys(),
- this._minFrame = this._keys[0].frame,
- this._maxFrame = this._keys[this._keys.length - 1].frame,
- this._minValue = this._keys[0].value,
- this._maxValue = this._keys[this._keys.length - 1].value,
- this._minFrame !== 0) {
- var d = {
- frame: 0,
- value: this._minValue
- };
- this._keys.splice(0, 0, d)
- }
- if (this._target instanceof Array) {
- for (var _ = 0, b = 0, k = this._target; b < k.length; b++) {
- var j = k[b];
- this._preparePath(j, _),
- this._getOriginalValues(_),
- _++
- }
- this._targetIsArray = !0
- } else
- this._preparePath(this._target),
- this._getOriginalValues(),
- this._targetIsArray = !1,
- this._directTarget = this._activeTargets[0];
- var $ = i.getEvents();
- $ && $.length > 0 && $.forEach(function(_e) {
- c._events.push(_e._clone())
- }),
- this._enableBlending = e && e.animationPropertiesOverride ? e.animationPropertiesOverride.enableBlending : this._animation.enableBlending
- }
- return Object.defineProperty(a.prototype, "currentFrame", {
- get: function() {
- return this._currentFrame
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "weight", {
- get: function() {
- return this._weight
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "currentValue", {
- get: function() {
- return this._currentValue
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "targetPath", {
- get: function() {
- return this._targetPath
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "target", {
- get: function() {
- return this._currentActiveTarget
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "isAdditive", {
- get: function() {
- return this._host && this._host.isAdditive
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._preparePath = function(e, i) {
- i === void 0 && (i = 0);
- var o = this._animation.targetPropertyPath;
- if (o.length > 1) {
- for (var s = e[o[0]], c = 1; c < o.length - 1; c++)
- s = s[o[c]];
- this._targetPath = o[o.length - 1],
- this._activeTargets[i] = s
- } else
- this._targetPath = o[0],
- this._activeTargets[i] = e
- }
- ,
- Object.defineProperty(a.prototype, "animation", {
- get: function() {
- return this._animation
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.reset = function(e) {
- if (e === void 0 && (e = !1),
- e)
- if (this._target instanceof Array)
- for (var i = 0, o = 0, s = this._target; o < s.length; o++) {
- var c = s[o];
- this._originalValue[i] !== void 0 && this._setValue(c, this._activeTargets[i], this._originalValue[i], -1, i),
- i++
- }
- else
- this._originalValue[0] !== void 0 && this._setValue(this._target, this._directTarget, this._originalValue[0], -1, 0);
- this._offsetsCache = {},
- this._highLimitsCache = {},
- this._currentFrame = 0,
- this._blendingFactor = 0;
- for (var i = 0; i < this._events.length; i++)
- this._events[i].isDone = !1
- }
- ,
- a.prototype.isStopped = function() {
- return this._stopped
- }
- ,
- a.prototype.dispose = function() {
- var e = this._animation.runtimeAnimations.indexOf(this);
- e > -1 && this._animation.runtimeAnimations.splice(e, 1)
- }
- ,
- a.prototype.setValue = function(e, i) {
- if (this._targetIsArray) {
- for (var o = 0; o < this._target.length; o++) {
- var s = this._target[o];
- this._setValue(s, this._activeTargets[o], e, i, o)
- }
- return
- }
- this._setValue(this._target, this._directTarget, e, i, 0)
- }
- ,
- a.prototype._getOriginalValues = function(e) {
- e === void 0 && (e = 0);
- var i, o = this._activeTargets[e];
- o.getRestPose && this._targetPath === "_matrix" ? i = o.getRestPose() : i = o[this._targetPath],
- i && i.clone ? this._originalValue[e] = i.clone() : this._originalValue[e] = i
- }
- ,
- a.prototype._setValue = function(e, i, o, s, c) {
- if (this._currentActiveTarget = i,
- this._weight = s,
- this._enableBlending && this._blendingFactor <= 1) {
- if (!this._originalBlendValue) {
- var d = i[this._targetPath];
- d.clone ? this._originalBlendValue = d.clone() : this._originalBlendValue = d
- }
- 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);
- var _ = e && e.animationPropertiesOverride ? e.animationPropertiesOverride.blendingSpeed : this._animation.blendingSpeed;
- this._blendingFactor += _
- } else
- this._currentValue ? this._currentValue.copyFrom ? this._currentValue.copyFrom(o) : this._currentValue = o : o != null && o.clone ? this._currentValue = o.clone() : this._currentValue = o;
- s !== -1 ? this._scene._registerTargetForLateAnimationBinding(this, this._originalValue[c]) : i[this._targetPath] = this._currentValue,
- e.markAsDirty && e.markAsDirty(this._animation.targetProperty)
- }
- ,
- a.prototype._getCorrectLoopMode = function() {
- return this._target && this._target.animationPropertiesOverride ? this._target.animationPropertiesOverride.loopMode : this._animation.loopMode
- }
- ,
- a.prototype.goToFrame = function(e) {
- var i = this._animation.getKeys();
- e < i[0].frame ? e = i[0].frame : e > i[i.length - 1].frame && (e = i[i.length - 1].frame);
- var o = this._events;
- if (o.length)
- for (var s = 0; s < o.length; s++)
- o[s].onlyOnce || (o[s].isDone = o[s].frame < e);
- this._currentFrame = e;
- var c = this._animation._interpolate(e, this._animationState);
- this.setValue(c, -1)
- }
- ,
- a.prototype._prepareForSpeedRatioChange = function(e) {
- var i = this._previousDelay * (this._animation.framePerSecond * e) / 1e3;
- this._ratioOffset = this._previousRatio - i
- }
- ,
- a.prototype.animate = function(e, i, o, s, c, d) {
- d === void 0 && (d = -1);
- var _ = this._animation
- , b = _.targetPropertyPath;
- if (!b || b.length < 1)
- return this._stopped = !0,
- !1;
- var k = !0;
- (i < this._minFrame || i > this._maxFrame) && (i = this._minFrame),
- (o < this._minFrame || o > this._maxFrame) && (o = this._maxFrame);
- var j = o - i, $, _e = e * (_.framePerSecond * c) / 1e3 + this._ratioOffset, et = 0;
- if (this._previousDelay = e,
- this._previousRatio = _e,
- !s && o >= i && _e >= j)
- k = !1,
- et = _._getKeyValue(this._maxValue);
- else if (!s && i >= o && _e <= j)
- k = !1,
- et = _._getKeyValue(this._minValue);
- else if (this._animationState.loopMode !== Animation.ANIMATIONLOOPMODE_CYCLE) {
- var tt = o.toString() + i.toString();
- if (!this._offsetsCache[tt]) {
- this._animationState.repeatCount = 0,
- this._animationState.loopMode = Animation.ANIMATIONLOOPMODE_CYCLE;
- var rt = _._interpolate(i, this._animationState)
- , it = _._interpolate(o, this._animationState);
- switch (this._animationState.loopMode = this._getCorrectLoopMode(),
- _.dataType) {
- case Animation.ANIMATIONTYPE_FLOAT:
- this._offsetsCache[tt] = it - rt;
- break;
- case Animation.ANIMATIONTYPE_QUATERNION:
- this._offsetsCache[tt] = it.subtract(rt);
- break;
- case Animation.ANIMATIONTYPE_VECTOR3:
- this._offsetsCache[tt] = it.subtract(rt);
- break;
- case Animation.ANIMATIONTYPE_VECTOR2:
- this._offsetsCache[tt] = it.subtract(rt);
- break;
- case Animation.ANIMATIONTYPE_SIZE:
- this._offsetsCache[tt] = it.subtract(rt);
- break;
- case Animation.ANIMATIONTYPE_COLOR3:
- this._offsetsCache[tt] = it.subtract(rt);
- break
- }
- this._highLimitsCache[tt] = it
- }
- et = this._highLimitsCache[tt],
- $ = this._offsetsCache[tt]
- }
- if ($ === void 0)
- switch (_.dataType) {
- case Animation.ANIMATIONTYPE_FLOAT:
- $ = 0;
- break;
- case Animation.ANIMATIONTYPE_QUATERNION:
- $ = _staticOffsetValueQuaternion;
- break;
- case Animation.ANIMATIONTYPE_VECTOR3:
- $ = _staticOffsetValueVector3;
- break;
- case Animation.ANIMATIONTYPE_VECTOR2:
- $ = _staticOffsetValueVector2;
- break;
- case Animation.ANIMATIONTYPE_SIZE:
- $ = _staticOffsetValueSize;
- break;
- case Animation.ANIMATIONTYPE_COLOR3:
- $ = _staticOffsetValueColor3
- }
- var nt;
- if (this._host && this._host.syncRoot) {
- var ot = this._host.syncRoot
- , at = (ot.masterFrame - ot.fromFrame) / (ot.toFrame - ot.fromFrame);
- nt = i + (o - i) * at
- } else
- _e > 0 && i > o || _e < 0 && i < o ? nt = k && j !== 0 ? o + _e % j : i : nt = k && j !== 0 ? i + _e % j : o;
- var st = this._events;
- if ((c > 0 && this.currentFrame > nt || c < 0 && this.currentFrame < nt) && (this._onLoop(),
- st.length))
- for (var ut = 0; ut < st.length; ut++)
- st[ut].onlyOnce || (st[ut].isDone = !1);
- this._currentFrame = nt,
- this._animationState.repeatCount = j === 0 ? 0 : _e / j >> 0,
- this._animationState.highLimitValue = et,
- this._animationState.offsetValue = $;
- var ct = _._interpolate(nt, this._animationState);
- if (this.setValue(ct, d),
- st.length) {
- for (var ut = 0; ut < st.length; ut++)
- if (j > 0 && nt >= st[ut].frame && st[ut].frame >= i || j < 0 && nt <= st[ut].frame && st[ut].frame <= i) {
- var lt = st[ut];
- lt.isDone || (lt.onlyOnce && (st.splice(ut, 1),
- ut--),
- lt.isDone = !0,
- lt.action(nt))
- }
- }
- return k || (this._stopped = !0),
- k
- }
- ,
- a
- }()
- , Bone = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _, b) {
- s === void 0 && (s = null),
- c === void 0 && (c = null),
- d === void 0 && (d = null),
- _ === void 0 && (_ = null),
- b === void 0 && (b = null);
- var k = a.call(this, i, o.getScene()) || this;
- return k.name = i,
- k.children = new Array,
- k.animations = new Array,
- k._index = null,
- k._absoluteTransform = new Matrix,
- k._invertedAbsoluteTransform = new Matrix,
- k._scalingDeterminant = 1,
- k._worldTransform = new Matrix,
- k._needToDecompose = !0,
- k._needToCompose = !1,
- k._linkedTransformNode = null,
- k._waitingTransformNodeId = null,
- k._skeleton = o,
- k._localMatrix = c ? c.clone() : Matrix.Identity(),
- k._restPose = d || k._localMatrix.clone(),
- k._baseMatrix = _ || k._localMatrix.clone(),
- k._index = b,
- o.bones.push(k),
- k.setParent(s, !1),
- (_ || c) && k._updateDifferenceMatrix(),
- k
- }
- return Object.defineProperty(e.prototype, "_matrix", {
- get: function() {
- return this._compose(),
- this._localMatrix
- },
- set: function(i) {
- this._needToCompose = !1,
- i.updateFlag !== this._localMatrix.updateFlag && (this._localMatrix.copyFrom(i),
- this._markAsDirtyAndDecompose())
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getClassName = function() {
- return "Bone"
- }
- ,
- e.prototype.getSkeleton = function() {
- return this._skeleton
- }
- ,
- e.prototype.getParent = function() {
- return this._parent
- }
- ,
- e.prototype.getChildren = function() {
- return this.children
- }
- ,
- e.prototype.getIndex = function() {
- return this._index === null ? this.getSkeleton().bones.indexOf(this) : this._index
- }
- ,
- e.prototype.setParent = function(i, o) {
- if (o === void 0 && (o = !0),
- this._parent !== i) {
- if (this._parent) {
- var s = this._parent.children.indexOf(this);
- s !== -1 && this._parent.children.splice(s, 1)
- }
- this._parent = i,
- this._parent && this._parent.children.push(this),
- o && this._updateDifferenceMatrix(),
- this.markAsDirty()
- }
- }
- ,
- e.prototype.getLocalMatrix = function() {
- return this._compose(),
- this._localMatrix
- }
- ,
- e.prototype.getBaseMatrix = function() {
- return this._baseMatrix
- }
- ,
- e.prototype.getRestPose = function() {
- return this._restPose
- }
- ,
- e.prototype.setRestPose = function(i) {
- this._restPose.copyFrom(i)
- }
- ,
- e.prototype.getBindPose = function() {
- return this._baseMatrix
- }
- ,
- e.prototype.setBindPose = function(i) {
- this.updateMatrix(i)
- }
- ,
- e.prototype.getWorldMatrix = function() {
- return this._worldTransform
- }
- ,
- e.prototype.returnToRest = function() {
- var i;
- if (this._linkedTransformNode) {
- var o = TmpVectors.Vector3[0]
- , s = TmpVectors.Quaternion[0]
- , c = TmpVectors.Vector3[1];
- this.getRestPose().decompose(o, s, c),
- this._linkedTransformNode.position.copyFrom(c),
- this._linkedTransformNode.rotationQuaternion = (i = this._linkedTransformNode.rotationQuaternion) !== null && i !== void 0 ? i : Quaternion.Identity(),
- this._linkedTransformNode.rotationQuaternion.copyFrom(s),
- this._linkedTransformNode.scaling.copyFrom(o)
- } else
- this._matrix = this._restPose
- }
- ,
- e.prototype.getInvertedAbsoluteTransform = function() {
- return this._invertedAbsoluteTransform
- }
- ,
- e.prototype.getAbsoluteTransform = function() {
- return this._absoluteTransform
- }
- ,
- e.prototype.linkTransformNode = function(i) {
- this._linkedTransformNode && this._skeleton._numBonesWithLinkedTransformNode--,
- this._linkedTransformNode = i,
- this._linkedTransformNode && this._skeleton._numBonesWithLinkedTransformNode++
- }
- ,
- e.prototype.getTransformNode = function() {
- return this._linkedTransformNode
- }
- ,
- Object.defineProperty(e.prototype, "position", {
- get: function() {
- return this._decompose(),
- this._localPosition
- },
- set: function(i) {
- this._decompose(),
- this._localPosition.copyFrom(i),
- this._markAsDirtyAndCompose()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "rotation", {
- get: function() {
- return this.getRotation()
- },
- set: function(i) {
- this.setRotation(i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "rotationQuaternion", {
- get: function() {
- return this._decompose(),
- this._localRotation
- },
- set: function(i) {
- this.setRotationQuaternion(i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "scaling", {
- get: function() {
- return this.getScale()
- },
- set: function(i) {
- this.setScale(i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "animationPropertiesOverride", {
- get: function() {
- return this._skeleton.animationPropertiesOverride
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._decompose = function() {
- !this._needToDecompose || (this._needToDecompose = !1,
- this._localScaling || (this._localScaling = Vector3.Zero(),
- this._localRotation = Quaternion.Zero(),
- this._localPosition = Vector3.Zero()),
- this._localMatrix.decompose(this._localScaling, this._localRotation, this._localPosition))
- }
- ,
- e.prototype._compose = function() {
- if (!!this._needToCompose) {
- if (!this._localScaling) {
- this._needToCompose = !1;
- return
- }
- this._needToCompose = !1,
- Matrix.ComposeToRef(this._localScaling, this._localRotation, this._localPosition, this._localMatrix)
- }
- }
- ,
- e.prototype.updateMatrix = function(i, o, s) {
- o === void 0 && (o = !0),
- s === void 0 && (s = !0),
- this._baseMatrix.copyFrom(i),
- o && this._updateDifferenceMatrix(),
- s ? this._matrix = i : this.markAsDirty()
- }
- ,
- e.prototype._updateDifferenceMatrix = function(i, o) {
- if (o === void 0 && (o = !0),
- i || (i = this._baseMatrix),
- this._parent ? i.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform) : this._absoluteTransform.copyFrom(i),
- this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform),
- o)
- for (var s = 0; s < this.children.length; s++)
- this.children[s]._updateDifferenceMatrix();
- this._scalingDeterminant = this._absoluteTransform.determinant() < 0 ? -1 : 1
- }
- ,
- e.prototype.markAsDirty = function(i) {
- return this._currentRenderId++,
- this._childUpdateId++,
- this._skeleton._markAsDirty(),
- this
- }
- ,
- e.prototype._markAsDirtyAndCompose = function() {
- this.markAsDirty(),
- this._needToCompose = !0
- }
- ,
- e.prototype._markAsDirtyAndDecompose = function() {
- this.markAsDirty(),
- this._needToDecompose = !0
- }
- ,
- e.prototype.translate = function(i, o, s) {
- o === void 0 && (o = Space.LOCAL);
- var c = this.getLocalMatrix();
- if (o == Space.LOCAL)
- c.addAtIndex(12, i.x),
- c.addAtIndex(13, i.y),
- c.addAtIndex(14, i.z);
- else {
- var d = null;
- s && (d = s.getWorldMatrix()),
- this._skeleton.computeAbsoluteTransforms();
- var _ = e._tmpMats[0]
- , b = e._tmpVecs[0];
- this._parent ? s && d ? (_.copyFrom(this._parent.getAbsoluteTransform()),
- _.multiplyToRef(d, _)) : _.copyFrom(this._parent.getAbsoluteTransform()) : Matrix.IdentityToRef(_),
- _.setTranslationFromFloats(0, 0, 0),
- _.invert(),
- Vector3.TransformCoordinatesToRef(i, _, b),
- c.addAtIndex(12, b.x),
- c.addAtIndex(13, b.y),
- c.addAtIndex(14, b.z)
- }
- this._markAsDirtyAndDecompose()
- }
- ,
- e.prototype.setPosition = function(i, o, s) {
- o === void 0 && (o = Space.LOCAL);
- var c = this.getLocalMatrix();
- if (o == Space.LOCAL)
- c.setTranslationFromFloats(i.x, i.y, i.z);
- else {
- var d = null;
- s && (d = s.getWorldMatrix()),
- this._skeleton.computeAbsoluteTransforms();
- var _ = e._tmpMats[0]
- , b = e._tmpVecs[0];
- this._parent ? (s && d ? (_.copyFrom(this._parent.getAbsoluteTransform()),
- _.multiplyToRef(d, _)) : _.copyFrom(this._parent.getAbsoluteTransform()),
- _.invert()) : Matrix.IdentityToRef(_),
- Vector3.TransformCoordinatesToRef(i, _, b),
- c.setTranslationFromFloats(b.x, b.y, b.z)
- }
- this._markAsDirtyAndDecompose()
- }
- ,
- e.prototype.setAbsolutePosition = function(i, o) {
- this.setPosition(i, Space.WORLD, o)
- }
- ,
- e.prototype.scale = function(i, o, s, c) {
- c === void 0 && (c = !1);
- var d = this.getLocalMatrix()
- , _ = e._tmpMats[0];
- Matrix.ScalingToRef(i, o, s, _),
- _.multiplyToRef(d, d),
- _.invert();
- for (var b = 0, k = this.children; b < k.length; b++) {
- var j = k[b]
- , $ = j.getLocalMatrix();
- $.multiplyToRef(_, $),
- $.multiplyAtIndex(12, i),
- $.multiplyAtIndex(13, o),
- $.multiplyAtIndex(14, s),
- j._markAsDirtyAndDecompose()
- }
- if (this._markAsDirtyAndDecompose(),
- c)
- for (var _e = 0, et = this.children; _e < et.length; _e++) {
- var j = et[_e];
- j.scale(i, o, s, c)
- }
- }
- ,
- e.prototype.setScale = function(i) {
- this._decompose(),
- this._localScaling.copyFrom(i),
- this._markAsDirtyAndCompose()
- }
- ,
- e.prototype.getScale = function() {
- return this._decompose(),
- this._localScaling
- }
- ,
- e.prototype.getScaleToRef = function(i) {
- this._decompose(),
- i.copyFrom(this._localScaling)
- }
- ,
- e.prototype.setYawPitchRoll = function(i, o, s, c, d) {
- if (c === void 0 && (c = Space.LOCAL),
- c === Space.LOCAL) {
- var _ = e._tmpQuat;
- Quaternion.RotationYawPitchRollToRef(i, o, s, _),
- this.setRotationQuaternion(_, c, d);
- return
- }
- var b = e._tmpMats[0];
- if (!!this._getNegativeRotationToRef(b, d)) {
- var k = e._tmpMats[1];
- Matrix.RotationYawPitchRollToRef(i, o, s, k),
- b.multiplyToRef(k, k),
- this._rotateWithMatrix(k, c, d)
- }
- }
- ,
- e.prototype.rotate = function(i, o, s, c) {
- s === void 0 && (s = Space.LOCAL);
- var d = e._tmpMats[0];
- d.setTranslationFromFloats(0, 0, 0),
- Matrix.RotationAxisToRef(i, o, d),
- this._rotateWithMatrix(d, s, c)
- }
- ,
- e.prototype.setAxisAngle = function(i, o, s, c) {
- if (s === void 0 && (s = Space.LOCAL),
- s === Space.LOCAL) {
- var d = e._tmpQuat;
- Quaternion.RotationAxisToRef(i, o, d),
- this.setRotationQuaternion(d, s, c);
- return
- }
- var _ = e._tmpMats[0];
- if (!!this._getNegativeRotationToRef(_, c)) {
- var b = e._tmpMats[1];
- Matrix.RotationAxisToRef(i, o, b),
- _.multiplyToRef(b, b),
- this._rotateWithMatrix(b, s, c)
- }
- }
- ,
- e.prototype.setRotation = function(i, o, s) {
- o === void 0 && (o = Space.LOCAL),
- this.setYawPitchRoll(i.y, i.x, i.z, o, s)
- }
- ,
- e.prototype.setRotationQuaternion = function(i, o, s) {
- if (o === void 0 && (o = Space.LOCAL),
- o === Space.LOCAL) {
- this._decompose(),
- this._localRotation.copyFrom(i),
- this._markAsDirtyAndCompose();
- return
- }
- var c = e._tmpMats[0];
- if (!!this._getNegativeRotationToRef(c, s)) {
- var d = e._tmpMats[1];
- Matrix.FromQuaternionToRef(i, d),
- c.multiplyToRef(d, d),
- this._rotateWithMatrix(d, o, s)
- }
- }
- ,
- e.prototype.setRotationMatrix = function(i, o, s) {
- if (o === void 0 && (o = Space.LOCAL),
- o === Space.LOCAL) {
- var c = e._tmpQuat;
- Quaternion.FromRotationMatrixToRef(i, c),
- this.setRotationQuaternion(c, o, s);
- return
- }
- var d = e._tmpMats[0];
- if (!!this._getNegativeRotationToRef(d, s)) {
- var _ = e._tmpMats[1];
- _.copyFrom(i),
- d.multiplyToRef(i, _),
- this._rotateWithMatrix(_, o, s)
- }
- }
- ,
- e.prototype._rotateWithMatrix = function(i, o, s) {
- o === void 0 && (o = Space.LOCAL);
- var c = this.getLocalMatrix()
- , d = c.m[12]
- , _ = c.m[13]
- , b = c.m[14]
- , k = this.getParent()
- , j = e._tmpMats[3]
- , $ = e._tmpMats[4];
- k && o == Space.WORLD ? (s ? (j.copyFrom(s.getWorldMatrix()),
- k.getAbsoluteTransform().multiplyToRef(j, j)) : j.copyFrom(k.getAbsoluteTransform()),
- $.copyFrom(j),
- $.invert(),
- c.multiplyToRef(j, c),
- c.multiplyToRef(i, c),
- c.multiplyToRef($, c)) : o == Space.WORLD && s ? (j.copyFrom(s.getWorldMatrix()),
- $.copyFrom(j),
- $.invert(),
- c.multiplyToRef(j, c),
- c.multiplyToRef(i, c),
- c.multiplyToRef($, c)) : c.multiplyToRef(i, c),
- c.setTranslationFromFloats(d, _, b),
- this.computeAbsoluteTransforms(),
- this._markAsDirtyAndDecompose()
- }
- ,
- e.prototype._getNegativeRotationToRef = function(i, o) {
- var s = e._tmpMats[2];
- return i.copyFrom(this.getAbsoluteTransform()),
- o && (i.multiplyToRef(o.getWorldMatrix(), i),
- Matrix.ScalingToRef(o.scaling.x, o.scaling.y, o.scaling.z, s)),
- i.invert(),
- isNaN(i.m[0]) ? !1 : (s.multiplyAtIndex(0, this._scalingDeterminant),
- i.multiplyToRef(s, i),
- !0)
- }
- ,
- e.prototype.getPosition = function(i, o) {
- i === void 0 && (i = Space.LOCAL),
- o === void 0 && (o = null);
- var s = Vector3.Zero();
- return this.getPositionToRef(i, o, s),
- s
- }
- ,
- e.prototype.getPositionToRef = function(i, o, s) {
- if (i === void 0 && (i = Space.LOCAL),
- i == Space.LOCAL) {
- var c = this.getLocalMatrix();
- s.x = c.m[12],
- s.y = c.m[13],
- s.z = c.m[14]
- } else {
- var d = null;
- o && (d = o.getWorldMatrix()),
- this._skeleton.computeAbsoluteTransforms();
- var _ = e._tmpMats[0];
- o && d ? (_.copyFrom(this.getAbsoluteTransform()),
- _.multiplyToRef(d, _)) : _ = this.getAbsoluteTransform(),
- s.x = _.m[12],
- s.y = _.m[13],
- s.z = _.m[14]
- }
- }
- ,
- e.prototype.getAbsolutePosition = function(i) {
- i === void 0 && (i = null);
- var o = Vector3.Zero();
- return this.getPositionToRef(Space.WORLD, i, o),
- o
- }
- ,
- e.prototype.getAbsolutePositionToRef = function(i, o) {
- this.getPositionToRef(Space.WORLD, i, o)
- }
- ,
- e.prototype.computeAbsoluteTransforms = function() {
- if (this._compose(),
- this._parent)
- this._localMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
- else {
- this._absoluteTransform.copyFrom(this._localMatrix);
- var i = this._skeleton.getPoseMatrix();
- i && this._absoluteTransform.multiplyToRef(i, this._absoluteTransform)
- }
- for (var o = this.children, s = o.length, c = 0; c < s; c++)
- o[c].computeAbsoluteTransforms()
- }
- ,
- e.prototype.getDirection = function(i, o) {
- o === void 0 && (o = null);
- var s = Vector3.Zero();
- return this.getDirectionToRef(i, o, s),
- s
- }
- ,
- e.prototype.getDirectionToRef = function(i, o, s) {
- o === void 0 && (o = null);
- var c = null;
- o && (c = o.getWorldMatrix()),
- this._skeleton.computeAbsoluteTransforms();
- var d = e._tmpMats[0];
- d.copyFrom(this.getAbsoluteTransform()),
- o && c && d.multiplyToRef(c, d),
- Vector3.TransformNormalToRef(i, d, s),
- s.normalize()
- }
- ,
- e.prototype.getRotation = function(i, o) {
- i === void 0 && (i = Space.LOCAL),
- o === void 0 && (o = null);
- var s = Vector3.Zero();
- return this.getRotationToRef(i, o, s),
- s
- }
- ,
- e.prototype.getRotationToRef = function(i, o, s) {
- i === void 0 && (i = Space.LOCAL),
- o === void 0 && (o = null);
- var c = e._tmpQuat;
- this.getRotationQuaternionToRef(i, o, c),
- c.toEulerAnglesToRef(s)
- }
- ,
- e.prototype.getRotationQuaternion = function(i, o) {
- i === void 0 && (i = Space.LOCAL),
- o === void 0 && (o = null);
- var s = Quaternion.Identity();
- return this.getRotationQuaternionToRef(i, o, s),
- s
- }
- ,
- e.prototype.getRotationQuaternionToRef = function(i, o, s) {
- if (i === void 0 && (i = Space.LOCAL),
- o === void 0 && (o = null),
- i == Space.LOCAL)
- this._decompose(),
- s.copyFrom(this._localRotation);
- else {
- var c = e._tmpMats[0]
- , d = this.getAbsoluteTransform();
- o ? d.multiplyToRef(o.getWorldMatrix(), c) : c.copyFrom(d),
- c.multiplyAtIndex(0, this._scalingDeterminant),
- c.multiplyAtIndex(1, this._scalingDeterminant),
- c.multiplyAtIndex(2, this._scalingDeterminant),
- c.decompose(void 0, s, void 0)
- }
- }
- ,
- e.prototype.getRotationMatrix = function(i, o) {
- i === void 0 && (i = Space.LOCAL);
- var s = Matrix.Identity();
- return this.getRotationMatrixToRef(i, o, s),
- s
- }
- ,
- e.prototype.getRotationMatrixToRef = function(i, o, s) {
- if (i === void 0 && (i = Space.LOCAL),
- i == Space.LOCAL)
- this.getLocalMatrix().getRotationMatrixToRef(s);
- else {
- var c = e._tmpMats[0]
- , d = this.getAbsoluteTransform();
- o ? d.multiplyToRef(o.getWorldMatrix(), c) : c.copyFrom(d),
- c.multiplyAtIndex(0, this._scalingDeterminant),
- c.multiplyAtIndex(1, this._scalingDeterminant),
- c.multiplyAtIndex(2, this._scalingDeterminant),
- c.getRotationMatrixToRef(s)
- }
- }
- ,
- e.prototype.getAbsolutePositionFromLocal = function(i, o) {
- o === void 0 && (o = null);
- var s = Vector3.Zero();
- return this.getAbsolutePositionFromLocalToRef(i, o, s),
- s
- }
- ,
- e.prototype.getAbsolutePositionFromLocalToRef = function(i, o, s) {
- o === void 0 && (o = null);
- var c = null;
- o && (c = o.getWorldMatrix()),
- this._skeleton.computeAbsoluteTransforms();
- var d = e._tmpMats[0];
- o && c ? (d.copyFrom(this.getAbsoluteTransform()),
- d.multiplyToRef(c, d)) : d = this.getAbsoluteTransform(),
- Vector3.TransformCoordinatesToRef(i, d, s)
- }
- ,
- e.prototype.getLocalPositionFromAbsolute = function(i, o) {
- o === void 0 && (o = null);
- var s = Vector3.Zero();
- return this.getLocalPositionFromAbsoluteToRef(i, o, s),
- s
- }
- ,
- e.prototype.getLocalPositionFromAbsoluteToRef = function(i, o, s) {
- o === void 0 && (o = null);
- var c = null;
- o && (c = o.getWorldMatrix()),
- this._skeleton.computeAbsoluteTransforms();
- var d = e._tmpMats[0];
- d.copyFrom(this.getAbsoluteTransform()),
- o && c && d.multiplyToRef(c, d),
- d.invert(),
- Vector3.TransformCoordinatesToRef(i, d, s)
- }
- ,
- e.prototype.setCurrentPoseAsRest = function() {
- this.setRestPose(this.getLocalMatrix())
- }
- ,
- e._tmpVecs = ArrayTools.BuildArray(2, Vector3.Zero),
- e._tmpQuat = Quaternion.Identity(),
- e._tmpMats = ArrayTools.BuildArray(5, Matrix.Identity),
- e
- }(Node$2)
- , Animatable = function() {
- function a(e, i, o, s, c, d, _, b, k, j) {
- o === void 0 && (o = 0),
- s === void 0 && (s = 100),
- c === void 0 && (c = !1),
- d === void 0 && (d = 1),
- j === void 0 && (j = !1),
- this.target = i,
- this.fromFrame = o,
- this.toFrame = s,
- this.loopAnimation = c,
- this.onAnimationEnd = _,
- this.onAnimationLoop = k,
- this.isAdditive = j,
- this._localDelayOffset = null,
- this._pausedDelay = null,
- this._manualJumpDelay = null,
- this._runtimeAnimations = new Array,
- this._paused = !1,
- this._speedRatio = 1,
- this._weight = -1,
- this._syncRoot = null,
- this._frameToSyncFromJump = 0,
- this.disposeOnEnd = !0,
- this.animationStarted = !1,
- this.onAnimationEndObservable = new Observable,
- this.onAnimationLoopObservable = new Observable,
- this._scene = e,
- b && this.appendAnimations(i, b),
- this._speedRatio = d,
- e._activeAnimatables.push(this)
- }
- return Object.defineProperty(a.prototype, "syncRoot", {
- get: function() {
- return this._syncRoot
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "masterFrame", {
- get: function() {
- return this._runtimeAnimations.length === 0 ? 0 : this._runtimeAnimations[0].currentFrame
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "weight", {
- get: function() {
- return this._weight
- },
- set: function(e) {
- if (e === -1) {
- this._weight = -1;
- return
- }
- this._weight = Math.min(Math.max(e, 0), 1)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "speedRatio", {
- get: function() {
- return this._speedRatio
- },
- set: function(e) {
- for (var i = 0; i < this._runtimeAnimations.length; i++) {
- var o = this._runtimeAnimations[i];
- o._prepareForSpeedRatioChange(e)
- }
- this._speedRatio = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.syncWith = function(e) {
- if (this._syncRoot = e,
- e) {
- var i = this._scene._activeAnimatables.indexOf(this);
- i > -1 && (this._scene._activeAnimatables.splice(i, 1),
- this._scene._activeAnimatables.push(this))
- }
- return this
- }
- ,
- a.prototype.getAnimations = function() {
- return this._runtimeAnimations
- }
- ,
- a.prototype.appendAnimations = function(e, i) {
- for (var o = this, s = 0; s < i.length; s++) {
- var c = i[s]
- , d = new RuntimeAnimation(e,c,this._scene,this);
- d._onLoop = function() {
- o.onAnimationLoopObservable.notifyObservers(o),
- o.onAnimationLoop && o.onAnimationLoop()
- }
- ,
- this._runtimeAnimations.push(d)
- }
- }
- ,
- a.prototype.getAnimationByTargetProperty = function(e) {
- for (var i = this._runtimeAnimations, o = 0; o < i.length; o++)
- if (i[o].animation.targetProperty === e)
- return i[o].animation;
- return null
- }
- ,
- a.prototype.getRuntimeAnimationByTargetProperty = function(e) {
- for (var i = this._runtimeAnimations, o = 0; o < i.length; o++)
- if (i[o].animation.targetProperty === e)
- return i[o];
- return null
- }
- ,
- a.prototype.reset = function() {
- for (var e = this._runtimeAnimations, i = 0; i < e.length; i++)
- e[i].reset(!0);
- this._localDelayOffset = null,
- this._pausedDelay = null
- }
- ,
- a.prototype.enableBlending = function(e) {
- for (var i = this._runtimeAnimations, o = 0; o < i.length; o++)
- i[o].animation.enableBlending = !0,
- i[o].animation.blendingSpeed = e
- }
- ,
- a.prototype.disableBlending = function() {
- for (var e = this._runtimeAnimations, i = 0; i < e.length; i++)
- e[i].animation.enableBlending = !1
- }
- ,
- a.prototype.goToFrame = function(e) {
- var i, o = this._runtimeAnimations;
- if (o[0]) {
- var s = o[0].animation.framePerSecond;
- this._frameToSyncFromJump = (i = this._frameToSyncFromJump) !== null && i !== void 0 ? i : o[0].currentFrame;
- var c = this.speedRatio === 0 ? 0 : (e - this._frameToSyncFromJump) / s * 1e3 / this.speedRatio;
- this._manualJumpDelay = -c
- }
- for (var d = 0; d < o.length; d++)
- o[d].goToFrame(e)
- }
- ,
- a.prototype.pause = function() {
- this._paused || (this._paused = !0)
- }
- ,
- a.prototype.restart = function() {
- this._paused = !1
- }
- ,
- a.prototype._raiseOnAnimationEnd = function() {
- this.onAnimationEnd && this.onAnimationEnd(),
- this.onAnimationEndObservable.notifyObservers(this)
- }
- ,
- a.prototype.stop = function(e, i) {
- if (e || i) {
- var o = this._scene._activeAnimatables.indexOf(this);
- if (o > -1) {
- for (var s = this._runtimeAnimations, c = s.length - 1; c >= 0; c--) {
- var d = s[c];
- e && d.animation.name != e || i && !i(d.target) || (d.dispose(),
- s.splice(c, 1))
- }
- s.length == 0 && (this._scene._activeAnimatables.splice(o, 1),
- this._raiseOnAnimationEnd())
- }
- } else {
- var c = this._scene._activeAnimatables.indexOf(this);
- if (c > -1) {
- this._scene._activeAnimatables.splice(c, 1);
- for (var s = this._runtimeAnimations, c = 0; c < s.length; c++)
- s[c].dispose();
- this._raiseOnAnimationEnd()
- }
- }
- }
- ,
- a.prototype.waitAsync = function() {
- var e = this;
- return new Promise(function(i, o) {
- e.onAnimationEndObservable.add(function() {
- i(e)
- }, void 0, void 0, e, !0)
- }
- )
- }
- ,
- a.prototype._animate = function(e) {
- if (this._paused)
- return this.animationStarted = !1,
- this._pausedDelay === null && (this._pausedDelay = e),
- !0;
- if (this._localDelayOffset === null ? (this._localDelayOffset = e,
- this._pausedDelay = null) : this._pausedDelay !== null && (this._localDelayOffset += e - this._pausedDelay,
- this._pausedDelay = null),
- this._manualJumpDelay !== null && (this._localDelayOffset += this._manualJumpDelay,
- this._manualJumpDelay = null,
- this._frameToSyncFromJump = null),
- this._weight === 0)
- return !0;
- var i = !1, o = this._runtimeAnimations, s;
- for (s = 0; s < o.length; s++) {
- var c = o[s]
- , d = c.animate(e - this._localDelayOffset, this.fromFrame, this.toFrame, this.loopAnimation, this._speedRatio, this._weight);
- i = i || d
- }
- if (this.animationStarted = i,
- !i) {
- if (this.disposeOnEnd)
- for (s = this._scene._activeAnimatables.indexOf(this),
- this._scene._activeAnimatables.splice(s, 1),
- s = 0; s < o.length; s++)
- o[s].dispose();
- this._raiseOnAnimationEnd(),
- this.disposeOnEnd && (this.onAnimationEnd = null,
- this.onAnimationLoop = null,
- this.onAnimationLoopObservable.clear(),
- this.onAnimationEndObservable.clear())
- }
- return i
- }
- ,
- a
- }();
- Scene.prototype._animate = function() {
- if (!!this.animationsEnabled) {
- var a = PrecisionDate.Now;
- if (!this._animationTimeLast) {
- if (this._pendingData.length > 0)
- return;
- this._animationTimeLast = a
- }
- this.deltaTime = this.useConstantAnimationDeltaTime ? 16 : (a - this._animationTimeLast) * this.animationTimeScale,
- this._animationTimeLast = a;
- var e = this._activeAnimatables;
- if (e.length !== 0) {
- this._animationTime += this.deltaTime;
- for (var i = this._animationTime, o = 0; o < e.length; o++) {
- var s = e[o];
- !s._animate(i) && s.disposeOnEnd && o--
- }
- this._processLateAnimationBindings()
- }
- }
- }
- ;
- Scene.prototype.beginWeightedAnimation = function(a, e, i, o, s, c, d, _, b, k, j) {
- o === void 0 && (o = 1),
- c === void 0 && (c = 1),
- j === void 0 && (j = !1);
- var $ = this.beginAnimation(a, e, i, s, c, d, _, !1, b, k, j);
- return $.weight = o,
- $
- }
- ;
- Scene.prototype.beginAnimation = function(a, e, i, o, s, c, d, _, b, k, j) {
- s === void 0 && (s = 1),
- _ === void 0 && (_ = !0),
- j === void 0 && (j = !1),
- e > i && s > 0 && (s *= -1),
- _ && this.stopAnimation(a, void 0, b),
- d || (d = new Animatable(this,a,e,i,o,s,c,void 0,k,j));
- var $ = b ? b(a) : !0;
- if (a.animations && $ && d.appendAnimations(a, a.animations),
- a.getAnimatables)
- for (var _e = a.getAnimatables(), et = 0; et < _e.length; et++)
- this.beginAnimation(_e[et], e, i, o, s, c, d, _, b, k);
- return d.reset(),
- d
- }
- ;
- Scene.prototype.beginHierarchyAnimation = function(a, e, i, o, s, c, d, _, b, k, j, $) {
- c === void 0 && (c = 1),
- b === void 0 && (b = !0),
- $ === void 0 && ($ = !1);
- var _e = a.getDescendants(e)
- , et = [];
- et.push(this.beginAnimation(a, i, o, s, c, d, _, b, k, void 0, $));
- for (var tt = 0, rt = _e; tt < rt.length; tt++) {
- var it = rt[tt];
- et.push(this.beginAnimation(it, i, o, s, c, d, _, b, k, void 0, $))
- }
- return et
- }
- ;
- Scene.prototype.beginDirectAnimation = function(a, e, i, o, s, c, d, _, b) {
- if (b === void 0 && (b = !1),
- c === void 0 && (c = 1),
- i > o && c > 0)
- c *= -1;
- else if (o > i && c < 0) {
- var k = o;
- o = i,
- i = k
- }
- var j = new Animatable(this,a,i,o,s,c,d,e,_,b);
- return j
- }
- ;
- Scene.prototype.beginDirectHierarchyAnimation = function(a, e, i, o, s, c, d, _, b, k) {
- k === void 0 && (k = !1);
- var j = a.getDescendants(e)
- , $ = [];
- $.push(this.beginDirectAnimation(a, i, o, s, c, d, _, b, k));
- for (var _e = 0, et = j; _e < et.length; _e++) {
- var tt = et[_e];
- $.push(this.beginDirectAnimation(tt, i, o, s, c, d, _, b, k))
- }
- return $
- }
- ;
- Scene.prototype.getAnimatableByTarget = function(a) {
- for (var e = 0; e < this._activeAnimatables.length; e++)
- if (this._activeAnimatables[e].target === a)
- return this._activeAnimatables[e];
- return null
- }
- ;
- Scene.prototype.getAllAnimatablesByTarget = function(a) {
- for (var e = [], i = 0; i < this._activeAnimatables.length; i++)
- this._activeAnimatables[i].target === a && e.push(this._activeAnimatables[i]);
- return e
- }
- ;
- Scene.prototype.stopAnimation = function(a, e, i) {
- for (var o = this.getAllAnimatablesByTarget(a), s = 0, c = o; s < c.length; s++) {
- var d = c[s];
- d.stop(e, i)
- }
- }
- ;
- Scene.prototype.stopAllAnimations = function() {
- if (this._activeAnimatables) {
- for (var a = 0; a < this._activeAnimatables.length; a++)
- this._activeAnimatables[a].stop();
- this._activeAnimatables = []
- }
- for (var e = 0, i = this.animationGroups; e < i.length; e++) {
- var o = i[e];
- o.stop()
- }
- }
- ;
- Scene.prototype._registerTargetForLateAnimationBinding = function(a, e) {
- var i = a.target;
- this._registeredForLateAnimationBindings.pushNoDuplicate(i),
- i._lateAnimationHolders || (i._lateAnimationHolders = {}),
- i._lateAnimationHolders[a.targetPath] || (i._lateAnimationHolders[a.targetPath] = {
- totalWeight: 0,
- totalAdditiveWeight: 0,
- animations: [],
- additiveAnimations: [],
- originalValue: e
- }),
- a.isAdditive ? (i._lateAnimationHolders[a.targetPath].additiveAnimations.push(a),
- i._lateAnimationHolders[a.targetPath].totalAdditiveWeight += a.weight) : (i._lateAnimationHolders[a.targetPath].animations.push(a),
- i._lateAnimationHolders[a.targetPath].totalWeight += a.weight)
- }
- ;
- Scene.prototype._processLateAnimationBindingsForMatrices = function(a) {
- if (a.totalWeight === 0 && a.totalAdditiveWeight === 0)
- return a.originalValue;
- var e = 1
- , i = TmpVectors.Vector3[0]
- , o = TmpVectors.Vector3[1]
- , s = TmpVectors.Quaternion[0]
- , c = 0
- , d = a.animations[0]
- , _ = a.originalValue
- , b = 1
- , k = !1;
- if (a.totalWeight < 1)
- b = 1 - a.totalWeight,
- _.decompose(o, s, i);
- else {
- if (c = 1,
- e = a.totalWeight,
- b = d.weight / e,
- b == 1)
- if (a.totalAdditiveWeight)
- k = !0;
- else
- return d.currentValue;
- d.currentValue.decompose(o, s, i)
- }
- if (!k) {
- o.scaleInPlace(b),
- i.scaleInPlace(b),
- s.scaleInPlace(b);
- for (var j = c; j < a.animations.length; j++) {
- var $ = a.animations[j];
- if ($.weight !== 0) {
- var b = $.weight / e
- , _e = TmpVectors.Vector3[2]
- , et = TmpVectors.Vector3[3]
- , tt = TmpVectors.Quaternion[1];
- $.currentValue.decompose(et, tt, _e),
- et.scaleAndAddToRef(b, o),
- tt.scaleAndAddToRef(b, s),
- _e.scaleAndAddToRef(b, i)
- }
- }
- }
- for (var rt = 0; rt < a.additiveAnimations.length; rt++) {
- var $ = a.additiveAnimations[rt];
- if ($.weight !== 0) {
- var _e = TmpVectors.Vector3[2]
- , et = TmpVectors.Vector3[3]
- , tt = TmpVectors.Quaternion[1];
- $.currentValue.decompose(et, tt, _e),
- et.multiplyToRef(o, et),
- Vector3.LerpToRef(o, et, $.weight, o),
- s.multiplyToRef(tt, tt),
- Quaternion.SlerpToRef(s, tt, $.weight, s),
- _e.scaleAndAddToRef($.weight, i)
- }
- }
- var it = d ? d._animationState.workValue : TmpVectors.Matrix[0].clone();
- return Matrix.ComposeToRef(o, s, i, it),
- it
- }
- ;
- Scene.prototype._processLateAnimationBindingsForQuaternions = function(a, e) {
- if (a.totalWeight === 0 && a.totalAdditiveWeight === 0)
- return e;
- var i = a.animations[0]
- , o = a.originalValue
- , s = e;
- if (a.totalWeight === 0 && a.totalAdditiveWeight > 0)
- s.copyFrom(o);
- else if (a.animations.length === 1) {
- if (Quaternion.SlerpToRef(o, i.currentValue, Math.min(1, a.totalWeight), s),
- a.totalAdditiveWeight === 0)
- return s
- } else if (a.animations.length > 1) {
- var c = 1
- , d = void 0
- , _ = void 0;
- if (a.totalWeight < 1) {
- var b = 1 - a.totalWeight;
- d = [],
- _ = [],
- d.push(o),
- _.push(b)
- } else {
- if (a.animations.length === 2 && (Quaternion.SlerpToRef(a.animations[0].currentValue, a.animations[1].currentValue, a.animations[1].weight / a.totalWeight, e),
- a.totalAdditiveWeight === 0))
- return e;
- d = [],
- _ = [],
- c = a.totalWeight
- }
- for (var k = 0; k < a.animations.length; k++) {
- var j = a.animations[k];
- d.push(j.currentValue),
- _.push(j.weight / c)
- }
- for (var $ = 0, _e = 0; _e < d.length; ) {
- if (!_e) {
- Quaternion.SlerpToRef(d[_e], d[_e + 1], _[_e + 1] / (_[_e] + _[_e + 1]), e),
- s = e,
- $ = _[_e] + _[_e + 1],
- _e += 2;
- continue
- }
- $ += _[_e],
- Quaternion.SlerpToRef(s, d[_e], _[_e] / $, s),
- _e++
- }
- }
- for (var et = 0; et < a.additiveAnimations.length; et++) {
- var j = a.additiveAnimations[et];
- j.weight !== 0 && (s.multiplyToRef(j.currentValue, TmpVectors.Quaternion[0]),
- Quaternion.SlerpToRef(s, TmpVectors.Quaternion[0], j.weight, s))
- }
- return s
- }
- ;
- Scene.prototype._processLateAnimationBindings = function() {
- if (!!this._registeredForLateAnimationBindings.length) {
- for (var a = 0; a < this._registeredForLateAnimationBindings.length; a++) {
- var e = this._registeredForLateAnimationBindings.data[a];
- for (var i in e._lateAnimationHolders) {
- var o = e._lateAnimationHolders[i]
- , s = o.animations[0]
- , c = o.originalValue
- , d = Animation.AllowMatrixDecomposeForInterpolation && c.m
- , _ = e[i];
- if (d)
- _ = this._processLateAnimationBindingsForMatrices(o);
- else {
- var b = c.w !== void 0;
- if (b)
- _ = this._processLateAnimationBindingsForQuaternions(o, _ || Quaternion.Identity());
- else {
- var k = 0
- , j = 1;
- if (o.totalWeight < 1)
- s && c.scale ? _ = c.scale(1 - o.totalWeight) : s ? _ = c * (1 - o.totalWeight) : c.clone ? _ = c.clone() : _ = c;
- else if (s) {
- j = o.totalWeight;
- var $ = s.weight / j;
- $ !== 1 ? s.currentValue.scale ? _ = s.currentValue.scale($) : _ = s.currentValue * $ : _ = s.currentValue,
- k = 1
- }
- for (var _e = k; _e < o.animations.length; _e++) {
- var et = o.animations[_e]
- , tt = et.weight / j;
- if (tt)
- et.currentValue.scaleAndAddToRef ? et.currentValue.scaleAndAddToRef(tt, _) : _ += et.currentValue * tt;
- else
- continue
- }
- for (var rt = 0; rt < o.additiveAnimations.length; rt++) {
- var et = o.additiveAnimations[rt]
- , tt = et.weight;
- if (tt)
- et.currentValue.scaleAndAddToRef ? et.currentValue.scaleAndAddToRef(tt, _) : _ += et.currentValue * tt;
- else
- continue
- }
- }
- }
- e[i] = _
- }
- e._lateAnimationHolders = {}
- }
- this._registeredForLateAnimationBindings.reset()
- }
- }
- ;
- Bone.prototype.copyAnimationRange = function(a, e, i, o, s) {
- o === void 0 && (o = !1),
- s === void 0 && (s = null),
- this.animations.length === 0 && (this.animations.push(new Animation(this.name,"_matrix",a.animations[0].framePerSecond,Animation.ANIMATIONTYPE_MATRIX,0)),
- this.animations[0].setKeys([]));
- var c = a.animations[0].getRange(e);
- if (!c)
- return !1;
- 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++)
- it = b[at],
- it.frame >= d && it.frame <= _ && (o ? (ot = it.value.clone(),
- _e ? (nt = ot.getTranslation(),
- ot.setTranslation(nt.scaleInPlace(et))) : tt && s ? (nt = ot.getTranslation(),
- ot.setTranslation(nt.multiplyInPlace(s))) : ot = it.value) : ot = it.value,
- rt.push({
- frame: it.frame + i,
- value: ot
- }));
- return this.animations[0].createRange(e, d + i, _ + i),
- !0
- }
- ;
- var TargetedAnimation = function() {
- function a() {}
- return a.prototype.getClassName = function() {
- return "TargetedAnimation"
- }
- ,
- a.prototype.serialize = function() {
- var e = {};
- return e.animation = this.animation.serialize(),
- e.targetId = this.target.id,
- e
- }
- ,
- a
- }()
- , AnimationGroup = function() {
- function a(e, i) {
- i === void 0 && (i = null),
- this.name = e,
- this._targetedAnimations = new Array,
- this._animatables = new Array,
- this._from = Number.MAX_VALUE,
- this._to = -Number.MAX_VALUE,
- this._speedRatio = 1,
- this._loopAnimation = !1,
- this._isAdditive = !1,
- this._parentContainer = null,
- this.onAnimationEndObservable = new Observable,
- this.onAnimationLoopObservable = new Observable,
- this.onAnimationGroupLoopObservable = new Observable,
- this.onAnimationGroupEndObservable = new Observable,
- this.onAnimationGroupPauseObservable = new Observable,
- this.onAnimationGroupPlayObservable = new Observable,
- this.metadata = null,
- this._scene = i || EngineStore.LastCreatedScene,
- this.uniqueId = this._scene.getUniqueId(),
- this._scene.addAnimationGroup(this)
- }
- return Object.defineProperty(a.prototype, "from", {
- get: function() {
- return this._from
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "to", {
- get: function() {
- return this._to
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "isStarted", {
- get: function() {
- return this._isStarted
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "isPlaying", {
- get: function() {
- return this._isStarted && !this._isPaused
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "speedRatio", {
- get: function() {
- return this._speedRatio
- },
- set: function(e) {
- if (this._speedRatio !== e) {
- this._speedRatio = e;
- for (var i = 0; i < this._animatables.length; i++) {
- var o = this._animatables[i];
- o.speedRatio = this._speedRatio
- }
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "loopAnimation", {
- get: function() {
- return this._loopAnimation
- },
- set: function(e) {
- if (this._loopAnimation !== e) {
- this._loopAnimation = e;
- for (var i = 0; i < this._animatables.length; i++) {
- var o = this._animatables[i];
- o.loopAnimation = this._loopAnimation
- }
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "isAdditive", {
- get: function() {
- return this._isAdditive
- },
- set: function(e) {
- if (this._isAdditive !== e) {
- this._isAdditive = e;
- for (var i = 0; i < this._animatables.length; i++) {
- var o = this._animatables[i];
- o.isAdditive = this._isAdditive
- }
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "targetedAnimations", {
- get: function() {
- return this._targetedAnimations
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "animatables", {
- get: function() {
- return this._animatables
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "children", {
- get: function() {
- return this._targetedAnimations
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.addTargetedAnimation = function(e, i) {
- var o = new TargetedAnimation;
- o.animation = e,
- o.target = i;
- var s = e.getKeys();
- return this._from > s[0].frame && (this._from = s[0].frame),
- this._to < s[s.length - 1].frame && (this._to = s[s.length - 1].frame),
- this._targetedAnimations.push(o),
- o
- }
- ,
- a.prototype.normalize = function(e, i) {
- e === void 0 && (e = null),
- i === void 0 && (i = null),
- e == null && (e = this._from),
- i == null && (i = this._to);
- for (var o = 0; o < this._targetedAnimations.length; o++) {
- var s = this._targetedAnimations[o]
- , c = s.animation.getKeys()
- , d = c[0]
- , _ = c[c.length - 1];
- if (d.frame > e) {
- var b = {
- frame: e,
- value: d.value,
- inTangent: d.inTangent,
- outTangent: d.outTangent,
- interpolation: d.interpolation
- };
- c.splice(0, 0, b)
- }
- if (_.frame < i) {
- var b = {
- frame: i,
- value: _.value,
- inTangent: _.inTangent,
- outTangent: _.outTangent,
- interpolation: _.interpolation
- };
- c.push(b)
- }
- }
- return this._from = e,
- this._to = i,
- this
- }
- ,
- a.prototype._processLoop = function(e, i, o) {
- var s = this;
- e.onAnimationLoop = function() {
- s.onAnimationLoopObservable.notifyObservers(i),
- !s._animationLoopFlags[o] && (s._animationLoopFlags[o] = !0,
- s._animationLoopCount++,
- s._animationLoopCount === s._targetedAnimations.length && (s.onAnimationGroupLoopObservable.notifyObservers(s),
- s._animationLoopCount = 0,
- s._animationLoopFlags = []))
- }
- }
- ,
- a.prototype.start = function(e, i, o, s, c) {
- var d = this;
- if (e === void 0 && (e = !1),
- i === void 0 && (i = 1),
- this._isStarted || this._targetedAnimations.length === 0)
- return this;
- this._loopAnimation = e,
- this._animationLoopCount = 0,
- this._animationLoopFlags = [];
- for (var _ = function() {
- var j = b._targetedAnimations[k]
- , $ = 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);
- $.onAnimationEnd = function() {
- d.onAnimationEndObservable.notifyObservers(j),
- d._checkAnimationGroupEnded($)
- }
- ,
- b._processLoop($, j, k),
- b._animatables.push($)
- }, b = this, k = 0; k < this._targetedAnimations.length; k++)
- _();
- return this._speedRatio = i,
- this._isStarted = !0,
- this._isPaused = !1,
- this.onAnimationGroupPlayObservable.notifyObservers(this),
- this
- }
- ,
- a.prototype.pause = function() {
- if (!this._isStarted)
- return this;
- this._isPaused = !0;
- for (var e = 0; e < this._animatables.length; e++) {
- var i = this._animatables[e];
- i.pause()
- }
- return this.onAnimationGroupPauseObservable.notifyObservers(this),
- this
- }
- ,
- a.prototype.play = function(e) {
- return this.isStarted && this._animatables.length === this._targetedAnimations.length ? (e !== void 0 && (this.loopAnimation = e),
- this.restart()) : (this.stop(),
- this.start(e, this._speedRatio)),
- this._isPaused = !1,
- this
- }
- ,
- a.prototype.reset = function() {
- if (!this._isStarted)
- return this.play(),
- this.goToFrame(0),
- this.stop(),
- this;
- for (var e = 0; e < this._animatables.length; e++) {
- var i = this._animatables[e];
- i.reset()
- }
- return this
- }
- ,
- a.prototype.restart = function() {
- if (!this._isStarted)
- return this;
- for (var e = 0; e < this._animatables.length; e++) {
- var i = this._animatables[e];
- i.restart()
- }
- return this.onAnimationGroupPlayObservable.notifyObservers(this),
- this
- }
- ,
- a.prototype.stop = function() {
- if (!this._isStarted)
- return this;
- for (var e = this._animatables.slice(), i = 0; i < e.length; i++)
- e[i].stop();
- return this._isStarted = !1,
- this
- }
- ,
- a.prototype.setWeightForAllAnimatables = function(e) {
- for (var i = 0; i < this._animatables.length; i++) {
- var o = this._animatables[i];
- o.weight = e
- }
- return this
- }
- ,
- a.prototype.syncAllAnimationsWith = function(e) {
- for (var i = 0; i < this._animatables.length; i++) {
- var o = this._animatables[i];
- o.syncWith(e)
- }
- return this
- }
- ,
- a.prototype.goToFrame = function(e) {
- if (!this._isStarted)
- return this;
- for (var i = 0; i < this._animatables.length; i++) {
- var o = this._animatables[i];
- o.goToFrame(e)
- }
- return this
- }
- ,
- a.prototype.dispose = function() {
- this._targetedAnimations = [],
- this._animatables = [];
- var e = this._scene.animationGroups.indexOf(this);
- if (e > -1 && this._scene.animationGroups.splice(e, 1),
- this._parentContainer) {
- var i = this._parentContainer.animationGroups.indexOf(this);
- i > -1 && this._parentContainer.animationGroups.splice(i, 1),
- this._parentContainer = null
- }
- this.onAnimationEndObservable.clear(),
- this.onAnimationGroupEndObservable.clear(),
- this.onAnimationGroupPauseObservable.clear(),
- this.onAnimationGroupPlayObservable.clear(),
- this.onAnimationLoopObservable.clear(),
- this.onAnimationGroupLoopObservable.clear()
- }
- ,
- a.prototype._checkAnimationGroupEnded = function(e) {
- var i = this._animatables.indexOf(e);
- i > -1 && this._animatables.splice(i, 1),
- this._animatables.length === 0 && (this._isStarted = !1,
- this.onAnimationGroupEndObservable.notifyObservers(this))
- }
- ,
- a.prototype.clone = function(e, i, o) {
- o === void 0 && (o = !1);
- for (var s = new a(e || this.name,this._scene), c = 0, d = this._targetedAnimations; c < d.length; c++) {
- var _ = d[c];
- s.addTargetedAnimation(o ? _.animation.clone() : _.animation, i ? i(_.target) : _.target)
- }
- return s
- }
- ,
- a.prototype.serialize = function() {
- var e = {};
- e.name = this.name,
- e.from = this.from,
- e.to = this.to,
- e.targetedAnimations = [];
- for (var i = 0; i < this.targetedAnimations.length; i++) {
- var o = this.targetedAnimations[i];
- e.targetedAnimations[i] = o.serialize()
- }
- return Tags && Tags.HasTags(this) && (e.tags = Tags.GetTags(this)),
- this.metadata && (e.metadata = this.metadata),
- e
- }
- ,
- a.Parse = function(e, i) {
- for (var o = new a(e.name,i), s = 0; s < e.targetedAnimations.length; s++) {
- var c = e.targetedAnimations[s]
- , d = Animation.Parse(c.animation)
- , _ = c.targetId;
- if (c.animation.property === "influence") {
- var b = i.getMorphTargetById(_);
- b && o.addTargetedAnimation(d, b)
- } else {
- var k = i.getNodeById(_);
- k != null && o.addTargetedAnimation(d, k)
- }
- }
- return e.from !== null && e.to !== null && o.normalize(e.from, e.to),
- Tags && Tags.AddTagsTo(o, e.tags),
- e.metadata !== void 0 && (o.metadata = e.metadata),
- o
- }
- ,
- a.MakeAnimationAdditive = function(e, i, o, s, c) {
- i === void 0 && (i = 0),
- s === void 0 && (s = !1);
- var d = e;
- s && (d = e.clone(c || d.name));
- for (var _ = d.targetedAnimations, b = 0; b < _.length; b++) {
- var k = _[b];
- Animation.MakeAnimationAdditive(k.animation, i, o)
- }
- return d.isAdditive = !0,
- d
- }
- ,
- a.prototype.getClassName = function() {
- return "AnimationGroup"
- }
- ,
- a.prototype.toString = function(e) {
- var i = "Name: " + this.name;
- return i += ", type: " + this.getClassName(),
- e && (i += ", from: " + this._from,
- i += ", to: " + this._to,
- i += ", isStarted: " + this._isStarted,
- i += ", speedRatio: " + this._speedRatio,
- i += ", targetedAnimations length: " + this._targetedAnimations.length,
- i += ", animatables length: " + this._animatables),
- i
- }
- ,
- a
- }()
- , RawTexture = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _, b, k, j, $) {
- _ === void 0 && (_ = !0),
- b === void 0 && (b = !1),
- k === void 0 && (k = 3),
- j === void 0 && (j = 0);
- 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;
- return _e.format = c,
- _e._engine && (!_e._engine._caps.textureFloatLinearFiltering && j === 1 && (k = 1),
- !_e._engine._caps.textureHalfFloatLinearFiltering && j === 2 && (k = 1),
- _e._texture = _e._engine.createRawTexture(i, o, s, c, _, b, k, null, j, $ != null ? $ : 0),
- _e.wrapU = Texture.CLAMP_ADDRESSMODE,
- _e.wrapV = Texture.CLAMP_ADDRESSMODE),
- _e
- }
- return e.prototype.update = function(i) {
- this._getEngine().updateRawTexture(this._texture, i, this._texture.format, this._texture.invertY, null, this._texture.type)
- }
- ,
- e.CreateLuminanceTexture = function(i, o, s, c, d, _, b) {
- return d === void 0 && (d = !0),
- _ === void 0 && (_ = !1),
- b === void 0 && (b = 3),
- new e(i,o,s,1,c,d,_,b)
- }
- ,
- e.CreateLuminanceAlphaTexture = function(i, o, s, c, d, _, b) {
- return d === void 0 && (d = !0),
- _ === void 0 && (_ = !1),
- b === void 0 && (b = 3),
- new e(i,o,s,2,c,d,_,b)
- }
- ,
- e.CreateAlphaTexture = function(i, o, s, c, d, _, b) {
- return d === void 0 && (d = !0),
- _ === void 0 && (_ = !1),
- b === void 0 && (b = 3),
- new e(i,o,s,0,c,d,_,b)
- }
- ,
- e.CreateRGBTexture = function(i, o, s, c, d, _, b, k) {
- return d === void 0 && (d = !0),
- _ === void 0 && (_ = !1),
- b === void 0 && (b = 3),
- k === void 0 && (k = 0),
- new e(i,o,s,4,c,d,_,b,k)
- }
- ,
- e.CreateRGBATexture = function(i, o, s, c, d, _, b, k) {
- return d === void 0 && (d = !0),
- _ === void 0 && (_ = !1),
- b === void 0 && (b = 3),
- k === void 0 && (k = 0),
- new e(i,o,s,5,c,d,_,b,k)
- }
- ,
- e.CreateRGBAStorageTexture = function(i, o, s, c, d, _, b, k) {
- return d === void 0 && (d = !0),
- _ === void 0 && (_ = !1),
- b === void 0 && (b = 3),
- k === void 0 && (k = 0),
- new e(i,o,s,5,c,d,_,b,k,1)
- }
- ,
- e.CreateRTexture = function(i, o, s, c, d, _, b, k) {
- return d === void 0 && (d = !0),
- _ === void 0 && (_ = !1),
- b === void 0 && (b = Texture.TRILINEAR_SAMPLINGMODE),
- k === void 0 && (k = 1),
- new e(i,o,s,6,c,d,_,b,k)
- }
- ,
- e.CreateRStorageTexture = function(i, o, s, c, d, _, b, k) {
- return d === void 0 && (d = !0),
- _ === void 0 && (_ = !1),
- b === void 0 && (b = Texture.TRILINEAR_SAMPLINGMODE),
- k === void 0 && (k = 1),
- new e(i,o,s,6,c,d,_,b,k,1)
- }
- ,
- e
- }(Texture)
- , Skeleton = function() {
- function a(e, i, o) {
- this.name = e,
- this.id = i,
- this.bones = new Array,
- this.needInitialSkinMatrix = !1,
- this.overrideMesh = null,
- this._isDirty = !0,
- this._meshesWithPoseMatrix = new Array,
- this._identity = Matrix.Identity(),
- this._ranges = {},
- this._lastAbsoluteTransformsUpdateId = -1,
- this._canUseTextureForBones = !1,
- this._uniqueId = 0,
- this._numBonesWithLinkedTransformNode = 0,
- this._hasWaitingData = null,
- this._waitingOverrideMeshId = null,
- this._parentContainer = null,
- this.doNotSerialize = !1,
- this._useTextureToStoreBoneMatrices = !0,
- this._animationPropertiesOverride = null,
- this.onBeforeComputeObservable = new Observable,
- this.bones = [],
- this._scene = o || EngineStore.LastCreatedScene,
- this._uniqueId = this._scene.getUniqueId(),
- this._scene.addSkeleton(this),
- this._isDirty = !0;
- var s = this._scene.getEngine().getCaps();
- this._canUseTextureForBones = s.textureFloat && s.maxVertexTextureImageUnits > 0
- }
- return Object.defineProperty(a.prototype, "useTextureToStoreBoneMatrices", {
- get: function() {
- return this._useTextureToStoreBoneMatrices
- },
- set: function(e) {
- this._useTextureToStoreBoneMatrices = e,
- this._markAsDirty()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "animationPropertiesOverride", {
- get: function() {
- return this._animationPropertiesOverride ? this._animationPropertiesOverride : this._scene.animationPropertiesOverride
- },
- set: function(e) {
- this._animationPropertiesOverride = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "isUsingTextureForMatrices", {
- get: function() {
- return this.useTextureToStoreBoneMatrices && this._canUseTextureForBones
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "uniqueId", {
- get: function() {
- return this._uniqueId
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.getClassName = function() {
- return "Skeleton"
- }
- ,
- a.prototype.getChildren = function() {
- return this.bones.filter(function(e) {
- return !e.getParent()
- })
- }
- ,
- a.prototype.getTransformMatrices = function(e) {
- return this.needInitialSkinMatrix && e._bonesTransformMatrices ? e._bonesTransformMatrices : (this._transformMatrices || this.prepare(),
- this._transformMatrices)
- }
- ,
- a.prototype.getTransformMatrixTexture = function(e) {
- return this.needInitialSkinMatrix && e._transformMatrixTexture ? e._transformMatrixTexture : this._transformMatrixTexture
- }
- ,
- a.prototype.getScene = function() {
- return this._scene
- }
- ,
- a.prototype.toString = function(e) {
- var i = "Name: " + this.name + ", nBones: " + this.bones.length;
- if (i += ", nAnimationRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none"),
- e) {
- i += ", Ranges: {";
- var o = !0;
- for (var s in this._ranges)
- o && (i += ", ",
- o = !1),
- i += s;
- i += "}"
- }
- return i
- }
- ,
- a.prototype.getBoneIndexByName = function(e) {
- for (var i = 0, o = this.bones.length; i < o; i++)
- if (this.bones[i].name === e)
- return i;
- return -1
- }
- ,
- a.prototype.createAnimationRange = function(e, i, o) {
- if (!this._ranges[e]) {
- this._ranges[e] = new AnimationRange(e,i,o);
- for (var s = 0, c = this.bones.length; s < c; s++)
- this.bones[s].animations[0] && this.bones[s].animations[0].createRange(e, i, o)
- }
- }
- ,
- a.prototype.deleteAnimationRange = function(e, i) {
- i === void 0 && (i = !0);
- for (var o = 0, s = this.bones.length; o < s; o++)
- this.bones[o].animations[0] && this.bones[o].animations[0].deleteRange(e, i);
- this._ranges[e] = null
- }
- ,
- a.prototype.getAnimationRange = function(e) {
- return this._ranges[e] || null
- }
- ,
- a.prototype.getAnimationRanges = function() {
- var e = [], i;
- for (i in this._ranges)
- e.push(this._ranges[i]);
- return e
- }
- ,
- a.prototype.copyAnimationRange = function(e, i, o) {
- if (o === void 0 && (o = !1),
- this._ranges[i] || !e.getAnimationRange(i))
- return !1;
- var s = !0, c = this._getHighestAnimationFrame() + 1, d = {}, _ = e.bones, b, k;
- for (k = 0,
- b = _.length; k < b; k++)
- d[_[k].name] = _[k];
- this.bones.length !== _.length && (Logger$2.Warn("copyAnimationRange: this rig has " + this.bones.length + " bones, while source as " + _.length),
- s = !1);
- var j = o && this.dimensionsAtRest && e.dimensionsAtRest ? this.dimensionsAtRest.divide(e.dimensionsAtRest) : null;
- for (k = 0,
- b = this.bones.length; k < b; k++) {
- var $ = this.bones[k].name
- , _e = d[$];
- _e ? s = s && this.bones[k].copyAnimationRange(_e, i, c, o, j) : (Logger$2.Warn("copyAnimationRange: not same rig, missing source bone " + $),
- s = !1)
- }
- var et = e.getAnimationRange(i);
- return et && (this._ranges[i] = new AnimationRange(i,et.from + c,et.to + c)),
- s
- }
- ,
- a.prototype.returnToRest = function() {
- for (var e = 0, i = this.bones; e < i.length; e++) {
- var o = i[e];
- o._index !== -1 && o.returnToRest()
- }
- }
- ,
- a.prototype._getHighestAnimationFrame = function() {
- for (var e = 0, i = 0, o = this.bones.length; i < o; i++)
- if (this.bones[i].animations[0]) {
- var s = this.bones[i].animations[0].getHighestFrame();
- e < s && (e = s)
- }
- return e
- }
- ,
- a.prototype.beginAnimation = function(e, i, o, s) {
- var c = this.getAnimationRange(e);
- return c ? this._scene.beginAnimation(this, c.from, c.to, i, o, s) : null
- }
- ,
- a.MakeAnimationAdditive = function(e, i, o) {
- i === void 0 && (i = 0);
- var s = e.getAnimationRange(o);
- if (!s)
- return null;
- for (var c = e._scene.getAllAnimatablesByTarget(e), d = null, _ = 0; _ < c.length; _++) {
- var b = c[_];
- if (b.fromFrame === (s == null ? void 0 : s.from) && b.toFrame === (s == null ? void 0 : s.to)) {
- d = b;
- break
- }
- }
- for (var k = e.getAnimatables(), _ = 0; _ < k.length; _++) {
- var j = k[_]
- , $ = j.animations;
- if (!!$)
- for (var _e = 0; _e < $.length; _e++)
- Animation.MakeAnimationAdditive($[_e], i, o)
- }
- return d && (d.isAdditive = !0),
- e
- }
- ,
- a.prototype._markAsDirty = function() {
- this._isDirty = !0
- }
- ,
- a.prototype._registerMeshWithPoseMatrix = function(e) {
- this._meshesWithPoseMatrix.push(e)
- }
- ,
- a.prototype._unregisterMeshWithPoseMatrix = function(e) {
- var i = this._meshesWithPoseMatrix.indexOf(e);
- i > -1 && this._meshesWithPoseMatrix.splice(i, 1)
- }
- ,
- a.prototype._computeTransformMatrices = function(e, i) {
- this.onBeforeComputeObservable.notifyObservers(this);
- for (var o = 0; o < this.bones.length; o++) {
- var s = this.bones[o];
- s._childUpdateId++;
- var c = s.getParent();
- if (c ? s.getLocalMatrix().multiplyToRef(c.getWorldMatrix(), s.getWorldMatrix()) : i ? s.getLocalMatrix().multiplyToRef(i, s.getWorldMatrix()) : s.getWorldMatrix().copyFrom(s.getLocalMatrix()),
- s._index !== -1) {
- var d = s._index === null ? o : s._index;
- s.getInvertedAbsoluteTransform().multiplyToArray(s.getWorldMatrix(), e, d * 16)
- }
- }
- this._identity.copyToArray(e, this.bones.length * 16)
- }
- ,
- a.prototype.prepare = function() {
- if (this._numBonesWithLinkedTransformNode > 0)
- for (var e = 0, i = this.bones; e < i.length; e++) {
- var o = i[e];
- o._linkedTransformNode && (o._linkedTransformNode.computeWorldMatrix(),
- o._matrix = o._linkedTransformNode._localMatrix)
- }
- if (!!this._isDirty) {
- if (this.needInitialSkinMatrix)
- for (var s = 0; s < this._meshesWithPoseMatrix.length; s++) {
- var c = this._meshesWithPoseMatrix[s]
- , d = c.getPoseMatrix();
- if ((!c._bonesTransformMatrices || c._bonesTransformMatrices.length !== 16 * (this.bones.length + 1)) && (c._bonesTransformMatrices = new Float32Array(16 * (this.bones.length + 1))),
- this._synchronizedWithMesh !== c) {
- this._synchronizedWithMesh = c;
- for (var _ = 0; _ < this.bones.length; _++) {
- var b = this.bones[_];
- if (!b.getParent()) {
- var k = b.getBaseMatrix();
- k.multiplyToRef(d, TmpVectors.Matrix[1]),
- b._updateDifferenceMatrix(TmpVectors.Matrix[1])
- }
- }
- if (this.isUsingTextureForMatrices) {
- var j = (this.bones.length + 1) * 4;
- (!c._transformMatrixTexture || c._transformMatrixTexture.getSize().width !== j) && (c._transformMatrixTexture && c._transformMatrixTexture.dispose(),
- c._transformMatrixTexture = RawTexture.CreateRGBATexture(c._bonesTransformMatrices, (this.bones.length + 1) * 4, 1, this._scene, !1, !1, 1, 1))
- }
- }
- this._computeTransformMatrices(c._bonesTransformMatrices, d),
- this.isUsingTextureForMatrices && c._transformMatrixTexture && c._transformMatrixTexture.update(c._bonesTransformMatrices)
- }
- else
- (!this._transformMatrices || this._transformMatrices.length !== 16 * (this.bones.length + 1)) && (this._transformMatrices = new Float32Array(16 * (this.bones.length + 1)),
- this.isUsingTextureForMatrices && (this._transformMatrixTexture && this._transformMatrixTexture.dispose(),
- this._transformMatrixTexture = RawTexture.CreateRGBATexture(this._transformMatrices, (this.bones.length + 1) * 4, 1, this._scene, !1, !1, 1, 1))),
- this._computeTransformMatrices(this._transformMatrices, null),
- this.isUsingTextureForMatrices && this._transformMatrixTexture && this._transformMatrixTexture.update(this._transformMatrices);
- this._isDirty = !1,
- this._scene._activeBones.addCount(this.bones.length, !1)
- }
- }
- ,
- a.prototype.getAnimatables = function() {
- if (!this._animatables || this._animatables.length !== this.bones.length) {
- this._animatables = [];
- for (var e = 0; e < this.bones.length; e++)
- this._animatables.push(this.bones[e])
- }
- return this._animatables
- }
- ,
- a.prototype.clone = function(e, i) {
- var o = new a(e,i || e,this._scene);
- o.needInitialSkinMatrix = this.needInitialSkinMatrix,
- o.overrideMesh = this.overrideMesh;
- for (var s = 0; s < this.bones.length; s++) {
- var c = this.bones[s]
- , d = null
- , _ = c.getParent();
- if (_) {
- var b = this.bones.indexOf(_);
- d = o.bones[b]
- }
- var k = new Bone(c.name,o,d,c.getBaseMatrix().clone(),c.getRestPose().clone());
- k._index = c._index,
- c._linkedTransformNode && k.linkTransformNode(c._linkedTransformNode),
- DeepCopier.DeepCopy(c.animations, k.animations)
- }
- if (this._ranges) {
- o._ranges = {};
- for (var j in this._ranges) {
- var $ = this._ranges[j];
- $ && (o._ranges[j] = $.clone())
- }
- }
- return this._isDirty = !0,
- o
- }
- ,
- a.prototype.enableBlending = function(e) {
- e === void 0 && (e = .01),
- this.bones.forEach(function(i) {
- i.animations.forEach(function(o) {
- o.enableBlending = !0,
- o.blendingSpeed = e
- })
- })
- }
- ,
- a.prototype.dispose = function() {
- if (this._meshesWithPoseMatrix = [],
- this.getScene().stopAnimation(this),
- this.getScene().removeSkeleton(this),
- this._parentContainer) {
- var e = this._parentContainer.skeletons.indexOf(this);
- e > -1 && this._parentContainer.skeletons.splice(e, 1),
- this._parentContainer = null
- }
- this._transformMatrixTexture && (this._transformMatrixTexture.dispose(),
- this._transformMatrixTexture = null)
- }
- ,
- a.prototype.serialize = function() {
- var e, i, o = {};
- o.name = this.name,
- o.id = this.id,
- this.dimensionsAtRest && (o.dimensionsAtRest = this.dimensionsAtRest.asArray()),
- o.bones = [],
- o.needInitialSkinMatrix = this.needInitialSkinMatrix,
- o.overrideMeshId = (e = this.overrideMesh) === null || e === void 0 ? void 0 : e.id;
- for (var s = 0; s < this.bones.length; s++) {
- var c = this.bones[s]
- , d = c.getParent()
- , _ = {
- parentBoneIndex: d ? this.bones.indexOf(d) : -1,
- index: c.getIndex(),
- name: c.name,
- id: c.id,
- matrix: c.getBaseMatrix().toArray(),
- rest: c.getRestPose().toArray(),
- linkedTransformNodeId: (i = c.getTransformNode()) === null || i === void 0 ? void 0 : i.id
- };
- o.bones.push(_),
- c.length && (_.length = c.length),
- c.metadata && (_.metadata = c.metadata),
- c.animations && c.animations.length > 0 && (_.animation = c.animations[0].serialize()),
- o.ranges = [];
- for (var b in this._ranges) {
- var k = this._ranges[b];
- if (!!k) {
- var j = {};
- j.name = b,
- j.from = k.from,
- j.to = k.to,
- o.ranges.push(j)
- }
- }
- }
- return o
- }
- ,
- a.Parse = function(e, i) {
- var o = new a(e.name,e.id,i);
- e.dimensionsAtRest && (o.dimensionsAtRest = Vector3.FromArray(e.dimensionsAtRest)),
- o.needInitialSkinMatrix = e.needInitialSkinMatrix,
- e.overrideMeshId && (o._hasWaitingData = !0,
- o._waitingOverrideMeshId = e.overrideMeshId);
- var s;
- for (s = 0; s < e.bones.length; s++) {
- var c = e.bones[s]
- , d = e.bones[s].index
- , _ = null;
- c.parentBoneIndex > -1 && (_ = o.bones[c.parentBoneIndex]);
- var b = c.rest ? Matrix.FromArray(c.rest) : null
- , k = new Bone(c.name,o,_,Matrix.FromArray(c.matrix),b,null,d);
- c.id !== void 0 && c.id !== null && (k.id = c.id),
- c.length && (k.length = c.length),
- c.metadata && (k.metadata = c.metadata),
- c.animation && k.animations.push(Animation.Parse(c.animation)),
- c.linkedTransformNodeId !== void 0 && c.linkedTransformNodeId !== null && (o._hasWaitingData = !0,
- k._waitingTransformNodeId = c.linkedTransformNodeId)
- }
- if (e.ranges)
- for (s = 0; s < e.ranges.length; s++) {
- var j = e.ranges[s];
- o.createAnimationRange(j.name, j.from, j.to)
- }
- return o
- }
- ,
- a.prototype.computeAbsoluteTransforms = function(e) {
- e === void 0 && (e = !1);
- var i = this._scene.getRenderId();
- (this._lastAbsoluteTransformsUpdateId != i || e) && (this.bones[0].computeAbsoluteTransforms(),
- this._lastAbsoluteTransformsUpdateId = i)
- }
- ,
- a.prototype.getPoseMatrix = function() {
- var e = null;
- return this._meshesWithPoseMatrix.length > 0 && (e = this._meshesWithPoseMatrix[0].getPoseMatrix()),
- e
- }
- ,
- a.prototype.sortBones = function() {
- for (var e = new Array, i = new Array(this.bones.length), o = 0; o < this.bones.length; o++)
- this._sortBones(o, e, i);
- this.bones = e
- }
- ,
- a.prototype._sortBones = function(e, i, o) {
- if (!o[e]) {
- o[e] = !0;
- var s = this.bones[e];
- s._index === void 0 && (s._index = e);
- var c = s.getParent();
- c && this._sortBones(this.bones.indexOf(c), i, o),
- i.push(s)
- }
- }
- ,
- a.prototype.setCurrentPoseAsRest = function() {
- this.bones.forEach(function(e) {
- e.setCurrentPoseAsRest()
- })
- }
- ,
- a
- }()
- , IntersectionInfo = function() {
- function a(e, i, o) {
- this.bu = e,
- this.bv = i,
- this.distance = o,
- this.faceId = 0,
- this.subMeshId = 0
- }
- return a
- }()
- , SubMesh = function() {
- function a(e, i, o, s, c, d, _, b, k) {
- b === void 0 && (b = !0),
- k === void 0 && (k = !0),
- this.materialIndex = e,
- this.verticesStart = i,
- this.verticesCount = o,
- this.indexStart = s,
- this.indexCount = c,
- this._mainDrawWrapperOverride = null,
- this._linesIndexCount = 0,
- this._linesIndexBuffer = null,
- this._lastColliderWorldVertices = null,
- this._lastColliderTransformMatrix = null,
- this._renderId = 0,
- this._alphaIndex = 0,
- this._distanceToCamera = 0,
- this._currentMaterial = null,
- this._mesh = d,
- this._renderingMesh = _ || d,
- k && d.subMeshes.push(this),
- this._engine = this._mesh.getScene().getEngine(),
- this.resetDrawCache(),
- this._trianglePlanes = [],
- this._id = d.subMeshes.length - 1,
- b && (this.refreshBoundingInfo(),
- d.computeWorldMatrix(!0))
- }
- return Object.defineProperty(a.prototype, "materialDefines", {
- get: function() {
- var e;
- return this._mainDrawWrapperOverride ? this._mainDrawWrapperOverride.defines : (e = this._getDrawWrapper()) === null || e === void 0 ? void 0 : e.defines
- },
- set: function(e) {
- var i, o = (i = this._mainDrawWrapperOverride) !== null && i !== void 0 ? i : this._getDrawWrapper(void 0, !0);
- o.defines = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._getDrawWrapper = function(e, i) {
- i === void 0 && (i = !1),
- e = e != null ? e : this._engine.currentRenderPassId;
- var o = this._drawWrappers[e];
- return !o && i && (this._drawWrappers[e] = o = new DrawWrapper(this._mesh.getScene().getEngine())),
- o
- }
- ,
- a.prototype._removeDrawWrapper = function(e, i) {
- var o;
- i === void 0 && (i = !0),
- i && ((o = this._drawWrappers[e]) === null || o === void 0 || o.dispose()),
- this._drawWrappers[e] = void 0
- }
- ,
- Object.defineProperty(a.prototype, "effect", {
- get: function() {
- var e, i;
- return this._mainDrawWrapperOverride ? this._mainDrawWrapperOverride.effect : (i = (e = this._getDrawWrapper()) === null || e === void 0 ? void 0 : e.effect) !== null && i !== void 0 ? i : null
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "_drawWrapper", {
- get: function() {
- var e;
- return (e = this._mainDrawWrapperOverride) !== null && e !== void 0 ? e : this._getDrawWrapper(void 0, !0)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "_drawWrapperOverride", {
- get: function() {
- return this._mainDrawWrapperOverride
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._setMainDrawWrapperOverride = function(e) {
- this._mainDrawWrapperOverride = e
- }
- ,
- a.prototype.setEffect = function(e, i, o, s) {
- i === void 0 && (i = null),
- s === void 0 && (s = !0);
- var c = this._drawWrapper;
- c.setEffect(e, i, s),
- o !== void 0 && (c.materialContext = o),
- e || (c.defines = null,
- c.materialContext = void 0)
- }
- ,
- a.prototype.resetDrawCache = function() {
- if (this._drawWrappers)
- for (var e = 0, i = this._drawWrappers; e < i.length; e++) {
- var o = i[e];
- o == null || o.dispose()
- }
- this._drawWrappers = []
- }
- ,
- a.AddToMesh = function(e, i, o, s, c, d, _, b) {
- return b === void 0 && (b = !0),
- new a(e,i,o,s,c,d,_,b)
- }
- ,
- Object.defineProperty(a.prototype, "IsGlobal", {
- get: function() {
- return this.verticesStart === 0 && this.verticesCount === this._mesh.getTotalVertices()
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.getBoundingInfo = function() {
- return this.IsGlobal ? this._mesh.getBoundingInfo() : this._boundingInfo
- }
- ,
- a.prototype.setBoundingInfo = function(e) {
- return this._boundingInfo = e,
- this
- }
- ,
- a.prototype.getMesh = function() {
- return this._mesh
- }
- ,
- a.prototype.getRenderingMesh = function() {
- return this._renderingMesh
- }
- ,
- a.prototype.getReplacementMesh = function() {
- return this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : null
- }
- ,
- a.prototype.getEffectiveMesh = function() {
- var e = this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : null;
- return e || this._renderingMesh
- }
- ,
- a.prototype.getMaterial = function() {
- var e, i = (e = this._renderingMesh.getMaterialForRenderPass(this._engine.currentRenderPassId)) !== null && e !== void 0 ? e : this._renderingMesh.material;
- if (i == null)
- return this._mesh.getScene().defaultMaterial;
- if (this._IsMultiMaterial(i)) {
- var o = i.getSubMaterial(this.materialIndex);
- return this._currentMaterial !== o && (this._currentMaterial = o,
- this.resetDrawCache()),
- o
- }
- return i
- }
- ,
- a.prototype._IsMultiMaterial = function(e) {
- return e.getSubMaterial !== void 0
- }
- ,
- a.prototype.refreshBoundingInfo = function(e) {
- if (e === void 0 && (e = null),
- this._lastColliderWorldVertices = null,
- this.IsGlobal || !this._renderingMesh || !this._renderingMesh.geometry)
- return this;
- if (e || (e = this._renderingMesh.getVerticesData(VertexBuffer.PositionKind)),
- !e)
- return this._boundingInfo = this._mesh.getBoundingInfo(),
- this;
- var i = this._renderingMesh.getIndices(), o;
- if (this.indexStart === 0 && this.indexCount === i.length) {
- var s = this._renderingMesh.getBoundingInfo();
- o = {
- minimum: s.minimum.clone(),
- maximum: s.maximum.clone()
- }
- } else
- o = extractMinAndMaxIndexed(e, i, this.indexStart, this.indexCount, this._renderingMesh.geometry.boundingBias);
- return this._boundingInfo ? this._boundingInfo.reConstruct(o.minimum, o.maximum) : this._boundingInfo = new BoundingInfo(o.minimum,o.maximum),
- this
- }
- ,
- a.prototype._checkCollision = function(e) {
- var i = this.getBoundingInfo();
- return i._checkCollision(e)
- }
- ,
- a.prototype.updateBoundingInfo = function(e) {
- var i = this.getBoundingInfo();
- return i || (this.refreshBoundingInfo(),
- i = this.getBoundingInfo()),
- i && i.update(e),
- this
- }
- ,
- a.prototype.isInFrustum = function(e) {
- var i = this.getBoundingInfo();
- return i ? i.isInFrustum(e, this._mesh.cullingStrategy) : !1
- }
- ,
- a.prototype.isCompletelyInFrustum = function(e) {
- var i = this.getBoundingInfo();
- return i ? i.isCompletelyInFrustum(e) : !1
- }
- ,
- a.prototype.render = function(e) {
- return this._renderingMesh.render(this, e, this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : void 0),
- this
- }
- ,
- a.prototype._getLinesIndexBuffer = function(e, i) {
- if (!this._linesIndexBuffer) {
- for (var o = [], s = this.indexStart; s < this.indexStart + this.indexCount; s += 3)
- o.push(e[s], e[s + 1], e[s + 1], e[s + 2], e[s + 2], e[s]);
- this._linesIndexBuffer = i.createIndexBuffer(o),
- this._linesIndexCount = o.length
- }
- return this._linesIndexBuffer
- }
- ,
- a.prototype.canIntersects = function(e) {
- var i = this.getBoundingInfo();
- return i ? e.intersectsBox(i.boundingBox) : !1
- }
- ,
- a.prototype.intersects = function(e, i, o, s, c) {
- var d = this.getMaterial();
- if (!d)
- return null;
- var _ = 3
- , b = !1;
- switch (d.fillMode) {
- case 3:
- case 4:
- case 5:
- case 6:
- case 8:
- return null;
- case 7:
- _ = 1,
- b = !0;
- break
- }
- 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)
- }
- ,
- a.prototype._intersectLines = function(e, i, o, s, c) {
- for (var d = null, _ = this.indexStart; _ < this.indexStart + this.indexCount; _ += 2) {
- var b = i[o[_]]
- , k = i[o[_ + 1]]
- , j = e.intersectionSegment(b, k, s);
- if (!(j < 0) && (c || !d || j < d.distance) && (d = new IntersectionInfo(null,null,j),
- d.faceId = _ / 2,
- c))
- break
- }
- return d
- }
- ,
- a.prototype._intersectUnIndexedLines = function(e, i, o, s, c) {
- for (var d = null, _ = this.verticesStart; _ < this.verticesStart + this.verticesCount; _ += 2) {
- var b = i[_]
- , k = i[_ + 1]
- , j = e.intersectionSegment(b, k, s);
- if (!(j < 0) && (c || !d || j < d.distance) && (d = new IntersectionInfo(null,null,j),
- d.faceId = _ / 2,
- c))
- break
- }
- return d
- }
- ,
- a.prototype._intersectTriangles = function(e, i, o, s, c, d, _) {
- for (var b = null, k = -1, j = this.indexStart; j < this.indexStart + this.indexCount - (3 - s); j += s) {
- k++;
- var $ = o[j]
- , _e = o[j + 1]
- , et = o[j + 2];
- if (c && et === 4294967295) {
- j += 2;
- continue
- }
- var tt = i[$]
- , rt = i[_e]
- , it = i[et];
- if (!(!tt || !rt || !it) && !(_ && !_(tt, rt, it, e))) {
- var nt = e.intersectsTriangle(tt, rt, it);
- if (nt) {
- if (nt.distance < 0)
- continue;
- if ((d || !b || nt.distance < b.distance) && (b = nt,
- b.faceId = k,
- d))
- break
- }
- }
- }
- return b
- }
- ,
- a.prototype._intersectUnIndexedTriangles = function(e, i, o, s, c) {
- for (var d = null, _ = this.verticesStart; _ < this.verticesStart + this.verticesCount; _ += 3) {
- var b = i[_]
- , k = i[_ + 1]
- , j = i[_ + 2];
- if (!(c && !c(b, k, j, e))) {
- var $ = e.intersectsTriangle(b, k, j);
- if ($) {
- if ($.distance < 0)
- continue;
- if ((s || !d || $.distance < d.distance) && (d = $,
- d.faceId = _ / 3,
- s))
- break
- }
- }
- }
- return d
- }
- ,
- a.prototype._rebuild = function() {
- this._linesIndexBuffer && (this._linesIndexBuffer = null)
- }
- ,
- a.prototype.clone = function(e, i) {
- var o = new a(this.materialIndex,this.verticesStart,this.verticesCount,this.indexStart,this.indexCount,e,i,!1);
- if (!this.IsGlobal) {
- var s = this.getBoundingInfo();
- if (!s)
- return o;
- o._boundingInfo = new BoundingInfo(s.minimum,s.maximum)
- }
- return o
- }
- ,
- a.prototype.dispose = function() {
- this._linesIndexBuffer && (this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer),
- this._linesIndexBuffer = null);
- var e = this._mesh.subMeshes.indexOf(this);
- this._mesh.subMeshes.splice(e, 1),
- this.resetDrawCache()
- }
- ,
- a.prototype.getClassName = function() {
- return "SubMesh"
- }
- ,
- a.CreateFromIndices = function(e, i, o, s, c, d) {
- d === void 0 && (d = !0);
- for (var _ = Number.MAX_VALUE, b = -Number.MAX_VALUE, k = c || s, j = k.getIndices(), $ = i; $ < i + o; $++) {
- var _e = j[$];
- _e < _ && (_ = _e),
- _e > b && (b = _e)
- }
- return new a(e,_,b - _ + 1,i,o,s,c,d)
- }
- ,
- a
- }()
- , Geometry = function() {
- function a(e, i, o, s, c) {
- s === void 0 && (s = !1),
- c === void 0 && (c = null),
- this.delayLoadState = 0,
- this._totalVertices = 0,
- this._isDisposed = !1,
- this._indexBufferIsUpdatable = !1,
- this._positionsCache = [],
- this._parentContainer = null,
- this.useBoundingInfoFromGeometry = !1,
- this.id = e,
- this.uniqueId = i.getUniqueId(),
- this._engine = i.getEngine(),
- this._meshes = [],
- this._scene = i,
- this._vertexBuffers = {},
- this._indices = [],
- this._updatable = s,
- o ? this.setAllVerticesData(o, s) : (this._totalVertices = 0,
- this._indices = []),
- this._engine.getCaps().vertexArrayObject && (this._vertexArrayObjects = {}),
- c && (this.applyToMesh(c),
- c.computeWorldMatrix(!0))
- }
- return Object.defineProperty(a.prototype, "boundingBias", {
- get: function() {
- return this._boundingBias
- },
- set: function(e) {
- this._boundingBias ? this._boundingBias.copyFrom(e) : this._boundingBias = e.clone(),
- this._updateBoundingInfo(!0, null)
- },
- enumerable: !1,
- configurable: !0
- }),
- a.CreateGeometryForMesh = function(e) {
- var i = new a(a.RandomId(),e.getScene());
- return i.applyToMesh(e),
- i
- }
- ,
- Object.defineProperty(a.prototype, "meshes", {
- get: function() {
- return this._meshes
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "extend", {
- get: function() {
- return this._extend
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.getScene = function() {
- return this._scene
- }
- ,
- a.prototype.getEngine = function() {
- return this._engine
- }
- ,
- a.prototype.isReady = function() {
- return this.delayLoadState === 1 || this.delayLoadState === 0
- }
- ,
- Object.defineProperty(a.prototype, "doNotSerialize", {
- get: function() {
- for (var e = 0; e < this._meshes.length; e++)
- if (!this._meshes[e].doNotSerialize)
- return !1;
- return !0
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._rebuild = function() {
- this._vertexArrayObjects && (this._vertexArrayObjects = {}),
- this._meshes.length !== 0 && this._indices && (this._indexBuffer = this._engine.createIndexBuffer(this._indices, this._updatable));
- for (var e in this._vertexBuffers) {
- var i = this._vertexBuffers[e];
- i._rebuild()
- }
- }
- ,
- a.prototype.setAllVerticesData = function(e, i) {
- e.applyToGeometry(this, i),
- this.notifyUpdate()
- }
- ,
- a.prototype.setVerticesData = function(e, i, o, s) {
- o === void 0 && (o = !1),
- o && Array.isArray(i) && (i = new Float32Array(i));
- var c = new VertexBuffer(this._engine,i,e,o,this._meshes.length === 0,s);
- this.setVerticesBuffer(c)
- }
- ,
- a.prototype.removeVerticesData = function(e) {
- this._vertexBuffers[e] && (this._vertexBuffers[e].dispose(),
- delete this._vertexBuffers[e]),
- this._vertexArrayObjects && this._disposeVertexArrayObjects()
- }
- ,
- a.prototype.setVerticesBuffer = function(e, i, o) {
- i === void 0 && (i = null),
- o === void 0 && (o = !0);
- var s = e.getKind();
- this._vertexBuffers[s] && o && this._vertexBuffers[s].dispose(),
- e._buffer && e._buffer._increaseReferences(),
- this._vertexBuffers[s] = e;
- var c = this._meshes
- , d = c.length;
- if (s === VertexBuffer.PositionKind) {
- var _ = e.getData();
- i != null ? this._totalVertices = i : _ != null && (this._totalVertices = _.length / (e.type === VertexBuffer.BYTE ? e.byteStride : e.byteStride / 4)),
- this._updateExtend(_),
- this._resetPointsArrayCache();
- for (var b = 0; b < d; b++) {
- var k = c[b];
- k.buildBoundingInfo(this._extend.minimum, this._extend.maximum),
- k._createGlobalSubMesh(!1),
- k.computeWorldMatrix(!0),
- k.synchronizeInstances()
- }
- }
- this.notifyUpdate(s)
- }
- ,
- a.prototype.updateVerticesDataDirectly = function(e, i, o, s) {
- s === void 0 && (s = !1);
- var c = this.getVertexBuffer(e);
- !c || (c.updateDirectly(i, o, s),
- this.notifyUpdate(e))
- }
- ,
- a.prototype.updateVerticesData = function(e, i, o) {
- o === void 0 && (o = !1);
- var s = this.getVertexBuffer(e);
- !s || (s.update(i),
- e === VertexBuffer.PositionKind && this._updateBoundingInfo(o, i),
- this.notifyUpdate(e))
- }
- ,
- a.prototype._updateBoundingInfo = function(e, i) {
- if (e && this._updateExtend(i),
- this._resetPointsArrayCache(),
- e)
- for (var o = this._meshes, s = 0, c = o; s < c.length; s++) {
- var d = c[s];
- d.hasBoundingInfo ? d.getBoundingInfo().reConstruct(this._extend.minimum, this._extend.maximum) : d.buildBoundingInfo(this._extend.minimum, this._extend.maximum);
- for (var _ = d.subMeshes, b = 0, k = _; b < k.length; b++) {
- var j = k[b];
- j.refreshBoundingInfo()
- }
- }
- }
- ,
- a.prototype._bind = function(e, i, o, s) {
- if (!!e) {
- i === void 0 && (i = this._indexBuffer);
- var c = this.getVertexBuffers();
- if (!!c) {
- if (i != this._indexBuffer || !this._vertexArrayObjects && !s) {
- this._engine.bindBuffers(c, i, e, o);
- return
- }
- var d = s || this._vertexArrayObjects;
- d[e.key] || (d[e.key] = this._engine.recordVertexArrayObject(c, i, e, o)),
- this._engine.bindVertexArrayObject(d[e.key], i)
- }
- }
- }
- ,
- a.prototype.getTotalVertices = function() {
- return this.isReady() ? this._totalVertices : 0
- }
- ,
- a.prototype.getVerticesData = function(e, i, o) {
- var s = this.getVertexBuffer(e);
- return s ? s.getFloatData(this._totalVertices, o || i && this._meshes.length !== 1) : null
- }
- ,
- a.prototype.isVertexBufferUpdatable = function(e) {
- var i = this._vertexBuffers[e];
- return i ? i.isUpdatable() : !1
- }
- ,
- a.prototype.getVertexBuffer = function(e) {
- return this.isReady() ? this._vertexBuffers[e] : null
- }
- ,
- a.prototype.getVertexBuffers = function() {
- return this.isReady() ? this._vertexBuffers : null
- }
- ,
- a.prototype.isVerticesDataPresent = function(e) {
- return this._vertexBuffers ? this._vertexBuffers[e] !== void 0 : this._delayInfo ? this._delayInfo.indexOf(e) !== -1 : !1
- }
- ,
- a.prototype.getVerticesDataKinds = function() {
- var e = [], i;
- if (!this._vertexBuffers && this._delayInfo)
- for (i in this._delayInfo)
- e.push(i);
- else
- for (i in this._vertexBuffers)
- e.push(i);
- return e
- }
- ,
- a.prototype.updateIndices = function(e, i, o) {
- if (o === void 0 && (o = !1),
- !!this._indexBuffer)
- if (!this._indexBufferIsUpdatable)
- this.setIndices(e, null, !0);
- else {
- var s = e.length !== this._indices.length;
- if (o || (this._indices = e.slice()),
- this._engine.updateDynamicIndexBuffer(this._indexBuffer, e, i),
- s)
- for (var c = 0, d = this._meshes; c < d.length; c++) {
- var _ = d[c];
- _._createGlobalSubMesh(!0)
- }
- }
- }
- ,
- a.prototype.setIndices = function(e, i, o) {
- i === void 0 && (i = null),
- o === void 0 && (o = !1),
- this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer),
- this._indices = e,
- this._indexBufferIsUpdatable = o,
- this._meshes.length !== 0 && this._indices && (this._indexBuffer = this._engine.createIndexBuffer(this._indices, o)),
- i != null && (this._totalVertices = i);
- for (var s = 0, c = this._meshes; s < c.length; s++) {
- var d = c[s];
- d._createGlobalSubMesh(!0),
- d.synchronizeInstances()
- }
- this.notifyUpdate()
- }
- ,
- a.prototype.getTotalIndices = function() {
- return this.isReady() ? this._indices.length : 0
- }
- ,
- a.prototype.getIndices = function(e, i) {
- if (!this.isReady())
- return null;
- var o = this._indices;
- return !i && (!e || this._meshes.length === 1) ? o : Tools.Slice(o)
- }
- ,
- a.prototype.getIndexBuffer = function() {
- return this.isReady() ? this._indexBuffer : null
- }
- ,
- a.prototype._releaseVertexArrayObject = function(e) {
- e === void 0 && (e = null),
- !(!e || !this._vertexArrayObjects) && this._vertexArrayObjects[e.key] && (this._engine.releaseVertexArrayObject(this._vertexArrayObjects[e.key]),
- delete this._vertexArrayObjects[e.key])
- }
- ,
- a.prototype.releaseForMesh = function(e, i) {
- var o = this._meshes
- , s = o.indexOf(e);
- s !== -1 && (o.splice(s, 1),
- this._vertexArrayObjects && e._invalidateInstanceVertexArrayObject(),
- e._geometry = null,
- o.length === 0 && i && this.dispose())
- }
- ,
- a.prototype.applyToMesh = function(e) {
- if (e._geometry !== this) {
- var i = e._geometry;
- i && i.releaseForMesh(e),
- this._vertexArrayObjects && e._invalidateInstanceVertexArrayObject();
- var o = this._meshes;
- e._geometry = this,
- e._internalAbstractMeshDataInfo._positions = null,
- this._scene.pushGeometry(this),
- o.push(e),
- this.isReady() ? this._applyToMesh(e) : this._boundingInfo && e.setBoundingInfo(this._boundingInfo)
- }
- }
- ,
- a.prototype._updateExtend = function(e) {
- e === void 0 && (e = null),
- this.useBoundingInfoFromGeometry && this._boundingInfo ? this._extend = {
- minimum: this._boundingInfo.minimum.clone(),
- maximum: this._boundingInfo.maximum.clone()
- } : (e || (e = this.getVerticesData(VertexBuffer.PositionKind)),
- this._extend = extractMinAndMax(e, 0, this._totalVertices, this.boundingBias, 3))
- }
- ,
- a.prototype._applyToMesh = function(e) {
- var i = this._meshes.length;
- for (var o in this._vertexBuffers)
- i === 1 && this._vertexBuffers[o].create(),
- o === VertexBuffer.PositionKind && (this._extend || this._updateExtend(),
- e.buildBoundingInfo(this._extend.minimum, this._extend.maximum),
- e._createGlobalSubMesh(!1),
- e._updateBoundingInfo());
- i === 1 && this._indices && this._indices.length > 0 && (this._indexBuffer = this._engine.createIndexBuffer(this._indices, this._updatable)),
- e._syncGeometryWithMorphTargetManager(),
- e.synchronizeInstances()
- }
- ,
- a.prototype.notifyUpdate = function(e) {
- this.onGeometryUpdated && this.onGeometryUpdated(this, e),
- this._vertexArrayObjects && this._disposeVertexArrayObjects();
- for (var i = 0, o = this._meshes; i < o.length; i++) {
- var s = o[i];
- s._markSubMeshesAsAttributesDirty()
- }
- }
- ,
- a.prototype.load = function(e, i) {
- if (this.delayLoadState !== 2) {
- if (this.isReady()) {
- i && i();
- return
- }
- this.delayLoadState = 2,
- this._queueLoad(e, i)
- }
- }
- ,
- a.prototype._queueLoad = function(e, i) {
- var o = this;
- !this.delayLoadingFile || (e._addPendingData(this),
- e._loadFile(this.delayLoadingFile, function(s) {
- if (!!o._delayLoadingFunction) {
- o._delayLoadingFunction(JSON.parse(s), o),
- o.delayLoadState = 1,
- o._delayInfo = [],
- e._removePendingData(o);
- for (var c = o._meshes, d = c.length, _ = 0; _ < d; _++)
- o._applyToMesh(c[_]);
- i && i()
- }
- }, void 0, !0))
- }
- ,
- a.prototype.toLeftHanded = function() {
- var e = this.getIndices(!1);
- if (e != null && e.length > 0) {
- for (var i = 0; i < e.length; i += 3) {
- var o = e[i + 0];
- e[i + 0] = e[i + 2],
- e[i + 2] = o
- }
- this.setIndices(e)
- }
- var s = this.getVerticesData(VertexBuffer.PositionKind, !1);
- if (s != null && s.length > 0) {
- for (var i = 0; i < s.length; i += 3)
- s[i + 2] = -s[i + 2];
- this.setVerticesData(VertexBuffer.PositionKind, s, !1)
- }
- var c = this.getVerticesData(VertexBuffer.NormalKind, !1);
- if (c != null && c.length > 0) {
- for (var i = 0; i < c.length; i += 3)
- c[i + 2] = -c[i + 2];
- this.setVerticesData(VertexBuffer.NormalKind, c, !1)
- }
- }
- ,
- a.prototype._resetPointsArrayCache = function() {
- this._positions = null
- }
- ,
- a.prototype._generatePointsArray = function() {
- if (this._positions)
- return !0;
- var e = this.getVerticesData(VertexBuffer.PositionKind);
- if (!e || e.length === 0)
- return !1;
- for (var i = this._positionsCache.length * 3, o = this._positionsCache.length; i < e.length; i += 3,
- ++o)
- this._positionsCache[o] = Vector3.FromArray(e, i);
- for (var i = 0, o = 0; i < e.length; i += 3,
- ++o)
- this._positionsCache[o].set(e[0 + i], e[1 + i], e[2 + i]);
- return this._positionsCache.length = e.length / 3,
- this._positions = this._positionsCache,
- !0
- }
- ,
- a.prototype.isDisposed = function() {
- return this._isDisposed
- }
- ,
- a.prototype._disposeVertexArrayObjects = function() {
- if (this._vertexArrayObjects) {
- for (var e in this._vertexArrayObjects)
- this._engine.releaseVertexArrayObject(this._vertexArrayObjects[e]);
- this._vertexArrayObjects = {};
- for (var i = this._meshes, o = i.length, s = 0; s < o; s++)
- i[s]._invalidateInstanceVertexArrayObject()
- }
- }
- ,
- a.prototype.dispose = function() {
- var e = this._meshes, i = e.length, o;
- for (o = 0; o < i; o++)
- this.releaseForMesh(e[o]);
- this._meshes = [],
- this._disposeVertexArrayObjects();
- for (var s in this._vertexBuffers)
- this._vertexBuffers[s].dispose();
- if (this._vertexBuffers = {},
- this._totalVertices = 0,
- this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer),
- this._indexBuffer = null,
- this._indices = [],
- this.delayLoadState = 0,
- this.delayLoadingFile = null,
- this._delayLoadingFunction = null,
- this._delayInfo = [],
- this._boundingInfo = null,
- this._scene.removeGeometry(this),
- this._parentContainer) {
- var c = this._parentContainer.geometries.indexOf(this);
- c > -1 && this._parentContainer.geometries.splice(c, 1),
- this._parentContainer = null
- }
- this._isDisposed = !0
- }
- ,
- a.prototype.copy = function(e) {
- var i = new VertexData;
- i.indices = [];
- var o = this.getIndices();
- if (o)
- for (var s = 0; s < o.length; s++)
- i.indices.push(o[s]);
- var c = !1, d = !1, _;
- for (_ in this._vertexBuffers) {
- var b = this.getVerticesData(_);
- if (b && (b instanceof Float32Array ? i.set(new Float32Array(b), _) : i.set(b.slice(0), _),
- !d)) {
- var k = this.getVertexBuffer(_);
- k && (c = k.isUpdatable(),
- d = !c)
- }
- }
- var j = new a(e,this._scene,i,c);
- j.delayLoadState = this.delayLoadState,
- j.delayLoadingFile = this.delayLoadingFile,
- j._delayLoadingFunction = this._delayLoadingFunction;
- for (_ in this._delayInfo)
- j._delayInfo = j._delayInfo || [],
- j._delayInfo.push(_);
- return j._boundingInfo = new BoundingInfo(this._extend.minimum,this._extend.maximum),
- j
- }
- ,
- a.prototype.serialize = function() {
- var e = {};
- return e.id = this.id,
- e.uniqueId = this.uniqueId,
- e.updatable = this._updatable,
- Tags && Tags.HasTags(this) && (e.tags = Tags.GetTags(this)),
- e
- }
- ,
- a.prototype.toNumberArray = function(e) {
- return Array.isArray(e) ? e : Array.prototype.slice.call(e)
- }
- ,
- a.prototype.clearCachedData = function() {
- this._indices = [],
- this._resetPointsArrayCache();
- for (var e in this._vertexBuffers)
- !this._vertexBuffers.hasOwnProperty(e) || (this._vertexBuffers[e]._buffer._data = null)
- }
- ,
- a.prototype.serializeVerticeData = function() {
- var e = this.serialize();
- return this.isVerticesDataPresent(VertexBuffer.PositionKind) && (e.positions = this.toNumberArray(this.getVerticesData(VertexBuffer.PositionKind)),
- this.isVertexBufferUpdatable(VertexBuffer.PositionKind) && (e.positions._updatable = !0)),
- this.isVerticesDataPresent(VertexBuffer.NormalKind) && (e.normals = this.toNumberArray(this.getVerticesData(VertexBuffer.NormalKind)),
- this.isVertexBufferUpdatable(VertexBuffer.NormalKind) && (e.normals._updatable = !0)),
- this.isVerticesDataPresent(VertexBuffer.TangentKind) && (e.tangents = this.toNumberArray(this.getVerticesData(VertexBuffer.TangentKind)),
- this.isVertexBufferUpdatable(VertexBuffer.TangentKind) && (e.tangents._updatable = !0)),
- this.isVerticesDataPresent(VertexBuffer.UVKind) && (e.uvs = this.toNumberArray(this.getVerticesData(VertexBuffer.UVKind)),
- this.isVertexBufferUpdatable(VertexBuffer.UVKind) && (e.uvs._updatable = !0)),
- this.isVerticesDataPresent(VertexBuffer.UV2Kind) && (e.uv2s = this.toNumberArray(this.getVerticesData(VertexBuffer.UV2Kind)),
- this.isVertexBufferUpdatable(VertexBuffer.UV2Kind) && (e.uv2s._updatable = !0)),
- this.isVerticesDataPresent(VertexBuffer.UV3Kind) && (e.uv3s = this.toNumberArray(this.getVerticesData(VertexBuffer.UV3Kind)),
- this.isVertexBufferUpdatable(VertexBuffer.UV3Kind) && (e.uv3s._updatable = !0)),
- this.isVerticesDataPresent(VertexBuffer.UV4Kind) && (e.uv4s = this.toNumberArray(this.getVerticesData(VertexBuffer.UV4Kind)),
- this.isVertexBufferUpdatable(VertexBuffer.UV4Kind) && (e.uv4s._updatable = !0)),
- this.isVerticesDataPresent(VertexBuffer.UV5Kind) && (e.uv5s = this.toNumberArray(this.getVerticesData(VertexBuffer.UV5Kind)),
- this.isVertexBufferUpdatable(VertexBuffer.UV5Kind) && (e.uv5s._updatable = !0)),
- this.isVerticesDataPresent(VertexBuffer.UV6Kind) && (e.uv6s = this.toNumberArray(this.getVerticesData(VertexBuffer.UV6Kind)),
- this.isVertexBufferUpdatable(VertexBuffer.UV6Kind) && (e.uv6s._updatable = !0)),
- this.isVerticesDataPresent(VertexBuffer.ColorKind) && (e.colors = this.toNumberArray(this.getVerticesData(VertexBuffer.ColorKind)),
- this.isVertexBufferUpdatable(VertexBuffer.ColorKind) && (e.colors._updatable = !0)),
- this.isVerticesDataPresent(VertexBuffer.MatricesIndicesKind) && (e.matricesIndices = this.toNumberArray(this.getVerticesData(VertexBuffer.MatricesIndicesKind)),
- e.matricesIndices._isExpanded = !0,
- this.isVertexBufferUpdatable(VertexBuffer.MatricesIndicesKind) && (e.matricesIndices._updatable = !0)),
- this.isVerticesDataPresent(VertexBuffer.MatricesWeightsKind) && (e.matricesWeights = this.toNumberArray(this.getVerticesData(VertexBuffer.MatricesWeightsKind)),
- this.isVertexBufferUpdatable(VertexBuffer.MatricesWeightsKind) && (e.matricesWeights._updatable = !0)),
- e.indices = this.toNumberArray(this.getIndices()),
- e
- }
- ,
- a.ExtractFromMesh = function(e, i) {
- var o = e._geometry;
- return o ? o.copy(i) : null
- }
- ,
- a.RandomId = function() {
- return Tools.RandomId()
- }
- ,
- a._GetGeometryByLoadedUniqueId = function(e, i) {
- for (var o = 0; o < i.geometries.length; o++)
- if (i.geometries[o]._loadedUniqueId === e)
- return i.geometries[o];
- return null
- }
- ,
- a._ImportGeometry = function(e, i) {
- var o = i.getScene()
- , s = e.geometryUniqueId
- , c = e.geometryId;
- if (s || c) {
- var d = s ? this._GetGeometryByLoadedUniqueId(s, o) : o.getGeometryById(c);
- d && d.applyToMesh(i)
- } else if (e instanceof ArrayBuffer) {
- var _ = i._binaryInfo;
- if (_.positionsAttrDesc && _.positionsAttrDesc.count > 0) {
- var b = new Float32Array(e,_.positionsAttrDesc.offset,_.positionsAttrDesc.count);
- i.setVerticesData(VertexBuffer.PositionKind, b, !1)
- }
- if (_.normalsAttrDesc && _.normalsAttrDesc.count > 0) {
- var k = new Float32Array(e,_.normalsAttrDesc.offset,_.normalsAttrDesc.count);
- i.setVerticesData(VertexBuffer.NormalKind, k, !1)
- }
- if (_.tangetsAttrDesc && _.tangetsAttrDesc.count > 0) {
- var j = new Float32Array(e,_.tangetsAttrDesc.offset,_.tangetsAttrDesc.count);
- i.setVerticesData(VertexBuffer.TangentKind, j, !1)
- }
- if (_.uvsAttrDesc && _.uvsAttrDesc.count > 0) {
- var $ = new Float32Array(e,_.uvsAttrDesc.offset,_.uvsAttrDesc.count);
- i.setVerticesData(VertexBuffer.UVKind, $, !1)
- }
- if (_.uvs2AttrDesc && _.uvs2AttrDesc.count > 0) {
- var _e = new Float32Array(e,_.uvs2AttrDesc.offset,_.uvs2AttrDesc.count);
- i.setVerticesData(VertexBuffer.UV2Kind, _e, !1)
- }
- if (_.uvs3AttrDesc && _.uvs3AttrDesc.count > 0) {
- var et = new Float32Array(e,_.uvs3AttrDesc.offset,_.uvs3AttrDesc.count);
- i.setVerticesData(VertexBuffer.UV3Kind, et, !1)
- }
- if (_.uvs4AttrDesc && _.uvs4AttrDesc.count > 0) {
- var tt = new Float32Array(e,_.uvs4AttrDesc.offset,_.uvs4AttrDesc.count);
- i.setVerticesData(VertexBuffer.UV4Kind, tt, !1)
- }
- if (_.uvs5AttrDesc && _.uvs5AttrDesc.count > 0) {
- var rt = new Float32Array(e,_.uvs5AttrDesc.offset,_.uvs5AttrDesc.count);
- i.setVerticesData(VertexBuffer.UV5Kind, rt, !1)
- }
- if (_.uvs6AttrDesc && _.uvs6AttrDesc.count > 0) {
- var it = new Float32Array(e,_.uvs6AttrDesc.offset,_.uvs6AttrDesc.count);
- i.setVerticesData(VertexBuffer.UV6Kind, it, !1)
- }
- if (_.colorsAttrDesc && _.colorsAttrDesc.count > 0) {
- var nt = new Float32Array(e,_.colorsAttrDesc.offset,_.colorsAttrDesc.count);
- i.setVerticesData(VertexBuffer.ColorKind, nt, !1, _.colorsAttrDesc.stride)
- }
- if (_.matricesIndicesAttrDesc && _.matricesIndicesAttrDesc.count > 0) {
- for (var ot = new Int32Array(e,_.matricesIndicesAttrDesc.offset,_.matricesIndicesAttrDesc.count), at = [], st = 0; st < ot.length; st++) {
- var ut = ot[st];
- at.push(ut & 255),
- at.push((ut & 65280) >> 8),
- at.push((ut & 16711680) >> 16),
- at.push(ut >> 24 & 255)
- }
- i.setVerticesData(VertexBuffer.MatricesIndicesKind, at, !1)
- }
- if (_.matricesIndicesExtraAttrDesc && _.matricesIndicesExtraAttrDesc.count > 0) {
- for (var ot = new Int32Array(e,_.matricesIndicesExtraAttrDesc.offset,_.matricesIndicesExtraAttrDesc.count), at = [], st = 0; st < ot.length; st++) {
- var ut = ot[st];
- at.push(ut & 255),
- at.push((ut & 65280) >> 8),
- at.push((ut & 16711680) >> 16),
- at.push(ut >> 24 & 255)
- }
- i.setVerticesData(VertexBuffer.MatricesIndicesExtraKind, at, !1)
- }
- if (_.matricesWeightsAttrDesc && _.matricesWeightsAttrDesc.count > 0) {
- var ct = new Float32Array(e,_.matricesWeightsAttrDesc.offset,_.matricesWeightsAttrDesc.count);
- i.setVerticesData(VertexBuffer.MatricesWeightsKind, ct, !1)
- }
- if (_.indicesAttrDesc && _.indicesAttrDesc.count > 0) {
- var lt = new Int32Array(e,_.indicesAttrDesc.offset,_.indicesAttrDesc.count);
- i.setIndices(lt, null)
- }
- if (_.subMeshesAttrDesc && _.subMeshesAttrDesc.count > 0) {
- var ft = new Int32Array(e,_.subMeshesAttrDesc.offset,_.subMeshesAttrDesc.count * 5);
- i.subMeshes = [];
- for (var st = 0; st < _.subMeshesAttrDesc.count; st++) {
- var ht = ft[st * 5 + 0]
- , pt = ft[st * 5 + 1]
- , dt = ft[st * 5 + 2]
- , _t = ft[st * 5 + 3]
- , mt = ft[st * 5 + 4];
- SubMesh.AddToMesh(ht, pt, dt, _t, mt, i)
- }
- }
- } else if (e.positions && e.normals && e.indices) {
- if (i.setVerticesData(VertexBuffer.PositionKind, e.positions, e.positions._updatable),
- i.setVerticesData(VertexBuffer.NormalKind, e.normals, e.normals._updatable),
- e.tangents && i.setVerticesData(VertexBuffer.TangentKind, e.tangents, e.tangents._updatable),
- e.uvs && i.setVerticesData(VertexBuffer.UVKind, e.uvs, e.uvs._updatable),
- e.uvs2 && i.setVerticesData(VertexBuffer.UV2Kind, e.uvs2, e.uvs2._updatable),
- e.uvs3 && i.setVerticesData(VertexBuffer.UV3Kind, e.uvs3, e.uvs3._updatable),
- e.uvs4 && i.setVerticesData(VertexBuffer.UV4Kind, e.uvs4, e.uvs4._updatable),
- e.uvs5 && i.setVerticesData(VertexBuffer.UV5Kind, e.uvs5, e.uvs5._updatable),
- e.uvs6 && i.setVerticesData(VertexBuffer.UV6Kind, e.uvs6, e.uvs6._updatable),
- e.colors && i.setVerticesData(VertexBuffer.ColorKind, Color4.CheckColors4(e.colors, e.positions.length / 3), e.colors._updatable),
- e.matricesIndices)
- if (e.matricesIndices._isExpanded)
- delete e.matricesIndices._isExpanded,
- i.setVerticesData(VertexBuffer.MatricesIndicesKind, e.matricesIndices, e.matricesIndices._updatable);
- else {
- for (var at = [], st = 0; st < e.matricesIndices.length; st++) {
- var vt = e.matricesIndices[st];
- at.push(vt & 255),
- at.push((vt & 65280) >> 8),
- at.push((vt & 16711680) >> 16),
- at.push(vt >> 24 & 255)
- }
- i.setVerticesData(VertexBuffer.MatricesIndicesKind, at, e.matricesIndices._updatable)
- }
- if (e.matricesIndicesExtra)
- if (e.matricesIndicesExtra._isExpanded)
- delete e.matricesIndices._isExpanded,
- i.setVerticesData(VertexBuffer.MatricesIndicesExtraKind, e.matricesIndicesExtra, e.matricesIndicesExtra._updatable);
- else {
- for (var at = [], st = 0; st < e.matricesIndicesExtra.length; st++) {
- var vt = e.matricesIndicesExtra[st];
- at.push(vt & 255),
- at.push((vt & 65280) >> 8),
- at.push((vt & 16711680) >> 16),
- at.push(vt >> 24 & 255)
- }
- i.setVerticesData(VertexBuffer.MatricesIndicesExtraKind, at, e.matricesIndicesExtra._updatable)
- }
- e.matricesWeights && (a._CleanMatricesWeights(e, i),
- i.setVerticesData(VertexBuffer.MatricesWeightsKind, e.matricesWeights, e.matricesWeights._updatable)),
- e.matricesWeightsExtra && i.setVerticesData(VertexBuffer.MatricesWeightsExtraKind, e.matricesWeightsExtra, e.matricesWeights._updatable),
- i.setIndices(e.indices, null)
- }
- if (e.subMeshes) {
- i.subMeshes = [];
- for (var yt = 0; yt < e.subMeshes.length; yt++) {
- var Et = e.subMeshes[yt];
- SubMesh.AddToMesh(Et.materialIndex, Et.verticesStart, Et.verticesCount, Et.indexStart, Et.indexCount, i)
- }
- }
- i._shouldGenerateFlatShading && (i.convertToFlatShadedMesh(),
- i._shouldGenerateFlatShading = !1),
- i.computeWorldMatrix(!0),
- o.onMeshImportedObservable.notifyObservers(i)
- }
- ,
- a._CleanMatricesWeights = function(e, i) {
- var o = .001;
- if (!!SceneLoaderFlags.CleanBoneMatrixWeights) {
- var s = 0;
- if (e.skeletonId > -1) {
- var c = i.getScene().getLastSkeletonById(e.skeletonId);
- if (!c)
- return;
- s = c.bones.length
- } else
- return;
- 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) {
- for (var et = 0, tt = -1, rt = 0; rt < 4; rt++) {
- var it = b[_e + rt];
- et += it,
- it < o && tt < 0 && (tt = rt)
- }
- if (k)
- for (var rt = 0; rt < 4; rt++) {
- var it = k[_e + rt];
- et += it,
- it < o && tt < 0 && (tt = rt + 4)
- }
- if ((tt < 0 || tt > j - 1) && (tt = j - 1),
- et > o) {
- for (var nt = 1 / et, rt = 0; rt < 4; rt++)
- b[_e + rt] *= nt;
- if (k)
- for (var rt = 0; rt < 4; rt++)
- k[_e + rt] *= nt
- } else
- tt >= 4 ? (k[_e + tt - 4] = 1 - et,
- _[_e + tt - 4] = s) : (b[_e + tt] = 1 - et,
- d[_e + tt] = s)
- }
- i.setVerticesData(VertexBuffer.MatricesIndicesKind, d),
- e.matricesWeightsExtra && i.setVerticesData(VertexBuffer.MatricesIndicesExtraKind, _)
- }
- }
- ,
- a.Parse = function(e, i, o) {
- var s = new a(e.id,i,void 0,e.updatable);
- return s._loadedUniqueId = e.uniqueId,
- Tags && Tags.AddTagsTo(s, e.tags),
- e.delayLoadingFile ? (s.delayLoadState = 4,
- s.delayLoadingFile = o + e.delayLoadingFile,
- s._boundingInfo = new BoundingInfo(Vector3.FromArray(e.boundingBoxMinimum),Vector3.FromArray(e.boundingBoxMaximum)),
- s._delayInfo = [],
- e.hasUVs && s._delayInfo.push(VertexBuffer.UVKind),
- e.hasUVs2 && s._delayInfo.push(VertexBuffer.UV2Kind),
- e.hasUVs3 && s._delayInfo.push(VertexBuffer.UV3Kind),
- e.hasUVs4 && s._delayInfo.push(VertexBuffer.UV4Kind),
- e.hasUVs5 && s._delayInfo.push(VertexBuffer.UV5Kind),
- e.hasUVs6 && s._delayInfo.push(VertexBuffer.UV6Kind),
- e.hasColors && s._delayInfo.push(VertexBuffer.ColorKind),
- e.hasMatricesIndices && s._delayInfo.push(VertexBuffer.MatricesIndicesKind),
- e.hasMatricesWeights && s._delayInfo.push(VertexBuffer.MatricesWeightsKind),
- s._delayLoadingFunction = VertexData.ImportVertexData) : VertexData.ImportVertexData(e, s),
- i.pushGeometry(s, !0),
- s
- }
- ,
- a
- }()
- , Light = function(a) {
- __extends(e, a);
- function e(i, o) {
- var s = a.call(this, i, o) || this;
- return s.diffuse = new Color3(1,1,1),
- s.specular = new Color3(1,1,1),
- s.falloffType = e.FALLOFF_DEFAULT,
- s.intensity = 1,
- s._range = Number.MAX_VALUE,
- s._inverseSquaredRange = 0,
- s._photometricScale = 1,
- s._intensityMode = e.INTENSITYMODE_AUTOMATIC,
- s._radius = 1e-5,
- s.renderPriority = 0,
- s._shadowEnabled = !0,
- s._excludeWithLayerMask = 0,
- s._includeOnlyWithLayerMask = 0,
- s._lightmapMode = 0,
- s._excludedMeshesIds = new Array,
- s._includedOnlyMeshesIds = new Array,
- s._isLight = !0,
- s.getScene().addLight(s),
- s._uniformBuffer = new UniformBuffer(s.getScene().getEngine(),void 0,void 0,i),
- s._buildUniformLayout(),
- s.includedOnlyMeshes = new Array,
- s.excludedMeshes = new Array,
- s._resyncMeshes(),
- s
- }
- return Object.defineProperty(e.prototype, "range", {
- get: function() {
- return this._range
- },
- set: function(i) {
- this._range = i,
- this._inverseSquaredRange = 1 / (this.range * this.range)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "intensityMode", {
- get: function() {
- return this._intensityMode
- },
- set: function(i) {
- this._intensityMode = i,
- this._computePhotometricScale()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "radius", {
- get: function() {
- return this._radius
- },
- set: function(i) {
- this._radius = i,
- this._computePhotometricScale()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "shadowEnabled", {
- get: function() {
- return this._shadowEnabled
- },
- set: function(i) {
- this._shadowEnabled !== i && (this._shadowEnabled = i,
- this._markMeshesAsLightDirty())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "includedOnlyMeshes", {
- get: function() {
- return this._includedOnlyMeshes
- },
- set: function(i) {
- this._includedOnlyMeshes = i,
- this._hookArrayForIncludedOnly(i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "excludedMeshes", {
- get: function() {
- return this._excludedMeshes
- },
- set: function(i) {
- this._excludedMeshes = i,
- this._hookArrayForExcluded(i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "excludeWithLayerMask", {
- get: function() {
- return this._excludeWithLayerMask
- },
- set: function(i) {
- this._excludeWithLayerMask = i,
- this._resyncMeshes()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "includeOnlyWithLayerMask", {
- get: function() {
- return this._includeOnlyWithLayerMask
- },
- set: function(i) {
- this._includeOnlyWithLayerMask = i,
- this._resyncMeshes()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "lightmapMode", {
- get: function() {
- return this._lightmapMode
- },
- set: function(i) {
- this._lightmapMode !== i && (this._lightmapMode = i,
- this._markMeshesAsLightDirty())
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.transferTexturesToEffect = function(i, o) {
- return this
- }
- ,
- e.prototype._bindLight = function(i, o, s, c, d) {
- d === void 0 && (d = !0);
- var _ = i.toString()
- , b = !1;
- if (this._uniformBuffer.bindToEffect(s, "Light" + _),
- this._renderId !== o.getRenderId() || !this._uniformBuffer.useUbo) {
- this._renderId = o.getRenderId();
- var k = this.getScaledIntensity();
- this.transferToEffect(s, _),
- this.diffuse.scaleToRef(k, TmpColors.Color3[0]),
- this._uniformBuffer.updateColor4("vLightDiffuse", TmpColors.Color3[0], this.range, _),
- c && (this.specular.scaleToRef(k, TmpColors.Color3[1]),
- this._uniformBuffer.updateColor4("vLightSpecular", TmpColors.Color3[1], this.radius, _)),
- b = !0
- }
- if (this.transferTexturesToEffect(s, _),
- o.shadowsEnabled && this.shadowEnabled && d) {
- var j = this.getShadowGenerator();
- j && (j.bindShadowLight(_, s),
- b = !0)
- }
- b ? this._uniformBuffer.update() : this._uniformBuffer.bindUniformBuffer()
- }
- ,
- e.prototype.getClassName = function() {
- return "Light"
- }
- ,
- e.prototype.toString = function(i) {
- var o = "Name: " + this.name;
- if (o += ", type: " + ["Point", "Directional", "Spot", "Hemispheric"][this.getTypeID()],
- this.animations)
- for (var s = 0; s < this.animations.length; s++)
- o += ", animation[0]: " + this.animations[s].toString(i);
- return o
- }
- ,
- e.prototype._syncParentEnabledState = function() {
- a.prototype._syncParentEnabledState.call(this),
- this.isDisposed() || this._resyncMeshes()
- }
- ,
- e.prototype.setEnabled = function(i) {
- a.prototype.setEnabled.call(this, i),
- this._resyncMeshes()
- }
- ,
- e.prototype.getShadowGenerator = function() {
- return this._shadowGenerator
- }
- ,
- e.prototype.getAbsolutePosition = function() {
- return Vector3.Zero()
- }
- ,
- e.prototype.canAffectMesh = function(i) {
- 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
- }
- ,
- e.prototype.dispose = function(i, o) {
- if (o === void 0 && (o = !1),
- this._shadowGenerator && (this._shadowGenerator.dispose(),
- this._shadowGenerator = null),
- this.getScene().stopAnimation(this),
- this._parentContainer) {
- var s = this._parentContainer.lights.indexOf(this);
- s > -1 && this._parentContainer.lights.splice(s, 1),
- this._parentContainer = null
- }
- for (var c = 0, d = this.getScene().meshes; c < d.length; c++) {
- var _ = d[c];
- _._removeLightSource(this, !0)
- }
- this._uniformBuffer.dispose(),
- this.getScene().removeLight(this),
- a.prototype.dispose.call(this, i, o)
- }
- ,
- e.prototype.getTypeID = function() {
- return 0
- }
- ,
- e.prototype.getScaledIntensity = function() {
- return this._photometricScale * this.intensity
- }
- ,
- e.prototype.clone = function(i, o) {
- o === void 0 && (o = null);
- var s = e.GetConstructorFromName(this.getTypeID(), i, this.getScene());
- if (!s)
- return null;
- var c = SerializationHelper.Clone(s, this);
- return i && (c.name = i),
- o && (c.parent = o),
- c.setEnabled(this.isEnabled()),
- this.onClonedObservable.notifyObservers(c),
- c
- }
- ,
- e.prototype.serialize = function() {
- var i = SerializationHelper.Serialize(this);
- return i.uniqueId = this.uniqueId,
- i.type = this.getTypeID(),
- this.parent && (i.parentId = this.parent.uniqueId),
- this.excludedMeshes.length > 0 && (i.excludedMeshesIds = [],
- this.excludedMeshes.forEach(function(o) {
- i.excludedMeshesIds.push(o.id)
- })),
- this.includedOnlyMeshes.length > 0 && (i.includedOnlyMeshesIds = [],
- this.includedOnlyMeshes.forEach(function(o) {
- i.includedOnlyMeshesIds.push(o.id)
- })),
- SerializationHelper.AppendSerializedAnimations(this, i),
- i.ranges = this.serializeAnimationRanges(),
- i.isEnabled = this.isEnabled(),
- i
- }
- ,
- e.GetConstructorFromName = function(i, o, s) {
- var c = Node$2.Construct("Light_Type_" + i, o, s);
- return c || null
- }
- ,
- e.Parse = function(i, o) {
- var s = e.GetConstructorFromName(i.type, i.name, o);
- if (!s)
- return null;
- var c = SerializationHelper.Parse(s, i, o);
- if (i.excludedMeshesIds && (c._excludedMeshesIds = i.excludedMeshesIds),
- i.includedOnlyMeshesIds && (c._includedOnlyMeshesIds = i.includedOnlyMeshesIds),
- i.parentId && (c._waitingParentId = i.parentId),
- i.falloffType !== void 0 && (c.falloffType = i.falloffType),
- i.lightmapMode !== void 0 && (c.lightmapMode = i.lightmapMode),
- i.animations) {
- for (var d = 0; d < i.animations.length; d++) {
- var _ = i.animations[d]
- , b = GetClass("BABYLON.Animation");
- b && c.animations.push(b.Parse(_))
- }
- Node$2.ParseAnimationRanges(c, i, o)
- }
- return i.autoAnimate && o.beginAnimation(c, i.autoAnimateFrom, i.autoAnimateTo, i.autoAnimateLoop, i.autoAnimateSpeed || 1),
- i.isEnabled !== void 0 && c.setEnabled(i.isEnabled),
- c
- }
- ,
- e.prototype._hookArrayForExcluded = function(i) {
- var o = this
- , s = i.push;
- i.push = function() {
- for (var k = [], j = 0; j < arguments.length; j++)
- k[j] = arguments[j];
- for (var $ = s.apply(i, k), _e = 0, et = k; _e < et.length; _e++) {
- var tt = et[_e];
- tt._resyncLightSource(o)
- }
- return $
- }
- ;
- var c = i.splice;
- i.splice = function(k, j) {
- for (var $ = c.apply(i, [k, j]), _e = 0, et = $; _e < et.length; _e++) {
- var tt = et[_e];
- tt._resyncLightSource(o)
- }
- return $
- }
- ;
- for (var d = 0, _ = i; d < _.length; d++) {
- var b = _[d];
- b._resyncLightSource(this)
- }
- }
- ,
- e.prototype._hookArrayForIncludedOnly = function(i) {
- var o = this
- , s = i.push;
- i.push = function() {
- for (var d = [], _ = 0; _ < arguments.length; _++)
- d[_] = arguments[_];
- var b = s.apply(i, d);
- return o._resyncMeshes(),
- b
- }
- ;
- var c = i.splice;
- i.splice = function(d, _) {
- var b = c.apply(i, [d, _]);
- return o._resyncMeshes(),
- b
- }
- ,
- this._resyncMeshes()
- }
- ,
- e.prototype._resyncMeshes = function() {
- for (var i = 0, o = this.getScene().meshes; i < o.length; i++) {
- var s = o[i];
- s._resyncLightSource(this)
- }
- }
- ,
- e.prototype._markMeshesAsLightDirty = function() {
- for (var i = 0, o = this.getScene().meshes; i < o.length; i++) {
- var s = o[i];
- s.lightSources.indexOf(this) !== -1 && s._markSubMeshesAsLightDirty()
- }
- }
- ,
- e.prototype._computePhotometricScale = function() {
- this._photometricScale = this._getPhotometricScale(),
- this.getScene().resetCachedMaterial()
- }
- ,
- e.prototype._getPhotometricScale = function() {
- var i = 0
- , o = this.getTypeID()
- , s = this.intensityMode;
- switch (s === e.INTENSITYMODE_AUTOMATIC && (o === e.LIGHTTYPEID_DIRECTIONALLIGHT ? s = e.INTENSITYMODE_ILLUMINANCE : s = e.INTENSITYMODE_LUMINOUSINTENSITY),
- o) {
- case e.LIGHTTYPEID_POINTLIGHT:
- case e.LIGHTTYPEID_SPOTLIGHT:
- switch (s) {
- case e.INTENSITYMODE_LUMINOUSPOWER:
- i = 1 / (4 * Math.PI);
- break;
- case e.INTENSITYMODE_LUMINOUSINTENSITY:
- i = 1;
- break;
- case e.INTENSITYMODE_LUMINANCE:
- i = this.radius * this.radius;
- break
- }
- break;
- case e.LIGHTTYPEID_DIRECTIONALLIGHT:
- switch (s) {
- case e.INTENSITYMODE_ILLUMINANCE:
- i = 1;
- break;
- case e.INTENSITYMODE_LUMINANCE:
- var c = this.radius;
- c = Math.max(c, .001);
- var d = 2 * Math.PI * (1 - Math.cos(c));
- i = d;
- break
- }
- break;
- case e.LIGHTTYPEID_HEMISPHERICLIGHT:
- i = 1;
- break
- }
- return i
- }
- ,
- e.prototype._reorderLightsInScene = function() {
- var i = this.getScene();
- this._renderPriority != 0 && (i.requireLightSorting = !0),
- this.getScene().sortLightsByPriority()
- }
- ,
- e.FALLOFF_DEFAULT = LightConstants.FALLOFF_DEFAULT,
- e.FALLOFF_PHYSICAL = LightConstants.FALLOFF_PHYSICAL,
- e.FALLOFF_GLTF = LightConstants.FALLOFF_GLTF,
- e.FALLOFF_STANDARD = LightConstants.FALLOFF_STANDARD,
- e.LIGHTMAP_DEFAULT = LightConstants.LIGHTMAP_DEFAULT,
- e.LIGHTMAP_SPECULAR = LightConstants.LIGHTMAP_SPECULAR,
- e.LIGHTMAP_SHADOWSONLY = LightConstants.LIGHTMAP_SHADOWSONLY,
- e.INTENSITYMODE_AUTOMATIC = LightConstants.INTENSITYMODE_AUTOMATIC,
- e.INTENSITYMODE_LUMINOUSPOWER = LightConstants.INTENSITYMODE_LUMINOUSPOWER,
- e.INTENSITYMODE_LUMINOUSINTENSITY = LightConstants.INTENSITYMODE_LUMINOUSINTENSITY,
- e.INTENSITYMODE_ILLUMINANCE = LightConstants.INTENSITYMODE_ILLUMINANCE,
- e.INTENSITYMODE_LUMINANCE = LightConstants.INTENSITYMODE_LUMINANCE,
- e.LIGHTTYPEID_POINTLIGHT = LightConstants.LIGHTTYPEID_POINTLIGHT,
- e.LIGHTTYPEID_DIRECTIONALLIGHT = LightConstants.LIGHTTYPEID_DIRECTIONALLIGHT,
- e.LIGHTTYPEID_SPOTLIGHT = LightConstants.LIGHTTYPEID_SPOTLIGHT,
- e.LIGHTTYPEID_HEMISPHERICLIGHT = LightConstants.LIGHTTYPEID_HEMISPHERICLIGHT,
- __decorate([serializeAsColor3()], e.prototype, "diffuse", void 0),
- __decorate([serializeAsColor3()], e.prototype, "specular", void 0),
- __decorate([serialize()], e.prototype, "falloffType", void 0),
- __decorate([serialize()], e.prototype, "intensity", void 0),
- __decorate([serialize()], e.prototype, "range", null),
- __decorate([serialize()], e.prototype, "intensityMode", null),
- __decorate([serialize()], e.prototype, "radius", null),
- __decorate([serialize()], e.prototype, "_renderPriority", void 0),
- __decorate([expandToProperty("_reorderLightsInScene")], e.prototype, "renderPriority", void 0),
- __decorate([serialize("shadowEnabled")], e.prototype, "_shadowEnabled", void 0),
- __decorate([serialize("excludeWithLayerMask")], e.prototype, "_excludeWithLayerMask", void 0),
- __decorate([serialize("includeOnlyWithLayerMask")], e.prototype, "_includeOnlyWithLayerMask", void 0),
- __decorate([serialize("lightmapMode")], e.prototype, "_lightmapMode", void 0),
- e
- }(Node$2)
- , ThinMaterialHelper = function() {
- function a() {}
- return a.BindClipPlane = function(e, i) {
- if (i.clipPlane) {
- var o = i.clipPlane;
- e.setFloat4("vClipPlane", o.normal.x, o.normal.y, o.normal.z, o.d)
- }
- if (i.clipPlane2) {
- var o = i.clipPlane2;
- e.setFloat4("vClipPlane2", o.normal.x, o.normal.y, o.normal.z, o.d)
- }
- if (i.clipPlane3) {
- var o = i.clipPlane3;
- e.setFloat4("vClipPlane3", o.normal.x, o.normal.y, o.normal.z, o.d)
- }
- if (i.clipPlane4) {
- var o = i.clipPlane4;
- e.setFloat4("vClipPlane4", o.normal.x, o.normal.y, o.normal.z, o.d)
- }
- if (i.clipPlane5) {
- var o = i.clipPlane5;
- e.setFloat4("vClipPlane5", o.normal.x, o.normal.y, o.normal.z, o.d)
- }
- if (i.clipPlane6) {
- var o = i.clipPlane6;
- e.setFloat4("vClipPlane6", o.normal.x, o.normal.y, o.normal.z, o.d)
- }
- }
- ,
- a
- }()
- , MaterialHelper = function() {
- function a() {}
- return a.BindSceneUniformBuffer = function(e, i) {
- i.bindToEffect(e, "Scene")
- }
- ,
- a.PrepareDefinesForMergedUV = function(e, i, o) {
- i._needUVs = !0,
- i[o] = !0,
- e.getTextureMatrix().isIdentityAs3x2() ? (i[o + "DIRECTUV"] = e.coordinatesIndex + 1,
- i["MAINUV" + (e.coordinatesIndex + 1)] = !0) : i[o + "DIRECTUV"] = 0
- }
- ,
- a.BindTextureMatrix = function(e, i, o) {
- var s = e.getTextureMatrix();
- i.updateMatrix(o + "Matrix", s)
- }
- ,
- a.GetFogState = function(e, i) {
- return i.fogEnabled && e.applyFog && i.fogMode !== Scene.FOGMODE_NONE
- }
- ,
- a.PrepareDefinesForMisc = function(e, i, o, s, c, d, _) {
- _._areMiscDirty && (_.LOGARITHMICDEPTH = o,
- _.POINTSIZE = s,
- _.FOG = c && this.GetFogState(e, i),
- _.NONUNIFORMSCALING = e.nonUniformScaling,
- _.ALPHATEST = d)
- }
- ,
- a.PrepareDefinesForFrameBoundValues = function(e, i, o, s, c, d) {
- c === void 0 && (c = null),
- d === void 0 && (d = !1);
- var _ = !1
- , b = !1
- , k = !1
- , j = !1
- , $ = !1
- , _e = !1
- , et = !1;
- b = c == null ? e.clipPlane !== void 0 && e.clipPlane !== null : c,
- k = c == null ? e.clipPlane2 !== void 0 && e.clipPlane2 !== null : c,
- j = c == null ? e.clipPlane3 !== void 0 && e.clipPlane3 !== null : c,
- $ = c == null ? e.clipPlane4 !== void 0 && e.clipPlane4 !== null : c,
- _e = c == null ? e.clipPlane5 !== void 0 && e.clipPlane5 !== null : c,
- et = c == null ? e.clipPlane6 !== void 0 && e.clipPlane6 !== null : c,
- o.CLIPPLANE !== b && (o.CLIPPLANE = b,
- _ = !0),
- o.CLIPPLANE2 !== k && (o.CLIPPLANE2 = k,
- _ = !0),
- o.CLIPPLANE3 !== j && (o.CLIPPLANE3 = j,
- _ = !0),
- o.CLIPPLANE4 !== $ && (o.CLIPPLANE4 = $,
- _ = !0),
- o.CLIPPLANE5 !== _e && (o.CLIPPLANE5 = _e,
- _ = !0),
- o.CLIPPLANE6 !== et && (o.CLIPPLANE6 = et,
- _ = !0),
- o.DEPTHPREPASS !== !i.getColorWrite() && (o.DEPTHPREPASS = !o.DEPTHPREPASS,
- _ = !0),
- o.INSTANCES !== s && (o.INSTANCES = s,
- _ = !0),
- o.THIN_INSTANCES !== d && (o.THIN_INSTANCES = d,
- _ = !0),
- _ && o.markAsUnprocessed()
- }
- ,
- a.PrepareDefinesForBones = function(e, i) {
- if (e.useBones && e.computeBonesUsingShaders && e.skeleton) {
- i.NUM_BONE_INFLUENCERS = e.numBoneInfluencers;
- var o = i.BONETEXTURE !== void 0;
- if (e.skeleton.isUsingTextureForMatrices && o)
- i.BONETEXTURE = !0;
- else {
- i.BonesPerMesh = e.skeleton.bones.length + 1,
- i.BONETEXTURE = o ? !1 : void 0;
- var s = e.getScene().prePassRenderer;
- if (s && s.enabled) {
- var c = s.excludedSkinnedMesh.indexOf(e) === -1;
- i.BONES_VELOCITY_ENABLED = c
- }
- }
- } else
- i.NUM_BONE_INFLUENCERS = 0,
- i.BonesPerMesh = 0
- }
- ,
- a.PrepareDefinesForMorphTargets = function(e, i) {
- var o = e.morphTargetManager;
- o ? (i.MORPHTARGETS_UV = o.supportsUVs && i.UV1,
- i.MORPHTARGETS_TANGENT = o.supportsTangents && i.TANGENT,
- i.MORPHTARGETS_NORMAL = o.supportsNormals && i.NORMAL,
- i.MORPHTARGETS = o.numInfluencers > 0,
- i.NUM_MORPH_INFLUENCERS = o.numInfluencers,
- i.MORPHTARGETS_TEXTURE = o.isUsingTextureForTargets) : (i.MORPHTARGETS_UV = !1,
- i.MORPHTARGETS_TANGENT = !1,
- i.MORPHTARGETS_NORMAL = !1,
- i.MORPHTARGETS = !1,
- i.NUM_MORPH_INFLUENCERS = 0)
- }
- ,
- a.PrepareDefinesForBakedVertexAnimation = function(e, i) {
- var o = e.bakedVertexAnimationManager;
- i.BAKED_VERTEX_ANIMATION_TEXTURE = !!(o && o.isEnabled)
- }
- ,
- a.PrepareDefinesForAttributes = function(e, i, o, s, c, d, _) {
- if (c === void 0 && (c = !1),
- d === void 0 && (d = !0),
- _ === void 0 && (_ = !0),
- !i._areAttributesDirty && i._needNormals === i._normals && i._needUVs === i._uvs)
- return !1;
- i._normals = i._needNormals,
- i._uvs = i._needUVs,
- i.NORMAL = i._needNormals && e.isVerticesDataPresent(VertexBuffer.NormalKind),
- i._needNormals && e.isVerticesDataPresent(VertexBuffer.TangentKind) && (i.TANGENT = !0);
- for (var b = 1; b <= 6; ++b)
- i["UV" + b] = i._needUVs ? e.isVerticesDataPresent("uv" + (b === 1 ? "" : b)) : !1;
- if (o) {
- var k = e.useVertexColors && e.isVerticesDataPresent(VertexBuffer.ColorKind);
- i.VERTEXCOLOR = k,
- i.VERTEXALPHA = e.hasVertexAlpha && k && d
- }
- return s && this.PrepareDefinesForBones(e, i),
- c && this.PrepareDefinesForMorphTargets(e, i),
- _ && this.PrepareDefinesForBakedVertexAnimation(e, i),
- !0
- }
- ,
- a.PrepareDefinesForMultiview = function(e, i) {
- if (e.activeCamera) {
- var o = i.MULTIVIEW;
- i.MULTIVIEW = e.activeCamera.outputRenderTarget !== null && e.activeCamera.outputRenderTarget.getViewCount() > 1,
- i.MULTIVIEW != o && i.markAsUnprocessed()
- }
- }
- ,
- a.PrepareDefinesForOIT = function(e, i, o) {
- var s = i.ORDER_INDEPENDENT_TRANSPARENCY
- , c = i.ORDER_INDEPENDENT_TRANSPARENCY_16BITS;
- i.ORDER_INDEPENDENT_TRANSPARENCY = e.useOrderIndependentTransparency && o,
- i.ORDER_INDEPENDENT_TRANSPARENCY_16BITS = !e.getEngine().getCaps().textureFloatLinearFiltering,
- (s !== i.ORDER_INDEPENDENT_TRANSPARENCY || c !== i.ORDER_INDEPENDENT_TRANSPARENCY_16BITS) && i.markAsUnprocessed()
- }
- ,
- a.PrepareDefinesForPrePass = function(e, i, o) {
- var s = i.PREPASS;
- if (!!i._arePrePassDirty) {
- var c = [{
- type: 1,
- define: "PREPASS_POSITION",
- index: "PREPASS_POSITION_INDEX"
- }, {
- type: 2,
- define: "PREPASS_VELOCITY",
- index: "PREPASS_VELOCITY_INDEX"
- }, {
- type: 3,
- define: "PREPASS_REFLECTIVITY",
- index: "PREPASS_REFLECTIVITY_INDEX"
- }, {
- type: 0,
- define: "PREPASS_IRRADIANCE",
- index: "PREPASS_IRRADIANCE_INDEX"
- }, {
- type: 7,
- define: "PREPASS_ALBEDO_SQRT",
- index: "PREPASS_ALBEDO_SQRT_INDEX"
- }, {
- type: 5,
- define: "PREPASS_DEPTH",
- index: "PREPASS_DEPTH_INDEX"
- }, {
- type: 6,
- define: "PREPASS_NORMAL",
- index: "PREPASS_NORMAL_INDEX"
- }];
- if (e.prePassRenderer && e.prePassRenderer.enabled && o) {
- i.PREPASS = !0,
- i.SCENE_MRT_COUNT = e.prePassRenderer.mrtCount;
- for (var d = 0; d < c.length; d++) {
- var _ = e.prePassRenderer.getIndex(c[d].type);
- _ !== -1 ? (i[c[d].define] = !0,
- i[c[d].index] = _) : i[c[d].define] = !1
- }
- } else {
- i.PREPASS = !1;
- for (var d = 0; d < c.length; d++)
- i[c[d].define] = !1
- }
- i.PREPASS != s && (i.markAsUnprocessed(),
- i.markAsImageProcessingDirty())
- }
- }
- ,
- a.PrepareDefinesForLight = function(e, i, o, s, c, d, _) {
- switch (_.needNormals = !0,
- c["LIGHT" + s] === void 0 && (_.needRebuild = !0),
- c["LIGHT" + s] = !0,
- c["SPOTLIGHT" + s] = !1,
- c["HEMILIGHT" + s] = !1,
- c["POINTLIGHT" + s] = !1,
- c["DIRLIGHT" + s] = !1,
- o.prepareLightSpecificDefines(c, s),
- c["LIGHT_FALLOFF_PHYSICAL" + s] = !1,
- c["LIGHT_FALLOFF_GLTF" + s] = !1,
- c["LIGHT_FALLOFF_STANDARD" + s] = !1,
- o.falloffType) {
- case Light.FALLOFF_GLTF:
- c["LIGHT_FALLOFF_GLTF" + s] = !0;
- break;
- case Light.FALLOFF_PHYSICAL:
- c["LIGHT_FALLOFF_PHYSICAL" + s] = !0;
- break;
- case Light.FALLOFF_STANDARD:
- c["LIGHT_FALLOFF_STANDARD" + s] = !0;
- break
- }
- if (d && !o.specular.equalsFloats(0, 0, 0) && (_.specularEnabled = !0),
- c["SHADOW" + s] = !1,
- c["SHADOWCSM" + s] = !1,
- c["SHADOWCSMDEBUG" + s] = !1,
- c["SHADOWCSMNUM_CASCADES" + s] = !1,
- c["SHADOWCSMUSESHADOWMAXZ" + s] = !1,
- c["SHADOWCSMNOBLEND" + s] = !1,
- c["SHADOWCSM_RIGHTHANDED" + s] = !1,
- c["SHADOWPCF" + s] = !1,
- c["SHADOWPCSS" + s] = !1,
- c["SHADOWPOISSON" + s] = !1,
- c["SHADOWESM" + s] = !1,
- c["SHADOWCLOSEESM" + s] = !1,
- c["SHADOWCUBE" + s] = !1,
- c["SHADOWLOWQUALITY" + s] = !1,
- c["SHADOWMEDIUMQUALITY" + s] = !1,
- i && i.receiveShadows && e.shadowsEnabled && o.shadowEnabled) {
- var b = o.getShadowGenerator();
- if (b) {
- var k = b.getShadowMap();
- k && k.renderList && k.renderList.length > 0 && (_.shadowEnabled = !0,
- b.prepareDefines(c, s))
- }
- }
- o.lightmapMode != Light.LIGHTMAP_DEFAULT ? (_.lightmapMode = !0,
- c["LIGHTMAPEXCLUDED" + s] = !0,
- c["LIGHTMAPNOSPECULAR" + s] = o.lightmapMode == Light.LIGHTMAP_SHADOWSONLY) : (c["LIGHTMAPEXCLUDED" + s] = !1,
- c["LIGHTMAPNOSPECULAR" + s] = !1)
- }
- ,
- a.PrepareDefinesForLights = function(e, i, o, s, c, d) {
- if (c === void 0 && (c = 4),
- d === void 0 && (d = !1),
- !o._areLightsDirty)
- return o._needNormals;
- var _ = 0
- , b = {
- needNormals: !1,
- needRebuild: !1,
- lightmapMode: !1,
- shadowEnabled: !1,
- specularEnabled: !1
- };
- if (e.lightsEnabled && !d)
- for (var k = 0, j = i.lightSources; k < j.length; k++) {
- var $ = j[k];
- if (this.PrepareDefinesForLight(e, i, $, _, o, s, b),
- _++,
- _ === c)
- break
- }
- o.SPECULARTERM = b.specularEnabled,
- o.SHADOWS = b.shadowEnabled;
- for (var _e = _; _e < c; _e++)
- o["LIGHT" + _e] !== void 0 && (o["LIGHT" + _e] = !1,
- o["HEMILIGHT" + _e] = !1,
- o["POINTLIGHT" + _e] = !1,
- o["DIRLIGHT" + _e] = !1,
- o["SPOTLIGHT" + _e] = !1,
- o["SHADOW" + _e] = !1,
- o["SHADOWCSM" + _e] = !1,
- o["SHADOWCSMDEBUG" + _e] = !1,
- o["SHADOWCSMNUM_CASCADES" + _e] = !1,
- o["SHADOWCSMUSESHADOWMAXZ" + _e] = !1,
- o["SHADOWCSMNOBLEND" + _e] = !1,
- o["SHADOWCSM_RIGHTHANDED" + _e] = !1,
- o["SHADOWPCF" + _e] = !1,
- o["SHADOWPCSS" + _e] = !1,
- o["SHADOWPOISSON" + _e] = !1,
- o["SHADOWESM" + _e] = !1,
- o["SHADOWCLOSEESM" + _e] = !1,
- o["SHADOWCUBE" + _e] = !1,
- o["SHADOWLOWQUALITY" + _e] = !1,
- o["SHADOWMEDIUMQUALITY" + _e] = !1);
- var et = e.getEngine().getCaps();
- return o.SHADOWFLOAT === void 0 && (b.needRebuild = !0),
- o.SHADOWFLOAT = b.shadowEnabled && (et.textureFloatRender && et.textureFloatLinearFiltering || et.textureHalfFloatRender && et.textureHalfFloatLinearFiltering),
- o.LIGHTMAPEXCLUDED = b.lightmapMode,
- b.needRebuild && o.rebuild(),
- b.needNormals
- }
- ,
- a.PrepareUniformsAndSamplersForLight = function(e, i, o, s, c, d) {
- c === void 0 && (c = null),
- d === void 0 && (d = !1),
- c && c.push("Light" + e),
- !d && (i.push("vLightData" + e, "vLightDiffuse" + e, "vLightSpecular" + e, "vLightDirection" + e, "vLightFalloff" + e, "vLightGround" + e, "lightMatrix" + e, "shadowsInfo" + e, "depthValues" + e),
- o.push("shadowSampler" + e),
- o.push("depthSampler" + e),
- i.push("viewFrustumZ" + e, "cascadeBlendFactor" + e, "lightSizeUVCorrection" + e, "depthCorrection" + e, "penumbraDarkness" + e, "frustumLengths" + e),
- s && (o.push("projectionLightSampler" + e),
- i.push("textureProjectionMatrix" + e)))
- }
- ,
- a.PrepareUniformsAndSamplersList = function(e, i, o, s) {
- s === void 0 && (s = 4);
- var c, d = null;
- if (e.uniformsNames) {
- var _ = e;
- c = _.uniformsNames,
- d = _.uniformBuffersNames,
- i = _.samplers,
- o = _.defines,
- s = _.maxSimultaneousLights || 0
- } else
- c = e,
- i || (i = []);
- for (var b = 0; b < s && o["LIGHT" + b]; b++)
- this.PrepareUniformsAndSamplersForLight(b, c, i, o["PROJECTEDLIGHTTEXTURE" + b], d);
- o.NUM_MORPH_INFLUENCERS && c.push("morphTargetInfluences"),
- o.BAKED_VERTEX_ANIMATION_TEXTURE && (c.push("bakedVertexAnimationSettings"),
- c.push("bakedVertexAnimationTextureSizeInverted"),
- c.push("bakedVertexAnimationTime"),
- i.push("bakedVertexAnimationTexture"))
- }
- ,
- a.HandleFallbacksForShadows = function(e, i, o, s) {
- o === void 0 && (o = 4),
- s === void 0 && (s = 0);
- for (var c = 0, d = 0; d < o && e["LIGHT" + d]; d++)
- d > 0 && (c = s + d,
- i.addFallback(c, "LIGHT" + d)),
- e.SHADOWS || (e["SHADOW" + d] && i.addFallback(s, "SHADOW" + d),
- e["SHADOWPCF" + d] && i.addFallback(s, "SHADOWPCF" + d),
- e["SHADOWPCSS" + d] && i.addFallback(s, "SHADOWPCSS" + d),
- e["SHADOWPOISSON" + d] && i.addFallback(s, "SHADOWPOISSON" + d),
- e["SHADOWESM" + d] && i.addFallback(s, "SHADOWESM" + d),
- e["SHADOWCLOSEESM" + d] && i.addFallback(s, "SHADOWCLOSEESM" + d));
- return c++
- }
- ,
- a.PrepareAttributesForMorphTargetsInfluencers = function(e, i, o) {
- this._TmpMorphInfluencers.NUM_MORPH_INFLUENCERS = o,
- this.PrepareAttributesForMorphTargets(e, i, this._TmpMorphInfluencers)
- }
- ,
- a.PrepareAttributesForMorphTargets = function(e, i, o) {
- var s = o.NUM_MORPH_INFLUENCERS;
- if (s > 0 && EngineStore.LastCreatedEngine) {
- var c = EngineStore.LastCreatedEngine.getCaps().maxVertexAttribs
- , d = i.morphTargetManager;
- if (d != null && d.isUsingTextureForTargets)
- return;
- for (var _ = d && d.supportsNormals && o.NORMAL, b = d && d.supportsTangents && o.TANGENT, k = d && d.supportsUVs && o.UV1, j = 0; j < s; j++)
- e.push(VertexBuffer.PositionKind + j),
- _ && e.push(VertexBuffer.NormalKind + j),
- b && e.push(VertexBuffer.TangentKind + j),
- k && e.push(VertexBuffer.UVKind + "_" + j),
- e.length > c && Logger$2.Error("Cannot add more vertex attributes for mesh " + i.name)
- }
- }
- ,
- a.PrepareAttributesForBakedVertexAnimation = function(e, i, o) {
- var s = o.BAKED_VERTEX_ANIMATION_TEXTURE && o.INSTANCES;
- s && (e.push("bakedVertexAnimationSettingsInstanced"),
- e.push("bakedVertexAnimationTimeInstanced"))
- }
- ,
- a.PrepareAttributesForBones = function(e, i, o, s) {
- o.NUM_BONE_INFLUENCERS > 0 && (s.addCPUSkinningFallback(0, i),
- e.push(VertexBuffer.MatricesIndicesKind),
- e.push(VertexBuffer.MatricesWeightsKind),
- o.NUM_BONE_INFLUENCERS > 4 && (e.push(VertexBuffer.MatricesIndicesExtraKind),
- e.push(VertexBuffer.MatricesWeightsExtraKind)))
- }
- ,
- a.PrepareAttributesForInstances = function(e, i) {
- (i.INSTANCES || i.THIN_INSTANCES) && this.PushAttributesForInstances(e, !!i.PREPASS_VELOCITY)
- }
- ,
- a.PushAttributesForInstances = function(e, i) {
- i === void 0 && (i = !1),
- e.push("world0"),
- e.push("world1"),
- e.push("world2"),
- e.push("world3"),
- i && (e.push("previousWorld0"),
- e.push("previousWorld1"),
- e.push("previousWorld2"),
- e.push("previousWorld3"))
- }
- ,
- a.BindLightProperties = function(e, i, o) {
- e.transferToEffect(i, o + "")
- }
- ,
- a.BindLight = function(e, i, o, s, c, d) {
- d === void 0 && (d = !0),
- e._bindLight(i, o, s, c, d)
- }
- ,
- a.BindLights = function(e, i, o, s, c) {
- c === void 0 && (c = 4);
- for (var d = Math.min(i.lightSources.length, c), _ = 0; _ < d; _++) {
- var b = i.lightSources[_];
- this.BindLight(b, _, e, o, typeof s == "boolean" ? s : s.SPECULARTERM, i.receiveShadows)
- }
- }
- ,
- a.BindFogParameters = function(e, i, o, s) {
- s === void 0 && (s = !1),
- e.fogEnabled && i.applyFog && e.fogMode !== Scene.FOGMODE_NONE && (o.setFloat4("vFogInfos", e.fogMode, e.fogStart, e.fogEnd, e.fogDensity),
- s ? (e.fogColor.toLinearSpaceToRef(this._tempFogColor),
- o.setColor3("vFogColor", this._tempFogColor)) : o.setColor3("vFogColor", e.fogColor))
- }
- ,
- a.BindBonesParameters = function(e, i, o) {
- if (!(!i || !e) && (e.computeBonesUsingShaders && i._bonesComputationForcedToCPU && (e.computeBonesUsingShaders = !1),
- e.useBones && e.computeBonesUsingShaders && e.skeleton)) {
- var s = e.skeleton;
- if (s.isUsingTextureForMatrices && i.getUniformIndex("boneTextureWidth") > -1) {
- var c = s.getTransformMatrixTexture(e);
- i.setTexture("boneSampler", c),
- i.setFloat("boneTextureWidth", 4 * (s.bones.length + 1))
- } else {
- var d = s.getTransformMatrices(e);
- d && (i.setMatrices("mBones", d),
- o && e.getScene().prePassRenderer && e.getScene().prePassRenderer.getIndex(2) && (o.previousBones[e.uniqueId] || (o.previousBones[e.uniqueId] = d.slice()),
- i.setMatrices("mPreviousBones", o.previousBones[e.uniqueId]),
- a._CopyBonesTransformationMatrices(d, o.previousBones[e.uniqueId])))
- }
- }
- }
- ,
- a._CopyBonesTransformationMatrices = function(e, i) {
- return i.set(e),
- i
- }
- ,
- a.BindMorphTargetParameters = function(e, i) {
- var o = e.morphTargetManager;
- !e || !o || i.setFloatArray("morphTargetInfluences", o.influences)
- }
- ,
- a.BindLogDepth = function(e, i, o) {
- if (!e || e.LOGARITHMICDEPTH) {
- var s = o.activeCamera;
- s.mode === Camera$1.ORTHOGRAPHIC_CAMERA && Logger$2.Error("Logarithmic depth is not compatible with orthographic cameras!", 20),
- i.setFloat("logarithmicDepthConstant", 2 / (Math.log(s.maxZ + 1) / Math.LN2))
- }
- }
- ,
- a.BindClipPlane = function(e, i) {
- ThinMaterialHelper.BindClipPlane(e, i)
- }
- ,
- a._TmpMorphInfluencers = {
- NUM_MORPH_INFLUENCERS: 0
- },
- a._tempFogColor = Color3.Black(),
- a
- }()
- , MaterialStencilState = function() {
- function a() {
- this.reset()
- }
- return a.prototype.reset = function() {
- this.enabled = !1,
- this.mask = 255,
- this.func = 519,
- this.funcRef = 1,
- this.funcMask = 255,
- this.opStencilFail = 7680,
- this.opDepthFail = 7680,
- this.opStencilDepthPass = 7681
- }
- ,
- Object.defineProperty(a.prototype, "func", {
- get: function() {
- return this._func
- },
- set: function(e) {
- this._func = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "funcRef", {
- get: function() {
- return this._funcRef
- },
- set: function(e) {
- this._funcRef = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "funcMask", {
- get: function() {
- return this._funcMask
- },
- set: function(e) {
- this._funcMask = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "opStencilFail", {
- get: function() {
- return this._opStencilFail
- },
- set: function(e) {
- this._opStencilFail = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "opDepthFail", {
- get: function() {
- return this._opDepthFail
- },
- set: function(e) {
- this._opDepthFail = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "opStencilDepthPass", {
- get: function() {
- return this._opStencilDepthPass
- },
- set: function(e) {
- this._opStencilDepthPass = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "mask", {
- get: function() {
- return this._mask
- },
- set: function(e) {
- this._mask = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "enabled", {
- get: function() {
- return this._enabled
- },
- set: function(e) {
- this._enabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.getClassName = function() {
- return "MaterialStencilState"
- }
- ,
- a.prototype.copyTo = function(e) {
- SerializationHelper.Clone(function() {
- return e
- }, this)
- }
- ,
- a.prototype.serialize = function() {
- return SerializationHelper.Serialize(this)
- }
- ,
- a.prototype.parse = function(e, i, o) {
- var s = this;
- SerializationHelper.Parse(function() {
- return s
- }, e, i, o)
- }
- ,
- __decorate([serialize()], a.prototype, "func", null),
- __decorate([serialize()], a.prototype, "funcRef", null),
- __decorate([serialize()], a.prototype, "funcMask", null),
- __decorate([serialize()], a.prototype, "opStencilFail", null),
- __decorate([serialize()], a.prototype, "opDepthFail", null),
- __decorate([serialize()], a.prototype, "opStencilDepthPass", null),
- __decorate([serialize()], a.prototype, "mask", null),
- __decorate([serialize()], a.prototype, "enabled", null),
- a
- }()
- , Material = function() {
- function a(e, i, o) {
- this.shadowDepthWrapper = null,
- this.allowShaderHotSwapping = !0,
- this.metadata = null,
- this.reservedDataStore = null,
- this.checkReadyOnEveryCall = !1,
- this.checkReadyOnlyOnce = !1,
- this.state = "",
- this._alpha = 1,
- this._backFaceCulling = !0,
- this._cullBackFaces = !0,
- this.onCompiled = null,
- this.onError = null,
- this.getRenderTargetTextures = null,
- this.doNotSerialize = !1,
- this._storeEffectOnSubMeshes = !1,
- this.animations = null,
- this.onDisposeObservable = new Observable,
- this._onDisposeObserver = null,
- this._onUnBindObservable = null,
- this._onBindObserver = null,
- this._alphaMode = 2,
- this._needDepthPrePass = !1,
- this.disableDepthWrite = !1,
- this.disableColorWrite = !1,
- this.forceDepthWrite = !1,
- this.depthFunction = 0,
- this.separateCullingPass = !1,
- this._fogEnabled = !0,
- this.pointSize = 1,
- this.zOffset = 0,
- this.zOffsetUnits = 0,
- this.stencil = new MaterialStencilState,
- this._useUBO = !1,
- this._fillMode = a.TriangleFillMode,
- this._cachedDepthWriteState = !1,
- this._cachedColorWriteState = !1,
- this._cachedDepthFunctionState = 0,
- this._indexInSceneMaterialArray = -1,
- this.meshMap = null,
- this._parentContainer = null,
- this._forceAlphaTest = !1,
- this._transparencyMode = null,
- this.name = e,
- this._scene = i || EngineStore.LastCreatedScene,
- this.id = e || Tools.RandomId(),
- this.uniqueId = this._scene.getUniqueId(),
- this._materialContext = this._scene.getEngine().createMaterialContext(),
- this._drawWrapper = new DrawWrapper(this._scene.getEngine(),!1),
- this._drawWrapper.materialContext = this._materialContext,
- this._scene.useRightHandedSystem ? this.sideOrientation = a.ClockWiseSideOrientation : this.sideOrientation = a.CounterClockWiseSideOrientation,
- this._uniformBuffer = new UniformBuffer(this._scene.getEngine(),void 0,void 0,e),
- this._useUBO = this.getScene().getEngine().supportsUniformBuffers,
- o || this._scene.addMaterial(this),
- this._scene.useMaterialMeshMap && (this.meshMap = {})
- }
- return Object.defineProperty(a.prototype, "canRenderToMRT", {
- get: function() {
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "alpha", {
- get: function() {
- return this._alpha
- },
- set: function(e) {
- this._alpha !== e && (this._alpha = e,
- this.markAsDirty(a.MiscDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "backFaceCulling", {
- get: function() {
- return this._backFaceCulling
- },
- set: function(e) {
- this._backFaceCulling !== e && (this._backFaceCulling = e,
- this.markAsDirty(a.TextureDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "cullBackFaces", {
- get: function() {
- return this._cullBackFaces
- },
- set: function(e) {
- this._cullBackFaces !== e && (this._cullBackFaces = e,
- this.markAsDirty(a.TextureDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "hasRenderTargetTextures", {
- get: function() {
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "onDispose", {
- set: function(e) {
- this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver),
- this._onDisposeObserver = this.onDisposeObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "onBindObservable", {
- get: function() {
- return this._onBindObservable || (this._onBindObservable = new Observable),
- this._onBindObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "onBind", {
- set: function(e) {
- this._onBindObserver && this.onBindObservable.remove(this._onBindObserver),
- this._onBindObserver = this.onBindObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "onUnBindObservable", {
- get: function() {
- return this._onUnBindObservable || (this._onUnBindObservable = new Observable),
- this._onUnBindObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "onEffectCreatedObservable", {
- get: function() {
- return this._onEffectCreatedObservable || (this._onEffectCreatedObservable = new Observable),
- this._onEffectCreatedObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "alphaMode", {
- get: function() {
- return this._alphaMode
- },
- set: function(e) {
- this._alphaMode !== e && (this._alphaMode = e,
- this.markAsDirty(a.TextureDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "needDepthPrePass", {
- get: function() {
- return this._needDepthPrePass
- },
- set: function(e) {
- this._needDepthPrePass !== e && (this._needDepthPrePass = e,
- this._needDepthPrePass && (this.checkReadyOnEveryCall = !0))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "isPrePassCapable", {
- get: function() {
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "fogEnabled", {
- get: function() {
- return this._fogEnabled
- },
- set: function(e) {
- this._fogEnabled !== e && (this._fogEnabled = e,
- this.markAsDirty(a.MiscDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "wireframe", {
- get: function() {
- switch (this._fillMode) {
- case a.WireFrameFillMode:
- case a.LineListDrawMode:
- case a.LineLoopDrawMode:
- case a.LineStripDrawMode:
- return !0
- }
- return this._scene.forceWireframe
- },
- set: function(e) {
- this.fillMode = e ? a.WireFrameFillMode : a.TriangleFillMode
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "pointsCloud", {
- get: function() {
- switch (this._fillMode) {
- case a.PointFillMode:
- case a.PointListDrawMode:
- return !0
- }
- return this._scene.forcePointsCloud
- },
- set: function(e) {
- this.fillMode = e ? a.PointFillMode : a.TriangleFillMode
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "fillMode", {
- get: function() {
- return this._fillMode
- },
- set: function(e) {
- this._fillMode !== e && (this._fillMode = e,
- this.markAsDirty(a.MiscDirtyFlag))
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._getDrawWrapper = function() {
- return this._drawWrapper
- }
- ,
- a.prototype._setDrawWrapper = function(e) {
- this._drawWrapper = e
- }
- ,
- a.prototype.toString = function(e) {
- var i = "Name: " + this.name;
- return i
- }
- ,
- a.prototype.getClassName = function() {
- return "Material"
- }
- ,
- Object.defineProperty(a.prototype, "isFrozen", {
- get: function() {
- return this.checkReadyOnlyOnce
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.freeze = function() {
- this.markDirty(),
- this.checkReadyOnlyOnce = !0
- }
- ,
- a.prototype.unfreeze = function() {
- this.markDirty(),
- this.checkReadyOnlyOnce = !1
- }
- ,
- a.prototype.isReady = function(e, i) {
- return !0
- }
- ,
- a.prototype.isReadyForSubMesh = function(e, i, o) {
- return !1
- }
- ,
- a.prototype.getEffect = function() {
- return this._drawWrapper.effect
- }
- ,
- a.prototype.getScene = function() {
- return this._scene
- }
- ,
- Object.defineProperty(a.prototype, "transparencyMode", {
- get: function() {
- return this._transparencyMode
- },
- set: function(e) {
- this._transparencyMode !== e && (this._transparencyMode = e,
- this._forceAlphaTest = e === a.MATERIAL_ALPHATESTANDBLEND,
- this._markAllSubMeshesAsTexturesAndMiscDirty())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "_disableAlphaBlending", {
- get: function() {
- return this._transparencyMode === a.MATERIAL_OPAQUE || this._transparencyMode === a.MATERIAL_ALPHATEST
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.needAlphaBlending = function() {
- return this._disableAlphaBlending ? !1 : this.alpha < 1
- }
- ,
- a.prototype.needAlphaBlendingForMesh = function(e) {
- return this._disableAlphaBlending && e.visibility >= 1 ? !1 : this.needAlphaBlending() || e.visibility < 1 || e.hasVertexAlpha
- }
- ,
- a.prototype.needAlphaTesting = function() {
- return !!this._forceAlphaTest
- }
- ,
- a.prototype._shouldTurnAlphaTestOn = function(e) {
- return !this.needAlphaBlendingForMesh(e) && this.needAlphaTesting()
- }
- ,
- a.prototype.getAlphaTestTexture = function() {
- return null
- }
- ,
- a.prototype.markDirty = function() {
- for (var e = this.getScene().meshes, i = 0, o = e; i < o.length; i++) {
- var s = o[i];
- if (!!s.subMeshes)
- for (var c = 0, d = s.subMeshes; c < d.length; c++) {
- var _ = d[c];
- _.getMaterial() === this && (!_.effect || (_.effect._wasPreviouslyReady = !1))
- }
- }
- }
- ,
- a.prototype._preBind = function(e, i) {
- i === void 0 && (i = null);
- var o = this._scene.getEngine()
- , s = i == null ? this.sideOrientation : i
- , c = s === a.ClockWiseSideOrientation;
- return o.enableEffect(e || this._getDrawWrapper()),
- o.setState(this.backFaceCulling, this.zOffset, !1, c, this.cullBackFaces, this.stencil, this.zOffsetUnits),
- c
- }
- ,
- a.prototype.bind = function(e, i) {}
- ,
- a.prototype.bindForSubMesh = function(e, i, o) {}
- ,
- a.prototype.bindOnlyWorldMatrix = function(e) {}
- ,
- a.prototype.bindView = function(e) {
- this._useUBO ? this._needToBindSceneUbo = !0 : e.setMatrix("view", this.getScene().getViewMatrix())
- }
- ,
- a.prototype.bindViewProjection = function(e) {
- this._useUBO ? this._needToBindSceneUbo = !0 : (e.setMatrix("viewProjection", this.getScene().getTransformMatrix()),
- e.setMatrix("projection", this.getScene().getProjectionMatrix()))
- }
- ,
- a.prototype.bindEyePosition = function(e, i) {
- this._useUBO ? this._needToBindSceneUbo = !0 : this._scene.bindEyePosition(e, i)
- }
- ,
- a.prototype._afterBind = function(e, i) {
- if (i === void 0 && (i = null),
- this._scene._cachedMaterial = this,
- this._needToBindSceneUbo && i && (this._needToBindSceneUbo = !1,
- MaterialHelper.BindSceneUniformBuffer(i, this.getScene().getSceneUniformBuffer()),
- this._scene.finalizeSceneUbo()),
- e ? this._scene._cachedVisibility = e.visibility : this._scene._cachedVisibility = 1,
- this._onBindObservable && e && this._onBindObservable.notifyObservers(e),
- this.disableDepthWrite) {
- var o = this._scene.getEngine();
- this._cachedDepthWriteState = o.getDepthWrite(),
- o.setDepthWrite(!1)
- }
- if (this.disableColorWrite) {
- var o = this._scene.getEngine();
- this._cachedColorWriteState = o.getColorWrite(),
- o.setColorWrite(!1)
- }
- if (this.depthFunction !== 0) {
- var o = this._scene.getEngine();
- this._cachedDepthFunctionState = o.getDepthFunction() || 0,
- o.setDepthFunction(this.depthFunction)
- }
- }
- ,
- a.prototype.unbind = function() {
- if (this._onUnBindObservable && this._onUnBindObservable.notifyObservers(this),
- this.depthFunction !== 0) {
- var e = this._scene.getEngine();
- e.setDepthFunction(this._cachedDepthFunctionState)
- }
- if (this.disableDepthWrite) {
- var e = this._scene.getEngine();
- e.setDepthWrite(this._cachedDepthWriteState)
- }
- if (this.disableColorWrite) {
- var e = this._scene.getEngine();
- e.setColorWrite(this._cachedColorWriteState)
- }
- }
- ,
- a.prototype.getActiveTextures = function() {
- return []
- }
- ,
- a.prototype.hasTexture = function(e) {
- return !1
- }
- ,
- a.prototype.clone = function(e) {
- return null
- }
- ,
- a.prototype.getBindedMeshes = function() {
- var e = this;
- if (this.meshMap) {
- var i = new Array;
- for (var o in this.meshMap) {
- var s = this.meshMap[o];
- s && i.push(s)
- }
- return i
- } else {
- var c = this._scene.meshes;
- return c.filter(function(d) {
- return d.material === e
- })
- }
- }
- ,
- a.prototype.forceCompilation = function(e, i, o, s) {
- var c = this
- , d = __assign({
- clipPlane: !1,
- useInstances: !1
- }, o)
- , _ = this.getScene()
- , b = this.allowShaderHotSwapping;
- this.allowShaderHotSwapping = !1;
- var k = function() {
- if (!(!c._scene || !c._scene.getEngine())) {
- var j = _.clipPlane;
- if (d.clipPlane && (_.clipPlane = new Plane(0,0,0,1)),
- c._storeEffectOnSubMeshes) {
- var $ = !0
- , _e = null;
- if (e.subMeshes) {
- var et = new SubMesh(0,0,0,0,0,e,void 0,!1,!1);
- et.materialDefines && (et.materialDefines._renderId = -1),
- c.isReadyForSubMesh(e, et, d.useInstances) || (et.effect && et.effect.getCompilationError() && et.effect.allFallbacksProcessed() ? _e = et.effect.getCompilationError() : ($ = !1,
- setTimeout(k, 16)))
- }
- $ && (c.allowShaderHotSwapping = b,
- _e && s && s(_e),
- i && i(c))
- } else
- c.isReady() ? (c.allowShaderHotSwapping = b,
- i && i(c)) : setTimeout(k, 16);
- d.clipPlane && (_.clipPlane = j)
- }
- };
- k()
- }
- ,
- a.prototype.forceCompilationAsync = function(e, i) {
- var o = this;
- return new Promise(function(s, c) {
- o.forceCompilation(e, function() {
- s()
- }, i, function(d) {
- c(d)
- })
- }
- )
- }
- ,
- a.prototype.markAsDirty = function(e) {
- this.getScene().blockMaterialDirtyMechanism || (a._DirtyCallbackArray.length = 0,
- e & a.TextureDirtyFlag && a._DirtyCallbackArray.push(a._TextureDirtyCallBack),
- e & a.LightDirtyFlag && a._DirtyCallbackArray.push(a._LightsDirtyCallBack),
- e & a.FresnelDirtyFlag && a._DirtyCallbackArray.push(a._FresnelDirtyCallBack),
- e & a.AttributesDirtyFlag && a._DirtyCallbackArray.push(a._AttributeDirtyCallBack),
- e & a.MiscDirtyFlag && a._DirtyCallbackArray.push(a._MiscDirtyCallBack),
- e & a.PrePassDirtyFlag && a._DirtyCallbackArray.push(a._PrePassDirtyCallBack),
- a._DirtyCallbackArray.length && this._markAllSubMeshesAsDirty(a._RunDirtyCallBacks),
- this.getScene().resetCachedMaterial())
- }
- ,
- a.prototype._markAllSubMeshesAsDirty = function(e) {
- if (!this.getScene().blockMaterialDirtyMechanism)
- for (var i = this.getScene().meshes, o = 0, s = i; o < s.length; o++) {
- var c = s[o];
- if (!!c.subMeshes)
- for (var d = 0, _ = c.subMeshes; d < _.length; d++) {
- var b = _[d];
- if (b.getMaterial() === this)
- for (var k = 0, j = b._drawWrappers; k < j.length; k++) {
- var $ = j[k];
- !$ || !$.defines || !$.defines.markAllAsDirty || this._materialContext === $.materialContext && e($.defines)
- }
- }
- }
- }
- ,
- a.prototype._markScenePrePassDirty = function() {
- if (!this.getScene().blockMaterialDirtyMechanism) {
- var e = this.getScene().enablePrePassRenderer();
- e && e.markAsDirty()
- }
- }
- ,
- a.prototype._markAllSubMeshesAsAllDirty = function() {
- this._markAllSubMeshesAsDirty(a._AllDirtyCallBack)
- }
- ,
- a.prototype._markAllSubMeshesAsImageProcessingDirty = function() {
- this._markAllSubMeshesAsDirty(a._ImageProcessingDirtyCallBack)
- }
- ,
- a.prototype._markAllSubMeshesAsTexturesDirty = function() {
- this._markAllSubMeshesAsDirty(a._TextureDirtyCallBack)
- }
- ,
- a.prototype._markAllSubMeshesAsFresnelDirty = function() {
- this._markAllSubMeshesAsDirty(a._FresnelDirtyCallBack)
- }
- ,
- a.prototype._markAllSubMeshesAsFresnelAndMiscDirty = function() {
- this._markAllSubMeshesAsDirty(a._FresnelAndMiscDirtyCallBack)
- }
- ,
- a.prototype._markAllSubMeshesAsLightsDirty = function() {
- this._markAllSubMeshesAsDirty(a._LightsDirtyCallBack)
- }
- ,
- a.prototype._markAllSubMeshesAsAttributesDirty = function() {
- this._markAllSubMeshesAsDirty(a._AttributeDirtyCallBack)
- }
- ,
- a.prototype._markAllSubMeshesAsMiscDirty = function() {
- this._markAllSubMeshesAsDirty(a._MiscDirtyCallBack)
- }
- ,
- a.prototype._markAllSubMeshesAsPrePassDirty = function() {
- this._markAllSubMeshesAsDirty(a._MiscDirtyCallBack)
- }
- ,
- a.prototype._markAllSubMeshesAsTexturesAndMiscDirty = function() {
- this._markAllSubMeshesAsDirty(a._TextureAndMiscDirtyCallBack)
- }
- ,
- a.prototype.setPrePassRenderer = function(e) {
- return !1
- }
- ,
- a.prototype.dispose = function(e, i, o) {
- var s = this.getScene();
- if (s.stopAnimation(this),
- s.freeProcessedMaterials(),
- s.removeMaterial(this),
- this._parentContainer) {
- var c = this._parentContainer.materials.indexOf(this);
- c > -1 && this._parentContainer.materials.splice(c, 1),
- this._parentContainer = null
- }
- if (o !== !0)
- if (this.meshMap)
- for (var d in this.meshMap) {
- var _ = this.meshMap[d];
- _ && (_.material = null,
- this.releaseVertexArrayObject(_, e))
- }
- else
- for (var b = s.meshes, k = 0, j = b; k < j.length; k++) {
- var _ = j[k];
- _.material === this && !_.sourceMesh && (_.material = null,
- this.releaseVertexArrayObject(_, e))
- }
- this._uniformBuffer.dispose(),
- e && this._drawWrapper.effect && (this._storeEffectOnSubMeshes || this._drawWrapper.effect.dispose(),
- this._drawWrapper.effect = null),
- this.metadata = null,
- this.onDisposeObservable.notifyObservers(this),
- this.onDisposeObservable.clear(),
- this._onBindObservable && this._onBindObservable.clear(),
- this._onUnBindObservable && this._onUnBindObservable.clear(),
- this._onEffectCreatedObservable && this._onEffectCreatedObservable.clear()
- }
- ,
- a.prototype.releaseVertexArrayObject = function(e, i) {
- if (e.geometry) {
- var o = e.geometry;
- if (this._storeEffectOnSubMeshes)
- for (var s = 0, c = e.subMeshes; s < c.length; s++) {
- var d = c[s];
- o._releaseVertexArrayObject(d.effect),
- i && d.effect && d.effect.dispose()
- }
- else
- o._releaseVertexArrayObject(this._drawWrapper.effect)
- }
- }
- ,
- a.prototype.serialize = function() {
- var e = SerializationHelper.Serialize(this);
- return e.stencil = this.stencil.serialize(),
- e
- }
- ,
- a.Parse = function(e, i, o) {
- if (!e.customType)
- e.customType = "BABYLON.StandardMaterial";
- else if (e.customType === "BABYLON.PBRMaterial" && e.overloadedAlbedo && (e.customType = "BABYLON.LegacyPBRMaterial",
- !BABYLON.LegacyPBRMaterial))
- return Logger$2.Error("Your scene is trying to load a legacy version of the PBRMaterial, please, include it from the materials library."),
- null;
- var s = Tools.Instantiate(e.customType);
- return s.Parse(e, i, o)
- }
- ,
- a.TriangleFillMode = 0,
- a.WireFrameFillMode = 1,
- a.PointFillMode = 2,
- a.PointListDrawMode = 3,
- a.LineListDrawMode = 4,
- a.LineLoopDrawMode = 5,
- a.LineStripDrawMode = 6,
- a.TriangleStripDrawMode = 7,
- a.TriangleFanDrawMode = 8,
- a.ClockWiseSideOrientation = 0,
- a.CounterClockWiseSideOrientation = 1,
- a.TextureDirtyFlag = 1,
- a.LightDirtyFlag = 2,
- a.FresnelDirtyFlag = 4,
- a.AttributesDirtyFlag = 8,
- a.MiscDirtyFlag = 16,
- a.PrePassDirtyFlag = 32,
- a.AllDirtyFlag = 63,
- a.MATERIAL_OPAQUE = 0,
- a.MATERIAL_ALPHATEST = 1,
- a.MATERIAL_ALPHABLEND = 2,
- a.MATERIAL_ALPHATESTANDBLEND = 3,
- a.MATERIAL_NORMALBLENDMETHOD_WHITEOUT = 0,
- a.MATERIAL_NORMALBLENDMETHOD_RNM = 1,
- a._AllDirtyCallBack = function(e) {
- return e.markAllAsDirty()
- }
- ,
- a._ImageProcessingDirtyCallBack = function(e) {
- return e.markAsImageProcessingDirty()
- }
- ,
- a._TextureDirtyCallBack = function(e) {
- return e.markAsTexturesDirty()
- }
- ,
- a._FresnelDirtyCallBack = function(e) {
- return e.markAsFresnelDirty()
- }
- ,
- a._MiscDirtyCallBack = function(e) {
- return e.markAsMiscDirty()
- }
- ,
- a._PrePassDirtyCallBack = function(e) {
- return e.markAsPrePassDirty()
- }
- ,
- a._LightsDirtyCallBack = function(e) {
- return e.markAsLightDirty()
- }
- ,
- a._AttributeDirtyCallBack = function(e) {
- return e.markAsAttributesDirty()
- }
- ,
- a._FresnelAndMiscDirtyCallBack = function(e) {
- a._FresnelDirtyCallBack(e),
- a._MiscDirtyCallBack(e)
- }
- ,
- a._TextureAndMiscDirtyCallBack = function(e) {
- a._TextureDirtyCallBack(e),
- a._MiscDirtyCallBack(e)
- }
- ,
- a._DirtyCallbackArray = [],
- a._RunDirtyCallBacks = function(e) {
- for (var i = 0, o = a._DirtyCallbackArray; i < o.length; i++) {
- var s = o[i];
- s(e)
- }
- }
- ,
- __decorate([serialize()], a.prototype, "id", void 0),
- __decorate([serialize()], a.prototype, "uniqueId", void 0),
- __decorate([serialize()], a.prototype, "name", void 0),
- __decorate([serialize()], a.prototype, "metadata", void 0),
- __decorate([serialize()], a.prototype, "checkReadyOnEveryCall", void 0),
- __decorate([serialize()], a.prototype, "checkReadyOnlyOnce", void 0),
- __decorate([serialize()], a.prototype, "state", void 0),
- __decorate([serialize("alpha")], a.prototype, "_alpha", void 0),
- __decorate([serialize("backFaceCulling")], a.prototype, "_backFaceCulling", void 0),
- __decorate([serialize("cullBackFaces")], a.prototype, "_cullBackFaces", void 0),
- __decorate([serialize()], a.prototype, "sideOrientation", void 0),
- __decorate([serialize("alphaMode")], a.prototype, "_alphaMode", void 0),
- __decorate([serialize()], a.prototype, "_needDepthPrePass", void 0),
- __decorate([serialize()], a.prototype, "disableDepthWrite", void 0),
- __decorate([serialize()], a.prototype, "disableColorWrite", void 0),
- __decorate([serialize()], a.prototype, "forceDepthWrite", void 0),
- __decorate([serialize()], a.prototype, "depthFunction", void 0),
- __decorate([serialize()], a.prototype, "separateCullingPass", void 0),
- __decorate([serialize("fogEnabled")], a.prototype, "_fogEnabled", void 0),
- __decorate([serialize()], a.prototype, "pointSize", void 0),
- __decorate([serialize()], a.prototype, "zOffset", void 0),
- __decorate([serialize()], a.prototype, "zOffsetUnits", void 0),
- __decorate([serialize()], a.prototype, "pointsCloud", null),
- __decorate([serialize()], a.prototype, "fillMode", null),
- __decorate([serialize()], a.prototype, "transparencyMode", null),
- a
- }()
- , MultiMaterial = function(a) {
- __extends(e, a);
- function e(i, o) {
- var s = a.call(this, i, o, !0) || this;
- return o.multiMaterials.push(s),
- s.subMaterials = new Array,
- s._storeEffectOnSubMeshes = !0,
- s
- }
- return Object.defineProperty(e.prototype, "subMaterials", {
- get: function() {
- return this._subMaterials
- },
- set: function(i) {
- this._subMaterials = i,
- this._hookArray(i)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getChildren = function() {
- return this.subMaterials
- }
- ,
- e.prototype._hookArray = function(i) {
- var o = this
- , s = i.push;
- i.push = function() {
- for (var d = [], _ = 0; _ < arguments.length; _++)
- d[_] = arguments[_];
- var b = s.apply(i, d);
- return o._markAllSubMeshesAsTexturesDirty(),
- b
- }
- ;
- var c = i.splice;
- i.splice = function(d, _) {
- var b = c.apply(i, [d, _]);
- return o._markAllSubMeshesAsTexturesDirty(),
- b
- }
- }
- ,
- e.prototype.getSubMaterial = function(i) {
- return i < 0 || i >= this.subMaterials.length ? this.getScene().defaultMaterial : this.subMaterials[i]
- }
- ,
- e.prototype.getActiveTextures = function() {
- var i;
- return (i = a.prototype.getActiveTextures.call(this)).concat.apply(i, this.subMaterials.map(function(o) {
- return o ? o.getActiveTextures() : []
- }))
- }
- ,
- e.prototype.hasTexture = function(i) {
- var o;
- if (a.prototype.hasTexture.call(this, i))
- return !0;
- for (var s = 0; s < this.subMaterials.length; s++)
- if (!((o = this.subMaterials[s]) === null || o === void 0) && o.hasTexture(i))
- return !0;
- return !1
- }
- ,
- e.prototype.getClassName = function() {
- return "MultiMaterial"
- }
- ,
- e.prototype.isReadyForSubMesh = function(i, o, s) {
- for (var c = 0; c < this.subMaterials.length; c++) {
- var d = this.subMaterials[c];
- if (d) {
- if (d._storeEffectOnSubMeshes) {
- if (!d.isReadyForSubMesh(i, o, s))
- return !1;
- continue
- }
- if (!d.isReady(i))
- return !1
- }
- }
- return !0
- }
- ,
- e.prototype.clone = function(i, o) {
- for (var s = new e(i,this.getScene()), c = 0; c < this.subMaterials.length; c++) {
- var d = null
- , _ = this.subMaterials[c];
- o && _ ? d = _.clone(i + "-" + _.name) : d = this.subMaterials[c],
- s.subMaterials.push(d)
- }
- return s
- }
- ,
- e.prototype.serialize = function() {
- var i = {};
- i.name = this.name,
- i.id = this.id,
- Tags && (i.tags = Tags.GetTags(this)),
- i.materials = [];
- for (var o = 0; o < this.subMaterials.length; o++) {
- var s = this.subMaterials[o];
- s ? i.materials.push(s.id) : i.materials.push(null)
- }
- return i
- }
- ,
- e.prototype.dispose = function(i, o, s) {
- var c = this.getScene();
- if (!!c) {
- if (s)
- for (var _ = 0; _ < this.subMaterials.length; _++) {
- var d = this.subMaterials[_];
- d && d.dispose(i, o)
- }
- var _ = c.multiMaterials.indexOf(this);
- _ >= 0 && c.multiMaterials.splice(_, 1),
- a.prototype.dispose.call(this, i, o)
- }
- }
- ,
- e.ParseMultiMaterial = function(i, o) {
- var s = new e(i.name,o);
- s.id = i.id,
- Tags && Tags.AddTagsTo(s, i.tags);
- for (var c = 0; c < i.materials.length; c++) {
- var d = i.materials[c];
- d ? s.subMaterials.push(o.getLastMaterialById(d)) : s.subMaterials.push(null)
- }
- return s
- }
- ,
- e
- }(Material);
- RegisterClass("BABYLON.MultiMaterial", MultiMaterial);
- var MeshLODLevel = function() {
- function a(e, i) {
- this.distanceOrScreenCoverage = e,
- this.mesh = i
- }
- return a
- }()
- , _injectLTSMesh = function(a) {
- a.prototype.setMaterialByID = function(e) {
- return this.setMaterialById(e)
- }
- ,
- a.CreateDisc = a.CreateDisc || function() {
- throw _WarnImport("MeshBuilder")
- }
- ,
- a.CreateBox = a.CreateBox || function() {
- throw _WarnImport("MeshBuilder")
- }
- ,
- a.CreateSphere = a.CreateSphere || function() {
- throw _WarnImport("MeshBuilder")
- }
- ,
- a.CreateCylinder = a.CreateCylinder || function() {
- throw _WarnImport("MeshBuilder")
- }
- ,
- a.CreateTorusKnot = a.CreateTorusKnot || function() {
- throw _WarnImport("MeshBuilder")
- }
- ,
- a.CreateTorus = a.CreateTorus || function() {
- throw _WarnImport("MeshBuilder")
- }
- ,
- a.CreatePlane = a.CreatePlane || function() {
- throw _WarnImport("MeshBuilder")
- }
- ,
- a.CreateGround = a.CreateGround || function() {
- throw _WarnImport("MeshBuilder")
- }
- ,
- a.CreateTiledGround = a.CreateTiledGround || function() {
- throw _WarnImport("MeshBuilder")
- }
- ,
- a.CreateGroundFromHeightMap = a.CreateGroundFromHeightMap || function() {
- throw _WarnImport("MeshBuilder")
- }
- ,
- a.CreateTube = a.CreateTube || function() {
- throw _WarnImport("MeshBuilder")
- }
- ,
- a.CreatePolyhedron = a.CreatePolyhedron || function() {
- throw _WarnImport("MeshBuilder")
- }
- ,
- a.CreateIcoSphere = a.CreateIcoSphere || function() {
- throw _WarnImport("MeshBuilder")
- }
- ,
- a.CreateDecal = a.CreateDecal || function() {
- throw _WarnImport("MeshBuilder")
- }
- ,
- a.CreateCapsule = a.CreateCapsule || function() {
- throw _WarnImport("MeshBuilder")
- }
- ,
- a.ExtendToGoldberg = a.ExtendToGoldberg || function() {
- throw _WarnImport("MeshBuilder")
- }
- }
- , _CreationDataStorage = function() {
- function a() {}
- return a
- }()
- , _InstanceDataStorage = function() {
- function a() {
- this.visibleInstances = {},
- this.batchCache = new _InstancesBatch,
- this.batchCacheReplacementModeInFrozenMode = new _InstancesBatch,
- this.instancesBufferSize = 32 * 16 * 4
- }
- return a
- }()
- , _InstancesBatch = function() {
- function a() {
- this.mustReturn = !1,
- this.visibleInstances = new Array,
- this.renderSelf = new Array,
- this.hardwareInstancedRendering = new Array
- }
- return a
- }()
- , _ThinInstanceDataStorage = function() {
- function a() {
- this.instancesCount = 0,
- this.matrixBuffer = null,
- this.previousMatrixBuffer = null,
- this.matrixBufferSize = 32 * 16,
- this.matrixData = null,
- this.boundingVectors = [],
- this.worldMatrices = null
- }
- return a
- }()
- , _InternalMeshDataInfo = function() {
- function a() {
- this._areNormalsFrozen = !1,
- this._source = null,
- this.meshMap = null,
- this._preActivateId = -1,
- this._LODLevels = new Array,
- this._useLODScreenCoverage = !1,
- this._effectiveMaterial = null,
- this._forcedInstanceCount = 0
- }
- return a
- }()
- , Mesh = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _) {
- o === void 0 && (o = null),
- s === void 0 && (s = null),
- c === void 0 && (c = null),
- _ === void 0 && (_ = !0);
- var b = a.call(this, i, o) || this;
- if (b._internalMeshDataInfo = new _InternalMeshDataInfo,
- b.delayLoadState = 0,
- b.instances = new Array,
- b._creationDataStorage = null,
- b._geometry = null,
- b._instanceDataStorage = new _InstanceDataStorage,
- b._thinInstanceDataStorage = new _ThinInstanceDataStorage,
- b._shouldGenerateFlatShading = !1,
- b._originalBuilderSideOrientation = e.DEFAULTSIDE,
- b.overrideMaterialSideOrientation = null,
- b.ignoreCameraMaxZ = !1,
- o = b.getScene(),
- c) {
- if (c._geometry && c._geometry.applyToMesh(b),
- 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"]),
- b._internalMeshDataInfo._source = c,
- o.useClonedMeshMap && (c._internalMeshDataInfo.meshMap || (c._internalMeshDataInfo.meshMap = {}),
- c._internalMeshDataInfo.meshMap[b.uniqueId] = b),
- b._originalBuilderSideOrientation = c._originalBuilderSideOrientation,
- b._creationDataStorage = c._creationDataStorage,
- c._ranges) {
- var k = c._ranges;
- for (var i in k)
- !k.hasOwnProperty(i) || !k[i] || b.createAnimationRange(i, k[i].from, k[i].to)
- }
- c.metadata && c.metadata.clone ? b.metadata = c.metadata.clone() : b.metadata = c.metadata,
- Tags && Tags.HasTags(c) && Tags.AddTagsTo(b, Tags.GetTags(c, !0)),
- b.setEnabled(c.isEnabled()),
- b.parent = c.parent,
- b.setPivotMatrix(c.getPivotMatrix()),
- b.id = i + "." + c.id,
- b.material = c.material;
- var j;
- if (!d)
- for (var $ = c.getDescendants(!0), _e = 0; _e < $.length; _e++) {
- var et = $[_e];
- et.clone && et.clone(i + "." + et.name, b)
- }
- if (c.morphTargetManager && (b.morphTargetManager = c.morphTargetManager),
- o.getPhysicsEngine) {
- var tt = o.getPhysicsEngine();
- if (_ && tt) {
- var rt = tt.getImpostorForPhysicsObject(c);
- rt && (b.physicsImpostor = rt.clone(b))
- }
- }
- for (j = 0; j < o.particleSystems.length; j++) {
- var it = o.particleSystems[j];
- it.emitter === c && it.clone(it.name, b)
- }
- b.refreshBoundingInfo(),
- b.computeWorldMatrix(!0)
- }
- return s !== null && (b.parent = s),
- b._instanceDataStorage.hardwareInstancedRendering = b.getEngine().getCaps().instancedArrays,
- b._internalMeshDataInfo._onMeshReadyObserverAdded = function(nt) {
- nt.unregisterOnNextCall = !0,
- b.isReady(!0) ? b.onMeshReadyObservable.notifyObservers(b) : b._internalMeshDataInfo._checkReadinessObserver || (b._internalMeshDataInfo._checkReadinessObserver = b._scene.onBeforeRenderObservable.add(function() {
- b.isReady(!0) && (b._scene.onBeforeRenderObservable.remove(b._internalMeshDataInfo._checkReadinessObserver),
- b._internalMeshDataInfo._checkReadinessObserver = null,
- b.onMeshReadyObservable.notifyObservers(b))
- }))
- }
- ,
- b.onMeshReadyObservable = new Observable(b._internalMeshDataInfo._onMeshReadyObserverAdded),
- c && c.onClonedObservable.notifyObservers(b),
- b
- }
- return e._GetDefaultSideOrientation = function(i) {
- return i || e.FRONTSIDE
- }
- ,
- Object.defineProperty(e.prototype, "useLODScreenCoverage", {
- get: function() {
- return this._internalMeshDataInfo._useLODScreenCoverage
- },
- set: function(i) {
- this._internalMeshDataInfo._useLODScreenCoverage = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "computeBonesUsingShaders", {
- get: function() {
- return this._internalAbstractMeshDataInfo._computeBonesUsingShaders
- },
- set: function(i) {
- this._internalAbstractMeshDataInfo._computeBonesUsingShaders !== i && (i && this._internalMeshDataInfo._sourcePositions && (this.setVerticesData(VertexBuffer.PositionKind, this._internalMeshDataInfo._sourcePositions.slice(), !0),
- this._internalMeshDataInfo._sourceNormals && this.setVerticesData(VertexBuffer.NormalKind, this._internalMeshDataInfo._sourceNormals.slice(), !0)),
- this._internalAbstractMeshDataInfo._computeBonesUsingShaders = i,
- this._markSubMeshesAsAttributesDirty())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "onBeforeRenderObservable", {
- get: function() {
- return this._internalMeshDataInfo._onBeforeRenderObservable || (this._internalMeshDataInfo._onBeforeRenderObservable = new Observable),
- this._internalMeshDataInfo._onBeforeRenderObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "onBeforeBindObservable", {
- get: function() {
- return this._internalMeshDataInfo._onBeforeBindObservable || (this._internalMeshDataInfo._onBeforeBindObservable = new Observable),
- this._internalMeshDataInfo._onBeforeBindObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "onAfterRenderObservable", {
- get: function() {
- return this._internalMeshDataInfo._onAfterRenderObservable || (this._internalMeshDataInfo._onAfterRenderObservable = new Observable),
- this._internalMeshDataInfo._onAfterRenderObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "onBetweenPassObservable", {
- get: function() {
- return this._internalMeshDataInfo._onBetweenPassObservable || (this._internalMeshDataInfo._onBetweenPassObservable = new Observable),
- this._internalMeshDataInfo._onBetweenPassObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "onBeforeDrawObservable", {
- get: function() {
- return this._internalMeshDataInfo._onBeforeDrawObservable || (this._internalMeshDataInfo._onBeforeDrawObservable = new Observable),
- this._internalMeshDataInfo._onBeforeDrawObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "onBeforeDraw", {
- set: function(i) {
- this._onBeforeDrawObserver && this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver),
- this._onBeforeDrawObserver = this.onBeforeDrawObservable.add(i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "hasInstances", {
- get: function() {
- return this.instances.length > 0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "hasThinInstances", {
- get: function() {
- var i;
- return ((i = this._thinInstanceDataStorage.instancesCount) !== null && i !== void 0 ? i : 0) > 0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "forcedInstanceCount", {
- get: function() {
- return this._internalMeshDataInfo._forcedInstanceCount
- },
- set: function(i) {
- this._internalMeshDataInfo._forcedInstanceCount = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "source", {
- get: function() {
- return this._internalMeshDataInfo._source
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cloneMeshMap", {
- get: function() {
- return this._internalMeshDataInfo.meshMap
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isUnIndexed", {
- get: function() {
- return this._unIndexed
- },
- set: function(i) {
- this._unIndexed !== i && (this._unIndexed = i,
- this._markSubMeshesAsAttributesDirty())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "worldMatrixInstancedBuffer", {
- get: function() {
- return this._instanceDataStorage.instancesData
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "previousWorldMatrixInstancedBuffer", {
- get: function() {
- return this._instanceDataStorage.instancesPreviousData
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "manualUpdateOfWorldMatrixInstancedBuffer", {
- get: function() {
- return this._instanceDataStorage.manualUpdate
- },
- set: function(i) {
- this._instanceDataStorage.manualUpdate = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "manualUpdateOfPreviousWorldMatrixInstancedBuffer", {
- get: function() {
- return this._instanceDataStorage.previousManualUpdate
- },
- set: function(i) {
- this._instanceDataStorage.previousManualUpdate = i
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.instantiateHierarchy = function(i, o, s) {
- i === void 0 && (i = null);
- 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);
- c && (c.parent = i || this.parent,
- c.position = this.position.clone(),
- c.scaling = this.scaling.clone(),
- this.rotationQuaternion ? c.rotationQuaternion = this.rotationQuaternion.clone() : c.rotation = this.rotation.clone(),
- s && s(this, c));
- for (var d = 0, _ = this.getChildTransformNodes(!0); d < _.length; d++) {
- var b = _[d];
- b.instantiateHierarchy(c, o, s)
- }
- return c
- }
- ,
- e.prototype.getClassName = function() {
- return "Mesh"
- }
- ,
- Object.defineProperty(e.prototype, "_isMesh", {
- get: function() {
- return !0
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.toString = function(i) {
- var o = a.prototype.toString.call(this, i);
- if (o += ", n vertices: " + this.getTotalVertices(),
- o += ", parent: " + (this._waitingParentId ? this._waitingParentId : this.parent ? this.parent.name : "NONE"),
- this.animations)
- for (var s = 0; s < this.animations.length; s++)
- o += ", animation[0]: " + this.animations[s].toString(i);
- if (i)
- if (this._geometry) {
- var c = this.getIndices()
- , d = this.getVerticesData(VertexBuffer.PositionKind);
- d && c && (o += ", flat shading: " + (d.length / 3 === c.length ? "YES" : "NO"))
- } else
- o += ", flat shading: UNKNOWN";
- return o
- }
- ,
- e.prototype._unBindEffect = function() {
- a.prototype._unBindEffect.call(this);
- for (var i = 0, o = this.instances; i < o.length; i++) {
- var s = o[i];
- s._unBindEffect()
- }
- }
- ,
- Object.defineProperty(e.prototype, "hasLODLevels", {
- get: function() {
- return this._internalMeshDataInfo._LODLevels.length > 0
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getLODLevels = function() {
- return this._internalMeshDataInfo._LODLevels
- }
- ,
- e.prototype._sortLODLevels = function() {
- var i = this._internalMeshDataInfo._useLODScreenCoverage ? -1 : 1;
- this._internalMeshDataInfo._LODLevels.sort(function(o, s) {
- return o.distanceOrScreenCoverage < s.distanceOrScreenCoverage ? i : o.distanceOrScreenCoverage > s.distanceOrScreenCoverage ? -i : 0
- })
- }
- ,
- e.prototype.addLODLevel = function(i, o) {
- if (o && o._masterMesh)
- return Logger$2.Warn("You cannot use a mesh as LOD level twice"),
- this;
- var s = new MeshLODLevel(i,o);
- return this._internalMeshDataInfo._LODLevels.push(s),
- o && (o._masterMesh = this),
- this._sortLODLevels(),
- this
- }
- ,
- e.prototype.getLODLevelAtDistance = function(i) {
- for (var o = this._internalMeshDataInfo, s = 0; s < o._LODLevels.length; s++) {
- var c = o._LODLevels[s];
- if (c.distanceOrScreenCoverage === i)
- return c.mesh
- }
- return null
- }
- ,
- e.prototype.removeLODLevel = function(i) {
- for (var o = this._internalMeshDataInfo, s = 0; s < o._LODLevels.length; s++)
- o._LODLevels[s].mesh === i && (o._LODLevels.splice(s, 1),
- i && (i._masterMesh = null));
- return this._sortLODLevels(),
- this
- }
- ,
- e.prototype.getLOD = function(i, o) {
- var s = this._internalMeshDataInfo;
- if (!s._LODLevels || s._LODLevels.length === 0)
- return this;
- var c;
- if (o)
- c = o;
- else {
- var d = this.getBoundingInfo();
- c = d.boundingSphere
- }
- var _ = c.centerWorld.subtract(i.globalPosition).length()
- , b = s._useLODScreenCoverage
- , k = _
- , j = 1;
- if (b) {
- var $ = i.screenArea
- , _e = c.radiusWorld * i.minZ / _;
- _e = _e * _e * Math.PI,
- k = _e / $,
- j = -1
- }
- if (j * s._LODLevels[s._LODLevels.length - 1].distanceOrScreenCoverage > j * k)
- return this.onLODLevelSelection && this.onLODLevelSelection(k, this, this),
- this;
- for (var et = 0; et < s._LODLevels.length; et++) {
- var tt = s._LODLevels[et];
- if (j * tt.distanceOrScreenCoverage < j * k) {
- if (tt.mesh) {
- if (tt.mesh.delayLoadState === 4)
- return tt.mesh._checkDelayState(),
- this;
- if (tt.mesh.delayLoadState === 2)
- return this;
- tt.mesh._preActivate(),
- tt.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache)
- }
- return this.onLODLevelSelection && this.onLODLevelSelection(k, this, tt.mesh),
- tt.mesh
- }
- }
- return this.onLODLevelSelection && this.onLODLevelSelection(k, this, this),
- this
- }
- ,
- Object.defineProperty(e.prototype, "geometry", {
- get: function() {
- return this._geometry
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getTotalVertices = function() {
- return this._geometry === null || this._geometry === void 0 ? 0 : this._geometry.getTotalVertices()
- }
- ,
- e.prototype.getVerticesData = function(i, o, s) {
- var c, d;
- if (!this._geometry)
- return null;
- 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);
- return _ || (_ = this._geometry.getVerticesData(i, o, s)),
- _
- }
- ,
- e.prototype.getVertexBuffer = function(i) {
- var o, s;
- 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
- }
- ,
- e.prototype.isVerticesDataPresent = function(i) {
- var o;
- 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
- }
- ,
- e.prototype.isVertexBufferUpdatable = function(i) {
- var o, s;
- 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
- }
- ,
- e.prototype.getVerticesDataKinds = function() {
- if (!this._geometry) {
- var i = new Array;
- return this._delayInfo && this._delayInfo.forEach(function(c) {
- i.push(c)
- }),
- i
- }
- var o = this._geometry.getVerticesDataKinds();
- if (this._userInstancedBuffersStorage)
- for (var s in this._userInstancedBuffersStorage.vertexBuffers)
- o.push(s);
- return o
- }
- ,
- e.prototype.getTotalIndices = function() {
- return this._geometry ? this._geometry.getTotalIndices() : 0
- }
- ,
- e.prototype.getIndices = function(i, o) {
- return this._geometry ? this._geometry.getIndices(i, o) : []
- }
- ,
- Object.defineProperty(e.prototype, "isBlocked", {
- get: function() {
- return this._masterMesh !== null && this._masterMesh !== void 0
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.isReady = function(i, o) {
- var s, c, d, _, b, k;
- if (i === void 0 && (i = !1),
- o === void 0 && (o = !1),
- this.delayLoadState === 2 || !a.prototype.isReady.call(this, i))
- return !1;
- if (!this.subMeshes || this.subMeshes.length === 0 || !i)
- return !0;
- var j = this.getEngine()
- , $ = this.getScene()
- , _e = o || j.getCaps().instancedArrays && (this.instances.length > 0 || this.hasThinInstances);
- this.computeWorldMatrix();
- var et = this.material || $.defaultMaterial;
- if (et) {
- if (et._storeEffectOnSubMeshes)
- for (var tt = 0, rt = this.subMeshes; tt < rt.length; tt++) {
- var it = rt[tt]
- , nt = it.getMaterial();
- if (nt) {
- if (nt._storeEffectOnSubMeshes) {
- if (!nt.isReadyForSubMesh(this, it, _e))
- return !1
- } else if (!nt.isReady(this, _e))
- return !1
- }
- }
- else if (!et.isReady(this, _e))
- return !1
- }
- for (var ot = j.currentRenderPassId, at = 0, st = this.lightSources; at < st.length; at++) {
- var ut = st[at]
- , ct = ut.getShadowGenerator();
- 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)) {
- ct.getShadowMap() && (j.currentRenderPassId = ct.getShadowMap().renderPassId);
- for (var lt = 0, ft = this.subMeshes; lt < ft.length; lt++) {
- var it = ft[lt];
- if (!ct.isReady(it, _e, (k = (b = it.getMaterial()) === null || b === void 0 ? void 0 : b.needAlphaBlendingForMesh(this)) !== null && k !== void 0 ? k : !1))
- return j.currentRenderPassId = ot,
- !1
- }
- j.currentRenderPassId = ot
- }
- }
- for (var ht = 0, pt = this._internalMeshDataInfo._LODLevels; ht < pt.length; ht++) {
- var dt = pt[ht];
- if (dt.mesh && !dt.mesh.isReady(_e))
- return !1
- }
- return !0
- }
- ,
- Object.defineProperty(e.prototype, "areNormalsFrozen", {
- get: function() {
- return this._internalMeshDataInfo._areNormalsFrozen
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.freezeNormals = function() {
- return this._internalMeshDataInfo._areNormalsFrozen = !0,
- this
- }
- ,
- e.prototype.unfreezeNormals = function() {
- return this._internalMeshDataInfo._areNormalsFrozen = !1,
- this
- }
- ,
- Object.defineProperty(e.prototype, "overridenInstanceCount", {
- set: function(i) {
- this._instanceDataStorage.overridenInstanceCount = i
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._preActivate = function() {
- var i = this._internalMeshDataInfo
- , o = this.getScene().getRenderId();
- return i._preActivateId === o ? this : (i._preActivateId = o,
- this._instanceDataStorage.visibleInstances = null,
- this)
- }
- ,
- e.prototype._preActivateForIntermediateRendering = function(i) {
- return this._instanceDataStorage.visibleInstances && (this._instanceDataStorage.visibleInstances.intermediateDefaultRenderId = i),
- this
- }
- ,
- e.prototype._registerInstanceForRenderId = function(i, o) {
- return this._instanceDataStorage.visibleInstances || (this._instanceDataStorage.visibleInstances = {
- defaultRenderId: o,
- selfDefaultRenderId: this._renderId
- }),
- this._instanceDataStorage.visibleInstances[o] || (this._instanceDataStorage.previousRenderId !== void 0 && this._instanceDataStorage.isFrozen && (this._instanceDataStorage.visibleInstances[this._instanceDataStorage.previousRenderId] = null),
- this._instanceDataStorage.previousRenderId = o,
- this._instanceDataStorage.visibleInstances[o] = new Array),
- this._instanceDataStorage.visibleInstances[o].push(i),
- this
- }
- ,
- e.prototype._afterComputeWorldMatrix = function() {
- a.prototype._afterComputeWorldMatrix.call(this),
- this.hasThinInstances && (this.doNotSyncBoundingInfo || this.thinInstanceRefreshBoundingInfo(!1))
- }
- ,
- e.prototype._postActivate = function() {
- this.edgesShareWithInstances && this.edgesRenderer && this.edgesRenderer.isEnabled && this._renderingGroup && (this._renderingGroup._edgesRenderers.pushNoDuplicate(this.edgesRenderer),
- this.edgesRenderer.customInstances.push(this.getWorldMatrix()))
- }
- ,
- e.prototype.refreshBoundingInfo = function(i, o) {
- if (i === void 0 && (i = !1),
- o === void 0 && (o = !0),
- this.hasBoundingInfo && this.getBoundingInfo().isLocked)
- return this;
- var s = this.geometry ? this.geometry.boundingBias : null;
- return this._refreshBoundingInfo(this._getPositionData(i, o), s),
- this
- }
- ,
- e.prototype._createGlobalSubMesh = function(i) {
- var o = this.getTotalVertices();
- if (!o || !this.getIndices())
- return null;
- if (this.subMeshes && this.subMeshes.length > 0) {
- var s = this.getIndices();
- if (!s)
- return null;
- var c = s.length
- , d = !1;
- if (i)
- d = !0;
- else
- for (var _ = 0, b = this.subMeshes; _ < b.length; _++) {
- var k = b[_];
- if (k.indexStart + k.indexCount > c) {
- d = !0;
- break
- }
- if (k.verticesStart + k.verticesCount > o) {
- d = !0;
- break
- }
- }
- if (!d)
- return this.subMeshes[0]
- }
- return this.releaseSubMeshes(),
- new SubMesh(0,0,o,0,this.getTotalIndices(),this)
- }
- ,
- e.prototype.subdivide = function(i) {
- if (!(i < 1)) {
- for (var o = this.getTotalIndices(), s = o / i | 0, c = 0; s % 3 !== 0; )
- s++;
- this.releaseSubMeshes();
- for (var d = 0; d < i && !(c >= o); d++)
- SubMesh.CreateFromIndices(0, c, d === i - 1 ? o - c : s, this),
- c += s;
- this.synchronizeInstances()
- }
- }
- ,
- e.prototype.setVerticesData = function(i, o, s, c) {
- if (s === void 0 && (s = !1),
- this._geometry)
- this._geometry.setVerticesData(i, o, s, c);
- else {
- var d = new VertexData;
- d.set(o, i);
- var _ = this.getScene();
- new Geometry(Geometry.RandomId(),_,d,s,this)
- }
- return this
- }
- ,
- e.prototype.removeVerticesData = function(i) {
- !this._geometry || this._geometry.removeVerticesData(i)
- }
- ,
- e.prototype.markVerticesDataAsUpdatable = function(i, o) {
- o === void 0 && (o = !0);
- var s = this.getVertexBuffer(i);
- !s || s.isUpdatable() === o || this.setVerticesData(i, this.getVerticesData(i), o)
- }
- ,
- e.prototype.setVerticesBuffer = function(i, o) {
- return o === void 0 && (o = !0),
- this._geometry || (this._geometry = Geometry.CreateGeometryForMesh(this)),
- this._geometry.setVerticesBuffer(i, null, o),
- this
- }
- ,
- e.prototype.updateVerticesData = function(i, o, s, c) {
- return this._geometry ? (c ? (this.makeGeometryUnique(),
- this.updateVerticesData(i, o, s, !1)) : this._geometry.updateVerticesData(i, o, s),
- this) : this
- }
- ,
- e.prototype.updateMeshPositions = function(i, o) {
- o === void 0 && (o = !0);
- var s = this.getVerticesData(VertexBuffer.PositionKind);
- if (!s)
- return this;
- if (i(s),
- this.updateVerticesData(VertexBuffer.PositionKind, s, !1, !1),
- o) {
- var c = this.getIndices()
- , d = this.getVerticesData(VertexBuffer.NormalKind);
- if (!d)
- return this;
- VertexData.ComputeNormals(s, c, d),
- this.updateVerticesData(VertexBuffer.NormalKind, d, !1, !1)
- }
- return this
- }
- ,
- e.prototype.makeGeometryUnique = function() {
- if (!this._geometry)
- return this;
- if (this._geometry.meshes.length === 1)
- return this;
- var i = this._geometry
- , o = this._geometry.copy(Geometry.RandomId());
- return i.releaseForMesh(this, !0),
- o.applyToMesh(this),
- this
- }
- ,
- e.prototype.setIndices = function(i, o, s) {
- if (o === void 0 && (o = null),
- s === void 0 && (s = !1),
- this._geometry)
- this._geometry.setIndices(i, o, s);
- else {
- var c = new VertexData;
- c.indices = i;
- var d = this.getScene();
- new Geometry(Geometry.RandomId(),d,c,s,this)
- }
- return this
- }
- ,
- e.prototype.updateIndices = function(i, o, s) {
- return s === void 0 && (s = !1),
- this._geometry ? (this._geometry.updateIndices(i, o, s),
- this) : this
- }
- ,
- e.prototype.toLeftHanded = function() {
- return this._geometry ? (this._geometry.toLeftHanded(),
- this) : this
- }
- ,
- e.prototype._bind = function(i, o, s) {
- if (!this._geometry)
- return this;
- var c = this.getScene().getEngine();
- this.morphTargetManager && this.morphTargetManager.isUsingTextureForTargets && this.morphTargetManager._bind(o);
- var d;
- if (this._unIndexed)
- d = null;
- else
- switch (s) {
- case Material.PointFillMode:
- d = null;
- break;
- case Material.WireFrameFillMode:
- d = i._getLinesIndexBuffer(this.getIndices(), c);
- break;
- default:
- case Material.TriangleFillMode:
- d = this._geometry.getIndexBuffer();
- break
- }
- return !this._userInstancedBuffersStorage || this.hasThinInstances ? this._geometry._bind(o, d) : this._geometry._bind(o, d, this._userInstancedBuffersStorage.vertexBuffers, this._userInstancedBuffersStorage.vertexArrayObjects),
- this
- }
- ,
- e.prototype._draw = function(i, o, s) {
- if (!this._geometry || !this._geometry.getVertexBuffers() || !this._unIndexed && !this._geometry.getIndexBuffer())
- return this;
- this._internalMeshDataInfo._onBeforeDrawObservable && this._internalMeshDataInfo._onBeforeDrawObservable.notifyObservers(this);
- var c = this.getScene()
- , d = c.getEngine();
- 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),
- this
- }
- ,
- e.prototype.registerBeforeRender = function(i) {
- return this.onBeforeRenderObservable.add(i),
- this
- }
- ,
- e.prototype.unregisterBeforeRender = function(i) {
- return this.onBeforeRenderObservable.removeCallback(i),
- this
- }
- ,
- e.prototype.registerAfterRender = function(i) {
- return this.onAfterRenderObservable.add(i),
- this
- }
- ,
- e.prototype.unregisterAfterRender = function(i) {
- return this.onAfterRenderObservable.removeCallback(i),
- this
- }
- ,
- e.prototype._getInstancesRenderList = function(i, o) {
- if (o === void 0 && (o = !1),
- this._instanceDataStorage.isFrozen) {
- if (o)
- return this._instanceDataStorage.batchCacheReplacementModeInFrozenMode.hardwareInstancedRendering[i] = !1,
- this._instanceDataStorage.batchCacheReplacementModeInFrozenMode.renderSelf[i] = !0,
- this._instanceDataStorage.batchCacheReplacementModeInFrozenMode;
- if (this._instanceDataStorage.previousBatch)
- return this._instanceDataStorage.previousBatch
- }
- var s = this.getScene()
- , c = s._isInIntermediateRendering()
- , d = c ? this._internalAbstractMeshDataInfo._onlyForInstancesIntermediate : this._internalAbstractMeshDataInfo._onlyForInstances
- , _ = this._instanceDataStorage.batchCache;
- if (_.mustReturn = !1,
- _.renderSelf[i] = o || !d && this.isEnabled() && this.isVisible,
- _.visibleInstances[i] = null,
- this._instanceDataStorage.visibleInstances && !o) {
- var b = this._instanceDataStorage.visibleInstances
- , k = s.getRenderId()
- , j = c ? b.intermediateDefaultRenderId : b.defaultRenderId;
- _.visibleInstances[i] = b[k],
- !_.visibleInstances[i] && j && (_.visibleInstances[i] = b[j])
- }
- return _.hardwareInstancedRendering[i] = !o && this._instanceDataStorage.hardwareInstancedRendering && _.visibleInstances[i] !== null && _.visibleInstances[i] !== void 0,
- this._instanceDataStorage.previousBatch = _,
- _
- }
- ,
- e.prototype._renderWithInstances = function(i, o, s, c, d) {
- var _, b = s.visibleInstances[i._id];
- if (!b)
- return this;
- for (var k = this._instanceDataStorage, j = k.instancesBufferSize, $ = k.instancesBuffer, _e = k.instancesPreviousBuffer, et = b.length + 1, tt = et * 16 * 4; k.instancesBufferSize < tt; )
- k.instancesBufferSize *= 2;
- (!k.instancesData || j != k.instancesBufferSize) && (k.instancesData = new Float32Array(k.instancesBufferSize / 4)),
- (this._scene.needsPreviousWorldMatrices && !k.instancesPreviousData || j != k.instancesBufferSize) && (k.instancesPreviousData = new Float32Array(k.instancesBufferSize / 4));
- var rt = 0
- , it = 0
- , nt = s.renderSelf[i._id]
- , ot = !$ || j !== k.instancesBufferSize || this._scene.needsPreviousWorldMatrices && !k.instancesPreviousBuffer;
- if (!this._instanceDataStorage.manualUpdate && (!k.isFrozen || ot)) {
- var at = this._effectiveMesh.getWorldMatrix();
- if (nt && (this._scene.needsPreviousWorldMatrices && (k.masterMeshPreviousWorldMatrix ? (k.masterMeshPreviousWorldMatrix.copyToArray(k.instancesPreviousData, rt),
- k.masterMeshPreviousWorldMatrix.copyFrom(at)) : (k.masterMeshPreviousWorldMatrix = at.clone(),
- k.masterMeshPreviousWorldMatrix.copyToArray(k.instancesPreviousData, rt))),
- at.copyToArray(k.instancesData, rt),
- rt += 16,
- it++),
- b) {
- if (e.INSTANCEDMESH_SORT_TRANSPARENT && this._scene.activeCamera && ((_ = i.getMaterial()) === null || _ === void 0 ? void 0 : _.needAlphaBlendingForMesh(i.getRenderingMesh()))) {
- for (var st = this._scene.activeCamera.globalPosition, ut = 0; ut < b.length; ut++) {
- var ct = b[ut];
- ct._distanceToCamera = Vector3.Distance(ct.getBoundingInfo().boundingSphere.centerWorld, st)
- }
- b.sort(function(pt, dt) {
- return pt._distanceToCamera > dt._distanceToCamera ? -1 : pt._distanceToCamera < dt._distanceToCamera ? 1 : 0
- })
- }
- for (var lt = 0; lt < b.length; lt++) {
- var ft = b[lt]
- , ht = ft.getWorldMatrix();
- ht.copyToArray(k.instancesData, rt),
- this._scene.needsPreviousWorldMatrices && (ft._previousWorldMatrix ? (ft._previousWorldMatrix.copyToArray(k.instancesPreviousData, rt),
- ft._previousWorldMatrix.copyFrom(ht)) : (ft._previousWorldMatrix = ht.clone(),
- ft._previousWorldMatrix.copyToArray(k.instancesPreviousData, rt))),
- rt += 16,
- it++
- }
- }
- } else
- it = (nt ? 1 : 0) + b.length;
- return ot ? ($ && $.dispose(),
- _e && _e.dispose(),
- $ = new Buffer(d,k.instancesData,!0,16,!1,!0),
- k.instancesBuffer = $,
- this._userInstancedBuffersStorage || (this._userInstancedBuffersStorage = {
- data: {},
- vertexBuffers: {},
- strides: {},
- sizes: {},
- vertexArrayObjects: this.getEngine().getCaps().vertexArrayObject ? {} : void 0
- }),
- this._userInstancedBuffersStorage.vertexBuffers.world0 = $.createVertexBuffer("world0", 0, 4),
- this._userInstancedBuffersStorage.vertexBuffers.world1 = $.createVertexBuffer("world1", 4, 4),
- this._userInstancedBuffersStorage.vertexBuffers.world2 = $.createVertexBuffer("world2", 8, 4),
- this._userInstancedBuffersStorage.vertexBuffers.world3 = $.createVertexBuffer("world3", 12, 4),
- this._scene.needsPreviousWorldMatrices && (_e = new Buffer(d,k.instancesPreviousData,!0,16,!1,!0),
- k.instancesPreviousBuffer = _e,
- this._userInstancedBuffersStorage.vertexBuffers.previousWorld0 = _e.createVertexBuffer("previousWorld0", 0, 4),
- this._userInstancedBuffersStorage.vertexBuffers.previousWorld1 = _e.createVertexBuffer("previousWorld1", 4, 4),
- this._userInstancedBuffersStorage.vertexBuffers.previousWorld2 = _e.createVertexBuffer("previousWorld2", 8, 4),
- this._userInstancedBuffersStorage.vertexBuffers.previousWorld3 = _e.createVertexBuffer("previousWorld3", 12, 4)),
- this._invalidateInstanceVertexArrayObject()) : this._instanceDataStorage.isFrozen || ($.updateDirectly(k.instancesData, 0, it),
- this._scene.needsPreviousWorldMatrices && (!this._instanceDataStorage.manualUpdate || this._instanceDataStorage.previousManualUpdate) && _e.updateDirectly(k.instancesPreviousData, 0, it)),
- this._processInstancedBuffers(b, nt),
- this.getScene()._activeIndices.addCount(i.indexCount * it, !1),
- d._currentDrawContext && (d._currentDrawContext.useInstancing = !0),
- this._bind(i, c, o),
- this._draw(i, o, it),
- this._scene.needsPreviousWorldMatrices && !ot && this._instanceDataStorage.manualUpdate && !this._instanceDataStorage.isFrozen && !this._instanceDataStorage.previousManualUpdate && _e.updateDirectly(k.instancesData, 0, it),
- d.unbindInstanceAttributes(),
- this
- }
- ,
- e.prototype._renderWithThinInstances = function(i, o, s, c) {
- var d, _, b = (_ = (d = this._thinInstanceDataStorage) === null || d === void 0 ? void 0 : d.instancesCount) !== null && _ !== void 0 ? _ : 0;
- this.getScene()._activeIndices.addCount(i.indexCount * b, !1),
- c._currentDrawContext && (c._currentDrawContext.useInstancing = !0),
- this._bind(i, s, o),
- this._draw(i, o, b),
- 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)),
- c.unbindInstanceAttributes()
- }
- ,
- e.prototype._processInstancedBuffers = function(i, o) {}
- ,
- e.prototype._processRendering = function(i, o, s, c, d, _, b, k) {
- var j = this.getScene()
- , $ = j.getEngine();
- if (_ && o.getRenderingMesh().hasThinInstances)
- return this._renderWithThinInstances(o, c, s, $),
- this;
- if (_)
- this._renderWithInstances(o, c, d, s, $);
- else {
- $._currentDrawContext && ($._currentDrawContext.useInstancing = !1);
- var _e = 0;
- d.renderSelf[o._id] && (b && b(!1, i._effectiveMesh.getWorldMatrix(), k, i._effectiveMesh),
- _e++,
- this._draw(o, c, this._instanceDataStorage.overridenInstanceCount));
- var et = d.visibleInstances[o._id];
- if (et) {
- var tt = et.length;
- _e += tt;
- for (var rt = 0; rt < tt; rt++) {
- var it = et[rt]
- , nt = it.getWorldMatrix();
- b && b(!0, nt, k),
- this._draw(o, c)
- }
- }
- j._activeIndices.addCount(o.indexCount * _e, !1)
- }
- return this
- }
- ,
- e.prototype._rebuild = function(i) {
- if (i === void 0 && (i = !1),
- this._instanceDataStorage.instancesBuffer && (i && this._instanceDataStorage.instancesBuffer.dispose(),
- this._instanceDataStorage.instancesBuffer = null),
- this._userInstancedBuffersStorage) {
- for (var o in this._userInstancedBuffersStorage.vertexBuffers) {
- var s = this._userInstancedBuffersStorage.vertexBuffers[o];
- s && (i && s.dispose(),
- this._userInstancedBuffersStorage.vertexBuffers[o] = null)
- }
- this._userInstancedBuffersStorage.vertexArrayObjects && (this._userInstancedBuffersStorage.vertexArrayObjects = {})
- }
- this._internalMeshDataInfo._effectiveMaterial = null,
- a.prototype._rebuild.call(this, i)
- }
- ,
- e.prototype._freeze = function() {
- if (!!this.subMeshes) {
- for (var i = 0; i < this.subMeshes.length; i++)
- this._getInstancesRenderList(i);
- this._internalMeshDataInfo._effectiveMaterial = null,
- this._instanceDataStorage.isFrozen = !0
- }
- }
- ,
- e.prototype._unFreeze = function() {
- this._instanceDataStorage.isFrozen = !1,
- this._instanceDataStorage.previousBatch = null
- }
- ,
- e.prototype.render = function(i, o, s) {
- var c, d, _, b = this.getScene();
- if (this._internalAbstractMeshDataInfo._isActiveIntermediate ? this._internalAbstractMeshDataInfo._isActiveIntermediate = !1 : this._internalAbstractMeshDataInfo._isActive = !1,
- this._checkOcclusionQuery())
- return this;
- var k = this._getInstancesRenderList(i._id, !!s);
- if (k.mustReturn)
- return this;
- if (!this._geometry || !this._geometry.getVertexBuffers() || !this._unIndexed && !this._geometry.getIndexBuffer())
- return this;
- var j = b.getEngine()
- , $ = 0
- , _e = null;
- this.ignoreCameraMaxZ && b.activeCamera && !b._isInIntermediateRendering() && ($ = b.activeCamera.maxZ,
- _e = b.activeCamera,
- b.activeCamera.maxZ = 0,
- b.updateTransformMatrix(!0)),
- this._internalMeshDataInfo._onBeforeRenderObservable && this._internalMeshDataInfo._onBeforeRenderObservable.notifyObservers(this);
- var et = k.hardwareInstancedRendering[i._id] || i.getRenderingMesh().hasThinInstances
- , tt = this._instanceDataStorage
- , rt = i.getMaterial();
- if (!rt)
- return _e && (_e.maxZ = $,
- b.updateTransformMatrix(!0)),
- this;
- if (!tt.isFrozen || !this._internalMeshDataInfo._effectiveMaterial || this._internalMeshDataInfo._effectiveMaterial !== rt) {
- if (rt._storeEffectOnSubMeshes) {
- if (!rt.isReadyForSubMesh(this, i, et))
- return _e && (_e.maxZ = $,
- b.updateTransformMatrix(!0)),
- this
- } else if (!rt.isReady(this, et))
- return _e && (_e.maxZ = $,
- b.updateTransformMatrix(!0)),
- this;
- this._internalMeshDataInfo._effectiveMaterial = rt
- } else if (rt._storeEffectOnSubMeshes && !(!((c = i.effect) === null || c === void 0) && c._wasPreviouslyReady) || !rt._storeEffectOnSubMeshes && !(!((d = rt.getEffect()) === null || d === void 0) && d._wasPreviouslyReady))
- return _e && (_e.maxZ = $,
- b.updateTransformMatrix(!0)),
- this;
- o && j.setAlphaMode(this._internalMeshDataInfo._effectiveMaterial.alphaMode);
- var it;
- this._internalMeshDataInfo._effectiveMaterial._storeEffectOnSubMeshes ? it = i._drawWrapper : it = this._internalMeshDataInfo._effectiveMaterial._getDrawWrapper();
- for (var nt = (_ = it == null ? void 0 : it.effect) !== null && _ !== void 0 ? _ : null, ot = 0, at = b._beforeRenderingMeshStage; ot < at.length; ot++) {
- var st = at[ot];
- st.action(this, i, k, nt)
- }
- if (!it || !nt)
- return _e && (_e.maxZ = $,
- b.updateTransformMatrix(!0)),
- this;
- var ut = s || this._effectiveMesh, ct;
- if (!tt.isFrozen && (this._internalMeshDataInfo._effectiveMaterial.backFaceCulling || this.overrideMaterialSideOrientation !== null)) {
- var lt = ut._getWorldMatrixDeterminant();
- ct = this.overrideMaterialSideOrientation,
- ct == null && (ct = this._internalMeshDataInfo._effectiveMaterial.sideOrientation),
- lt < 0 && (ct = ct === Material.ClockWiseSideOrientation ? Material.CounterClockWiseSideOrientation : Material.ClockWiseSideOrientation),
- tt.sideOrientation = ct
- } else
- ct = tt.sideOrientation;
- var ft = this._internalMeshDataInfo._effectiveMaterial._preBind(it, ct);
- this._internalMeshDataInfo._effectiveMaterial.forceDepthWrite && j.setDepthWrite(!0);
- var ht = b.forcePointsCloud ? Material.PointFillMode : b.forceWireframe ? Material.WireFrameFillMode : this._internalMeshDataInfo._effectiveMaterial.fillMode;
- this._internalMeshDataInfo._onBeforeBindObservable && this._internalMeshDataInfo._onBeforeBindObservable.notifyObservers(this),
- et || this._bind(i, nt, ht);
- var pt = this._internalMeshDataInfo._effectiveMaterial
- , dt = ut.getWorldMatrix();
- pt._storeEffectOnSubMeshes ? pt.bindForSubMesh(dt, this, i) : pt.bind(dt, this),
- !pt.backFaceCulling && pt.separateCullingPass && (j.setState(!0, pt.zOffset, !1, !ft, pt.cullBackFaces, pt.stencil, pt.zOffsetUnits),
- this._processRendering(this, i, nt, ht, k, et, this._onBeforeDraw, this._internalMeshDataInfo._effectiveMaterial),
- j.setState(!0, pt.zOffset, !1, ft, pt.cullBackFaces, pt.stencil, pt.zOffsetUnits),
- this._internalMeshDataInfo._onBetweenPassObservable && this._internalMeshDataInfo._onBetweenPassObservable.notifyObservers(i)),
- this._processRendering(this, i, nt, ht, k, et, this._onBeforeDraw, this._internalMeshDataInfo._effectiveMaterial),
- this._internalMeshDataInfo._effectiveMaterial.unbind();
- for (var _t = 0, mt = b._afterRenderingMeshStage; _t < mt.length; _t++) {
- var st = mt[_t];
- st.action(this, i, k, nt)
- }
- return this._internalMeshDataInfo._onAfterRenderObservable && this._internalMeshDataInfo._onAfterRenderObservable.notifyObservers(this),
- _e && (_e.maxZ = $,
- b.updateTransformMatrix(!0)),
- this
- }
- ,
- e.prototype._onBeforeDraw = function(i, o, s) {
- i && s && s.bindOnlyWorldMatrix(o)
- }
- ,
- e.prototype.cleanMatrixWeights = function() {
- this.isVerticesDataPresent(VertexBuffer.MatricesWeightsKind) && (this.isVerticesDataPresent(VertexBuffer.MatricesWeightsExtraKind) ? this.normalizeSkinWeightsAndExtra() : this.normalizeSkinFourWeights())
- }
- ,
- e.prototype.normalizeSkinFourWeights = function() {
- for (var i = this.getVerticesData(VertexBuffer.MatricesWeightsKind), o = i.length, s = 0; s < o; s += 4) {
- var c = i[s] + i[s + 1] + i[s + 2] + i[s + 3];
- if (c === 0)
- i[s] = 1;
- else {
- var d = 1 / c;
- i[s] *= d,
- i[s + 1] *= d,
- i[s + 2] *= d,
- i[s + 3] *= d
- }
- }
- this.setVerticesData(VertexBuffer.MatricesWeightsKind, i)
- }
- ,
- e.prototype.normalizeSkinWeightsAndExtra = function() {
- for (var i = this.getVerticesData(VertexBuffer.MatricesWeightsExtraKind), o = this.getVerticesData(VertexBuffer.MatricesWeightsKind), s = o.length, c = 0; c < s; c += 4) {
- var d = o[c] + o[c + 1] + o[c + 2] + o[c + 3];
- if (d += i[c] + i[c + 1] + i[c + 2] + i[c + 3],
- d === 0)
- o[c] = 1;
- else {
- var _ = 1 / d;
- o[c] *= _,
- o[c + 1] *= _,
- o[c + 2] *= _,
- o[c + 3] *= _,
- i[c] *= _,
- i[c + 1] *= _,
- i[c + 2] *= _,
- i[c + 3] *= _
- }
- }
- this.setVerticesData(VertexBuffer.MatricesWeightsKind, o),
- this.setVerticesData(VertexBuffer.MatricesWeightsKind, i)
- }
- ,
- e.prototype.validateSkinning = function() {
- var i = this.getVerticesData(VertexBuffer.MatricesWeightsExtraKind)
- , o = this.getVerticesData(VertexBuffer.MatricesWeightsKind);
- if (o === null || this.skeleton == null)
- return {
- skinned: !1,
- valid: !0,
- report: "not skinned"
- };
- for (var s = o.length, c = 0, d = 0, _ = 0, b = 0, k = i === null ? 4 : 8, j = new Array, $ = 0; $ <= k; $++)
- j[$] = 0;
- for (var _e = .001, $ = 0; $ < s; $ += 4) {
- for (var et = o[$], tt = et, rt = tt === 0 ? 0 : 1, it = 1; it < k; it++) {
- var nt = it < 4 ? o[$ + it] : i[$ + it - 4];
- nt > et && c++,
- nt !== 0 && rt++,
- tt += nt,
- et = nt
- }
- if (j[rt]++,
- rt > _ && (_ = rt),
- tt === 0)
- d++;
- else {
- var ot = 1 / tt
- , at = 0;
- for (it = 0; it < k; it++)
- it < 4 ? at += Math.abs(o[$ + it] - o[$ + it] * ot) : at += Math.abs(i[$ + it - 4] - i[$ + it - 4] * ot);
- at > _e && b++
- }
- }
- for (var st = this.skeleton.bones.length, ut = this.getVerticesData(VertexBuffer.MatricesIndicesKind), ct = this.getVerticesData(VertexBuffer.MatricesIndicesExtraKind), lt = 0, $ = 0; $ < s; $ += 4)
- for (var it = 0; it < k; it++) {
- var ft = it < 4 ? ut[$ + it] : ct[$ + it - 4];
- (ft >= st || ft < 0) && lt++
- }
- var ht = "Number of Weights = " + s / 4 + `
- Maximum influences = ` + _ + `
- Missing Weights = ` + d + `
- Not Sorted = ` + c + `
- Not Normalized = ` + b + `
- WeightCounts = [` + j + `]
- Number of bones = ` + st + `
- Bad Bone Indices = ` + lt;
- return {
- skinned: !0,
- valid: d === 0 && b === 0 && lt === 0,
- report: ht
- }
- }
- ,
- e.prototype._checkDelayState = function() {
- var i = this.getScene();
- return this._geometry ? this._geometry.load(i) : this.delayLoadState === 4 && (this.delayLoadState = 2,
- this._queueLoad(i)),
- this
- }
- ,
- e.prototype._queueLoad = function(i) {
- var o = this;
- i._addPendingData(this);
- var s = this.delayLoadingFile.indexOf(".babylonbinarymeshdata") !== -1;
- return Tools.LoadFile(this.delayLoadingFile, function(c) {
- c instanceof ArrayBuffer ? o._delayLoadingFunction(c, o) : o._delayLoadingFunction(JSON.parse(c), o),
- o.instances.forEach(function(d) {
- d.refreshBoundingInfo(),
- d._syncSubMeshes()
- }),
- o.delayLoadState = 1,
- i._removePendingData(o)
- }, function() {}, i.offlineProvider, s),
- this
- }
- ,
- e.prototype.isInFrustum = function(i) {
- return this.delayLoadState === 2 || !a.prototype.isInFrustum.call(this, i) ? !1 : (this._checkDelayState(),
- !0)
- }
- ,
- e.prototype.setMaterialById = function(i) {
- var o = this.getScene().materials, s;
- for (s = o.length - 1; s > -1; s--)
- if (o[s].id === i)
- return this.material = o[s],
- this;
- var c = this.getScene().multiMaterials;
- for (s = c.length - 1; s > -1; s--)
- if (c[s].id === i)
- return this.material = c[s],
- this;
- return this
- }
- ,
- e.prototype.getAnimatables = function() {
- var i = new Array;
- return this.material && i.push(this.material),
- this.skeleton && i.push(this.skeleton),
- i
- }
- ,
- e.prototype.bakeTransformIntoVertices = function(i) {
- if (!this.isVerticesDataPresent(VertexBuffer.PositionKind))
- return this;
- var o = this.subMeshes.splice(0);
- this._resetPointsArrayCache();
- var s = this.getVerticesData(VertexBuffer.PositionKind), c = new Array, d;
- for (d = 0; d < s.length; d += 3)
- Vector3.TransformCoordinates(Vector3.FromArray(s, d), i).toArray(c, d);
- if (this.setVerticesData(VertexBuffer.PositionKind, c, this.getVertexBuffer(VertexBuffer.PositionKind).isUpdatable()),
- this.isVerticesDataPresent(VertexBuffer.NormalKind)) {
- for (s = this.getVerticesData(VertexBuffer.NormalKind),
- c = [],
- d = 0; d < s.length; d += 3)
- Vector3.TransformNormal(Vector3.FromArray(s, d), i).normalize().toArray(c, d);
- this.setVerticesData(VertexBuffer.NormalKind, c, this.getVertexBuffer(VertexBuffer.NormalKind).isUpdatable())
- }
- return i.determinant() < 0 && this.flipFaces(),
- this.releaseSubMeshes(),
- this.subMeshes = o,
- this
- }
- ,
- e.prototype.bakeCurrentTransformIntoVertices = function(i) {
- return i === void 0 && (i = !0),
- this.bakeTransformIntoVertices(this.computeWorldMatrix(!0)),
- this.resetLocalMatrix(i),
- this
- }
- ,
- Object.defineProperty(e.prototype, "_positions", {
- get: function() {
- return this._internalAbstractMeshDataInfo._positions ? this._internalAbstractMeshDataInfo._positions : this._geometry ? this._geometry._positions : null
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._resetPointsArrayCache = function() {
- return this._geometry && this._geometry._resetPointsArrayCache(),
- this
- }
- ,
- e.prototype._generatePointsArray = function() {
- return this._geometry ? this._geometry._generatePointsArray() : !1
- }
- ,
- e.prototype.clone = function(i, o, s, c) {
- return i === void 0 && (i = ""),
- o === void 0 && (o = null),
- c === void 0 && (c = !0),
- new e(i,this.getScene(),o,this,s,c)
- }
- ,
- e.prototype.dispose = function(i, o) {
- o === void 0 && (o = !1),
- this.morphTargetManager = null,
- this._geometry && this._geometry.releaseForMesh(this, !0);
- var s = this._internalMeshDataInfo;
- if (s._onBeforeDrawObservable && s._onBeforeDrawObservable.clear(),
- s._onBeforeBindObservable && s._onBeforeBindObservable.clear(),
- s._onBeforeRenderObservable && s._onBeforeRenderObservable.clear(),
- s._onAfterRenderObservable && s._onAfterRenderObservable.clear(),
- s._onBetweenPassObservable && s._onBetweenPassObservable.clear(),
- this._scene.useClonedMeshMap) {
- if (s.meshMap)
- for (var c in s.meshMap) {
- var d = s.meshMap[c];
- d && (d._internalMeshDataInfo._source = null,
- s.meshMap[c] = void 0)
- }
- s._source && s._source._internalMeshDataInfo.meshMap && (s._source._internalMeshDataInfo.meshMap[this.uniqueId] = void 0)
- } else
- for (var _ = this.getScene().meshes, b = 0, k = _; b < k.length; b++) {
- var j = k[b]
- , d = j;
- d._internalMeshDataInfo && d._internalMeshDataInfo._source && d._internalMeshDataInfo._source === this && (d._internalMeshDataInfo._source = null)
- }
- s._source = null,
- this._disposeInstanceSpecificData(),
- this._disposeThinInstanceSpecificData(),
- this._internalMeshDataInfo._checkReadinessObserver && this._scene.onBeforeRenderObservable.remove(this._internalMeshDataInfo._checkReadinessObserver),
- a.prototype.dispose.call(this, i, o)
- }
- ,
- e.prototype._disposeInstanceSpecificData = function() {}
- ,
- e.prototype._disposeThinInstanceSpecificData = function() {}
- ,
- e.prototype._invalidateInstanceVertexArrayObject = function() {}
- ,
- e.prototype.applyDisplacementMap = function(i, o, s, c, d, _, b) {
- var k = this;
- b === void 0 && (b = !1);
- var j = this.getScene()
- , $ = function(_e) {
- var et = _e.width
- , tt = _e.height
- , rt = k.getEngine().createCanvas(et, tt)
- , it = rt.getContext("2d");
- it.drawImage(_e, 0, 0);
- var nt = it.getImageData(0, 0, et, tt).data;
- k.applyDisplacementMapFromBuffer(nt, et, tt, o, s, d, _, b),
- c && c(k)
- };
- return Tools.LoadImage(i, $, function() {}, j.offlineProvider),
- this
- }
- ,
- e.prototype.applyDisplacementMapFromBuffer = function(i, o, s, c, d, _, b, k) {
- if (k === void 0 && (k = !1),
- !this.isVerticesDataPresent(VertexBuffer.PositionKind) || !this.isVerticesDataPresent(VertexBuffer.NormalKind) || !this.isVerticesDataPresent(VertexBuffer.UVKind))
- return Logger$2.Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing"),
- this;
- var j = this.getVerticesData(VertexBuffer.PositionKind, !0, !0)
- , $ = this.getVerticesData(VertexBuffer.NormalKind)
- , _e = this.getVerticesData(VertexBuffer.UVKind)
- , et = Vector3.Zero()
- , tt = Vector3.Zero()
- , rt = Vector2.Zero();
- _ = _ || Vector2.Zero(),
- b = b || new Vector2(1,1);
- for (var it = 0; it < j.length; it += 3) {
- Vector3.FromArrayToRef(j, it, et),
- Vector3.FromArrayToRef($, it, tt),
- Vector2.FromArrayToRef(_e, it / 3 * 2, rt);
- var nt = Math.abs(rt.x * b.x + _.x % 1) * (o - 1) % o | 0
- , ot = Math.abs(rt.y * b.y + _.y % 1) * (s - 1) % s | 0
- , at = (nt + ot * o) * 4
- , st = i[at] / 255
- , ut = i[at + 1] / 255
- , ct = i[at + 2] / 255
- , lt = st * .3 + ut * .59 + ct * .11;
- tt.normalize(),
- tt.scaleInPlace(c + (d - c) * lt),
- et = et.add(tt),
- et.toArray(j, it)
- }
- return VertexData.ComputeNormals(j, this.getIndices(), $),
- k ? (this.setVerticesData(VertexBuffer.PositionKind, j),
- this.setVerticesData(VertexBuffer.NormalKind, $),
- this.setVerticesData(VertexBuffer.UVKind, _e)) : (this.updateVerticesData(VertexBuffer.PositionKind, j),
- this.updateVerticesData(VertexBuffer.NormalKind, $)),
- this
- }
- ,
- e.prototype.convertToFlatShadedMesh = function() {
- var i = this.getVerticesDataKinds(), o = {}, s = {}, c = {}, d = !1, _, b;
- for (_ = 0; _ < i.length; _++) {
- b = i[_];
- var k = this.getVertexBuffer(b);
- if (b === VertexBuffer.NormalKind) {
- d = k.isUpdatable(),
- i.splice(_, 1),
- _--;
- continue
- }
- o[b] = k,
- s[b] = this.getVerticesData(b),
- c[b] = []
- }
- var j = this.subMeshes.slice(0), $ = this.getIndices(), _e = this.getTotalIndices(), et;
- for (et = 0; et < _e; et++) {
- var tt = $[et];
- for (_ = 0; _ < i.length; _++) {
- b = i[_];
- for (var rt = o[b].getStrideSize(), it = 0; it < rt; it++)
- c[b].push(s[b][tt * rt + it])
- }
- }
- var nt = [], ot = c[VertexBuffer.PositionKind], at = this.getScene().useRightHandedSystem, st;
- for (at ? st = this.overrideMaterialSideOrientation === 1 : st = this.overrideMaterialSideOrientation === 0,
- et = 0; et < _e; et += 3) {
- $[et] = et,
- $[et + 1] = et + 1,
- $[et + 2] = et + 2;
- var ut = Vector3.FromArray(ot, et * 3)
- , ct = Vector3.FromArray(ot, (et + 1) * 3)
- , lt = Vector3.FromArray(ot, (et + 2) * 3)
- , ft = ut.subtract(ct)
- , ht = lt.subtract(ct)
- , pt = Vector3.Normalize(Vector3.Cross(ft, ht));
- st && pt.scaleInPlace(-1);
- for (var dt = 0; dt < 3; dt++)
- nt.push(pt.x),
- nt.push(pt.y),
- nt.push(pt.z)
- }
- for (this.setIndices($),
- this.setVerticesData(VertexBuffer.NormalKind, nt, d),
- _ = 0; _ < i.length; _++)
- b = i[_],
- this.setVerticesData(b, c[b], o[b].isUpdatable());
- this.releaseSubMeshes();
- for (var _t = 0; _t < j.length; _t++) {
- var mt = j[_t];
- SubMesh.AddToMesh(mt.materialIndex, mt.indexStart, mt.indexCount, mt.indexStart, mt.indexCount, this)
- }
- return this.synchronizeInstances(),
- this
- }
- ,
- e.prototype.convertToUnIndexedMesh = function() {
- var i = this.getVerticesDataKinds(), o = {}, s = {}, c = {}, d, _;
- for (d = 0; d < i.length; d++) {
- _ = i[d];
- var b = this.getVertexBuffer(_);
- o[_] = b,
- s[_] = o[_].getData(),
- c[_] = []
- }
- var k = this.subMeshes.slice(0), j = this.getIndices(), $ = this.getTotalIndices(), _e;
- for (_e = 0; _e < $; _e++) {
- var et = j[_e];
- for (d = 0; d < i.length; d++) {
- _ = i[d];
- for (var tt = o[_].getStrideSize(), rt = 0; rt < tt; rt++)
- c[_].push(s[_][et * tt + rt])
- }
- }
- for (_e = 0; _e < $; _e += 3)
- j[_e] = _e,
- j[_e + 1] = _e + 1,
- j[_e + 2] = _e + 2;
- for (this.setIndices(j),
- d = 0; d < i.length; d++)
- _ = i[d],
- this.setVerticesData(_, c[_], o[_].isUpdatable());
- this.releaseSubMeshes();
- for (var it = 0; it < k.length; it++) {
- var nt = k[it];
- SubMesh.AddToMesh(nt.materialIndex, nt.indexStart, nt.indexCount, nt.indexStart, nt.indexCount, this)
- }
- return this._unIndexed = !0,
- this.synchronizeInstances(),
- this
- }
- ,
- e.prototype.flipFaces = function(i) {
- i === void 0 && (i = !1);
- var o = VertexData.ExtractFromMesh(this), s;
- if (i && this.isVerticesDataPresent(VertexBuffer.NormalKind) && o.normals)
- for (s = 0; s < o.normals.length; s++)
- o.normals[s] *= -1;
- if (o.indices) {
- var c;
- for (s = 0; s < o.indices.length; s += 3)
- c = o.indices[s + 1],
- o.indices[s + 1] = o.indices[s + 2],
- o.indices[s + 2] = c
- }
- return o.applyToMesh(this, this.isVertexBufferUpdatable(VertexBuffer.PositionKind)),
- this
- }
- ,
- e.prototype.increaseVertices = function(i) {
- var o = VertexData.ExtractFromMesh(this)
- , s = o.uvs && !Array.isArray(o.uvs) && Array.from ? Array.from(o.uvs) : o.uvs
- , c = o.indices && !Array.isArray(o.indices) && Array.from ? Array.from(o.indices) : o.indices
- , d = o.positions && !Array.isArray(o.positions) && Array.from ? Array.from(o.positions) : o.positions
- , _ = o.normals && !Array.isArray(o.normals) && Array.from ? Array.from(o.normals) : o.normals;
- if (!c || !d || !_ || !s)
- Logger$2.Warn("VertexData contains null entries");
- else {
- o.indices = c,
- o.positions = d,
- o.normals = _,
- o.uvs = s;
- for (var b = i + 1, k = new Array, j = 0; j < b + 1; j++)
- k[j] = new Array;
- 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) {
- nt[0] = c[j],
- nt[1] = c[j + 1],
- nt[2] = c[j + 2];
- for (var ct = 0; ct < 3; ct++)
- if ($ = nt[ct],
- _e = nt[(ct + 1) % 3],
- ot[$] === void 0 && ot[_e] === void 0 ? (ot[$] = new Array,
- ot[_e] = new Array) : (ot[$] === void 0 && (ot[$] = new Array),
- ot[_e] === void 0 && (ot[_e] = new Array)),
- ot[$][_e] === void 0 && ot[_e][$] === void 0) {
- ot[$][_e] = [],
- et.x = (d[3 * _e] - d[3 * $]) / b,
- et.y = (d[3 * _e + 1] - d[3 * $ + 1]) / b,
- et.z = (d[3 * _e + 2] - d[3 * $ + 2]) / b,
- tt.x = (_[3 * _e] - _[3 * $]) / b,
- tt.y = (_[3 * _e + 1] - _[3 * $ + 1]) / b,
- tt.z = (_[3 * _e + 2] - _[3 * $ + 2]) / b,
- rt.x = (s[2 * _e] - s[2 * $]) / b,
- rt.y = (s[2 * _e + 1] - s[2 * $ + 1]) / b,
- ot[$][_e].push($);
- for (var lt = 1; lt < b; lt++)
- ot[$][_e].push(d.length / 3),
- d[st] = d[3 * $] + lt * et.x,
- _[st++] = _[3 * $] + lt * tt.x,
- d[st] = d[3 * $ + 1] + lt * et.y,
- _[st++] = _[3 * $ + 1] + lt * tt.y,
- d[st] = d[3 * $ + 2] + lt * et.z,
- _[st++] = _[3 * $ + 2] + lt * tt.z,
- s[ut++] = s[2 * $] + lt * rt.x,
- s[ut++] = s[2 * $ + 1] + lt * rt.y;
- ot[$][_e].push(_e),
- ot[_e][$] = new Array,
- at = ot[$][_e].length;
- for (var ft = 0; ft < at; ft++)
- ot[_e][$][ft] = ot[$][_e][at - 1 - ft]
- }
- k[0][0] = c[j],
- k[1][0] = ot[c[j]][c[j + 1]][1],
- k[1][1] = ot[c[j]][c[j + 2]][1];
- for (var lt = 2; lt < b; lt++) {
- k[lt][0] = ot[c[j]][c[j + 1]][lt],
- k[lt][lt] = ot[c[j]][c[j + 2]][lt],
- et.x = (d[3 * k[lt][lt]] - d[3 * k[lt][0]]) / lt,
- et.y = (d[3 * k[lt][lt] + 1] - d[3 * k[lt][0] + 1]) / lt,
- et.z = (d[3 * k[lt][lt] + 2] - d[3 * k[lt][0] + 2]) / lt,
- tt.x = (_[3 * k[lt][lt]] - _[3 * k[lt][0]]) / lt,
- tt.y = (_[3 * k[lt][lt] + 1] - _[3 * k[lt][0] + 1]) / lt,
- tt.z = (_[3 * k[lt][lt] + 2] - _[3 * k[lt][0] + 2]) / lt,
- rt.x = (s[2 * k[lt][lt]] - s[2 * k[lt][0]]) / lt,
- rt.y = (s[2 * k[lt][lt] + 1] - s[2 * k[lt][0] + 1]) / lt;
- for (var ct = 1; ct < lt; ct++)
- k[lt][ct] = d.length / 3,
- d[st] = d[3 * k[lt][0]] + ct * et.x,
- _[st++] = _[3 * k[lt][0]] + ct * tt.x,
- d[st] = d[3 * k[lt][0] + 1] + ct * et.y,
- _[st++] = _[3 * k[lt][0] + 1] + ct * tt.y,
- d[st] = d[3 * k[lt][0] + 2] + ct * et.z,
- _[st++] = _[3 * k[lt][0] + 2] + ct * tt.z,
- s[ut++] = s[2 * k[lt][0]] + ct * rt.x,
- s[ut++] = s[2 * k[lt][0] + 1] + ct * rt.y
- }
- k[b] = ot[c[j + 1]][c[j + 2]],
- it.push(k[0][0], k[1][0], k[1][1]);
- for (var lt = 1; lt < b; lt++) {
- for (var ct = 0; ct < lt; ct++)
- it.push(k[lt][ct], k[lt + 1][ct], k[lt + 1][ct + 1]),
- it.push(k[lt][ct], k[lt + 1][ct + 1], k[lt][ct + 1]);
- it.push(k[lt][ct], k[lt + 1][ct], k[lt + 1][ct + 1])
- }
- }
- o.indices = it,
- o.applyToMesh(this, this.isVertexBufferUpdatable(VertexBuffer.PositionKind))
- }
- }
- ,
- e.prototype.forceSharedVertices = function() {
- var i = VertexData.ExtractFromMesh(this)
- , o = i.uvs
- , s = i.indices
- , c = i.positions
- , d = i.colors;
- if (s === void 0 || c === void 0 || s === null || c === null)
- Logger$2.Warn("VertexData contains empty entries");
- else {
- 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) {
- rt = [s[it], s[it + 1], s[it + 2]],
- $ = new Array;
- for (var nt = 0; nt < 3; nt++) {
- $[nt] = "";
- for (var ot = 0; ot < 3; ot++)
- Math.abs(c[3 * rt[nt] + ot]) < 1e-8 && (c[3 * rt[nt] + ot] = 0),
- $[nt] += c[3 * rt[nt] + ot] + "|"
- }
- if (!($[0] == $[1] || $[0] == $[2] || $[1] == $[2]))
- for (var nt = 0; nt < 3; nt++) {
- if (tt = et[$[nt]],
- tt === void 0) {
- et[$[nt]] = _e,
- tt = _e++;
- for (var ot = 0; ot < 3; ot++)
- _.push(c[3 * rt[nt] + ot]);
- if (d != null)
- for (var ot = 0; ot < 4; ot++)
- j.push(d[4 * rt[nt] + ot]);
- if (o != null)
- for (var ot = 0; ot < 2; ot++)
- k.push(o[2 * rt[nt] + ot])
- }
- b.push(tt)
- }
- }
- var at = new Array;
- VertexData.ComputeNormals(_, b, at),
- i.positions = _,
- i.indices = b,
- i.normals = at,
- o != null && (i.uvs = k),
- d != null && (i.colors = j),
- i.applyToMesh(this, this.isVertexBufferUpdatable(VertexBuffer.PositionKind))
- }
- }
- ,
- e._instancedMeshFactory = function(i, o) {
- throw _WarnImport("InstancedMesh")
- }
- ,
- e._PhysicsImpostorParser = function(i, o, s) {
- throw _WarnImport("PhysicsImpostor")
- }
- ,
- e.prototype.createInstance = function(i) {
- return e._instancedMeshFactory(i, this)
- }
- ,
- e.prototype.synchronizeInstances = function() {
- for (var i = 0; i < this.instances.length; i++) {
- var o = this.instances[i];
- o._syncSubMeshes()
- }
- return this
- }
- ,
- e.prototype.optimizeIndices = function(i) {
- var o = this
- , s = this.getIndices()
- , c = this.getVerticesData(VertexBuffer.PositionKind);
- if (!c || !s)
- return this;
- for (var d = new Array, _ = 0; _ < c.length; _ = _ + 3)
- d.push(Vector3.FromArray(c, _));
- var b = new Array;
- return AsyncLoop.SyncAsyncForLoop(d.length, 40, function(k) {
- for (var j = d.length - 1 - k, $ = d[j], _e = 0; _e < j; ++_e) {
- var et = d[_e];
- if ($.equals(et)) {
- b[j] = _e;
- break
- }
- }
- }, function() {
- for (var k = 0; k < s.length; ++k)
- s[k] = b[s[k]] || s[k];
- var j = o.subMeshes.slice(0);
- o.setIndices(s),
- o.subMeshes = j,
- i && i(o)
- }),
- this
- }
- ,
- e.prototype.serialize = function(i) {
- i.name = this.name,
- i.id = this.id,
- i.uniqueId = this.uniqueId,
- i.type = this.getClassName(),
- Tags && Tags.HasTags(this) && (i.tags = Tags.GetTags(this)),
- i.position = this.position.asArray(),
- this.rotationQuaternion ? i.rotationQuaternion = this.rotationQuaternion.asArray() : this.rotation && (i.rotation = this.rotation.asArray()),
- i.scaling = this.scaling.asArray(),
- this._postMultiplyPivotMatrix ? i.pivotMatrix = this.getPivotMatrix().asArray() : i.localMatrix = this.getPivotMatrix().asArray(),
- i.isEnabled = this.isEnabled(!1),
- i.isVisible = this.isVisible,
- i.infiniteDistance = this.infiniteDistance,
- i.pickable = this.isPickable,
- i.receiveShadows = this.receiveShadows,
- i.billboardMode = this.billboardMode,
- i.visibility = this.visibility,
- i.checkCollisions = this.checkCollisions,
- i.isBlocker = this.isBlocker,
- i.overrideMaterialSideOrientation = this.overrideMaterialSideOrientation,
- this.parent && (i.parentId = this.parent.uniqueId),
- i.isUnIndexed = this.isUnIndexed;
- var o = this._geometry;
- if (o && this.subMeshes) {
- i.geometryUniqueId = o.uniqueId,
- i.geometryId = o.id,
- i.subMeshes = [];
- for (var s = 0; s < this.subMeshes.length; s++) {
- var c = this.subMeshes[s];
- i.subMeshes.push({
- materialIndex: c.materialIndex,
- verticesStart: c.verticesStart,
- verticesCount: c.verticesCount,
- indexStart: c.indexStart,
- indexCount: c.indexCount
- })
- }
- }
- if (this.material ? this.material.doNotSerialize || (i.materialId = this.material.id) : (this.material = null,
- i.materialId = this._scene.defaultMaterial.id),
- this.morphTargetManager && (i.morphTargetManagerId = this.morphTargetManager.uniqueId),
- this.skeleton && (i.skeletonId = this.skeleton.id,
- i.numBoneInfluencers = this.numBoneInfluencers),
- this.getScene()._getComponent(SceneComponentConstants.NAME_PHYSICSENGINE)) {
- var d = this.getPhysicsImpostor();
- d && (i.physicsMass = d.getParam("mass"),
- i.physicsFriction = d.getParam("friction"),
- i.physicsRestitution = d.getParam("mass"),
- i.physicsImpostor = d.type)
- }
- this.metadata && (i.metadata = this.metadata),
- i.instances = [];
- for (var _ = 0; _ < this.instances.length; _++) {
- var b = this.instances[_];
- if (!b.doNotSerialize) {
- var k = {
- name: b.name,
- id: b.id,
- isEnabled: b.isEnabled(!1),
- isVisible: b.isVisible,
- isPickable: b.isPickable,
- checkCollisions: b.checkCollisions,
- position: b.position.asArray(),
- scaling: b.scaling.asArray()
- };
- if (b.parent && (k.parentId = b.parent.uniqueId),
- b.rotationQuaternion ? k.rotationQuaternion = b.rotationQuaternion.asArray() : b.rotation && (k.rotation = b.rotation.asArray()),
- this.getScene()._getComponent(SceneComponentConstants.NAME_PHYSICSENGINE)) {
- var d = b.getPhysicsImpostor();
- d && (k.physicsMass = d.getParam("mass"),
- k.physicsFriction = d.getParam("friction"),
- k.physicsRestitution = d.getParam("mass"),
- k.physicsImpostor = d.type)
- }
- b.metadata && (k.metadata = b.metadata),
- i.instances.push(k),
- SerializationHelper.AppendSerializedAnimations(b, k),
- k.ranges = b.serializeAnimationRanges()
- }
- }
- if (this._thinInstanceDataStorage.instancesCount && this._thinInstanceDataStorage.matrixData && (i.thinInstances = {
- instancesCount: this._thinInstanceDataStorage.instancesCount,
- matrixData: Tools.SliceToArray(this._thinInstanceDataStorage.matrixData),
- matrixBufferSize: this._thinInstanceDataStorage.matrixBufferSize,
- enablePicking: this.thinInstanceEnablePicking
- },
- this._userThinInstanceBuffersStorage)) {
- var j = {
- data: {},
- sizes: {},
- strides: {}
- };
- for (var $ in this._userThinInstanceBuffersStorage.data)
- j.data[$] = Tools.SliceToArray(this._userThinInstanceBuffersStorage.data[$]),
- j.sizes[$] = this._userThinInstanceBuffersStorage.sizes[$],
- j.strides[$] = this._userThinInstanceBuffersStorage.strides[$];
- i.thinInstances.userThinInstance = j
- }
- SerializationHelper.AppendSerializedAnimations(this, i),
- i.ranges = this.serializeAnimationRanges(),
- i.layerMask = this.layerMask,
- i.alphaIndex = this.alphaIndex,
- i.hasVertexAlpha = this.hasVertexAlpha,
- i.overlayAlpha = this.overlayAlpha,
- i.overlayColor = this.overlayColor.asArray(),
- i.renderOverlay = this.renderOverlay,
- i.applyFog = this.applyFog,
- this.actionManager && (i.actions = this.actionManager.serialize(this.name))
- }
- ,
- e.prototype._syncGeometryWithMorphTargetManager = function() {
- if (!!this.geometry) {
- this._markSubMeshesAsAttributesDirty();
- var i = this._internalAbstractMeshDataInfo._morphTargetManager;
- if (i && i.vertexCount) {
- if (i.vertexCount !== this.getTotalVertices()) {
- Logger$2.Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count."),
- this.morphTargetManager = null;
- return
- }
- if (i.isUsingTextureForTargets)
- return;
- for (var o = 0; o < i.numInfluencers; o++) {
- var s = i.getActiveTarget(o)
- , c = s.getPositions();
- if (!c) {
- Logger$2.Error("Invalid morph target. Target must have positions.");
- return
- }
- this.geometry.setVerticesData(VertexBuffer.PositionKind + o, c, !1, 3);
- var d = s.getNormals();
- d && this.geometry.setVerticesData(VertexBuffer.NormalKind + o, d, !1, 3);
- var _ = s.getTangents();
- _ && this.geometry.setVerticesData(VertexBuffer.TangentKind + o, _, !1, 3);
- var b = s.getUVs();
- b && this.geometry.setVerticesData(VertexBuffer.UVKind + "_" + o, b, !1, 2)
- }
- } else
- for (var o = 0; this.geometry.isVerticesDataPresent(VertexBuffer.PositionKind + o); )
- this.geometry.removeVerticesData(VertexBuffer.PositionKind + o),
- this.geometry.isVerticesDataPresent(VertexBuffer.NormalKind + o) && this.geometry.removeVerticesData(VertexBuffer.NormalKind + o),
- this.geometry.isVerticesDataPresent(VertexBuffer.TangentKind + o) && this.geometry.removeVerticesData(VertexBuffer.TangentKind + o),
- this.geometry.isVerticesDataPresent(VertexBuffer.UVKind + o) && this.geometry.removeVerticesData(VertexBuffer.UVKind + "_" + o),
- o++
- }
- }
- ,
- e.Parse = function(i, o, s) {
- var c;
- 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),
- c.id = i.id,
- Tags && Tags.AddTagsTo(c, i.tags),
- c.position = Vector3.FromArray(i.position),
- i.metadata !== void 0 && (c.metadata = i.metadata),
- i.rotationQuaternion ? c.rotationQuaternion = Quaternion.FromArray(i.rotationQuaternion) : i.rotation && (c.rotation = Vector3.FromArray(i.rotation)),
- c.scaling = Vector3.FromArray(i.scaling),
- i.localMatrix ? c.setPreTransformMatrix(Matrix.FromArray(i.localMatrix)) : i.pivotMatrix && c.setPivotMatrix(Matrix.FromArray(i.pivotMatrix)),
- c.setEnabled(i.isEnabled),
- c.isVisible = i.isVisible,
- c.infiniteDistance = i.infiniteDistance,
- c.showBoundingBox = i.showBoundingBox,
- c.showSubMeshesBoundingBox = i.showSubMeshesBoundingBox,
- i.applyFog !== void 0 && (c.applyFog = i.applyFog),
- i.pickable !== void 0 && (c.isPickable = i.pickable),
- i.alphaIndex !== void 0 && (c.alphaIndex = i.alphaIndex),
- c.receiveShadows = i.receiveShadows,
- c.billboardMode = i.billboardMode,
- i.visibility !== void 0 && (c.visibility = i.visibility),
- c.checkCollisions = i.checkCollisions,
- c.overrideMaterialSideOrientation = i.overrideMaterialSideOrientation,
- i.isBlocker !== void 0 && (c.isBlocker = i.isBlocker),
- c._shouldGenerateFlatShading = i.useFlatShading,
- i.freezeWorldMatrix && (c._waitingData.freezeWorldMatrix = i.freezeWorldMatrix),
- i.parentId && (c._waitingParentId = i.parentId),
- i.actions !== void 0 && (c._waitingData.actions = i.actions),
- i.overlayAlpha !== void 0 && (c.overlayAlpha = i.overlayAlpha),
- i.overlayColor !== void 0 && (c.overlayColor = Color3.FromArray(i.overlayColor)),
- i.renderOverlay !== void 0 && (c.renderOverlay = i.renderOverlay),
- c.isUnIndexed = !!i.isUnIndexed,
- c.hasVertexAlpha = i.hasVertexAlpha,
- i.delayLoadingFile ? (c.delayLoadState = 4,
- c.delayLoadingFile = s + i.delayLoadingFile,
- c.buildBoundingInfo(Vector3.FromArray(i.boundingBoxMinimum), Vector3.FromArray(i.boundingBoxMaximum)),
- i._binaryInfo && (c._binaryInfo = i._binaryInfo),
- c._delayInfo = [],
- i.hasUVs && c._delayInfo.push(VertexBuffer.UVKind),
- i.hasUVs2 && c._delayInfo.push(VertexBuffer.UV2Kind),
- i.hasUVs3 && c._delayInfo.push(VertexBuffer.UV3Kind),
- i.hasUVs4 && c._delayInfo.push(VertexBuffer.UV4Kind),
- i.hasUVs5 && c._delayInfo.push(VertexBuffer.UV5Kind),
- i.hasUVs6 && c._delayInfo.push(VertexBuffer.UV6Kind),
- i.hasColors && c._delayInfo.push(VertexBuffer.ColorKind),
- i.hasMatricesIndices && c._delayInfo.push(VertexBuffer.MatricesIndicesKind),
- i.hasMatricesWeights && c._delayInfo.push(VertexBuffer.MatricesWeightsKind),
- c._delayLoadingFunction = Geometry._ImportGeometry,
- SceneLoaderFlags.ForceFullSceneLoadingForIncremental && c._checkDelayState()) : Geometry._ImportGeometry(i, c),
- i.materialId ? c.setMaterialById(i.materialId) : c.material = null,
- i.morphTargetManagerId > -1 && (c.morphTargetManager = o.getMorphTargetManagerById(i.morphTargetManagerId)),
- i.skeletonId !== void 0 && i.skeletonId !== null && (c.skeleton = o.getLastSkeletonById(i.skeletonId),
- i.numBoneInfluencers && (c.numBoneInfluencers = i.numBoneInfluencers)),
- i.animations) {
- for (var d = 0; d < i.animations.length; d++) {
- var _ = i.animations[d]
- , b = GetClass("BABYLON.Animation");
- b && c.animations.push(b.Parse(_))
- }
- Node$2.ParseAnimationRanges(c, i, o)
- }
- if (i.autoAnimate && o.beginAnimation(c, i.autoAnimateFrom, i.autoAnimateTo, i.autoAnimateLoop, i.autoAnimateSpeed || 1),
- i.layerMask && !isNaN(i.layerMask) ? c.layerMask = Math.abs(parseInt(i.layerMask)) : c.layerMask = 268435455,
- i.physicsImpostor && e._PhysicsImpostorParser(o, c, i),
- i.lodMeshIds && (c._waitingData.lods = {
- ids: i.lodMeshIds,
- distances: i.lodDistances ? i.lodDistances : null,
- coverages: i.lodCoverages ? i.lodCoverages : null
- }),
- i.instances)
- for (var k = 0; k < i.instances.length; k++) {
- var j = i.instances[k]
- , $ = c.createInstance(j.name);
- if (j.id && ($.id = j.id),
- Tags && (j.tags ? Tags.AddTagsTo($, j.tags) : Tags.AddTagsTo($, i.tags)),
- $.position = Vector3.FromArray(j.position),
- j.metadata !== void 0 && ($.metadata = j.metadata),
- j.parentId && ($._waitingParentId = j.parentId),
- j.isEnabled !== void 0 && j.isEnabled !== null && $.setEnabled(j.isEnabled),
- j.isVisible !== void 0 && j.isVisible !== null && ($.isVisible = j.isVisible),
- j.isPickable !== void 0 && j.isPickable !== null && ($.isPickable = j.isPickable),
- j.rotationQuaternion ? $.rotationQuaternion = Quaternion.FromArray(j.rotationQuaternion) : j.rotation && ($.rotation = Vector3.FromArray(j.rotation)),
- $.scaling = Vector3.FromArray(j.scaling),
- j.checkCollisions != null && j.checkCollisions != null && ($.checkCollisions = j.checkCollisions),
- j.pickable != null && j.pickable != null && ($.isPickable = j.pickable),
- j.showBoundingBox != null && j.showBoundingBox != null && ($.showBoundingBox = j.showBoundingBox),
- j.showSubMeshesBoundingBox != null && j.showSubMeshesBoundingBox != null && ($.showSubMeshesBoundingBox = j.showSubMeshesBoundingBox),
- j.alphaIndex != null && j.showSubMeshesBoundingBox != null && ($.alphaIndex = j.alphaIndex),
- j.physicsImpostor && e._PhysicsImpostorParser(o, $, j),
- j.animations) {
- for (d = 0; d < j.animations.length; d++) {
- _ = j.animations[d];
- var b = GetClass("BABYLON.Animation");
- b && $.animations.push(b.Parse(_))
- }
- Node$2.ParseAnimationRanges($, j, o),
- j.autoAnimate && o.beginAnimation($, j.autoAnimateFrom, j.autoAnimateTo, j.autoAnimateLoop, j.autoAnimateSpeed || 1)
- }
- }
- if (i.thinInstances) {
- var _e = i.thinInstances;
- if (c.thinInstanceEnablePicking = !!_e.enablePicking,
- _e.matrixData ? (c.thinInstanceSetBuffer("matrix", new Float32Array(_e.matrixData), 16, !1),
- c._thinInstanceDataStorage.matrixBufferSize = _e.matrixBufferSize,
- c._thinInstanceDataStorage.instancesCount = _e.instancesCount) : c._thinInstanceDataStorage.matrixBufferSize = _e.matrixBufferSize,
- i.thinInstances.userThinInstance) {
- var et = i.thinInstances.userThinInstance;
- for (var tt in et.data)
- c.thinInstanceSetBuffer(tt, new Float32Array(et.data[tt]), et.strides[tt], !1),
- c._userThinInstanceBuffersStorage.sizes[tt] = et.sizes[tt]
- }
- }
- return c
- }
- ,
- e.prototype.setPositionsForCPUSkinning = function() {
- var i = this._internalMeshDataInfo;
- if (!i._sourcePositions) {
- var o = this.getVerticesData(VertexBuffer.PositionKind);
- if (!o)
- return i._sourcePositions;
- i._sourcePositions = new Float32Array(o),
- this.isVertexBufferUpdatable(VertexBuffer.PositionKind) || this.setVerticesData(VertexBuffer.PositionKind, o, !0)
- }
- return i._sourcePositions
- }
- ,
- e.prototype.setNormalsForCPUSkinning = function() {
- var i = this._internalMeshDataInfo;
- if (!i._sourceNormals) {
- var o = this.getVerticesData(VertexBuffer.NormalKind);
- if (!o)
- return i._sourceNormals;
- i._sourceNormals = new Float32Array(o),
- this.isVertexBufferUpdatable(VertexBuffer.NormalKind) || this.setVerticesData(VertexBuffer.NormalKind, o, !0)
- }
- return i._sourceNormals
- }
- ,
- e.prototype.applySkeleton = function(i) {
- if (!this.geometry)
- return this;
- if (this.geometry._softwareSkinningFrameId == this.getScene().getFrameId())
- return this;
- if (this.geometry._softwareSkinningFrameId = this.getScene().getFrameId(),
- !this.isVerticesDataPresent(VertexBuffer.PositionKind))
- return this;
- if (!this.isVerticesDataPresent(VertexBuffer.MatricesIndicesKind))
- return this;
- if (!this.isVerticesDataPresent(VertexBuffer.MatricesWeightsKind))
- return this;
- var o = this.isVerticesDataPresent(VertexBuffer.NormalKind)
- , s = this._internalMeshDataInfo;
- if (!s._sourcePositions) {
- var c = this.subMeshes.slice();
- this.setPositionsForCPUSkinning(),
- this.subMeshes = c
- }
- o && !s._sourceNormals && this.setNormalsForCPUSkinning();
- var d = this.getVerticesData(VertexBuffer.PositionKind);
- if (!d)
- return this;
- d instanceof Float32Array || (d = new Float32Array(d));
- var _ = this.getVerticesData(VertexBuffer.NormalKind);
- if (o) {
- if (!_)
- return this;
- _ instanceof Float32Array || (_ = new Float32Array(_))
- }
- var b = this.getVerticesData(VertexBuffer.MatricesIndicesKind)
- , k = this.getVerticesData(VertexBuffer.MatricesWeightsKind);
- if (!k || !b)
- return this;
- 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,
- nt += 4) {
- var st;
- for (ot = 0; ot < 4; ot++)
- st = k[nt + ot],
- st > 0 && (Matrix.FromFloat32ArrayToRefScaled(et, Math.floor(b[nt + ot] * 16), st, it),
- rt.addToSelf(it));
- if (j)
- for (ot = 0; ot < 4; ot++)
- st = _e[nt + ot],
- st > 0 && (Matrix.FromFloat32ArrayToRefScaled(et, Math.floor($[nt + ot] * 16), st, it),
- rt.addToSelf(it));
- Vector3.TransformCoordinatesFromFloatsToRef(s._sourcePositions[at], s._sourcePositions[at + 1], s._sourcePositions[at + 2], rt, tt),
- tt.toArray(d, at),
- o && (Vector3.TransformNormalFromFloatsToRef(s._sourceNormals[at], s._sourceNormals[at + 1], s._sourceNormals[at + 2], rt, tt),
- tt.toArray(_, at)),
- rt.reset()
- }
- return this.updateVerticesData(VertexBuffer.PositionKind, d),
- o && this.updateVerticesData(VertexBuffer.NormalKind, _),
- this
- }
- ,
- e.MinMax = function(i) {
- var o = null
- , s = null;
- return i.forEach(function(c) {
- var d = c.getBoundingInfo()
- , _ = d.boundingBox;
- !o || !s ? (o = _.minimumWorld,
- s = _.maximumWorld) : (o.minimizeInPlace(_.minimumWorld),
- s.maximizeInPlace(_.maximumWorld))
- }),
- !o || !s ? {
- min: Vector3.Zero(),
- max: Vector3.Zero()
- } : {
- min: o,
- max: s
- }
- }
- ,
- e.Center = function(i) {
- var o = i instanceof Array ? e.MinMax(i) : i;
- return Vector3.Center(o.min, o.max)
- }
- ,
- e.MergeMeshes = function(i, o, s, c, d, _) {
- return o === void 0 && (o = !0),
- runCoroutineSync(e._MergeMeshesCoroutine(i, o, s, c, d, _, !1))
- }
- ,
- e.MergeMeshesAsync = function(i, o, s, c, d, _) {
- return o === void 0 && (o = !0),
- runCoroutineAsync(e._MergeMeshesCoroutine(i, o, s, c, d, _, !0), createYieldingScheduler())
- }
- ,
- e._MergeMeshesCoroutine = function(i, o, s, c, d, _, b) {
- var k, j, $, _e, et, tt, rt, it, nt, ot, at, st, ut, ct, lt, ft, ht, pt, dt, _t, mt, vt, yt, Et;
- return o === void 0 && (o = !0),
- __generator(this, function(At) {
- switch (At.label) {
- case 0:
- if (i = i.filter(Boolean),
- i.length === 0)
- return [2, null];
- if (!s) {
- for (j = 0,
- k = 0; k < i.length; k++)
- if (j += i[k].getTotalVertices(),
- j >= 65536)
- 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"),
- [2, null]
- }
- for (_ && ($ = null,
- d = !1),
- tt = new Array,
- rt = new Array,
- it = new Array,
- k = 0; k < i.length; k++) {
- if (nt = i[k],
- nt.isAnInstance)
- return Logger$2.Warn("Cannot merge instance meshes."),
- [2, null];
- if (d && it.push(nt.getTotalIndices()),
- _)
- if (nt.material)
- if (ot = nt.material,
- ot instanceof MultiMaterial) {
- for (et = 0; et < ot.subMaterials.length; et++)
- tt.indexOf(ot.subMaterials[et]) < 0 && tt.push(ot.subMaterials[et]);
- for (_e = 0; _e < nt.subMeshes.length; _e++)
- rt.push(tt.indexOf(ot.subMaterials[nt.subMeshes[_e].materialIndex])),
- it.push(nt.subMeshes[_e].indexCount)
- } else
- for (tt.indexOf(ot) < 0 && tt.push(ot),
- _e = 0; _e < nt.subMeshes.length; _e++)
- rt.push(tt.indexOf(ot)),
- it.push(nt.subMeshes[_e].indexCount);
- else
- for (_e = 0; _e < nt.subMeshes.length; _e++)
- rt.push(0),
- it.push(nt.subMeshes[_e].indexCount)
- }
- return at = i[0],
- st = function(gt) {
- var St = gt.computeWorldMatrix(!0)
- , xt = VertexData.ExtractFromMesh(gt, !0, !0);
- return xt.transform(St),
- xt
- }
- ,
- ut = st(at),
- b ? [4] : [3, 2];
- case 1:
- At.sent(),
- At.label = 2;
- case 2:
- ct = new Array(i.length - 1),
- lt = 1,
- At.label = 3;
- case 3:
- return lt < i.length ? (ct[lt - 1] = st(i[lt]),
- b ? [4] : [3, 5]) : [3, 6];
- case 4:
- At.sent(),
- At.label = 5;
- case 5:
- return lt++,
- [3, 3];
- case 6:
- ft = ut._mergeCoroutine(ct, s, b),
- ht = ft.next(),
- At.label = 7;
- case 7:
- return ht.done ? [3, 10] : b ? [4] : [3, 9];
- case 8:
- At.sent(),
- At.label = 9;
- case 9:
- return ht = ft.next(),
- [3, 7];
- case 10:
- pt = ht.value,
- c || (c = new e(at.name + "_merged",at.getScene())),
- dt = pt._applyToCoroutine(c, void 0, b),
- _t = dt.next(),
- At.label = 11;
- case 11:
- return _t.done ? [3, 14] : b ? [4] : [3, 13];
- case 12:
- At.sent(),
- At.label = 13;
- case 13:
- return _t = dt.next(),
- [3, 11];
- case 14:
- if (c.checkCollisions = at.checkCollisions,
- c.overrideMaterialSideOrientation = at.overrideMaterialSideOrientation,
- o)
- for (k = 0; k < i.length; k++)
- i[k].dispose();
- if (d || _) {
- for (c.releaseSubMeshes(),
- k = 0,
- mt = 0; k < it.length; )
- SubMesh.CreateFromIndices(0, mt, it[k], c, void 0, !1),
- mt += it[k],
- k++;
- for (vt = 0,
- yt = c.subMeshes; vt < yt.length; vt++)
- Et = yt[vt],
- Et.refreshBoundingInfo();
- c.computeWorldMatrix(!0)
- }
- if (_) {
- for ($ = new MultiMaterial(at.name + "_merged",at.getScene()),
- $.subMaterials = tt,
- _e = 0; _e < c.subMeshes.length; _e++)
- c.subMeshes[_e].materialIndex = rt[_e];
- c.material = $
- } else
- c.material = at.material;
- return [2, c]
- }
- })
- }
- ,
- e.prototype.addInstance = function(i) {
- i._indexInSourceMeshInstanceArray = this.instances.length,
- this.instances.push(i)
- }
- ,
- e.prototype.removeInstance = function(i) {
- var o = i._indexInSourceMeshInstanceArray;
- if (o != -1) {
- if (o !== this.instances.length - 1) {
- var s = this.instances[this.instances.length - 1];
- this.instances[o] = s,
- s._indexInSourceMeshInstanceArray = o
- }
- i._indexInSourceMeshInstanceArray = -1,
- this.instances.pop()
- }
- }
- ,
- e.FRONTSIDE = VertexData.FRONTSIDE,
- e.BACKSIDE = VertexData.BACKSIDE,
- e.DOUBLESIDE = VertexData.DOUBLESIDE,
- e.DEFAULTSIDE = VertexData.DEFAULTSIDE,
- e.NO_CAP = 0,
- e.CAP_START = 1,
- e.CAP_END = 2,
- e.CAP_ALL = 3,
- e.NO_FLIP = 0,
- e.FLIP_TILE = 1,
- e.ROTATE_TILE = 2,
- e.FLIP_ROW = 3,
- e.ROTATE_ROW = 4,
- e.FLIP_N_ROTATE_TILE = 5,
- e.FLIP_N_ROTATE_ROW = 6,
- e.CENTER = 0,
- e.LEFT = 1,
- e.RIGHT = 2,
- e.TOP = 3,
- e.BOTTOM = 4,
- e.INSTANCEDMESH_SORT_TRANSPARENT = !1,
- e._GroundMeshParser = function(i, o) {
- throw _WarnImport("GroundMesh")
- }
- ,
- e._LinesMeshParser = function(i, o) {
- throw _WarnImport("LinesMesh")
- }
- ,
- e
- }(AbstractMesh);
- RegisterClass("BABYLON.Mesh", Mesh);
- _injectLTSMesh(Mesh);
- var AutoRotationBehavior = function() {
- function a() {
- this._zoomStopsAnimation = !1,
- this._idleRotationSpeed = .05,
- this._idleRotationWaitTime = 2e3,
- this._idleRotationSpinupTime = 2e3,
- this._isPointerDown = !1,
- this._lastFrameTime = null,
- this._lastInteractionTime = -1 / 0,
- this._cameraRotationSpeed = 0,
- this._lastFrameRadius = 0
- }
- return Object.defineProperty(a.prototype, "name", {
- get: function() {
- return "AutoRotation"
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "zoomStopsAnimation", {
- get: function() {
- return this._zoomStopsAnimation
- },
- set: function(e) {
- this._zoomStopsAnimation = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "idleRotationSpeed", {
- get: function() {
- return this._idleRotationSpeed
- },
- set: function(e) {
- this._idleRotationSpeed = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "idleRotationWaitTime", {
- get: function() {
- return this._idleRotationWaitTime
- },
- set: function(e) {
- this._idleRotationWaitTime = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "idleRotationSpinupTime", {
- get: function() {
- return this._idleRotationSpinupTime
- },
- set: function(e) {
- this._idleRotationSpinupTime = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "rotationInProgress", {
- get: function() {
- return Math.abs(this._cameraRotationSpeed) > 0
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.init = function() {}
- ,
- a.prototype.attach = function(e) {
- var i = this;
- this._attachedCamera = e;
- var o = this._attachedCamera.getScene();
- this._onPrePointerObservableObserver = o.onPrePointerObservable.add(function(s) {
- if (s.type === PointerEventTypes.POINTERDOWN) {
- i._isPointerDown = !0;
- return
- }
- s.type === PointerEventTypes.POINTERUP && (i._isPointerDown = !1)
- }),
- this._onAfterCheckInputsObserver = e.onAfterCheckInputsObservable.add(function() {
- var s = PrecisionDate.Now
- , c = 0;
- i._lastFrameTime != null && (c = s - i._lastFrameTime),
- i._lastFrameTime = s,
- i._applyUserInteraction();
- var d = s - i._lastInteractionTime - i._idleRotationWaitTime
- , _ = Math.max(Math.min(d / i._idleRotationSpinupTime, 1), 0);
- i._cameraRotationSpeed = i._idleRotationSpeed * _,
- i._attachedCamera && (i._attachedCamera.alpha -= i._cameraRotationSpeed * (c / 1e3))
- })
- }
- ,
- a.prototype.detach = function() {
- if (!!this._attachedCamera) {
- var e = this._attachedCamera.getScene();
- this._onPrePointerObservableObserver && e.onPrePointerObservable.remove(this._onPrePointerObservableObserver),
- this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),
- this._attachedCamera = null
- }
- }
- ,
- a.prototype.resetLastInteractionTime = function(e) {
- this._lastInteractionTime = e != null ? e : PrecisionDate.Now
- }
- ,
- a.prototype._userIsZooming = function() {
- return this._attachedCamera ? this._attachedCamera.inertialRadiusOffset !== 0 : !1
- }
- ,
- a.prototype._shouldAnimationStopForInteraction = function() {
- if (!this._attachedCamera)
- return !1;
- var e = !1;
- return this._lastFrameRadius === this._attachedCamera.radius && this._attachedCamera.inertialRadiusOffset !== 0 && (e = !0),
- this._lastFrameRadius = this._attachedCamera.radius,
- this._zoomStopsAnimation ? e : this._userIsZooming()
- }
- ,
- a.prototype._applyUserInteraction = function() {
- this._userIsMoving() && !this._shouldAnimationStopForInteraction() && (this._lastInteractionTime = PrecisionDate.Now)
- }
- ,
- a.prototype._userIsMoving = function() {
- 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
- }
- ,
- a
- }()
- , EasingFunction = function() {
- function a() {
- this._easingMode = a.EASINGMODE_EASEIN
- }
- return a.prototype.setEasingMode = function(e) {
- var i = Math.min(Math.max(e, 0), 2);
- this._easingMode = i
- }
- ,
- a.prototype.getEasingMode = function() {
- return this._easingMode
- }
- ,
- a.prototype.easeInCore = function(e) {
- throw new Error("You must implement this method")
- }
- ,
- a.prototype.ease = function(e) {
- switch (this._easingMode) {
- case a.EASINGMODE_EASEIN:
- return this.easeInCore(e);
- case a.EASINGMODE_EASEOUT:
- return 1 - this.easeInCore(1 - e)
- }
- return e >= .5 ? (1 - this.easeInCore((1 - e) * 2)) * .5 + .5 : this.easeInCore(e * 2) * .5
- }
- ,
- a.EASINGMODE_EASEIN = 0,
- a.EASINGMODE_EASEOUT = 1,
- a.EASINGMODE_EASEINOUT = 2,
- a
- }()
- , CircleEase = function(a) {
- __extends(e, a);
- function e() {
- return a !== null && a.apply(this, arguments) || this
- }
- return e.prototype.easeInCore = function(i) {
- return i = Math.max(0, Math.min(1, i)),
- 1 - Math.sqrt(1 - i * i)
- }
- ,
- e
- }(EasingFunction)
- , BackEase = function(a) {
- __extends(e, a);
- function e(i) {
- i === void 0 && (i = 1);
- var o = a.call(this) || this;
- return o.amplitude = i,
- o
- }
- return e.prototype.easeInCore = function(i) {
- var o = Math.max(0, this.amplitude);
- return Math.pow(i, 3) - i * o * Math.sin(3.141592653589793 * i)
- }
- ,
- e
- }(EasingFunction);
- (function(a) {
- __extends(e, a);
- function e(i, o) {
- i === void 0 && (i = 3),
- o === void 0 && (o = 2);
- var s = a.call(this) || this;
- return s.bounces = i,
- s.bounciness = o,
- s
- }
- return e.prototype.easeInCore = function(i) {
- var o = Math.max(0, this.bounces)
- , s = this.bounciness;
- s <= 1 && (s = 1.001);
- var c = Math.pow(s, o)
- , d = 1 - s
- , _ = (1 - c) / d + c * .5
- , b = i * _
- , k = Math.log(-b * (1 - s) + 1) / Math.log(s)
- , j = Math.floor(k)
- , $ = j + 1
- , _e = (1 - Math.pow(s, j)) / (d * _)
- , et = (1 - Math.pow(s, $)) / (d * _)
- , tt = (_e + et) * .5
- , rt = i - tt
- , it = tt - _e;
- return -Math.pow(1 / s, o - j) / (it * it) * (rt - it) * (rt + it)
- }
- ,
- e
- }
- )(EasingFunction);
- (function(a) {
- __extends(e, a);
- function e() {
- return a !== null && a.apply(this, arguments) || this
- }
- return e.prototype.easeInCore = function(i) {
- return i * i * i
- }
- ,
- e
- }
- )(EasingFunction);
- (function(a) {
- __extends(e, a);
- function e(i, o) {
- i === void 0 && (i = 3),
- o === void 0 && (o = 3);
- var s = a.call(this) || this;
- return s.oscillations = i,
- s.springiness = o,
- s
- }
- return e.prototype.easeInCore = function(i) {
- var o, s = Math.max(0, this.oscillations), c = Math.max(0, this.springiness);
- return c == 0 ? o = i : o = (Math.exp(c * i) - 1) / (Math.exp(c) - 1),
- o * Math.sin((6.283185307179586 * s + 1.5707963267948966) * i)
- }
- ,
- e
- }
- )(EasingFunction);
- var ExponentialEase = function(a) {
- __extends(e, a);
- function e(i) {
- i === void 0 && (i = 2);
- var o = a.call(this) || this;
- return o.exponent = i,
- o
- }
- return e.prototype.easeInCore = function(i) {
- return this.exponent <= 0 ? i : (Math.exp(this.exponent * i) - 1) / (Math.exp(this.exponent) - 1)
- }
- ,
- e
- }(EasingFunction);
- (function(a) {
- __extends(e, a);
- function e(i) {
- i === void 0 && (i = 2);
- var o = a.call(this) || this;
- return o.power = i,
- o
- }
- return e.prototype.easeInCore = function(i) {
- var o = Math.max(0, this.power);
- return Math.pow(i, o)
- }
- ,
- e
- }
- )(EasingFunction);
- (function(a) {
- __extends(e, a);
- function e() {
- return a !== null && a.apply(this, arguments) || this
- }
- return e.prototype.easeInCore = function(i) {
- return i * i
- }
- ,
- e
- }
- )(EasingFunction);
- (function(a) {
- __extends(e, a);
- function e() {
- return a !== null && a.apply(this, arguments) || this
- }
- return e.prototype.easeInCore = function(i) {
- return i * i * i * i
- }
- ,
- e
- }
- )(EasingFunction);
- (function(a) {
- __extends(e, a);
- function e() {
- return a !== null && a.apply(this, arguments) || this
- }
- return e.prototype.easeInCore = function(i) {
- return i * i * i * i * i
- }
- ,
- e
- }
- )(EasingFunction);
- var SineEase = function(a) {
- __extends(e, a);
- function e() {
- return a !== null && a.apply(this, arguments) || this
- }
- return e.prototype.easeInCore = function(i) {
- return 1 - Math.sin(1.5707963267948966 * (1 - i))
- }
- ,
- e
- }(EasingFunction);
- (function(a) {
- __extends(e, a);
- function e(i, o, s, c) {
- i === void 0 && (i = 0),
- o === void 0 && (o = 0),
- s === void 0 && (s = 1),
- c === void 0 && (c = 1);
- var d = a.call(this) || this;
- return d.x1 = i,
- d.y1 = o,
- d.x2 = s,
- d.y2 = c,
- d
- }
- return e.prototype.easeInCore = function(i) {
- return BezierCurve.Interpolate(i, this.x1, this.y1, this.x2, this.y2)
- }
- ,
- e
- }
- )(EasingFunction);
- var BouncingBehavior = function() {
- function a() {
- this.transitionDuration = 450,
- this.lowerRadiusTransitionRange = 2,
- this.upperRadiusTransitionRange = -2,
- this._autoTransitionRange = !1,
- this._radiusIsAnimating = !1,
- this._radiusBounceTransition = null,
- this._animatables = new Array
- }
- return Object.defineProperty(a.prototype, "name", {
- get: function() {
- return "Bouncing"
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "autoTransitionRange", {
- get: function() {
- return this._autoTransitionRange
- },
- set: function(e) {
- var i = this;
- if (this._autoTransitionRange !== e) {
- this._autoTransitionRange = e;
- var o = this._attachedCamera;
- !o || (e ? this._onMeshTargetChangedObserver = o.onMeshTargetChangedObservable.add(function(s) {
- if (!!s) {
- s.computeWorldMatrix(!0);
- var c = s.getBoundingInfo().diagonalLength;
- i.lowerRadiusTransitionRange = c * .05,
- i.upperRadiusTransitionRange = c * .05
- }
- }) : this._onMeshTargetChangedObserver && o.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver))
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.init = function() {}
- ,
- a.prototype.attach = function(e) {
- var i = this;
- this._attachedCamera = e,
- this._onAfterCheckInputsObserver = e.onAfterCheckInputsObservable.add(function() {
- !i._attachedCamera || (i._isRadiusAtLimit(i._attachedCamera.lowerRadiusLimit) && i._applyBoundRadiusAnimation(i.lowerRadiusTransitionRange),
- i._isRadiusAtLimit(i._attachedCamera.upperRadiusLimit) && i._applyBoundRadiusAnimation(i.upperRadiusTransitionRange))
- })
- }
- ,
- a.prototype.detach = function() {
- !this._attachedCamera || (this._onAfterCheckInputsObserver && this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),
- this._onMeshTargetChangedObserver && this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),
- this._attachedCamera = null)
- }
- ,
- a.prototype._isRadiusAtLimit = function(e) {
- return this._attachedCamera ? this._attachedCamera.radius === e && !this._radiusIsAnimating : !1
- }
- ,
- a.prototype._applyBoundRadiusAnimation = function(e) {
- var i = this;
- if (!!this._attachedCamera) {
- this._radiusBounceTransition || (a.EasingFunction.setEasingMode(a.EasingMode),
- this._radiusBounceTransition = Animation.CreateAnimation("radius", Animation.ANIMATIONTYPE_FLOAT, 60, a.EasingFunction)),
- this._cachedWheelPrecision = this._attachedCamera.wheelPrecision,
- this._attachedCamera.wheelPrecision = 1 / 0,
- this._attachedCamera.inertialRadiusOffset = 0,
- this.stopAllAnimations(),
- this._radiusIsAnimating = !0;
- var o = Animation.TransitionTo("radius", this._attachedCamera.radius + e, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusBounceTransition, this.transitionDuration, function() {
- return i._clearAnimationLocks()
- });
- o && this._animatables.push(o)
- }
- }
- ,
- a.prototype._clearAnimationLocks = function() {
- this._radiusIsAnimating = !1,
- this._attachedCamera && (this._attachedCamera.wheelPrecision = this._cachedWheelPrecision)
- }
- ,
- a.prototype.stopAllAnimations = function() {
- for (this._attachedCamera && (this._attachedCamera.animations = []); this._animatables.length; )
- this._animatables[0].onAnimationEnd = null,
- this._animatables[0].stop(),
- this._animatables.shift()
- }
- ,
- a.EasingFunction = new BackEase(.3),
- a.EasingMode = EasingFunction.EASINGMODE_EASEOUT,
- a
- }()
- , FramingBehavior = function() {
- function a() {
- this.onTargetFramingAnimationEndObservable = new Observable,
- this._mode = a.FitFrustumSidesMode,
- this._radiusScale = 1,
- this._positionScale = .5,
- this._defaultElevation = .3,
- this._elevationReturnTime = 1500,
- this._elevationReturnWaitTime = 1e3,
- this._zoomStopsAnimation = !1,
- this._framingTime = 1500,
- this.autoCorrectCameraLimitsAndSensibility = !0,
- this._isPointerDown = !1,
- this._lastInteractionTime = -1 / 0,
- this._animatables = new Array,
- this._betaIsAnimating = !1
- }
- return Object.defineProperty(a.prototype, "name", {
- get: function() {
- return "Framing"
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "mode", {
- get: function() {
- return this._mode
- },
- set: function(e) {
- this._mode = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "radiusScale", {
- get: function() {
- return this._radiusScale
- },
- set: function(e) {
- this._radiusScale = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "positionScale", {
- get: function() {
- return this._positionScale
- },
- set: function(e) {
- this._positionScale = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "defaultElevation", {
- get: function() {
- return this._defaultElevation
- },
- set: function(e) {
- this._defaultElevation = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "elevationReturnTime", {
- get: function() {
- return this._elevationReturnTime
- },
- set: function(e) {
- this._elevationReturnTime = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "elevationReturnWaitTime", {
- get: function() {
- return this._elevationReturnWaitTime
- },
- set: function(e) {
- this._elevationReturnWaitTime = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "zoomStopsAnimation", {
- get: function() {
- return this._zoomStopsAnimation
- },
- set: function(e) {
- this._zoomStopsAnimation = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "framingTime", {
- get: function() {
- return this._framingTime
- },
- set: function(e) {
- this._framingTime = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.init = function() {}
- ,
- a.prototype.attach = function(e) {
- var i = this;
- this._attachedCamera = e;
- var o = this._attachedCamera.getScene();
- a.EasingFunction.setEasingMode(a.EasingMode),
- this._onPrePointerObservableObserver = o.onPrePointerObservable.add(function(s) {
- if (s.type === PointerEventTypes.POINTERDOWN) {
- i._isPointerDown = !0;
- return
- }
- s.type === PointerEventTypes.POINTERUP && (i._isPointerDown = !1)
- }),
- this._onMeshTargetChangedObserver = e.onMeshTargetChangedObservable.add(function(s) {
- s && i.zoomOnMesh(s, void 0, function() {
- i.onTargetFramingAnimationEndObservable.notifyObservers()
- })
- }),
- this._onAfterCheckInputsObserver = e.onAfterCheckInputsObservable.add(function() {
- i._applyUserInteraction(),
- i._maintainCameraAboveGround()
- })
- }
- ,
- a.prototype.detach = function() {
- if (!!this._attachedCamera) {
- var e = this._attachedCamera.getScene();
- this._onPrePointerObservableObserver && e.onPrePointerObservable.remove(this._onPrePointerObservableObserver),
- this._onAfterCheckInputsObserver && this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),
- this._onMeshTargetChangedObserver && this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),
- this._attachedCamera = null
- }
- }
- ,
- a.prototype.zoomOnMesh = function(e, i, o) {
- i === void 0 && (i = !1),
- o === void 0 && (o = null),
- e.computeWorldMatrix(!0);
- var s = e.getBoundingInfo().boundingBox;
- this.zoomOnBoundingInfo(s.minimumWorld, s.maximumWorld, i, o)
- }
- ,
- a.prototype.zoomOnMeshHierarchy = function(e, i, o) {
- i === void 0 && (i = !1),
- o === void 0 && (o = null),
- e.computeWorldMatrix(!0);
- var s = e.getHierarchyBoundingVectors(!0);
- this.zoomOnBoundingInfo(s.min, s.max, i, o)
- }
- ,
- a.prototype.zoomOnMeshesHierarchy = function(e, i, o) {
- i === void 0 && (i = !1),
- o === void 0 && (o = null);
- 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++) {
- var _ = e[d].getHierarchyBoundingVectors(!0);
- Vector3.CheckExtends(_.min, s, c),
- Vector3.CheckExtends(_.max, s, c)
- }
- this.zoomOnBoundingInfo(s, c, i, o)
- }
- ,
- a.prototype.zoomOnBoundingInfo = function(e, i, o, s) {
- var c = this;
- o === void 0 && (o = !1),
- s === void 0 && (s = null);
- var d;
- if (!!this._attachedCamera) {
- var _ = e.y
- , b = i.y
- , k = _ + (b - _) * this._positionScale
- , j = i.subtract(e).scale(.5);
- if (o)
- d = new Vector3(0,k,0);
- else {
- var $ = e.add(j);
- d = new Vector3($.x,k,$.z)
- }
- this._vectorTransition || (this._vectorTransition = Animation.CreateAnimation("target", Animation.ANIMATIONTYPE_VECTOR3, 60, a.EasingFunction)),
- this._betaIsAnimating = !0;
- var _e = Animation.TransitionTo("target", d, this._attachedCamera, this._attachedCamera.getScene(), 60, this._vectorTransition, this._framingTime);
- _e && this._animatables.push(_e);
- var et = 0;
- if (this._mode === a.FitFrustumSidesMode) {
- var tt = this._calculateLowerRadiusFromModelBoundingSphere(e, i);
- this.autoCorrectCameraLimitsAndSensibility && (this._attachedCamera.lowerRadiusLimit = j.length() + this._attachedCamera.minZ),
- et = tt
- } else
- this._mode === a.IgnoreBoundsSizeMode && (et = this._calculateLowerRadiusFromModelBoundingSphere(e, i),
- this.autoCorrectCameraLimitsAndSensibility && this._attachedCamera.lowerRadiusLimit === null && (this._attachedCamera.lowerRadiusLimit = this._attachedCamera.minZ));
- if (this.autoCorrectCameraLimitsAndSensibility) {
- var rt = i.subtract(e).length();
- this._attachedCamera.panningSensibility = 5e3 / rt,
- this._attachedCamera.wheelPrecision = 100 / et
- }
- this._radiusTransition || (this._radiusTransition = Animation.CreateAnimation("radius", Animation.ANIMATIONTYPE_FLOAT, 60, a.EasingFunction)),
- _e = Animation.TransitionTo("radius", et, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime, function() {
- c.stopAllAnimations(),
- s && s(),
- c._attachedCamera && c._attachedCamera.useInputToRestoreState && c._attachedCamera.storeState()
- }),
- _e && this._animatables.push(_e)
- }
- }
- ,
- a.prototype._calculateLowerRadiusFromModelBoundingSphere = function(e, i) {
- var o = i.subtract(e)
- , s = o.length()
- , c = this._getFrustumSlope()
- , d = s * .5
- , _ = d * this._radiusScale
- , b = _ * Math.sqrt(1 + 1 / (c.x * c.x))
- , k = _ * Math.sqrt(1 + 1 / (c.y * c.y))
- , j = Math.max(b, k)
- , $ = this._attachedCamera;
- return $ ? ($.lowerRadiusLimit && this._mode === a.IgnoreBoundsSizeMode && (j = j < $.lowerRadiusLimit ? $.lowerRadiusLimit : j),
- $.upperRadiusLimit && (j = j > $.upperRadiusLimit ? $.upperRadiusLimit : j),
- j) : 0
- }
- ,
- a.prototype._maintainCameraAboveGround = function() {
- var e = this;
- if (!(this._elevationReturnTime < 0)) {
- var i = PrecisionDate.Now - this._lastInteractionTime
- , o = Math.PI * .5 - this._defaultElevation
- , s = Math.PI * .5;
- if (this._attachedCamera && !this._betaIsAnimating && this._attachedCamera.beta > s && i >= this._elevationReturnWaitTime) {
- this._betaIsAnimating = !0,
- this.stopAllAnimations(),
- this._betaTransition || (this._betaTransition = Animation.CreateAnimation("beta", Animation.ANIMATIONTYPE_FLOAT, 60, a.EasingFunction));
- var c = Animation.TransitionTo("beta", o, this._attachedCamera, this._attachedCamera.getScene(), 60, this._betaTransition, this._elevationReturnTime, function() {
- e._clearAnimationLocks(),
- e.stopAllAnimations()
- });
- c && this._animatables.push(c)
- }
- }
- }
- ,
- a.prototype._getFrustumSlope = function() {
- var e = this._attachedCamera;
- if (!e)
- return Vector2.Zero();
- var i = e.getScene().getEngine()
- , o = i.getAspectRatio(e)
- , s = Math.tan(e.fov / 2)
- , c = s * o;
- return new Vector2(c,s)
- }
- ,
- a.prototype._clearAnimationLocks = function() {
- this._betaIsAnimating = !1
- }
- ,
- a.prototype._applyUserInteraction = function() {
- this.isUserIsMoving && (this._lastInteractionTime = PrecisionDate.Now,
- this.stopAllAnimations(),
- this._clearAnimationLocks())
- }
- ,
- a.prototype.stopAllAnimations = function() {
- for (this._attachedCamera && (this._attachedCamera.animations = []); this._animatables.length; )
- this._animatables[0] && (this._animatables[0].onAnimationEnd = null,
- this._animatables[0].stop()),
- this._animatables.shift()
- }
- ,
- Object.defineProperty(a.prototype, "isUserIsMoving", {
- get: function() {
- 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
- },
- enumerable: !1,
- configurable: !0
- }),
- a.EasingFunction = new ExponentialEase,
- a.EasingMode = EasingFunction.EASINGMODE_EASEINOUT,
- a.IgnoreBoundsSizeMode = 0,
- a.FitFrustumSidesMode = 1,
- a
- }()
- , TargetCamera = function(a) {
- __extends(e, a);
- function e(i, o, s, c) {
- c === void 0 && (c = !0);
- var d = a.call(this, i, o, s, c) || this;
- return d._tmpUpVector = Vector3.Zero(),
- d._tmpTargetVector = Vector3.Zero(),
- d.cameraDirection = new Vector3(0,0,0),
- d.cameraRotation = new Vector2(0,0),
- d.ignoreParentScaling = !1,
- d.updateUpVectorFromRotation = !1,
- d._tmpQuaternion = new Quaternion,
- d.rotation = new Vector3(0,0,0),
- d.speed = 2,
- d.noRotationConstraint = !1,
- d.invertRotation = !1,
- d.inverseRotationSpeed = .2,
- d.lockedTarget = null,
- d._currentTarget = Vector3.Zero(),
- d._initialFocalDistance = 1,
- d._viewMatrix = Matrix.Zero(),
- d._camMatrix = Matrix.Zero(),
- d._cameraTransformMatrix = Matrix.Zero(),
- d._cameraRotationMatrix = Matrix.Zero(),
- d._referencePoint = new Vector3(0,0,1),
- d._transformedReferencePoint = Vector3.Zero(),
- d._defaultUp = Vector3.Up(),
- d._cachedRotationZ = 0,
- d._cachedQuaternionRotationZ = 0,
- d
- }
- return e.prototype.getFrontPosition = function(i) {
- this.getWorldMatrix();
- var o = this.getTarget().subtract(this.position);
- return o.normalize(),
- o.scaleInPlace(i),
- this.globalPosition.add(o)
- }
- ,
- e.prototype._getLockedTargetPosition = function() {
- return this.lockedTarget ? (this.lockedTarget.absolutePosition && this.lockedTarget.computeWorldMatrix(),
- this.lockedTarget.absolutePosition || this.lockedTarget) : null
- }
- ,
- e.prototype.storeState = function() {
- return this._storedPosition = this.position.clone(),
- this._storedRotation = this.rotation.clone(),
- this.rotationQuaternion && (this._storedRotationQuaternion = this.rotationQuaternion.clone()),
- a.prototype.storeState.call(this)
- }
- ,
- e.prototype._restoreStateValues = function() {
- return a.prototype._restoreStateValues.call(this) ? (this.position = this._storedPosition.clone(),
- this.rotation = this._storedRotation.clone(),
- this.rotationQuaternion && (this.rotationQuaternion = this._storedRotationQuaternion.clone()),
- this.cameraDirection.copyFromFloats(0, 0, 0),
- this.cameraRotation.copyFromFloats(0, 0),
- !0) : !1
- }
- ,
- e.prototype._initCache = function() {
- a.prototype._initCache.call(this),
- this._cache.lockedTarget = new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
- this._cache.rotation = new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
- this._cache.rotationQuaternion = new Quaternion(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)
- }
- ,
- e.prototype._updateCache = function(i) {
- i || a.prototype._updateCache.call(this);
- var o = this._getLockedTargetPosition();
- o ? this._cache.lockedTarget ? this._cache.lockedTarget.copyFrom(o) : this._cache.lockedTarget = o.clone() : this._cache.lockedTarget = null,
- this._cache.rotation.copyFrom(this.rotation),
- this.rotationQuaternion && this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion)
- }
- ,
- e.prototype._isSynchronizedViewMatrix = function() {
- if (!a.prototype._isSynchronizedViewMatrix.call(this))
- return !1;
- var i = this._getLockedTargetPosition();
- return (this._cache.lockedTarget ? this._cache.lockedTarget.equals(i) : !i) && (this.rotationQuaternion ? this.rotationQuaternion.equals(this._cache.rotationQuaternion) : this._cache.rotation.equals(this.rotation))
- }
- ,
- e.prototype._computeLocalCameraSpeed = function() {
- var i = this.getEngine();
- return this.speed * Math.sqrt(i.getDeltaTime() / (i.getFps() * 100))
- }
- ,
- e.prototype.setTarget = function(i) {
- this.upVector.normalize(),
- this._initialFocalDistance = i.subtract(this.position).length(),
- this.position.z === i.z && (this.position.z += Epsilon),
- this._referencePoint.normalize().scaleInPlace(this._initialFocalDistance),
- Matrix.LookAtLHToRef(this.position, i, this._defaultUp, this._camMatrix),
- this._camMatrix.invert(),
- this.rotation.x = Math.atan(this._camMatrix.m[6] / this._camMatrix.m[10]);
- var o = i.subtract(this.position);
- 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,
- this.rotation.z = 0,
- isNaN(this.rotation.x) && (this.rotation.x = 0),
- isNaN(this.rotation.y) && (this.rotation.y = 0),
- isNaN(this.rotation.z) && (this.rotation.z = 0),
- this.rotationQuaternion && Quaternion.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion)
- }
- ,
- Object.defineProperty(e.prototype, "target", {
- get: function() {
- return this.getTarget()
- },
- set: function(i) {
- this.setTarget(i)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getTarget = function() {
- return this._currentTarget
- }
- ,
- e.prototype._decideIfNeedsToMove = function() {
- return Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0
- }
- ,
- e.prototype._updatePosition = function() {
- if (this.parent) {
- this.parent.getWorldMatrix().invertToRef(TmpVectors.Matrix[0]),
- Vector3.TransformNormalToRef(this.cameraDirection, TmpVectors.Matrix[0], TmpVectors.Vector3[0]),
- this.position.addInPlace(TmpVectors.Vector3[0]);
- return
- }
- this.position.addInPlace(this.cameraDirection)
- }
- ,
- e.prototype._checkInputs = function() {
- var i = this.invertRotation ? -this.inverseRotationSpeed : 1
- , o = this._decideIfNeedsToMove()
- , s = Math.abs(this.cameraRotation.x) > 0 || Math.abs(this.cameraRotation.y) > 0;
- if (o && this._updatePosition(),
- s) {
- if (this.rotationQuaternion && this.rotationQuaternion.toEulerAnglesToRef(this.rotation),
- this.rotation.x += this.cameraRotation.x * i,
- this.rotation.y += this.cameraRotation.y * i,
- !this.noRotationConstraint) {
- var c = 1.570796;
- this.rotation.x > c && (this.rotation.x = c),
- this.rotation.x < -c && (this.rotation.x = -c)
- }
- if (this.rotationQuaternion) {
- var d = this.rotation.lengthSquared();
- d && Quaternion.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion)
- }
- }
- o && (Math.abs(this.cameraDirection.x) < this.speed * Epsilon && (this.cameraDirection.x = 0),
- Math.abs(this.cameraDirection.y) < this.speed * Epsilon && (this.cameraDirection.y = 0),
- Math.abs(this.cameraDirection.z) < this.speed * Epsilon && (this.cameraDirection.z = 0),
- this.cameraDirection.scaleInPlace(this.inertia)),
- s && (Math.abs(this.cameraRotation.x) < this.speed * Epsilon && (this.cameraRotation.x = 0),
- Math.abs(this.cameraRotation.y) < this.speed * Epsilon && (this.cameraRotation.y = 0),
- this.cameraRotation.scaleInPlace(this.inertia)),
- a.prototype._checkInputs.call(this)
- }
- ,
- e.prototype._updateCameraRotationMatrix = function() {
- this.rotationQuaternion ? this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix) : Matrix.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix)
- }
- ,
- e.prototype._rotateUpVectorWithCameraRotationMatrix = function() {
- return Vector3.TransformNormalToRef(this._defaultUp, this._cameraRotationMatrix, this.upVector),
- this
- }
- ,
- e.prototype._getViewMatrix = function() {
- return this.lockedTarget && this.setTarget(this._getLockedTargetPosition()),
- this._updateCameraRotationMatrix(),
- this.rotationQuaternion && this._cachedQuaternionRotationZ != this.rotationQuaternion.z ? (this._rotateUpVectorWithCameraRotationMatrix(),
- this._cachedQuaternionRotationZ = this.rotationQuaternion.z) : this._cachedRotationZ !== this.rotation.z && (this._rotateUpVectorWithCameraRotationMatrix(),
- this._cachedRotationZ = this.rotation.z),
- Vector3.TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint),
- this.position.addToRef(this._transformedReferencePoint, this._currentTarget),
- this.updateUpVectorFromRotation && (this.rotationQuaternion ? Axis.Y.rotateByQuaternionToRef(this.rotationQuaternion, this.upVector) : (Quaternion.FromEulerVectorToRef(this.rotation, this._tmpQuaternion),
- Axis.Y.rotateByQuaternionToRef(this._tmpQuaternion, this.upVector))),
- this._computeViewMatrix(this.position, this._currentTarget, this.upVector),
- this._viewMatrix
- }
- ,
- e.prototype._computeViewMatrix = function(i, o, s) {
- if (this.ignoreParentScaling) {
- if (this.parent) {
- var c = this.parent.getWorldMatrix();
- Vector3.TransformCoordinatesToRef(i, c, this._globalPosition),
- Vector3.TransformCoordinatesToRef(o, c, this._tmpTargetVector),
- Vector3.TransformNormalToRef(s, c, this._tmpUpVector),
- this._markSyncedWithParent()
- } else
- this._globalPosition.copyFrom(i),
- this._tmpTargetVector.copyFrom(o),
- this._tmpUpVector.copyFrom(s);
- this.getScene().useRightHandedSystem ? Matrix.LookAtRHToRef(this._globalPosition, this._tmpTargetVector, this._tmpUpVector, this._viewMatrix) : Matrix.LookAtLHToRef(this._globalPosition, this._tmpTargetVector, this._tmpUpVector, this._viewMatrix);
- return
- }
- if (this.getScene().useRightHandedSystem ? Matrix.LookAtRHToRef(i, o, s, this._viewMatrix) : Matrix.LookAtLHToRef(i, o, s, this._viewMatrix),
- this.parent) {
- var c = this.parent.getWorldMatrix();
- this._viewMatrix.invert(),
- this._viewMatrix.multiplyToRef(c, this._viewMatrix),
- this._viewMatrix.getTranslationToRef(this._globalPosition),
- this._viewMatrix.invert(),
- this._markSyncedWithParent()
- } else
- this._globalPosition.copyFrom(i)
- }
- ,
- e.prototype.createRigCamera = function(i, o) {
- if (this.cameraRigMode !== Camera$1.RIG_MODE_NONE) {
- var s = new e(i,this.position.clone(),this.getScene());
- return s.isRigCamera = !0,
- s.rigParent = this,
- (this.cameraRigMode === Camera$1.RIG_MODE_VR || this.cameraRigMode === Camera$1.RIG_MODE_WEBVR) && (this.rotationQuaternion || (this.rotationQuaternion = new Quaternion),
- s._cameraRigParams = {},
- s.rotationQuaternion = new Quaternion),
- s
- }
- return null
- }
- ,
- e.prototype._updateRigCameras = function() {
- var i = this._rigCameras[0]
- , o = this._rigCameras[1];
- switch (this.computeWorldMatrix(),
- this.cameraRigMode) {
- case Camera$1.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
- case Camera$1.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
- case Camera$1.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
- case Camera$1.RIG_MODE_STEREOSCOPIC_OVERUNDER:
- case Camera$1.RIG_MODE_STEREOSCOPIC_INTERLACED:
- var s = this.cameraRigMode === Camera$1.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED ? 1 : -1
- , c = this.cameraRigMode === Camera$1.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED ? -1 : 1;
- this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * s, i),
- this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * c, o);
- break;
- case Camera$1.RIG_MODE_VR:
- i.rotationQuaternion ? (i.rotationQuaternion.copyFrom(this.rotationQuaternion),
- o.rotationQuaternion.copyFrom(this.rotationQuaternion)) : (i.rotation.copyFrom(this.rotation),
- o.rotation.copyFrom(this.rotation)),
- i.position.copyFrom(this.position),
- o.position.copyFrom(this.position);
- break
- }
- a.prototype._updateRigCameras.call(this)
- }
- ,
- e.prototype._getRigCamPositionAndTarget = function(i, o) {
- var s = this.getTarget();
- s.subtractToRef(this.position, e._TargetFocalPoint),
- e._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);
- var c = e._TargetFocalPoint.addInPlace(this.position);
- Matrix.TranslationToRef(-c.x, -c.y, -c.z, e._TargetTransformMatrix),
- e._TargetTransformMatrix.multiplyToRef(Matrix.RotationAxis(o.upVector, i), e._RigCamTransformMatrix),
- Matrix.TranslationToRef(c.x, c.y, c.z, e._TargetTransformMatrix),
- e._RigCamTransformMatrix.multiplyToRef(e._TargetTransformMatrix, e._RigCamTransformMatrix),
- Vector3.TransformCoordinatesToRef(this.position, e._RigCamTransformMatrix, o.position),
- o.setTarget(c)
- }
- ,
- e.prototype.getClassName = function() {
- return "TargetCamera"
- }
- ,
- e._RigCamTransformMatrix = new Matrix,
- e._TargetTransformMatrix = new Matrix,
- e._TargetFocalPoint = new Vector3,
- __decorate([serializeAsVector3()], e.prototype, "rotation", void 0),
- __decorate([serialize()], e.prototype, "speed", void 0),
- __decorate([serializeAsMeshReference("lockedTargetId")], e.prototype, "lockedTarget", void 0),
- e
- }(Camera$1)
- , CameraInputTypes = {}
- , CameraInputsManager = function() {
- function a(e) {
- this.attachedToElement = !1,
- this.attached = {},
- this.camera = e,
- this.checkInputs = function() {}
- }
- return a.prototype.add = function(e) {
- var i = e.getSimpleName();
- if (this.attached[i]) {
- Logger$2.Warn("camera input of type " + i + " already exists on camera");
- return
- }
- this.attached[i] = e,
- e.camera = this.camera,
- e.checkInputs && (this.checkInputs = this._addCheckInputs(e.checkInputs.bind(e))),
- this.attachedToElement && e.attachControl()
- }
- ,
- a.prototype.remove = function(e) {
- for (var i in this.attached) {
- var o = this.attached[i];
- o === e && (o.detachControl(),
- o.camera = null,
- delete this.attached[i],
- this.rebuildInputCheck())
- }
- }
- ,
- a.prototype.removeByType = function(e) {
- for (var i in this.attached) {
- var o = this.attached[i];
- o.getClassName() === e && (o.detachControl(),
- o.camera = null,
- delete this.attached[i],
- this.rebuildInputCheck())
- }
- }
- ,
- a.prototype._addCheckInputs = function(e) {
- var i = this.checkInputs;
- return function() {
- i(),
- e()
- }
- }
- ,
- a.prototype.attachInput = function(e) {
- this.attachedToElement && e.attachControl(this.noPreventDefault)
- }
- ,
- a.prototype.attachElement = function(e) {
- if (e === void 0 && (e = !1),
- !this.attachedToElement) {
- e = Camera$1.ForceAttachControlToAlwaysPreventDefault ? !1 : e,
- this.attachedToElement = !0,
- this.noPreventDefault = e;
- for (var i in this.attached)
- this.attached[i].attachControl(e)
- }
- }
- ,
- a.prototype.detachElement = function(e) {
- e === void 0 && (e = !1);
- for (var i in this.attached)
- this.attached[i].detachControl(),
- e && (this.attached[i].camera = null);
- this.attachedToElement = !1
- }
- ,
- a.prototype.rebuildInputCheck = function() {
- this.checkInputs = function() {}
- ;
- for (var e in this.attached) {
- var i = this.attached[e];
- i.checkInputs && (this.checkInputs = this._addCheckInputs(i.checkInputs.bind(i)))
- }
- }
- ,
- a.prototype.clear = function() {
- this.attachedToElement && this.detachElement(!0),
- this.attached = {},
- this.attachedToElement = !1,
- this.checkInputs = function() {}
- }
- ,
- a.prototype.serialize = function(e) {
- var i = {};
- for (var o in this.attached) {
- var s = this.attached[o]
- , c = SerializationHelper.Serialize(s);
- i[s.getClassName()] = c
- }
- e.inputsmgr = i
- }
- ,
- a.prototype.parse = function(e) {
- var i = e.inputsmgr;
- if (i) {
- this.clear();
- for (var o in i) {
- var s = CameraInputTypes[o];
- if (s) {
- var c = i[o]
- , d = SerializationHelper.Parse(function() {
- return new s
- }, c, null);
- this.add(d)
- }
- }
- } else
- for (var o in this.attached) {
- var s = CameraInputTypes[this.attached[o].getClassName()];
- if (s) {
- var d = SerializationHelper.Parse(function() {
- return new s
- }, e, null);
- this.remove(this.attached[o]),
- this.add(d)
- }
- }
- }
- ,
- a
- }()
- , BaseCameraPointersInput = function() {
- function a() {
- this._currentActiveButton = -1,
- this.buttons = [0, 1, 2]
- }
- return a.prototype.attachControl = function(e) {
- var i = this;
- e = Tools.BackCompatCameraNoPreventDefault(arguments);
- var o = this.camera.getEngine()
- , s = o.getInputElement()
- , c = 0
- , d = null;
- this.pointA = null,
- this.pointB = null,
- this._altKey = !1,
- this._ctrlKey = !1,
- this._metaKey = !1,
- this._shiftKey = !1,
- this._buttonsPressed = 0,
- this._pointerInput = function(b, k) {
- var j = b.event
- , $ = j.pointerType === "touch";
- if (!o.isInVRExclusivePointerMode && !(b.type !== PointerEventTypes.POINTERMOVE && i.buttons.indexOf(j.button) === -1)) {
- var _e = j.srcElement || j.target;
- if (i._altKey = j.altKey,
- i._ctrlKey = j.ctrlKey,
- i._metaKey = j.metaKey,
- i._shiftKey = j.shiftKey,
- i._buttonsPressed = j.buttons,
- o.isPointerLock) {
- var et = j.movementX || j.mozMovementX || j.webkitMovementX || j.msMovementX || 0
- , tt = j.movementY || j.mozMovementY || j.webkitMovementY || j.msMovementY || 0;
- i.onTouch(null, et, tt),
- i.pointA = null,
- i.pointB = null
- } else if (b.type === PointerEventTypes.POINTERDOWN && (i._currentActiveButton === -1 || $)) {
- try {
- _e == null || _e.setPointerCapture(j.pointerId)
- } catch {}
- i.pointA === null ? i.pointA = {
- x: j.clientX,
- y: j.clientY,
- pointerId: j.pointerId,
- type: j.pointerType
- } : i.pointB === null && (i.pointB = {
- x: j.clientX,
- y: j.clientY,
- pointerId: j.pointerId,
- type: j.pointerType
- }),
- i._currentActiveButton === -1 && !$ && (i._currentActiveButton = j.button),
- i.onButtonDown(j),
- e || (j.preventDefault(),
- s && s.focus())
- } else if (b.type === PointerEventTypes.POINTERDOUBLETAP)
- i.onDoubleTap(j.pointerType);
- else if (b.type === PointerEventTypes.POINTERUP && (i._currentActiveButton === j.button || $)) {
- try {
- _e == null || _e.releasePointerCapture(j.pointerId)
- } catch {}
- $ || (i.pointB = null),
- o._badOS ? i.pointA = i.pointB = null : i.pointB && i.pointA && i.pointA.pointerId == j.pointerId ? (i.pointA = i.pointB,
- i.pointB = null) : i.pointA && i.pointB && i.pointB.pointerId == j.pointerId ? i.pointB = null : i.pointA = i.pointB = null,
- (c !== 0 || d) && (i.onMultiTouch(i.pointA, i.pointB, c, 0, d, null),
- c = 0,
- d = null),
- i._currentActiveButton = -1,
- i.onButtonUp(j),
- e || j.preventDefault()
- } else if (b.type === PointerEventTypes.POINTERMOVE) {
- if (e || j.preventDefault(),
- i.pointA && i.pointB === null) {
- var et = j.clientX - i.pointA.x
- , tt = j.clientY - i.pointA.y;
- i.onTouch(i.pointA, et, tt),
- i.pointA.x = j.clientX,
- i.pointA.y = j.clientY
- } else if (i.pointA && i.pointB) {
- var rt = i.pointA.pointerId === j.pointerId ? i.pointA : i.pointB;
- rt.x = j.clientX,
- rt.y = j.clientY;
- var it = i.pointA.x - i.pointB.x
- , nt = i.pointA.y - i.pointB.y
- , ot = it * it + nt * nt
- , at = {
- x: (i.pointA.x + i.pointB.x) / 2,
- y: (i.pointA.y + i.pointB.y) / 2,
- pointerId: j.pointerId,
- type: b.type
- };
- i.onMultiTouch(i.pointA, i.pointB, c, ot, d, at),
- d = at,
- c = ot
- }
- }
- }
- }
- ,
- this._observer = this.camera.getScene().onPointerObservable.add(this._pointerInput, PointerEventTypes.POINTERDOWN | PointerEventTypes.POINTERUP | PointerEventTypes.POINTERMOVE | PointerEventTypes.POINTERDOUBLETAP),
- this._onLostFocus = function() {
- i.pointA = i.pointB = null,
- c = 0,
- d = null,
- i.onLostFocus()
- }
- ,
- s && s.addEventListener("contextmenu", this.onContextMenu.bind(this), !1);
- var _ = this.camera.getScene().getEngine().getHostWindow();
- _ && Tools.RegisterTopRootEvents(_, [{
- name: "blur",
- handler: this._onLostFocus
- }])
- }
- ,
- a.prototype.detachControl = function(e) {
- if (this._onLostFocus) {
- var i = this.camera.getScene().getEngine().getHostWindow();
- i && Tools.UnregisterTopRootEvents(i, [{
- name: "blur",
- handler: this._onLostFocus
- }])
- }
- if (this._observer) {
- if (this.camera.getScene().onPointerObservable.remove(this._observer),
- this._observer = null,
- this.onContextMenu) {
- var o = this.camera.getScene().getEngine().getInputElement();
- o && o.removeEventListener("contextmenu", this.onContextMenu)
- }
- this._onLostFocus = null
- }
- this._altKey = !1,
- this._ctrlKey = !1,
- this._metaKey = !1,
- this._shiftKey = !1,
- this._buttonsPressed = 0
- }
- ,
- a.prototype.getClassName = function() {
- return "BaseCameraPointersInput"
- }
- ,
- a.prototype.getSimpleName = function() {
- return "pointers"
- }
- ,
- a.prototype.onDoubleTap = function(e) {}
- ,
- a.prototype.onTouch = function(e, i, o) {}
- ,
- a.prototype.onMultiTouch = function(e, i, o, s, c, d) {}
- ,
- a.prototype.onContextMenu = function(e) {
- e.preventDefault()
- }
- ,
- a.prototype.onButtonDown = function(e) {}
- ,
- a.prototype.onButtonUp = function(e) {}
- ,
- a.prototype.onLostFocus = function() {}
- ,
- __decorate([serialize()], a.prototype, "buttons", void 0),
- a
- }()
- , ArcRotateCameraPointersInput = function(a) {
- __extends(e, a);
- function e() {
- var i = a !== null && a.apply(this, arguments) || this;
- return i.buttons = [0, 1, 2],
- i.angularSensibilityX = 1e3,
- i.angularSensibilityY = 1e3,
- i.pinchPrecision = 12,
- i.pinchDeltaPercentage = 0,
- i.useNaturalPinchZoom = !1,
- i.pinchZoom = !0,
- i.panningSensibility = 1e3,
- i.multiTouchPanning = !0,
- i.multiTouchPanAndZoom = !0,
- i.pinchInwards = !0,
- i._isPanClick = !1,
- i._twoFingerActivityCount = 0,
- i._isPinching = !1,
- i
- }
- return e.prototype.getClassName = function() {
- return "ArcRotateCameraPointersInput"
- }
- ,
- e.prototype._computeMultiTouchPanning = function(i, o) {
- if (this.panningSensibility !== 0 && i && o) {
- var s = o.x - i.x
- , c = o.y - i.y;
- this.camera.inertialPanningX += -s / this.panningSensibility,
- this.camera.inertialPanningY += c / this.panningSensibility
- }
- }
- ,
- e.prototype._computePinchZoom = function(i, o) {
- var s = this.camera.radius || e.MinimumRadiusForPinch;
- 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)
- }
- ,
- e.prototype.onTouch = function(i, o, s) {
- this.panningSensibility !== 0 && (this._ctrlKey && this.camera._useCtrlForPanning || this._isPanClick) ? (this.camera.inertialPanningX += -o / this.panningSensibility,
- this.camera.inertialPanningY += s / this.panningSensibility) : (this.camera.inertialAlphaOffset -= o / this.angularSensibilityX,
- this.camera.inertialBetaOffset -= s / this.angularSensibilityY)
- }
- ,
- e.prototype.onDoubleTap = function(i) {
- this.camera.useInputToRestoreState && this.camera.restoreState()
- }
- ,
- e.prototype.onMultiTouch = function(i, o, s, c, d, _) {
- s === 0 && d === null || c === 0 && _ === null || (this.multiTouchPanAndZoom ? (this._computePinchZoom(s, c),
- this._computeMultiTouchPanning(d, _)) : this.multiTouchPanning && this.pinchZoom ? (this._twoFingerActivityCount++,
- this._isPinching || this._twoFingerActivityCount < 20 && Math.abs(Math.sqrt(c) - Math.sqrt(s)) > this.camera.pinchToPanMaxDistance ? (this._computePinchZoom(s, c),
- this._isPinching = !0) : this._computeMultiTouchPanning(d, _)) : this.multiTouchPanning ? this._computeMultiTouchPanning(d, _) : this.pinchZoom && this._computePinchZoom(s, c))
- }
- ,
- e.prototype.onButtonDown = function(i) {
- this._isPanClick = i.button === this.camera._panningMouseButton
- }
- ,
- e.prototype.onButtonUp = function(i) {
- this._twoFingerActivityCount = 0,
- this._isPinching = !1
- }
- ,
- e.prototype.onLostFocus = function() {
- this._isPanClick = !1,
- this._twoFingerActivityCount = 0,
- this._isPinching = !1
- }
- ,
- e.MinimumRadiusForPinch = .001,
- __decorate([serialize()], e.prototype, "buttons", void 0),
- __decorate([serialize()], e.prototype, "angularSensibilityX", void 0),
- __decorate([serialize()], e.prototype, "angularSensibilityY", void 0),
- __decorate([serialize()], e.prototype, "pinchPrecision", void 0),
- __decorate([serialize()], e.prototype, "pinchDeltaPercentage", void 0),
- __decorate([serialize()], e.prototype, "useNaturalPinchZoom", void 0),
- __decorate([serialize()], e.prototype, "pinchZoom", void 0),
- __decorate([serialize()], e.prototype, "panningSensibility", void 0),
- __decorate([serialize()], e.prototype, "multiTouchPanning", void 0),
- __decorate([serialize()], e.prototype, "multiTouchPanAndZoom", void 0),
- e
- }(BaseCameraPointersInput);
- CameraInputTypes.ArcRotateCameraPointersInput = ArcRotateCameraPointersInput;
- var ArcRotateCameraKeyboardMoveInput = function() {
- function a() {
- this.keysUp = [38],
- this.keysDown = [40],
- this.keysLeft = [37],
- this.keysRight = [39],
- this.keysReset = [220],
- this.panningSensibility = 50,
- this.zoomingSensibility = 25,
- this.useAltToZoom = !0,
- this.angularSpeed = .01,
- this._keys = new Array
- }
- return a.prototype.attachControl = function(e) {
- var i = this;
- e = Tools.BackCompatCameraNoPreventDefault(arguments),
- !this._onCanvasBlurObserver && (this._scene = this.camera.getScene(),
- this._engine = this._scene.getEngine(),
- this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function() {
- i._keys = []
- }),
- this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function(o) {
- var s = o.event;
- if (!s.metaKey) {
- if (o.type === KeyboardEventTypes.KEYDOWN) {
- if (i._ctrlPressed = s.ctrlKey,
- i._altPressed = s.altKey,
- 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) {
- var c = i._keys.indexOf(s.keyCode);
- c === -1 && i._keys.push(s.keyCode),
- s.preventDefault && (e || s.preventDefault())
- }
- } 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) {
- var c = i._keys.indexOf(s.keyCode);
- c >= 0 && i._keys.splice(c, 1),
- s.preventDefault && (e || s.preventDefault())
- }
- }
- }))
- }
- ,
- a.prototype.detachControl = function(e) {
- this._scene && (this._onKeyboardObserver && this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),
- this._onCanvasBlurObserver && this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),
- this._onKeyboardObserver = null,
- this._onCanvasBlurObserver = null),
- this._keys = []
- }
- ,
- a.prototype.checkInputs = function() {
- if (this._onKeyboardObserver)
- for (var e = this.camera, i = 0; i < this._keys.length; i++) {
- var o = this._keys[i];
- 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()
- }
- }
- ,
- a.prototype.getClassName = function() {
- return "ArcRotateCameraKeyboardMoveInput"
- }
- ,
- a.prototype.getSimpleName = function() {
- return "keyboard"
- }
- ,
- __decorate([serialize()], a.prototype, "keysUp", void 0),
- __decorate([serialize()], a.prototype, "keysDown", void 0),
- __decorate([serialize()], a.prototype, "keysLeft", void 0),
- __decorate([serialize()], a.prototype, "keysRight", void 0),
- __decorate([serialize()], a.prototype, "keysReset", void 0),
- __decorate([serialize()], a.prototype, "panningSensibility", void 0),
- __decorate([serialize()], a.prototype, "zoomingSensibility", void 0),
- __decorate([serialize()], a.prototype, "useAltToZoom", void 0),
- __decorate([serialize()], a.prototype, "angularSpeed", void 0),
- a
- }();
- CameraInputTypes.ArcRotateCameraKeyboardMoveInput = ArcRotateCameraKeyboardMoveInput;
- var ffMultiplier = 40
- , ArcRotateCameraMouseWheelInput = function() {
- function a() {
- this.wheelPrecision = 3,
- this.zoomToMouseLocation = !1,
- this.wheelDeltaPercentage = 0,
- this.customComputeDeltaFromMouseWheel = null,
- this._inertialPanning = Vector3.Zero()
- }
- return a.prototype.computeDeltaFromMouseWheelLegacyEvent = function(e, i) {
- var o = 0
- , s = e * .01 * this.wheelDeltaPercentage * i;
- return e > 0 ? o = s / (1 + this.wheelDeltaPercentage) : o = s * (1 + this.wheelDeltaPercentage),
- o
- }
- ,
- a.prototype.attachControl = function(e) {
- var i = this;
- e = Tools.BackCompatCameraNoPreventDefault(arguments),
- this._wheel = function(o, s) {
- if (o.type === PointerEventTypes.POINTERWHEEL) {
- var c = o.event
- , d = 0
- , _ = c
- , b = 0
- , k = c.deltaMode === EventConstants.DOM_DELTA_LINE ? ffMultiplier : 1;
- if (c.deltaY !== void 0 ? b = -(c.deltaY * k) : c.wheelDeltaY !== void 0 ? b = -(c.wheelDeltaY * k) : b = _.wheelDelta,
- i.customComputeDeltaFromMouseWheel)
- d = i.customComputeDeltaFromMouseWheel(b, i, c);
- else if (i.wheelDeltaPercentage) {
- if (d = i.computeDeltaFromMouseWheelLegacyEvent(b, i.camera.radius),
- d > 0) {
- for (var j = i.camera.radius, $ = i.camera.inertialRadiusOffset + d, _e = 0; _e < 20 && Math.abs($) > .001; _e++)
- j -= $,
- $ *= i.camera.inertia;
- j = Scalar.Clamp(j, 0, Number.MAX_VALUE),
- d = i.computeDeltaFromMouseWheelLegacyEvent(b, j)
- }
- } else
- d = b / (i.wheelPrecision * 40);
- d && (i.zoomToMouseLocation && i._hitPlane ? i._zoomToMouse(d) : i.camera.inertialRadiusOffset += d),
- c.preventDefault && (e || c.preventDefault())
- }
- }
- ,
- this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, PointerEventTypes.POINTERWHEEL),
- this.zoomToMouseLocation && this._inertialPanning.setAll(0)
- }
- ,
- a.prototype.detachControl = function(e) {
- this._observer && (this.camera.getScene().onPointerObservable.remove(this._observer),
- this._observer = null,
- this._wheel = null)
- }
- ,
- a.prototype.checkInputs = function() {
- if (!!this.zoomToMouseLocation) {
- var e = this.camera
- , i = 0 + e.inertialAlphaOffset + e.inertialBetaOffset + e.inertialRadiusOffset;
- i && (this._updateHitPlane(),
- e.target.addInPlace(this._inertialPanning),
- this._inertialPanning.scaleInPlace(e.inertia),
- this._zeroIfClose(this._inertialPanning))
- }
- }
- ,
- a.prototype.getClassName = function() {
- return "ArcRotateCameraMouseWheelInput"
- }
- ,
- a.prototype.getSimpleName = function() {
- return "mousewheel"
- }
- ,
- a.prototype._updateHitPlane = function() {
- var e = this.camera
- , i = e.target.subtract(e.position);
- this._hitPlane = Plane.FromPositionAndNormal(Vector3.Zero(), i)
- }
- ,
- a.prototype._getPosition = function() {
- var e, i = this.camera, o = i.getScene(), s = o.createPickingRay(o.pointerX, o.pointerY, Matrix.Identity(), i, !1), c = 0;
- return this._hitPlane && (c = (e = s.intersectsPlane(this._hitPlane)) !== null && e !== void 0 ? e : 0),
- s.origin.addInPlace(s.direction.scaleInPlace(c))
- }
- ,
- a.prototype._zoomToMouse = function(e) {
- var i, o, s = this.camera, c = 1 - s.inertia;
- if (s.lowerRadiusLimit) {
- var d = (i = s.lowerRadiusLimit) !== null && i !== void 0 ? i : 0;
- s.radius - (s.inertialRadiusOffset + e) / c < d && (e = (s.radius - d) * c - s.inertialRadiusOffset)
- }
- if (s.upperRadiusLimit) {
- var _ = (o = s.upperRadiusLimit) !== null && o !== void 0 ? o : 0;
- s.radius - (s.inertialRadiusOffset + e) / c > _ && (e = (s.radius - _) * c - s.inertialRadiusOffset)
- }
- var b = e / c
- , k = b / s.radius
- , j = this._getPosition()
- , $ = j.subtract(s.target)
- , _e = $.scale(k);
- _e.scaleInPlace(c),
- this._inertialPanning.addInPlace(_e),
- s.inertialRadiusOffset += e
- }
- ,
- a.prototype._zeroIfClose = function(e) {
- Math.abs(e.x) < Epsilon && (e.x = 0),
- Math.abs(e.y) < Epsilon && (e.y = 0),
- Math.abs(e.z) < Epsilon && (e.z = 0)
- }
- ,
- __decorate([serialize()], a.prototype, "wheelPrecision", void 0),
- __decorate([serialize()], a.prototype, "zoomToMouseLocation", void 0),
- __decorate([serialize()], a.prototype, "wheelDeltaPercentage", void 0),
- a
- }();
- CameraInputTypes.ArcRotateCameraMouseWheelInput = ArcRotateCameraMouseWheelInput;
- var ArcRotateCameraInputsManager = function(a) {
- __extends(e, a);
- function e(i) {
- return a.call(this, i) || this
- }
- return e.prototype.addMouseWheel = function() {
- return this.add(new ArcRotateCameraMouseWheelInput),
- this
- }
- ,
- e.prototype.addPointers = function() {
- return this.add(new ArcRotateCameraPointersInput),
- this
- }
- ,
- e.prototype.addKeyboard = function() {
- return this.add(new ArcRotateCameraKeyboardMoveInput),
- this
- }
- ,
- e
- }(CameraInputsManager);
- Node$2.AddNodeConstructor("ArcRotateCamera", function(a, e) {
- return function() {
- return new ArcRotateCamera(a,0,0,1,Vector3.Zero(),e)
- }
- });
- var ArcRotateCamera = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _, b) {
- b === void 0 && (b = !0);
- var k = a.call(this, i, Vector3.Zero(), _, b) || this;
- return k.inertialAlphaOffset = 0,
- k.inertialBetaOffset = 0,
- k.inertialRadiusOffset = 0,
- k.lowerAlphaLimit = null,
- k.upperAlphaLimit = null,
- k.lowerBetaLimit = .01,
- k.upperBetaLimit = Math.PI - .01,
- k.lowerRadiusLimit = null,
- k.upperRadiusLimit = null,
- k.inertialPanningX = 0,
- k.inertialPanningY = 0,
- k.pinchToPanMaxDistance = 20,
- k.panningDistanceLimit = null,
- k.panningOriginTarget = Vector3.Zero(),
- k.panningInertia = .9,
- k.zoomOnFactor = 1,
- k.targetScreenOffset = Vector2.Zero(),
- k.allowUpsideDown = !0,
- k.useInputToRestoreState = !0,
- k._viewMatrix = new Matrix,
- k.panningAxis = new Vector3(1,1,0),
- k._transformedDirection = new Vector3,
- k.mapPanning = !1,
- k.onMeshTargetChangedObservable = new Observable,
- k.checkCollisions = !1,
- k.collisionRadius = new Vector3(.5,.5,.5),
- k._previousPosition = Vector3.Zero(),
- k._collisionVelocity = Vector3.Zero(),
- k._newPosition = Vector3.Zero(),
- k._computationVector = Vector3.Zero(),
- k._onCollisionPositionChange = function(j, $, _e) {
- _e === void 0 && (_e = null),
- _e ? (k.setPosition($),
- k.onCollide && k.onCollide(_e)) : k._previousPosition.copyFrom(k._position);
- var et = Math.cos(k.alpha)
- , tt = Math.sin(k.alpha)
- , rt = Math.cos(k.beta)
- , it = Math.sin(k.beta);
- it === 0 && (it = 1e-4);
- var nt = k._getTargetPosition();
- k._computationVector.copyFromFloats(k.radius * et * it, k.radius * rt, k.radius * tt * it),
- nt.addToRef(k._computationVector, k._newPosition),
- k._position.copyFrom(k._newPosition);
- var ot = k.upVector;
- k.allowUpsideDown && k.beta < 0 && (ot = ot.clone(),
- ot = ot.negate()),
- k._computeViewMatrix(k._position, nt, ot),
- k._viewMatrix.addAtIndex(12, k.targetScreenOffset.x),
- k._viewMatrix.addAtIndex(13, k.targetScreenOffset.y),
- k._collisionTriggered = !1
- }
- ,
- k._target = Vector3.Zero(),
- d && k.setTarget(d),
- k.alpha = o,
- k.beta = s,
- k.radius = c,
- k.getViewMatrix(),
- k.inputs = new ArcRotateCameraInputsManager(k),
- k.inputs.addKeyboard().addMouseWheel().addPointers(),
- k
- }
- return Object.defineProperty(e.prototype, "target", {
- get: function() {
- return this._target
- },
- set: function(i) {
- this.setTarget(i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "targetHost", {
- get: function() {
- return this._targetHost
- },
- set: function(i) {
- i && this.setTarget(i)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getTarget = function() {
- return this.target
- }
- ,
- Object.defineProperty(e.prototype, "position", {
- get: function() {
- return this._position
- },
- set: function(i) {
- this.setPosition(i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "upVector", {
- get: function() {
- return this._upVector
- },
- set: function(i) {
- this._upToYMatrix || (this._YToUpMatrix = new Matrix,
- this._upToYMatrix = new Matrix,
- this._upVector = Vector3.Zero()),
- i.normalize(),
- this._upVector.copyFrom(i),
- this.setMatUp()
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.setMatUp = function() {
- Matrix.RotationAlignToRef(Vector3.UpReadOnly, this._upVector, this._YToUpMatrix),
- Matrix.RotationAlignToRef(this._upVector, Vector3.UpReadOnly, this._upToYMatrix)
- }
- ,
- Object.defineProperty(e.prototype, "angularSensibilityX", {
- get: function() {
- var i = this.inputs.attached.pointers;
- return i ? i.angularSensibilityX : 0
- },
- set: function(i) {
- var o = this.inputs.attached.pointers;
- o && (o.angularSensibilityX = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "angularSensibilityY", {
- get: function() {
- var i = this.inputs.attached.pointers;
- return i ? i.angularSensibilityY : 0
- },
- set: function(i) {
- var o = this.inputs.attached.pointers;
- o && (o.angularSensibilityY = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "pinchPrecision", {
- get: function() {
- var i = this.inputs.attached.pointers;
- return i ? i.pinchPrecision : 0
- },
- set: function(i) {
- var o = this.inputs.attached.pointers;
- o && (o.pinchPrecision = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "pinchDeltaPercentage", {
- get: function() {
- var i = this.inputs.attached.pointers;
- return i ? i.pinchDeltaPercentage : 0
- },
- set: function(i) {
- var o = this.inputs.attached.pointers;
- o && (o.pinchDeltaPercentage = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "useNaturalPinchZoom", {
- get: function() {
- var i = this.inputs.attached.pointers;
- return i ? i.useNaturalPinchZoom : !1
- },
- set: function(i) {
- var o = this.inputs.attached.pointers;
- o && (o.useNaturalPinchZoom = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "panningSensibility", {
- get: function() {
- var i = this.inputs.attached.pointers;
- return i ? i.panningSensibility : 0
- },
- set: function(i) {
- var o = this.inputs.attached.pointers;
- o && (o.panningSensibility = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "keysUp", {
- get: function() {
- var i = this.inputs.attached.keyboard;
- return i ? i.keysUp : []
- },
- set: function(i) {
- var o = this.inputs.attached.keyboard;
- o && (o.keysUp = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "keysDown", {
- get: function() {
- var i = this.inputs.attached.keyboard;
- return i ? i.keysDown : []
- },
- set: function(i) {
- var o = this.inputs.attached.keyboard;
- o && (o.keysDown = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "keysLeft", {
- get: function() {
- var i = this.inputs.attached.keyboard;
- return i ? i.keysLeft : []
- },
- set: function(i) {
- var o = this.inputs.attached.keyboard;
- o && (o.keysLeft = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "keysRight", {
- get: function() {
- var i = this.inputs.attached.keyboard;
- return i ? i.keysRight : []
- },
- set: function(i) {
- var o = this.inputs.attached.keyboard;
- o && (o.keysRight = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "wheelPrecision", {
- get: function() {
- var i = this.inputs.attached.mousewheel;
- return i ? i.wheelPrecision : 0
- },
- set: function(i) {
- var o = this.inputs.attached.mousewheel;
- o && (o.wheelPrecision = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "zoomToMouseLocation", {
- get: function() {
- var i = this.inputs.attached.mousewheel;
- return i ? i.zoomToMouseLocation : !1
- },
- set: function(i) {
- var o = this.inputs.attached.mousewheel;
- o && (o.zoomToMouseLocation = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "wheelDeltaPercentage", {
- get: function() {
- var i = this.inputs.attached.mousewheel;
- return i ? i.wheelDeltaPercentage : 0
- },
- set: function(i) {
- var o = this.inputs.attached.mousewheel;
- o && (o.wheelDeltaPercentage = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "bouncingBehavior", {
- get: function() {
- return this._bouncingBehavior
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "useBouncingBehavior", {
- get: function() {
- return this._bouncingBehavior != null
- },
- set: function(i) {
- i !== this.useBouncingBehavior && (i ? (this._bouncingBehavior = new BouncingBehavior,
- this.addBehavior(this._bouncingBehavior)) : this._bouncingBehavior && (this.removeBehavior(this._bouncingBehavior),
- this._bouncingBehavior = null))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "framingBehavior", {
- get: function() {
- return this._framingBehavior
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "useFramingBehavior", {
- get: function() {
- return this._framingBehavior != null
- },
- set: function(i) {
- i !== this.useFramingBehavior && (i ? (this._framingBehavior = new FramingBehavior,
- this.addBehavior(this._framingBehavior)) : this._framingBehavior && (this.removeBehavior(this._framingBehavior),
- this._framingBehavior = null))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "autoRotationBehavior", {
- get: function() {
- return this._autoRotationBehavior
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "useAutoRotationBehavior", {
- get: function() {
- return this._autoRotationBehavior != null
- },
- set: function(i) {
- i !== this.useAutoRotationBehavior && (i ? (this._autoRotationBehavior = new AutoRotationBehavior,
- this.addBehavior(this._autoRotationBehavior)) : this._autoRotationBehavior && (this.removeBehavior(this._autoRotationBehavior),
- this._autoRotationBehavior = null))
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._initCache = function() {
- a.prototype._initCache.call(this),
- this._cache._target = new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
- this._cache.alpha = void 0,
- this._cache.beta = void 0,
- this._cache.radius = void 0,
- this._cache.targetScreenOffset = Vector2.Zero()
- }
- ,
- e.prototype._updateCache = function(i) {
- i || a.prototype._updateCache.call(this),
- this._cache._target.copyFrom(this._getTargetPosition()),
- this._cache.alpha = this.alpha,
- this._cache.beta = this.beta,
- this._cache.radius = this.radius,
- this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset)
- }
- ,
- e.prototype._getTargetPosition = function() {
- if (this._targetHost && this._targetHost.getAbsolutePosition) {
- var i = this._targetHost.getAbsolutePosition();
- this._targetBoundingCenter ? i.addToRef(this._targetBoundingCenter, this._target) : this._target.copyFrom(i)
- }
- var o = this._getLockedTargetPosition();
- return o || this._target
- }
- ,
- e.prototype.storeState = function() {
- return this._storedAlpha = this.alpha,
- this._storedBeta = this.beta,
- this._storedRadius = this.radius,
- this._storedTarget = this._getTargetPosition().clone(),
- this._storedTargetScreenOffset = this.targetScreenOffset.clone(),
- a.prototype.storeState.call(this)
- }
- ,
- e.prototype._restoreStateValues = function() {
- return a.prototype._restoreStateValues.call(this) ? (this.setTarget(this._storedTarget.clone()),
- this.alpha = this._storedAlpha,
- this.beta = this._storedBeta,
- this.radius = this._storedRadius,
- this.targetScreenOffset = this._storedTargetScreenOffset.clone(),
- this.inertialAlphaOffset = 0,
- this.inertialBetaOffset = 0,
- this.inertialRadiusOffset = 0,
- this.inertialPanningX = 0,
- this.inertialPanningY = 0,
- !0) : !1
- }
- ,
- e.prototype._isSynchronizedViewMatrix = function() {
- 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
- }
- ,
- e.prototype.attachControl = function(i, o, s, c) {
- var d = this;
- s === void 0 && (s = !0),
- c === void 0 && (c = 2),
- o = Tools.BackCompatCameraNoPreventDefault(arguments),
- this._useCtrlForPanning = s,
- this._panningMouseButton = c,
- typeof arguments[0] == "boolean" && (arguments.length > 1 && (this._useCtrlForPanning = arguments[1]),
- arguments.length > 2 && (this._panningMouseButton = arguments[2])),
- this.inputs.attachElement(o),
- this._reset = function() {
- d.inertialAlphaOffset = 0,
- d.inertialBetaOffset = 0,
- d.inertialRadiusOffset = 0,
- d.inertialPanningX = 0,
- d.inertialPanningY = 0
- }
- }
- ,
- e.prototype.detachControl = function(i) {
- this.inputs.detachElement(),
- this._reset && this._reset()
- }
- ,
- e.prototype._checkInputs = function() {
- if (!this._collisionTriggered) {
- if (this.inputs.checkInputs(),
- this.inertialAlphaOffset !== 0 || this.inertialBetaOffset !== 0 || this.inertialRadiusOffset !== 0) {
- var i = this.inertialAlphaOffset;
- this.beta <= 0 && (i *= -1),
- this.getScene().useRightHandedSystem && (i *= -1),
- this.parent && this.parent._getWorldMatrixDeterminant() < 0 && (i *= -1),
- this.alpha += i,
- this.beta += this.inertialBetaOffset,
- this.radius -= this.inertialRadiusOffset,
- this.inertialAlphaOffset *= this.inertia,
- this.inertialBetaOffset *= this.inertia,
- this.inertialRadiusOffset *= this.inertia,
- Math.abs(this.inertialAlphaOffset) < Epsilon && (this.inertialAlphaOffset = 0),
- Math.abs(this.inertialBetaOffset) < Epsilon && (this.inertialBetaOffset = 0),
- Math.abs(this.inertialRadiusOffset) < this.speed * Epsilon && (this.inertialRadiusOffset = 0)
- }
- if (this.inertialPanningX !== 0 || this.inertialPanningY !== 0) {
- var o = new Vector3(this.inertialPanningX,this.inertialPanningY,this.inertialPanningY);
- if (this._viewMatrix.invertToRef(this._cameraTransformMatrix),
- o.multiplyInPlace(this.panningAxis),
- Vector3.TransformNormalToRef(o, this._cameraTransformMatrix, this._transformedDirection),
- this.mapPanning && (this._transformedDirection.y = 0),
- !this._targetHost)
- if (this.panningDistanceLimit) {
- this._transformedDirection.addInPlace(this._target);
- var s = Vector3.DistanceSquared(this._transformedDirection, this.panningOriginTarget);
- s <= this.panningDistanceLimit * this.panningDistanceLimit && this._target.copyFrom(this._transformedDirection)
- } else
- this._target.addInPlace(this._transformedDirection);
- this.inertialPanningX *= this.panningInertia,
- this.inertialPanningY *= this.panningInertia,
- Math.abs(this.inertialPanningX) < this.speed * Epsilon && (this.inertialPanningX = 0),
- Math.abs(this.inertialPanningY) < this.speed * Epsilon && (this.inertialPanningY = 0)
- }
- this._checkLimits(),
- a.prototype._checkInputs.call(this)
- }
- }
- ,
- e.prototype._checkLimits = function() {
- 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),
- 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),
- this.lowerAlphaLimit !== null && this.alpha < this.lowerAlphaLimit && (this.alpha = this.lowerAlphaLimit),
- this.upperAlphaLimit !== null && this.alpha > this.upperAlphaLimit && (this.alpha = this.upperAlphaLimit),
- this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit && (this.radius = this.lowerRadiusLimit,
- this.inertialRadiusOffset = 0),
- this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit && (this.radius = this.upperRadiusLimit,
- this.inertialRadiusOffset = 0)
- }
- ,
- e.prototype.rebuildAnglesAndRadius = function() {
- this._position.subtractToRef(this._getTargetPosition(), this._computationVector),
- (this._upVector.x !== 0 || this._upVector.y !== 1 || this._upVector.z !== 0) && Vector3.TransformCoordinatesToRef(this._computationVector, this._upToYMatrix, this._computationVector),
- this.radius = this._computationVector.length(),
- this.radius === 0 && (this.radius = 1e-4);
- var i = this.alpha;
- 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))),
- this._computationVector.z < 0 && (this.alpha = 2 * Math.PI - this.alpha);
- var o = Math.round((i - this.alpha) / (2 * Math.PI));
- this.alpha += o * 2 * Math.PI,
- this.beta = Math.acos(this._computationVector.y / this.radius),
- this._checkLimits()
- }
- ,
- e.prototype.setPosition = function(i) {
- this._position.equals(i) || (this._position.copyFrom(i),
- this.rebuildAnglesAndRadius())
- }
- ,
- e.prototype.setTarget = function(i, o, s) {
- if (o === void 0 && (o = !1),
- s === void 0 && (s = !1),
- i.getBoundingInfo)
- o ? this._targetBoundingCenter = i.getBoundingInfo().boundingBox.centerWorld.clone() : this._targetBoundingCenter = null,
- i.computeWorldMatrix(),
- this._targetHost = i,
- this._target = this._getTargetPosition(),
- this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);
- else {
- var c = i
- , d = this._getTargetPosition();
- if (d && !s && d.equals(c))
- return;
- this._targetHost = null,
- this._target = c,
- this._targetBoundingCenter = null,
- this.onMeshTargetChangedObservable.notifyObservers(null)
- }
- this.rebuildAnglesAndRadius()
- }
- ,
- e.prototype._getViewMatrix = function() {
- var i = Math.cos(this.alpha)
- , o = Math.sin(this.alpha)
- , s = Math.cos(this.beta)
- , c = Math.sin(this.beta);
- c === 0 && (c = 1e-4),
- this.radius === 0 && (this.radius = 1e-4);
- var d = this._getTargetPosition();
- if (this._computationVector.copyFromFloats(this.radius * i * c, this.radius * s, this.radius * o * c),
- (this._upVector.x !== 0 || this._upVector.y !== 1 || this._upVector.z !== 0) && Vector3.TransformCoordinatesToRef(this._computationVector, this._YToUpMatrix, this._computationVector),
- d.addToRef(this._computationVector, this._newPosition),
- this.getScene().collisionsEnabled && this.checkCollisions) {
- var _ = this.getScene().collisionCoordinator;
- this._collider || (this._collider = _.createCollider()),
- this._collider._radius = this.collisionRadius,
- this._newPosition.subtractToRef(this._position, this._collisionVelocity),
- this._collisionTriggered = !0,
- _.getNewPosition(this._position, this._collisionVelocity, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId)
- } else {
- this._position.copyFrom(this._newPosition);
- var b = this.upVector;
- this.allowUpsideDown && c < 0 && (b = b.negate()),
- this._computeViewMatrix(this._position, d, b),
- this._viewMatrix.addAtIndex(12, this.targetScreenOffset.x),
- this._viewMatrix.addAtIndex(13, this.targetScreenOffset.y)
- }
- return this._currentTarget = d,
- this._viewMatrix
- }
- ,
- e.prototype.zoomOn = function(i, o) {
- o === void 0 && (o = !1),
- i = i || this.getScene().meshes;
- var s = Mesh.MinMax(i)
- , c = Vector3.Distance(s.min, s.max);
- this.radius = c * this.zoomOnFactor,
- this.focusOn({
- min: s.min,
- max: s.max,
- distance: c
- }, o)
- }
- ,
- e.prototype.focusOn = function(i, o) {
- o === void 0 && (o = !1);
- var s, c;
- if (i.min === void 0) {
- var d = i || this.getScene().meshes;
- s = Mesh.MinMax(d),
- c = Vector3.Distance(s.min, s.max)
- } else {
- var _ = i;
- s = _,
- c = _.distance
- }
- this._target = Mesh.Center(s),
- o || (this.maxZ = c * 2)
- }
- ,
- e.prototype.createRigCamera = function(i, o) {
- var s = 0;
- switch (this.cameraRigMode) {
- case Camera$1.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
- case Camera$1.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
- case Camera$1.RIG_MODE_STEREOSCOPIC_OVERUNDER:
- case Camera$1.RIG_MODE_STEREOSCOPIC_INTERLACED:
- case Camera$1.RIG_MODE_VR:
- s = this._cameraRigParams.stereoHalfAngle * (o === 0 ? 1 : -1);
- break;
- case Camera$1.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
- s = this._cameraRigParams.stereoHalfAngle * (o === 0 ? -1 : 1);
- break
- }
- var c = new e(i,this.alpha + s,this.beta,this.radius,this._target,this.getScene());
- return c._cameraRigParams = {},
- c.isRigCamera = !0,
- c.rigParent = this,
- c.upVector = this.upVector,
- c
- }
- ,
- e.prototype._updateRigCameras = function() {
- var i = this._rigCameras[0]
- , o = this._rigCameras[1];
- switch (i.beta = o.beta = this.beta,
- this.cameraRigMode) {
- case Camera$1.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
- case Camera$1.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
- case Camera$1.RIG_MODE_STEREOSCOPIC_OVERUNDER:
- case Camera$1.RIG_MODE_STEREOSCOPIC_INTERLACED:
- case Camera$1.RIG_MODE_VR:
- i.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle,
- o.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
- break;
- case Camera$1.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
- i.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle,
- o.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
- break
- }
- a.prototype._updateRigCameras.call(this)
- }
- ,
- e.prototype.dispose = function() {
- this.inputs.clear(),
- a.prototype.dispose.call(this)
- }
- ,
- e.prototype.getClassName = function() {
- return "ArcRotateCamera"
- }
- ,
- __decorate([serialize()], e.prototype, "alpha", void 0),
- __decorate([serialize()], e.prototype, "beta", void 0),
- __decorate([serialize()], e.prototype, "radius", void 0),
- __decorate([serializeAsVector3("target")], e.prototype, "_target", void 0),
- __decorate([serializeAsMeshReference("targetHost")], e.prototype, "_targetHost", void 0),
- __decorate([serialize()], e.prototype, "inertialAlphaOffset", void 0),
- __decorate([serialize()], e.prototype, "inertialBetaOffset", void 0),
- __decorate([serialize()], e.prototype, "inertialRadiusOffset", void 0),
- __decorate([serialize()], e.prototype, "lowerAlphaLimit", void 0),
- __decorate([serialize()], e.prototype, "upperAlphaLimit", void 0),
- __decorate([serialize()], e.prototype, "lowerBetaLimit", void 0),
- __decorate([serialize()], e.prototype, "upperBetaLimit", void 0),
- __decorate([serialize()], e.prototype, "lowerRadiusLimit", void 0),
- __decorate([serialize()], e.prototype, "upperRadiusLimit", void 0),
- __decorate([serialize()], e.prototype, "inertialPanningX", void 0),
- __decorate([serialize()], e.prototype, "inertialPanningY", void 0),
- __decorate([serialize()], e.prototype, "pinchToPanMaxDistance", void 0),
- __decorate([serialize()], e.prototype, "panningDistanceLimit", void 0),
- __decorate([serializeAsVector3()], e.prototype, "panningOriginTarget", void 0),
- __decorate([serialize()], e.prototype, "panningInertia", void 0),
- __decorate([serialize()], e.prototype, "zoomToMouseLocation", null),
- __decorate([serialize()], e.prototype, "zoomOnFactor", void 0),
- __decorate([serialize()], e.prototype, "targetScreenOffset", void 0),
- __decorate([serialize()], e.prototype, "allowUpsideDown", void 0),
- __decorate([serialize()], e.prototype, "useInputToRestoreState", void 0),
- e
- }(TargetCamera)
- , FreeCameraKeyboardMoveInput = function() {
- function a() {
- this.keysUp = [38],
- this.keysUpward = [33],
- this.keysDown = [40],
- this.keysDownward = [34],
- this.keysLeft = [37],
- this.keysRight = [39],
- this.rotationSpeed = .5,
- this.keysRotateLeft = [],
- this.keysRotateRight = [],
- this._keys = new Array
- }
- return a.prototype.attachControl = function(e) {
- var i = this;
- e = Tools.BackCompatCameraNoPreventDefault(arguments),
- !this._onCanvasBlurObserver && (this._scene = this.camera.getScene(),
- this._engine = this._scene.getEngine(),
- this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function() {
- i._keys = []
- }),
- this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function(o) {
- var s = o.event;
- if (!s.metaKey) {
- if (o.type === KeyboardEventTypes.KEYDOWN) {
- 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) {
- var c = i._keys.indexOf(s.keyCode);
- c === -1 && i._keys.push(s.keyCode),
- e || s.preventDefault()
- }
- } 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) {
- var c = i._keys.indexOf(s.keyCode);
- c >= 0 && i._keys.splice(c, 1),
- e || s.preventDefault()
- }
- }
- }))
- }
- ,
- a.prototype.detachControl = function(e) {
- this._scene && (this._onKeyboardObserver && this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),
- this._onCanvasBlurObserver && this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),
- this._onKeyboardObserver = null,
- this._onCanvasBlurObserver = null),
- this._keys = []
- }
- ,
- a.prototype.checkInputs = function() {
- if (this._onKeyboardObserver)
- for (var e = this.camera, i = 0; i < this._keys.length; i++) {
- var o = this._keys[i]
- , s = e._computeLocalCameraSpeed();
- 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),
- e.cameraRotation.y -= this._getLocalRotation()) : this.keysRotateRight.indexOf(o) !== -1 && (e._localDirection.copyFromFloats(0, 0, 0),
- e.cameraRotation.y += this._getLocalRotation()),
- e.getScene().useRightHandedSystem && (e._localDirection.z *= -1),
- e.getViewMatrix().invertToRef(e._cameraTransformMatrix),
- Vector3.TransformNormalToRef(e._localDirection, e._cameraTransformMatrix, e._transformedDirection),
- e.cameraDirection.addInPlace(e._transformedDirection)
- }
- }
- ,
- a.prototype.getClassName = function() {
- return "FreeCameraKeyboardMoveInput"
- }
- ,
- a.prototype._onLostFocus = function() {
- this._keys = []
- }
- ,
- a.prototype.getSimpleName = function() {
- return "keyboard"
- }
- ,
- a.prototype._getLocalRotation = function() {
- var e = this.rotationSpeed * this._engine.getDeltaTime() / 1e3;
- return this.camera.getScene().useRightHandedSystem && (e *= -1),
- this.camera.parent && this.camera.parent._getWorldMatrixDeterminant() < 0 && (e *= -1),
- e
- }
- ,
- __decorate([serialize()], a.prototype, "keysUp", void 0),
- __decorate([serialize()], a.prototype, "keysUpward", void 0),
- __decorate([serialize()], a.prototype, "keysDown", void 0),
- __decorate([serialize()], a.prototype, "keysDownward", void 0),
- __decorate([serialize()], a.prototype, "keysLeft", void 0),
- __decorate([serialize()], a.prototype, "keysRight", void 0),
- __decorate([serialize()], a.prototype, "rotationSpeed", void 0),
- __decorate([serialize()], a.prototype, "keysRotateLeft", void 0),
- __decorate([serialize()], a.prototype, "keysRotateRight", void 0),
- a
- }();
- CameraInputTypes.FreeCameraKeyboardMoveInput = FreeCameraKeyboardMoveInput;
- var FreeCameraMouseInput = function() {
- function a(e) {
- e === void 0 && (e = !0),
- this.touchEnabled = e,
- this.buttons = [0, 1, 2],
- this.angularSensibility = 2e3,
- this.previousPosition = null,
- this.onPointerMovedObservable = new Observable,
- this._allowCameraRotation = !0,
- this._currentActiveButton = -1
- }
- return a.prototype.attachControl = function(e) {
- var i = this;
- e = Tools.BackCompatCameraNoPreventDefault(arguments);
- var o = this.camera.getEngine()
- , s = o.getInputElement();
- this._pointerInput || (this._pointerInput = function(c) {
- var d = c.event
- , _ = d.pointerType === "touch";
- if (!o.isInVRExclusivePointerMode && !(!i.touchEnabled && _) && !(c.type !== PointerEventTypes.POINTERMOVE && i.buttons.indexOf(d.button) === -1)) {
- var b = d.srcElement || d.target;
- if (c.type === PointerEventTypes.POINTERDOWN && (i._currentActiveButton === -1 || _)) {
- try {
- b == null || b.setPointerCapture(d.pointerId)
- } catch {}
- i._currentActiveButton === -1 && (i._currentActiveButton = d.button),
- i.previousPosition = {
- x: d.clientX,
- y: d.clientY
- },
- e || (d.preventDefault(),
- s && s.focus()),
- o.isPointerLock && i._onMouseMove && i._onMouseMove(c.event)
- } else if (c.type === PointerEventTypes.POINTERUP && (i._currentActiveButton === d.button || _)) {
- try {
- b == null || b.releasePointerCapture(d.pointerId)
- } catch {}
- i._currentActiveButton = -1,
- i.previousPosition = null,
- e || d.preventDefault()
- } else if (c.type === PointerEventTypes.POINTERMOVE) {
- if (o.isPointerLock && i._onMouseMove)
- i._onMouseMove(c.event);
- else if (i.previousPosition) {
- var k = d.clientX - i.previousPosition.x
- , j = d.clientY - i.previousPosition.y;
- i.camera.getScene().useRightHandedSystem && (k *= -1),
- i.camera.parent && i.camera.parent._getWorldMatrixDeterminant() < 0 && (k *= -1),
- i._allowCameraRotation && (i.camera.cameraRotation.y += k / i.angularSensibility,
- i.camera.cameraRotation.x += j / i.angularSensibility),
- i.onPointerMovedObservable.notifyObservers({
- offsetX: k,
- offsetY: j
- }),
- i.previousPosition = {
- x: d.clientX,
- y: d.clientY
- },
- e || d.preventDefault()
- }
- }
- }
- }
- ),
- this._onMouseMove = function(c) {
- if (!!o.isPointerLock && !o.isInVRExclusivePointerMode) {
- var d = c.movementX || c.mozMovementX || c.webkitMovementX || c.msMovementX || 0;
- i.camera.getScene().useRightHandedSystem && (d *= -1),
- i.camera.parent && i.camera.parent._getWorldMatrixDeterminant() < 0 && (d *= -1),
- i.camera.cameraRotation.y += d / i.angularSensibility;
- var _ = c.movementY || c.mozMovementY || c.webkitMovementY || c.msMovementY || 0;
- i.camera.cameraRotation.x += _ / i.angularSensibility,
- i.previousPosition = null,
- e || c.preventDefault()
- }
- }
- ,
- this._observer = this.camera.getScene().onPointerObservable.add(this._pointerInput, PointerEventTypes.POINTERDOWN | PointerEventTypes.POINTERUP | PointerEventTypes.POINTERMOVE),
- s && s.addEventListener("contextmenu", this.onContextMenu.bind(this), !1)
- }
- ,
- a.prototype.onContextMenu = function(e) {
- e.preventDefault()
- }
- ,
- a.prototype.detachControl = function(e) {
- if (this._observer) {
- if (this.camera.getScene().onPointerObservable.remove(this._observer),
- this.onContextMenu) {
- var i = this.camera.getEngine()
- , o = i.getInputElement();
- o && o.removeEventListener("contextmenu", this.onContextMenu)
- }
- this.onPointerMovedObservable && this.onPointerMovedObservable.clear(),
- this._observer = null,
- this._onMouseMove = null,
- this.previousPosition = null
- }
- }
- ,
- a.prototype.getClassName = function() {
- return "FreeCameraMouseInput"
- }
- ,
- a.prototype.getSimpleName = function() {
- return "mouse"
- }
- ,
- __decorate([serialize()], a.prototype, "buttons", void 0),
- __decorate([serialize()], a.prototype, "angularSensibility", void 0),
- a
- }();
- CameraInputTypes.FreeCameraMouseInput = FreeCameraMouseInput;
- var BaseCameraMouseWheelInput = function() {
- function a() {
- this.wheelPrecisionX = 3,
- this.wheelPrecisionY = 3,
- this.wheelPrecisionZ = 3,
- this.onChangedObservable = new Observable,
- this._wheelDeltaX = 0,
- this._wheelDeltaY = 0,
- this._wheelDeltaZ = 0,
- this._ffMultiplier = 12,
- this._normalize = 120
- }
- return a.prototype.attachControl = function(e) {
- var i = this;
- e = Tools.BackCompatCameraNoPreventDefault(arguments),
- this._wheel = function(o) {
- if (o.type === PointerEventTypes.POINTERWHEEL) {
- var s = o.event
- , c = s.deltaMode === EventConstants.DOM_DELTA_LINE ? i._ffMultiplier : 1;
- s.deltaY !== void 0 ? (i._wheelDeltaX += i.wheelPrecisionX * c * s.deltaX / i._normalize,
- i._wheelDeltaY -= i.wheelPrecisionY * c * s.deltaY / i._normalize,
- i._wheelDeltaZ += i.wheelPrecisionZ * c * s.deltaZ / i._normalize) : s.wheelDeltaY !== void 0 ? (i._wheelDeltaX += i.wheelPrecisionX * c * s.wheelDeltaX / i._normalize,
- i._wheelDeltaY -= i.wheelPrecisionY * c * s.wheelDeltaY / i._normalize,
- i._wheelDeltaZ += i.wheelPrecisionZ * c * s.wheelDeltaZ / i._normalize) : s.wheelDelta && (i._wheelDeltaY -= i.wheelPrecisionY * s.wheelDelta / i._normalize),
- s.preventDefault && (e || s.preventDefault())
- }
- }
- ,
- this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, PointerEventTypes.POINTERWHEEL)
- }
- ,
- a.prototype.detachControl = function(e) {
- this._observer && (this.camera.getScene().onPointerObservable.remove(this._observer),
- this._observer = null,
- this._wheel = null),
- this.onChangedObservable && this.onChangedObservable.clear()
- }
- ,
- a.prototype.checkInputs = function() {
- this.onChangedObservable.notifyObservers({
- wheelDeltaX: this._wheelDeltaX,
- wheelDeltaY: this._wheelDeltaY,
- wheelDeltaZ: this._wheelDeltaZ
- }),
- this._wheelDeltaX = 0,
- this._wheelDeltaY = 0,
- this._wheelDeltaZ = 0
- }
- ,
- a.prototype.getClassName = function() {
- return "BaseCameraMouseWheelInput"
- }
- ,
- a.prototype.getSimpleName = function() {
- return "mousewheel"
- }
- ,
- __decorate([serialize()], a.prototype, "wheelPrecisionX", void 0),
- __decorate([serialize()], a.prototype, "wheelPrecisionY", void 0),
- __decorate([serialize()], a.prototype, "wheelPrecisionZ", void 0),
- a
- }(), _CameraProperty;
- (function(a) {
- a[a.MoveRelative = 0] = "MoveRelative",
- a[a.RotateRelative = 1] = "RotateRelative",
- a[a.MoveScene = 2] = "MoveScene"
- }
- )(_CameraProperty || (_CameraProperty = {}));
- var FreeCameraMouseWheelInput = function(a) {
- __extends(e, a);
- function e() {
- var i = a !== null && a.apply(this, arguments) || this;
- return i._moveRelative = Vector3.Zero(),
- i._rotateRelative = Vector3.Zero(),
- i._moveScene = Vector3.Zero(),
- i._wheelXAction = _CameraProperty.MoveRelative,
- i._wheelXActionCoordinate = Coordinate.X,
- i._wheelYAction = _CameraProperty.MoveRelative,
- i._wheelYActionCoordinate = Coordinate.Z,
- i._wheelZAction = null,
- i._wheelZActionCoordinate = null,
- i
- }
- return e.prototype.getClassName = function() {
- return "FreeCameraMouseWheelInput"
- }
- ,
- Object.defineProperty(e.prototype, "wheelXMoveRelative", {
- get: function() {
- return this._wheelXAction !== _CameraProperty.MoveRelative ? null : this._wheelXActionCoordinate
- },
- set: function(i) {
- i === null && this._wheelXAction !== _CameraProperty.MoveRelative || (this._wheelXAction = _CameraProperty.MoveRelative,
- this._wheelXActionCoordinate = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "wheelYMoveRelative", {
- get: function() {
- return this._wheelYAction !== _CameraProperty.MoveRelative ? null : this._wheelYActionCoordinate
- },
- set: function(i) {
- i === null && this._wheelYAction !== _CameraProperty.MoveRelative || (this._wheelYAction = _CameraProperty.MoveRelative,
- this._wheelYActionCoordinate = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "wheelZMoveRelative", {
- get: function() {
- return this._wheelZAction !== _CameraProperty.MoveRelative ? null : this._wheelZActionCoordinate
- },
- set: function(i) {
- i === null && this._wheelZAction !== _CameraProperty.MoveRelative || (this._wheelZAction = _CameraProperty.MoveRelative,
- this._wheelZActionCoordinate = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "wheelXRotateRelative", {
- get: function() {
- return this._wheelXAction !== _CameraProperty.RotateRelative ? null : this._wheelXActionCoordinate
- },
- set: function(i) {
- i === null && this._wheelXAction !== _CameraProperty.RotateRelative || (this._wheelXAction = _CameraProperty.RotateRelative,
- this._wheelXActionCoordinate = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "wheelYRotateRelative", {
- get: function() {
- return this._wheelYAction !== _CameraProperty.RotateRelative ? null : this._wheelYActionCoordinate
- },
- set: function(i) {
- i === null && this._wheelYAction !== _CameraProperty.RotateRelative || (this._wheelYAction = _CameraProperty.RotateRelative,
- this._wheelYActionCoordinate = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "wheelZRotateRelative", {
- get: function() {
- return this._wheelZAction !== _CameraProperty.RotateRelative ? null : this._wheelZActionCoordinate
- },
- set: function(i) {
- i === null && this._wheelZAction !== _CameraProperty.RotateRelative || (this._wheelZAction = _CameraProperty.RotateRelative,
- this._wheelZActionCoordinate = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "wheelXMoveScene", {
- get: function() {
- return this._wheelXAction !== _CameraProperty.MoveScene ? null : this._wheelXActionCoordinate
- },
- set: function(i) {
- i === null && this._wheelXAction !== _CameraProperty.MoveScene || (this._wheelXAction = _CameraProperty.MoveScene,
- this._wheelXActionCoordinate = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "wheelYMoveScene", {
- get: function() {
- return this._wheelYAction !== _CameraProperty.MoveScene ? null : this._wheelYActionCoordinate
- },
- set: function(i) {
- i === null && this._wheelYAction !== _CameraProperty.MoveScene || (this._wheelYAction = _CameraProperty.MoveScene,
- this._wheelYActionCoordinate = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "wheelZMoveScene", {
- get: function() {
- return this._wheelZAction !== _CameraProperty.MoveScene ? null : this._wheelZActionCoordinate
- },
- set: function(i) {
- i === null && this._wheelZAction !== _CameraProperty.MoveScene || (this._wheelZAction = _CameraProperty.MoveScene,
- this._wheelZActionCoordinate = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.checkInputs = function() {
- if (!(this._wheelDeltaX === 0 && this._wheelDeltaY === 0 && this._wheelDeltaZ == 0)) {
- this._moveRelative.setAll(0),
- this._rotateRelative.setAll(0),
- this._moveScene.setAll(0),
- this._updateCamera(),
- this.camera.getScene().useRightHandedSystem && (this._moveRelative.z *= -1);
- var i = Matrix.Zero();
- this.camera.getViewMatrix().invertToRef(i);
- var o = Vector3.Zero();
- Vector3.TransformNormalToRef(this._moveRelative, i, o),
- this.camera.cameraRotation.x += this._rotateRelative.x / 200,
- this.camera.cameraRotation.y += this._rotateRelative.y / 200,
- this.camera.cameraDirection.addInPlace(o),
- this.camera.cameraDirection.addInPlace(this._moveScene),
- a.prototype.checkInputs.call(this)
- }
- }
- ,
- e.prototype._updateCamera = function() {
- this._updateCameraProperty(this._wheelDeltaX, this._wheelXAction, this._wheelXActionCoordinate),
- this._updateCameraProperty(this._wheelDeltaY, this._wheelYAction, this._wheelYActionCoordinate),
- this._updateCameraProperty(this._wheelDeltaZ, this._wheelZAction, this._wheelZActionCoordinate)
- }
- ,
- e.prototype._updateCameraProperty = function(i, o, s) {
- if (i !== 0 && !(o === null || s === null)) {
- var c = null;
- switch (o) {
- case _CameraProperty.MoveRelative:
- c = this._moveRelative;
- break;
- case _CameraProperty.RotateRelative:
- c = this._rotateRelative;
- break;
- case _CameraProperty.MoveScene:
- c = this._moveScene;
- break
- }
- switch (s) {
- case Coordinate.X:
- c.set(i, 0, 0);
- break;
- case Coordinate.Y:
- c.set(0, i, 0);
- break;
- case Coordinate.Z:
- c.set(0, 0, i);
- break
- }
- }
- }
- ,
- __decorate([serialize()], e.prototype, "wheelXMoveRelative", null),
- __decorate([serialize()], e.prototype, "wheelYMoveRelative", null),
- __decorate([serialize()], e.prototype, "wheelZMoveRelative", null),
- __decorate([serialize()], e.prototype, "wheelXRotateRelative", null),
- __decorate([serialize()], e.prototype, "wheelYRotateRelative", null),
- __decorate([serialize()], e.prototype, "wheelZRotateRelative", null),
- __decorate([serialize()], e.prototype, "wheelXMoveScene", null),
- __decorate([serialize()], e.prototype, "wheelYMoveScene", null),
- __decorate([serialize()], e.prototype, "wheelZMoveScene", null),
- e
- }(BaseCameraMouseWheelInput);
- CameraInputTypes.FreeCameraMouseWheelInput = FreeCameraMouseWheelInput;
- var FreeCameraTouchInput = function() {
- function a(e) {
- e === void 0 && (e = !1),
- this.allowMouse = e,
- this.touchAngularSensibility = 2e5,
- this.touchMoveSensibility = 250,
- this.singleFingerRotate = !1,
- this._offsetX = null,
- this._offsetY = null,
- this._pointerPressed = new Array
- }
- return a.prototype.attachControl = function(e) {
- var i = this;
- e = Tools.BackCompatCameraNoPreventDefault(arguments);
- var o = null;
- if (this._pointerInput === void 0 && (this._onLostFocus = function() {
- i._offsetX = null,
- i._offsetY = null
- }
- ,
- this._pointerInput = function(d) {
- var _ = d.event
- , b = !i.camera.getEngine().hostInformation.isMobile && _ instanceof MouseEvent;
- if (!(!i.allowMouse && (_.pointerType === "mouse" || b))) {
- if (d.type === PointerEventTypes.POINTERDOWN) {
- if (e || _.preventDefault(),
- i._pointerPressed.push(_.pointerId),
- i._pointerPressed.length !== 1)
- return;
- o = {
- x: _.clientX,
- y: _.clientY
- }
- } else if (d.type === PointerEventTypes.POINTERUP) {
- e || _.preventDefault();
- var k = i._pointerPressed.indexOf(_.pointerId);
- if (k === -1 || (i._pointerPressed.splice(k, 1),
- k != 0))
- return;
- o = null,
- i._offsetX = null,
- i._offsetY = null
- } else if (d.type === PointerEventTypes.POINTERMOVE) {
- if (e || _.preventDefault(),
- !o)
- return;
- var k = i._pointerPressed.indexOf(_.pointerId);
- if (k != 0)
- return;
- i._offsetX = _.clientX - o.x,
- i._offsetY = -(_.clientY - o.y)
- }
- }
- }
- ),
- this._observer = this.camera.getScene().onPointerObservable.add(this._pointerInput, PointerEventTypes.POINTERDOWN | PointerEventTypes.POINTERUP | PointerEventTypes.POINTERMOVE),
- this._onLostFocus) {
- var s = this.camera.getEngine()
- , c = s.getInputElement();
- c && c.addEventListener("blur", this._onLostFocus)
- }
- }
- ,
- a.prototype.detachControl = function(e) {
- if (this._pointerInput) {
- if (this._observer && (this.camera.getScene().onPointerObservable.remove(this._observer),
- this._observer = null),
- this._onLostFocus) {
- var i = this.camera.getEngine()
- , o = i.getInputElement();
- o && o.removeEventListener("blur", this._onLostFocus),
- this._onLostFocus = null
- }
- this._pointerPressed = [],
- this._offsetX = null,
- this._offsetY = null
- }
- }
- ,
- a.prototype.checkInputs = function() {
- if (!(this._offsetX === null || this._offsetY === null) && !(this._offsetX === 0 && this._offsetY === 0)) {
- var e = this.camera;
- e.cameraRotation.y = this._offsetX / this.touchAngularSensibility;
- var i = this.singleFingerRotate && this._pointerPressed.length === 1 || !this.singleFingerRotate && this._pointerPressed.length > 1;
- if (i)
- e.cameraRotation.x = -this._offsetY / this.touchAngularSensibility;
- else {
- var o = e._computeLocalCameraSpeed()
- , s = new Vector3(0,0,o * this._offsetY / this.touchMoveSensibility);
- Matrix.RotationYawPitchRollToRef(e.rotation.y, e.rotation.x, 0, e._cameraRotationMatrix),
- e.cameraDirection.addInPlace(Vector3.TransformCoordinates(s, e._cameraRotationMatrix))
- }
- }
- }
- ,
- a.prototype.getClassName = function() {
- return "FreeCameraTouchInput"
- }
- ,
- a.prototype.getSimpleName = function() {
- return "touch"
- }
- ,
- __decorate([serialize()], a.prototype, "touchAngularSensibility", void 0),
- __decorate([serialize()], a.prototype, "touchMoveSensibility", void 0),
- a
- }();
- CameraInputTypes.FreeCameraTouchInput = FreeCameraTouchInput;
- var FreeCameraInputsManager = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i) || this;
- return o._mouseInput = null,
- o._mouseWheelInput = null,
- o
- }
- return e.prototype.addKeyboard = function() {
- return this.add(new FreeCameraKeyboardMoveInput),
- this
- }
- ,
- e.prototype.addMouse = function(i) {
- return i === void 0 && (i = !0),
- this._mouseInput || (this._mouseInput = new FreeCameraMouseInput(i),
- this.add(this._mouseInput)),
- this
- }
- ,
- e.prototype.removeMouse = function() {
- return this._mouseInput && this.remove(this._mouseInput),
- this
- }
- ,
- e.prototype.addMouseWheel = function() {
- return this._mouseWheelInput || (this._mouseWheelInput = new FreeCameraMouseWheelInput,
- this.add(this._mouseWheelInput)),
- this
- }
- ,
- e.prototype.removeMouseWheel = function() {
- return this._mouseWheelInput && this.remove(this._mouseWheelInput),
- this
- }
- ,
- e.prototype.addTouch = function() {
- return this.add(new FreeCameraTouchInput),
- this
- }
- ,
- e.prototype.clear = function() {
- a.prototype.clear.call(this),
- this._mouseInput = null
- }
- ,
- e
- }(CameraInputsManager)
- , FreeCamera = function(a) {
- __extends(e, a);
- function e(i, o, s, c) {
- c === void 0 && (c = !0);
- var d = a.call(this, i, o, s, c) || this;
- return d.ellipsoid = new Vector3(.5,1,.5),
- d.ellipsoidOffset = new Vector3(0,0,0),
- d.checkCollisions = !1,
- d.applyGravity = !1,
- d._needMoveForGravity = !1,
- d._oldPosition = Vector3.Zero(),
- d._diffPosition = Vector3.Zero(),
- d._newPosition = Vector3.Zero(),
- d._collisionMask = -1,
- d._onCollisionPositionChange = function(_, b, k) {
- k === void 0 && (k = null);
- var j = function($) {
- d._newPosition.copyFrom($),
- d._newPosition.subtractToRef(d._oldPosition, d._diffPosition),
- d._diffPosition.length() > Engine.CollisionsEpsilon && (d.position.addInPlace(d._diffPosition),
- d.onCollide && k && d.onCollide(k))
- };
- j(b)
- }
- ,
- d.inputs = new FreeCameraInputsManager(d),
- d.inputs.addKeyboard().addMouse(),
- d
- }
- return Object.defineProperty(e.prototype, "angularSensibility", {
- get: function() {
- var i = this.inputs.attached.mouse;
- return i ? i.angularSensibility : 0
- },
- set: function(i) {
- var o = this.inputs.attached.mouse;
- o && (o.angularSensibility = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "keysUp", {
- get: function() {
- var i = this.inputs.attached.keyboard;
- return i ? i.keysUp : []
- },
- set: function(i) {
- var o = this.inputs.attached.keyboard;
- o && (o.keysUp = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "keysUpward", {
- get: function() {
- var i = this.inputs.attached.keyboard;
- return i ? i.keysUpward : []
- },
- set: function(i) {
- var o = this.inputs.attached.keyboard;
- o && (o.keysUpward = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "keysDown", {
- get: function() {
- var i = this.inputs.attached.keyboard;
- return i ? i.keysDown : []
- },
- set: function(i) {
- var o = this.inputs.attached.keyboard;
- o && (o.keysDown = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "keysDownward", {
- get: function() {
- var i = this.inputs.attached.keyboard;
- return i ? i.keysDownward : []
- },
- set: function(i) {
- var o = this.inputs.attached.keyboard;
- o && (o.keysDownward = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "keysLeft", {
- get: function() {
- var i = this.inputs.attached.keyboard;
- return i ? i.keysLeft : []
- },
- set: function(i) {
- var o = this.inputs.attached.keyboard;
- o && (o.keysLeft = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "keysRight", {
- get: function() {
- var i = this.inputs.attached.keyboard;
- return i ? i.keysRight : []
- },
- set: function(i) {
- var o = this.inputs.attached.keyboard;
- o && (o.keysRight = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "keysRotateLeft", {
- get: function() {
- var i = this.inputs.attached.keyboard;
- return i ? i.keysRotateLeft : []
- },
- set: function(i) {
- var o = this.inputs.attached.keyboard;
- o && (o.keysRotateLeft = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "keysRotateRight", {
- get: function() {
- var i = this.inputs.attached.keyboard;
- return i ? i.keysRotateRight : []
- },
- set: function(i) {
- var o = this.inputs.attached.keyboard;
- o && (o.keysRotateRight = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.attachControl = function(i, o) {
- o = Tools.BackCompatCameraNoPreventDefault(arguments),
- this.inputs.attachElement(o)
- }
- ,
- e.prototype.detachControl = function(i) {
- this.inputs.detachElement(),
- this.cameraDirection = new Vector3(0,0,0),
- this.cameraRotation = new Vector2(0,0)
- }
- ,
- Object.defineProperty(e.prototype, "collisionMask", {
- get: function() {
- return this._collisionMask
- },
- set: function(i) {
- this._collisionMask = isNaN(i) ? -1 : i
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._collideWithWorld = function(i) {
- var o;
- this.parent ? o = Vector3.TransformCoordinates(this.position, this.parent.getWorldMatrix()) : o = this.position,
- o.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition),
- this._oldPosition.addInPlace(this.ellipsoidOffset);
- var s = this.getScene().collisionCoordinator;
- this._collider || (this._collider = s.createCollider()),
- this._collider._radius = this.ellipsoid,
- this._collider.collisionMask = this._collisionMask;
- var c = i;
- this.applyGravity && (c = i.add(this.getScene().gravity)),
- s.getNewPosition(this._oldPosition, c, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId)
- }
- ,
- e.prototype._checkInputs = function() {
- this._localDirection || (this._localDirection = Vector3.Zero(),
- this._transformedDirection = Vector3.Zero()),
- this.inputs.checkInputs(),
- a.prototype._checkInputs.call(this)
- }
- ,
- e.prototype._decideIfNeedsToMove = function() {
- return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0
- }
- ,
- e.prototype._updatePosition = function() {
- this.checkCollisions && this.getScene().collisionsEnabled ? this._collideWithWorld(this.cameraDirection) : a.prototype._updatePosition.call(this)
- }
- ,
- e.prototype.dispose = function() {
- this.inputs.clear(),
- a.prototype.dispose.call(this)
- }
- ,
- e.prototype.getClassName = function() {
- return "FreeCamera"
- }
- ,
- __decorate([serializeAsVector3()], e.prototype, "ellipsoid", void 0),
- __decorate([serializeAsVector3()], e.prototype, "ellipsoidOffset", void 0),
- __decorate([serialize()], e.prototype, "checkCollisions", void 0),
- __decorate([serialize()], e.prototype, "applyGravity", void 0),
- e
- }(TargetCamera)
- , ShadowLight = function(a) {
- __extends(e, a);
- function e() {
- var i = a !== null && a.apply(this, arguments) || this;
- return i._needProjectionMatrixCompute = !0,
- i
- }
- return e.prototype._setPosition = function(i) {
- this._position = i
- }
- ,
- Object.defineProperty(e.prototype, "position", {
- get: function() {
- return this._position
- },
- set: function(i) {
- this._setPosition(i)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._setDirection = function(i) {
- this._direction = i
- }
- ,
- Object.defineProperty(e.prototype, "direction", {
- get: function() {
- return this._direction
- },
- set: function(i) {
- this._setDirection(i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "shadowMinZ", {
- get: function() {
- return this._shadowMinZ
- },
- set: function(i) {
- this._shadowMinZ = i,
- this.forceProjectionMatrixCompute()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "shadowMaxZ", {
- get: function() {
- return this._shadowMaxZ
- },
- set: function(i) {
- this._shadowMaxZ = i,
- this.forceProjectionMatrixCompute()
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.computeTransformedInformation = function() {
- return this.parent && this.parent.getWorldMatrix ? (this.transformedPosition || (this.transformedPosition = Vector3.Zero()),
- Vector3.TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition),
- this.direction && (this.transformedDirection || (this.transformedDirection = Vector3.Zero()),
- Vector3.TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this.transformedDirection)),
- !0) : !1
- }
- ,
- e.prototype.getDepthScale = function() {
- return 50
- }
- ,
- e.prototype.getShadowDirection = function(i) {
- return this.transformedDirection ? this.transformedDirection : this.direction
- }
- ,
- e.prototype.getAbsolutePosition = function() {
- return this.transformedPosition ? this.transformedPosition : this.position
- }
- ,
- e.prototype.setDirectionToTarget = function(i) {
- return this.direction = Vector3.Normalize(i.subtract(this.position)),
- this.direction
- }
- ,
- e.prototype.getRotation = function() {
- this.direction.normalize();
- var i = Vector3.Cross(this.direction, Axis.Y)
- , o = Vector3.Cross(i, this.direction);
- return Vector3.RotationFromAxis(i, o, this.direction)
- }
- ,
- e.prototype.needCube = function() {
- return !1
- }
- ,
- e.prototype.needProjectionMatrixCompute = function() {
- return this._needProjectionMatrixCompute
- }
- ,
- e.prototype.forceProjectionMatrixCompute = function() {
- this._needProjectionMatrixCompute = !0
- }
- ,
- e.prototype._initCache = function() {
- a.prototype._initCache.call(this),
- this._cache.position = Vector3.Zero()
- }
- ,
- e.prototype._isSynchronized = function() {
- return !!this._cache.position.equals(this.position)
- }
- ,
- e.prototype.computeWorldMatrix = function(i) {
- return !i && this.isSynchronized() ? (this._currentRenderId = this.getScene().getRenderId(),
- this._worldMatrix) : (this._updateCache(),
- this._cache.position.copyFrom(this.position),
- this._worldMatrix || (this._worldMatrix = Matrix.Identity()),
- Matrix.TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix),
- this.parent && this.parent.getWorldMatrix && (this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix),
- this._markSyncedWithParent()),
- this._worldMatrixDeterminantIsDirty = !0,
- this._worldMatrix)
- }
- ,
- e.prototype.getDepthMinZ = function(i) {
- return this.shadowMinZ !== void 0 ? this.shadowMinZ : i.minZ
- }
- ,
- e.prototype.getDepthMaxZ = function(i) {
- return this.shadowMaxZ !== void 0 ? this.shadowMaxZ : i.maxZ
- }
- ,
- e.prototype.setShadowProjectionMatrix = function(i, o, s) {
- return this.customProjectionMatrixBuilder ? this.customProjectionMatrixBuilder(o, s, i) : this._setDefaultShadowProjectionMatrix(i, o, s),
- this
- }
- ,
- __decorate([serializeAsVector3()], e.prototype, "position", null),
- __decorate([serializeAsVector3()], e.prototype, "direction", null),
- __decorate([serialize()], e.prototype, "shadowMinZ", null),
- __decorate([serialize()], e.prototype, "shadowMaxZ", null),
- e
- }(Light);
- Node$2.AddNodeConstructor("Light_Type_1", function(a, e) {
- return function() {
- return new DirectionalLight(a,Vector3.Zero(),e)
- }
- });
- var DirectionalLight = function(a) {
- __extends(e, a);
- function e(i, o, s) {
- var c = a.call(this, i, s) || this;
- return c._shadowFrustumSize = 0,
- c._shadowOrthoScale = .1,
- c.autoUpdateExtends = !0,
- c.autoCalcShadowZBounds = !1,
- c._orthoLeft = Number.MAX_VALUE,
- c._orthoRight = Number.MIN_VALUE,
- c._orthoTop = Number.MIN_VALUE,
- c._orthoBottom = Number.MAX_VALUE,
- c.position = o.scale(-1),
- c.direction = o,
- c
- }
- return Object.defineProperty(e.prototype, "shadowFrustumSize", {
- get: function() {
- return this._shadowFrustumSize
- },
- set: function(i) {
- this._shadowFrustumSize = i,
- this.forceProjectionMatrixCompute()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "shadowOrthoScale", {
- get: function() {
- return this._shadowOrthoScale
- },
- set: function(i) {
- this._shadowOrthoScale = i,
- this.forceProjectionMatrixCompute()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "orthoLeft", {
- get: function() {
- return this._orthoLeft
- },
- set: function(i) {
- this._orthoLeft = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "orthoRight", {
- get: function() {
- return this._orthoRight
- },
- set: function(i) {
- this._orthoRight = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "orthoTop", {
- get: function() {
- return this._orthoTop
- },
- set: function(i) {
- this._orthoTop = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "orthoBottom", {
- get: function() {
- return this._orthoBottom
- },
- set: function(i) {
- this._orthoBottom = i
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getClassName = function() {
- return "DirectionalLight"
- }
- ,
- e.prototype.getTypeID = function() {
- return Light.LIGHTTYPEID_DIRECTIONALLIGHT
- }
- ,
- e.prototype._setDefaultShadowProjectionMatrix = function(i, o, s) {
- this.shadowFrustumSize > 0 ? this._setDefaultFixedFrustumShadowProjectionMatrix(i) : this._setDefaultAutoExtendShadowProjectionMatrix(i, o, s)
- }
- ,
- e.prototype._setDefaultFixedFrustumShadowProjectionMatrix = function(i) {
- var o = this.getScene().activeCamera;
- !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)
- }
- ,
- e.prototype._setDefaultAutoExtendShadowProjectionMatrix = function(i, o, s) {
- var c = this.getScene().activeCamera;
- if (!!c) {
- if (this.autoUpdateExtends || this._orthoLeft === Number.MAX_VALUE) {
- var d = Vector3.Zero();
- this._orthoLeft = Number.MAX_VALUE,
- this._orthoRight = Number.MIN_VALUE,
- this._orthoTop = Number.MIN_VALUE,
- this._orthoBottom = Number.MAX_VALUE;
- for (var _ = Number.MAX_VALUE, b = Number.MIN_VALUE, k = 0; k < s.length; k++) {
- var j = s[k];
- if (!!j)
- for (var $ = j.getBoundingInfo(), _e = $.boundingBox, et = 0; et < _e.vectorsWorld.length; et++)
- Vector3.TransformCoordinatesToRef(_e.vectorsWorld[et], o, d),
- d.x < this._orthoLeft && (this._orthoLeft = d.x),
- d.y < this._orthoBottom && (this._orthoBottom = d.y),
- d.x > this._orthoRight && (this._orthoRight = d.x),
- d.y > this._orthoTop && (this._orthoTop = d.y),
- this.autoCalcShadowZBounds && (d.z < _ && (_ = d.z),
- d.z > b && (b = d.z))
- }
- this.autoCalcShadowZBounds && (this._shadowMinZ = _,
- this._shadowMaxZ = b)
- }
- var tt = this._orthoRight - this._orthoLeft
- , rt = this._orthoTop - this._orthoBottom
- , it = this.shadowMinZ !== void 0 ? this.shadowMinZ : c.minZ
- , nt = this.shadowMaxZ !== void 0 ? this.shadowMaxZ : c.maxZ
- , ot = this.getScene().getEngine().useReverseDepthBuffer;
- 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)
- }
- }
- ,
- e.prototype._buildUniformLayout = function() {
- this._uniformBuffer.addUniform("vLightData", 4),
- this._uniformBuffer.addUniform("vLightDiffuse", 4),
- this._uniformBuffer.addUniform("vLightSpecular", 4),
- this._uniformBuffer.addUniform("shadowsInfo", 3),
- this._uniformBuffer.addUniform("depthValues", 2),
- this._uniformBuffer.create()
- }
- ,
- e.prototype.transferToEffect = function(i, o) {
- return this.computeTransformedInformation() ? (this._uniformBuffer.updateFloat4("vLightData", this.transformedDirection.x, this.transformedDirection.y, this.transformedDirection.z, 1, o),
- this) : (this._uniformBuffer.updateFloat4("vLightData", this.direction.x, this.direction.y, this.direction.z, 1, o),
- this)
- }
- ,
- e.prototype.transferToNodeMaterialEffect = function(i, o) {
- return this.computeTransformedInformation() ? (i.setFloat3(o, this.transformedDirection.x, this.transformedDirection.y, this.transformedDirection.z),
- this) : (i.setFloat3(o, this.direction.x, this.direction.y, this.direction.z),
- this)
- }
- ,
- e.prototype.getDepthMinZ = function(i) {
- var o = this._scene.getEngine();
- return !o.useReverseDepthBuffer && o.isNDCHalfZRange ? 0 : 1
- }
- ,
- e.prototype.getDepthMaxZ = function(i) {
- var o = this._scene.getEngine();
- return o.useReverseDepthBuffer && o.isNDCHalfZRange ? 0 : 1
- }
- ,
- e.prototype.prepareLightSpecificDefines = function(i, o) {
- i["DIRLIGHT" + o] = !0
- }
- ,
- __decorate([serialize()], e.prototype, "shadowFrustumSize", null),
- __decorate([serialize()], e.prototype, "shadowOrthoScale", null),
- __decorate([serialize()], e.prototype, "autoUpdateExtends", void 0),
- __decorate([serialize()], e.prototype, "autoCalcShadowZBounds", void 0),
- __decorate([serialize("orthoLeft")], e.prototype, "_orthoLeft", void 0),
- __decorate([serialize("orthoRight")], e.prototype, "_orthoRight", void 0),
- __decorate([serialize("orthoTop")], e.prototype, "_orthoTop", void 0),
- __decorate([serialize("orthoBottom")], e.prototype, "_orthoBottom", void 0),
- e
- }(ShadowLight);
- Node$2.AddNodeConstructor("Light_Type_3", function(a, e) {
- return function() {
- return new HemisphericLight(a,Vector3.Zero(),e)
- }
- });
- var HemisphericLight = function(a) {
- __extends(e, a);
- function e(i, o, s) {
- var c = a.call(this, i, s) || this;
- return c.groundColor = new Color3(0,0,0),
- c.direction = o || Vector3.Up(),
- c
- }
- return e.prototype._buildUniformLayout = function() {
- this._uniformBuffer.addUniform("vLightData", 4),
- this._uniformBuffer.addUniform("vLightDiffuse", 4),
- this._uniformBuffer.addUniform("vLightSpecular", 4),
- this._uniformBuffer.addUniform("vLightGround", 3),
- this._uniformBuffer.addUniform("shadowsInfo", 3),
- this._uniformBuffer.addUniform("depthValues", 2),
- this._uniformBuffer.create()
- }
- ,
- e.prototype.getClassName = function() {
- return "HemisphericLight"
- }
- ,
- e.prototype.setDirectionToTarget = function(i) {
- return this.direction = Vector3.Normalize(i.subtract(Vector3.Zero())),
- this.direction
- }
- ,
- e.prototype.getShadowGenerator = function() {
- return null
- }
- ,
- e.prototype.transferToEffect = function(i, o) {
- var s = Vector3.Normalize(this.direction);
- return this._uniformBuffer.updateFloat4("vLightData", s.x, s.y, s.z, 0, o),
- this._uniformBuffer.updateColor3("vLightGround", this.groundColor.scale(this.intensity), o),
- this
- }
- ,
- e.prototype.transferToNodeMaterialEffect = function(i, o) {
- var s = Vector3.Normalize(this.direction);
- return i.setFloat3(o, s.x, s.y, s.z),
- this
- }
- ,
- e.prototype.computeWorldMatrix = function() {
- return this._worldMatrix || (this._worldMatrix = Matrix.Identity()),
- this._worldMatrix
- }
- ,
- e.prototype.getTypeID = function() {
- return Light.LIGHTTYPEID_HEMISPHERICLIGHT
- }
- ,
- e.prototype.prepareLightSpecificDefines = function(i, o) {
- i["HEMILIGHT" + o] = !0
- }
- ,
- __decorate([serializeAsColor3()], e.prototype, "groundColor", void 0),
- __decorate([serializeAsVector3()], e.prototype, "direction", void 0),
- e
- }(Light)
- , name$2D = "kernelBlurVaryingDeclaration"
- , shader$2D = "varying vec2 sampleCoord{X};";
- ShaderStore.IncludesShadersStore[name$2D] = shader$2D;
- var name$2C = "packingFunctions"
- , shader$2C = `vec4 pack(float depth)
- {
- const vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);
- const vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);
- vec4 res=fract(depth*bit_shift);
- res-=res.xxyz*bit_mask;
- return res;
- }
- float unpack(vec4 color)
- {
- 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);
- return dot(color,bit_shift);
- }`;
- ShaderStore.IncludesShadersStore[name$2C] = shader$2C;
- var name$2B = "kernelBlurFragment"
- , shader$2B = `#ifdef DOF
- factor=sampleCoC(sampleCoord{X});
- computedWeight=KERNEL_WEIGHT{X}*factor;
- sumOfWeights+=computedWeight;
- #else
- computedWeight=KERNEL_WEIGHT{X};
- #endif
- #ifdef PACKEDFLOAT
- blend+=unpack(texture2D(textureSampler,sampleCoord{X}))*computedWeight;
- #else
- blend+=texture2D(textureSampler,sampleCoord{X})*computedWeight;
- #endif`;
- ShaderStore.IncludesShadersStore[name$2B] = shader$2B;
- var name$2A = "kernelBlurFragment2"
- , shader$2A = `#ifdef DOF
- factor=sampleCoC(sampleCenter+delta*KERNEL_DEP_OFFSET{X});
- computedWeight=KERNEL_DEP_WEIGHT{X}*factor;
- sumOfWeights+=computedWeight;
- #else
- computedWeight=KERNEL_DEP_WEIGHT{X};
- #endif
- #ifdef PACKEDFLOAT
- blend+=unpack(texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X}))*computedWeight;
- #else
- blend+=texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X})*computedWeight;
- #endif`;
- ShaderStore.IncludesShadersStore[name$2A] = shader$2A;
- var name$2z = "kernelBlurPixelShader"
- , shader$2z = `
- uniform sampler2D textureSampler;
- uniform vec2 delta;
- varying vec2 sampleCenter;
- #ifdef DOF
- uniform sampler2D circleOfConfusionSampler;
- uniform vec2 cameraMinMaxZ;
- float sampleDistance(in vec2 offset) {
- float depth=texture2D(circleOfConfusionSampler,offset).g;
- return cameraMinMaxZ.x+(cameraMinMaxZ.y-cameraMinMaxZ.x)*depth;
- }
- float sampleCoC(in vec2 offset) {
- float coc=texture2D(circleOfConfusionSampler,offset).r;
- return coc;
- }
- #endif
- #include<kernelBlurVaryingDeclaration>[0..varyingCount]
- #ifdef PACKEDFLOAT
- #include<packingFunctions>
- #endif
- void main(void)
- {
- float computedWeight=0.0;
- #ifdef PACKEDFLOAT
- float blend=0.;
- #else
- vec4 blend=vec4(0.);
- #endif
- #ifdef DOF
- float sumOfWeights=CENTER_WEIGHT;
- float factor=0.0;
- #ifdef PACKEDFLOAT
- blend+=unpack(texture2D(textureSampler,sampleCenter))*CENTER_WEIGHT;
- #else
- blend+=texture2D(textureSampler,sampleCenter)*CENTER_WEIGHT;
- #endif
- #endif
- #include<kernelBlurFragment>[0..varyingCount]
- #include<kernelBlurFragment2>[0..depCount]
- #ifdef PACKEDFLOAT
- gl_FragColor=pack(blend);
- #else
- gl_FragColor=blend;
- #endif
- #ifdef DOF
- gl_FragColor/=sumOfWeights;
- #endif
- }`;
- ShaderStore.ShadersStore[name$2z] = shader$2z;
- var name$2y = "kernelBlurVertex"
- , shader$2y = "sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";
- ShaderStore.IncludesShadersStore[name$2y] = shader$2y;
- var name$2x = "kernelBlurVertexShader"
- , shader$2x = `
- attribute vec2 position;
- uniform vec2 delta;
- varying vec2 sampleCenter;
- #include<kernelBlurVaryingDeclaration>[0..varyingCount]
- const vec2 madd=vec2(0.5,0.5);
- void main(void) {
- sampleCenter=(position*madd+madd);
- #include<kernelBlurVertex>[0..varyingCount]
- gl_Position=vec4(position,0.0,1.0);
- }`;
- ShaderStore.ShadersStore[name$2x] = shader$2x;
- var BlurPostProcess = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _, b, k, j, $, _e) {
- _ === void 0 && (_ = Texture.BILINEAR_SAMPLINGMODE),
- j === void 0 && (j = 0),
- $ === void 0 && ($ = ""),
- _e === void 0 && (_e = !1);
- var et = a.call(this, i, "kernelBlur", ["delta", "direction", "cameraMinMaxZ"], ["circleOfConfusionSampler"], c, d, _, b, k, null, j, "kernelBlur", {
- varyingCount: 0,
- depCount: 0
- }, !0) || this;
- return et.blockCompilation = _e,
- et._packedFloat = !1,
- et._staticDefines = "",
- et._staticDefines = $,
- et.direction = o,
- et.onApplyObservable.add(function(tt) {
- 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)
- }),
- et.kernel = s,
- et
- }
- return Object.defineProperty(e.prototype, "kernel", {
- get: function() {
- return this._idealKernel
- },
- set: function(i) {
- this._idealKernel !== i && (i = Math.max(i, 1),
- this._idealKernel = i,
- this._kernel = this._nearestBestKernel(i),
- this.blockCompilation || this._updateParameters())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "packedFloat", {
- get: function() {
- return this._packedFloat
- },
- set: function(i) {
- this._packedFloat !== i && (this._packedFloat = i,
- this.blockCompilation || this._updateParameters())
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getClassName = function() {
- return "BlurPostProcess"
- }
- ,
- e.prototype.updateEffect = function(i, o, s, c, d, _) {
- this._updateParameters(d, _)
- }
- ,
- e.prototype._updateParameters = function(i, o) {
- for (var s = this._kernel, c = (s - 1) / 2, d = [], _ = [], b = 0, k = 0; k < s; k++) {
- var j = k / (s - 1)
- , $ = this._gaussianWeight(j * 2 - 1);
- d[k] = k - c,
- _[k] = $,
- b += $
- }
- for (var k = 0; k < _.length; k++)
- _[k] /= b;
- for (var _e = [], et = [], tt = [], k = 0; k <= c; k += 2) {
- var rt = Math.min(k + 1, Math.floor(c))
- , it = k === rt;
- if (it)
- tt.push({
- o: d[k],
- w: _[k]
- });
- else {
- var nt = rt === c
- , ot = _[k] + _[rt] * (nt ? .5 : 1)
- , at = d[k] + 1 / (1 + _[k] / _[rt]);
- at === 0 ? (tt.push({
- o: d[k],
- w: _[k]
- }),
- tt.push({
- o: d[k + 1],
- w: _[k + 1]
- })) : (tt.push({
- o: at,
- w: ot
- }),
- tt.push({
- o: -at,
- w: ot
- }))
- }
- }
- for (var k = 0; k < tt.length; k++)
- et[k] = tt[k].o,
- _e[k] = tt[k].w;
- d = et,
- _ = _e;
- var st = this.getEngine().getCaps().maxVaryingVectors
- , ut = Math.max(st, 0) - 1
- , ct = Math.min(d.length, ut)
- , lt = "";
- lt += this._staticDefines,
- this._staticDefines.indexOf("DOF") != -1 && (lt += "#define CENTER_WEIGHT " + this._glslFloat(_[ct - 1]) + `\r
- `,
- ct--);
- for (var k = 0; k < ct; k++)
- lt += "#define KERNEL_OFFSET" + k + " " + this._glslFloat(d[k]) + `\r
- `,
- lt += "#define KERNEL_WEIGHT" + k + " " + this._glslFloat(_[k]) + `\r
- `;
- for (var ft = 0, k = ut; k < d.length; k++)
- lt += "#define KERNEL_DEP_OFFSET" + ft + " " + this._glslFloat(d[k]) + `\r
- `,
- lt += "#define KERNEL_DEP_WEIGHT" + ft + " " + this._glslFloat(_[k]) + `\r
- `,
- ft++;
- this.packedFloat && (lt += "#define PACKEDFLOAT 1"),
- this.blockCompilation = !1,
- a.prototype.updateEffect.call(this, lt, null, null, {
- varyingCount: ct,
- depCount: ft
- }, i, o)
- }
- ,
- e.prototype._nearestBestKernel = function(i) {
- for (var o = Math.round(i), s = 0, c = [o, o - 1, o + 1, o - 2, o + 2]; s < c.length; s++) {
- var d = c[s];
- if (d % 2 !== 0 && Math.floor(d / 2) % 2 === 0 && d > 0)
- return Math.max(d, 3)
- }
- return Math.max(o, 3)
- }
- ,
- e.prototype._gaussianWeight = function(i) {
- var o = .3333333333333333
- , s = Math.sqrt(2 * Math.PI) * o
- , c = -(i * i / (2 * o * o))
- , d = 1 / s * Math.exp(c);
- return d
- }
- ,
- e.prototype._glslFloat = function(i, o) {
- return o === void 0 && (o = 8),
- i.toFixed(o).replace(/0+$/, "")
- }
- ,
- e._Parse = function(i, o, s, c) {
- return SerializationHelper.Parse(function() {
- return new e(i.name,i.direction,i.kernel,i.options,o,i.renderTargetSamplingMode,s.getEngine(),i.reusable,i.textureType,void 0,!1)
- }, i, s, c)
- }
- ,
- __decorate([serialize("kernel")], e.prototype, "_kernel", void 0),
- __decorate([serialize("packedFloat")], e.prototype, "_packedFloat", void 0),
- __decorate([serializeAsVector2()], e.prototype, "direction", void 0),
- e
- }(PostProcess);
- RegisterClass("BABYLON.BlurPostProcess", BlurPostProcess);
- var EffectFallbacks = function() {
- function a() {
- this._defines = {},
- this._currentRank = 32,
- this._maxRank = -1,
- this._mesh = null
- }
- return a.prototype.unBindMesh = function() {
- this._mesh = null
- }
- ,
- a.prototype.addFallback = function(e, i) {
- this._defines[e] || (e < this._currentRank && (this._currentRank = e),
- e > this._maxRank && (this._maxRank = e),
- this._defines[e] = new Array),
- this._defines[e].push(i)
- }
- ,
- a.prototype.addCPUSkinningFallback = function(e, i) {
- this._mesh = i,
- e < this._currentRank && (this._currentRank = e),
- e > this._maxRank && (this._maxRank = e)
- }
- ,
- Object.defineProperty(a.prototype, "hasMoreFallbacks", {
- get: function() {
- return this._currentRank <= this._maxRank
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.reduce = function(e, i) {
- if (this._mesh && this._mesh.computeBonesUsingShaders && this._mesh.numBoneInfluencers > 0) {
- this._mesh.computeBonesUsingShaders = !1,
- e = e.replace("#define NUM_BONE_INFLUENCERS " + this._mesh.numBoneInfluencers, "#define NUM_BONE_INFLUENCERS 0"),
- i._bonesComputationForcedToCPU = !0;
- for (var o = this._mesh.getScene(), s = 0; s < o.meshes.length; s++) {
- var c = o.meshes[s];
- if (!c.material) {
- !this._mesh.material && c.computeBonesUsingShaders && c.numBoneInfluencers > 0 && (c.computeBonesUsingShaders = !1);
- continue
- }
- if (!(!c.computeBonesUsingShaders || c.numBoneInfluencers === 0)) {
- if (c.material.getEffect() === i)
- c.computeBonesUsingShaders = !1;
- else if (c.subMeshes)
- for (var d = 0, _ = c.subMeshes; d < _.length; d++) {
- var b = _[d]
- , k = b.effect;
- if (k === i) {
- c.computeBonesUsingShaders = !1;
- break
- }
- }
- }
- }
- } else {
- var j = this._defines[this._currentRank];
- if (j)
- for (var s = 0; s < j.length; s++)
- e = e.replace("#define " + j[s], "");
- this._currentRank++
- }
- return e
- }
- ,
- a
- }()
- , name$2w = "bayerDitherFunctions"
- , shader$2w = `
- float bayerDither2(vec2 _P) {
- return mod(2.0*_P.y+_P.x+1.0,4.0);
- }
- float bayerDither4(vec2 _P) {
- vec2 P1=mod(_P,2.0);
- vec2 P2=floor(0.5*mod(_P,4.0));
- return 4.0*bayerDither2(P1)+bayerDither2(P2);
- }
- float bayerDither8(vec2 _P) {
- vec2 P1=mod(_P,2.0);
- vec2 P2=floor(0.5*mod(_P,4.0));
- vec2 P4=floor(0.25*mod(_P,8.0));
- return 4.0*(4.0*bayerDither2(P1)+bayerDither2(P2))+bayerDither2(P4);
- }
- `;
- ShaderStore.IncludesShadersStore[name$2w] = shader$2w;
- var name$2v = "shadowMapFragmentExtraDeclaration"
- , shader$2v = `#if SM_FLOAT == 0
- #include<packingFunctions>
- #endif
- #if SM_SOFTTRANSPARENTSHADOW == 1
- #include<bayerDitherFunctions>
- uniform float softTransparentShadowSM;
- #endif
- varying float vDepthMetricSM;
- #if SM_USEDISTANCE == 1
- uniform vec3 lightDataSM;
- varying vec3 vPositionWSM;
- #endif
- uniform vec3 biasAndScaleSM;
- uniform vec2 depthValuesSM;
- #if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1
- varying float zSM;
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$2v] = shader$2v;
- var name$2u = "clipPlaneFragmentDeclaration"
- , shader$2u = `#ifdef CLIPPLANE
- varying float fClipDistance;
- #endif
- #ifdef CLIPPLANE2
- varying float fClipDistance2;
- #endif
- #ifdef CLIPPLANE3
- varying float fClipDistance3;
- #endif
- #ifdef CLIPPLANE4
- varying float fClipDistance4;
- #endif
- #ifdef CLIPPLANE5
- varying float fClipDistance5;
- #endif
- #ifdef CLIPPLANE6
- varying float fClipDistance6;
- #endif`;
- ShaderStore.IncludesShadersStore[name$2u] = shader$2u;
- var name$2t = "clipPlaneFragment"
- , shader$2t = `#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)
- if (false) {}
- #endif
- #ifdef CLIPPLANE
- else if (fClipDistance>0.0)
- {
- discard;
- }
- #endif
- #ifdef CLIPPLANE2
- else if (fClipDistance2>0.0)
- {
- discard;
- }
- #endif
- #ifdef CLIPPLANE3
- else if (fClipDistance3>0.0)
- {
- discard;
- }
- #endif
- #ifdef CLIPPLANE4
- else if (fClipDistance4>0.0)
- {
- discard;
- }
- #endif
- #ifdef CLIPPLANE5
- else if (fClipDistance5>0.0)
- {
- discard;
- }
- #endif
- #ifdef CLIPPLANE6
- else if (fClipDistance6>0.0)
- {
- discard;
- }
- #endif`;
- ShaderStore.IncludesShadersStore[name$2t] = shader$2t;
- var name$2s = "shadowMapFragment"
- , shader$2s = ` float depthSM=vDepthMetricSM;
- #if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1
- #if SM_USEDISTANCE == 1
- depthSM=(length(vPositionWSM-lightDataSM)+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;
- #else
- #ifdef USE_REVERSE_DEPTHBUFFER
- depthSM=(-zSM+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;
- #else
- depthSM=(zSM+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;
- #endif
- #endif
- #ifdef USE_REVERSE_DEPTHBUFFER
- gl_FragDepth=clamp(1.0-depthSM,0.0,1.0);
- #else
- gl_FragDepth=clamp(depthSM,0.0,1.0);
- #endif
- #elif SM_USEDISTANCE == 1
- depthSM=(length(vPositionWSM-lightDataSM)+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;
- #endif
- #if SM_ESM == 1
- depthSM=clamp(exp(-min(87.,biasAndScaleSM.z*depthSM)),0.,1.);
- #endif
- #if SM_FLOAT == 1
- gl_FragColor=vec4(depthSM,1.0,1.0,1.0);
- #else
- gl_FragColor=pack(depthSM);
- #endif
- return;`;
- ShaderStore.IncludesShadersStore[name$2s] = shader$2s;
- var name$2r = "shadowMapPixelShader"
- , shader$2r = `#include<shadowMapFragmentExtraDeclaration>
- #ifdef ALPHATEST
- varying vec2 vUV;
- uniform sampler2D diffuseSampler;
- #endif
- #include<clipPlaneFragmentDeclaration>
- void main(void)
- {
- #include<clipPlaneFragment>
- #ifdef ALPHATEST
- float alphaFromAlphaTexture=texture2D(diffuseSampler,vUV).a;
- if (alphaFromAlphaTexture<0.4)
- discard;
- #endif
- #if SM_SOFTTRANSPARENTSHADOW == 1
- #ifdef ALPHATEST
- if ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM*alphaFromAlphaTexture) discard;
- #else
- if ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM) discard;
- #endif
- #endif
- #include<shadowMapFragment>
- }`;
- ShaderStore.ShadersStore[name$2r] = shader$2r;
- var name$2q = "bonesDeclaration"
- , shader$2q = `#if NUM_BONE_INFLUENCERS>0
- attribute vec4 matricesIndices;
- attribute vec4 matricesWeights;
- #if NUM_BONE_INFLUENCERS>4
- attribute vec4 matricesIndicesExtra;
- attribute vec4 matricesWeightsExtra;
- #endif
- #ifndef BAKED_VERTEX_ANIMATION_TEXTURE
- #ifdef BONETEXTURE
- uniform sampler2D boneSampler;
- uniform float boneTextureWidth;
- #else
- uniform mat4 mBones[BonesPerMesh];
- #ifdef BONES_VELOCITY_ENABLED
- uniform mat4 mPreviousBones[BonesPerMesh];
- #endif
- #endif
- #ifdef BONETEXTURE
- #define inline
- mat4 readMatrixFromRawSampler(sampler2D smp,float index)
- {
- float offset=index*4.0;
- float dx=1.0/boneTextureWidth;
- vec4 m0=texture2D(smp,vec2(dx*(offset+0.5),0.));
- vec4 m1=texture2D(smp,vec2(dx*(offset+1.5),0.));
- vec4 m2=texture2D(smp,vec2(dx*(offset+2.5),0.));
- vec4 m3=texture2D(smp,vec2(dx*(offset+3.5),0.));
- return mat4(m0,m1,m2,m3);
- }
- #endif
- #endif
- #endif`;
- ShaderStore.IncludesShadersStore[name$2q] = shader$2q;
- var name$2p = "bakedVertexAnimationDeclaration"
- , shader$2p = `#ifdef BAKED_VERTEX_ANIMATION_TEXTURE
- uniform float bakedVertexAnimationTime;
- uniform vec2 bakedVertexAnimationTextureSizeInverted;
- uniform vec4 bakedVertexAnimationSettings;
- uniform sampler2D bakedVertexAnimationTexture;
- #ifdef INSTANCES
- attribute vec4 bakedVertexAnimationSettingsInstanced;
- attribute float bakedVertexAnimationTimeInstanced;
- #endif
- #define inline
- mat4 readMatrixFromRawSamplerVAT(sampler2D smp,float index,float frame)
- {
- float offset=index*4.0;
- float frameUV=(frame+0.5)*bakedVertexAnimationTextureSizeInverted.y;
- float dx=bakedVertexAnimationTextureSizeInverted.x;
- vec4 m0=texture2D(smp,vec2(dx*(offset+0.5),frameUV));
- vec4 m1=texture2D(smp,vec2(dx*(offset+1.5),frameUV));
- vec4 m2=texture2D(smp,vec2(dx*(offset+2.5),frameUV));
- vec4 m3=texture2D(smp,vec2(dx*(offset+3.5),frameUV));
- return mat4(m0,m1,m2,m3);
- }
- #endif`;
- ShaderStore.IncludesShadersStore[name$2p] = shader$2p;
- var name$2o = "morphTargetsVertexGlobalDeclaration"
- , shader$2o = `#ifdef MORPHTARGETS
- uniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];
- #ifdef MORPHTARGETS_TEXTURE
- precision mediump sampler2DArray;
- uniform float morphTargetTextureIndices[NUM_MORPH_INFLUENCERS];
- uniform vec3 morphTargetTextureInfo;
- uniform sampler2DArray morphTargets;
- vec3 readVector3FromRawSampler(int targetIndex,float vertexIndex)
- {
- float y=floor(vertexIndex/morphTargetTextureInfo.y);
- float x=vertexIndex-y*morphTargetTextureInfo.y;
- vec3 textureUV=vec3((x+0.5)/morphTargetTextureInfo.y,(y+0.5)/morphTargetTextureInfo.z,morphTargetTextureIndices[targetIndex]);
- return texture(morphTargets,textureUV).xyz;
- }
- #endif
- #endif`;
- ShaderStore.IncludesShadersStore[name$2o] = shader$2o;
- var name$2n = "morphTargetsVertexDeclaration"
- , shader$2n = `#ifdef MORPHTARGETS
- #ifndef MORPHTARGETS_TEXTURE
- attribute vec3 position{X};
- #ifdef MORPHTARGETS_NORMAL
- attribute vec3 normal{X};
- #endif
- #ifdef MORPHTARGETS_TANGENT
- attribute vec3 tangent{X};
- #endif
- #ifdef MORPHTARGETS_UV
- attribute vec2 uv_{X};
- #endif
- #endif
- #endif`;
- ShaderStore.IncludesShadersStore[name$2n] = shader$2n;
- var name$2m = "sceneVertexDeclaration"
- , shader$2m = `uniform mat4 viewProjection;
- #ifdef MULTIVIEW
- uniform mat4 viewProjectionR;
- #endif
- uniform mat4 view;
- uniform mat4 projection;
- uniform vec4 vEyePosition;
- `;
- ShaderStore.IncludesShadersStore[name$2m] = shader$2m;
- var name$2l = "meshVertexDeclaration"
- , shader$2l = `uniform mat4 world;
- uniform float visibility;
- `;
- ShaderStore.IncludesShadersStore[name$2l] = shader$2l;
- var name$2k = "shadowMapVertexDeclaration"
- , shader$2k = `#include<sceneVertexDeclaration>
- #include<meshVertexDeclaration>
- `;
- ShaderStore.IncludesShadersStore[name$2k] = shader$2k;
- var name$2j = "sceneUboDeclaration"
- , shader$2j = `layout(std140,column_major) uniform;
- uniform Scene {
- mat4 viewProjection;
- #ifdef MULTIVIEW
- mat4 viewProjectionR;
- #endif
- mat4 view;
- mat4 projection;
- vec4 vEyePosition;
- };
- `;
- ShaderStore.IncludesShadersStore[name$2j] = shader$2j;
- var name$2i = "meshUboDeclaration"
- , shader$2i = `layout(std140,column_major) uniform;
- uniform Mesh
- {
- mat4 world;
- float visibility;
- };
- #define WORLD_UBO`;
- ShaderStore.IncludesShadersStore[name$2i] = shader$2i;
- var name$2h = "shadowMapUboDeclaration"
- , shader$2h = `layout(std140,column_major) uniform;
- #include<sceneUboDeclaration>
- #include<meshUboDeclaration>
- `;
- ShaderStore.IncludesShadersStore[name$2h] = shader$2h;
- var name$2g = "shadowMapVertexExtraDeclaration"
- , shader$2g = `#if SM_NORMALBIAS == 1
- uniform vec3 lightDataSM;
- #endif
- uniform vec3 biasAndScaleSM;
- uniform vec2 depthValuesSM;
- varying float vDepthMetricSM;
- #if SM_USEDISTANCE == 1
- varying vec3 vPositionWSM;
- #endif
- #if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1
- varying float zSM;
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$2g] = shader$2g;
- var name$2f = "clipPlaneVertexDeclaration"
- , shader$2f = `#ifdef CLIPPLANE
- uniform vec4 vClipPlane;
- varying float fClipDistance;
- #endif
- #ifdef CLIPPLANE2
- uniform vec4 vClipPlane2;
- varying float fClipDistance2;
- #endif
- #ifdef CLIPPLANE3
- uniform vec4 vClipPlane3;
- varying float fClipDistance3;
- #endif
- #ifdef CLIPPLANE4
- uniform vec4 vClipPlane4;
- varying float fClipDistance4;
- #endif
- #ifdef CLIPPLANE5
- uniform vec4 vClipPlane5;
- varying float fClipDistance5;
- #endif
- #ifdef CLIPPLANE6
- uniform vec4 vClipPlane6;
- varying float fClipDistance6;
- #endif`;
- ShaderStore.IncludesShadersStore[name$2f] = shader$2f;
- var name$2e = "morphTargetsVertexGlobal"
- , shader$2e = `#ifdef MORPHTARGETS
- #ifdef MORPHTARGETS_TEXTURE
- float vertexID;
- #endif
- #endif`;
- ShaderStore.IncludesShadersStore[name$2e] = shader$2e;
- var name$2d = "morphTargetsVertex"
- , shader$2d = `#ifdef MORPHTARGETS
- #ifdef MORPHTARGETS_TEXTURE
- vertexID=float(gl_VertexID)*morphTargetTextureInfo.x;
- positionUpdated+=(readVector3FromRawSampler({X},vertexID)-position)*morphTargetInfluences[{X}];
- vertexID+=1.0;
- #ifdef MORPHTARGETS_NORMAL
- normalUpdated+=(readVector3FromRawSampler({X},vertexID)-normal)*morphTargetInfluences[{X}];
- vertexID+=1.0;
- #endif
- #ifdef MORPHTARGETS_UV
- uvUpdated+=(readVector3FromRawSampler({X},vertexID).xy-uv)*morphTargetInfluences[{X}];
- vertexID+=1.0;
- #endif
- #ifdef MORPHTARGETS_TANGENT
- tangentUpdated.xyz+=(readVector3FromRawSampler({X},vertexID)-tangent.xyz)*morphTargetInfluences[{X}];
- #endif
- #else
- positionUpdated+=(position{X}-position)*morphTargetInfluences[{X}];
- #ifdef MORPHTARGETS_NORMAL
- normalUpdated+=(normal{X}-normal)*morphTargetInfluences[{X}];
- #endif
- #ifdef MORPHTARGETS_TANGENT
- tangentUpdated.xyz+=(tangent{X}-tangent.xyz)*morphTargetInfluences[{X}];
- #endif
- #ifdef MORPHTARGETS_UV
- uvUpdated+=(uv_{X}-uv)*morphTargetInfluences[{X}];
- #endif
- #endif
- #endif`;
- ShaderStore.IncludesShadersStore[name$2d] = shader$2d;
- var name$2c = "instancesVertex"
- , shader$2c = `#ifdef INSTANCES
- mat4 finalWorld=mat4(world0,world1,world2,world3);
- #if defined(PREPASS_VELOCITY) || defined(VELOCITY)
- mat4 finalPreviousWorld=mat4(previousWorld0,previousWorld1,previousWorld2,previousWorld3);
- #endif
- #ifdef THIN_INSTANCES
- finalWorld=world*finalWorld;
- #if defined(PREPASS_VELOCITY) || defined(VELOCITY)
- finalPreviousWorld=previousWorld*finalPreviousWorld;
- #endif
- #endif
- #else
- mat4 finalWorld=world;
- #if defined(PREPASS_VELOCITY) || defined(VELOCITY)
- mat4 finalPreviousWorld=previousWorld;
- #endif
- #endif`;
- ShaderStore.IncludesShadersStore[name$2c] = shader$2c;
- var name$2b = "bonesVertex"
- , shader$2b = `#ifndef BAKED_VERTEX_ANIMATION_TEXTURE
- #if NUM_BONE_INFLUENCERS>0
- mat4 influence;
- #ifdef BONETEXTURE
- influence=readMatrixFromRawSampler(boneSampler,matricesIndices[0])*matricesWeights[0];
- #if NUM_BONE_INFLUENCERS>1
- influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[1])*matricesWeights[1];
- #endif
- #if NUM_BONE_INFLUENCERS>2
- influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[2])*matricesWeights[2];
- #endif
- #if NUM_BONE_INFLUENCERS>3
- influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[3])*matricesWeights[3];
- #endif
- #if NUM_BONE_INFLUENCERS>4
- influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[0])*matricesWeightsExtra[0];
- #endif
- #if NUM_BONE_INFLUENCERS>5
- influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[1])*matricesWeightsExtra[1];
- #endif
- #if NUM_BONE_INFLUENCERS>6
- influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[2])*matricesWeightsExtra[2];
- #endif
- #if NUM_BONE_INFLUENCERS>7
- influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[3])*matricesWeightsExtra[3];
- #endif
- #else
- influence=mBones[int(matricesIndices[0])]*matricesWeights[0];
- #if NUM_BONE_INFLUENCERS>1
- influence+=mBones[int(matricesIndices[1])]*matricesWeights[1];
- #endif
- #if NUM_BONE_INFLUENCERS>2
- influence+=mBones[int(matricesIndices[2])]*matricesWeights[2];
- #endif
- #if NUM_BONE_INFLUENCERS>3
- influence+=mBones[int(matricesIndices[3])]*matricesWeights[3];
- #endif
- #if NUM_BONE_INFLUENCERS>4
- influence+=mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];
- #endif
- #if NUM_BONE_INFLUENCERS>5
- influence+=mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];
- #endif
- #if NUM_BONE_INFLUENCERS>6
- influence+=mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];
- #endif
- #if NUM_BONE_INFLUENCERS>7
- influence+=mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];
- #endif
- #endif
- finalWorld=finalWorld*influence;
- #endif
- #endif`;
- ShaderStore.IncludesShadersStore[name$2b] = shader$2b;
- var name$2a = "bakedVertexAnimation"
- , shader$2a = `#ifdef BAKED_VERTEX_ANIMATION_TEXTURE
- {
- #ifdef INSTANCES
- #define BVASNAME bakedVertexAnimationSettingsInstanced
- #else
- #define BVASNAME bakedVertexAnimationSettings
- #endif
- float VATStartFrame=BVASNAME.x;
- float VATEndFrame=BVASNAME.y;
- float VATOffsetFrame=BVASNAME.z;
- float VATSpeed=BVASNAME.w;
- float totalFrames=VATEndFrame-VATStartFrame+1.0;
- #ifdef INSTANCES
- float time=bakedVertexAnimationTimeInstanced*VATSpeed/totalFrames;
- #else
- float time=bakedVertexAnimationTime*VATSpeed/totalFrames;
- #endif
- float frameCorrection=time<1.0 ? 0.0 : 1.0;
- float numOfFrames=totalFrames-frameCorrection;
- float VATFrameNum=fract(time)*numOfFrames;
- VATFrameNum=mod(VATFrameNum+VATOffsetFrame,numOfFrames);
- VATFrameNum=floor(VATFrameNum);
- VATFrameNum+=VATStartFrame+frameCorrection;
- mat4 VATInfluence;
- VATInfluence=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[0],VATFrameNum)*matricesWeights[0];
- #if NUM_BONE_INFLUENCERS>1
- VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[1],VATFrameNum)*matricesWeights[1];
- #endif
- #if NUM_BONE_INFLUENCERS>2
- VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[2],VATFrameNum)*matricesWeights[2];
- #endif
- #if NUM_BONE_INFLUENCERS>3
- VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[3],VATFrameNum)*matricesWeights[3];
- #endif
- #if NUM_BONE_INFLUENCERS>4
- VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[0],VATFrameNum)*matricesWeightsExtra[0];
- #endif
- #if NUM_BONE_INFLUENCERS>5
- VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[1],VATFrameNum)*matricesWeightsExtra[1];
- #endif
- #if NUM_BONE_INFLUENCERS>6
- VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[2],VATFrameNum)*matricesWeightsExtra[2];
- #endif
- #if NUM_BONE_INFLUENCERS>7
- VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[3],VATFrameNum)*matricesWeightsExtra[3];
- #endif
- finalWorld=finalWorld*VATInfluence;
- }
- #endif`;
- ShaderStore.IncludesShadersStore[name$2a] = shader$2a;
- var name$29 = "shadowMapVertexNormalBias"
- , shader$29 = `
- #if SM_NORMALBIAS == 1
- #if SM_DIRECTIONINLIGHTDATA == 1
- vec3 worldLightDirSM=normalize(-lightDataSM.xyz);
- #else
- vec3 directionToLightSM=lightDataSM.xyz-worldPos.xyz;
- vec3 worldLightDirSM=normalize(directionToLightSM);
- #endif
- float ndlSM=dot(vNormalW,worldLightDirSM);
- float sinNLSM=sqrt(1.0-ndlSM*ndlSM);
- float normalBiasSM=biasAndScaleSM.y*sinNLSM;
- worldPos.xyz-=vNormalW*normalBiasSM;
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$29] = shader$29;
- var name$28 = "shadowMapVertexMetric"
- , shader$28 = `#if SM_USEDISTANCE == 1
- vPositionWSM=worldPos.xyz;
- #endif
- #if SM_DEPTHTEXTURE == 1
- #ifdef IS_NDC_HALF_ZRANGE
- #define BIASFACTOR 0.5
- #else
- #define BIASFACTOR 1.0
- #endif
- #ifdef USE_REVERSE_DEPTHBUFFER
- gl_Position.z-=biasAndScaleSM.x*gl_Position.w*BIASFACTOR;
- #else
- gl_Position.z+=biasAndScaleSM.x*gl_Position.w*BIASFACTOR;
- #endif
- #endif
- #if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1
- zSM=gl_Position.z;
- gl_Position.z=0.0;
- #elif SM_USEDISTANCE == 0
- #ifdef USE_REVERSE_DEPTHBUFFER
- vDepthMetricSM=(-gl_Position.z+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;
- #else
- vDepthMetricSM=(gl_Position.z+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;
- #endif
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$28] = shader$28;
- var name$27 = "clipPlaneVertex"
- , shader$27 = `#ifdef CLIPPLANE
- fClipDistance=dot(worldPos,vClipPlane);
- #endif
- #ifdef CLIPPLANE2
- fClipDistance2=dot(worldPos,vClipPlane2);
- #endif
- #ifdef CLIPPLANE3
- fClipDistance3=dot(worldPos,vClipPlane3);
- #endif
- #ifdef CLIPPLANE4
- fClipDistance4=dot(worldPos,vClipPlane4);
- #endif
- #ifdef CLIPPLANE5
- fClipDistance5=dot(worldPos,vClipPlane5);
- #endif
- #ifdef CLIPPLANE6
- fClipDistance6=dot(worldPos,vClipPlane6);
- #endif`;
- ShaderStore.IncludesShadersStore[name$27] = shader$27;
- var name$26 = "shadowMapVertexShader"
- , shader$26 = `
- attribute vec3 position;
- #ifdef NORMAL
- attribute vec3 normal;
- #endif
- #include<bonesDeclaration>
- #include<bakedVertexAnimationDeclaration>
- #include<morphTargetsVertexGlobalDeclaration>
- #include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
- #ifdef INSTANCES
- attribute vec4 world0;
- attribute vec4 world1;
- attribute vec4 world2;
- attribute vec4 world3;
- #endif
- #include<helperFunctions>
- #include<__decl__shadowMapVertex>
- #ifdef ALPHATEST
- varying vec2 vUV;
- uniform mat4 diffuseMatrix;
- #ifdef UV1
- attribute vec2 uv;
- #endif
- #ifdef UV2
- attribute vec2 uv2;
- #endif
- #endif
- #include<shadowMapVertexExtraDeclaration>
- #include<clipPlaneVertexDeclaration>
- void main(void)
- {
- vec3 positionUpdated=position;
- #ifdef UV1
- vec2 uvUpdated=uv;
- #endif
- #ifdef NORMAL
- vec3 normalUpdated=normal;
- #endif
- #include<morphTargetsVertexGlobal>
- #include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
- #include<instancesVertex>
- #include<bonesVertex>
- #include<bakedVertexAnimation>
- vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);
- #ifdef NORMAL
- mat3 normWorldSM=mat3(finalWorld);
- #if defined(INSTANCES) && defined(THIN_INSTANCES)
- vec3 vNormalW=normalUpdated/vec3(dot(normWorldSM[0],normWorldSM[0]),dot(normWorldSM[1],normWorldSM[1]),dot(normWorldSM[2],normWorldSM[2]));
- vNormalW=normalize(normWorldSM*vNormalW);
- #else
- #ifdef NONUNIFORMSCALING
- normWorldSM=transposeMat3(inverseMat3(normWorldSM));
- #endif
- vec3 vNormalW=normalize(normWorldSM*normalUpdated);
- #endif
- #endif
- #include<shadowMapVertexNormalBias>
- gl_Position=viewProjection*worldPos;
- #include<shadowMapVertexMetric>
- #ifdef ALPHATEST
- #ifdef UV1
- vUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));
- #endif
- #ifdef UV2
- vUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
- #endif
- #endif
- #include<clipPlaneVertex>
- }`;
- ShaderStore.ShadersStore[name$26] = shader$26;
- var name$25 = "depthBoxBlurPixelShader"
- , shader$25 = `
- varying vec2 vUV;
- uniform sampler2D textureSampler;
- uniform vec2 screenSize;
- void main(void)
- {
- vec4 colorDepth=vec4(0.0);
- for (int x=-OFFSET; x<=OFFSET; x++)
- for (int y=-OFFSET; y<=OFFSET; y++)
- colorDepth+=texture2D(textureSampler,vUV+vec2(x,y)/screenSize);
- gl_FragColor=(colorDepth/float((OFFSET*2+1)*(OFFSET*2+1)));
- }`;
- ShaderStore.ShadersStore[name$25] = shader$25;
- var name$24 = "shadowMapFragmentSoftTransparentShadow"
- , shader$24 = `#if SM_SOFTTRANSPARENTSHADOW == 1
- if ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM*alpha) discard;
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$24] = shader$24;
- var ShadowGenerator = function() {
- function a(e, i, o) {
- this.onBeforeShadowMapRenderObservable = new Observable,
- this.onAfterShadowMapRenderObservable = new Observable,
- this.onBeforeShadowMapRenderMeshObservable = new Observable,
- this.onAfterShadowMapRenderMeshObservable = new Observable,
- this._bias = 5e-5,
- this._normalBias = 0,
- this._blurBoxOffset = 1,
- this._blurScale = 2,
- this._blurKernel = 1,
- this._useKernelBlur = !1,
- this._filter = a.FILTER_NONE,
- this._filteringQuality = a.QUALITY_HIGH,
- this._contactHardeningLightSizeUVRatio = .1,
- this._darkness = 0,
- this._transparencyShadow = !1,
- this.enableSoftTransparentShadow = !1,
- this.frustumEdgeFalloff = 0,
- this.forceBackFacesOnly = !1,
- this._lightDirection = Vector3.Zero(),
- this._viewMatrix = Matrix.Zero(),
- this._projectionMatrix = Matrix.Zero(),
- this._transformMatrix = Matrix.Zero(),
- this._cachedPosition = new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
- this._cachedDirection = new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),
- this._currentFaceIndex = 0,
- this._currentFaceIndexCache = 0,
- this._defaultTextureMatrix = Matrix.Identity(),
- this._mapSize = e,
- this._light = i,
- this._scene = i.getScene(),
- i._shadowGenerator = this,
- this.id = i.id,
- this._useUBO = this._scene.getEngine().supportsUniformBuffers,
- this._useUBO && (this._sceneUBOs = [],
- this._sceneUBOs.push(this._scene.createSceneUniformBuffer('Scene for Shadow Generator (light "' + this._light.name + '")'))),
- a._SceneComponentInitialization(this._scene);
- var s = this._scene.getEngine().getCaps();
- 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,
- this._initializeGenerator(),
- this._applyFilterValues()
- }
- return Object.defineProperty(a.prototype, "bias", {
- get: function() {
- return this._bias
- },
- set: function(e) {
- this._bias = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "normalBias", {
- get: function() {
- return this._normalBias
- },
- set: function(e) {
- this._normalBias = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "blurBoxOffset", {
- get: function() {
- return this._blurBoxOffset
- },
- set: function(e) {
- this._blurBoxOffset !== e && (this._blurBoxOffset = e,
- this._disposeBlurPostProcesses())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "blurScale", {
- get: function() {
- return this._blurScale
- },
- set: function(e) {
- this._blurScale !== e && (this._blurScale = e,
- this._disposeBlurPostProcesses())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "blurKernel", {
- get: function() {
- return this._blurKernel
- },
- set: function(e) {
- this._blurKernel !== e && (this._blurKernel = e,
- this._disposeBlurPostProcesses())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "useKernelBlur", {
- get: function() {
- return this._useKernelBlur
- },
- set: function(e) {
- this._useKernelBlur !== e && (this._useKernelBlur = e,
- this._disposeBlurPostProcesses())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "depthScale", {
- get: function() {
- return this._depthScale !== void 0 ? this._depthScale : this._light.getDepthScale()
- },
- set: function(e) {
- this._depthScale = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._validateFilter = function(e) {
- return e
- }
- ,
- Object.defineProperty(a.prototype, "filter", {
- get: function() {
- return this._filter
- },
- set: function(e) {
- if (e = this._validateFilter(e),
- this._light.needCube()) {
- if (e === a.FILTER_BLUREXPONENTIALSHADOWMAP) {
- this.useExponentialShadowMap = !0;
- return
- } else if (e === a.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
- this.useCloseExponentialShadowMap = !0;
- return
- } else if (e === a.FILTER_PCF || e === a.FILTER_PCSS) {
- this.usePoissonSampling = !0;
- return
- }
- }
- if ((e === a.FILTER_PCF || e === a.FILTER_PCSS) && !this._scene.getEngine()._features.supportShadowSamplers) {
- this.usePoissonSampling = !0;
- return
- }
- this._filter !== e && (this._filter = e,
- this._disposeBlurPostProcesses(),
- this._applyFilterValues(),
- this._light._markMeshesAsLightDirty())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "usePoissonSampling", {
- get: function() {
- return this.filter === a.FILTER_POISSONSAMPLING
- },
- set: function(e) {
- var i = this._validateFilter(a.FILTER_POISSONSAMPLING);
- !e && this.filter !== a.FILTER_POISSONSAMPLING || (this.filter = e ? i : a.FILTER_NONE)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "useExponentialShadowMap", {
- get: function() {
- return this.filter === a.FILTER_EXPONENTIALSHADOWMAP
- },
- set: function(e) {
- var i = this._validateFilter(a.FILTER_EXPONENTIALSHADOWMAP);
- !e && this.filter !== a.FILTER_EXPONENTIALSHADOWMAP || (this.filter = e ? i : a.FILTER_NONE)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "useBlurExponentialShadowMap", {
- get: function() {
- return this.filter === a.FILTER_BLUREXPONENTIALSHADOWMAP
- },
- set: function(e) {
- var i = this._validateFilter(a.FILTER_BLUREXPONENTIALSHADOWMAP);
- !e && this.filter !== a.FILTER_BLUREXPONENTIALSHADOWMAP || (this.filter = e ? i : a.FILTER_NONE)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "useCloseExponentialShadowMap", {
- get: function() {
- return this.filter === a.FILTER_CLOSEEXPONENTIALSHADOWMAP
- },
- set: function(e) {
- var i = this._validateFilter(a.FILTER_CLOSEEXPONENTIALSHADOWMAP);
- !e && this.filter !== a.FILTER_CLOSEEXPONENTIALSHADOWMAP || (this.filter = e ? i : a.FILTER_NONE)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "useBlurCloseExponentialShadowMap", {
- get: function() {
- return this.filter === a.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP
- },
- set: function(e) {
- var i = this._validateFilter(a.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP);
- !e && this.filter !== a.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP || (this.filter = e ? i : a.FILTER_NONE)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "usePercentageCloserFiltering", {
- get: function() {
- return this.filter === a.FILTER_PCF
- },
- set: function(e) {
- var i = this._validateFilter(a.FILTER_PCF);
- !e && this.filter !== a.FILTER_PCF || (this.filter = e ? i : a.FILTER_NONE)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "filteringQuality", {
- get: function() {
- return this._filteringQuality
- },
- set: function(e) {
- this._filteringQuality !== e && (this._filteringQuality = e,
- this._disposeBlurPostProcesses(),
- this._applyFilterValues(),
- this._light._markMeshesAsLightDirty())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "useContactHardeningShadow", {
- get: function() {
- return this.filter === a.FILTER_PCSS
- },
- set: function(e) {
- var i = this._validateFilter(a.FILTER_PCSS);
- !e && this.filter !== a.FILTER_PCSS || (this.filter = e ? i : a.FILTER_NONE)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "contactHardeningLightSizeUVRatio", {
- get: function() {
- return this._contactHardeningLightSizeUVRatio
- },
- set: function(e) {
- this._contactHardeningLightSizeUVRatio = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "darkness", {
- get: function() {
- return this._darkness
- },
- set: function(e) {
- this.setDarkness(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.getDarkness = function() {
- return this._darkness
- }
- ,
- a.prototype.setDarkness = function(e) {
- return e >= 1 ? this._darkness = 1 : e <= 0 ? this._darkness = 0 : this._darkness = e,
- this
- }
- ,
- Object.defineProperty(a.prototype, "transparencyShadow", {
- get: function() {
- return this._transparencyShadow
- },
- set: function(e) {
- this.setTransparencyShadow(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.setTransparencyShadow = function(e) {
- return this._transparencyShadow = e,
- this
- }
- ,
- a.prototype.getShadowMap = function() {
- return this._shadowMap
- }
- ,
- a.prototype.getShadowMapForRendering = function() {
- return this._shadowMap2 ? this._shadowMap2 : this._shadowMap
- }
- ,
- a.prototype.getClassName = function() {
- return a.CLASSNAME
- }
- ,
- a.prototype.addShadowCaster = function(e, i) {
- if (i === void 0 && (i = !0),
- !this._shadowMap)
- return this;
- if (this._shadowMap.renderList || (this._shadowMap.renderList = []),
- this._shadowMap.renderList.indexOf(e) === -1 && this._shadowMap.renderList.push(e),
- i)
- for (var o = 0, s = e.getChildMeshes(); o < s.length; o++) {
- var c = s[o];
- this._shadowMap.renderList.indexOf(c) === -1 && this._shadowMap.renderList.push(c)
- }
- return this
- }
- ,
- a.prototype.removeShadowCaster = function(e, i) {
- if (i === void 0 && (i = !0),
- !this._shadowMap || !this._shadowMap.renderList)
- return this;
- var o = this._shadowMap.renderList.indexOf(e);
- if (o !== -1 && this._shadowMap.renderList.splice(o, 1),
- i)
- for (var s = 0, c = e.getChildren(); s < c.length; s++) {
- var d = c[s];
- this.removeShadowCaster(d)
- }
- return this
- }
- ,
- a.prototype.getLight = function() {
- return this._light
- }
- ,
- Object.defineProperty(a.prototype, "mapSize", {
- get: function() {
- return this._mapSize
- },
- set: function(e) {
- this._mapSize = e,
- this._light._markMeshesAsLightDirty(),
- this.recreateShadowMap()
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._initializeGenerator = function() {
- this._light._markMeshesAsLightDirty(),
- this._initializeShadowMap()
- }
- ,
- a.prototype._createTargetRenderTexture = function() {
- var e = this._scene.getEngine();
- 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),
- 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())
- }
- ,
- a.prototype._initializeShadowMap = function() {
- var e = this;
- if (this._createTargetRenderTexture(),
- this._shadowMap !== null) {
- this._shadowMap.wrapU = Texture.CLAMP_ADDRESSMODE,
- this._shadowMap.wrapV = Texture.CLAMP_ADDRESSMODE,
- this._shadowMap.anisotropicFilteringLevel = 1,
- this._shadowMap.updateSamplingMode(Texture.BILINEAR_SAMPLINGMODE),
- this._shadowMap.renderParticles = !1,
- this._shadowMap.ignoreCameraViewport = !0,
- this._storedUniqueId && (this._shadowMap.uniqueId = this._storedUniqueId),
- this._shadowMap.customRenderFunction = this._renderForShadowMap.bind(this),
- this._shadowMap.customIsReadyFunction = function(d, _) {
- return !0
- }
- ;
- var i = this._scene.getEngine();
- this._shadowMap.onBeforeBindObservable.add(function() {
- var d;
- e._currentSceneUBO = e._scene.getSceneUniformBuffer(),
- (d = i._debugPushGroup) === null || d === void 0 || d.call(i, "shadow map generation for pass id " + i.currentRenderPassId, 1)
- }),
- this._shadowMap.onBeforeRenderObservable.add(function(d) {
- e._sceneUBOs && e._scene.setSceneUniformBuffer(e._sceneUBOs[0]),
- e._currentFaceIndex = d,
- e._filter === a.FILTER_PCF && i.setColorWrite(!1),
- e.getTransformMatrix(),
- e._scene.setTransformMatrix(e._viewMatrix, e._projectionMatrix),
- e._useUBO && (e._scene.getSceneUniformBuffer().unbindEffect(),
- e._scene.finalizeSceneUbo())
- }),
- this._shadowMap.onAfterUnbindObservable.add(function() {
- var d, _;
- if (e._sceneUBOs && e._scene.setSceneUniformBuffer(e._currentSceneUBO),
- e._scene.updateTransformMatrix(),
- e._filter === a.FILTER_PCF && i.setColorWrite(!0),
- !e.useBlurExponentialShadowMap && !e.useBlurCloseExponentialShadowMap) {
- (d = i._debugPopGroup) === null || d === void 0 || d.call(i, 1);
- return
- }
- var b = e.getShadowMapForRendering();
- b && (e._scene.postProcessManager.directRender(e._blurPostProcesses, b.renderTarget, !0),
- i.unBindFramebuffer(b.renderTarget, !0),
- (_ = i._debugPopGroup) === null || _ === void 0 || _.call(i, 1))
- });
- var o = new Color4(0,0,0,0)
- , s = new Color4(1,1,1,1);
- this._shadowMap.onClearObservable.add(function(d) {
- 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)
- }),
- this._shadowMap.onResizeObservable.add(function(d) {
- e._storedUniqueId = e._shadowMap.uniqueId,
- e._mapSize = d.getRenderSize(),
- e._light._markMeshesAsLightDirty(),
- e.recreateShadowMap()
- });
- for (var c = RenderingManager.MIN_RENDERINGGROUPS; c < RenderingManager.MAX_RENDERINGGROUPS; c++)
- this._shadowMap.setRenderingAutoClearDepthStencil(c, !1)
- }
- }
- ,
- a.prototype._initializeBlurRTTAndPostProcesses = function() {
- var e = this
- , i = this._scene.getEngine()
- , o = this._mapSize / this.blurScale;
- (!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),
- this._shadowMap2.wrapU = Texture.CLAMP_ADDRESSMODE,
- this._shadowMap2.wrapV = Texture.CLAMP_ADDRESSMODE,
- this._shadowMap2.updateSamplingMode(Texture.BILINEAR_SAMPLINGMODE)),
- 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),
- this._kernelBlurXPostprocess.width = o,
- this._kernelBlurXPostprocess.height = o,
- this._kernelBlurXPostprocess.externalTextureSamplerBinding = !0,
- this._kernelBlurXPostprocess.onApplyObservable.add(function(s) {
- s.setTexture("textureSampler", e._shadowMap)
- }),
- this._kernelBlurYPostprocess = new BlurPostProcess(this._light.name + "KernelBlurY",new Vector2(0,1),this.blurKernel,1,null,Texture.BILINEAR_SAMPLINGMODE,i,!1,this._textureType),
- this._kernelBlurXPostprocess.autoClear = !1,
- this._kernelBlurYPostprocess.autoClear = !1,
- this._textureType === 0 && (this._kernelBlurXPostprocess.packedFloat = !0,
- this._kernelBlurYPostprocess.packedFloat = !0),
- 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),
- this._boxBlurPostprocess.externalTextureSamplerBinding = !0,
- this._boxBlurPostprocess.onApplyObservable.add(function(s) {
- s.setFloat2("screenSize", o, o),
- s.setTexture("textureSampler", e._shadowMap)
- }),
- this._boxBlurPostprocess.autoClear = !1,
- this._blurPostProcesses = [this._boxBlurPostprocess])
- }
- ,
- a.prototype._renderForShadowMap = function(e, i, o, s) {
- var c;
- if (s.length)
- for (c = 0; c < s.length; c++)
- this._renderSubMeshForShadowMap(s.data[c]);
- for (c = 0; c < e.length; c++)
- this._renderSubMeshForShadowMap(e.data[c]);
- for (c = 0; c < i.length; c++)
- this._renderSubMeshForShadowMap(i.data[c]);
- if (this._transparencyShadow)
- for (c = 0; c < o.length; c++)
- this._renderSubMeshForShadowMap(o.data[c], !0);
- else
- for (c = 0; c < o.length; c++)
- o.data[c].getEffectiveMesh()._internalAbstractMeshDataInfo._isActiveIntermediate = !1
- }
- ,
- a.prototype._bindCustomEffectForRenderSubMeshForShadowMap = function(e, i, o) {
- i.setMatrix("viewProjection", this.getTransformMatrix())
- }
- ,
- a.prototype._renderSubMeshForShadowMap = function(e, i) {
- var o, s;
- i === void 0 && (i = !1);
- var c = e.getRenderingMesh()
- , d = e.getEffectiveMesh()
- , _ = this._scene
- , b = _.getEngine()
- , k = e.getMaterial();
- if (d._internalAbstractMeshDataInfo._isActiveIntermediate = !1,
- !(!k || e.verticesCount === 0 || e._renderId === _.getRenderId())) {
- var j = d._getWorldMatrixDeterminant() < 0
- , $ = (o = c.overrideMaterialSideOrientation) !== null && o !== void 0 ? o : k.sideOrientation;
- (_.useRightHandedSystem && !j || !_.useRightHandedSystem && j) && ($ = $ === 0 ? 1 : 0);
- var _e = $ === 0;
- b.setState(k.backFaceCulling, void 0, void 0, _e, k.cullBackFaces);
- var et = c._getInstancesRenderList(e._id, !!e.getReplacementMesh());
- if (!et.mustReturn) {
- var tt = b.getCaps().instancedArrays && (et.visibleInstances[e._id] !== null && et.visibleInstances[e._id] !== void 0 || c.hasThinInstances);
- if (!(this.customAllowRendering && !this.customAllowRendering(e)))
- if (this.isReady(e, tt, i)) {
- e._renderId = _.getRenderId();
- var rt = k.shadowDepthWrapper
- , it = (s = rt == null ? void 0 : rt.getEffect(e, this, b.currentRenderPassId)) !== null && s !== void 0 ? s : e._getDrawWrapper()
- , nt = DrawWrapper.GetEffect(it);
- if (b.enableEffect(it),
- tt || c._bind(e, nt, k.fillMode),
- this.getTransformMatrix(),
- nt.setFloat3("biasAndScaleSM", this.bias, this.normalBias, this.depthScale),
- this.getLight().getTypeID() === Light.LIGHTTYPEID_DIRECTIONALLIGHT ? nt.setVector3("lightDataSM", this._cachedDirection) : nt.setVector3("lightDataSM", this._cachedPosition),
- _.activeCamera && nt.setFloat2("depthValuesSM", this.getLight().getDepthMinZ(_.activeCamera), this.getLight().getDepthMinZ(_.activeCamera) + this.getLight().getDepthMaxZ(_.activeCamera)),
- i && this.enableSoftTransparentShadow && nt.setFloat("softTransparentShadowSM", d.visibility * k.alpha),
- rt)
- e._setMainDrawWrapperOverride(it),
- rt.standalone ? rt.baseMaterial.bindForSubMesh(d.getWorldMatrix(), c, e) : k.bindForSubMesh(d.getWorldMatrix(), c, e),
- e._setMainDrawWrapperOverride(null);
- else {
- if (k && k.needAlphaTesting()) {
- var ot = k.getAlphaTestTexture();
- ot && (nt.setTexture("diffuseSampler", ot),
- nt.setMatrix("diffuseMatrix", ot.getTextureMatrix() || this._defaultTextureMatrix))
- }
- if (c.useBones && c.computeBonesUsingShaders && c.skeleton) {
- var at = c.skeleton;
- if (at.isUsingTextureForMatrices) {
- var st = at.getTransformMatrixTexture(c);
- if (!st)
- return;
- nt.setTexture("boneSampler", st),
- nt.setFloat("boneTextureWidth", 4 * (at.bones.length + 1))
- } else
- nt.setMatrices("mBones", at.getTransformMatrices(c))
- }
- MaterialHelper.BindMorphTargetParameters(c, nt),
- c.morphTargetManager && c.morphTargetManager.isUsingTextureForTargets && c.morphTargetManager._bind(nt),
- MaterialHelper.BindClipPlane(nt, _)
- }
- !this._useUBO && !rt && this._bindCustomEffectForRenderSubMeshForShadowMap(e, nt, d),
- MaterialHelper.BindSceneUniformBuffer(nt, this._scene.getSceneUniformBuffer()),
- this._scene.getSceneUniformBuffer().bindUniformBuffer();
- var ut = d.getWorldMatrix();
- tt && (d.getMeshUniformBuffer().bindToEffect(nt, "Mesh"),
- d.transferToEffect(ut)),
- this.forceBackFacesOnly && b.setState(!0, 0, !1, !0, k.cullBackFaces),
- this.onBeforeShadowMapRenderMeshObservable.notifyObservers(c),
- this.onBeforeShadowMapRenderObservable.notifyObservers(nt),
- c._processRendering(d, e, nt, k.fillMode, et, tt, function(ct, lt, ft, ht) {
- ht && d !== ht ? (ht.getMeshUniformBuffer().bindToEffect(nt, "Mesh"),
- ht.transferToEffect(lt)) : (d.getMeshUniformBuffer().bindToEffect(nt, "Mesh"),
- d.transferToEffect(ut))
- }),
- this.forceBackFacesOnly && b.setState(!0, 0, !1, !1, k.cullBackFaces),
- this.onAfterShadowMapRenderObservable.notifyObservers(nt),
- this.onAfterShadowMapRenderMeshObservable.notifyObservers(c)
- } else
- this._shadowMap && this._shadowMap.resetRefreshCounter()
- }
- }
- }
- ,
- a.prototype._applyFilterValues = function() {
- !this._shadowMap || (this.filter === a.FILTER_NONE || this.filter === a.FILTER_PCSS ? this._shadowMap.updateSamplingMode(Texture.NEAREST_SAMPLINGMODE) : this._shadowMap.updateSamplingMode(Texture.BILINEAR_SAMPLINGMODE))
- }
- ,
- a.prototype.forceCompilation = function(e, i) {
- var o = this
- , s = __assign({
- useInstances: !1
- }, i)
- , c = this.getShadowMap();
- if (!c) {
- e && e(this);
- return
- }
- var d = c.renderList;
- if (!d) {
- e && e(this);
- return
- }
- for (var _ = new Array, b = 0, k = d; b < k.length; b++) {
- var j = k[b];
- _.push.apply(_, j.subMeshes)
- }
- if (_.length === 0) {
- e && e(this);
- return
- }
- var $ = 0
- , _e = function() {
- var et, tt;
- if (!(!o._scene || !o._scene.getEngine())) {
- for (; o.isReady(_[$], s.useInstances, (tt = (et = _[$].getMaterial()) === null || et === void 0 ? void 0 : et.needAlphaBlendingForMesh(_[$].getMesh())) !== null && tt !== void 0 ? tt : !1); )
- if ($++,
- $ >= _.length) {
- e && e(o);
- return
- }
- setTimeout(_e, 16)
- }
- };
- _e()
- }
- ,
- a.prototype.forceCompilationAsync = function(e) {
- var i = this;
- return new Promise(function(o) {
- i.forceCompilation(function() {
- o()
- }, e)
- }
- )
- }
- ,
- a.prototype._isReadyCustomDefines = function(e, i, o) {}
- ,
- a.prototype._prepareShadowDefines = function(e, i, o, s) {
- o.push("#define SM_FLOAT " + (this._textureType !== 0 ? "1" : "0")),
- o.push("#define SM_ESM " + (this.useExponentialShadowMap || this.useBlurExponentialShadowMap ? "1" : "0")),
- o.push("#define SM_DEPTHTEXTURE " + (this.usePercentageCloserFiltering || this.useContactHardeningShadow ? "1" : "0"));
- var c = e.getMesh();
- return o.push("#define SM_NORMALBIAS " + (this.normalBias && c.isVerticesDataPresent(VertexBuffer.NormalKind) ? "1" : "0")),
- o.push("#define SM_DIRECTIONINLIGHTDATA " + (this.getLight().getTypeID() === Light.LIGHTTYPEID_DIRECTIONALLIGHT ? "1" : "0")),
- o.push("#define SM_USEDISTANCE " + (this._light.needCube() ? "1" : "0")),
- o.push("#define SM_SOFTTRANSPARENTSHADOW " + (this.enableSoftTransparentShadow && s ? "1" : "0")),
- this._isReadyCustomDefines(o, e, i),
- o
- }
- ,
- a.prototype.isReady = function(e, i, o) {
- var s = e.getMaterial()
- , c = s == null ? void 0 : s.shadowDepthWrapper
- , d = [];
- if (this._prepareShadowDefines(e, i, d, o),
- c) {
- if (!c.isReadyForSubMesh(e, d, this, i, this._scene.getEngine().currentRenderPassId))
- return !1
- } else {
- var _ = e._getDrawWrapper(void 0, !0)
- , b = _.effect
- , k = _.defines
- , j = [VertexBuffer.PositionKind]
- , $ = e.getMesh();
- if (this.normalBias && $.isVerticesDataPresent(VertexBuffer.NormalKind) && (j.push(VertexBuffer.NormalKind),
- d.push("#define NORMAL"),
- $.nonUniformScaling && d.push("#define NONUNIFORMSCALING")),
- s && s.needAlphaTesting()) {
- var _e = s.getAlphaTestTexture();
- if (_e) {
- if (!_e.isReady())
- return !1;
- d.push("#define ALPHATEST"),
- $.isVerticesDataPresent(VertexBuffer.UVKind) && (j.push(VertexBuffer.UVKind),
- d.push("#define UV1")),
- $.isVerticesDataPresent(VertexBuffer.UV2Kind) && _e.coordinatesIndex === 1 && (j.push(VertexBuffer.UV2Kind),
- d.push("#define UV2"))
- }
- }
- var et = new EffectFallbacks;
- if ($.useBones && $.computeBonesUsingShaders && $.skeleton) {
- j.push(VertexBuffer.MatricesIndicesKind),
- j.push(VertexBuffer.MatricesWeightsKind),
- $.numBoneInfluencers > 4 && (j.push(VertexBuffer.MatricesIndicesExtraKind),
- j.push(VertexBuffer.MatricesWeightsExtraKind));
- var tt = $.skeleton;
- d.push("#define NUM_BONE_INFLUENCERS " + $.numBoneInfluencers),
- $.numBoneInfluencers > 0 && et.addCPUSkinningFallback(0, $),
- tt.isUsingTextureForMatrices ? d.push("#define BONETEXTURE") : d.push("#define BonesPerMesh " + (tt.bones.length + 1))
- } else
- d.push("#define NUM_BONE_INFLUENCERS 0");
- var rt = $.morphTargetManager
- , it = 0;
- rt && rt.numInfluencers > 0 && (d.push("#define MORPHTARGETS"),
- it = rt.numInfluencers,
- d.push("#define NUM_MORPH_INFLUENCERS " + it),
- rt.isUsingTextureForTargets && d.push("#define MORPHTARGETS_TEXTURE"),
- MaterialHelper.PrepareAttributesForMorphTargetsInfluencers(j, $, it));
- var nt = this._scene;
- if (nt.clipPlane && d.push("#define CLIPPLANE"),
- nt.clipPlane2 && d.push("#define CLIPPLANE2"),
- nt.clipPlane3 && d.push("#define CLIPPLANE3"),
- nt.clipPlane4 && d.push("#define CLIPPLANE4"),
- nt.clipPlane5 && d.push("#define CLIPPLANE5"),
- nt.clipPlane6 && d.push("#define CLIPPLANE6"),
- i && (d.push("#define INSTANCES"),
- MaterialHelper.PushAttributesForInstances(j),
- e.getRenderingMesh().hasThinInstances && d.push("#define THIN_INSTANCES")),
- this.customShaderOptions && this.customShaderOptions.defines)
- for (var ot = 0, at = this.customShaderOptions.defines; ot < at.length; ot++) {
- var st = at[ot];
- d.indexOf(st) === -1 && d.push(st)
- }
- var ut = d.join(`
- `);
- if (k !== ut) {
- k = ut;
- var ct = "shadowMap"
- , lt = ["world", "mBones", "viewProjection", "diffuseMatrix", "lightDataSM", "depthValuesSM", "biasAndScaleSM", "morphTargetInfluences", "boneTextureWidth", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "softTransparentShadowSM", "morphTargetTextureInfo", "morphTargetTextureIndices"]
- , ft = ["diffuseSampler", "boneSampler", "morphTargets"]
- , ht = ["Scene", "Mesh"];
- if (this.customShaderOptions) {
- if (ct = this.customShaderOptions.shaderName,
- this.customShaderOptions.attributes)
- for (var pt = 0, dt = this.customShaderOptions.attributes; pt < dt.length; pt++) {
- var _t = dt[pt];
- j.indexOf(_t) === -1 && j.push(_t)
- }
- if (this.customShaderOptions.uniforms)
- for (var mt = 0, vt = this.customShaderOptions.uniforms; mt < vt.length; mt++) {
- var yt = vt[mt];
- lt.indexOf(yt) === -1 && lt.push(yt)
- }
- if (this.customShaderOptions.samplers)
- for (var Et = 0, At = this.customShaderOptions.samplers; Et < At.length; Et++) {
- var gt = At[Et];
- ft.indexOf(gt) === -1 && ft.push(gt)
- }
- }
- var St = this._scene.getEngine();
- b = St.createEffect(ct, {
- attributes: j,
- uniformsNames: lt,
- uniformBuffersNames: ht,
- samplers: ft,
- defines: ut,
- fallbacks: et,
- onCompiled: null,
- onError: null,
- indexParameters: {
- maxSimultaneousMorphTargets: it
- }
- }, St),
- _.setEffect(b, k)
- }
- if (!b.isReady())
- return !1
- }
- return (this.useBlurExponentialShadowMap || this.useBlurCloseExponentialShadowMap) && (!this._blurPostProcesses || !this._blurPostProcesses.length) && this._initializeBlurRTTAndPostProcesses(),
- !(this._kernelBlurXPostprocess && !this._kernelBlurXPostprocess.isReady() || this._kernelBlurYPostprocess && !this._kernelBlurYPostprocess.isReady() || this._boxBlurPostprocess && !this._boxBlurPostprocess.isReady())
- }
- ,
- a.prototype.prepareDefines = function(e, i) {
- var o = this._scene
- , s = this._light;
- !o.shadowsEnabled || !s.shadowEnabled || (e["SHADOW" + i] = !0,
- this.useContactHardeningShadow ? (e["SHADOWPCSS" + i] = !0,
- this._filteringQuality === a.QUALITY_LOW ? e["SHADOWLOWQUALITY" + i] = !0 : this._filteringQuality === a.QUALITY_MEDIUM && (e["SHADOWMEDIUMQUALITY" + i] = !0)) : this.usePercentageCloserFiltering ? (e["SHADOWPCF" + i] = !0,
- 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),
- s.needCube() && (e["SHADOWCUBE" + i] = !0))
- }
- ,
- a.prototype.bindShadowLight = function(e, i) {
- var o = this._light
- , s = this._scene;
- if (!(!s.shadowsEnabled || !o.shadowEnabled)) {
- var c = s.activeCamera;
- if (!!c) {
- var d = this.getShadowMap();
- !d || (o.needCube() || i.setMatrix("lightMatrix" + e, this.getTransformMatrix()),
- this._filter === a.FILTER_PCF ? (i.setDepthStencilTexture("shadowSampler" + e, this.getShadowMapForRendering()),
- 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()),
- i.setTexture("depthSampler" + e, this.getShadowMapForRendering()),
- o._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / d.getSize().width, this._contactHardeningLightSizeUVRatio * d.getSize().width, this.frustumEdgeFalloff, e)) : (i.setTexture("shadowSampler" + e, this.getShadowMapForRendering()),
- o._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), this.blurScale / d.getSize().width, this.depthScale, this.frustumEdgeFalloff, e)),
- o._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(c), this.getLight().getDepthMinZ(c) + this.getLight().getDepthMaxZ(c), e))
- }
- }
- }
- ,
- a.prototype.getTransformMatrix = function() {
- var e = this._scene;
- if (this._currentRenderId === e.getRenderId() && this._currentFaceIndexCache === this._currentFaceIndex)
- return this._transformMatrix;
- this._currentRenderId = e.getRenderId(),
- this._currentFaceIndexCache = this._currentFaceIndex;
- var i = this._light.position;
- if (this._light.computeTransformedInformation() && (i = this._light.transformedPosition),
- Vector3.NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex), this._lightDirection),
- Math.abs(Vector3.Dot(this._lightDirection, Vector3.Up())) === 1 && (this._lightDirection.z = 1e-13),
- this._light.needProjectionMatrixCompute() || !this._cachedPosition || !this._cachedDirection || !i.equals(this._cachedPosition) || !this._lightDirection.equals(this._cachedDirection)) {
- this._cachedPosition.copyFrom(i),
- this._cachedDirection.copyFrom(this._lightDirection),
- Matrix.LookAtLHToRef(i, i.add(this._lightDirection), Vector3.Up(), this._viewMatrix);
- var o = this.getShadowMap();
- if (o) {
- var s = o.renderList;
- s && this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, s)
- }
- this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix)
- }
- return this._transformMatrix
- }
- ,
- a.prototype.recreateShadowMap = function() {
- var e = this._shadowMap;
- if (!!e) {
- var i = e.renderList;
- if (this._disposeRTTandPostProcesses(),
- this._initializeGenerator(),
- this.filter = this.filter,
- this._applyFilterValues(),
- i) {
- this._shadowMap.renderList || (this._shadowMap.renderList = []);
- for (var o = 0, s = i; o < s.length; o++) {
- var c = s[o];
- this._shadowMap.renderList.push(c)
- }
- } else
- this._shadowMap.renderList = null
- }
- }
- ,
- a.prototype._disposeBlurPostProcesses = function() {
- this._shadowMap2 && (this._shadowMap2.dispose(),
- this._shadowMap2 = null),
- this._boxBlurPostprocess && (this._boxBlurPostprocess.dispose(),
- this._boxBlurPostprocess = null),
- this._kernelBlurXPostprocess && (this._kernelBlurXPostprocess.dispose(),
- this._kernelBlurXPostprocess = null),
- this._kernelBlurYPostprocess && (this._kernelBlurYPostprocess.dispose(),
- this._kernelBlurYPostprocess = null),
- this._blurPostProcesses = []
- }
- ,
- a.prototype._disposeRTTandPostProcesses = function() {
- this._shadowMap && (this._shadowMap.dispose(),
- this._shadowMap = null),
- this._disposeBlurPostProcesses()
- }
- ,
- a.prototype._disposeSceneUBOs = function() {
- if (this._sceneUBOs) {
- for (var e = 0, i = this._sceneUBOs; e < i.length; e++) {
- var o = i[e];
- o.dispose()
- }
- this._sceneUBOs = []
- }
- }
- ,
- a.prototype.dispose = function() {
- this._disposeRTTandPostProcesses(),
- this._disposeSceneUBOs(),
- this._light && (this._light._shadowGenerator = null,
- this._light._markMeshesAsLightDirty()),
- this.onBeforeShadowMapRenderMeshObservable.clear(),
- this.onBeforeShadowMapRenderObservable.clear(),
- this.onAfterShadowMapRenderMeshObservable.clear(),
- this.onAfterShadowMapRenderObservable.clear()
- }
- ,
- a.prototype.serialize = function() {
- var e = {}
- , i = this.getShadowMap();
- if (!i)
- return e;
- if (e.className = this.getClassName(),
- e.lightId = this._light.id,
- e.id = this.id,
- e.mapSize = i.getRenderSize(),
- e.forceBackFacesOnly = this.forceBackFacesOnly,
- e.darkness = this.getDarkness(),
- e.transparencyShadow = this._transparencyShadow,
- e.frustumEdgeFalloff = this.frustumEdgeFalloff,
- e.bias = this.bias,
- e.normalBias = this.normalBias,
- e.usePercentageCloserFiltering = this.usePercentageCloserFiltering,
- e.useContactHardeningShadow = this.useContactHardeningShadow,
- e.contactHardeningLightSizeUVRatio = this.contactHardeningLightSizeUVRatio,
- e.filteringQuality = this.filteringQuality,
- e.useExponentialShadowMap = this.useExponentialShadowMap,
- e.useBlurExponentialShadowMap = this.useBlurExponentialShadowMap,
- e.useCloseExponentialShadowMap = this.useBlurExponentialShadowMap,
- e.useBlurCloseExponentialShadowMap = this.useBlurExponentialShadowMap,
- e.usePoissonSampling = this.usePoissonSampling,
- e.depthScale = this.depthScale,
- e.blurBoxOffset = this.blurBoxOffset,
- e.blurKernel = this.blurKernel,
- e.blurScale = this.blurScale,
- e.useKernelBlur = this.useKernelBlur,
- e.renderList = [],
- i.renderList)
- for (var o = 0; o < i.renderList.length; o++) {
- var s = i.renderList[o];
- e.renderList.push(s.id)
- }
- return e
- }
- ,
- a.Parse = function(e, i, o) {
- 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; _++) {
- var b = i.getMeshesById(e.renderList[_]);
- b.forEach(function(k) {
- !d || (d.renderList || (d.renderList = []),
- d.renderList.push(k))
- })
- }
- return e.id !== void 0 && (c.id = e.id),
- c.forceBackFacesOnly = !!e.forceBackFacesOnly,
- e.darkness !== void 0 && c.setDarkness(e.darkness),
- e.transparencyShadow && c.setTransparencyShadow(!0),
- e.frustumEdgeFalloff !== void 0 && (c.frustumEdgeFalloff = e.frustumEdgeFalloff),
- e.bias !== void 0 && (c.bias = e.bias),
- e.normalBias !== void 0 && (c.normalBias = e.normalBias),
- 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),
- e.contactHardeningLightSizeUVRatio !== void 0 && (c.contactHardeningLightSizeUVRatio = e.contactHardeningLightSizeUVRatio),
- e.filteringQuality !== void 0 && (c.filteringQuality = e.filteringQuality),
- e.depthScale && (c.depthScale = e.depthScale),
- e.blurScale && (c.blurScale = e.blurScale),
- e.blurBoxOffset && (c.blurBoxOffset = e.blurBoxOffset),
- e.useKernelBlur && (c.useKernelBlur = e.useKernelBlur),
- e.blurKernel && (c.blurKernel = e.blurKernel),
- c
- }
- ,
- a.CLASSNAME = "ShadowGenerator",
- a.FILTER_NONE = 0,
- a.FILTER_EXPONENTIALSHADOWMAP = 1,
- a.FILTER_POISSONSAMPLING = 2,
- a.FILTER_BLUREXPONENTIALSHADOWMAP = 3,
- a.FILTER_CLOSEEXPONENTIALSHADOWMAP = 4,
- a.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP = 5,
- a.FILTER_PCF = 6,
- a.FILTER_PCSS = 7,
- a.QUALITY_HIGH = 0,
- a.QUALITY_MEDIUM = 1,
- a.QUALITY_LOW = 2,
- a._SceneComponentInitialization = function(e) {
- throw _WarnImport("ShadowGeneratorSceneComponent")
- }
- ,
- a
- }()
- , PushMaterial = function(a) {
- __extends(e, a);
- function e(i, o, s) {
- s === void 0 && (s = !0);
- var c = a.call(this, i, o) || this;
- return c._normalMatrix = new Matrix,
- c._storeEffectOnSubMeshes = s,
- c
- }
- return e.prototype.getEffect = function() {
- return this._storeEffectOnSubMeshes ? this._activeEffect : a.prototype.getEffect.call(this)
- }
- ,
- e.prototype.isReady = function(i, o) {
- return i ? !this._storeEffectOnSubMeshes || !i.subMeshes || i.subMeshes.length === 0 ? !0 : this.isReadyForSubMesh(i, i.subMeshes[0], o) : !1
- }
- ,
- e.prototype._isReadyForSubMesh = function(i) {
- var o = i.materialDefines;
- return !!(!this.checkReadyOnEveryCall && i.effect && o && o._renderId === this.getScene().getRenderId())
- }
- ,
- e.prototype.bindOnlyWorldMatrix = function(i) {
- this._activeEffect.setMatrix("world", i)
- }
- ,
- e.prototype.bindOnlyNormalMatrix = function(i) {
- this._activeEffect.setMatrix("normalMatrix", i)
- }
- ,
- e.prototype.bind = function(i, o) {
- !o || this.bindForSubMesh(i, o, o.subMeshes[0])
- }
- ,
- e.prototype._afterBind = function(i, o) {
- o === void 0 && (o = null),
- a.prototype._afterBind.call(this, i, o),
- this.getScene()._cachedEffect = o
- }
- ,
- e.prototype._mustRebind = function(i, o, s) {
- return s === void 0 && (s = 1),
- i.isCachedMaterialInvalid(this, o, s)
- }
- ,
- e
- }(Material)
- , onCreatedEffectParameters$3 = {
- effect: null,
- subMesh: null
- }
- , ShaderMaterial = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d) {
- c === void 0 && (c = {}),
- d === void 0 && (d = !0);
- var _ = a.call(this, i, o, d) || this;
- return _._textures = {},
- _._textureArrays = {},
- _._externalTextures = {},
- _._floats = {},
- _._ints = {},
- _._floatsArrays = {},
- _._colors3 = {},
- _._colors3Arrays = {},
- _._colors4 = {},
- _._colors4Arrays = {},
- _._vectors2 = {},
- _._vectors3 = {},
- _._vectors4 = {},
- _._matrices = {},
- _._matrixArrays = {},
- _._matrices3x3 = {},
- _._matrices2x2 = {},
- _._vectors2Arrays = {},
- _._vectors3Arrays = {},
- _._vectors4Arrays = {},
- _._uniformBuffers = {},
- _._textureSamplers = {},
- _._storageBuffers = {},
- _._cachedWorldViewMatrix = new Matrix,
- _._cachedWorldViewProjectionMatrix = new Matrix,
- _._multiview = !1,
- _._shaderPath = s,
- _._options = __assign({
- needAlphaBlending: !1,
- needAlphaTesting: !1,
- attributes: ["position", "normal", "uv"],
- uniforms: ["worldViewProjection"],
- uniformBuffers: [],
- samplers: [],
- externalTextures: [],
- samplerObjects: [],
- storageBuffers: [],
- defines: [],
- useClipPlane: !1
- }, c),
- _
- }
- return Object.defineProperty(e.prototype, "shaderPath", {
- get: function() {
- return this._shaderPath
- },
- set: function(i) {
- this._shaderPath = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "options", {
- get: function() {
- return this._options
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getClassName = function() {
- return "ShaderMaterial"
- }
- ,
- e.prototype.needAlphaBlending = function() {
- return this.alpha < 1 || this._options.needAlphaBlending
- }
- ,
- e.prototype.needAlphaTesting = function() {
- return this._options.needAlphaTesting
- }
- ,
- e.prototype._checkUniform = function(i) {
- this._options.uniforms.indexOf(i) === -1 && this._options.uniforms.push(i)
- }
- ,
- e.prototype.setTexture = function(i, o) {
- return this._options.samplers.indexOf(i) === -1 && this._options.samplers.push(i),
- this._textures[i] = o,
- this
- }
- ,
- e.prototype.setTextureArray = function(i, o) {
- return this._options.samplers.indexOf(i) === -1 && this._options.samplers.push(i),
- this._checkUniform(i),
- this._textureArrays[i] = o,
- this
- }
- ,
- e.prototype.setExternalTexture = function(i, o) {
- return this._options.externalTextures.indexOf(i) === -1 && this._options.externalTextures.push(i),
- this._externalTextures[i] = o,
- this
- }
- ,
- e.prototype.setFloat = function(i, o) {
- return this._checkUniform(i),
- this._floats[i] = o,
- this
- }
- ,
- e.prototype.setInt = function(i, o) {
- return this._checkUniform(i),
- this._ints[i] = o,
- this
- }
- ,
- e.prototype.setFloats = function(i, o) {
- return this._checkUniform(i),
- this._floatsArrays[i] = o,
- this
- }
- ,
- e.prototype.setColor3 = function(i, o) {
- return this._checkUniform(i),
- this._colors3[i] = o,
- this
- }
- ,
- e.prototype.setColor3Array = function(i, o) {
- return this._checkUniform(i),
- this._colors3Arrays[i] = o.reduce(function(s, c) {
- return c.toArray(s, s.length),
- s
- }, []),
- this
- }
- ,
- e.prototype.setColor4 = function(i, o) {
- return this._checkUniform(i),
- this._colors4[i] = o,
- this
- }
- ,
- e.prototype.setColor4Array = function(i, o) {
- return this._checkUniform(i),
- this._colors4Arrays[i] = o.reduce(function(s, c) {
- return c.toArray(s, s.length),
- s
- }, []),
- this
- }
- ,
- e.prototype.setVector2 = function(i, o) {
- return this._checkUniform(i),
- this._vectors2[i] = o,
- this
- }
- ,
- e.prototype.setVector3 = function(i, o) {
- return this._checkUniform(i),
- this._vectors3[i] = o,
- this
- }
- ,
- e.prototype.setVector4 = function(i, o) {
- return this._checkUniform(i),
- this._vectors4[i] = o,
- this
- }
- ,
- e.prototype.setMatrix = function(i, o) {
- return this._checkUniform(i),
- this._matrices[i] = o,
- this
- }
- ,
- e.prototype.setMatrices = function(i, o) {
- this._checkUniform(i);
- for (var s = new Float32Array(o.length * 16), c = 0; c < o.length; c++) {
- var d = o[c];
- d.copyToArray(s, c * 16)
- }
- return this._matrixArrays[i] = s,
- this
- }
- ,
- e.prototype.setMatrix3x3 = function(i, o) {
- return this._checkUniform(i),
- this._matrices3x3[i] = o,
- this
- }
- ,
- e.prototype.setMatrix2x2 = function(i, o) {
- return this._checkUniform(i),
- this._matrices2x2[i] = o,
- this
- }
- ,
- e.prototype.setArray2 = function(i, o) {
- return this._checkUniform(i),
- this._vectors2Arrays[i] = o,
- this
- }
- ,
- e.prototype.setArray3 = function(i, o) {
- return this._checkUniform(i),
- this._vectors3Arrays[i] = o,
- this
- }
- ,
- e.prototype.setArray4 = function(i, o) {
- return this._checkUniform(i),
- this._vectors4Arrays[i] = o,
- this
- }
- ,
- e.prototype.setUniformBuffer = function(i, o) {
- return this._options.uniformBuffers.indexOf(i) === -1 && this._options.uniformBuffers.push(i),
- this._uniformBuffers[i] = o,
- this
- }
- ,
- e.prototype.setTextureSampler = function(i, o) {
- return this._options.samplerObjects.indexOf(i) === -1 && this._options.samplerObjects.push(i),
- this._textureSamplers[i] = o,
- this
- }
- ,
- e.prototype.setStorageBuffer = function(i, o) {
- return this._options.storageBuffers.indexOf(i) === -1 && this._options.storageBuffers.push(i),
- this._storageBuffers[i] = o,
- this
- }
- ,
- e.prototype.isReadyForSubMesh = function(i, o, s) {
- return this.isReady(i, s, o)
- }
- ,
- e.prototype.isReady = function(i, o, s) {
- var c, d, _, b, k = s && this._storeEffectOnSubMeshes;
- if (this.isFrozen)
- if (k) {
- if (s.effect && s.effect._wasPreviouslyReady)
- return !0
- } else {
- var j = this._drawWrapper.effect;
- if (j && j._wasPreviouslyReady && this._effectUsesInstances === o)
- return !0
- }
- var $ = this.getScene()
- , _e = $.getEngine()
- , et = []
- , tt = []
- , rt = new EffectFallbacks
- , it = this._shaderPath
- , nt = this._options.uniforms
- , ot = this._options.uniformBuffers
- , at = this._options.samplers;
- _e.getCaps().multiview && $.activeCamera && $.activeCamera.outputRenderTarget && $.activeCamera.outputRenderTarget.getViewCount() > 1 && (this._multiview = !0,
- et.push("#define MULTIVIEW"),
- this._options.uniforms.indexOf("viewProjection") !== -1 && this._options.uniforms.indexOf("viewProjectionR") === -1 && this._options.uniforms.push("viewProjectionR"));
- for (var st = 0; st < this._options.defines.length; st++) {
- var ut = this._options.defines[st].indexOf("#define") === 0 ? this._options.defines[st] : "#define " + this._options.defines[st];
- et.push(ut)
- }
- for (var st = 0; st < this._options.attributes.length; st++)
- tt.push(this._options.attributes[st]);
- if (i && i.isVerticesDataPresent(VertexBuffer.ColorKind) && (tt.push(VertexBuffer.ColorKind),
- et.push("#define VERTEXCOLOR")),
- o && (et.push("#define INSTANCES"),
- MaterialHelper.PushAttributesForInstances(tt),
- i != null && i.hasThinInstances && et.push("#define THIN_INSTANCES")),
- i && i.useBones && i.computeBonesUsingShaders && i.skeleton) {
- tt.push(VertexBuffer.MatricesIndicesKind),
- tt.push(VertexBuffer.MatricesWeightsKind),
- i.numBoneInfluencers > 4 && (tt.push(VertexBuffer.MatricesIndicesExtraKind),
- tt.push(VertexBuffer.MatricesWeightsExtraKind));
- var ct = i.skeleton;
- et.push("#define NUM_BONE_INFLUENCERS " + i.numBoneInfluencers),
- rt.addCPUSkinningFallback(0, i),
- ct.isUsingTextureForMatrices ? (et.push("#define BONETEXTURE"),
- this._options.uniforms.indexOf("boneTextureWidth") === -1 && this._options.uniforms.push("boneTextureWidth"),
- this._options.samplers.indexOf("boneSampler") === -1 && this._options.samplers.push("boneSampler")) : (et.push("#define BonesPerMesh " + (ct.bones.length + 1)),
- this._options.uniforms.indexOf("mBones") === -1 && this._options.uniforms.push("mBones"))
- } else
- et.push("#define NUM_BONE_INFLUENCERS 0");
- var lt = 0
- , ft = i ? i.morphTargetManager : null;
- if (ft) {
- var ht = ft.supportsUVs && et.indexOf("#define UV1") !== -1
- , pt = ft.supportsTangents && et.indexOf("#define TANGENT") !== -1
- , dt = ft.supportsNormals && et.indexOf("#define NORMAL") !== -1;
- lt = ft.numInfluencers,
- ht && et.push("#define MORPHTARGETS_UV"),
- pt && et.push("#define MORPHTARGETS_TANGENT"),
- dt && et.push("#define MORPHTARGETS_NORMAL"),
- lt > 0 && et.push("#define MORPHTARGETS"),
- ft.isUsingTextureForTargets && (et.push("#define MORPHTARGETS_TEXTURE"),
- this._options.uniforms.indexOf("morphTargetTextureIndices") === -1 && this._options.uniforms.push("morphTargetTextureIndices"),
- this._options.samplers.indexOf("morphTargets") === -1 && this._options.samplers.push("morphTargets")),
- et.push("#define NUM_MORPH_INFLUENCERS " + lt);
- for (var st = 0; st < lt; st++)
- tt.push(VertexBuffer.PositionKind + st),
- dt && tt.push(VertexBuffer.NormalKind + st),
- pt && tt.push(VertexBuffer.TangentKind + st),
- ht && tt.push(VertexBuffer.UVKind + "_" + st);
- lt > 0 && (nt = nt.slice(),
- nt.push("morphTargetInfluences"),
- nt.push("morphTargetTextureInfo"),
- nt.push("morphTargetTextureIndices"))
- } else
- et.push("#define NUM_MORPH_INFLUENCERS 0");
- if (i) {
- var _t = i.bakedVertexAnimationManager;
- _t && _t.isEnabled && (et.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),
- this._options.uniforms.indexOf("bakedVertexAnimationSettings") === -1 && this._options.uniforms.push("bakedVertexAnimationSettings"),
- this._options.uniforms.indexOf("bakedVertexAnimationTextureSizeInverted") === -1 && this._options.uniforms.push("bakedVertexAnimationTextureSizeInverted"),
- this._options.uniforms.indexOf("bakedVertexAnimationTime") === -1 && this._options.uniforms.push("bakedVertexAnimationTime"),
- this._options.samplers.indexOf("bakedVertexAnimationTexture") === -1 && this._options.samplers.push("bakedVertexAnimationTexture")),
- MaterialHelper.PrepareAttributesForBakedVertexAnimation(tt, i, et)
- }
- for (var mt in this._textures)
- if (!this._textures[mt].isReady())
- return !1;
- i && this._shouldTurnAlphaTestOn(i) && et.push("#define ALPHATEST"),
- (this._options.useClipPlane === null && !!$.clipPlane || this._options.useClipPlane) && (et.push("#define CLIPPLANE"),
- nt.indexOf("vClipPlane") === -1 && nt.push("vClipPlane")),
- (this._options.useClipPlane === null && !!$.clipPlane2 || this._options.useClipPlane) && (et.push("#define CLIPPLANE2"),
- nt.indexOf("vClipPlane2") === -1 && nt.push("vClipPlane2")),
- (this._options.useClipPlane === null && !!$.clipPlane3 || this._options.useClipPlane) && (et.push("#define CLIPPLANE3"),
- nt.indexOf("vClipPlane3") === -1 && nt.push("vClipPlane3")),
- (this._options.useClipPlane === null && !!$.clipPlane4 || this._options.useClipPlane) && (et.push("#define CLIPPLANE4"),
- nt.indexOf("vClipPlane4") === -1 && nt.push("vClipPlane4")),
- (this._options.useClipPlane === null && !!$.clipPlane5 || this._options.useClipPlane) && (et.push("#define CLIPPLANE5"),
- nt.indexOf("vClipPlane5") === -1 && nt.push("vClipPlane5")),
- (this._options.useClipPlane === null && !!$.clipPlane6 || this._options.useClipPlane) && (et.push("#define CLIPPLANE6"),
- nt.indexOf("vClipPlane6") === -1 && nt.push("vClipPlane6")),
- this.customShaderNameResolve && (nt = nt.slice(),
- ot = ot.slice(),
- at = at.slice(),
- it = this.customShaderNameResolve(it, nt, ot, at, et, tt));
- var vt = k ? s._getDrawWrapper() : this._drawWrapper
- , yt = (c = vt == null ? void 0 : vt.effect) !== null && c !== void 0 ? c : null
- , Et = (d = vt == null ? void 0 : vt.defines) !== null && d !== void 0 ? d : null
- , At = et.join(`
- `)
- , gt = yt;
- return Et !== At && (gt = _e.createEffect(it, {
- attributes: tt,
- uniformsNames: nt,
- uniformBuffersNames: ot,
- samplers: at,
- defines: At,
- fallbacks: rt,
- onCompiled: this.onCompiled,
- onError: this.onError,
- indexParameters: {
- maxSimultaneousMorphTargets: lt
- },
- shaderLanguage: this._options.shaderLanguage
- }, _e),
- k ? s.setEffect(gt, At, this._materialContext) : vt && vt.setEffect(gt, At),
- this._onEffectCreatedObservable && (onCreatedEffectParameters$3.effect = gt,
- onCreatedEffectParameters$3.subMesh = (_ = s != null ? s : i == null ? void 0 : i.subMeshes[0]) !== null && _ !== void 0 ? _ : null,
- this._onEffectCreatedObservable.notifyObservers(onCreatedEffectParameters$3))),
- this._effectUsesInstances = !!o,
- !((b = !(gt != null && gt.isReady())) !== null && b !== void 0) || b ? !1 : (yt !== gt && $.resetCachedMaterial(),
- gt._wasPreviouslyReady = !0,
- !0)
- }
- ,
- e.prototype.bindOnlyWorldMatrix = function(i, o) {
- var s = this.getScene()
- , c = o != null ? o : this.getEffect();
- !c || (this._options.uniforms.indexOf("world") !== -1 && c.setMatrix("world", i),
- this._options.uniforms.indexOf("worldView") !== -1 && (i.multiplyToRef(s.getViewMatrix(), this._cachedWorldViewMatrix),
- c.setMatrix("worldView", this._cachedWorldViewMatrix)),
- this._options.uniforms.indexOf("worldViewProjection") !== -1 && (i.multiplyToRef(s.getTransformMatrix(), this._cachedWorldViewProjectionMatrix),
- c.setMatrix("worldViewProjection", this._cachedWorldViewProjectionMatrix)))
- }
- ,
- e.prototype.bindForSubMesh = function(i, o, s) {
- var c;
- this.bind(i, o, (c = s._drawWrapperOverride) === null || c === void 0 ? void 0 : c.effect, s)
- }
- ,
- e.prototype.bind = function(i, o, s, c) {
- var d, _ = c && this._storeEffectOnSubMeshes, b = s != null ? s : _ ? c.effect : this.getEffect();
- if (!!b) {
- this._activeEffect = b,
- this.bindOnlyWorldMatrix(i, s);
- var k = this._options.uniformBuffers
- , j = !1;
- if (b && k && k.length > 0 && this.getScene().getEngine().supportsUniformBuffers)
- for (var $ = 0; $ < k.length; ++$) {
- var _e = k[$];
- switch (_e) {
- case "Mesh":
- o && (o.getMeshUniformBuffer().bindToEffect(b, "Mesh"),
- o.transferToEffect(i));
- break;
- case "Scene":
- MaterialHelper.BindSceneUniformBuffer(b, this.getScene().getSceneUniformBuffer()),
- this.getScene().finalizeSceneUbo(),
- j = !0;
- break
- }
- }
- var et = o && _ ? this._mustRebind(this.getScene(), b, o.visibility) : this.getScene().getCachedMaterial() !== this;
- if (b && et) {
- !j && this._options.uniforms.indexOf("view") !== -1 && b.setMatrix("view", this.getScene().getViewMatrix()),
- !j && this._options.uniforms.indexOf("projection") !== -1 && b.setMatrix("projection", this.getScene().getProjectionMatrix()),
- !j && this._options.uniforms.indexOf("viewProjection") !== -1 && (b.setMatrix("viewProjection", this.getScene().getTransformMatrix()),
- this._multiview && b.setMatrix("viewProjectionR", this.getScene()._transformMatrixR)),
- this.getScene().activeCamera && this._options.uniforms.indexOf("cameraPosition") !== -1 && b.setVector3("cameraPosition", this.getScene().activeCamera.globalPosition),
- MaterialHelper.BindBonesParameters(o, b),
- MaterialHelper.BindClipPlane(b, this.getScene());
- var tt;
- for (tt in this._textures)
- b.setTexture(tt, this._textures[tt]);
- for (tt in this._textureArrays)
- b.setTextureArray(tt, this._textureArrays[tt]);
- for (tt in this._externalTextures)
- b.setExternalTexture(tt, this._externalTextures[tt]);
- for (tt in this._ints)
- b.setInt(tt, this._ints[tt]);
- for (tt in this._floats)
- b.setFloat(tt, this._floats[tt]);
- for (tt in this._floatsArrays)
- b.setArray(tt, this._floatsArrays[tt]);
- for (tt in this._colors3)
- b.setColor3(tt, this._colors3[tt]);
- for (tt in this._colors3Arrays)
- b.setArray3(tt, this._colors3Arrays[tt]);
- for (tt in this._colors4) {
- var rt = this._colors4[tt];
- b.setFloat4(tt, rt.r, rt.g, rt.b, rt.a)
- }
- for (tt in this._colors4Arrays)
- b.setArray4(tt, this._colors4Arrays[tt]);
- for (tt in this._vectors2)
- b.setVector2(tt, this._vectors2[tt]);
- for (tt in this._vectors3)
- b.setVector3(tt, this._vectors3[tt]);
- for (tt in this._vectors4)
- b.setVector4(tt, this._vectors4[tt]);
- for (tt in this._matrices)
- b.setMatrix(tt, this._matrices[tt]);
- for (tt in this._matrixArrays)
- b.setMatrices(tt, this._matrixArrays[tt]);
- for (tt in this._matrices3x3)
- b.setMatrix3x3(tt, this._matrices3x3[tt]);
- for (tt in this._matrices2x2)
- b.setMatrix2x2(tt, this._matrices2x2[tt]);
- for (tt in this._vectors2Arrays)
- b.setArray2(tt, this._vectors2Arrays[tt]);
- for (tt in this._vectors3Arrays)
- b.setArray3(tt, this._vectors3Arrays[tt]);
- for (tt in this._vectors4Arrays)
- b.setArray4(tt, this._vectors4Arrays[tt]);
- for (tt in this._uniformBuffers) {
- var it = this._uniformBuffers[tt].getBuffer();
- it && b.bindUniformBuffer(it, tt)
- }
- for (tt in this._textureSamplers)
- b.setTextureSampler(tt, this._textureSamplers[tt]);
- for (tt in this._storageBuffers)
- b.setStorageBuffer(tt, this._storageBuffers[tt])
- }
- if (b && o && (et || !this.isFrozen)) {
- var nt = o.morphTargetManager;
- nt && nt.numInfluencers > 0 && MaterialHelper.BindMorphTargetParameters(o, b);
- var ot = o.bakedVertexAnimationManager;
- ot && ot.isEnabled && ((d = o.bakedVertexAnimationManager) === null || d === void 0 || d.bind(b, this._effectUsesInstances))
- }
- this._afterBind(o, b)
- }
- }
- ,
- e.prototype.getActiveTextures = function() {
- var i = a.prototype.getActiveTextures.call(this);
- for (var o in this._textures)
- i.push(this._textures[o]);
- for (var o in this._textureArrays)
- for (var s = this._textureArrays[o], c = 0; c < s.length; c++)
- i.push(s[c]);
- return i
- }
- ,
- e.prototype.hasTexture = function(i) {
- if (a.prototype.hasTexture.call(this, i))
- return !0;
- for (var o in this._textures)
- if (this._textures[o] === i)
- return !0;
- for (var o in this._textureArrays)
- for (var s = this._textureArrays[o], c = 0; c < s.length; c++)
- if (s[c] === i)
- return !0;
- return !1
- }
- ,
- e.prototype.clone = function(i) {
- var o = this
- , s = SerializationHelper.Clone(function() {
- return new e(i,o.getScene(),o._shaderPath,o._options,o._storeEffectOnSubMeshes)
- }, this);
- s.name = i,
- s.id = i,
- typeof s._shaderPath == "object" && (s._shaderPath = __assign({}, s._shaderPath)),
- this._options = __assign({}, this._options),
- Object.keys(this._options).forEach(function(d) {
- var _ = o._options[d];
- Array.isArray(_) && (o._options[d] = _.slice(0))
- }),
- this.stencil.copyTo(s.stencil);
- for (var c in this._textures)
- s.setTexture(c, this._textures[c]);
- for (var c in this._textureArrays)
- s.setTextureArray(c, this._textureArrays[c]);
- for (var c in this._externalTextures)
- s.setExternalTexture(c, this._externalTextures[c]);
- for (var c in this._ints)
- s.setInt(c, this._ints[c]);
- for (var c in this._floats)
- s.setFloat(c, this._floats[c]);
- for (var c in this._floatsArrays)
- s.setFloats(c, this._floatsArrays[c]);
- for (var c in this._colors3)
- s.setColor3(c, this._colors3[c]);
- for (var c in this._colors3Arrays)
- s._colors3Arrays[c] = this._colors3Arrays[c];
- for (var c in this._colors4)
- s.setColor4(c, this._colors4[c]);
- for (var c in this._colors4Arrays)
- s._colors4Arrays[c] = this._colors4Arrays[c];
- for (var c in this._vectors2)
- s.setVector2(c, this._vectors2[c]);
- for (var c in this._vectors3)
- s.setVector3(c, this._vectors3[c]);
- for (var c in this._vectors4)
- s.setVector4(c, this._vectors4[c]);
- for (var c in this._matrices)
- s.setMatrix(c, this._matrices[c]);
- for (var c in this._matrixArrays)
- s._matrixArrays[c] = this._matrixArrays[c].slice();
- for (var c in this._matrices3x3)
- s.setMatrix3x3(c, this._matrices3x3[c]);
- for (var c in this._matrices2x2)
- s.setMatrix2x2(c, this._matrices2x2[c]);
- for (var c in this._vectors2Arrays)
- s.setArray2(c, this._vectors2Arrays[c]);
- for (var c in this._vectors3Arrays)
- s.setArray3(c, this._vectors3Arrays[c]);
- for (var c in this._vectors4Arrays)
- s.setArray4(c, this._vectors4Arrays[c]);
- for (var c in this._uniformBuffers)
- s.setUniformBuffer(c, this._uniformBuffers[c]);
- for (var c in this._textureSamplers)
- s.setTextureSampler(c, this._textureSamplers[c]);
- for (var c in this._storageBuffers)
- s.setStorageBuffer(c, this._storageBuffers[c]);
- return s
- }
- ,
- e.prototype.dispose = function(i, o, s) {
- if (o) {
- var c;
- for (c in this._textures)
- this._textures[c].dispose();
- for (c in this._textureArrays)
- for (var d = this._textureArrays[c], _ = 0; _ < d.length; _++)
- d[_].dispose()
- }
- this._textures = {},
- a.prototype.dispose.call(this, i, o, s)
- }
- ,
- e.prototype.serialize = function() {
- var i = SerializationHelper.Serialize(this);
- i.customType = "BABYLON.ShaderMaterial",
- i.options = this._options,
- i.shaderPath = this._shaderPath,
- i.storeEffectOnSubMeshes = this._storeEffectOnSubMeshes;
- var o;
- i.stencil = this.stencil.serialize(),
- i.textures = {};
- for (o in this._textures)
- i.textures[o] = this._textures[o].serialize();
- i.textureArrays = {};
- for (o in this._textureArrays) {
- i.textureArrays[o] = [];
- for (var s = this._textureArrays[o], c = 0; c < s.length; c++)
- i.textureArrays[o].push(s[c].serialize())
- }
- i.ints = {};
- for (o in this._ints)
- i.ints[o] = this._ints[o];
- i.floats = {};
- for (o in this._floats)
- i.floats[o] = this._floats[o];
- i.FloatArrays = {};
- for (o in this._floatsArrays)
- i.FloatArrays[o] = this._floatsArrays[o];
- i.colors3 = {};
- for (o in this._colors3)
- i.colors3[o] = this._colors3[o].asArray();
- i.colors3Arrays = {};
- for (o in this._colors3Arrays)
- i.colors3Arrays[o] = this._colors3Arrays[o];
- i.colors4 = {};
- for (o in this._colors4)
- i.colors4[o] = this._colors4[o].asArray();
- i.colors4Arrays = {};
- for (o in this._colors4Arrays)
- i.colors4Arrays[o] = this._colors4Arrays[o];
- i.vectors2 = {};
- for (o in this._vectors2)
- i.vectors2[o] = this._vectors2[o].asArray();
- i.vectors3 = {};
- for (o in this._vectors3)
- i.vectors3[o] = this._vectors3[o].asArray();
- i.vectors4 = {};
- for (o in this._vectors4)
- i.vectors4[o] = this._vectors4[o].asArray();
- i.matrices = {};
- for (o in this._matrices)
- i.matrices[o] = this._matrices[o].asArray();
- i.matrixArray = {};
- for (o in this._matrixArrays)
- i.matrixArray[o] = this._matrixArrays[o];
- i.matrices3x3 = {};
- for (o in this._matrices3x3)
- i.matrices3x3[o] = this._matrices3x3[o];
- i.matrices2x2 = {};
- for (o in this._matrices2x2)
- i.matrices2x2[o] = this._matrices2x2[o];
- i.vectors2Arrays = {};
- for (o in this._vectors2Arrays)
- i.vectors2Arrays[o] = this._vectors2Arrays[o];
- i.vectors3Arrays = {};
- for (o in this._vectors3Arrays)
- i.vectors3Arrays[o] = this._vectors3Arrays[o];
- i.vectors4Arrays = {};
- for (o in this._vectors4Arrays)
- i.vectors4Arrays[o] = this._vectors4Arrays[o];
- return i
- }
- ,
- e.Parse = function(i, o, s) {
- var c = SerializationHelper.Parse(function() {
- return new e(i.name,o,i.shaderPath,i.options,i.storeEffectOnSubMeshes)
- }, i, o, s), d;
- i.stencil && c.stencil.parse(i.stencil, o, s);
- for (d in i.textures)
- c.setTexture(d, Texture.Parse(i.textures[d], o, s));
- for (d in i.textureArrays) {
- for (var _ = i.textureArrays[d], b = new Array, k = 0; k < _.length; k++)
- b.push(Texture.Parse(_[k], o, s));
- c.setTextureArray(d, b)
- }
- for (d in i.ints)
- c.setInt(d, i.ints[d]);
- for (d in i.floats)
- c.setFloat(d, i.floats[d]);
- for (d in i.floatsArrays)
- c.setFloats(d, i.floatsArrays[d]);
- for (d in i.colors3)
- c.setColor3(d, Color3.FromArray(i.colors3[d]));
- for (d in i.colors3Arrays) {
- var j = i.colors3Arrays[d].reduce(function($, _e, et) {
- return et % 3 === 0 ? $.push([_e]) : $[$.length - 1].push(_e),
- $
- }, []).map(function($) {
- return Color3.FromArray($)
- });
- c.setColor3Array(d, j)
- }
- for (d in i.colors4)
- c.setColor4(d, Color4.FromArray(i.colors4[d]));
- for (d in i.colors4Arrays) {
- var j = i.colors4Arrays[d].reduce(function(_e, et, tt) {
- return tt % 4 === 0 ? _e.push([et]) : _e[_e.length - 1].push(et),
- _e
- }, []).map(function(_e) {
- return Color4.FromArray(_e)
- });
- c.setColor4Array(d, j)
- }
- for (d in i.vectors2)
- c.setVector2(d, Vector2.FromArray(i.vectors2[d]));
- for (d in i.vectors3)
- c.setVector3(d, Vector3.FromArray(i.vectors3[d]));
- for (d in i.vectors4)
- c.setVector4(d, Vector4.FromArray(i.vectors4[d]));
- for (d in i.matrices)
- c.setMatrix(d, Matrix.FromArray(i.matrices[d]));
- for (d in i.matrixArray)
- c._matrixArrays[d] = new Float32Array(i.matrixArray[d]);
- for (d in i.matrices3x3)
- c.setMatrix3x3(d, i.matrices3x3[d]);
- for (d in i.matrices2x2)
- c.setMatrix2x2(d, i.matrices2x2[d]);
- for (d in i.vectors2Arrays)
- c.setArray2(d, i.vectors2Arrays[d]);
- for (d in i.vectors3Arrays)
- c.setArray3(d, i.vectors3Arrays[d]);
- for (d in i.vectors4Arrays)
- c.setArray4(d, i.vectors4Arrays[d]);
- return c
- }
- ,
- e.ParseFromFileAsync = function(i, o, s, c) {
- var d = this;
- return c === void 0 && (c = ""),
- new Promise(function(_, b) {
- var k = new WebRequest;
- k.addEventListener("readystatechange", function() {
- if (k.readyState == 4)
- if (k.status == 200) {
- var j = JSON.parse(k.responseText)
- , $ = d.Parse(j, s || Engine.LastCreatedScene, c);
- i && ($.name = i),
- _($)
- } else
- b("Unable to load the ShaderMaterial")
- }),
- k.open("GET", o),
- k.send()
- }
- )
- }
- ,
- e.CreateFromSnippetAsync = function(i, o, s) {
- var c = this;
- return s === void 0 && (s = ""),
- new Promise(function(d, _) {
- var b = new WebRequest;
- b.addEventListener("readystatechange", function() {
- if (b.readyState == 4)
- if (b.status == 200) {
- var k = JSON.parse(JSON.parse(b.responseText).jsonPayload)
- , j = JSON.parse(k.shaderMaterial)
- , $ = c.Parse(j, o || Engine.LastCreatedScene, s);
- $.snippetId = i,
- d($)
- } else
- _("Unable to load the snippet " + i)
- }),
- b.open("GET", c.SnippetUrl + "/" + i.replace(/#/g, "/")),
- b.send()
- }
- )
- }
- ,
- e.SnippetUrl = "https://snippet.babylonjs.com",
- e
- }(PushMaterial);
- RegisterClass("BABYLON.ShaderMaterial", ShaderMaterial);
- var PrePassConfiguration = function() {
- function a() {
- this.previousWorldMatrices = {},
- this.previousBones = {}
- }
- return a.AddUniforms = function(e) {
- e.push("previousWorld", "previousViewProjection", "mPreviousBones")
- }
- ,
- a.AddSamplers = function(e) {}
- ,
- a.prototype.bindForSubMesh = function(e, i, o, s, c) {
- if (i.prePassRenderer && i.prePassRenderer.enabled && i.prePassRenderer.currentRTisSceneRT && i.prePassRenderer.getIndex(2) !== -1) {
- this.previousWorldMatrices[o.uniqueId] || (this.previousWorldMatrices[o.uniqueId] = s.clone()),
- this.previousViewProjection || (this.previousViewProjection = i.getTransformMatrix().clone(),
- this.currentViewProjection = i.getTransformMatrix().clone());
- var d = i.getEngine();
- this.currentViewProjection.updateFlag !== i.getTransformMatrix().updateFlag ? (this._lastUpdateFrameId = d.frameId,
- this.previousViewProjection.copyFrom(this.currentViewProjection),
- this.currentViewProjection.copyFrom(i.getTransformMatrix())) : this._lastUpdateFrameId !== d.frameId && (this._lastUpdateFrameId = d.frameId,
- this.previousViewProjection.copyFrom(this.currentViewProjection)),
- e.setMatrix("previousWorld", this.previousWorldMatrices[o.uniqueId]),
- e.setMatrix("previousViewProjection", this.previousViewProjection),
- this.previousWorldMatrices[o.uniqueId] = s.clone()
- }
- }
- ,
- a
- }()
- , MaterialFlags = function() {
- function a() {}
- return Object.defineProperty(a, "DiffuseTextureEnabled", {
- get: function() {
- return this._DiffuseTextureEnabled
- },
- set: function(e) {
- this._DiffuseTextureEnabled !== e && (this._DiffuseTextureEnabled = e,
- Engine.MarkAllMaterialsAsDirty(1))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "DetailTextureEnabled", {
- get: function() {
- return this._DetailTextureEnabled
- },
- set: function(e) {
- this._DetailTextureEnabled !== e && (this._DetailTextureEnabled = e,
- Engine.MarkAllMaterialsAsDirty(1))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "AmbientTextureEnabled", {
- get: function() {
- return this._AmbientTextureEnabled
- },
- set: function(e) {
- this._AmbientTextureEnabled !== e && (this._AmbientTextureEnabled = e,
- Engine.MarkAllMaterialsAsDirty(1))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "OpacityTextureEnabled", {
- get: function() {
- return this._OpacityTextureEnabled
- },
- set: function(e) {
- this._OpacityTextureEnabled !== e && (this._OpacityTextureEnabled = e,
- Engine.MarkAllMaterialsAsDirty(1))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "ReflectionTextureEnabled", {
- get: function() {
- return this._ReflectionTextureEnabled
- },
- set: function(e) {
- this._ReflectionTextureEnabled !== e && (this._ReflectionTextureEnabled = e,
- Engine.MarkAllMaterialsAsDirty(1))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "EmissiveTextureEnabled", {
- get: function() {
- return this._EmissiveTextureEnabled
- },
- set: function(e) {
- this._EmissiveTextureEnabled !== e && (this._EmissiveTextureEnabled = e,
- Engine.MarkAllMaterialsAsDirty(1))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "SpecularTextureEnabled", {
- get: function() {
- return this._SpecularTextureEnabled
- },
- set: function(e) {
- this._SpecularTextureEnabled !== e && (this._SpecularTextureEnabled = e,
- Engine.MarkAllMaterialsAsDirty(1))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "BumpTextureEnabled", {
- get: function() {
- return this._BumpTextureEnabled
- },
- set: function(e) {
- this._BumpTextureEnabled !== e && (this._BumpTextureEnabled = e,
- Engine.MarkAllMaterialsAsDirty(1))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "LightmapTextureEnabled", {
- get: function() {
- return this._LightmapTextureEnabled
- },
- set: function(e) {
- this._LightmapTextureEnabled !== e && (this._LightmapTextureEnabled = e,
- Engine.MarkAllMaterialsAsDirty(1))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "RefractionTextureEnabled", {
- get: function() {
- return this._RefractionTextureEnabled
- },
- set: function(e) {
- this._RefractionTextureEnabled !== e && (this._RefractionTextureEnabled = e,
- Engine.MarkAllMaterialsAsDirty(1))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "ColorGradingTextureEnabled", {
- get: function() {
- return this._ColorGradingTextureEnabled
- },
- set: function(e) {
- this._ColorGradingTextureEnabled !== e && (this._ColorGradingTextureEnabled = e,
- Engine.MarkAllMaterialsAsDirty(1))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "FresnelEnabled", {
- get: function() {
- return this._FresnelEnabled
- },
- set: function(e) {
- this._FresnelEnabled !== e && (this._FresnelEnabled = e,
- Engine.MarkAllMaterialsAsDirty(4))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "ClearCoatTextureEnabled", {
- get: function() {
- return this._ClearCoatTextureEnabled
- },
- set: function(e) {
- this._ClearCoatTextureEnabled !== e && (this._ClearCoatTextureEnabled = e,
- Engine.MarkAllMaterialsAsDirty(1))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "ClearCoatBumpTextureEnabled", {
- get: function() {
- return this._ClearCoatBumpTextureEnabled
- },
- set: function(e) {
- this._ClearCoatBumpTextureEnabled !== e && (this._ClearCoatBumpTextureEnabled = e,
- Engine.MarkAllMaterialsAsDirty(1))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "ClearCoatTintTextureEnabled", {
- get: function() {
- return this._ClearCoatTintTextureEnabled
- },
- set: function(e) {
- this._ClearCoatTintTextureEnabled !== e && (this._ClearCoatTintTextureEnabled = e,
- Engine.MarkAllMaterialsAsDirty(1))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "SheenTextureEnabled", {
- get: function() {
- return this._SheenTextureEnabled
- },
- set: function(e) {
- this._SheenTextureEnabled !== e && (this._SheenTextureEnabled = e,
- Engine.MarkAllMaterialsAsDirty(1))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "AnisotropicTextureEnabled", {
- get: function() {
- return this._AnisotropicTextureEnabled
- },
- set: function(e) {
- this._AnisotropicTextureEnabled !== e && (this._AnisotropicTextureEnabled = e,
- Engine.MarkAllMaterialsAsDirty(1))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "ThicknessTextureEnabled", {
- get: function() {
- return this._ThicknessTextureEnabled
- },
- set: function(e) {
- this._ThicknessTextureEnabled !== e && (this._ThicknessTextureEnabled = e,
- Engine.MarkAllMaterialsAsDirty(1))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "RefractionIntensityTextureEnabled", {
- get: function() {
- return this._ThicknessTextureEnabled
- },
- set: function(e) {
- this._RefractionIntensityTextureEnabled !== e && (this._RefractionIntensityTextureEnabled = e,
- Engine.MarkAllMaterialsAsDirty(1))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "TranslucencyIntensityTextureEnabled", {
- get: function() {
- return this._ThicknessTextureEnabled
- },
- set: function(e) {
- this._TranslucencyIntensityTextureEnabled !== e && (this._TranslucencyIntensityTextureEnabled = e,
- Engine.MarkAllMaterialsAsDirty(1))
- },
- enumerable: !1,
- configurable: !0
- }),
- a._DiffuseTextureEnabled = !0,
- a._DetailTextureEnabled = !0,
- a._AmbientTextureEnabled = !0,
- a._OpacityTextureEnabled = !0,
- a._ReflectionTextureEnabled = !0,
- a._EmissiveTextureEnabled = !0,
- a._SpecularTextureEnabled = !0,
- a._BumpTextureEnabled = !0,
- a._LightmapTextureEnabled = !0,
- a._RefractionTextureEnabled = !0,
- a._ColorGradingTextureEnabled = !0,
- a._FresnelEnabled = !0,
- a._ClearCoatTextureEnabled = !0,
- a._ClearCoatBumpTextureEnabled = !0,
- a._ClearCoatTintTextureEnabled = !0,
- a._SheenTextureEnabled = !0,
- a._AnisotropicTextureEnabled = !0,
- a._ThicknessTextureEnabled = !0,
- a._RefractionIntensityTextureEnabled = !0,
- a._TranslucencyIntensityTextureEnabled = !0,
- a
- }()
- , name$23 = "defaultFragmentDeclaration"
- , shader$23 = `uniform vec4 vEyePosition;
- uniform vec4 vDiffuseColor;
- #ifdef SPECULARTERM
- uniform vec4 vSpecularColor;
- #endif
- uniform vec3 vEmissiveColor;
- uniform vec3 vAmbientColor;
- uniform float visibility;
- #ifdef DIFFUSE
- uniform vec2 vDiffuseInfos;
- #endif
- #ifdef AMBIENT
- uniform vec2 vAmbientInfos;
- #endif
- #ifdef OPACITY
- uniform vec2 vOpacityInfos;
- #endif
- #ifdef EMISSIVE
- uniform vec2 vEmissiveInfos;
- #endif
- #ifdef LIGHTMAP
- uniform vec2 vLightmapInfos;
- #endif
- #ifdef BUMP
- uniform vec3 vBumpInfos;
- uniform vec2 vTangentSpaceParams;
- #endif
- #ifdef ALPHATEST
- uniform float alphaCutOff;
- #endif
- #if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)
- uniform mat4 view;
- #endif
- #ifdef REFRACTION
- uniform vec4 vRefractionInfos;
- #ifndef REFRACTIONMAP_3D
- uniform mat4 refractionMatrix;
- #endif
- #ifdef REFRACTIONFRESNEL
- uniform vec4 refractionLeftColor;
- uniform vec4 refractionRightColor;
- #endif
- #if defined(USE_LOCAL_REFRACTIONMAP_CUBIC) && defined(REFRACTIONMAP_3D)
- uniform vec3 vRefractionPosition;
- uniform vec3 vRefractionSize;
- #endif
- #endif
- #if defined(SPECULAR) && defined(SPECULARTERM)
- uniform vec2 vSpecularInfos;
- #endif
- #ifdef DIFFUSEFRESNEL
- uniform vec4 diffuseLeftColor;
- uniform vec4 diffuseRightColor;
- #endif
- #ifdef OPACITYFRESNEL
- uniform vec4 opacityParts;
- #endif
- #ifdef EMISSIVEFRESNEL
- uniform vec4 emissiveLeftColor;
- uniform vec4 emissiveRightColor;
- #endif
- #ifdef REFLECTION
- uniform vec2 vReflectionInfos;
- #if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION) || defined(REFLECTIONMAP_EQUIRECTANGULAR) || defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_SKYBOX)
- uniform mat4 reflectionMatrix;
- #endif
- #ifndef REFLECTIONMAP_SKYBOX
- #if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)
- uniform vec3 vReflectionPosition;
- uniform vec3 vReflectionSize;
- #endif
- #endif
- #ifdef REFLECTIONFRESNEL
- uniform vec4 reflectionLeftColor;
- uniform vec4 reflectionRightColor;
- #endif
- #endif
- #ifdef DETAIL
- uniform vec4 vDetailInfos;
- #endif`;
- ShaderStore.IncludesShadersStore[name$23] = shader$23;
- var name$22 = "defaultUboDeclaration"
- , shader$22 = `layout(std140,column_major) uniform;
- uniform Material
- {
- vec4 diffuseLeftColor;
- vec4 diffuseRightColor;
- vec4 opacityParts;
- vec4 reflectionLeftColor;
- vec4 reflectionRightColor;
- vec4 refractionLeftColor;
- vec4 refractionRightColor;
- vec4 emissiveLeftColor;
- vec4 emissiveRightColor;
- vec2 vDiffuseInfos;
- vec2 vAmbientInfos;
- vec2 vOpacityInfos;
- vec2 vReflectionInfos;
- vec3 vReflectionPosition;
- vec3 vReflectionSize;
- vec2 vEmissiveInfos;
- vec2 vLightmapInfos;
- vec2 vSpecularInfos;
- vec3 vBumpInfos;
- mat4 diffuseMatrix;
- mat4 ambientMatrix;
- mat4 opacityMatrix;
- mat4 reflectionMatrix;
- mat4 emissiveMatrix;
- mat4 lightmapMatrix;
- mat4 specularMatrix;
- mat4 bumpMatrix;
- vec2 vTangentSpaceParams;
- float pointSize;
- float alphaCutOff;
- mat4 refractionMatrix;
- vec4 vRefractionInfos;
- vec3 vRefractionPosition;
- vec3 vRefractionSize;
- vec4 vSpecularColor;
- vec3 vEmissiveColor;
- vec4 vDiffuseColor;
- vec3 vAmbientColor;
- vec4 vDetailInfos;
- mat4 detailMatrix;
- };
- #include<sceneUboDeclaration>
- #include<meshUboDeclaration>
- `;
- ShaderStore.IncludesShadersStore[name$22] = shader$22;
- var name$21 = "prePassDeclaration"
- , shader$21 = `#ifdef PREPASS
- #extension GL_EXT_draw_buffers : require
- layout(location=0) out highp vec4 glFragData[{X}];
- highp vec4 gl_FragColor;
- #ifdef PREPASS_DEPTH
- varying highp vec3 vViewPos;
- #endif
- #ifdef PREPASS_VELOCITY
- varying highp vec4 vCurrentPosition;
- varying highp vec4 vPreviousPosition;
- #endif
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$21] = shader$21;
- var name$20 = "oitDeclaration"
- , shader$20 = `#ifdef ORDER_INDEPENDENT_TRANSPARENCY
- #extension GL_EXT_draw_buffers : require
- layout(location=0) out vec2 depth;
- layout(location=1) out vec4 frontColor;
- layout(location=2) out vec4 backColor;
- #define MAX_DEPTH 99999.0
- highp vec4 gl_FragColor;
- uniform sampler2D oitDepthSampler;
- uniform sampler2D oitFrontColorSampler;
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$20] = shader$20;
- var name$1$ = "mainUVVaryingDeclaration"
- , shader$1$ = `#ifdef MAINUV{X}
- varying vec2 vMainUV{X};
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$1$] = shader$1$;
- var name$1_ = "lightFragmentDeclaration"
- , shader$1_ = `#ifdef LIGHT{X}
- uniform vec4 vLightData{X};
- uniform vec4 vLightDiffuse{X};
- #ifdef SPECULARTERM
- uniform vec4 vLightSpecular{X};
- #else
- vec4 vLightSpecular{X}=vec4(0.);
- #endif
- #ifdef SHADOW{X}
- #ifdef SHADOWCSM{X}
- uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];
- uniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];
- uniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];
- uniform float cascadeBlendFactor{X};
- varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];
- varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];
- varying vec4 vPositionFromCamera{X};
- #if defined(SHADOWPCSS{X})
- uniform highp sampler2DArrayShadow shadowSampler{X};
- uniform highp sampler2DArray depthSampler{X};
- uniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];
- uniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];
- uniform float penumbraDarkness{X};
- #elif defined(SHADOWPCF{X})
- uniform highp sampler2DArrayShadow shadowSampler{X};
- #else
- uniform highp sampler2DArray shadowSampler{X};
- #endif
- #ifdef SHADOWCSMDEBUG{X}
- const vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]
- (
- vec3 ( 1.5,0.0,0.0 ),
- vec3 ( 0.0,1.5,0.0 ),
- vec3 ( 0.0,0.0,5.5 ),
- vec3 ( 1.5,0.0,5.5 ),
- vec3 ( 1.5,1.5,0.0 ),
- vec3 ( 1.0,1.0,1.0 ),
- vec3 ( 0.0,1.0,5.5 ),
- vec3 ( 0.5,3.5,0.75 )
- );
- vec3 shadowDebug{X};
- #endif
- #ifdef SHADOWCSMUSESHADOWMAXZ{X}
- int index{X}=-1;
- #else
- int index{X}=SHADOWCSMNUM_CASCADES{X}-1;
- #endif
- float diff{X}=0.;
- #elif defined(SHADOWCUBE{X})
- uniform samplerCube shadowSampler{X};
- #else
- varying vec4 vPositionFromLight{X};
- varying float vDepthMetric{X};
- #if defined(SHADOWPCSS{X})
- uniform highp sampler2DShadow shadowSampler{X};
- uniform highp sampler2D depthSampler{X};
- #elif defined(SHADOWPCF{X})
- uniform highp sampler2DShadow shadowSampler{X};
- #else
- uniform sampler2D shadowSampler{X};
- #endif
- uniform mat4 lightMatrix{X};
- #endif
- uniform vec4 shadowsInfo{X};
- uniform vec2 depthValues{X};
- #endif
- #ifdef SPOTLIGHT{X}
- uniform vec4 vLightDirection{X};
- uniform vec4 vLightFalloff{X};
- #elif defined(POINTLIGHT{X})
- uniform vec4 vLightFalloff{X};
- #elif defined(HEMILIGHT{X})
- uniform vec3 vLightGround{X};
- #endif
- #ifdef PROJECTEDLIGHTTEXTURE{X}
- uniform mat4 textureProjectionMatrix{X};
- uniform sampler2D projectionLightSampler{X};
- #endif
- #endif`;
- ShaderStore.IncludesShadersStore[name$1_] = shader$1_;
- var name$1Z = "lightUboDeclaration"
- , shader$1Z = `#ifdef LIGHT{X}
- uniform Light{X}
- {
- vec4 vLightData;
- vec4 vLightDiffuse;
- vec4 vLightSpecular;
- #ifdef SPOTLIGHT{X}
- vec4 vLightDirection;
- vec4 vLightFalloff;
- #elif defined(POINTLIGHT{X})
- vec4 vLightFalloff;
- #elif defined(HEMILIGHT{X})
- vec3 vLightGround;
- #endif
- vec4 shadowsInfo;
- vec2 depthValues;
- } light{X};
- #ifdef PROJECTEDLIGHTTEXTURE{X}
- uniform mat4 textureProjectionMatrix{X};
- uniform sampler2D projectionLightSampler{X};
- #endif
- #ifdef SHADOW{X}
- #ifdef SHADOWCSM{X}
- uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];
- uniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];
- uniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];
- uniform float cascadeBlendFactor{X};
- varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];
- varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];
- varying vec4 vPositionFromCamera{X};
- #if defined(SHADOWPCSS{X})
- uniform highp sampler2DArrayShadow shadowSampler{X};
- uniform highp sampler2DArray depthSampler{X};
- uniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];
- uniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];
- uniform float penumbraDarkness{X};
- #elif defined(SHADOWPCF{X})
- uniform highp sampler2DArrayShadow shadowSampler{X};
- #else
- uniform highp sampler2DArray shadowSampler{X};
- #endif
- #ifdef SHADOWCSMDEBUG{X}
- const vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]
- (
- vec3 ( 1.5,0.0,0.0 ),
- vec3 ( 0.0,1.5,0.0 ),
- vec3 ( 0.0,0.0,5.5 ),
- vec3 ( 1.5,0.0,5.5 ),
- vec3 ( 1.5,1.5,0.0 ),
- vec3 ( 1.0,1.0,1.0 ),
- vec3 ( 0.0,1.0,5.5 ),
- vec3 ( 0.5,3.5,0.75 )
- );
- vec3 shadowDebug{X};
- #endif
- #ifdef SHADOWCSMUSESHADOWMAXZ{X}
- int index{X}=-1;
- #else
- int index{X}=SHADOWCSMNUM_CASCADES{X}-1;
- #endif
- float diff{X}=0.;
- #elif defined(SHADOWCUBE{X})
- uniform samplerCube shadowSampler{X};
- #else
- varying vec4 vPositionFromLight{X};
- varying float vDepthMetric{X};
- #if defined(SHADOWPCSS{X})
- uniform highp sampler2DShadow shadowSampler{X};
- uniform highp sampler2D depthSampler{X};
- #elif defined(SHADOWPCF{X})
- uniform highp sampler2DShadow shadowSampler{X};
- #else
- uniform sampler2D shadowSampler{X};
- #endif
- uniform mat4 lightMatrix{X};
- #endif
- #endif
- #endif`;
- ShaderStore.IncludesShadersStore[name$1Z] = shader$1Z;
- var name$1Y = "lightsFragmentFunctions"
- , shader$1Y = `
- struct lightingInfo
- {
- vec3 diffuse;
- #ifdef SPECULARTERM
- vec3 specular;
- #endif
- #ifdef NDOTL
- float ndl;
- #endif
- };
- lightingInfo computeLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {
- lightingInfo result;
- vec3 lightVectorW;
- float attenuation=1.0;
- if (lightData.w == 0.)
- {
- vec3 direction=lightData.xyz-vPositionW;
- attenuation=max(0.,1.0-length(direction)/range);
- lightVectorW=normalize(direction);
- }
- else
- {
- lightVectorW=normalize(-lightData.xyz);
- }
- float ndl=max(0.,dot(vNormal,lightVectorW));
- #ifdef NDOTL
- result.ndl=ndl;
- #endif
- result.diffuse=ndl*diffuseColor*attenuation;
- #ifdef SPECULARTERM
- vec3 angleW=normalize(viewDirectionW+lightVectorW);
- float specComp=max(0.,dot(vNormal,angleW));
- specComp=pow(specComp,max(1.,glossiness));
- result.specular=specComp*specularColor*attenuation;
- #endif
- return result;
- }
- lightingInfo computeSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {
- lightingInfo result;
- vec3 direction=lightData.xyz-vPositionW;
- vec3 lightVectorW=normalize(direction);
- float attenuation=max(0.,1.0-length(direction)/range);
- float cosAngle=max(0.,dot(lightDirection.xyz,-lightVectorW));
- if (cosAngle>=lightDirection.w)
- {
- cosAngle=max(0.,pow(cosAngle,lightData.w));
- attenuation*=cosAngle;
- float ndl=max(0.,dot(vNormal,lightVectorW));
- #ifdef NDOTL
- result.ndl=ndl;
- #endif
- result.diffuse=ndl*diffuseColor*attenuation;
- #ifdef SPECULARTERM
- vec3 angleW=normalize(viewDirectionW+lightVectorW);
- float specComp=max(0.,dot(vNormal,angleW));
- specComp=pow(specComp,max(1.,glossiness));
- result.specular=specComp*specularColor*attenuation;
- #endif
- return result;
- }
- result.diffuse=vec3(0.);
- #ifdef SPECULARTERM
- result.specular=vec3(0.);
- #endif
- #ifdef NDOTL
- result.ndl=0.;
- #endif
- return result;
- }
- lightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float glossiness) {
- lightingInfo result;
- float ndl=dot(vNormal,lightData.xyz)*0.5+0.5;
- #ifdef NDOTL
- result.ndl=ndl;
- #endif
- result.diffuse=mix(groundColor,diffuseColor,ndl);
- #ifdef SPECULARTERM
- vec3 angleW=normalize(viewDirectionW+lightData.xyz);
- float specComp=max(0.,dot(vNormal,angleW));
- specComp=pow(specComp,max(1.,glossiness));
- result.specular=specComp*specularColor;
- #endif
- return result;
- }
- #define inline
- vec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){
- vec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);
- strq/=strq.w;
- vec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;
- return textureColor;
- }`;
- ShaderStore.IncludesShadersStore[name$1Y] = shader$1Y;
- var name$1X = "shadowsFragmentFunctions"
- , shader$1X = `#ifdef SHADOWS
- #ifndef SHADOWFLOAT
- float unpack(vec4 color)
- {
- 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);
- return dot(color,bit_shift);
- }
- #endif
- float computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)
- {
- float mask=smoothstep(1.0-frustumEdgeFalloff,1.00000012,clamp(dot(clipSpace,clipSpace),0.,1.));
- return mix(value,1.0,mask);
- }
- #define inline
- float computeShadowCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues)
- {
- vec3 directionToLight=vPositionW-lightPosition;
- float depth=length(directionToLight);
- depth=(depth+depthValues.x)/(depthValues.y);
- depth=clamp(depth,0.,1.0);
- directionToLight=normalize(directionToLight);
- directionToLight.y=-directionToLight.y;
- #ifndef SHADOWFLOAT
- float shadow=unpack(textureCube(shadowSampler,directionToLight));
- #else
- float shadow=textureCube(shadowSampler,directionToLight).x;
- #endif
- return depth>shadow ? darkness : 1.0;
- }
- #define inline
- float computeShadowWithPoissonSamplingCube(vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues)
- {
- vec3 directionToLight=vPositionW-lightPosition;
- float depth=length(directionToLight);
- depth=(depth+depthValues.x)/(depthValues.y);
- depth=clamp(depth,0.,1.0);
- directionToLight=normalize(directionToLight);
- directionToLight.y=-directionToLight.y;
- float visibility=1.;
- vec3 poissonDisk[4];
- poissonDisk[0]=vec3(-1.0,1.0,-1.0);
- poissonDisk[1]=vec3(1.0,-1.0,-1.0);
- poissonDisk[2]=vec3(-1.0,-1.0,-1.0);
- poissonDisk[3]=vec3(1.0,-1.0,1.0);
- #ifndef SHADOWFLOAT
- if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))<depth) visibility-=0.25;
- if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize))<depth) visibility-=0.25;
- if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize))<depth) visibility-=0.25;
- if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize))<depth) visibility-=0.25;
- #else
- if (textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize).x<depth) visibility-=0.25;
- if (textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize).x<depth) visibility-=0.25;
- if (textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize).x<depth) visibility-=0.25;
- if (textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize).x<depth) visibility-=0.25;
- #endif
- return min(1.0,visibility+darkness);
- }
- #define inline
- float computeShadowWithESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)
- {
- vec3 directionToLight=vPositionW-lightPosition;
- float depth=length(directionToLight);
- depth=(depth+depthValues.x)/(depthValues.y);
- float shadowPixelDepth=clamp(depth,0.,1.0);
- directionToLight=normalize(directionToLight);
- directionToLight.y=-directionToLight.y;
- #ifndef SHADOWFLOAT
- float shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));
- #else
- float shadowMapSample=textureCube(shadowSampler,directionToLight).x;
- #endif
- float esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);
- return esm;
- }
- #define inline
- float computeShadowWithCloseESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)
- {
- vec3 directionToLight=vPositionW-lightPosition;
- float depth=length(directionToLight);
- depth=(depth+depthValues.x)/(depthValues.y);
- float shadowPixelDepth=clamp(depth,0.,1.0);
- directionToLight=normalize(directionToLight);
- directionToLight.y=-directionToLight.y;
- #ifndef SHADOWFLOAT
- float shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));
- #else
- float shadowMapSample=textureCube(shadowSampler,directionToLight).x;
- #endif
- float esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);
- return esm;
- }
- #if defined(WEBGL2) || defined(WEBGPU)
- #define inline
- float computeShadowCSM(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray shadowSampler,float darkness,float frustumEdgeFalloff)
- {
- vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
- vec2 uv=0.5*clipSpace.xy+vec2(0.5);
- vec3 uvLayer=vec3(uv.x,uv.y,layer);
- float shadowPixelDepth=clamp(depthMetric,0.,1.0);
- #ifndef SHADOWFLOAT
- float shadow=unpack(texture2D(shadowSampler,uvLayer));
- #else
- float shadow=texture2D(shadowSampler,uvLayer).x;
- #endif
- return shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;
- }
- #endif
- #define inline
- float computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff)
- {
- vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
- vec2 uv=0.5*clipSpace.xy+vec2(0.5);
- if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
- {
- return 1.0;
- }
- else
- {
- float shadowPixelDepth=clamp(depthMetric,0.,1.0);
- #ifndef SHADOWFLOAT
- float shadow=unpack(texture2D(shadowSampler,uv));
- #else
- float shadow=texture2D(shadowSampler,uv).x;
- #endif
- return shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;
- }
- }
- #define inline
- float computeShadowWithPoissonSampling(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)
- {
- vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
- vec2 uv=0.5*clipSpace.xy+vec2(0.5);
- if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
- {
- return 1.0;
- }
- else
- {
- float shadowPixelDepth=clamp(depthMetric,0.,1.0);
- float visibility=1.;
- vec2 poissonDisk[4];
- poissonDisk[0]=vec2(-0.94201624,-0.39906216);
- poissonDisk[1]=vec2(0.94558609,-0.76890725);
- poissonDisk[2]=vec2(-0.094184101,-0.92938870);
- poissonDisk[3]=vec2(0.34495938,0.29387760);
- #ifndef SHADOWFLOAT
- if (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))<shadowPixelDepth) visibility-=0.25;
- if (unpack(texture2D(shadowSampler,uv+poissonDisk[1]*mapSize))<shadowPixelDepth) visibility-=0.25;
- if (unpack(texture2D(shadowSampler,uv+poissonDisk[2]*mapSize))<shadowPixelDepth) visibility-=0.25;
- if (unpack(texture2D(shadowSampler,uv+poissonDisk[3]*mapSize))<shadowPixelDepth) visibility-=0.25;
- #else
- if (texture2D(shadowSampler,uv+poissonDisk[0]*mapSize).x<shadowPixelDepth) visibility-=0.25;
- if (texture2D(shadowSampler,uv+poissonDisk[1]*mapSize).x<shadowPixelDepth) visibility-=0.25;
- if (texture2D(shadowSampler,uv+poissonDisk[2]*mapSize).x<shadowPixelDepth) visibility-=0.25;
- if (texture2D(shadowSampler,uv+poissonDisk[3]*mapSize).x<shadowPixelDepth) visibility-=0.25;
- #endif
- return computeFallOff(min(1.0,visibility+darkness),clipSpace.xy,frustumEdgeFalloff);
- }
- }
- #define inline
- float computeShadowWithESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)
- {
- vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
- vec2 uv=0.5*clipSpace.xy+vec2(0.5);
- if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
- {
- return 1.0;
- }
- else
- {
- float shadowPixelDepth=clamp(depthMetric,0.,1.0);
- #ifndef SHADOWFLOAT
- float shadowMapSample=unpack(texture2D(shadowSampler,uv));
- #else
- float shadowMapSample=texture2D(shadowSampler,uv).x;
- #endif
- float esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);
- return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);
- }
- }
- #define inline
- float computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)
- {
- vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
- vec2 uv=0.5*clipSpace.xy+vec2(0.5);
- if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
- {
- return 1.0;
- }
- else
- {
- float shadowPixelDepth=clamp(depthMetric,0.,1.0);
- #ifndef SHADOWFLOAT
- float shadowMapSample=unpack(texture2D(shadowSampler,uv));
- #else
- float shadowMapSample=texture2D(shadowSampler,uv).x;
- #endif
- float esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);
- return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);
- }
- }
- #ifdef IS_NDC_HALF_ZRANGE
- #define ZINCLIP clipSpace.z
- #else
- #define ZINCLIP uvDepth.z
- #endif
- #if defined(WEBGL2) || defined(WEBGPU)
- #define GREATEST_LESS_THAN_ONE 0.99999994
- #define inline
- float computeShadowWithCSMPCF1(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,float darkness,float frustumEdgeFalloff)
- {
- vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
- vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
- uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);
- vec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);
- float shadow=texture2D(shadowSampler,uvDepthLayer);
- shadow=mix(darkness,1.,shadow);
- return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);
- }
- #define inline
- float computeShadowWithCSMPCF3(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
- {
- vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
- vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
- uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);
- vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;
- uv+=0.5;
- vec2 st=fract(uv);
- vec2 base_uv=floor(uv)-0.5;
- base_uv*=shadowMapSizeAndInverse.y;
- vec2 uvw0=3.-2.*st;
- vec2 uvw1=1.+2.*st;
- vec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;
- vec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;
- float shadow=0.;
- shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));
- shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));
- shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));
- shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));
- shadow=shadow/16.;
- shadow=mix(darkness,1.,shadow);
- return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);
- }
- #define inline
- float computeShadowWithCSMPCF5(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
- {
- vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
- vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
- uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);
- vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;
- uv+=0.5;
- vec2 st=fract(uv);
- vec2 base_uv=floor(uv)-0.5;
- base_uv*=shadowMapSizeAndInverse.y;
- vec2 uvw0=4.-3.*st;
- vec2 uvw1=vec2(7.);
- vec2 uvw2=1.+3.*st;
- vec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;
- vec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;
- float shadow=0.;
- shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));
- shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));
- shadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[0]),layer,uvDepth.z));
- shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));
- shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));
- shadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[1]),layer,uvDepth.z));
- shadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[2]),layer,uvDepth.z));
- shadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[2]),layer,uvDepth.z));
- shadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[2]),layer,uvDepth.z));
- shadow=shadow/144.;
- shadow=mix(darkness,1.,shadow);
- return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);
- }
- #define inline
- float computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff)
- {
- if (depthMetric>1.0 || depthMetric<0.0) {
- return 1.0;
- }
- else
- {
- vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
- vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
- uvDepth.z=ZINCLIP;
- float shadow=texture2D(shadowSampler,uvDepth);
- shadow=mix(darkness,1.,shadow);
- return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);
- }
- }
- #define inline
- float computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
- {
- if (depthMetric>1.0 || depthMetric<0.0) {
- return 1.0;
- }
- else
- {
- vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
- vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
- uvDepth.z=ZINCLIP;
- vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;
- uv+=0.5;
- vec2 st=fract(uv);
- vec2 base_uv=floor(uv)-0.5;
- base_uv*=shadowMapSizeAndInverse.y;
- vec2 uvw0=3.-2.*st;
- vec2 uvw1=1.+2.*st;
- vec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;
- vec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;
- float shadow=0.;
- shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));
- shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));
- shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));
- shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));
- shadow=shadow/16.;
- shadow=mix(darkness,1.,shadow);
- return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);
- }
- }
- #define inline
- float computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)
- {
- if (depthMetric>1.0 || depthMetric<0.0) {
- return 1.0;
- }
- else
- {
- vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
- vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
- uvDepth.z=ZINCLIP;
- vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;
- uv+=0.5;
- vec2 st=fract(uv);
- vec2 base_uv=floor(uv)-0.5;
- base_uv*=shadowMapSizeAndInverse.y;
- vec2 uvw0=4.-3.*st;
- vec2 uvw1=vec2(7.);
- vec2 uvw2=1.+3.*st;
- vec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;
- vec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;
- float shadow=0.;
- shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));
- shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));
- shadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[0]),uvDepth.z));
- shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));
- shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));
- shadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[1]),uvDepth.z));
- shadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[2]),uvDepth.z));
- shadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[2]),uvDepth.z));
- shadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[2]),uvDepth.z));
- shadow=shadow/144.;
- shadow=mix(darkness,1.,shadow);
- return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);
- }
- }
- const vec3 PoissonSamplers32[64]=vec3[64](
- vec3(0.06407013,0.05409927,0.),
- vec3(0.7366577,0.5789394,0.),
- vec3(-0.6270542,-0.5320278,0.),
- vec3(-0.4096107,0.8411095,0.),
- vec3(0.6849564,-0.4990818,0.),
- vec3(-0.874181,-0.04579735,0.),
- vec3(0.9989998,0.0009880066,0.),
- vec3(-0.004920578,-0.9151649,0.),
- vec3(0.1805763,0.9747483,0.),
- vec3(-0.2138451,0.2635818,0.),
- vec3(0.109845,0.3884785,0.),
- vec3(0.06876755,-0.3581074,0.),
- vec3(0.374073,-0.7661266,0.),
- vec3(0.3079132,-0.1216763,0.),
- vec3(-0.3794335,-0.8271583,0.),
- vec3(-0.203878,-0.07715034,0.),
- vec3(0.5912697,0.1469799,0.),
- vec3(-0.88069,0.3031784,0.),
- vec3(0.5040108,0.8283722,0.),
- vec3(-0.5844124,0.5494877,0.),
- vec3(0.6017799,-0.1726654,0.),
- vec3(-0.5554981,0.1559997,0.),
- vec3(-0.3016369,-0.3900928,0.),
- vec3(-0.5550632,-0.1723762,0.),
- vec3(0.925029,0.2995041,0.),
- vec3(-0.2473137,0.5538505,0.),
- vec3(0.9183037,-0.2862392,0.),
- vec3(0.2469421,0.6718712,0.),
- vec3(0.3916397,-0.4328209,0.),
- vec3(-0.03576927,-0.6220032,0.),
- vec3(-0.04661255,0.7995201,0.),
- vec3(0.4402924,0.3640312,0.),
- vec3(0.,0.,0.),
- vec3(0.,0.,0.),
- vec3(0.,0.,0.),
- vec3(0.,0.,0.),
- vec3(0.,0.,0.),
- vec3(0.,0.,0.),
- vec3(0.,0.,0.),
- vec3(0.,0.,0.),
- vec3(0.,0.,0.),
- vec3(0.,0.,0.),
- vec3(0.,0.,0.),
- vec3(0.,0.,0.),
- vec3(0.,0.,0.),
- vec3(0.,0.,0.),
- vec3(0.,0.,0.),
- vec3(0.,0.,0.),
- vec3(0.,0.,0.),
- vec3(0.,0.,0.),
- vec3(0.,0.,0.),
- vec3(0.,0.,0.),
- vec3(0.,0.,0.),
- vec3(0.,0.,0.),
- vec3(0.,0.,0.),
- vec3(0.,0.,0.),
- vec3(0.,0.,0.),
- vec3(0.,0.,0.),
- vec3(0.,0.,0.),
- vec3(0.,0.,0.),
- vec3(0.,0.,0.),
- vec3(0.,0.,0.),
- vec3(0.,0.,0.),
- vec3(0.,0.,0.)
- );
- const vec3 PoissonSamplers64[64]=vec3[64](
- vec3(-0.613392,0.617481,0.),
- vec3(0.170019,-0.040254,0.),
- vec3(-0.299417,0.791925,0.),
- vec3(0.645680,0.493210,0.),
- vec3(-0.651784,0.717887,0.),
- vec3(0.421003,0.027070,0.),
- vec3(-0.817194,-0.271096,0.),
- vec3(-0.705374,-0.668203,0.),
- vec3(0.977050,-0.108615,0.),
- vec3(0.063326,0.142369,0.),
- vec3(0.203528,0.214331,0.),
- vec3(-0.667531,0.326090,0.),
- vec3(-0.098422,-0.295755,0.),
- vec3(-0.885922,0.215369,0.),
- vec3(0.566637,0.605213,0.),
- vec3(0.039766,-0.396100,0.),
- vec3(0.751946,0.453352,0.),
- vec3(0.078707,-0.715323,0.),
- vec3(-0.075838,-0.529344,0.),
- vec3(0.724479,-0.580798,0.),
- vec3(0.222999,-0.215125,0.),
- vec3(-0.467574,-0.405438,0.),
- vec3(-0.248268,-0.814753,0.),
- vec3(0.354411,-0.887570,0.),
- vec3(0.175817,0.382366,0.),
- vec3(0.487472,-0.063082,0.),
- vec3(-0.084078,0.898312,0.),
- vec3(0.488876,-0.783441,0.),
- vec3(0.470016,0.217933,0.),
- vec3(-0.696890,-0.549791,0.),
- vec3(-0.149693,0.605762,0.),
- vec3(0.034211,0.979980,0.),
- vec3(0.503098,-0.308878,0.),
- vec3(-0.016205,-0.872921,0.),
- vec3(0.385784,-0.393902,0.),
- vec3(-0.146886,-0.859249,0.),
- vec3(0.643361,0.164098,0.),
- vec3(0.634388,-0.049471,0.),
- vec3(-0.688894,0.007843,0.),
- vec3(0.464034,-0.188818,0.),
- vec3(-0.440840,0.137486,0.),
- vec3(0.364483,0.511704,0.),
- vec3(0.034028,0.325968,0.),
- vec3(0.099094,-0.308023,0.),
- vec3(0.693960,-0.366253,0.),
- vec3(0.678884,-0.204688,0.),
- vec3(0.001801,0.780328,0.),
- vec3(0.145177,-0.898984,0.),
- vec3(0.062655,-0.611866,0.),
- vec3(0.315226,-0.604297,0.),
- vec3(-0.780145,0.486251,0.),
- vec3(-0.371868,0.882138,0.),
- vec3(0.200476,0.494430,0.),
- vec3(-0.494552,-0.711051,0.),
- vec3(0.612476,0.705252,0.),
- vec3(-0.578845,-0.768792,0.),
- vec3(-0.772454,-0.090976,0.),
- vec3(0.504440,0.372295,0.),
- vec3(0.155736,0.065157,0.),
- vec3(0.391522,0.849605,0.),
- vec3(-0.620106,-0.328104,0.),
- vec3(0.789239,-0.419965,0.),
- vec3(-0.545396,0.538133,0.),
- vec3(-0.178564,-0.596057,0.)
- );
- #define inline
- 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)
- {
- vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
- vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
- uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE);
- vec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);
- float blockerDepth=0.0;
- float sumBlockerDepth=0.0;
- float numBlocker=0.0;
- for (int i=0; i<searchTapCount; i ++) {
- blockerDepth=texture2D(depthSampler,vec3(uvDepth.xy+(lightSizeUV*lightSizeUVCorrection*shadowMapSizeInverse*PoissonSamplers32[i].xy),layer)).r;
- if (blockerDepth<depthMetric) {
- sumBlockerDepth+=blockerDepth;
- numBlocker++;
- }
- }
- if (numBlocker<1.0) {
- return 1.0;
- }
- else
- {
- float avgBlockerDepth=sumBlockerDepth/numBlocker;
- float AAOffset=shadowMapSizeInverse*10.;
- float penumbraRatio=((depthMetric-avgBlockerDepth)*depthCorrection+AAOffset);
- vec4 filterRadius=vec4(penumbraRatio*lightSizeUV*lightSizeUVCorrection*shadowMapSizeInverse,0.,0.);
- float random=getRand(vPositionFromLight.xy);
- float rotationAngle=random*3.1415926;
- vec2 rotationVector=vec2(cos(rotationAngle),sin(rotationAngle));
- float shadow=0.;
- for (int i=0; i<pcfTapCount; i++) {
- vec4 offset=vec4(poissonSamplers[i],0.);
- offset=vec4(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.,0.);
- shadow+=texture2D(shadowSampler,uvDepthLayer+offset*filterRadius);
- }
- shadow/=float(pcfTapCount);
- shadow=mix(shadow,1.,min((depthMetric-avgBlockerDepth)*depthCorrection*penumbraDarkness,1.));
- shadow=mix(darkness,1.,shadow);
- return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);
- }
- }
- #define inline
- 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)
- {
- if (depthMetric>1.0 || depthMetric<0.0) {
- return 1.0;
- }
- else
- {
- vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;
- vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
- uvDepth.z=ZINCLIP;
- float blockerDepth=0.0;
- float sumBlockerDepth=0.0;
- float numBlocker=0.0;
- for (int i=0; i<searchTapCount; i ++) {
- blockerDepth=texture2D(depthSampler,uvDepth.xy+(lightSizeUV*shadowMapSizeInverse*PoissonSamplers32[i].xy)).r;
- if (blockerDepth<depthMetric) {
- sumBlockerDepth+=blockerDepth;
- numBlocker++;
- }
- }
- if (numBlocker<1.0) {
- return 1.0;
- }
- else
- {
- float avgBlockerDepth=sumBlockerDepth/numBlocker;
- float AAOffset=shadowMapSizeInverse*10.;
- float penumbraRatio=((depthMetric-avgBlockerDepth)+AAOffset);
- float filterRadius=penumbraRatio*lightSizeUV*shadowMapSizeInverse;
- float random=getRand(vPositionFromLight.xy);
- float rotationAngle=random*3.1415926;
- vec2 rotationVector=vec2(cos(rotationAngle),sin(rotationAngle));
- float shadow=0.;
- for (int i=0; i<pcfTapCount; i++) {
- vec3 offset=poissonSamplers[i];
- offset=vec3(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.);
- shadow+=texture2D(shadowSampler,uvDepth+offset*filterRadius);
- }
- shadow/=float(pcfTapCount);
- shadow=mix(shadow,1.,depthMetric-avgBlockerDepth);
- shadow=mix(darkness,1.,shadow);
- return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);
- }
- }
- }
- #define inline
- float computeShadowWithPCSS16(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)
- {
- return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32);
- }
- #define inline
- float computeShadowWithPCSS32(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)
- {
- return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32);
- }
- #define inline
- float computeShadowWithPCSS64(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)
- {
- return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64);
- }
- #define inline
- 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)
- {
- return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);
- }
- #define inline
- 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)
- {
- return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);
- }
- #define inline
- 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)
- {
- return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64,lightSizeUVCorrection,depthCorrection,penumbraDarkness);
- }
- #endif
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$1X] = shader$1X;
- var name$1W = "samplerFragmentDeclaration"
- , shader$1W = `#ifdef _DEFINENAME_
- #if _DEFINENAME_DIRECTUV == 1
- #define v_VARYINGNAME_UV vMainUV1
- #elif _DEFINENAME_DIRECTUV == 2
- #define v_VARYINGNAME_UV vMainUV2
- #elif _DEFINENAME_DIRECTUV == 3
- #define v_VARYINGNAME_UV vMainUV3
- #elif _DEFINENAME_DIRECTUV == 4
- #define v_VARYINGNAME_UV vMainUV4
- #elif _DEFINENAME_DIRECTUV == 5
- #define v_VARYINGNAME_UV vMainUV5
- #elif _DEFINENAME_DIRECTUV == 6
- #define v_VARYINGNAME_UV vMainUV6
- #else
- varying vec2 v_VARYINGNAME_UV;
- #endif
- uniform sampler2D _SAMPLERNAME_Sampler;
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$1W] = shader$1W;
- var name$1V = "fresnelFunction"
- , shader$1V = `#ifdef FRESNEL
- float computeFresnelTerm(vec3 viewDirection,vec3 worldNormal,float bias,float power)
- {
- float fresnelTerm=pow(bias+abs(dot(viewDirection,worldNormal)),power);
- return clamp(fresnelTerm,0.,1.);
- }
- #endif`;
- ShaderStore.IncludesShadersStore[name$1V] = shader$1V;
- var name$1U = "reflectionFunction"
- , shader$1U = `vec3 computeFixedEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 direction)
- {
- float lon=atan(direction.z,direction.x);
- float lat=acos(direction.y);
- vec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;
- float s=sphereCoords.x*0.5+0.5;
- float t=sphereCoords.y;
- return vec3(s,t,0);
- }
- vec3 computeMirroredFixedEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 direction)
- {
- float lon=atan(direction.z,direction.x);
- float lat=acos(direction.y);
- vec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;
- float s=sphereCoords.x*0.5+0.5;
- float t=sphereCoords.y;
- return vec3(1.0-s,t,0);
- }
- vec3 computeEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix)
- {
- vec3 cameraToVertex=normalize(worldPos.xyz-eyePosition);
- vec3 r=normalize(reflect(cameraToVertex,worldNormal));
- r=vec3(reflectionMatrix*vec4(r,0));
- float lon=atan(r.z,r.x);
- float lat=acos(r.y);
- vec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;
- float s=sphereCoords.x*0.5+0.5;
- float t=sphereCoords.y;
- return vec3(s,t,0);
- }
- vec3 computeSphericalCoords(vec4 worldPos,vec3 worldNormal,mat4 view,mat4 reflectionMatrix)
- {
- vec3 viewDir=normalize(vec3(view*worldPos));
- vec3 viewNormal=normalize(vec3(view*vec4(worldNormal,0.0)));
- vec3 r=reflect(viewDir,viewNormal);
- r=vec3(reflectionMatrix*vec4(r,0));
- r.z=r.z-1.0;
- float m=2.0*length(r);
- return vec3(r.x/m+0.5,1.0-r.y/m-0.5,0);
- }
- vec3 computePlanarCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix)
- {
- vec3 viewDir=worldPos.xyz-eyePosition;
- vec3 coords=normalize(reflect(viewDir,worldNormal));
- return vec3(reflectionMatrix*vec4(coords,1));
- }
- vec3 computeCubicCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix)
- {
- vec3 viewDir=normalize(worldPos.xyz-eyePosition);
- vec3 coords=reflect(viewDir,worldNormal);
- coords=vec3(reflectionMatrix*vec4(coords,0));
- #ifdef INVERTCUBICMAP
- coords.y*=-1.0;
- #endif
- return coords;
- }
- vec3 computeCubicLocalCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix,vec3 reflectionSize,vec3 reflectionPosition)
- {
- vec3 viewDir=normalize(worldPos.xyz-eyePosition);
- vec3 coords=reflect(viewDir,worldNormal);
- coords=parallaxCorrectNormal(worldPos.xyz,coords,reflectionSize,reflectionPosition);
- coords=vec3(reflectionMatrix*vec4(coords,0));
- #ifdef INVERTCUBICMAP
- coords.y*=-1.0;
- #endif
- return coords;
- }
- vec3 computeProjectionCoords(vec4 worldPos,mat4 view,mat4 reflectionMatrix)
- {
- return vec3(reflectionMatrix*(view*worldPos));
- }
- vec3 computeSkyBoxCoords(vec3 positionW,mat4 reflectionMatrix)
- {
- return vec3(reflectionMatrix*vec4(positionW,1.));
- }
- #ifdef REFLECTION
- vec3 computeReflectionCoords(vec4 worldPos,vec3 worldNormal)
- {
- #ifdef REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED
- vec3 direction=normalize(vDirectionW);
- return computeMirroredFixedEquirectangularCoords(worldPos,worldNormal,direction);
- #endif
- #ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED
- vec3 direction=normalize(vDirectionW);
- return computeFixedEquirectangularCoords(worldPos,worldNormal,direction);
- #endif
- #ifdef REFLECTIONMAP_EQUIRECTANGULAR
- return computeEquirectangularCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix);
- #endif
- #ifdef REFLECTIONMAP_SPHERICAL
- return computeSphericalCoords(worldPos,worldNormal,view,reflectionMatrix);
- #endif
- #ifdef REFLECTIONMAP_PLANAR
- return computePlanarCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix);
- #endif
- #ifdef REFLECTIONMAP_CUBIC
- #ifdef USE_LOCAL_REFLECTIONMAP_CUBIC
- return computeCubicLocalCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix,vReflectionSize,vReflectionPosition);
- #else
- return computeCubicCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix);
- #endif
- #endif
- #ifdef REFLECTIONMAP_PROJECTION
- return computeProjectionCoords(worldPos,view,reflectionMatrix);
- #endif
- #ifdef REFLECTIONMAP_SKYBOX
- return computeSkyBoxCoords(vPositionUVW,reflectionMatrix);
- #endif
- #ifdef REFLECTIONMAP_EXPLICIT
- return vec3(0,0,0);
- #endif
- }
- #endif`;
- ShaderStore.IncludesShadersStore[name$1U] = shader$1U;
- var name$1T = "imageProcessingDeclaration"
- , shader$1T = `#ifdef EXPOSURE
- uniform float exposureLinear;
- #endif
- #ifdef CONTRAST
- uniform float contrast;
- #endif
- #ifdef VIGNETTE
- uniform vec2 vInverseScreenSize;
- uniform vec4 vignetteSettings1;
- uniform vec4 vignetteSettings2;
- #endif
- #ifdef COLORCURVES
- uniform vec4 vCameraColorCurveNegative;
- uniform vec4 vCameraColorCurveNeutral;
- uniform vec4 vCameraColorCurvePositive;
- #endif
- #ifdef COLORGRADING
- #ifdef COLORGRADING3D
- uniform highp sampler3D txColorTransform;
- #else
- uniform sampler2D txColorTransform;
- #endif
- uniform vec4 colorTransformSettings;
- #endif`;
- ShaderStore.IncludesShadersStore[name$1T] = shader$1T;
- var name$1S = "imageProcessingFunctions"
- , shader$1S = `#if defined(COLORGRADING) && !defined(COLORGRADING3D)
- #define inline
- vec3 sampleTexture3D(sampler2D colorTransform,vec3 color,vec2 sampler3dSetting)
- {
- float sliceSize=2.0*sampler3dSetting.x;
- #ifdef SAMPLER3DGREENDEPTH
- float sliceContinuous=(color.g-sampler3dSetting.x)*sampler3dSetting.y;
- #else
- float sliceContinuous=(color.b-sampler3dSetting.x)*sampler3dSetting.y;
- #endif
- float sliceInteger=floor(sliceContinuous);
- float sliceFraction=sliceContinuous-sliceInteger;
- #ifdef SAMPLER3DGREENDEPTH
- vec2 sliceUV=color.rb;
- #else
- vec2 sliceUV=color.rg;
- #endif
- sliceUV.x*=sliceSize;
- sliceUV.x+=sliceInteger*sliceSize;
- sliceUV=saturate(sliceUV);
- vec4 slice0Color=texture2D(colorTransform,sliceUV);
- sliceUV.x+=sliceSize;
- sliceUV=saturate(sliceUV);
- vec4 slice1Color=texture2D(colorTransform,sliceUV);
- vec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction);
- #ifdef SAMPLER3DBGRMAP
- color.rgb=result.rgb;
- #else
- color.rgb=result.bgr;
- #endif
- return color;
- }
- #endif
- #ifdef TONEMAPPING_ACES
- const mat3 ACESInputMat=mat3(
- vec3(0.59719,0.07600,0.02840),
- vec3(0.35458,0.90834,0.13383),
- vec3(0.04823,0.01566,0.83777)
- );
- const mat3 ACESOutputMat=mat3(
- vec3( 1.60475,-0.10208,-0.00327),
- vec3(-0.53108,1.10813,-0.07276),
- vec3(-0.07367,-0.00605,1.07602)
- );
- vec3 RRTAndODTFit(vec3 v)
- {
- vec3 a=v*(v+0.0245786)-0.000090537;
- vec3 b=v*(0.983729*v+0.4329510)+0.238081;
- return a/b;
- }
- vec3 ACESFitted(vec3 color)
- {
- color=ACESInputMat*color;
- color=RRTAndODTFit(color);
- color=ACESOutputMat*color;
- color=saturate(color);
- return color;
- }
- #endif
- vec4 applyImageProcessing(vec4 result) {
- #ifdef EXPOSURE
- result.rgb*=exposureLinear;
- #endif
- #ifdef VIGNETTE
- vec2 viewportXY=gl_FragCoord.xy*vInverseScreenSize;
- viewportXY=viewportXY*2.0-1.0;
- vec3 vignetteXY1=vec3(viewportXY*vignetteSettings1.xy+vignetteSettings1.zw,1.0);
- float vignetteTerm=dot(vignetteXY1,vignetteXY1);
- float vignette=pow(vignetteTerm,vignetteSettings2.w);
- vec3 vignetteColor=vignetteSettings2.rgb;
- #ifdef VIGNETTEBLENDMODEMULTIPLY
- vec3 vignetteColorMultiplier=mix(vignetteColor,vec3(1,1,1),vignette);
- result.rgb*=vignetteColorMultiplier;
- #endif
- #ifdef VIGNETTEBLENDMODEOPAQUE
- result.rgb=mix(vignetteColor,result.rgb,vignette);
- #endif
- #endif
- #ifdef TONEMAPPING
- #ifdef TONEMAPPING_ACES
- result.rgb=ACESFitted(result.rgb);
- #else
- const float tonemappingCalibration=1.590579;
- result.rgb=1.0-exp2(-tonemappingCalibration*result.rgb);
- #endif
- #endif
- result.rgb=toGammaSpace(result.rgb);
- result.rgb=saturate(result.rgb);
- #ifdef CONTRAST
- vec3 resultHighContrast=result.rgb*result.rgb*(3.0-2.0*result.rgb);
- if (contrast<1.0) {
- result.rgb=mix(vec3(0.5,0.5,0.5),result.rgb,contrast);
- } else {
- result.rgb=mix(result.rgb,resultHighContrast,contrast-1.0);
- }
- #endif
- #ifdef COLORGRADING
- vec3 colorTransformInput=result.rgb*colorTransformSettings.xxx+colorTransformSettings.yyy;
- #ifdef COLORGRADING3D
- vec3 colorTransformOutput=texture(txColorTransform,colorTransformInput).rgb;
- #else
- vec3 colorTransformOutput=sampleTexture3D(txColorTransform,colorTransformInput,colorTransformSettings.yz).rgb;
- #endif
- result.rgb=mix(result.rgb,colorTransformOutput,colorTransformSettings.www);
- #endif
- #ifdef COLORCURVES
- float luma=getLuminance(result.rgb);
- vec2 curveMix=clamp(vec2(luma*3.0-1.5,luma*-3.0+1.5),vec2(0.0),vec2(1.0));
- vec4 colorCurve=vCameraColorCurveNeutral+curveMix.x*vCameraColorCurvePositive-curveMix.y*vCameraColorCurveNegative;
- result.rgb*=colorCurve.rgb;
- result.rgb=mix(vec3(luma),result.rgb,colorCurve.a);
- #endif
- return result;
- }`;
- ShaderStore.IncludesShadersStore[name$1S] = shader$1S;
- var name$1R = "bumpFragmentMainFunctions"
- , shader$1R = `#if defined(BUMP) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) || defined(DETAIL)
- #if defined(TANGENT) && defined(NORMAL)
- varying mat3 vTBN;
- #endif
- #ifdef OBJECTSPACE_NORMALMAP
- uniform mat4 normalMatrix;
- #endif
- vec3 perturbNormalBase(mat3 cotangentFrame,vec3 normal,float scale)
- {
- #ifdef NORMALXYSCALE
- normal=normalize(normal*vec3(scale,scale,1.0));
- #endif
- return normalize(cotangentFrame*normal);
- }
- vec3 perturbNormal(mat3 cotangentFrame,vec3 textureSample,float scale)
- {
- return perturbNormalBase(cotangentFrame,textureSample*2.0-1.0,scale);
- }
- mat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv,vec2 tangentSpaceParams)
- {
- vec3 dp1=dFdx(p);
- vec3 dp2=dFdy(p);
- vec2 duv1=dFdx(uv);
- vec2 duv2=dFdy(uv);
- vec3 dp2perp=cross(dp2,normal);
- vec3 dp1perp=cross(normal,dp1);
- vec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;
- vec3 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;
- tangent*=tangentSpaceParams.x;
- bitangent*=tangentSpaceParams.y;
- float invmax=inversesqrt(max(dot(tangent,tangent),dot(bitangent,bitangent)));
- return mat3(tangent*invmax,bitangent*invmax,normal);
- }
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$1R] = shader$1R;
- var name$1Q = "bumpFragmentFunctions"
- , shader$1Q = `#if defined(BUMP)
- #include<samplerFragmentDeclaration>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_SAMPLERNAME_,bump)
- #endif
- #if defined(DETAIL)
- #include<samplerFragmentDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_SAMPLERNAME_,detail)
- #endif
- #if defined(BUMP) && defined(PARALLAX)
- const float minSamples=4.;
- const float maxSamples=15.;
- const int iMaxSamples=15;
- vec2 parallaxOcclusion(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale) {
- float parallaxLimit=length(vViewDirCoT.xy)/vViewDirCoT.z;
- parallaxLimit*=parallaxScale;
- vec2 vOffsetDir=normalize(vViewDirCoT.xy);
- vec2 vMaxOffset=vOffsetDir*parallaxLimit;
- float numSamples=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));
- float stepSize=1.0/numSamples;
- float currRayHeight=1.0;
- vec2 vCurrOffset=vec2(0,0);
- vec2 vLastOffset=vec2(0,0);
- float lastSampledHeight=1.0;
- float currSampledHeight=1.0;
- for (int i=0; i<iMaxSamples; i++)
- {
- currSampledHeight=texture2D(bumpSampler,texCoord+vCurrOffset).w;
- if (currSampledHeight>currRayHeight)
- {
- float delta1=currSampledHeight-currRayHeight;
- float delta2=(currRayHeight+stepSize)-lastSampledHeight;
- float ratio=delta1/(delta1+delta2);
- vCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;
- break;
- }
- else
- {
- currRayHeight-=stepSize;
- vLastOffset=vCurrOffset;
- vCurrOffset+=stepSize*vMaxOffset;
- lastSampledHeight=currSampledHeight;
- }
- }
- return vCurrOffset;
- }
- vec2 parallaxOffset(vec3 viewDir,float heightScale)
- {
- float height=texture2D(bumpSampler,vBumpUV).w;
- vec2 texCoordOffset=heightScale*viewDir.xy*height;
- return -texCoordOffset;
- }
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$1Q] = shader$1Q;
- var name$1P = "logDepthDeclaration"
- , shader$1P = `#ifdef LOGARITHMICDEPTH
- uniform float logarithmicDepthConstant;
- varying float vFragmentDepth;
- #endif`;
- ShaderStore.IncludesShadersStore[name$1P] = shader$1P;
- var name$1O = "fogFragmentDeclaration"
- , shader$1O = `#ifdef FOG
- #define FOGMODE_NONE 0.
- #define FOGMODE_EXP 1.
- #define FOGMODE_EXP2 2.
- #define FOGMODE_LINEAR 3.
- #define E 2.71828
- uniform vec4 vFogInfos;
- uniform vec3 vFogColor;
- varying vec3 vFogDistance;
- float CalcFogFactor()
- {
- float fogCoeff=1.0;
- float fogStart=vFogInfos.y;
- float fogEnd=vFogInfos.z;
- float fogDensity=vFogInfos.w;
- float fogDistance=length(vFogDistance);
- if (FOGMODE_LINEAR == vFogInfos.x)
- {
- fogCoeff=(fogEnd-fogDistance)/(fogEnd-fogStart);
- }
- else if (FOGMODE_EXP == vFogInfos.x)
- {
- fogCoeff=1.0/pow(E,fogDistance*fogDensity);
- }
- else if (FOGMODE_EXP2 == vFogInfos.x)
- {
- fogCoeff=1.0/pow(E,fogDistance*fogDistance*fogDensity*fogDensity);
- }
- return clamp(fogCoeff,0.0,1.0);
- }
- #endif`;
- ShaderStore.IncludesShadersStore[name$1O] = shader$1O;
- var name$1N = "oitFragment"
- , shader$1N = `#ifdef ORDER_INDEPENDENT_TRANSPARENCY
- float fragDepth=gl_FragCoord.z;
- #ifdef ORDER_INDEPENDENT_TRANSPARENCY_16BITS
- uint halfFloat=packHalf2x16(vec2(fragDepth));
- vec2 full=unpackHalf2x16(halfFloat);
- fragDepth=full.x;
- #endif
- ivec2 fragCoord=ivec2(gl_FragCoord.xy);
- vec2 lastDepth=texelFetch(oitDepthSampler,fragCoord,0).rg;
- vec4 lastFrontColor=texelFetch(oitFrontColorSampler,fragCoord,0);
- depth.rg=vec2(-MAX_DEPTH);
- frontColor=lastFrontColor;
- backColor=vec4(0.0);
- #ifdef USE_REVERSE_DEPTHBUFFER
- float furthestDepth=-lastDepth.x;
- float nearestDepth=lastDepth.y;
- #else
- float nearestDepth=-lastDepth.x;
- float furthestDepth=lastDepth.y;
- #endif
- float alphaMultiplier=1.0-lastFrontColor.a;
- #ifdef USE_REVERSE_DEPTHBUFFER
- if (fragDepth>nearestDepth || fragDepth<furthestDepth) {
- #else
- if (fragDepth<nearestDepth || fragDepth>furthestDepth) {
- #endif
- return;
- }
- #ifdef USE_REVERSE_DEPTHBUFFER
- if (fragDepth<nearestDepth && fragDepth>furthestDepth) {
- #else
- if (fragDepth>nearestDepth && fragDepth<furthestDepth) {
- #endif
- depth.rg=vec2(-fragDepth,fragDepth);
- return;
- }
- #endif`;
- ShaderStore.IncludesShadersStore[name$1N] = shader$1N;
- var name$1M = "bumpFragment"
- , shader$1M = `vec2 uvOffset=vec2(0.0,0.0);
- #if defined(BUMP) || defined(PARALLAX) || defined(DETAIL)
- #ifdef NORMALXYSCALE
- float normalScale=1.0;
- #elif defined(BUMP)
- float normalScale=vBumpInfos.y;
- #else
- float normalScale=1.0;
- #endif
- #if defined(TANGENT) && defined(NORMAL)
- mat3 TBN=vTBN;
- #elif defined(BUMP)
- vec2 TBNUV=gl_FrontFacing ? vBumpUV : -vBumpUV;
- mat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,TBNUV,vTangentSpaceParams);
- #else
- vec2 TBNUV=gl_FrontFacing ? vDetailUV : -vDetailUV;
- mat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,TBNUV,vec2(1.,1.));
- #endif
- #elif defined(ANISOTROPIC)
- #if defined(TANGENT) && defined(NORMAL)
- mat3 TBN=vTBN;
- #else
- vec2 TBNUV=gl_FrontFacing ? vMainUV1 : -vMainUV1;
- mat3 TBN=cotangent_frame(normalW,vPositionW,TBNUV,vec2(1.,1.));
- #endif
- #endif
- #ifdef PARALLAX
- mat3 invTBN=transposeMat3(TBN);
- #ifdef PARALLAXOCCLUSION
- uvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,vBumpUV,vBumpInfos.z);
- #else
- uvOffset=parallaxOffset(invTBN*viewDirectionW,vBumpInfos.z);
- #endif
- #endif
- #ifdef DETAIL
- vec4 detailColor=texture2D(detailSampler,vDetailUV+uvOffset);
- vec2 detailNormalRG=detailColor.wy*2.0-1.0;
- float detailNormalB=sqrt(1.-saturate(dot(detailNormalRG,detailNormalRG)));
- vec3 detailNormal=vec3(detailNormalRG,detailNormalB);
- #endif
- #ifdef BUMP
- #ifdef OBJECTSPACE_NORMALMAP
- normalW=normalize(texture2D(bumpSampler,vBumpUV).xyz*2.0-1.0);
- normalW=normalize(mat3(normalMatrix)*normalW);
- #elif !defined(DETAIL)
- normalW=perturbNormal(TBN,texture2D(bumpSampler,vBumpUV+uvOffset).xyz,vBumpInfos.y);
- #else
- vec3 bumpNormal=texture2D(bumpSampler,vBumpUV+uvOffset).xyz*2.0-1.0;
- #if DETAIL_NORMALBLENDMETHOD == 0
- detailNormal.xy*=vDetailInfos.z;
- vec3 blendedNormal=normalize(vec3(bumpNormal.xy+detailNormal.xy,bumpNormal.z*detailNormal.z));
- #elif DETAIL_NORMALBLENDMETHOD == 1
- detailNormal.xy*=vDetailInfos.z;
- bumpNormal+=vec3(0.0,0.0,1.0);
- detailNormal*=vec3(-1.0,-1.0,1.0);
- vec3 blendedNormal=bumpNormal*dot(bumpNormal,detailNormal)/bumpNormal.z-detailNormal;
- #endif
- normalW=perturbNormalBase(TBN,blendedNormal,vBumpInfos.y);
- #endif
- #elif defined(DETAIL)
- detailNormal.xy*=vDetailInfos.z;
- normalW=perturbNormalBase(TBN,detailNormal,vDetailInfos.z);
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$1M] = shader$1M;
- var name$1L = "depthPrePass"
- , shader$1L = `#ifdef DEPTHPREPASS
- gl_FragColor=vec4(0.,0.,0.,1.0);
- return;
- #endif`;
- ShaderStore.IncludesShadersStore[name$1L] = shader$1L;
- var name$1K = "lightFragment"
- , shader$1K = `#ifdef LIGHT{X}
- #if defined(SHADOWONLY) || defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})
- #else
- #ifdef PBR
- #ifdef SPOTLIGHT{X}
- preInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);
- #elif defined(POINTLIGHT{X})
- preInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);
- #elif defined(HEMILIGHT{X})
- preInfo=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);
- #elif defined(DIRLIGHT{X})
- preInfo=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);
- #endif
- preInfo.NdotV=NdotV;
- #ifdef SPOTLIGHT{X}
- #ifdef LIGHT_FALLOFF_GLTF{X}
- preInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);
- preInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);
- #elif defined(LIGHT_FALLOFF_PHYSICAL{X})
- preInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);
- preInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w);
- #elif defined(LIGHT_FALLOFF_STANDARD{X})
- preInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);
- preInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w);
- #else
- preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);
- 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);
- #endif
- #elif defined(POINTLIGHT{X})
- #ifdef LIGHT_FALLOFF_GLTF{X}
- preInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);
- #elif defined(LIGHT_FALLOFF_PHYSICAL{X})
- preInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);
- #elif defined(LIGHT_FALLOFF_STANDARD{X})
- preInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);
- #else
- preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);
- #endif
- #else
- preInfo.attenuation=1.0;
- #endif
- #ifdef HEMILIGHT{X}
- preInfo.roughness=roughness;
- #else
- preInfo.roughness=adjustRoughnessFromLightProperties(roughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
- #endif
- #ifdef HEMILIGHT{X}
- info.diffuse=computeHemisphericDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb,light{X}.vLightGround);
- #elif defined(SS_TRANSLUCENCY)
- info.diffuse=computeDiffuseAndTransmittedLighting(preInfo,light{X}.vLightDiffuse.rgb,subSurfaceOut.transmittance);
- #else
- info.diffuse=computeDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb);
- #endif
- #ifdef SPECULARTERM
- #ifdef ANISOTROPIC
- info.specular=computeAnisotropicSpecularLighting(preInfo,viewDirectionW,normalW,anisotropicOut.anisotropicTangent,anisotropicOut.anisotropicBitangent,anisotropicOut.anisotropy,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);
- #else
- info.specular=computeSpecularLighting(preInfo,normalW,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);
- #endif
- #endif
- #ifdef SHEEN
- #ifdef SHEEN_LINKWITHALBEDO
- preInfo.roughness=sheenOut.sheenIntensity;
- #else
- #ifdef HEMILIGHT{X}
- preInfo.roughness=sheenOut.sheenRoughness;
- #else
- preInfo.roughness=adjustRoughnessFromLightProperties(sheenOut.sheenRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
- #endif
- #endif
- info.sheen=computeSheenLighting(preInfo,normalW,sheenOut.sheenColor,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);
- #endif
- #ifdef CLEARCOAT
- #ifdef HEMILIGHT{X}
- preInfo.roughness=clearcoatOut.clearCoatRoughness;
- #else
- preInfo.roughness=adjustRoughnessFromLightProperties(clearcoatOut.clearCoatRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
- #endif
- info.clearCoat=computeClearCoatLighting(preInfo,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatAARoughnessFactors.x,clearcoatOut.clearCoatIntensity,light{X}.vLightDiffuse.rgb);
- #ifdef CLEARCOAT_TINT
- absorption=computeClearCoatLightingAbsorption(clearcoatOut.clearCoatNdotVRefract,preInfo.L,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatColor,clearcoatOut.clearCoatThickness,clearcoatOut.clearCoatIntensity);
- info.diffuse*=absorption;
- #ifdef SPECULARTERM
- info.specular*=absorption;
- #endif
- #endif
- info.diffuse*=info.clearCoat.w;
- #ifdef SPECULARTERM
- info.specular*=info.clearCoat.w;
- #endif
- #ifdef SHEEN
- info.sheen*=info.clearCoat.w;
- #endif
- #endif
- #else
- #ifdef SPOTLIGHT{X}
- info=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightDiffuse.a,glossiness);
- #elif defined(HEMILIGHT{X})
- info=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightGround,glossiness);
- #elif defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})
- info=computeLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightDiffuse.a,glossiness);
- #endif
- #endif
- #ifdef PROJECTEDLIGHTTEXTURE{X}
- info.diffuse*=computeProjectionTextureDiffuseLighting(projectionLightSampler{X},textureProjectionMatrix{X});
- #endif
- #endif
- #ifdef SHADOW{X}
- #ifdef SHADOWCSM{X}
- for (int i=0; i<SHADOWCSMNUM_CASCADES{X}; i++)
- {
- #ifdef SHADOWCSM_RIGHTHANDED{X}
- diff{X}=viewFrustumZ{X}[i]+vPositionFromCamera{X}.z;
- #else
- diff{X}=viewFrustumZ{X}[i]-vPositionFromCamera{X}.z;
- #endif
- if (diff{X}>=0.) {
- index{X}=i;
- break;
- }
- }
- #ifdef SHADOWCSMUSESHADOWMAXZ{X}
- if (index{X}>=0)
- #endif
- {
- #if defined(SHADOWPCF{X})
- #if defined(SHADOWLOWQUALITY{X})
- shadow=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
- #elif defined(SHADOWMEDIUMQUALITY{X})
- 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);
- #else
- 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);
- #endif
- #elif defined(SHADOWPCSS{X})
- #if defined(SHADOWLOWQUALITY{X})
- 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});
- #elif defined(SHADOWMEDIUMQUALITY{X})
- 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});
- #else
- 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});
- #endif
- #else
- shadow=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
- #endif
- #ifdef SHADOWCSMDEBUG{X}
- shadowDebug{X}=vec3(shadow)*vCascadeColorsMultiplier{X}[index{X}];
- #endif
- #ifndef SHADOWCSMNOBLEND{X}
- float frustumLength=frustumLengths{X}[index{X}];
- float diffRatio=clamp(diff{X}/frustumLength,0.,1.)*cascadeBlendFactor{X};
- if (index{X}<(SHADOWCSMNUM_CASCADES{X}-1) && diffRatio<1.)
- {
- index{X}+=1;
- float nextShadow=0.;
- #if defined(SHADOWPCF{X})
- #if defined(SHADOWLOWQUALITY{X})
- nextShadow=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
- #elif defined(SHADOWMEDIUMQUALITY{X})
- 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);
- #else
- 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);
- #endif
- #elif defined(SHADOWPCSS{X})
- #if defined(SHADOWLOWQUALITY{X})
- 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});
- #elif defined(SHADOWMEDIUMQUALITY{X})
- 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});
- #else
- 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});
- #endif
- #else
- nextShadow=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
- #endif
- shadow=mix(nextShadow,shadow,diffRatio);
- #ifdef SHADOWCSMDEBUG{X}
- shadowDebug{X}=mix(vec3(nextShadow)*vCascadeColorsMultiplier{X}[index{X}],shadowDebug{X},diffRatio);
- #endif
- }
- #endif
- }
- #elif defined(SHADOWCLOSEESM{X})
- #if defined(SHADOWCUBE{X})
- shadow=computeShadowWithCloseESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);
- #else
- shadow=computeShadowWithCloseESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);
- #endif
- #elif defined(SHADOWESM{X})
- #if defined(SHADOWCUBE{X})
- shadow=computeShadowWithESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);
- #else
- shadow=computeShadowWithESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);
- #endif
- #elif defined(SHADOWPOISSON{X})
- #if defined(SHADOWCUBE{X})
- shadow=computeShadowWithPoissonSamplingCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);
- #else
- shadow=computeShadowWithPoissonSampling(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
- #endif
- #elif defined(SHADOWPCF{X})
- #if defined(SHADOWLOWQUALITY{X})
- shadow=computeShadowWithPCF1(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
- #elif defined(SHADOWMEDIUMQUALITY{X})
- shadow=computeShadowWithPCF3(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
- #else
- shadow=computeShadowWithPCF5(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
- #endif
- #elif defined(SHADOWPCSS{X})
- #if defined(SHADOWLOWQUALITY{X})
- 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);
- #elif defined(SHADOWMEDIUMQUALITY{X})
- 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);
- #else
- 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);
- #endif
- #else
- #if defined(SHADOWCUBE{X})
- shadow=computeShadowCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.depthValues);
- #else
- shadow=computeShadow(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
- #endif
- #endif
- #ifdef SHADOWONLY
- #ifndef SHADOWINUSE
- #define SHADOWINUSE
- #endif
- globalShadow+=shadow;
- shadowLightCount+=1.0;
- #endif
- #else
- shadow=1.;
- #endif
- #ifndef SHADOWONLY
- #ifdef CUSTOMUSERLIGHTING
- diffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow);
- #ifdef SPECULARTERM
- specularBase+=computeCustomSpecularLighting(info,specularBase,shadow);
- #endif
- #elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})
- diffuseBase+=lightmapColor.rgb*shadow;
- #ifdef SPECULARTERM
- #ifndef LIGHTMAPNOSPECULAR{X}
- specularBase+=info.specular*shadow*lightmapColor.rgb;
- #endif
- #endif
- #ifdef CLEARCOAT
- #ifndef LIGHTMAPNOSPECULAR{X}
- clearCoatBase+=info.clearCoat.rgb*shadow*lightmapColor.rgb;
- #endif
- #endif
- #ifdef SHEEN
- #ifndef LIGHTMAPNOSPECULAR{X}
- sheenBase+=info.sheen.rgb*shadow;
- #endif
- #endif
- #else
- #ifdef SHADOWCSMDEBUG{X}
- diffuseBase+=info.diffuse*shadowDebug{X};
- #else
- diffuseBase+=info.diffuse*shadow;
- #endif
- #ifdef SPECULARTERM
- specularBase+=info.specular*shadow;
- #endif
- #ifdef CLEARCOAT
- clearCoatBase+=info.clearCoat.rgb*shadow;
- #endif
- #ifdef SHEEN
- sheenBase+=info.sheen.rgb*shadow;
- #endif
- #endif
- #endif
- #endif`;
- ShaderStore.IncludesShadersStore[name$1K] = shader$1K;
- var name$1J = "logDepthFragment"
- , shader$1J = `#ifdef LOGARITHMICDEPTH
- gl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;
- #endif`;
- ShaderStore.IncludesShadersStore[name$1J] = shader$1J;
- var name$1I = "fogFragment"
- , shader$1I = `#ifdef FOG
- float fog=CalcFogFactor();
- #ifdef PBR
- fog=toLinearSpace(fog);
- #endif
- color.rgb=mix(vFogColor,color.rgb,fog);
- #endif`;
- ShaderStore.IncludesShadersStore[name$1I] = shader$1I;
- var name$1H = "defaultPixelShader"
- , shader$1H = `#include<__decl__defaultFragment>
- #if defined(BUMP) || !defined(NORMAL)
- #extension GL_OES_standard_derivatives : enable
- #endif
- #include<prePassDeclaration>[SCENE_MRT_COUNT]
- #include<oitDeclaration>
- #define CUSTOM_FRAGMENT_BEGIN
- #ifdef LOGARITHMICDEPTH
- #extension GL_EXT_frag_depth : enable
- #endif
- #define RECIPROCAL_PI2 0.15915494
- varying vec3 vPositionW;
- #ifdef NORMAL
- varying vec3 vNormalW;
- #endif
- #ifdef VERTEXCOLOR
- varying vec4 vColor;
- #endif
- #include<mainUVVaryingDeclaration>[1..7]
- #include<helperFunctions>
- #include<__decl__lightFragment>[0..maxSimultaneousLights]
- #include<lightsFragmentFunctions>
- #include<shadowsFragmentFunctions>
- #include<samplerFragmentDeclaration>(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse,_SAMPLERNAME_,diffuse)
- #include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient)
- #include<samplerFragmentDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity)
- #include<samplerFragmentDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive)
- #include<samplerFragmentDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap)
- #ifdef REFRACTION
- #ifdef REFRACTIONMAP_3D
- uniform samplerCube refractionCubeSampler;
- #else
- uniform sampler2D refraction2DSampler;
- #endif
- #endif
- #if defined(SPECULARTERM)
- #include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular,_SAMPLERNAME_,specular)
- #endif
- #include<fresnelFunction>
- #ifdef REFLECTION
- #ifdef REFLECTIONMAP_3D
- uniform samplerCube reflectionCubeSampler;
- #else
- uniform sampler2D reflection2DSampler;
- #endif
- #ifdef REFLECTIONMAP_SKYBOX
- varying vec3 vPositionUVW;
- #else
- #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
- varying vec3 vDirectionW;
- #endif
- #endif
- #include<reflectionFunction>
- #endif
- #include<imageProcessingDeclaration>
- #include<imageProcessingFunctions>
- #include<bumpFragmentMainFunctions>
- #include<bumpFragmentFunctions>
- #include<clipPlaneFragmentDeclaration>
- #include<logDepthDeclaration>
- #include<fogFragmentDeclaration>
- #define CUSTOM_FRAGMENT_DEFINITIONS
- void main(void) {
- #define CUSTOM_FRAGMENT_MAIN_BEGIN
- #include<oitFragment>
- #include<clipPlaneFragment>
- vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);
- vec4 baseColor=vec4(1.,1.,1.,1.);
- vec3 diffuseColor=vDiffuseColor.rgb;
- float alpha=vDiffuseColor.a;
- #ifdef NORMAL
- vec3 normalW=normalize(vNormalW);
- #else
- vec3 normalW=normalize(-cross(dFdx(vPositionW),dFdy(vPositionW)));
- #endif
- #include<bumpFragment>
- #ifdef TWOSIDEDLIGHTING
- normalW=gl_FrontFacing ? normalW : -normalW;
- #endif
- #ifdef DIFFUSE
- baseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);
- #if defined(ALPHATEST) && !defined(ALPHATEST_AFTERALLALPHACOMPUTATIONS)
- if (baseColor.a<alphaCutOff)
- discard;
- #endif
- #ifdef ALPHAFROMDIFFUSE
- alpha*=baseColor.a;
- #endif
- #define CUSTOM_FRAGMENT_UPDATE_ALPHA
- baseColor.rgb*=vDiffuseInfos.y;
- #endif
- #include<depthPrePass>
- #ifdef VERTEXCOLOR
- baseColor.rgb*=vColor.rgb;
- #endif
- #ifdef DETAIL
- baseColor.rgb=baseColor.rgb*2.0*mix(0.5,detailColor.r,vDetailInfos.y);
- #endif
- #define CUSTOM_FRAGMENT_UPDATE_DIFFUSE
- vec3 baseAmbientColor=vec3(1.,1.,1.);
- #ifdef AMBIENT
- baseAmbientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;
- #endif
- #define CUSTOM_FRAGMENT_BEFORE_LIGHTS
- #ifdef SPECULARTERM
- float glossiness=vSpecularColor.a;
- vec3 specularColor=vSpecularColor.rgb;
- #ifdef SPECULAR
- vec4 specularMapColor=texture2D(specularSampler,vSpecularUV+uvOffset);
- specularColor=specularMapColor.rgb;
- #ifdef GLOSSINESS
- glossiness=glossiness*specularMapColor.a;
- #endif
- #endif
- #else
- float glossiness=0.;
- #endif
- vec3 diffuseBase=vec3(0.,0.,0.);
- lightingInfo info;
- #ifdef SPECULARTERM
- vec3 specularBase=vec3(0.,0.,0.);
- #endif
- float shadow=1.;
- #ifdef LIGHTMAP
- vec4 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset);
- #ifdef RGBDLIGHTMAP
- lightmapColor.rgb=fromRGBD(lightmapColor);
- #endif
- lightmapColor.rgb*=vLightmapInfos.y;
- #endif
- #include<lightFragment>[0..maxSimultaneousLights]
- vec4 refractionColor=vec4(0.,0.,0.,1.);
- #ifdef REFRACTION
- vec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y));
- #ifdef REFRACTIONMAP_3D
- #ifdef USE_LOCAL_REFRACTIONMAP_CUBIC
- refractionVector=parallaxCorrectNormal(vPositionW,refractionVector,vRefractionSize,vRefractionPosition);
- #endif
- refractionVector.y=refractionVector.y*vRefractionInfos.w;
- if (dot(refractionVector,viewDirectionW)<1.0) {
- refractionColor=textureCube(refractionCubeSampler,refractionVector);
- }
- #else
- vec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));
- vec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;
- refractionCoords.y=1.0-refractionCoords.y;
- refractionColor=texture2D(refraction2DSampler,refractionCoords);
- #endif
- #ifdef RGBDREFRACTION
- refractionColor.rgb=fromRGBD(refractionColor);
- #endif
- #ifdef IS_REFRACTION_LINEAR
- refractionColor.rgb=toGammaSpace(refractionColor.rgb);
- #endif
- refractionColor.rgb*=vRefractionInfos.x;
- #endif
- vec4 reflectionColor=vec4(0.,0.,0.,1.);
- #ifdef REFLECTION
- vec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);
- #ifdef REFLECTIONMAP_OPPOSITEZ
- vReflectionUVW.z*=-1.0;
- #endif
- #ifdef REFLECTIONMAP_3D
- #ifdef ROUGHNESS
- float bias=vReflectionInfos.y;
- #ifdef SPECULARTERM
- #ifdef SPECULAR
- #ifdef GLOSSINESS
- bias*=(1.0-specularMapColor.a);
- #endif
- #endif
- #endif
- reflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias);
- #else
- reflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW);
- #endif
- #else
- vec2 coords=vReflectionUVW.xy;
- #ifdef REFLECTIONMAP_PROJECTION
- coords/=vReflectionUVW.z;
- #endif
- coords.y=1.0-coords.y;
- reflectionColor=texture2D(reflection2DSampler,coords);
- #endif
- #ifdef RGBDREFLECTION
- reflectionColor.rgb=fromRGBD(reflectionColor);
- #endif
- #ifdef IS_REFLECTION_LINEAR
- reflectionColor.rgb=toGammaSpace(reflectionColor.rgb);
- #endif
- reflectionColor.rgb*=vReflectionInfos.x;
- #ifdef REFLECTIONFRESNEL
- float reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a);
- #ifdef REFLECTIONFRESNELFROMSPECULAR
- #ifdef SPECULARTERM
- reflectionColor.rgb*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;
- #else
- reflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;
- #endif
- #else
- reflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;
- #endif
- #endif
- #endif
- #ifdef REFRACTIONFRESNEL
- float refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a);
- refractionColor.rgb*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb;
- #endif
- #ifdef OPACITY
- vec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);
- #ifdef OPACITYRGB
- opacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);
- alpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;
- #else
- alpha*=opacityMap.a*vOpacityInfos.y;
- #endif
- #endif
- #ifdef VERTEXALPHA
- alpha*=vColor.a;
- #endif
- #ifdef OPACITYFRESNEL
- float opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);
- alpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y;
- #endif
- #ifdef ALPHATEST
- #ifdef ALPHATEST_AFTERALLALPHACOMPUTATIONS
- if (alpha<alphaCutOff)
- discard;
- #endif
- #ifndef ALPHABLEND
- alpha=1.0;
- #endif
- #endif
- vec3 emissiveColor=vEmissiveColor;
- #ifdef EMISSIVE
- emissiveColor+=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb*vEmissiveInfos.y;
- #endif
- #ifdef EMISSIVEFRESNEL
- float emissiveFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,emissiveRightColor.a,emissiveLeftColor.a);
- emissiveColor*=emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*emissiveRightColor.rgb;
- #endif
- #ifdef DIFFUSEFRESNEL
- float diffuseFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,diffuseRightColor.a,diffuseLeftColor.a);
- diffuseBase*=diffuseLeftColor.rgb*(1.0-diffuseFresnelTerm)+diffuseFresnelTerm*diffuseRightColor.rgb;
- #endif
- #ifdef EMISSIVEASILLUMINATION
- vec3 finalDiffuse=clamp(diffuseBase*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;
- #else
- #ifdef LINKEMISSIVEWITHDIFFUSE
- vec3 finalDiffuse=clamp((diffuseBase+emissiveColor)*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;
- #else
- vec3 finalDiffuse=clamp(diffuseBase*diffuseColor+emissiveColor+vAmbientColor,0.0,1.0)*baseColor.rgb;
- #endif
- #endif
- #ifdef SPECULARTERM
- vec3 finalSpecular=specularBase*specularColor;
- #ifdef SPECULAROVERALPHA
- alpha=clamp(alpha+dot(finalSpecular,vec3(0.3,0.59,0.11)),0.,1.);
- #endif
- #else
- vec3 finalSpecular=vec3(0.0);
- #endif
- #ifdef REFLECTIONOVERALPHA
- alpha=clamp(alpha+dot(reflectionColor.rgb,vec3(0.3,0.59,0.11)),0.,1.);
- #endif
- #ifdef EMISSIVEASILLUMINATION
- vec4 color=vec4(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor.rgb+emissiveColor+refractionColor.rgb,0.0,1.0),alpha);
- #else
- vec4 color=vec4(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor.rgb+refractionColor.rgb,alpha);
- #endif
- #ifdef LIGHTMAP
- #ifndef LIGHTMAPEXCLUDED
- #ifdef USELIGHTMAPASSHADOWMAP
- color.rgb*=lightmapColor.rgb;
- #else
- color.rgb+=lightmapColor.rgb;
- #endif
- #endif
- #endif
- #define CUSTOM_FRAGMENT_BEFORE_FOG
- color.rgb=max(color.rgb,0.);
- #include<logDepthFragment>
- #include<fogFragment>
- #ifdef IMAGEPROCESSINGPOSTPROCESS
- color.rgb=toLinearSpace(color.rgb);
- #else
- #ifdef IMAGEPROCESSING
- color.rgb=toLinearSpace(color.rgb);
- color=applyImageProcessing(color);
- #endif
- #endif
- color.a*=visibility;
- #ifdef PREMULTIPLYALPHA
- color.rgb*=color.a;
- #endif
- #define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR
- #ifdef PREPASS
- float writeGeometryInfo=color.a>0.4 ? 1.0 : 0.0;
- gl_FragData[0]=color;
- #ifdef PREPASS_POSITION
- gl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,writeGeometryInfo);
- #endif
- #ifdef PREPASS_VELOCITY
- vec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;
- vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;
- vec2 velocity=abs(a-b);
- velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;
- gl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,writeGeometryInfo);
- #endif
- #ifdef PREPASS_IRRADIANCE
- gl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo);
- #endif
- #ifdef PREPASS_DEPTH
- gl_FragData[PREPASS_DEPTH_INDEX]=vec4(vViewPos.z,0.0,0.0,writeGeometryInfo);
- #endif
- #ifdef PREPASS_NORMAL
- gl_FragData[PREPASS_NORMAL_INDEX]=vec4((view*vec4(normalW,0.0)).rgb,writeGeometryInfo);
- #endif
- #ifdef PREPASS_ALBEDO_SQRT
- gl_FragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo);
- #endif
- #ifdef PREPASS_REFLECTIVITY
- #if defined(SPECULAR)
- gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(specularMapColor.rgb,specularMapColor.a*writeGeometryInfo);
- #else
- gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo);
- #endif
- #endif
- #endif
- #if !defined(PREPASS) || defined(WEBGL2)
- gl_FragColor=color;
- #endif
- #if ORDER_INDEPENDENT_TRANSPARENCY
- if (fragDepth == nearestDepth) {
- frontColor.rgb+=color.rgb*color.a*alphaMultiplier;
- frontColor.a=1.0-alphaMultiplier*(1.0-color.a);
- } else {
- backColor+=color;
- }
- #endif
- }
- `;
- ShaderStore.ShadersStore[name$1H] = shader$1H;
- var name$1G = "defaultVertexDeclaration"
- , shader$1G = `
- uniform mat4 viewProjection;
- uniform mat4 view;
- #ifdef DIFFUSE
- uniform mat4 diffuseMatrix;
- uniform vec2 vDiffuseInfos;
- #endif
- #ifdef AMBIENT
- uniform mat4 ambientMatrix;
- uniform vec2 vAmbientInfos;
- #endif
- #ifdef OPACITY
- uniform mat4 opacityMatrix;
- uniform vec2 vOpacityInfos;
- #endif
- #ifdef EMISSIVE
- uniform vec2 vEmissiveInfos;
- uniform mat4 emissiveMatrix;
- #endif
- #ifdef LIGHTMAP
- uniform vec2 vLightmapInfos;
- uniform mat4 lightmapMatrix;
- #endif
- #if defined(SPECULAR) && defined(SPECULARTERM)
- uniform vec2 vSpecularInfos;
- uniform mat4 specularMatrix;
- #endif
- #ifdef BUMP
- uniform vec3 vBumpInfos;
- uniform mat4 bumpMatrix;
- #endif
- #ifdef REFLECTION
- uniform mat4 reflectionMatrix;
- #endif
- #ifdef POINTSIZE
- uniform float pointSize;
- #endif
- #ifdef DETAIL
- uniform vec4 vDetailInfos;
- uniform mat4 detailMatrix;
- #endif`;
- ShaderStore.IncludesShadersStore[name$1G] = shader$1G;
- var name$1F = "uvAttributeDeclaration"
- , shader$1F = `#ifdef UV{X}
- attribute vec2 uv{X};
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$1F] = shader$1F;
- var name$1E = "instancesDeclaration"
- , shader$1E = `#ifdef INSTANCES
- attribute vec4 world0;
- attribute vec4 world1;
- attribute vec4 world2;
- attribute vec4 world3;
- #if defined(THIN_INSTANCES) && !defined(WORLD_UBO)
- uniform mat4 world;
- #endif
- #if defined(VELOCITY) || defined(PREPASS_VELOCITY)
- attribute vec4 previousWorld0;
- attribute vec4 previousWorld1;
- attribute vec4 previousWorld2;
- attribute vec4 previousWorld3;
- #ifdef THIN_INSTANCES
- uniform mat4 previousWorld;
- #endif
- #endif
- #else
- #if !defined(WORLD_UBO)
- uniform mat4 world;
- #endif
- #if defined(VELOCITY) || defined(PREPASS_VELOCITY)
- uniform mat4 previousWorld;
- #endif
- #endif`;
- ShaderStore.IncludesShadersStore[name$1E] = shader$1E;
- var name$1D = "prePassVertexDeclaration"
- , shader$1D = `#ifdef PREPASS
- #ifdef PREPASS_DEPTH
- varying vec3 vViewPos;
- #endif
- #ifdef PREPASS_VELOCITY
- uniform mat4 previousViewProjection;
- varying vec4 vCurrentPosition;
- varying vec4 vPreviousPosition;
- #endif
- #endif`;
- ShaderStore.IncludesShadersStore[name$1D] = shader$1D;
- var name$1C = "samplerVertexDeclaration"
- , shader$1C = `#if defined(_DEFINENAME_) && _DEFINENAME_DIRECTUV == 0
- varying vec2 v_VARYINGNAME_UV;
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$1C] = shader$1C;
- var name$1B = "bumpVertexDeclaration"
- , shader$1B = `#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)
- #if defined(TANGENT) && defined(NORMAL)
- varying mat3 vTBN;
- #endif
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$1B] = shader$1B;
- var name$1A = "fogVertexDeclaration"
- , shader$1A = `#ifdef FOG
- varying vec3 vFogDistance;
- #endif`;
- ShaderStore.IncludesShadersStore[name$1A] = shader$1A;
- var name$1z = "lightVxFragmentDeclaration"
- , shader$1z = `#ifdef LIGHT{X}
- uniform vec4 vLightData{X};
- uniform vec4 vLightDiffuse{X};
- #ifdef SPECULARTERM
- uniform vec4 vLightSpecular{X};
- #else
- vec4 vLightSpecular{X}=vec4(0.);
- #endif
- #ifdef SHADOW{X}
- #ifdef SHADOWCSM{X}
- uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];
- varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];
- varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];
- varying vec4 vPositionFromCamera{X};
- #elif defined(SHADOWCUBE{X})
- #else
- varying vec4 vPositionFromLight{X};
- varying float vDepthMetric{X};
- uniform mat4 lightMatrix{X};
- #endif
- uniform vec4 shadowsInfo{X};
- uniform vec2 depthValues{X};
- #endif
- #ifdef SPOTLIGHT{X}
- uniform vec4 vLightDirection{X};
- uniform vec4 vLightFalloff{X};
- #elif defined(POINTLIGHT{X})
- uniform vec4 vLightFalloff{X};
- #elif defined(HEMILIGHT{X})
- uniform vec3 vLightGround{X};
- #endif
- #endif`;
- ShaderStore.IncludesShadersStore[name$1z] = shader$1z;
- var name$1y = "lightVxUboDeclaration"
- , shader$1y = `#ifdef LIGHT{X}
- uniform Light{X}
- {
- vec4 vLightData;
- vec4 vLightDiffuse;
- vec4 vLightSpecular;
- #ifdef SPOTLIGHT{X}
- vec4 vLightDirection;
- vec4 vLightFalloff;
- #elif defined(POINTLIGHT{X})
- vec4 vLightFalloff;
- #elif defined(HEMILIGHT{X})
- vec3 vLightGround;
- #endif
- vec4 shadowsInfo;
- vec2 depthValues;
- } light{X};
- #ifdef SHADOW{X}
- #ifdef SHADOWCSM{X}
- uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];
- varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];
- varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];
- varying vec4 vPositionFromCamera{X};
- #elif defined(SHADOWCUBE{X})
- #else
- varying vec4 vPositionFromLight{X};
- varying float vDepthMetric{X};
- uniform mat4 lightMatrix{X};
- #endif
- #endif
- #endif`;
- ShaderStore.IncludesShadersStore[name$1y] = shader$1y;
- var name$1x = "prePassVertex"
- , shader$1x = `#ifdef PREPASS_DEPTH
- vViewPos=(view*worldPos).rgb;
- #endif
- #if defined(PREPASS_VELOCITY) && defined(BONES_VELOCITY_ENABLED)
- vCurrentPosition=viewProjection*worldPos;
- #if NUM_BONE_INFLUENCERS>0
- mat4 previousInfluence;
- previousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0];
- #if NUM_BONE_INFLUENCERS>1
- previousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1];
- #endif
- #if NUM_BONE_INFLUENCERS>2
- previousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2];
- #endif
- #if NUM_BONE_INFLUENCERS>3
- previousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3];
- #endif
- #if NUM_BONE_INFLUENCERS>4
- previousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];
- #endif
- #if NUM_BONE_INFLUENCERS>5
- previousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];
- #endif
- #if NUM_BONE_INFLUENCERS>6
- previousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];
- #endif
- #if NUM_BONE_INFLUENCERS>7
- previousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];
- #endif
- vPreviousPosition=previousViewProjection*previousWorld*previousInfluence*vec4(positionUpdated,1.0);
- #else
- vPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0);
- #endif
- #endif`;
- ShaderStore.IncludesShadersStore[name$1x] = shader$1x;
- var name$1w = "uvVariableDeclaration"
- , shader$1w = `#if !defined(UV{X}) && defined(MAINUV{X})
- vec2 uv{X}=vec2(0.,0.);
- #endif
- #ifdef MAINUV{X}
- vMainUV{X}=uv{X};
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$1w] = shader$1w;
- var name$1v = "samplerVertexImplementation"
- , shader$1v = `#if defined(_DEFINENAME_) && _DEFINENAME_DIRECTUV == 0
- if (v_INFONAME_ == 0.)
- {
- v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uvUpdated,1.0,0.0));
- }
- #ifdef UV2
- else if (v_INFONAME_ == 1.)
- {
- v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv2,1.0,0.0));
- }
- #endif
- #ifdef UV3
- else if (v_INFONAME_ == 2.)
- {
- v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv3,1.0,0.0));
- }
- #endif
- #ifdef UV4
- else if (v_INFONAME_ == 3.)
- {
- v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv4,1.0,0.0));
- }
- #endif
- #ifdef UV5
- else if (v_INFONAME_ == 4.)
- {
- v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv5,1.0,0.0));
- }
- #endif
- #ifdef UV6
- else if (v_INFONAME_ == 5.)
- {
- v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv6,1.0,0.0));
- }
- #endif
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$1v] = shader$1v;
- var name$1u = "bumpVertex"
- , shader$1u = `#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)
- #if defined(TANGENT) && defined(NORMAL)
- vec3 tbnNormal=normalize(normalUpdated);
- vec3 tbnTangent=normalize(tangentUpdated.xyz);
- vec3 tbnBitangent=cross(tbnNormal,tbnTangent)*tangentUpdated.w;
- vTBN=mat3(finalWorld)*mat3(tbnTangent,tbnBitangent,tbnNormal);
- #endif
- #endif`;
- ShaderStore.IncludesShadersStore[name$1u] = shader$1u;
- var name$1t = "fogVertex"
- , shader$1t = `#ifdef FOG
- vFogDistance=(view*worldPos).xyz;
- #endif`;
- ShaderStore.IncludesShadersStore[name$1t] = shader$1t;
- var name$1s = "shadowsVertex"
- , shader$1s = `#ifdef SHADOWS
- #if defined(SHADOWCSM{X})
- vPositionFromCamera{X}=view*worldPos;
- for (int i=0; i<SHADOWCSMNUM_CASCADES{X}; i++) {
- vPositionFromLight{X}[i]=lightMatrix{X}[i]*worldPos;
- #ifdef USE_REVERSE_DEPTHBUFFER
- vDepthMetric{X}[i]=(-vPositionFromLight{X}[i].z+light{X}.depthValues.x)/light{X}.depthValues.y;
- #else
- vDepthMetric{X}[i]=(vPositionFromLight{X}[i].z+light{X}.depthValues.x)/light{X}.depthValues.y;
- #endif
- }
- #elif defined(SHADOW{X}) && !defined(SHADOWCUBE{X})
- vPositionFromLight{X}=lightMatrix{X}*worldPos;
- #ifdef USE_REVERSE_DEPTHBUFFER
- vDepthMetric{X}=(-vPositionFromLight{X}.z+light{X}.depthValues.x)/light{X}.depthValues.y;
- #else
- vDepthMetric{X}=(vPositionFromLight{X}.z+light{X}.depthValues.x)/light{X}.depthValues.y;
- #endif
- #endif
- #endif`;
- ShaderStore.IncludesShadersStore[name$1s] = shader$1s;
- var name$1r = "pointCloudVertex"
- , shader$1r = `#ifdef POINTSIZE
- gl_PointSize=pointSize;
- #endif`;
- ShaderStore.IncludesShadersStore[name$1r] = shader$1r;
- var name$1q = "logDepthVertex"
- , shader$1q = `#ifdef LOGARITHMICDEPTH
- vFragmentDepth=1.0+gl_Position.w;
- gl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;
- #endif`;
- ShaderStore.IncludesShadersStore[name$1q] = shader$1q;
- var name$1p = "defaultVertexShader"
- , shader$1p = `#include<__decl__defaultVertex>
- #define CUSTOM_VERTEX_BEGIN
- attribute vec3 position;
- #ifdef NORMAL
- attribute vec3 normal;
- #endif
- #ifdef TANGENT
- attribute vec4 tangent;
- #endif
- #ifdef UV1
- attribute vec2 uv;
- #endif
- #include<uvAttributeDeclaration>[2..7]
- #ifdef VERTEXCOLOR
- attribute vec4 color;
- #endif
- #include<helperFunctions>
- #include<bonesDeclaration>
- #include<bakedVertexAnimationDeclaration>
- #include<instancesDeclaration>
- #include<prePassVertexDeclaration>
- #include<mainUVVaryingDeclaration>[1..7]
- #include<samplerVertexDeclaration>(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse)
- #include<samplerVertexDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail)
- #include<samplerVertexDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient)
- #include<samplerVertexDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity)
- #include<samplerVertexDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive)
- #include<samplerVertexDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap)
- #if defined(SPECULARTERM)
- #include<samplerVertexDeclaration>(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular)
- #endif
- #include<samplerVertexDeclaration>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump)
- varying vec3 vPositionW;
- #ifdef NORMAL
- varying vec3 vNormalW;
- #endif
- #ifdef VERTEXCOLOR
- varying vec4 vColor;
- #endif
- #include<bumpVertexDeclaration>
- #include<clipPlaneVertexDeclaration>
- #include<fogVertexDeclaration>
- #include<__decl__lightVxFragment>[0..maxSimultaneousLights]
- #include<morphTargetsVertexGlobalDeclaration>
- #include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
- #ifdef REFLECTIONMAP_SKYBOX
- varying vec3 vPositionUVW;
- #endif
- #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
- varying vec3 vDirectionW;
- #endif
- #include<logDepthDeclaration>
- #define CUSTOM_VERTEX_DEFINITIONS
- void main(void) {
- #define CUSTOM_VERTEX_MAIN_BEGIN
- vec3 positionUpdated=position;
- #ifdef NORMAL
- vec3 normalUpdated=normal;
- #endif
- #ifdef TANGENT
- vec4 tangentUpdated=tangent;
- #endif
- #ifdef UV1
- vec2 uvUpdated=uv;
- #endif
- #include<morphTargetsVertexGlobal>
- #include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
- #ifdef REFLECTIONMAP_SKYBOX
- vPositionUVW=positionUpdated;
- #endif
- #define CUSTOM_VERTEX_UPDATE_POSITION
- #define CUSTOM_VERTEX_UPDATE_NORMAL
- #include<instancesVertex>
- #if defined(PREPASS) && defined(PREPASS_VELOCITY) && !defined(BONES_VELOCITY_ENABLED)
- vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);
- vPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);
- #endif
- #include<bonesVertex>
- #include<bakedVertexAnimation>
- vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);
- #ifdef NORMAL
- mat3 normalWorld=mat3(finalWorld);
- #if defined(INSTANCES) && defined(THIN_INSTANCES)
- vNormalW=normalUpdated/vec3(dot(normalWorld[0],normalWorld[0]),dot(normalWorld[1],normalWorld[1]),dot(normalWorld[2],normalWorld[2]));
- vNormalW=normalize(normalWorld*vNormalW);
- #else
- #ifdef NONUNIFORMSCALING
- normalWorld=transposeMat3(inverseMat3(normalWorld));
- #endif
- vNormalW=normalize(normalWorld*normalUpdated);
- #endif
- #endif
- #define CUSTOM_VERTEX_UPDATE_WORLDPOS
- #ifdef MULTIVIEW
- if (gl_ViewID_OVR == 0u) {
- gl_Position=viewProjection*worldPos;
- } else {
- gl_Position=viewProjectionR*worldPos;
- }
- #else
- gl_Position=viewProjection*worldPos;
- #endif
- vPositionW=vec3(worldPos);
- #include<prePassVertex>
- #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
- vDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));
- #endif
- #ifndef UV1
- vec2 uvUpdated=vec2(0.,0.);
- #endif
- #ifdef MAINUV1
- vMainUV1=uvUpdated;
- #endif
- #include<uvVariableDeclaration>[2..7]
- #include<samplerVertexImplementation>(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse,_MATRIXNAME_,diffuse,_INFONAME_,DiffuseInfos.x)
- #include<samplerVertexImplementation>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_MATRIXNAME_,detail,_INFONAME_,DetailInfos.x)
- #include<samplerVertexImplementation>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_MATRIXNAME_,ambient,_INFONAME_,AmbientInfos.x)
- #include<samplerVertexImplementation>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_MATRIXNAME_,opacity,_INFONAME_,OpacityInfos.x)
- #include<samplerVertexImplementation>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_MATRIXNAME_,emissive,_INFONAME_,EmissiveInfos.x)
- #include<samplerVertexImplementation>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_MATRIXNAME_,lightmap,_INFONAME_,LightmapInfos.x)
- #if defined(SPECULARTERM)
- #include<samplerVertexImplementation>(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular,_MATRIXNAME_,specular,_INFONAME_,SpecularInfos.x)
- #endif
- #include<samplerVertexImplementation>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_MATRIXNAME_,bump,_INFONAME_,BumpInfos.x)
- #include<bumpVertex>
- #include<clipPlaneVertex>
- #include<fogVertex>
- #include<shadowsVertex>[0..maxSimultaneousLights]
- #ifdef VERTEXCOLOR
- vColor=color;
- #endif
- #include<pointCloudVertex>
- #include<logDepthVertex>
- #define CUSTOM_VERTEX_MAIN_END
- }
- `;
- ShaderStore.ShadersStore[name$1p] = shader$1p;
- var DetailMapConfiguration = function() {
- function a(e) {
- this._texture = null,
- this.diffuseBlendLevel = 1,
- this.roughnessBlendLevel = 1,
- this.bumpLevel = 1,
- this._normalBlendMethod = Material.MATERIAL_NORMALBLENDMETHOD_WHITEOUT,
- this._isEnabled = !1,
- this.isEnabled = !1,
- this._internalMarkAllSubMeshesAsTexturesDirty = e
- }
- return a.prototype._markAllSubMeshesAsTexturesDirty = function() {
- this._internalMarkAllSubMeshesAsTexturesDirty()
- }
- ,
- a.prototype.isReadyForSubMesh = function(e, i) {
- if (!this._isEnabled)
- return !0;
- var o = i.getEngine();
- return !(e._areTexturesDirty && i.texturesEnabled && o.getCaps().standardDerivatives && this._texture && MaterialFlags.DetailTextureEnabled && !this._texture.isReady())
- }
- ,
- a.prototype.prepareDefines = function(e, i) {
- if (this._isEnabled) {
- e.DETAIL_NORMALBLENDMETHOD = this._normalBlendMethod;
- var o = i.getEngine();
- e._areTexturesDirty && (o.getCaps().standardDerivatives && this._texture && MaterialFlags.DetailTextureEnabled && this._isEnabled ? (MaterialHelper.PrepareDefinesForMergedUV(this._texture, e, "DETAIL"),
- e.DETAIL_NORMALBLENDMETHOD = this._normalBlendMethod) : e.DETAIL = !1)
- } else
- e.DETAIL = !1
- }
- ,
- a.prototype.bindForSubMesh = function(e, i, o) {
- !this._isEnabled || ((!e.useUbo || !o || !e.isSync) && this._texture && MaterialFlags.DetailTextureEnabled && (e.updateFloat4("vDetailInfos", this._texture.coordinatesIndex, this.diffuseBlendLevel, this.bumpLevel, this.roughnessBlendLevel),
- MaterialHelper.BindTextureMatrix(this._texture, e, "detail")),
- i.texturesEnabled && this._texture && MaterialFlags.DetailTextureEnabled && e.setTexture("detailSampler", this._texture))
- }
- ,
- a.prototype.hasTexture = function(e) {
- return this._texture === e
- }
- ,
- a.prototype.getActiveTextures = function(e) {
- this._texture && e.push(this._texture)
- }
- ,
- a.prototype.getAnimatables = function(e) {
- this._texture && this._texture.animations && this._texture.animations.length > 0 && e.push(this._texture)
- }
- ,
- a.prototype.dispose = function(e) {
- var i;
- e && ((i = this._texture) === null || i === void 0 || i.dispose())
- }
- ,
- a.prototype.getClassName = function() {
- return "DetailMapConfiguration"
- }
- ,
- a.AddUniforms = function(e) {
- e.push("vDetailInfos"),
- e.push("detailMatrix")
- }
- ,
- a.AddSamplers = function(e) {
- e.push("detailSampler")
- }
- ,
- a.PrepareUniformBuffer = function(e) {
- e.addUniform("vDetailInfos", 4),
- e.addUniform("detailMatrix", 16)
- }
- ,
- a.prototype.copyTo = function(e) {
- SerializationHelper.Clone(function() {
- return e
- }, this)
- }
- ,
- a.prototype.serialize = function() {
- return SerializationHelper.Serialize(this)
- }
- ,
- a.prototype.parse = function(e, i, o) {
- var s = this;
- SerializationHelper.Parse(function() {
- return s
- }, e, i, o)
- }
- ,
- __decorate([serializeAsTexture("detailTexture"), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "texture", void 0),
- __decorate([serialize()], a.prototype, "diffuseBlendLevel", void 0),
- __decorate([serialize()], a.prototype, "roughnessBlendLevel", void 0),
- __decorate([serialize()], a.prototype, "bumpLevel", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "normalBlendMethod", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "isEnabled", void 0),
- a
- }()
- , onCreatedEffectParameters$2 = {
- effect: null,
- subMesh: null
- }
- , StandardMaterialDefines = function(a) {
- __extends(e, a);
- function e() {
- var i = a.call(this) || this;
- return i.MAINUV1 = !1,
- i.MAINUV2 = !1,
- i.MAINUV3 = !1,
- i.MAINUV4 = !1,
- i.MAINUV5 = !1,
- i.MAINUV6 = !1,
- i.DIFFUSE = !1,
- i.DIFFUSEDIRECTUV = 0,
- i.DETAIL = !1,
- i.DETAILDIRECTUV = 0,
- i.DETAIL_NORMALBLENDMETHOD = 0,
- i.BAKED_VERTEX_ANIMATION_TEXTURE = !1,
- i.AMBIENT = !1,
- i.AMBIENTDIRECTUV = 0,
- i.OPACITY = !1,
- i.OPACITYDIRECTUV = 0,
- i.OPACITYRGB = !1,
- i.REFLECTION = !1,
- i.EMISSIVE = !1,
- i.EMISSIVEDIRECTUV = 0,
- i.SPECULAR = !1,
- i.SPECULARDIRECTUV = 0,
- i.BUMP = !1,
- i.BUMPDIRECTUV = 0,
- i.PARALLAX = !1,
- i.PARALLAXOCCLUSION = !1,
- i.SPECULAROVERALPHA = !1,
- i.CLIPPLANE = !1,
- i.CLIPPLANE2 = !1,
- i.CLIPPLANE3 = !1,
- i.CLIPPLANE4 = !1,
- i.CLIPPLANE5 = !1,
- i.CLIPPLANE6 = !1,
- i.ALPHATEST = !1,
- i.DEPTHPREPASS = !1,
- i.ALPHAFROMDIFFUSE = !1,
- i.POINTSIZE = !1,
- i.FOG = !1,
- i.SPECULARTERM = !1,
- i.DIFFUSEFRESNEL = !1,
- i.OPACITYFRESNEL = !1,
- i.REFLECTIONFRESNEL = !1,
- i.REFRACTIONFRESNEL = !1,
- i.EMISSIVEFRESNEL = !1,
- i.FRESNEL = !1,
- i.NORMAL = !1,
- i.TANGENT = !1,
- i.UV1 = !1,
- i.UV2 = !1,
- i.UV3 = !1,
- i.UV4 = !1,
- i.UV5 = !1,
- i.UV6 = !1,
- i.VERTEXCOLOR = !1,
- i.VERTEXALPHA = !1,
- i.NUM_BONE_INFLUENCERS = 0,
- i.BonesPerMesh = 0,
- i.BONETEXTURE = !1,
- i.BONES_VELOCITY_ENABLED = !1,
- i.INSTANCES = !1,
- i.THIN_INSTANCES = !1,
- i.GLOSSINESS = !1,
- i.ROUGHNESS = !1,
- i.EMISSIVEASILLUMINATION = !1,
- i.LINKEMISSIVEWITHDIFFUSE = !1,
- i.REFLECTIONFRESNELFROMSPECULAR = !1,
- i.LIGHTMAP = !1,
- i.LIGHTMAPDIRECTUV = 0,
- i.OBJECTSPACE_NORMALMAP = !1,
- i.USELIGHTMAPASSHADOWMAP = !1,
- i.REFLECTIONMAP_3D = !1,
- i.REFLECTIONMAP_SPHERICAL = !1,
- i.REFLECTIONMAP_PLANAR = !1,
- i.REFLECTIONMAP_CUBIC = !1,
- i.USE_LOCAL_REFLECTIONMAP_CUBIC = !1,
- i.USE_LOCAL_REFRACTIONMAP_CUBIC = !1,
- i.REFLECTIONMAP_PROJECTION = !1,
- i.REFLECTIONMAP_SKYBOX = !1,
- i.REFLECTIONMAP_EXPLICIT = !1,
- i.REFLECTIONMAP_EQUIRECTANGULAR = !1,
- i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1,
- i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1,
- i.REFLECTIONMAP_OPPOSITEZ = !1,
- i.INVERTCUBICMAP = !1,
- i.LOGARITHMICDEPTH = !1,
- i.REFRACTION = !1,
- i.REFRACTIONMAP_3D = !1,
- i.REFLECTIONOVERALPHA = !1,
- i.TWOSIDEDLIGHTING = !1,
- i.SHADOWFLOAT = !1,
- i.MORPHTARGETS = !1,
- i.MORPHTARGETS_NORMAL = !1,
- i.MORPHTARGETS_TANGENT = !1,
- i.MORPHTARGETS_UV = !1,
- i.NUM_MORPH_INFLUENCERS = 0,
- i.MORPHTARGETS_TEXTURE = !1,
- i.NONUNIFORMSCALING = !1,
- i.PREMULTIPLYALPHA = !1,
- i.ALPHATEST_AFTERALLALPHACOMPUTATIONS = !1,
- i.ALPHABLEND = !0,
- i.PREPASS = !1,
- i.PREPASS_IRRADIANCE = !1,
- i.PREPASS_IRRADIANCE_INDEX = -1,
- i.PREPASS_ALBEDO_SQRT = !1,
- i.PREPASS_ALBEDO_SQRT_INDEX = -1,
- i.PREPASS_DEPTH = !1,
- i.PREPASS_DEPTH_INDEX = -1,
- i.PREPASS_NORMAL = !1,
- i.PREPASS_NORMAL_INDEX = -1,
- i.PREPASS_POSITION = !1,
- i.PREPASS_POSITION_INDEX = -1,
- i.PREPASS_VELOCITY = !1,
- i.PREPASS_VELOCITY_INDEX = -1,
- i.PREPASS_REFLECTIVITY = !1,
- i.PREPASS_REFLECTIVITY_INDEX = -1,
- i.SCENE_MRT_COUNT = 0,
- i.RGBDLIGHTMAP = !1,
- i.RGBDREFLECTION = !1,
- i.RGBDREFRACTION = !1,
- i.IMAGEPROCESSING = !1,
- i.VIGNETTE = !1,
- i.VIGNETTEBLENDMODEMULTIPLY = !1,
- i.VIGNETTEBLENDMODEOPAQUE = !1,
- i.TONEMAPPING = !1,
- i.TONEMAPPING_ACES = !1,
- i.CONTRAST = !1,
- i.COLORCURVES = !1,
- i.COLORGRADING = !1,
- i.COLORGRADING3D = !1,
- i.SAMPLER3DGREENDEPTH = !1,
- i.SAMPLER3DBGRMAP = !1,
- i.IMAGEPROCESSINGPOSTPROCESS = !1,
- i.SKIPFINALCOLORCLAMP = !1,
- i.MULTIVIEW = !1,
- i.ORDER_INDEPENDENT_TRANSPARENCY = !1,
- i.ORDER_INDEPENDENT_TRANSPARENCY_16BITS = !1,
- i.IS_REFLECTION_LINEAR = !1,
- i.IS_REFRACTION_LINEAR = !1,
- i.EXPOSURE = !1,
- i.rebuild(),
- i
- }
- return e.prototype.setReflectionMode = function(i) {
- 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++) {
- var d = c[s];
- this[d] = d === i
- }
- }
- ,
- e
- }(MaterialDefines)
- , StandardMaterial = function(a) {
- __extends(e, a);
- function e(i, o) {
- var s = a.call(this, i, o) || this;
- return s._diffuseTexture = null,
- s._ambientTexture = null,
- s._opacityTexture = null,
- s._reflectionTexture = null,
- s._emissiveTexture = null,
- s._specularTexture = null,
- s._bumpTexture = null,
- s._lightmapTexture = null,
- s._refractionTexture = null,
- s.ambientColor = new Color3(0,0,0),
- s.diffuseColor = new Color3(1,1,1),
- s.specularColor = new Color3(1,1,1),
- s.emissiveColor = new Color3(0,0,0),
- s.specularPower = 64,
- s._useAlphaFromDiffuseTexture = !1,
- s._useEmissiveAsIllumination = !1,
- s._linkEmissiveWithDiffuse = !1,
- s._useSpecularOverAlpha = !1,
- s._useReflectionOverAlpha = !1,
- s._disableLighting = !1,
- s._useObjectSpaceNormalMap = !1,
- s._useParallax = !1,
- s._useParallaxOcclusion = !1,
- s.parallaxScaleBias = .05,
- s._roughness = 0,
- s.indexOfRefraction = .98,
- s.invertRefractionY = !0,
- s.alphaCutOff = .4,
- s._useLightmapAsShadowmap = !1,
- s._useReflectionFresnelFromSpecular = !1,
- s._useGlossinessFromSpecularMapAlpha = !1,
- s._maxSimultaneousLights = 4,
- s._invertNormalMapX = !1,
- s._invertNormalMapY = !1,
- s._twoSidedLighting = !1,
- s.detailMap = new DetailMapConfiguration(s._markAllSubMeshesAsTexturesDirty.bind(s)),
- s._renderTargets = new SmartArray(16),
- s._worldViewProjectionMatrix = Matrix.Zero(),
- s._globalAmbientColor = new Color3(0,0,0),
- s.buildUniformLayout(),
- s._attachImageProcessingConfiguration(null),
- s.prePassConfiguration = new PrePassConfiguration,
- s.getRenderTargetTextures = function() {
- return s._renderTargets.reset(),
- e.ReflectionTextureEnabled && s._reflectionTexture && s._reflectionTexture.isRenderTarget && s._renderTargets.push(s._reflectionTexture),
- e.RefractionTextureEnabled && s._refractionTexture && s._refractionTexture.isRenderTarget && s._renderTargets.push(s._refractionTexture),
- s._renderTargets
- }
- ,
- s
- }
- return Object.defineProperty(e.prototype, "imageProcessingConfiguration", {
- get: function() {
- return this._imageProcessingConfiguration
- },
- set: function(i) {
- this._attachImageProcessingConfiguration(i),
- this._markAllSubMeshesAsTexturesDirty()
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._attachImageProcessingConfiguration = function(i) {
- var o = this;
- i !== this._imageProcessingConfiguration && (this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
- i ? this._imageProcessingConfiguration = i : this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration,
- this._imageProcessingConfiguration && (this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function() {
- o._markAllSubMeshesAsImageProcessingDirty()
- })))
- }
- ,
- Object.defineProperty(e.prototype, "isPrePassCapable", {
- get: function() {
- return !this.disableDepthWrite
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cameraColorCurvesEnabled", {
- get: function() {
- return this.imageProcessingConfiguration.colorCurvesEnabled
- },
- set: function(i) {
- this.imageProcessingConfiguration.colorCurvesEnabled = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cameraColorGradingEnabled", {
- get: function() {
- return this.imageProcessingConfiguration.colorGradingEnabled
- },
- set: function(i) {
- this.imageProcessingConfiguration.colorGradingEnabled = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cameraToneMappingEnabled", {
- get: function() {
- return this._imageProcessingConfiguration.toneMappingEnabled
- },
- set: function(i) {
- this._imageProcessingConfiguration.toneMappingEnabled = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cameraExposure", {
- get: function() {
- return this._imageProcessingConfiguration.exposure
- },
- set: function(i) {
- this._imageProcessingConfiguration.exposure = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cameraContrast", {
- get: function() {
- return this._imageProcessingConfiguration.contrast
- },
- set: function(i) {
- this._imageProcessingConfiguration.contrast = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cameraColorGradingTexture", {
- get: function() {
- return this._imageProcessingConfiguration.colorGradingTexture
- },
- set: function(i) {
- this._imageProcessingConfiguration.colorGradingTexture = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cameraColorCurves", {
- get: function() {
- return this._imageProcessingConfiguration.colorCurves
- },
- set: function(i) {
- this._imageProcessingConfiguration.colorCurves = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "canRenderToMRT", {
- get: function() {
- return !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "hasRenderTargetTextures", {
- get: function() {
- return !!(e.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget || e.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getClassName = function() {
- return "StandardMaterial"
- }
- ,
- Object.defineProperty(e.prototype, "useLogarithmicDepth", {
- get: function() {
- return this._useLogarithmicDepth
- },
- set: function(i) {
- this._useLogarithmicDepth = i && this.getScene().getEngine().getCaps().fragmentDepthSupported,
- this._markAllSubMeshesAsMiscDirty()
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.needAlphaBlending = function() {
- return this._disableAlphaBlending ? !1 : this.alpha < 1 || this._opacityTexture != null || this._shouldUseAlphaFromDiffuseTexture() || this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled
- }
- ,
- e.prototype.needAlphaTesting = function() {
- return this._forceAlphaTest ? !0 : this._hasAlphaChannel() && (this._transparencyMode == null || this._transparencyMode === Material.MATERIAL_ALPHATEST)
- }
- ,
- e.prototype._shouldUseAlphaFromDiffuseTexture = function() {
- return this._diffuseTexture != null && this._diffuseTexture.hasAlpha && this._useAlphaFromDiffuseTexture && this._transparencyMode !== Material.MATERIAL_OPAQUE
- }
- ,
- e.prototype._hasAlphaChannel = function() {
- return this._diffuseTexture != null && this._diffuseTexture.hasAlpha || this._opacityTexture != null
- }
- ,
- e.prototype.getAlphaTestTexture = function() {
- return this._diffuseTexture
- }
- ,
- e.prototype.isReadyForSubMesh = function(i, o, s) {
- if (s === void 0 && (s = !1),
- o.effect && this.isFrozen && o.effect._wasPreviouslyReady)
- return !0;
- o.materialDefines || (o.materialDefines = new StandardMaterialDefines);
- var c = this.getScene()
- , d = o.materialDefines;
- if (this._isReadyForSubMesh(o))
- return !0;
- var _ = c.getEngine();
- d._needNormals = MaterialHelper.PrepareDefinesForLights(c, i, d, !0, this._maxSimultaneousLights, this._disableLighting),
- MaterialHelper.PrepareDefinesForMultiview(c, d);
- var b = this.needAlphaBlendingForMesh(i) && this.getScene().useOrderIndependentTransparency;
- if (MaterialHelper.PrepareDefinesForPrePass(c, d, this.canRenderToMRT && !b),
- MaterialHelper.PrepareDefinesForOIT(c, d, b),
- d._areTexturesDirty) {
- d._needUVs = !1;
- for (var k = 1; k <= 6; ++k)
- d["MAINUV" + k] = !1;
- if (c.texturesEnabled) {
- if (this._diffuseTexture && e.DiffuseTextureEnabled)
- if (this._diffuseTexture.isReadyOrNotBlocking())
- MaterialHelper.PrepareDefinesForMergedUV(this._diffuseTexture, d, "DIFFUSE");
- else
- return !1;
- else
- d.DIFFUSE = !1;
- if (this._ambientTexture && e.AmbientTextureEnabled)
- if (this._ambientTexture.isReadyOrNotBlocking())
- MaterialHelper.PrepareDefinesForMergedUV(this._ambientTexture, d, "AMBIENT");
- else
- return !1;
- else
- d.AMBIENT = !1;
- if (this._opacityTexture && e.OpacityTextureEnabled)
- if (this._opacityTexture.isReadyOrNotBlocking())
- MaterialHelper.PrepareDefinesForMergedUV(this._opacityTexture, d, "OPACITY"),
- d.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
- else
- return !1;
- else
- d.OPACITY = !1;
- if (this._reflectionTexture && e.ReflectionTextureEnabled)
- if (this._reflectionTexture.isReadyOrNotBlocking()) {
- switch (d._needNormals = !0,
- d.REFLECTION = !0,
- d.ROUGHNESS = this._roughness > 0,
- d.REFLECTIONOVERALPHA = this._useReflectionOverAlpha,
- d.INVERTCUBICMAP = this._reflectionTexture.coordinatesMode === Texture.INVCUBIC_MODE,
- d.REFLECTIONMAP_3D = this._reflectionTexture.isCube,
- d.RGBDREFLECTION = this._reflectionTexture.isRGBD,
- d.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !this._reflectionTexture.invertZ : this._reflectionTexture.invertZ,
- this._reflectionTexture.coordinatesMode) {
- case Texture.EXPLICIT_MODE:
- d.setReflectionMode("REFLECTIONMAP_EXPLICIT");
- break;
- case Texture.PLANAR_MODE:
- d.setReflectionMode("REFLECTIONMAP_PLANAR");
- break;
- case Texture.PROJECTION_MODE:
- d.setReflectionMode("REFLECTIONMAP_PROJECTION");
- break;
- case Texture.SKYBOX_MODE:
- d.setReflectionMode("REFLECTIONMAP_SKYBOX");
- break;
- case Texture.SPHERICAL_MODE:
- d.setReflectionMode("REFLECTIONMAP_SPHERICAL");
- break;
- case Texture.EQUIRECTANGULAR_MODE:
- d.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");
- break;
- case Texture.FIXED_EQUIRECTANGULAR_MODE:
- d.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");
- break;
- case Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
- d.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");
- break;
- case Texture.CUBIC_MODE:
- case Texture.INVCUBIC_MODE:
- default:
- d.setReflectionMode("REFLECTIONMAP_CUBIC");
- break
- }
- d.USE_LOCAL_REFLECTIONMAP_CUBIC = !!this._reflectionTexture.boundingBoxSize
- } else
- return !1;
- else
- d.REFLECTION = !1,
- d.REFLECTIONMAP_OPPOSITEZ = !1;
- if (this._emissiveTexture && e.EmissiveTextureEnabled)
- if (this._emissiveTexture.isReadyOrNotBlocking())
- MaterialHelper.PrepareDefinesForMergedUV(this._emissiveTexture, d, "EMISSIVE");
- else
- return !1;
- else
- d.EMISSIVE = !1;
- if (this._lightmapTexture && e.LightmapTextureEnabled)
- if (this._lightmapTexture.isReadyOrNotBlocking())
- MaterialHelper.PrepareDefinesForMergedUV(this._lightmapTexture, d, "LIGHTMAP"),
- d.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap,
- d.RGBDLIGHTMAP = this._lightmapTexture.isRGBD;
- else
- return !1;
- else
- d.LIGHTMAP = !1;
- if (this._specularTexture && e.SpecularTextureEnabled)
- if (this._specularTexture.isReadyOrNotBlocking())
- MaterialHelper.PrepareDefinesForMergedUV(this._specularTexture, d, "SPECULAR"),
- d.GLOSSINESS = this._useGlossinessFromSpecularMapAlpha;
- else
- return !1;
- else
- d.SPECULAR = !1;
- if (c.getEngine().getCaps().standardDerivatives && this._bumpTexture && e.BumpTextureEnabled) {
- if (this._bumpTexture.isReady())
- MaterialHelper.PrepareDefinesForMergedUV(this._bumpTexture, d, "BUMP"),
- d.PARALLAX = this._useParallax,
- d.PARALLAXOCCLUSION = this._useParallaxOcclusion;
- else
- return !1;
- d.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap
- } else
- d.BUMP = !1;
- if (this._refractionTexture && e.RefractionTextureEnabled)
- if (this._refractionTexture.isReadyOrNotBlocking())
- d._needUVs = !0,
- d.REFRACTION = !0,
- d.REFRACTIONMAP_3D = this._refractionTexture.isCube,
- d.RGBDREFRACTION = this._refractionTexture.isRGBD,
- d.USE_LOCAL_REFRACTIONMAP_CUBIC = !!this._refractionTexture.boundingBoxSize;
- else
- return !1;
- else
- d.REFRACTION = !1;
- d.TWOSIDEDLIGHTING = !this._backFaceCulling && this._twoSidedLighting
- } else
- d.DIFFUSE = !1,
- d.AMBIENT = !1,
- d.OPACITY = !1,
- d.REFLECTION = !1,
- d.EMISSIVE = !1,
- d.LIGHTMAP = !1,
- d.BUMP = !1,
- d.REFRACTION = !1;
- d.ALPHAFROMDIFFUSE = this._shouldUseAlphaFromDiffuseTexture(),
- d.EMISSIVEASILLUMINATION = this._useEmissiveAsIllumination,
- d.LINKEMISSIVEWITHDIFFUSE = this._linkEmissiveWithDiffuse,
- d.SPECULAROVERALPHA = this._useSpecularOverAlpha,
- d.PREMULTIPLYALPHA = this.alphaMode === 7 || this.alphaMode === 8,
- d.ALPHATEST_AFTERALLALPHACOMPUTATIONS = this.transparencyMode !== null,
- d.ALPHABLEND = this.transparencyMode === null || this.needAlphaBlendingForMesh(i)
- }
- if (!this.detailMap.isReadyForSubMesh(d, c))
- return !1;
- if (d._areImageProcessingDirty && this._imageProcessingConfiguration) {
- if (!this._imageProcessingConfiguration.isReady())
- return !1;
- this._imageProcessingConfiguration.prepareDefines(d),
- d.IS_REFLECTION_LINEAR = this.reflectionTexture != null && !this.reflectionTexture.gammaSpace,
- d.IS_REFRACTION_LINEAR = this.refractionTexture != null && !this.refractionTexture.gammaSpace
- }
- if (d._areFresnelDirty && (e.FresnelEnabled ? (this._diffuseFresnelParameters || this._opacityFresnelParameters || this._emissiveFresnelParameters || this._refractionFresnelParameters || this._reflectionFresnelParameters) && (d.DIFFUSEFRESNEL = this._diffuseFresnelParameters && this._diffuseFresnelParameters.isEnabled,
- d.OPACITYFRESNEL = this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled,
- d.REFLECTIONFRESNEL = this._reflectionFresnelParameters && this._reflectionFresnelParameters.isEnabled,
- d.REFLECTIONFRESNELFROMSPECULAR = this._useReflectionFresnelFromSpecular,
- d.REFRACTIONFRESNEL = this._refractionFresnelParameters && this._refractionFresnelParameters.isEnabled,
- d.EMISSIVEFRESNEL = this._emissiveFresnelParameters && this._emissiveFresnelParameters.isEnabled,
- d._needNormals = !0,
- d.FRESNEL = !0) : d.FRESNEL = !1),
- MaterialHelper.PrepareDefinesForMisc(i, c, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(i) || this._forceAlphaTest, d),
- MaterialHelper.PrepareDefinesForAttributes(i, d, !0, !0, !0),
- MaterialHelper.PrepareDefinesForFrameBoundValues(c, _, d, s, null, o.getRenderingMesh().hasThinInstances),
- this.detailMap.prepareDefines(d, c),
- d.isDirty) {
- var j = d._areLightsDisposed;
- d.markAsProcessed();
- var $ = new EffectFallbacks;
- d.REFLECTION && $.addFallback(0, "REFLECTION"),
- d.SPECULAR && $.addFallback(0, "SPECULAR"),
- d.BUMP && $.addFallback(0, "BUMP"),
- d.PARALLAX && $.addFallback(1, "PARALLAX"),
- d.PARALLAXOCCLUSION && $.addFallback(0, "PARALLAXOCCLUSION"),
- d.SPECULAROVERALPHA && $.addFallback(0, "SPECULAROVERALPHA"),
- d.FOG && $.addFallback(1, "FOG"),
- d.POINTSIZE && $.addFallback(0, "POINTSIZE"),
- d.LOGARITHMICDEPTH && $.addFallback(0, "LOGARITHMICDEPTH"),
- MaterialHelper.HandleFallbacksForShadows(d, $, this._maxSimultaneousLights),
- d.SPECULARTERM && $.addFallback(0, "SPECULARTERM"),
- d.DIFFUSEFRESNEL && $.addFallback(1, "DIFFUSEFRESNEL"),
- d.OPACITYFRESNEL && $.addFallback(2, "OPACITYFRESNEL"),
- d.REFLECTIONFRESNEL && $.addFallback(3, "REFLECTIONFRESNEL"),
- d.EMISSIVEFRESNEL && $.addFallback(4, "EMISSIVEFRESNEL"),
- d.FRESNEL && $.addFallback(4, "FRESNEL"),
- d.MULTIVIEW && $.addFallback(0, "MULTIVIEW");
- var _e = [VertexBuffer.PositionKind];
- d.NORMAL && _e.push(VertexBuffer.NormalKind),
- d.TANGENT && _e.push(VertexBuffer.TangentKind);
- for (var k = 1; k <= 6; ++k)
- d["UV" + k] && _e.push("uv" + (k === 1 ? "" : k));
- d.VERTEXCOLOR && _e.push(VertexBuffer.ColorKind),
- MaterialHelper.PrepareAttributesForBones(_e, i, d, $),
- MaterialHelper.PrepareAttributesForInstances(_e, d),
- MaterialHelper.PrepareAttributesForMorphTargets(_e, i, d),
- MaterialHelper.PrepareAttributesForBakedVertexAnimation(_e, i, d);
- var et = "default"
- , 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"]
- , rt = ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler", "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler", "refractionCubeSampler", "refraction2DSampler", "boneSampler", "morphTargets", "oitDepthSampler", "oitFrontColorSampler"]
- , it = ["Material", "Scene", "Mesh"];
- DetailMapConfiguration.AddUniforms(tt),
- DetailMapConfiguration.AddSamplers(rt),
- PrePassConfiguration.AddUniforms(tt),
- PrePassConfiguration.AddSamplers(rt),
- ImageProcessingConfiguration && (ImageProcessingConfiguration.PrepareUniforms(tt, d),
- ImageProcessingConfiguration.PrepareSamplers(rt, d)),
- MaterialHelper.PrepareUniformsAndSamplersList({
- uniformsNames: tt,
- uniformBuffersNames: it,
- samplers: rt,
- defines: d,
- maxSimultaneousLights: this._maxSimultaneousLights
- });
- var nt = {};
- this.customShaderNameResolve && (et = this.customShaderNameResolve(et, tt, it, rt, d, _e, nt));
- var ot = d.toString()
- , at = o.effect
- , st = c.getEngine().createEffect(et, {
- attributes: _e,
- uniformsNames: tt,
- uniformBuffersNames: it,
- samplers: rt,
- defines: ot,
- fallbacks: $,
- onCompiled: this.onCompiled,
- onError: this.onError,
- indexParameters: {
- maxSimultaneousLights: this._maxSimultaneousLights,
- maxSimultaneousMorphTargets: d.NUM_MORPH_INFLUENCERS
- },
- processFinalCode: nt.processFinalCode,
- multiTarget: d.PREPASS
- }, _);
- if (st)
- if (this._onEffectCreatedObservable && (onCreatedEffectParameters$2.effect = st,
- onCreatedEffectParameters$2.subMesh = o,
- this._onEffectCreatedObservable.notifyObservers(onCreatedEffectParameters$2)),
- this.allowShaderHotSwapping && at && !st.isReady()) {
- if (st = at,
- d.markAsUnprocessed(),
- j)
- return d._areLightsDisposed = !0,
- !1
- } else
- c.resetCachedMaterial(),
- o.setEffect(st, d, this._materialContext)
- }
- return !o.effect || !o.effect.isReady() ? !1 : (d._renderId = c.getRenderId(),
- o.effect._wasPreviouslyReady = !0,
- !0)
- }
- ,
- e.prototype.buildUniformLayout = function() {
- var i = this._uniformBuffer;
- i.addUniform("diffuseLeftColor", 4),
- i.addUniform("diffuseRightColor", 4),
- i.addUniform("opacityParts", 4),
- i.addUniform("reflectionLeftColor", 4),
- i.addUniform("reflectionRightColor", 4),
- i.addUniform("refractionLeftColor", 4),
- i.addUniform("refractionRightColor", 4),
- i.addUniform("emissiveLeftColor", 4),
- i.addUniform("emissiveRightColor", 4),
- i.addUniform("vDiffuseInfos", 2),
- i.addUniform("vAmbientInfos", 2),
- i.addUniform("vOpacityInfos", 2),
- i.addUniform("vReflectionInfos", 2),
- i.addUniform("vReflectionPosition", 3),
- i.addUniform("vReflectionSize", 3),
- i.addUniform("vEmissiveInfos", 2),
- i.addUniform("vLightmapInfos", 2),
- i.addUniform("vSpecularInfos", 2),
- i.addUniform("vBumpInfos", 3),
- i.addUniform("diffuseMatrix", 16),
- i.addUniform("ambientMatrix", 16),
- i.addUniform("opacityMatrix", 16),
- i.addUniform("reflectionMatrix", 16),
- i.addUniform("emissiveMatrix", 16),
- i.addUniform("lightmapMatrix", 16),
- i.addUniform("specularMatrix", 16),
- i.addUniform("bumpMatrix", 16),
- i.addUniform("vTangentSpaceParams", 2),
- i.addUniform("pointSize", 1),
- i.addUniform("alphaCutOff", 1),
- i.addUniform("refractionMatrix", 16),
- i.addUniform("vRefractionInfos", 4),
- i.addUniform("vRefractionPosition", 3),
- i.addUniform("vRefractionSize", 3),
- i.addUniform("vSpecularColor", 4),
- i.addUniform("vEmissiveColor", 3),
- i.addUniform("vDiffuseColor", 4),
- i.addUniform("vAmbientColor", 3),
- DetailMapConfiguration.PrepareUniformBuffer(i),
- i.create()
- }
- ,
- e.prototype.unbind = function() {
- if (this._activeEffect && !this.getScene().getEngine()._features.needToAlwaysBindUniformBuffers) {
- var i = !1;
- this._reflectionTexture && this._reflectionTexture.isRenderTarget && (this._activeEffect.setTexture("reflection2DSampler", null),
- i = !0),
- this._refractionTexture && this._refractionTexture.isRenderTarget && (this._activeEffect.setTexture("refraction2DSampler", null),
- i = !0),
- i && this._markAllSubMeshesAsTexturesDirty()
- }
- a.prototype.unbind.call(this)
- }
- ,
- e.prototype.bindForSubMesh = function(i, o, s) {
- var c, d = this.getScene(), _ = s.materialDefines;
- if (!!_) {
- var b = s.effect;
- if (!!b) {
- this._activeEffect = b,
- o.getMeshUniformBuffer().bindToEffect(b, "Mesh"),
- o.transferToEffect(i),
- this.prePassConfiguration.bindForSubMesh(this._activeEffect, d, o, i, this.isFrozen),
- _.OBJECTSPACE_NORMALMAP && (i.toNormalMatrix(this._normalMatrix),
- this.bindOnlyNormalMatrix(this._normalMatrix));
- var k = this._mustRebind(d, b, o.visibility);
- MaterialHelper.BindBonesParameters(o, b);
- var j = this._uniformBuffer;
- if (k) {
- if (j.bindToEffect(b, "Material"),
- this.bindViewProjection(b),
- !j.useUbo || !this.isFrozen || !j.isSync) {
- if (e.FresnelEnabled && _.FRESNEL && (this.diffuseFresnelParameters && this.diffuseFresnelParameters.isEnabled && (j.updateColor4("diffuseLeftColor", this.diffuseFresnelParameters.leftColor, this.diffuseFresnelParameters.power),
- j.updateColor4("diffuseRightColor", this.diffuseFresnelParameters.rightColor, this.diffuseFresnelParameters.bias)),
- this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled && j.updateColor4("opacityParts", new Color3(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias), this.opacityFresnelParameters.power),
- this.reflectionFresnelParameters && this.reflectionFresnelParameters.isEnabled && (j.updateColor4("reflectionLeftColor", this.reflectionFresnelParameters.leftColor, this.reflectionFresnelParameters.power),
- j.updateColor4("reflectionRightColor", this.reflectionFresnelParameters.rightColor, this.reflectionFresnelParameters.bias)),
- this.refractionFresnelParameters && this.refractionFresnelParameters.isEnabled && (j.updateColor4("refractionLeftColor", this.refractionFresnelParameters.leftColor, this.refractionFresnelParameters.power),
- j.updateColor4("refractionRightColor", this.refractionFresnelParameters.rightColor, this.refractionFresnelParameters.bias)),
- this.emissiveFresnelParameters && this.emissiveFresnelParameters.isEnabled && (j.updateColor4("emissiveLeftColor", this.emissiveFresnelParameters.leftColor, this.emissiveFresnelParameters.power),
- j.updateColor4("emissiveRightColor", this.emissiveFresnelParameters.rightColor, this.emissiveFresnelParameters.bias))),
- d.texturesEnabled) {
- if (this._diffuseTexture && e.DiffuseTextureEnabled && (j.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level),
- MaterialHelper.BindTextureMatrix(this._diffuseTexture, j, "diffuse")),
- this._ambientTexture && e.AmbientTextureEnabled && (j.updateFloat2("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level),
- MaterialHelper.BindTextureMatrix(this._ambientTexture, j, "ambient")),
- this._opacityTexture && e.OpacityTextureEnabled && (j.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level),
- MaterialHelper.BindTextureMatrix(this._opacityTexture, j, "opacity")),
- this._hasAlphaChannel() && j.updateFloat("alphaCutOff", this.alphaCutOff),
- this._reflectionTexture && e.ReflectionTextureEnabled && (j.updateFloat2("vReflectionInfos", this._reflectionTexture.level, this.roughness),
- j.updateMatrix("reflectionMatrix", this._reflectionTexture.getReflectionTextureMatrix()),
- this._reflectionTexture.boundingBoxSize)) {
- var $ = this._reflectionTexture;
- j.updateVector3("vReflectionPosition", $.boundingBoxPosition),
- j.updateVector3("vReflectionSize", $.boundingBoxSize)
- }
- if (this._emissiveTexture && e.EmissiveTextureEnabled && (j.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level),
- MaterialHelper.BindTextureMatrix(this._emissiveTexture, j, "emissive")),
- this._lightmapTexture && e.LightmapTextureEnabled && (j.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level),
- MaterialHelper.BindTextureMatrix(this._lightmapTexture, j, "lightmap")),
- this._specularTexture && e.SpecularTextureEnabled && (j.updateFloat2("vSpecularInfos", this._specularTexture.coordinatesIndex, this._specularTexture.level),
- MaterialHelper.BindTextureMatrix(this._specularTexture, j, "specular")),
- this._bumpTexture && d.getEngine().getCaps().standardDerivatives && e.BumpTextureEnabled && (j.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, 1 / this._bumpTexture.level, this.parallaxScaleBias),
- MaterialHelper.BindTextureMatrix(this._bumpTexture, j, "bump"),
- d._mirroredCameraPosition ? j.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1 : -1, this._invertNormalMapY ? 1 : -1) : j.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1 : 1, this._invertNormalMapY ? -1 : 1)),
- this._refractionTexture && e.RefractionTextureEnabled) {
- var _e = 1;
- if (this._refractionTexture.isCube || (j.updateMatrix("refractionMatrix", this._refractionTexture.getReflectionTextureMatrix()),
- this._refractionTexture.depth && (_e = this._refractionTexture.depth)),
- j.updateFloat4("vRefractionInfos", this._refractionTexture.level, this.indexOfRefraction, _e, this.invertRefractionY ? -1 : 1),
- this._refractionTexture.boundingBoxSize) {
- var $ = this._refractionTexture;
- j.updateVector3("vRefractionPosition", $.boundingBoxPosition),
- j.updateVector3("vRefractionSize", $.boundingBoxSize)
- }
- }
- }
- this.pointsCloud && j.updateFloat("pointSize", this.pointSize),
- _.SPECULARTERM && j.updateColor4("vSpecularColor", this.specularColor, this.specularPower),
- j.updateColor3("vEmissiveColor", e.EmissiveTextureEnabled ? this.emissiveColor : Color3.BlackReadOnly),
- j.updateColor4("vDiffuseColor", this.diffuseColor, this.alpha),
- d.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor),
- j.updateColor3("vAmbientColor", this._globalAmbientColor)
- }
- if (d.texturesEnabled && (this._diffuseTexture && e.DiffuseTextureEnabled && b.setTexture("diffuseSampler", this._diffuseTexture),
- this._ambientTexture && e.AmbientTextureEnabled && b.setTexture("ambientSampler", this._ambientTexture),
- this._opacityTexture && e.OpacityTextureEnabled && b.setTexture("opacitySampler", this._opacityTexture),
- this._reflectionTexture && e.ReflectionTextureEnabled && (this._reflectionTexture.isCube ? b.setTexture("reflectionCubeSampler", this._reflectionTexture) : b.setTexture("reflection2DSampler", this._reflectionTexture)),
- this._emissiveTexture && e.EmissiveTextureEnabled && b.setTexture("emissiveSampler", this._emissiveTexture),
- this._lightmapTexture && e.LightmapTextureEnabled && b.setTexture("lightmapSampler", this._lightmapTexture),
- this._specularTexture && e.SpecularTextureEnabled && b.setTexture("specularSampler", this._specularTexture),
- this._bumpTexture && d.getEngine().getCaps().standardDerivatives && e.BumpTextureEnabled && b.setTexture("bumpSampler", this._bumpTexture),
- this._refractionTexture && e.RefractionTextureEnabled)) {
- var _e = 1;
- this._refractionTexture.isCube ? b.setTexture("refractionCubeSampler", this._refractionTexture) : b.setTexture("refraction2DSampler", this._refractionTexture)
- }
- this.getScene().useOrderIndependentTransparency && this.needAlphaBlendingForMesh(o) && this.getScene().depthPeelingRenderer.bind(b),
- this.detailMap.bindForSubMesh(j, d, this.isFrozen),
- MaterialHelper.BindClipPlane(b, d),
- this.bindEyePosition(b)
- } else
- d.getEngine()._features.needToAlwaysBindUniformBuffers && (j.bindToEffect(b, "Material"),
- this._needToBindSceneUbo = !0);
- (k || !this.isFrozen) && (d.lightsEnabled && !this._disableLighting && MaterialHelper.BindLights(d, o, b, _, this._maxSimultaneousLights),
- (d.fogEnabled && o.applyFog && d.fogMode !== Scene.FOGMODE_NONE || this._reflectionTexture || this._refractionTexture || o.receiveShadows) && this.bindView(b),
- MaterialHelper.BindFogParameters(d, o, b),
- _.NUM_MORPH_INFLUENCERS && MaterialHelper.BindMorphTargetParameters(o, b),
- _.BAKED_VERTEX_ANIMATION_TEXTURE && ((c = o.bakedVertexAnimationManager) === null || c === void 0 || c.bind(b, _.INSTANCES)),
- this.useLogarithmicDepth && MaterialHelper.BindLogDepth(_, b, d),
- this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess && this._imageProcessingConfiguration.bind(this._activeEffect)),
- this._afterBind(o, this._activeEffect),
- j.update()
- }
- }
- }
- ,
- e.prototype.getAnimatables = function() {
- var i = [];
- return this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0 && i.push(this._diffuseTexture),
- this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0 && i.push(this._ambientTexture),
- this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0 && i.push(this._opacityTexture),
- this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0 && i.push(this._reflectionTexture),
- this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0 && i.push(this._emissiveTexture),
- this._specularTexture && this._specularTexture.animations && this._specularTexture.animations.length > 0 && i.push(this._specularTexture),
- this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0 && i.push(this._bumpTexture),
- this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0 && i.push(this._lightmapTexture),
- this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0 && i.push(this._refractionTexture),
- this.detailMap.getAnimatables(i),
- i
- }
- ,
- e.prototype.getActiveTextures = function() {
- var i = a.prototype.getActiveTextures.call(this);
- return this._diffuseTexture && i.push(this._diffuseTexture),
- this._ambientTexture && i.push(this._ambientTexture),
- this._opacityTexture && i.push(this._opacityTexture),
- this._reflectionTexture && i.push(this._reflectionTexture),
- this._emissiveTexture && i.push(this._emissiveTexture),
- this._specularTexture && i.push(this._specularTexture),
- this._bumpTexture && i.push(this._bumpTexture),
- this._lightmapTexture && i.push(this._lightmapTexture),
- this._refractionTexture && i.push(this._refractionTexture),
- this.detailMap.getActiveTextures(i),
- i
- }
- ,
- e.prototype.hasTexture = function(i) {
- 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))
- }
- ,
- e.prototype.dispose = function(i, o) {
- var s, c, d, _, b, k, j, $, _e;
- o && ((s = this._diffuseTexture) === null || s === void 0 || s.dispose(),
- (c = this._ambientTexture) === null || c === void 0 || c.dispose(),
- (d = this._opacityTexture) === null || d === void 0 || d.dispose(),
- (_ = this._reflectionTexture) === null || _ === void 0 || _.dispose(),
- (b = this._emissiveTexture) === null || b === void 0 || b.dispose(),
- (k = this._specularTexture) === null || k === void 0 || k.dispose(),
- (j = this._bumpTexture) === null || j === void 0 || j.dispose(),
- ($ = this._lightmapTexture) === null || $ === void 0 || $.dispose(),
- (_e = this._refractionTexture) === null || _e === void 0 || _e.dispose()),
- this.detailMap.dispose(o),
- this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
- a.prototype.dispose.call(this, i, o)
- }
- ,
- e.prototype.clone = function(i) {
- var o = this
- , s = SerializationHelper.Clone(function() {
- return new e(i,o.getScene())
- }, this);
- return s.name = i,
- s.id = i,
- this.stencil.copyTo(s.stencil),
- s
- }
- ,
- e.prototype.serialize = function() {
- var i = SerializationHelper.Serialize(this);
- return i.stencil = this.stencil.serialize(),
- i
- }
- ,
- e.Parse = function(i, o, s) {
- var c = SerializationHelper.Parse(function() {
- return new e(i.name,o)
- }, i, o, s);
- return i.stencil && c.stencil.parse(i.stencil, o, s),
- c
- }
- ,
- Object.defineProperty(e, "DiffuseTextureEnabled", {
- get: function() {
- return MaterialFlags.DiffuseTextureEnabled
- },
- set: function(i) {
- MaterialFlags.DiffuseTextureEnabled = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "DetailTextureEnabled", {
- get: function() {
- return MaterialFlags.DetailTextureEnabled
- },
- set: function(i) {
- MaterialFlags.DetailTextureEnabled = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "AmbientTextureEnabled", {
- get: function() {
- return MaterialFlags.AmbientTextureEnabled
- },
- set: function(i) {
- MaterialFlags.AmbientTextureEnabled = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "OpacityTextureEnabled", {
- get: function() {
- return MaterialFlags.OpacityTextureEnabled
- },
- set: function(i) {
- MaterialFlags.OpacityTextureEnabled = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "ReflectionTextureEnabled", {
- get: function() {
- return MaterialFlags.ReflectionTextureEnabled
- },
- set: function(i) {
- MaterialFlags.ReflectionTextureEnabled = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "EmissiveTextureEnabled", {
- get: function() {
- return MaterialFlags.EmissiveTextureEnabled
- },
- set: function(i) {
- MaterialFlags.EmissiveTextureEnabled = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "SpecularTextureEnabled", {
- get: function() {
- return MaterialFlags.SpecularTextureEnabled
- },
- set: function(i) {
- MaterialFlags.SpecularTextureEnabled = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "BumpTextureEnabled", {
- get: function() {
- return MaterialFlags.BumpTextureEnabled
- },
- set: function(i) {
- MaterialFlags.BumpTextureEnabled = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "LightmapTextureEnabled", {
- get: function() {
- return MaterialFlags.LightmapTextureEnabled
- },
- set: function(i) {
- MaterialFlags.LightmapTextureEnabled = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "RefractionTextureEnabled", {
- get: function() {
- return MaterialFlags.RefractionTextureEnabled
- },
- set: function(i) {
- MaterialFlags.RefractionTextureEnabled = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "ColorGradingTextureEnabled", {
- get: function() {
- return MaterialFlags.ColorGradingTextureEnabled
- },
- set: function(i) {
- MaterialFlags.ColorGradingTextureEnabled = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "FresnelEnabled", {
- get: function() {
- return MaterialFlags.FresnelEnabled
- },
- set: function(i) {
- MaterialFlags.FresnelEnabled = i
- },
- enumerable: !1,
- configurable: !0
- }),
- __decorate([serializeAsTexture("diffuseTexture")], e.prototype, "_diffuseTexture", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")], e.prototype, "diffuseTexture", void 0),
- __decorate([serializeAsTexture("ambientTexture")], e.prototype, "_ambientTexture", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "ambientTexture", void 0),
- __decorate([serializeAsTexture("opacityTexture")], e.prototype, "_opacityTexture", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")], e.prototype, "opacityTexture", void 0),
- __decorate([serializeAsTexture("reflectionTexture")], e.prototype, "_reflectionTexture", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "reflectionTexture", void 0),
- __decorate([serializeAsTexture("emissiveTexture")], e.prototype, "_emissiveTexture", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "emissiveTexture", void 0),
- __decorate([serializeAsTexture("specularTexture")], e.prototype, "_specularTexture", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "specularTexture", void 0),
- __decorate([serializeAsTexture("bumpTexture")], e.prototype, "_bumpTexture", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "bumpTexture", void 0),
- __decorate([serializeAsTexture("lightmapTexture")], e.prototype, "_lightmapTexture", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "lightmapTexture", void 0),
- __decorate([serializeAsTexture("refractionTexture")], e.prototype, "_refractionTexture", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "refractionTexture", void 0),
- __decorate([serializeAsColor3("ambient")], e.prototype, "ambientColor", void 0),
- __decorate([serializeAsColor3("diffuse")], e.prototype, "diffuseColor", void 0),
- __decorate([serializeAsColor3("specular")], e.prototype, "specularColor", void 0),
- __decorate([serializeAsColor3("emissive")], e.prototype, "emissiveColor", void 0),
- __decorate([serialize()], e.prototype, "specularPower", void 0),
- __decorate([serialize("useAlphaFromDiffuseTexture")], e.prototype, "_useAlphaFromDiffuseTexture", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")], e.prototype, "useAlphaFromDiffuseTexture", void 0),
- __decorate([serialize("useEmissiveAsIllumination")], e.prototype, "_useEmissiveAsIllumination", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useEmissiveAsIllumination", void 0),
- __decorate([serialize("linkEmissiveWithDiffuse")], e.prototype, "_linkEmissiveWithDiffuse", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "linkEmissiveWithDiffuse", void 0),
- __decorate([serialize("useSpecularOverAlpha")], e.prototype, "_useSpecularOverAlpha", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useSpecularOverAlpha", void 0),
- __decorate([serialize("useReflectionOverAlpha")], e.prototype, "_useReflectionOverAlpha", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useReflectionOverAlpha", void 0),
- __decorate([serialize("disableLighting")], e.prototype, "_disableLighting", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsLightsDirty")], e.prototype, "disableLighting", void 0),
- __decorate([serialize("useObjectSpaceNormalMap")], e.prototype, "_useObjectSpaceNormalMap", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useObjectSpaceNormalMap", void 0),
- __decorate([serialize("useParallax")], e.prototype, "_useParallax", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useParallax", void 0),
- __decorate([serialize("useParallaxOcclusion")], e.prototype, "_useParallaxOcclusion", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useParallaxOcclusion", void 0),
- __decorate([serialize()], e.prototype, "parallaxScaleBias", void 0),
- __decorate([serialize("roughness")], e.prototype, "_roughness", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "roughness", void 0),
- __decorate([serialize()], e.prototype, "indexOfRefraction", void 0),
- __decorate([serialize()], e.prototype, "invertRefractionY", void 0),
- __decorate([serialize()], e.prototype, "alphaCutOff", void 0),
- __decorate([serialize("useLightmapAsShadowmap")], e.prototype, "_useLightmapAsShadowmap", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useLightmapAsShadowmap", void 0),
- __decorate([serializeAsFresnelParameters("diffuseFresnelParameters")], e.prototype, "_diffuseFresnelParameters", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsFresnelDirty")], e.prototype, "diffuseFresnelParameters", void 0),
- __decorate([serializeAsFresnelParameters("opacityFresnelParameters")], e.prototype, "_opacityFresnelParameters", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsFresnelAndMiscDirty")], e.prototype, "opacityFresnelParameters", void 0),
- __decorate([serializeAsFresnelParameters("reflectionFresnelParameters")], e.prototype, "_reflectionFresnelParameters", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsFresnelDirty")], e.prototype, "reflectionFresnelParameters", void 0),
- __decorate([serializeAsFresnelParameters("refractionFresnelParameters")], e.prototype, "_refractionFresnelParameters", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsFresnelDirty")], e.prototype, "refractionFresnelParameters", void 0),
- __decorate([serializeAsFresnelParameters("emissiveFresnelParameters")], e.prototype, "_emissiveFresnelParameters", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsFresnelDirty")], e.prototype, "emissiveFresnelParameters", void 0),
- __decorate([serialize("useReflectionFresnelFromSpecular")], e.prototype, "_useReflectionFresnelFromSpecular", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsFresnelDirty")], e.prototype, "useReflectionFresnelFromSpecular", void 0),
- __decorate([serialize("useGlossinessFromSpecularMapAlpha")], e.prototype, "_useGlossinessFromSpecularMapAlpha", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useGlossinessFromSpecularMapAlpha", void 0),
- __decorate([serialize("maxSimultaneousLights")], e.prototype, "_maxSimultaneousLights", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsLightsDirty")], e.prototype, "maxSimultaneousLights", void 0),
- __decorate([serialize("invertNormalMapX")], e.prototype, "_invertNormalMapX", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "invertNormalMapX", void 0),
- __decorate([serialize("invertNormalMapY")], e.prototype, "_invertNormalMapY", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "invertNormalMapY", void 0),
- __decorate([serialize("twoSidedLighting")], e.prototype, "_twoSidedLighting", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "twoSidedLighting", void 0),
- __decorate([serialize()], e.prototype, "useLogarithmicDepth", null),
- e
- }(PushMaterial);
- RegisterClass("BABYLON.StandardMaterial", StandardMaterial);
- Scene.DefaultMaterialFactory = function(a) {
- return new StandardMaterial("default material",a)
- }
- ;
- var CubeTexture = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _, b, k, j, $, _e, et, tt, rt, it) {
- s === void 0 && (s = null),
- c === void 0 && (c = !1),
- d === void 0 && (d = null),
- _ === void 0 && (_ = null),
- b === void 0 && (b = null),
- k === void 0 && (k = 5),
- j === void 0 && (j = !1),
- $ === void 0 && ($ = null),
- _e === void 0 && (_e = !1),
- et === void 0 && (et = .8),
- tt === void 0 && (tt = 0);
- var nt, ot = a.call(this, o) || this;
- return ot._lodScale = .8,
- ot._lodOffset = 0,
- ot.onLoadObservable = new Observable,
- ot.boundingBoxPosition = Vector3.Zero(),
- ot._rotationY = 0,
- ot._files = null,
- ot._forcedExtension = null,
- ot._extensions = null,
- ot.name = i,
- ot.url = i,
- ot._noMipmap = c,
- ot.hasAlpha = !1,
- ot._format = k,
- ot.isCube = !0,
- ot._textureMatrix = Matrix.Identity(),
- ot._createPolynomials = _e,
- ot.coordinatesMode = Texture.CUBIC_MODE,
- ot._extensions = s,
- ot._files = d,
- ot._forcedExtension = $,
- ot._loaderOptions = rt,
- ot._useSRGBBuffer = it,
- ot._lodScale = et,
- ot._lodOffset = tt,
- !i && !d || ot.updateURL(i, $, _, j, b, s, (nt = ot.getScene()) === null || nt === void 0 ? void 0 : nt.useDelayedTextureLoading, d),
- ot
- }
- return Object.defineProperty(e.prototype, "boundingBoxSize", {
- get: function() {
- return this._boundingBoxSize
- },
- set: function(i) {
- if (!(this._boundingBoxSize && this._boundingBoxSize.equals(i))) {
- this._boundingBoxSize = i;
- var o = this.getScene();
- o && o.markAllMaterialsAsDirty(1)
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "rotationY", {
- get: function() {
- return this._rotationY
- },
- set: function(i) {
- this._rotationY = i,
- this.setReflectionTextureMatrix(Matrix.RotationY(this._rotationY))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "noMipmap", {
- get: function() {
- return this._noMipmap
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "forcedExtension", {
- get: function() {
- return this._forcedExtension
- },
- enumerable: !1,
- configurable: !0
- }),
- e.CreateFromImages = function(i, o, s) {
- var c = "";
- return i.forEach(function(d) {
- return c += d
- }),
- new e(c,o,null,s,i)
- }
- ,
- e.CreateFromPrefilteredData = function(i, o, s, c) {
- s === void 0 && (s = null),
- c === void 0 && (c = !0);
- var d = o.useDelayedTextureLoading;
- o.useDelayedTextureLoading = !1;
- var _ = new e(i,o,null,!1,null,null,null,void 0,!0,s,c);
- return o.useDelayedTextureLoading = d,
- _
- }
- ,
- e.prototype.getClassName = function() {
- return "CubeTexture"
- }
- ,
- e.prototype.updateURL = function(i, o, s, c, d, _, b, k) {
- s === void 0 && (s = null),
- c === void 0 && (c = !1),
- d === void 0 && (d = null),
- _ === void 0 && (_ = null),
- b === void 0 && (b = !1),
- k === void 0 && (k = null),
- (!this.name || StartsWith(this.name, "data:")) && (this.name = i),
- this.url = i;
- var j = i.lastIndexOf(".")
- , $ = o || (j > -1 ? i.substring(j).toLowerCase() : "")
- , _e = $.indexOf(".dds") === 0
- , et = $.indexOf(".env") === 0;
- if (et ? (this.gammaSpace = !1,
- this._prefiltered = !1,
- this.anisotropicFilteringLevel = 1) : (this._prefiltered = c,
- c && (this.gammaSpace = !1,
- this.anisotropicFilteringLevel = 1)),
- k)
- this._files = k;
- else if (!et && !_e && !_ && (_ = ["_px.jpg", "_py.jpg", "_pz.jpg", "_nx.jpg", "_ny.jpg", "_nz.jpg"]),
- this._files = this._files || [],
- this._files.length = 0,
- _) {
- for (var tt = 0; tt < _.length; tt++)
- this._files.push(i + _[tt]);
- this._extensions = _
- }
- b ? (this.delayLoadState = 4,
- this._delayedOnLoad = s,
- this._delayedOnError = d) : this._loadTexture(s, d)
- }
- ,
- e.prototype.delayLoad = function(i) {
- this.delayLoadState === 4 && (i && (this._forcedExtension = i),
- this.delayLoadState = 1,
- this._loadTexture(this._delayedOnLoad, this._delayedOnError))
- }
- ,
- e.prototype.getReflectionTextureMatrix = function() {
- return this._textureMatrix
- }
- ,
- e.prototype.setReflectionTextureMatrix = function(i) {
- var o = this, s;
- i.updateFlag !== this._textureMatrix.updateFlag && (i.isIdentity() !== this._textureMatrix.isIdentity() && ((s = this.getScene()) === null || s === void 0 || s.markAllMaterialsAsDirty(1, function(c) {
- return c.getActiveTextures().indexOf(o) !== -1
- })),
- this._textureMatrix = i)
- }
- ,
- e.prototype._loadTexture = function(i, o) {
- var s = this, c;
- i === void 0 && (i = null),
- o === void 0 && (o = null);
- var d = this.getScene()
- , _ = this._texture;
- this._texture = this._getFromCache(this.url, this._noMipmap, void 0, void 0, this._useSRGBBuffer);
- var b = function() {
- var j;
- s.onLoadObservable.notifyObservers(s),
- _ && (_.dispose(),
- (j = s.getScene()) === null || j === void 0 || j.markAllMaterialsAsDirty(1)),
- i && i()
- }
- , k = function(j, $) {
- s._loadingError = !0,
- s._errorObject = {
- message: j,
- exception: $
- },
- o && o(j, $),
- Texture.OnTextureLoadErrorObservable.notifyObservers(s)
- };
- this._texture ? this._texture.isReady ? Tools.SetImmediate(function() {
- return b()
- }) : this._texture.onLoadedObservable.add(function() {
- return b()
- }) : (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),
- (c = this._texture) === null || c === void 0 || c.onLoadedObservable.add(function() {
- return s.onLoadObservable.notifyObservers(s)
- }))
- }
- ,
- e.Parse = function(i, o, s) {
- var c = SerializationHelper.Parse(function() {
- var k = !1;
- return i.prefiltered && (k = i.prefiltered),
- new e(s + i.name,o,i.extensions,!1,i.files || null,null,null,void 0,k,i.forcedExtension)
- }, i, o);
- if (i.boundingBoxPosition && (c.boundingBoxPosition = Vector3.FromArray(i.boundingBoxPosition)),
- i.boundingBoxSize && (c.boundingBoxSize = Vector3.FromArray(i.boundingBoxSize)),
- i.animations)
- for (var d = 0; d < i.animations.length; d++) {
- var _ = i.animations[d]
- , b = GetClass("BABYLON.Animation");
- b && c.animations.push(b.Parse(_))
- }
- return c
- }
- ,
- e.prototype.clone = function() {
- var i = this
- , o = 0
- , s = SerializationHelper.Clone(function() {
- var c = new e(i.url,i.getScene() || i._getEngine(),i._extensions,i._noMipmap,i._files);
- return o = c.uniqueId,
- c
- }, this);
- return s.uniqueId = o,
- s
- }
- ,
- __decorate([serialize()], e.prototype, "url", void 0),
- __decorate([serialize("rotationY")], e.prototype, "rotationY", null),
- __decorate([serialize("files")], e.prototype, "_files", void 0),
- __decorate([serialize("forcedExtension")], e.prototype, "_forcedExtension", void 0),
- __decorate([serialize("extensions")], e.prototype, "_extensions", void 0),
- __decorate([serializeAsMatrix("textureMatrix")], e.prototype, "_textureMatrix", void 0),
- e
- }(BaseTexture);
- Texture._CubeTextureParser = CubeTexture.Parse;
- RegisterClass("BABYLON.CubeTexture", CubeTexture);
- var DynamicTexture = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _, b) {
- s === void 0 && (s = null),
- c === void 0 && (c = !1),
- d === void 0 && (d = 3),
- _ === void 0 && (_ = 5);
- var k = a.call(this, null, s, !c, b, d, void 0, void 0, void 0, void 0, _) || this;
- k.name = i,
- k.wrapU = Texture.CLAMP_ADDRESSMODE,
- k.wrapV = Texture.CLAMP_ADDRESSMODE,
- k._generateMipMaps = c;
- var j = k._getEngine();
- if (!j)
- return k;
- o.getContext ? (k._canvas = o,
- k._texture = j.createDynamicTexture(o.width, o.height, c, d)) : (k._canvas = j.createCanvas(1, 1),
- o.width || o.width === 0 ? k._texture = j.createDynamicTexture(o.width, o.height, c, d) : k._texture = j.createDynamicTexture(o, o, c, d));
- var $ = k.getSize();
- return k._canvas.width !== $.width && (k._canvas.width = $.width),
- k._canvas.height !== $.height && (k._canvas.height = $.height),
- k._context = k._canvas.getContext("2d"),
- k
- }
- return e.prototype.getClassName = function() {
- return "DynamicTexture"
- }
- ,
- Object.defineProperty(e.prototype, "canRescale", {
- get: function() {
- return !0
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._recreate = function(i) {
- this._canvas.width = i.width,
- this._canvas.height = i.height,
- this.releaseInternalTexture(),
- this._texture = this._getEngine().createDynamicTexture(i.width, i.height, this._generateMipMaps, this.samplingMode)
- }
- ,
- e.prototype.scale = function(i) {
- var o = this.getSize();
- o.width *= i,
- o.height *= i,
- this._recreate(o)
- }
- ,
- e.prototype.scaleTo = function(i, o) {
- var s = this.getSize();
- s.width = i,
- s.height = o,
- this._recreate(s)
- }
- ,
- e.prototype.getContext = function() {
- return this._context
- }
- ,
- e.prototype.clear = function() {
- var i = this.getSize();
- this._context.fillRect(0, 0, i.width, i.height)
- }
- ,
- e.prototype.update = function(i, o, s) {
- o === void 0 && (o = !1),
- s === void 0 && (s = !1),
- this._getEngine().updateDynamicTexture(this._texture, this._canvas, i === void 0 ? !0 : i, o, this._format || void 0, void 0, s)
- }
- ,
- e.prototype.drawText = function(i, o, s, c, d, _, b, k) {
- k === void 0 && (k = !0);
- var j = this.getSize();
- if (_ && (this._context.fillStyle = _,
- this._context.fillRect(0, 0, j.width, j.height)),
- this._context.font = c,
- o == null) {
- var $ = this._context.measureText(i);
- o = (j.width - $.width) / 2
- }
- if (s == null) {
- var _e = parseInt(c.replace(/\D/g, ""));
- s = j.height / 2 + _e / 3.65
- }
- this._context.fillStyle = d || "",
- this._context.fillText(i, o, s),
- k && this.update(b)
- }
- ,
- e.prototype.clone = function() {
- var i = this.getScene();
- if (!i)
- return this;
- var o = this.getSize()
- , s = new e(this.name,o,i,this._generateMipMaps);
- return s.hasAlpha = this.hasAlpha,
- s.level = this.level,
- s.wrapU = this.wrapU,
- s.wrapV = this.wrapV,
- s
- }
- ,
- e.prototype.serialize = function() {
- var i = this.getScene();
- i && !i.isReady() && Logger$2.Warn("The scene must be ready before serializing the dynamic texture");
- var o = a.prototype.serialize.call(this);
- return this._IsCanvasElement(this._canvas) && (o.base64String = this._canvas.toDataURL()),
- o.invertY = this._invertY,
- o.samplingMode = this.samplingMode,
- o
- }
- ,
- e.prototype._IsCanvasElement = function(i) {
- return i.toDataURL !== void 0
- }
- ,
- e.prototype._rebuild = function() {
- this.update()
- }
- ,
- e
- }(Texture)
- , VideoTexture = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _, b, k) {
- c === void 0 && (c = !1),
- d === void 0 && (d = !1),
- _ === void 0 && (_ = Texture.TRILINEAR_SAMPLINGMODE);
- var j = a.call(this, null, s, !c, d) || this;
- j._onUserActionRequestedObservable = null,
- j._stillImageCaptured = !1,
- j._displayingPosterTexture = !1,
- j._frameId = -1,
- j._currentSrc = null,
- j._errorFound = !1,
- j._createInternalTexture = function() {
- if (j._texture != null)
- if (j._displayingPosterTexture)
- j._texture.dispose(),
- j._displayingPosterTexture = !1;
- else
- return;
- if (!j._getEngine().needPOTTextures || Tools.IsExponentOfTwo(j.video.videoWidth) && Tools.IsExponentOfTwo(j.video.videoHeight) ? (j.wrapU = Texture.WRAP_ADDRESSMODE,
- j.wrapV = Texture.WRAP_ADDRESSMODE) : (j.wrapU = Texture.CLAMP_ADDRESSMODE,
- j.wrapV = Texture.CLAMP_ADDRESSMODE,
- j._generateMipMaps = !1),
- j._texture = j._getEngine().createDynamicTexture(j.video.videoWidth, j.video.videoHeight, j._generateMipMaps, j.samplingMode),
- !j.video.autoplay && !j._settings.poster) {
- var _e = j.video.onplaying
- , et = j.video.muted;
- j.video.muted = !0,
- j.video.onplaying = function() {
- j.video.muted = et,
- j.video.onplaying = _e,
- j._updateInternalTexture(),
- j._errorFound || j.video.pause(),
- j.onLoadObservable.hasObservers() && j.onLoadObservable.notifyObservers(j)
- }
- ,
- j._handlePlay()
- } else
- j._updateInternalTexture(),
- j.onLoadObservable.hasObservers() && j.onLoadObservable.notifyObservers(j)
- }
- ,
- j.reset = function() {
- j._texture != null && (j._displayingPosterTexture || (j._texture.dispose(),
- j._texture = null))
- }
- ,
- j._updateInternalTexture = function() {
- if (j._texture != null && !(j.video.readyState < j.video.HAVE_CURRENT_DATA) && !j._displayingPosterTexture) {
- var _e = j.getScene().getFrameId();
- j._frameId !== _e && (j._frameId = _e,
- j._getEngine().updateVideoTexture(j._texture, j.video, j._invertY))
- }
- }
- ,
- b || (b = {
- autoPlay: !0,
- loop: !0,
- autoUpdateTexture: !0
- }),
- j._onError = k,
- j._generateMipMaps = c,
- j._initialSamplingMode = _,
- j.autoUpdateTexture = b.autoUpdateTexture,
- j._currentSrc = o,
- j.name = i || j._getName(o),
- j.video = j._getVideo(o),
- j._settings = b,
- b.poster && (j.video.poster = b.poster),
- b.autoPlay !== void 0 && (j.video.autoplay = b.autoPlay),
- b.loop !== void 0 && (j.video.loop = b.loop),
- b.muted !== void 0 && (j.video.muted = b.muted),
- j.video.setAttribute("playsinline", ""),
- j.video.addEventListener("paused", j._updateInternalTexture),
- j.video.addEventListener("seeked", j._updateInternalTexture),
- j.video.addEventListener("emptied", j.reset),
- j._createInternalTextureOnEvent = b.poster && !b.autoPlay ? "play" : "canplay",
- j.video.addEventListener(j._createInternalTextureOnEvent, j._createInternalTexture),
- b.autoPlay && j._handlePlay();
- var $ = j.video.readyState >= j.video.HAVE_CURRENT_DATA;
- return b.poster && (!b.autoPlay || !$) ? (j._texture = j._getEngine().createTexture(b.poster, !1, !j.invertY, s),
- j._displayingPosterTexture = !0) : $ && j._createInternalTexture(),
- j
- }
- return Object.defineProperty(e.prototype, "onUserActionRequestedObservable", {
- get: function() {
- return this._onUserActionRequestedObservable || (this._onUserActionRequestedObservable = new Observable),
- this._onUserActionRequestedObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._processError = function(i) {
- this._errorFound = !0,
- this._onError ? this._onError(i == null ? void 0 : i.message) : Logger$2.Error(i == null ? void 0 : i.message)
- }
- ,
- e.prototype._handlePlay = function() {
- var i = this;
- this._errorFound = !1,
- this.video.play().catch(function(o) {
- if ((o == null ? void 0 : o.name) === "NotAllowedError") {
- if (i._onUserActionRequestedObservable && i._onUserActionRequestedObservable.hasObservers()) {
- i._onUserActionRequestedObservable.notifyObservers(i);
- return
- } else if (!i.video.muted) {
- Logger$2.Warn("Unable to autoplay a video with sound. Trying again with muted turned true"),
- i.video.muted = !0,
- i._errorFound = !1,
- i.video.play().catch(function(s) {
- i._processError(s)
- });
- return
- }
- }
- i._processError(o)
- })
- }
- ,
- e.prototype.getClassName = function() {
- return "VideoTexture"
- }
- ,
- e.prototype._getName = function(i) {
- return i instanceof HTMLVideoElement ? i.currentSrc : typeof i == "object" ? i.toString() : i
- }
- ,
- e.prototype._getVideo = function(i) {
- if (i.isNative)
- return i;
- if (i instanceof HTMLVideoElement)
- return Tools.SetCorsBehavior(i.currentSrc, i),
- i;
- var o = document.createElement("video");
- return typeof i == "string" ? (Tools.SetCorsBehavior(i, o),
- o.src = i) : (Tools.SetCorsBehavior(i[0], o),
- i.forEach(function(s) {
- var c = document.createElement("source");
- c.src = s,
- o.appendChild(c)
- })),
- o
- }
- ,
- e.prototype._rebuild = function() {
- this.update()
- }
- ,
- e.prototype.update = function() {
- !this.autoUpdateTexture || this.updateTexture(!0)
- }
- ,
- e.prototype.updateTexture = function(i) {
- !i || this.video.paused && this._stillImageCaptured || (this._stillImageCaptured = !0,
- this._updateInternalTexture())
- }
- ,
- e.prototype.updateURL = function(i) {
- this.video.src = i,
- this._currentSrc = i
- }
- ,
- e.prototype.clone = function() {
- return new e(this.name,this._currentSrc,this.getScene(),this._generateMipMaps,this.invertY,this.samplingMode,this._settings)
- }
- ,
- e.prototype.dispose = function() {
- a.prototype.dispose.call(this),
- this._currentSrc = null,
- this._onUserActionRequestedObservable && (this._onUserActionRequestedObservable.clear(),
- this._onUserActionRequestedObservable = null),
- this.video.removeEventListener(this._createInternalTextureOnEvent, this._createInternalTexture),
- this.video.removeEventListener("paused", this._updateInternalTexture),
- this.video.removeEventListener("seeked", this._updateInternalTexture),
- this.video.removeEventListener("emptied", this.reset),
- this.video.pause()
- }
- ,
- e.CreateFromStreamAsync = function(i, o, s, c) {
- c === void 0 && (c = !0);
- var d = i.getEngine().createVideoElement(s);
- return i.getEngine()._badOS && (document.body.appendChild(d),
- d.style.transform = "scale(0.0001, 0.0001)",
- d.style.opacity = "0",
- d.style.position = "fixed",
- d.style.bottom = "0px",
- d.style.right = "0px"),
- d.setAttribute("autoplay", ""),
- d.setAttribute("muted", "true"),
- d.setAttribute("playsinline", ""),
- d.muted = !0,
- d.mozSrcObject !== void 0 ? d.mozSrcObject = o : typeof d.srcObject == "object" ? d.srcObject = o : (window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL,
- d.src = window.URL && window.URL.createObjectURL(o)),
- new Promise(function(_) {
- var b = function() {
- _(new e("video",d,i,!0,c)),
- d.removeEventListener("playing", b)
- };
- d.addEventListener("playing", b),
- d.play()
- }
- )
- }
- ,
- e.CreateFromWebCamAsync = function(i, o, s, c) {
- var d = this;
- s === void 0 && (s = !1),
- c === void 0 && (c = !0);
- var _;
- if (o && o.deviceId && (_ = {
- exact: o.deviceId
- }),
- navigator.mediaDevices)
- return navigator.mediaDevices.getUserMedia({
- video: o,
- audio: s
- }).then(function(k) {
- return d.CreateFromStreamAsync(i, k, o, c)
- });
- var b = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
- return b && b({
- video: {
- deviceId: _,
- width: {
- min: o && o.minWidth || 256,
- max: o && o.maxWidth || 640
- },
- height: {
- min: o && o.minHeight || 256,
- max: o && o.maxHeight || 480
- }
- },
- audio: s
- }, function(k) {
- return d.CreateFromStreamAsync(i, k, o, c)
- }, function(k) {
- Logger$2.Error(k.name)
- }),
- Promise.reject("No support for userMedia on this device")
- }
- ,
- e.CreateFromWebCam = function(i, o, s, c, d) {
- c === void 0 && (c = !1),
- d === void 0 && (d = !0),
- this.CreateFromWebCamAsync(i, s, c, d).then(function(_) {
- o && o(_)
- }).catch(function(_) {
- Logger$2.Error(_.name)
- })
- }
- ,
- e
- }(Texture)
- , Action = function() {
- function a(e, i) {
- this.triggerOptions = e,
- this.onBeforeExecuteObservable = new Observable,
- e.parameter ? (this.trigger = e.trigger,
- this._triggerParameter = e.parameter) : e.trigger ? this.trigger = e.trigger : this.trigger = e,
- this._nextActiveAction = this,
- this._condition = i
- }
- return a.prototype._prepare = function() {}
- ,
- a.prototype.getTriggerParameter = function() {
- return this._triggerParameter
- }
- ,
- a.prototype.setTriggerParameter = function(e) {
- this._triggerParameter = e
- }
- ,
- a.prototype._evaluateConditionForCurrentFrame = function() {
- var e = this._condition;
- if (!e)
- return !0;
- var i = this._actionManager.getScene().getRenderId();
- return e._evaluationId !== i && (e._evaluationId = i,
- e._currentResult = e.isValid()),
- e._currentResult
- }
- ,
- a.prototype._executeCurrent = function(e) {
- var i = this._evaluateConditionForCurrentFrame();
- !i || (this.onBeforeExecuteObservable.notifyObservers(this),
- this._nextActiveAction.execute(e),
- this.skipToNextActiveAction())
- }
- ,
- a.prototype.execute = function(e) {}
- ,
- a.prototype.skipToNextActiveAction = function() {
- this._nextActiveAction._child ? (this._nextActiveAction._child._actionManager || (this._nextActiveAction._child._actionManager = this._actionManager),
- this._nextActiveAction = this._nextActiveAction._child) : this._nextActiveAction = this
- }
- ,
- a.prototype.then = function(e) {
- return this._child = e,
- e._actionManager = this._actionManager,
- e._prepare(),
- e
- }
- ,
- a.prototype._getProperty = function(e) {
- return this._actionManager._getProperty(e)
- }
- ,
- a.prototype._getEffectiveTarget = function(e, i) {
- return this._actionManager._getEffectiveTarget(e, i)
- }
- ,
- a.prototype.serialize = function(e) {}
- ,
- a.prototype._serialize = function(e, i) {
- var o = {
- type: 1,
- children: [],
- name: e.name,
- properties: e.properties || []
- };
- if (this._child && this._child.serialize(o),
- this._condition) {
- var s = this._condition.serialize();
- return s.children.push(o),
- i && i.children.push(s),
- s
- }
- return i && i.children.push(o),
- o
- }
- ,
- a._SerializeValueAsString = function(e) {
- 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
- }
- ,
- a._GetTargetProperty = function(e) {
- return {
- name: "target",
- targetType: e._isMesh ? "MeshProperties" : e._isLight ? "LightProperties" : e._isCamera ? "CameraProperties" : "SceneProperties",
- value: e._isScene ? "Scene" : e.name
- }
- }
- ,
- a
- }();
- RegisterClass("BABYLON.Action", Action);
- var Condition = function() {
- function a(e) {
- this._actionManager = e
- }
- return a.prototype.isValid = function() {
- return !0
- }
- ,
- a.prototype._getProperty = function(e) {
- return this._actionManager._getProperty(e)
- }
- ,
- a.prototype._getEffectiveTarget = function(e, i) {
- return this._actionManager._getEffectiveTarget(e, i)
- }
- ,
- a.prototype.serialize = function() {}
- ,
- a.prototype._serialize = function(e) {
- return {
- type: 2,
- children: [],
- name: e.name,
- properties: e.properties
- }
- }
- ,
- a
- }()
- , ValueCondition = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d) {
- d === void 0 && (d = e.IsEqual);
- var _ = a.call(this, i) || this;
- return _.propertyPath = s,
- _.value = c,
- _.operator = d,
- _._target = o,
- _._effectiveTarget = _._getEffectiveTarget(o, _.propertyPath),
- _._property = _._getProperty(_.propertyPath),
- _
- }
- return Object.defineProperty(e, "IsEqual", {
- get: function() {
- return e._IsEqual
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "IsDifferent", {
- get: function() {
- return e._IsDifferent
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "IsGreater", {
- get: function() {
- return e._IsGreater
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e, "IsLesser", {
- get: function() {
- return e._IsLesser
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.isValid = function() {
- switch (this.operator) {
- case e.IsGreater:
- return this._effectiveTarget[this._property] > this.value;
- case e.IsLesser:
- return this._effectiveTarget[this._property] < this.value;
- case e.IsEqual:
- case e.IsDifferent:
- var i;
- return this.value.equals ? i = this.value.equals(this._effectiveTarget[this._property]) : i = this.value === this._effectiveTarget[this._property],
- this.operator === e.IsEqual ? i : !i
- }
- return !1
- }
- ,
- e.prototype.serialize = function() {
- return this._serialize({
- name: "ValueCondition",
- properties: [Action._GetTargetProperty(this._target), {
- name: "propertyPath",
- value: this.propertyPath
- }, {
- name: "value",
- value: Action._SerializeValueAsString(this.value)
- }, {
- name: "operator",
- value: e.GetOperatorName(this.operator)
- }]
- })
- }
- ,
- e.GetOperatorName = function(i) {
- switch (i) {
- case e._IsEqual:
- return "IsEqual";
- case e._IsDifferent:
- return "IsDifferent";
- case e._IsGreater:
- return "IsGreater";
- case e._IsLesser:
- return "IsLesser";
- default:
- return ""
- }
- }
- ,
- e._IsEqual = 0,
- e._IsDifferent = 1,
- e._IsGreater = 2,
- e._IsLesser = 3,
- e
- }(Condition)
- , PredicateCondition = function(a) {
- __extends(e, a);
- function e(i, o) {
- var s = a.call(this, i) || this;
- return s.predicate = o,
- s
- }
- return e.prototype.isValid = function() {
- return this.predicate()
- }
- ,
- e
- }(Condition)
- , StateCondition = function(a) {
- __extends(e, a);
- function e(i, o, s) {
- var c = a.call(this, i) || this;
- return c.value = s,
- c._target = o,
- c
- }
- return e.prototype.isValid = function() {
- return this._target.state === this.value
- }
- ,
- e.prototype.serialize = function() {
- return this._serialize({
- name: "StateCondition",
- properties: [Action._GetTargetProperty(this._target), {
- name: "value",
- value: this.value
- }]
- })
- }
- ,
- e
- }(Condition);
- RegisterClass("BABYLON.ValueCondition", ValueCondition);
- RegisterClass("BABYLON.PredicateCondition", PredicateCondition);
- RegisterClass("BABYLON.StateCondition", StateCondition);
- (function(a) {
- __extends(e, a);
- function e(i, o, s, c) {
- var d = a.call(this, i, c) || this;
- return d.propertyPath = s,
- d._target = d._effectiveTarget = o,
- d
- }
- return e.prototype._prepare = function() {
- this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath),
- this._property = this._getProperty(this.propertyPath)
- }
- ,
- e.prototype.execute = function() {
- this._effectiveTarget[this._property] = !this._effectiveTarget[this._property]
- }
- ,
- e.prototype.serialize = function(i) {
- return a.prototype._serialize.call(this, {
- name: "SwitchBooleanAction",
- properties: [Action._GetTargetProperty(this._target), {
- name: "propertyPath",
- value: this.propertyPath
- }]
- }, i)
- }
- ,
- e
- }
- )(Action);
- var SetStateAction = function(a) {
- __extends(e, a);
- function e(i, o, s, c) {
- var d = a.call(this, i, c) || this;
- return d.value = s,
- d._target = o,
- d
- }
- return e.prototype.execute = function() {
- this._target.state = this.value
- }
- ,
- e.prototype.serialize = function(i) {
- return a.prototype._serialize.call(this, {
- name: "SetStateAction",
- properties: [Action._GetTargetProperty(this._target), {
- name: "value",
- value: this.value
- }]
- }, i)
- }
- ,
- e
- }(Action)
- , SetValueAction = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d) {
- var _ = a.call(this, i, d) || this;
- return _.propertyPath = s,
- _.value = c,
- _._target = _._effectiveTarget = o,
- _
- }
- return e.prototype._prepare = function() {
- this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath),
- this._property = this._getProperty(this.propertyPath)
- }
- ,
- e.prototype.execute = function() {
- this._effectiveTarget[this._property] = this.value,
- this._target.markAsDirty && this._target.markAsDirty(this._property)
- }
- ,
- e.prototype.serialize = function(i) {
- return a.prototype._serialize.call(this, {
- name: "SetValueAction",
- properties: [Action._GetTargetProperty(this._target), {
- name: "propertyPath",
- value: this.propertyPath
- }, {
- name: "value",
- value: Action._SerializeValueAsString(this.value)
- }]
- }, i)
- }
- ,
- e
- }(Action)
- , IncrementValueAction = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d) {
- var _ = a.call(this, i, d) || this;
- return _.propertyPath = s,
- _.value = c,
- _._target = _._effectiveTarget = o,
- _
- }
- return e.prototype._prepare = function() {
- this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath),
- this._property = this._getProperty(this.propertyPath),
- typeof this._effectiveTarget[this._property] != "number" && Logger$2.Warn("Warning: IncrementValueAction can only be used with number values")
- }
- ,
- e.prototype.execute = function() {
- this._effectiveTarget[this._property] += this.value,
- this._target.markAsDirty && this._target.markAsDirty(this._property)
- }
- ,
- e.prototype.serialize = function(i) {
- return a.prototype._serialize.call(this, {
- name: "IncrementValueAction",
- properties: [Action._GetTargetProperty(this._target), {
- name: "propertyPath",
- value: this.propertyPath
- }, {
- name: "value",
- value: Action._SerializeValueAsString(this.value)
- }]
- }, i)
- }
- ,
- e
- }(Action)
- , PlayAnimationAction = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _) {
- var b = a.call(this, i, _) || this;
- return b.from = s,
- b.to = c,
- b.loop = d,
- b._target = o,
- b
- }
- return e.prototype._prepare = function() {}
- ,
- e.prototype.execute = function() {
- var i = this._actionManager.getScene();
- i.beginAnimation(this._target, this.from, this.to, this.loop)
- }
- ,
- e.prototype.serialize = function(i) {
- return a.prototype._serialize.call(this, {
- name: "PlayAnimationAction",
- properties: [Action._GetTargetProperty(this._target), {
- name: "from",
- value: String(this.from)
- }, {
- name: "to",
- value: String(this.to)
- }, {
- name: "loop",
- value: Action._SerializeValueAsString(this.loop) || !1
- }]
- }, i)
- }
- ,
- e
- }(Action)
- , StopAnimationAction = function(a) {
- __extends(e, a);
- function e(i, o, s) {
- var c = a.call(this, i, s) || this;
- return c._target = o,
- c
- }
- return e.prototype._prepare = function() {}
- ,
- e.prototype.execute = function() {
- var i = this._actionManager.getScene();
- i.stopAnimation(this._target)
- }
- ,
- e.prototype.serialize = function(i) {
- return a.prototype._serialize.call(this, {
- name: "StopAnimationAction",
- properties: [Action._GetTargetProperty(this._target)]
- }, i)
- }
- ,
- e
- }(Action)
- , DoNothingAction = function(a) {
- __extends(e, a);
- function e(i, o) {
- return i === void 0 && (i = 0),
- a.call(this, i, o) || this
- }
- return e.prototype.execute = function() {}
- ,
- e.prototype.serialize = function(i) {
- return a.prototype._serialize.call(this, {
- name: "DoNothingAction",
- properties: []
- }, i)
- }
- ,
- e
- }(Action);
- (function(a) {
- __extends(e, a);
- function e(i, o, s, c) {
- c === void 0 && (c = !0);
- var d = a.call(this, i, s) || this;
- return d.children = o,
- d.enableChildrenConditions = c,
- d
- }
- return e.prototype._prepare = function() {
- for (var i = 0; i < this.children.length; i++)
- this.children[i]._actionManager = this._actionManager,
- this.children[i]._prepare()
- }
- ,
- e.prototype.execute = function(i) {
- for (var o = 0, s = this.children; o < s.length; o++) {
- var c = s[o];
- (!this.enableChildrenConditions || c._evaluateConditionForCurrentFrame()) && c.execute(i)
- }
- }
- ,
- e.prototype.serialize = function(i) {
- for (var o = a.prototype._serialize.call(this, {
- name: "CombineAction",
- properties: [],
- combine: []
- }, i), s = 0; s < this.children.length; s++)
- o.combine.push(this.children[s].serialize(null));
- return o
- }
- ,
- e
- }
- )(Action);
- var ExecuteCodeAction = function(a) {
- __extends(e, a);
- function e(i, o, s) {
- var c = a.call(this, i, s) || this;
- return c.func = o,
- c
- }
- return e.prototype.execute = function(i) {
- this.func(i)
- }
- ,
- e
- }(Action)
- , SetParentAction = function(a) {
- __extends(e, a);
- function e(i, o, s, c) {
- var d = a.call(this, i, c) || this;
- return d._target = o,
- d._parent = s,
- d
- }
- return e.prototype._prepare = function() {}
- ,
- e.prototype.execute = function() {
- if (this._target.parent !== this._parent) {
- var i = this._parent.getWorldMatrix().clone();
- i.invert(),
- this._target.position = Vector3.TransformCoordinates(this._target.position, i),
- this._target.parent = this._parent
- }
- }
- ,
- e.prototype.serialize = function(i) {
- return a.prototype._serialize.call(this, {
- name: "SetParentAction",
- properties: [Action._GetTargetProperty(this._target), Action._GetTargetProperty(this._parent)]
- }, i)
- }
- ,
- e
- }(Action);
- RegisterClass("BABYLON.SetParentAction", SetParentAction);
- RegisterClass("BABYLON.ExecuteCodeAction", ExecuteCodeAction);
- RegisterClass("BABYLON.DoNothingAction", DoNothingAction);
- RegisterClass("BABYLON.StopAnimationAction", StopAnimationAction);
- RegisterClass("BABYLON.PlayAnimationAction", PlayAnimationAction);
- RegisterClass("BABYLON.IncrementValueAction", IncrementValueAction);
- RegisterClass("BABYLON.SetValueAction", SetValueAction);
- RegisterClass("BABYLON.SetStateAction", SetStateAction);
- RegisterClass("BABYLON.SetParentAction", SetParentAction);
- var ActionManager = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this) || this;
- return o._scene = i || EngineStore.LastCreatedScene,
- i.actionManagers.push(o),
- o
- }
- return e.prototype.dispose = function() {
- for (var i = this._scene.actionManagers.indexOf(this), o = 0; o < this.actions.length; o++) {
- var s = this.actions[o];
- e.Triggers[s.trigger]--,
- e.Triggers[s.trigger] === 0 && delete e.Triggers[s.trigger]
- }
- i > -1 && this._scene.actionManagers.splice(i, 1)
- }
- ,
- e.prototype.getScene = function() {
- return this._scene
- }
- ,
- e.prototype.hasSpecificTriggers = function(i) {
- for (var o = 0; o < this.actions.length; o++) {
- var s = this.actions[o];
- if (i.indexOf(s.trigger) > -1)
- return !0
- }
- return !1
- }
- ,
- e.prototype.hasSpecificTriggers2 = function(i, o) {
- for (var s = 0; s < this.actions.length; s++) {
- var c = this.actions[s];
- if (i == c.trigger || o == c.trigger)
- return !0
- }
- return !1
- }
- ,
- e.prototype.hasSpecificTrigger = function(i, o) {
- for (var s = 0; s < this.actions.length; s++) {
- var c = this.actions[s];
- if (c.trigger === i)
- if (o) {
- if (o(c.getTriggerParameter()))
- return !0
- } else
- return !0
- }
- return !1
- }
- ,
- Object.defineProperty(e.prototype, "hasPointerTriggers", {
- get: function() {
- for (var i = 0; i < this.actions.length; i++) {
- var o = this.actions[i];
- if (o.trigger >= e.OnPickTrigger && o.trigger <= e.OnPointerOutTrigger)
- return !0
- }
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "hasPickTriggers", {
- get: function() {
- for (var i = 0; i < this.actions.length; i++) {
- var o = this.actions[i];
- if (o.trigger >= e.OnPickTrigger && o.trigger <= e.OnPickUpTrigger)
- return !0
- }
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.registerAction = function(i) {
- return i.trigger === e.OnEveryFrameTrigger && this.getScene().actionManager !== this ? (Logger$2.Warn("OnEveryFrameTrigger can only be used with scene.actionManager"),
- null) : (this.actions.push(i),
- e.Triggers[i.trigger] ? e.Triggers[i.trigger]++ : e.Triggers[i.trigger] = 1,
- i._actionManager = this,
- i._prepare(),
- i)
- }
- ,
- e.prototype.unregisterAction = function(i) {
- var o = this.actions.indexOf(i);
- return o !== -1 ? (this.actions.splice(o, 1),
- e.Triggers[i.trigger] -= 1,
- e.Triggers[i.trigger] === 0 && delete e.Triggers[i.trigger],
- i._actionManager = null,
- !0) : !1
- }
- ,
- e.prototype.processTrigger = function(i, o) {
- for (var s = 0; s < this.actions.length; s++) {
- var c = this.actions[s];
- if (c.trigger === i) {
- if (o && (i === e.OnKeyUpTrigger || i === e.OnKeyDownTrigger)) {
- var d = c.getTriggerParameter();
- if (d && d !== o.sourceEvent.keyCode) {
- if (!d.toLowerCase)
- continue;
- var _ = d.toLowerCase();
- if (_ !== o.sourceEvent.key) {
- var b = o.sourceEvent.charCode ? o.sourceEvent.charCode : o.sourceEvent.keyCode
- , k = String.fromCharCode(b).toLowerCase();
- if (k !== _)
- continue
- }
- }
- }
- c._executeCurrent(o)
- }
- }
- }
- ,
- e.prototype._getEffectiveTarget = function(i, o) {
- for (var s = o.split("."), c = 0; c < s.length - 1; c++)
- i = i[s[c]];
- return i
- }
- ,
- e.prototype._getProperty = function(i) {
- var o = i.split(".");
- return o[o.length - 1]
- }
- ,
- e.prototype.serialize = function(i) {
- for (var o = {
- children: new Array,
- name: i,
- type: 3,
- properties: new Array
- }, s = 0; s < this.actions.length; s++) {
- var c = {
- type: 0,
- children: new Array,
- name: e.GetTriggerName(this.actions[s].trigger),
- properties: new Array
- }
- , d = this.actions[s].triggerOptions;
- if (d && typeof d != "number")
- if (d.parameter instanceof Node)
- c.properties.push(Action._GetTargetProperty(d.parameter));
- else {
- var _ = {};
- DeepCopier.DeepCopy(d.parameter, _, ["mesh"]),
- d.parameter && d.parameter.mesh && (_._meshId = d.parameter.mesh.id),
- c.properties.push({
- name: "parameter",
- targetType: null,
- value: _
- })
- }
- this.actions[s].serialize(c),
- o.children.push(c)
- }
- return o
- }
- ,
- e.Parse = function(i, o, s) {
- var c = new e(s);
- o === null ? s.actionManager = c : o.actionManager = c;
- for (var d = function(rt, it) {
- var nt = GetClass("BABYLON." + rt);
- if (nt) {
- var ot = Object.create(nt.prototype);
- return ot.constructor.apply(ot, it),
- ot
- }
- }, _ = function(rt, it, nt, ot) {
- if (ot === null) {
- var at = parseFloat(it);
- return it === "true" || it === "false" ? it === "true" : isNaN(at) ? it : at
- }
- for (var st = ot.split("."), ut = it.split(","), ct = 0; ct < st.length; ct++)
- nt = nt[st[ct]];
- if (typeof nt == "boolean")
- return ut[0] === "true";
- if (typeof nt == "string")
- return ut[0];
- for (var lt = new Array, ct = 0; ct < ut.length; ct++)
- lt.push(parseFloat(ut[ct]));
- 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])
- }, b = function(rt, it, nt, ot, at) {
- if (at === void 0 && (at = null),
- !rt.detached) {
- var st = new Array
- , ut = null
- , ct = null
- , lt = rt.combine && rt.combine.length > 0;
- if (rt.type === 2 ? st.push(c) : st.push(it),
- lt) {
- for (var ft = new Array, ht = 0; ht < rt.combine.length; ht++)
- b(rt.combine[ht], e.NothingTrigger, nt, ot, ft);
- st.push(ft)
- } else
- for (var pt = 0; pt < rt.properties.length; pt++) {
- var dt = rt.properties[pt].value
- , _t = rt.properties[pt].name
- , mt = rt.properties[pt].targetType;
- _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,
- st.push(dt)
- }
- if (at === null ? st.push(nt) : st.push(null),
- rt.name === "InterpolateValueAction") {
- var vt = st[st.length - 2];
- st[st.length - 1] = vt,
- st[st.length - 2] = nt
- }
- var yt = d(rt.name, st);
- if (yt instanceof Condition && nt !== null) {
- var Et = new DoNothingAction(it,nt);
- ot ? ot.then(Et) : c.registerAction(Et),
- ot = Et
- }
- at === null ? yt instanceof Condition ? (nt = yt,
- yt = ot) : (nt = null,
- ot ? ot.then(yt) : c.registerAction(yt)) : at.push(yt);
- for (var pt = 0; pt < rt.children.length; pt++)
- b(rt.children[pt], it, nt, yt, null)
- }
- }, k = 0; k < i.children.length; k++) {
- var j, $ = i.children[k];
- if ($.properties.length > 0) {
- var _e = $.properties[0].value
- , et = $.properties[0].targetType === null ? _e : s.getMeshByName(_e);
- et._meshId && (et.mesh = s.getMeshById(et._meshId)),
- j = {
- trigger: e[$.name],
- parameter: et
- }
- } else
- j = e[$.name];
- for (var tt = 0; tt < $.children.length; tt++)
- $.detached || b($.children[tt], j, null, null)
- }
- }
- ,
- e.GetTriggerName = function(i) {
- switch (i) {
- case 0:
- return "NothingTrigger";
- case 1:
- return "OnPickTrigger";
- case 2:
- return "OnLeftPickTrigger";
- case 3:
- return "OnRightPickTrigger";
- case 4:
- return "OnCenterPickTrigger";
- case 5:
- return "OnPickDownTrigger";
- case 6:
- return "OnPickUpTrigger";
- case 7:
- return "OnLongPressTrigger";
- case 8:
- return "OnPointerOverTrigger";
- case 9:
- return "OnPointerOutTrigger";
- case 10:
- return "OnEveryFrameTrigger";
- case 11:
- return "OnIntersectionEnterTrigger";
- case 12:
- return "OnIntersectionExitTrigger";
- case 13:
- return "OnKeyDownTrigger";
- case 14:
- return "OnKeyUpTrigger";
- case 15:
- return "OnPickOutTrigger";
- default:
- return ""
- }
- }
- ,
- e.NothingTrigger = 0,
- e.OnPickTrigger = 1,
- e.OnLeftPickTrigger = 2,
- e.OnRightPickTrigger = 3,
- e.OnCenterPickTrigger = 4,
- e.OnPickDownTrigger = 5,
- e.OnDoublePickTrigger = 6,
- e.OnPickUpTrigger = 7,
- e.OnPickOutTrigger = 16,
- e.OnLongPressTrigger = 8,
- e.OnPointerOverTrigger = 9,
- e.OnPointerOutTrigger = 10,
- e.OnEveryFrameTrigger = 11,
- e.OnIntersectionEnterTrigger = 12,
- e.OnIntersectionExitTrigger = 13,
- e.OnKeyDownTrigger = 14,
- e.OnKeyUpTrigger = 15,
- e
- }(AbstractActionManager);
- Node$2.AddNodeConstructor("Light_Type_0", function(a, e) {
- return function() {
- return new PointLight(a,Vector3.Zero(),e)
- }
- });
- var PointLight = function(a) {
- __extends(e, a);
- function e(i, o, s) {
- var c = a.call(this, i, s) || this;
- return c._shadowAngle = Math.PI / 2,
- c.position = o,
- c
- }
- return Object.defineProperty(e.prototype, "shadowAngle", {
- get: function() {
- return this._shadowAngle
- },
- set: function(i) {
- this._shadowAngle = i,
- this.forceProjectionMatrixCompute()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "direction", {
- get: function() {
- return this._direction
- },
- set: function(i) {
- var o = this.needCube();
- this._direction = i,
- this.needCube() !== o && this._shadowGenerator && this._shadowGenerator.recreateShadowMap()
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getClassName = function() {
- return "PointLight"
- }
- ,
- e.prototype.getTypeID = function() {
- return Light.LIGHTTYPEID_POINTLIGHT
- }
- ,
- e.prototype.needCube = function() {
- return !this.direction
- }
- ,
- e.prototype.getShadowDirection = function(i) {
- if (this.direction)
- return a.prototype.getShadowDirection.call(this, i);
- switch (i) {
- case 0:
- return new Vector3(1,0,0);
- case 1:
- return new Vector3(-1,0,0);
- case 2:
- return new Vector3(0,-1,0);
- case 3:
- return new Vector3(0,1,0);
- case 4:
- return new Vector3(0,0,1);
- case 5:
- return new Vector3(0,0,-1)
- }
- return Vector3.Zero()
- }
- ,
- e.prototype._setDefaultShadowProjectionMatrix = function(i, o, s) {
- var c = this.getScene().activeCamera;
- if (!!c) {
- var d = this.shadowMinZ !== void 0 ? this.shadowMinZ : c.minZ
- , _ = this.shadowMaxZ !== void 0 ? this.shadowMaxZ : c.maxZ
- , b = this.getScene().getEngine().useReverseDepthBuffer;
- Matrix.PerspectiveFovLHToRef(this.shadowAngle, 1, b ? _ : d, b ? d : _, i, !0, this._scene.getEngine().isNDCHalfZRange, void 0, b)
- }
- }
- ,
- e.prototype._buildUniformLayout = function() {
- this._uniformBuffer.addUniform("vLightData", 4),
- this._uniformBuffer.addUniform("vLightDiffuse", 4),
- this._uniformBuffer.addUniform("vLightSpecular", 4),
- this._uniformBuffer.addUniform("vLightFalloff", 4),
- this._uniformBuffer.addUniform("shadowsInfo", 3),
- this._uniformBuffer.addUniform("depthValues", 2),
- this._uniformBuffer.create()
- }
- ,
- e.prototype.transferToEffect = function(i, o) {
- 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),
- this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, 0, 0, o),
- this
- }
- ,
- e.prototype.transferToNodeMaterialEffect = function(i, o) {
- 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),
- this
- }
- ,
- e.prototype.prepareLightSpecificDefines = function(i, o) {
- i["POINTLIGHT" + o] = !0
- }
- ,
- __decorate([serialize()], e.prototype, "shadowAngle", null),
- e
- }(ShadowLight);
- function CreateRibbonVertexData(a) {
- var e = a.pathArray
- , i = a.closeArray || !1
- , o = a.closePath || !1
- , s = a.invertUV || !1
- , c = Math.floor(e[0].length / 2)
- , d = a.offset || c;
- d = d > c ? c : Math.floor(d);
- 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;
- if (e.length < 2) {
- var ft = []
- , ht = [];
- for (ct = 0; ct < e[0].length - d; ct++)
- ft.push(e[0][ct]),
- ht.push(e[0][ct + d]);
- e = [ft, ht]
- }
- var pt = 0, dt = o ? 1 : 0, _t, mt;
- ot = e[0].length;
- var vt, yt;
- for (ut = 0; ut < e.length; ut++) {
- for (it[ut] = 0,
- tt[ut] = [0],
- _t = e[ut],
- mt = _t.length,
- ot = ot < mt ? ot : mt,
- lt = 0; lt < mt; )
- j.push(_t[lt].x, _t[lt].y, _t[lt].z),
- lt > 0 && (vt = _t[lt].subtract(_t[lt - 1]).length(),
- yt = vt + it[ut],
- tt[ut].push(yt),
- it[ut] = yt),
- lt++;
- o && (lt--,
- j.push(_t[0].x, _t[0].y, _t[0].z),
- vt = _t[lt].subtract(_t[0]).length(),
- yt = vt + it[ut],
- tt[ut].push(yt),
- it[ut] = yt),
- at[ut] = mt + dt,
- st[ut] = pt,
- pt += mt + dt
- }
- var Et, At, gt = null, St = null;
- for (ct = 0; ct < ot + dt; ct++) {
- for (nt[ct] = 0,
- rt[ct] = [0],
- ut = 0; ut < e.length - 1; ut++)
- Et = e[ut],
- At = e[ut + 1],
- ct === ot ? (gt = Et[0],
- St = At[0]) : (gt = Et[ct],
- St = At[ct]),
- vt = St.subtract(gt).length(),
- yt = vt + nt[ct],
- rt[ct].push(yt),
- nt[ct] = yt;
- i && St && gt && (Et = e[ut],
- At = e[0],
- ct === ot && (St = At[0]),
- vt = St.subtract(gt).length(),
- yt = vt + nt[ct],
- nt[ct] = yt)
- }
- var xt, bt;
- if (b)
- for (ut = 0; ut < b.length; ut++)
- et.push(b[ut].x, b[ut].y);
- else
- for (ut = 0; ut < e.length; ut++)
- for (ct = 0; ct < ot + dt; ct++)
- xt = it[ut] != 0 ? tt[ut][ct] / it[ut] : 0,
- bt = nt[ct] != 0 ? rt[ct][ut] / nt[ct] : 0,
- s ? et.push(bt, xt) : et.push(xt, bt);
- ut = 0;
- 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; )
- $.push(Rt, Rt + Dt, Rt + 1),
- $.push(Rt + Dt + 1, Rt + 1, Rt + Dt),
- Rt += 1,
- Rt === It && (ut++,
- ut === at.length - 1 ? (Dt = st[0] - st[ut],
- Mt = at[ut] - 1,
- Pt = at[0] - 1) : (Dt = st[ut + 1] - st[ut],
- Mt = at[ut] - 1,
- Pt = at[ut + 1] - 1),
- Rt = st[ut],
- It = Mt < Pt ? Mt + Rt : Pt + Rt);
- if (VertexData.ComputeNormals(j, $, _e),
- o) {
- var Ot = 0
- , wt = 0;
- for (ut = 0; ut < e.length; ut++)
- Ot = st[ut] * 3,
- ut + 1 < e.length ? wt = (st[ut + 1] - 1) * 3 : wt = _e.length - 3,
- _e[Ot] = (_e[Ot] + _e[wt]) * .5,
- _e[Ot + 1] = (_e[Ot + 1] + _e[wt + 1]) * .5,
- _e[Ot + 2] = (_e[Ot + 2] + _e[wt + 2]) * .5,
- _e[wt] = _e[Ot],
- _e[wt + 1] = _e[Ot + 1],
- _e[wt + 2] = _e[Ot + 2]
- }
- VertexData._ComputeSides(_, j, $, _e, et, a.frontUVs, a.backUVs);
- var Nt = null;
- if (k) {
- Nt = new Float32Array(k.length * 4);
- for (var Ft = 0; Ft < k.length; Ft++)
- Nt[Ft * 4] = k[Ft].r,
- Nt[Ft * 4 + 1] = k[Ft].g,
- Nt[Ft * 4 + 2] = k[Ft].b,
- Nt[Ft * 4 + 3] = k[Ft].a
- }
- var Vt = new VertexData
- , Lt = new Float32Array(j)
- , kt = new Float32Array(_e)
- , Bt = new Float32Array(et);
- return Vt.indices = $,
- Vt.positions = Lt,
- Vt.normals = kt,
- Vt.uvs = Bt,
- Nt && Vt.set(Nt, VertexBuffer.ColorKind),
- o && (Vt._idx = st),
- Vt
- }
- function CreateRibbon(a, e, i) {
- i === void 0 && (i = null);
- var o = e.pathArray
- , s = e.closeArray
- , c = e.closePath
- , d = Mesh._GetDefaultSideOrientation(e.sideOrientation)
- , _ = e.instance
- , b = e.updatable;
- if (_) {
- var k = TmpVectors.Vector3[0].setAll(Number.MAX_VALUE)
- , j = TmpVectors.Vector3[1].setAll(-Number.MAX_VALUE)
- , $ = function(dt) {
- for (var _t = o[0].length, mt = _, vt = 0, yt = mt._originalBuilderSideOrientation === Mesh.DOUBLESIDE ? 2 : 1, Et = 1; Et <= yt; ++Et)
- for (var At = 0; At < o.length; ++At) {
- var gt = o[At]
- , St = gt.length;
- _t = _t < St ? _t : St;
- for (var xt = 0; xt < _t; ++xt) {
- var bt = gt[xt];
- dt[vt] = bt.x,
- dt[vt + 1] = bt.y,
- dt[vt + 2] = bt.z,
- k.minimizeInPlaceFromFloats(bt.x, bt.y, bt.z),
- j.maximizeInPlaceFromFloats(bt.x, bt.y, bt.z),
- vt += 3
- }
- if (mt._creationDataStorage && mt._creationDataStorage.closePath) {
- var bt = gt[0];
- dt[vt] = bt.x,
- dt[vt + 1] = bt.y,
- dt[vt + 2] = bt.z,
- vt += 3
- }
- }
- }
- , _e = _.getVerticesData(VertexBuffer.PositionKind);
- if ($(_e),
- _.hasBoundingInfo ? _.getBoundingInfo().reConstruct(k, j, _._worldMatrix) : _.buildBoundingInfo(k, j, _._worldMatrix),
- _.updateVerticesData(VertexBuffer.PositionKind, _e, !1, !1),
- e.colors) {
- for (var et = _.getVerticesData(VertexBuffer.ColorKind), tt = 0, rt = 0; tt < e.colors.length; tt++,
- rt += 4) {
- var it = e.colors[tt];
- et[rt] = it.r,
- et[rt + 1] = it.g,
- et[rt + 2] = it.b,
- et[rt + 3] = it.a
- }
- _.updateVerticesData(VertexBuffer.ColorKind, et, !1, !1)
- }
- if (e.uvs) {
- for (var nt = _.getVerticesData(VertexBuffer.UVKind), ot = 0; ot < e.uvs.length; ot++)
- nt[ot * 2] = e.uvs[ot].x,
- nt[ot * 2 + 1] = e.uvs[ot].y;
- _.updateVerticesData(VertexBuffer.UVKind, nt, !1, !1)
- }
- if (!_.areNormalsFrozen || _.isFacetDataEnabled) {
- var at = _.getIndices()
- , st = _.getVerticesData(VertexBuffer.NormalKind)
- , ut = _.isFacetDataEnabled ? _.getFacetDataParameters() : null;
- if (VertexData.ComputeNormals(_e, at, st, ut),
- _._creationDataStorage && _._creationDataStorage.closePath)
- for (var ct = 0, lt = 0, ft = 0; ft < o.length; ft++)
- ct = _._creationDataStorage.idx[ft] * 3,
- ft + 1 < o.length ? lt = (_._creationDataStorage.idx[ft + 1] - 1) * 3 : lt = st.length - 3,
- st[ct] = (st[ct] + st[lt]) * .5,
- st[ct + 1] = (st[ct + 1] + st[lt + 1]) * .5,
- st[ct + 2] = (st[ct + 2] + st[lt + 2]) * .5,
- st[lt] = st[ct],
- st[lt + 1] = st[ct + 1],
- st[lt + 2] = st[ct + 2];
- _.areNormalsFrozen || _.updateVerticesData(VertexBuffer.NormalKind, st, !1, !1)
- }
- return _
- } else {
- var ht = new Mesh(a,i);
- ht._originalBuilderSideOrientation = d,
- ht._creationDataStorage = new _CreationDataStorage;
- var pt = CreateRibbonVertexData(e);
- return c && (ht._creationDataStorage.idx = pt._idx),
- ht._creationDataStorage.closePath = c,
- ht._creationDataStorage.closeArray = s,
- pt.applyToMesh(ht, b),
- ht
- }
- }
- VertexData.CreateRibbon = CreateRibbonVertexData;
- Mesh.CreateRibbon = function(a, e, i, o, s, c, d, _, b) {
- return i === void 0 && (i = !1),
- d === void 0 && (d = !1),
- CreateRibbon(a, {
- pathArray: e,
- closeArray: i,
- closePath: o,
- offset: s,
- updatable: d,
- sideOrientation: _,
- instance: b
- }, c)
- }
- ;
- function CreateDiscVertexData(a) {
- var e = new Array
- , i = new Array
- , o = new Array
- , s = new Array
- , c = a.radius || .5
- , d = a.tessellation || 64
- , _ = a.arc && (a.arc <= 0 || a.arc > 1) ? 1 : a.arc || 1
- , b = a.sideOrientation === 0 ? 0 : a.sideOrientation || VertexData.DEFAULTSIDE;
- e.push(0, 0, 0),
- s.push(.5, .5);
- for (var k = Math.PI * 2 * _, j = _ === 1 ? k / d : k / (d - 1), $ = 0, _e = 0; _e < d; _e++) {
- var et = Math.cos($)
- , tt = Math.sin($)
- , rt = (et + 1) / 2
- , it = (1 - tt) / 2;
- e.push(c * et, c * tt, 0),
- s.push(rt, it),
- $ += j
- }
- _ === 1 && (e.push(e[3], e[4], e[5]),
- s.push(s[2], s[3]));
- for (var nt = e.length / 3, ot = 1; ot < nt - 1; ot++)
- i.push(ot + 1, 0, ot);
- VertexData.ComputeNormals(e, i, o),
- VertexData._ComputeSides(b, e, i, o, s, a.frontUVs, a.backUVs);
- var at = new VertexData;
- return at.indices = i,
- at.positions = e,
- at.normals = o,
- at.uvs = s,
- at
- }
- function CreateDisc(a, e, i) {
- e === void 0 && (e = {}),
- i === void 0 && (i = null);
- var o = new Mesh(a,i);
- e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
- o._originalBuilderSideOrientation = e.sideOrientation;
- var s = CreateDiscVertexData(e);
- return s.applyToMesh(o, e.updatable),
- o
- }
- VertexData.CreateDisc = CreateDiscVertexData;
- Mesh.CreateDisc = function(a, e, i, o, s, c) {
- o === void 0 && (o = null);
- var d = {
- radius: e,
- tessellation: i,
- sideOrientation: c,
- updatable: s
- };
- return CreateDisc(a, d, o)
- }
- ;
- function CreateBoxVertexData(a) {
- var e = 6
- , 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]
- , 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]
- , s = []
- , c = []
- , d = a.width || a.size || 1
- , _ = a.height || a.size || 1
- , b = a.depth || a.size || 1
- , k = a.wrap || !1
- , j = a.topBaseAt === void 0 ? 1 : a.topBaseAt
- , $ = a.bottomBaseAt === void 0 ? 0 : a.bottomBaseAt;
- j = (j + 4) % 4,
- $ = ($ + 4) % 4;
- var _e = [2, 0, 3, 1]
- , et = [2, 0, 1, 3]
- , tt = _e[j]
- , rt = et[$]
- , 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];
- if (k) {
- 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],
- 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];
- 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; )
- nt.unshift(nt.pop()),
- at.unshift(at.pop()),
- tt--;
- for (; rt > 0; )
- ot.unshift(ot.pop()),
- st.unshift(st.pop()),
- rt--;
- nt = nt.flat(),
- ot = ot.flat(),
- it = it.concat(nt).concat(ot),
- i.push(at[0], at[2], at[3], at[0], at[1], at[2]),
- i.push(st[0], st[2], st[3], st[0], st[1], st[2])
- }
- var ut = [d / 2, _ / 2, b / 2];
- c = it.reduce(function(yt, Et, At) {
- return yt.concat(Et * ut[At % 3])
- }, []);
- 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++)
- lt[pt] === void 0 && (lt[pt] = new Vector4(0,0,1,1)),
- ft && ft[pt] === void 0 && (ft[pt] = new Color4(1,1,1,1));
- for (var dt = 0; dt < e; dt++)
- if (s.push(lt[dt].z, lt[dt].w),
- s.push(lt[dt].x, lt[dt].w),
- s.push(lt[dt].x, lt[dt].y),
- s.push(lt[dt].z, lt[dt].y),
- ft)
- for (var _t = 0; _t < 4; _t++)
- ht.push(ft[dt].r, ft[dt].g, ft[dt].b, ft[dt].a);
- VertexData._ComputeSides(ct, c, i, o, s, a.frontUVs, a.backUVs);
- var mt = new VertexData;
- if (mt.indices = i,
- mt.positions = c,
- mt.normals = o,
- mt.uvs = s,
- ft) {
- var vt = ct === VertexData.DOUBLESIDE ? ht.concat(ht) : ht;
- mt.colors = vt
- }
- return mt
- }
- function CreateBox(a, e, i) {
- e === void 0 && (e = {}),
- i === void 0 && (i = null);
- var o = new Mesh(a,i);
- e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
- o._originalBuilderSideOrientation = e.sideOrientation;
- var s = CreateBoxVertexData(e);
- return s.applyToMesh(o, e.updatable),
- o
- }
- VertexData.CreateBox = CreateBoxVertexData;
- Mesh.CreateBox = function(a, e, i, o, s) {
- i === void 0 && (i = null);
- var c = {
- size: e,
- sideOrientation: s,
- updatable: o
- };
- return CreateBox(a, c, i)
- }
- ;
- function CreateTiledPlaneVertexData(a) {
- var e = a.pattern || Mesh.NO_FLIP
- , i = a.tileWidth || a.tileSize || 1
- , o = a.tileHeight || a.tileSize || 1
- , s = a.alignHorizontal || 0
- , c = a.alignVertical || 0
- , d = a.width || a.size || 1
- , _ = Math.floor(d / i)
- , b = d - _ * i
- , k = a.height || a.size || 1
- , j = Math.floor(k / o)
- , $ = k - j * o
- , _e = i * _ / 2
- , et = o * j / 2
- , tt = 0
- , rt = 0
- , it = 0
- , nt = 0
- , ot = 0
- , at = 0;
- if (b > 0 || $ > 0) {
- it = -_e,
- nt = -et;
- var ot = _e
- , at = et;
- switch (s) {
- case Mesh.CENTER:
- b /= 2,
- it -= b,
- ot += b;
- break;
- case Mesh.LEFT:
- ot += b,
- tt = -b / 2;
- break;
- case Mesh.RIGHT:
- it -= b,
- tt = b / 2;
- break
- }
- switch (c) {
- case Mesh.CENTER:
- $ /= 2,
- nt -= $,
- at += $;
- break;
- case Mesh.BOTTOM:
- at += $,
- rt = -$ / 2;
- break;
- case Mesh.TOP:
- nt -= $,
- rt = $ / 2;
- break
- }
- }
- var st = []
- , ut = []
- , ct = [];
- ct[0] = [0, 0, 1, 0, 1, 1, 0, 1],
- ct[1] = [0, 0, 1, 0, 1, 1, 0, 1],
- (e === Mesh.ROTATE_TILE || e === Mesh.ROTATE_ROW) && (ct[1] = [1, 1, 0, 1, 0, 0, 1, 0]),
- (e === Mesh.FLIP_TILE || e === Mesh.FLIP_ROW) && (ct[1] = [1, 0, 0, 0, 0, 1, 1, 1]),
- (e === Mesh.FLIP_N_ROTATE_TILE || e === Mesh.FLIP_N_ROTATE_ROW) && (ct[1] = [0, 1, 1, 1, 1, 0, 0, 0]);
- for (var lt = [], ft = [], ht = [], pt = 0, dt = 0; dt < j; dt++)
- for (var _t = 0; _t < _; _t++)
- st.push(-_e + _t * i + tt, -et + dt * o + rt, 0),
- st.push(-_e + (_t + 1) * i + tt, -et + dt * o + rt, 0),
- st.push(-_e + (_t + 1) * i + tt, -et + (dt + 1) * o + rt, 0),
- st.push(-_e + _t * i + tt, -et + (dt + 1) * o + rt, 0),
- ht.push(pt, pt + 1, pt + 3, pt + 1, pt + 2, pt + 3),
- 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]),
- ft.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
- ut.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1),
- pt += 4;
- if (b > 0 || $ > 0) {
- 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;
- if (mt && yt && (st.push(it + tt, nt + rt, 0),
- st.push(-_e + tt, nt + rt, 0),
- st.push(-_e + tt, nt + $ + rt, 0),
- st.push(it + tt, nt + $ + rt, 0),
- ht.push(pt, pt + 1, pt + 3, pt + 1, pt + 2, pt + 3),
- pt += 4,
- gt = 1 - b / i,
- St = 1 - $ / o,
- xt = 1,
- bt = 1,
- At = [gt, St, xt, St, xt, bt, gt, bt],
- e === Mesh.ROTATE_ROW && (At = [1 - gt, 1 - St, 1 - xt, 1 - St, 1 - xt, 1 - bt, 1 - gt, 1 - bt]),
- e === Mesh.FLIP_ROW && (At = [1 - gt, St, 1 - xt, St, 1 - xt, bt, 1 - gt, bt]),
- e === Mesh.FLIP_N_ROTATE_ROW && (At = [gt, 1 - St, xt, 1 - St, xt, 1 - bt, gt, 1 - bt]),
- lt = lt.concat(At),
- ft.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
- ut.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)),
- mt && Et && (st.push(_e + tt, nt + rt, 0),
- st.push(ot + tt, nt + rt, 0),
- st.push(ot + tt, nt + $ + rt, 0),
- st.push(_e + tt, nt + $ + rt, 0),
- ht.push(pt, pt + 1, pt + 3, pt + 1, pt + 2, pt + 3),
- pt += 4,
- gt = 0,
- St = 1 - $ / o,
- xt = b / i,
- bt = 1,
- At = [gt, St, xt, St, xt, bt, gt, bt],
- (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]),
- (e === Mesh.FLIP_ROW || e === Mesh.FLIP_TILE && _ % 2 === 0) && (At = [1 - gt, St, 1 - xt, St, 1 - xt, bt, 1 - gt, bt]),
- (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]),
- lt = lt.concat(At),
- ft.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
- ut.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)),
- vt && yt && (st.push(it + tt, et + rt, 0),
- st.push(-_e + tt, et + rt, 0),
- st.push(-_e + tt, at + rt, 0),
- st.push(it + tt, at + rt, 0),
- ht.push(pt, pt + 1, pt + 3, pt + 1, pt + 2, pt + 3),
- pt += 4,
- gt = 1 - b / i,
- St = 0,
- xt = 1,
- bt = $ / o,
- At = [gt, St, xt, St, xt, bt, gt, bt],
- (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]),
- (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]),
- (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]),
- lt = lt.concat(At),
- ft.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
- ut.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)),
- vt && Et && (st.push(_e + tt, et + rt, 0),
- st.push(ot + tt, et + rt, 0),
- st.push(ot + tt, at + rt, 0),
- st.push(_e + tt, at + rt, 0),
- ht.push(pt, pt + 1, pt + 3, pt + 1, pt + 2, pt + 3),
- pt += 4,
- gt = 0,
- St = 0,
- xt = b / i,
- bt = $ / o,
- At = [gt, St, xt, St, xt, bt, gt, bt],
- (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]),
- (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]),
- (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]),
- lt = lt.concat(At),
- ft.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
- ut.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)),
- mt) {
- var Rt = [];
- gt = 0,
- St = 1 - $ / o,
- xt = 1,
- bt = 1,
- Rt[0] = [gt, St, xt, St, xt, bt, gt, bt],
- Rt[1] = [gt, St, xt, St, xt, bt, gt, bt],
- (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]),
- (e === Mesh.FLIP_TILE || e === Mesh.FLIP_ROW) && (Rt[1] = [1 - gt, St, 1 - xt, St, 1 - xt, bt, 1 - gt, bt]),
- (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]);
- for (var _t = 0; _t < _; _t++)
- st.push(-_e + _t * i + tt, nt + rt, 0),
- st.push(-_e + (_t + 1) * i + tt, nt + rt, 0),
- st.push(-_e + (_t + 1) * i + tt, nt + $ + rt, 0),
- st.push(-_e + _t * i + tt, nt + $ + rt, 0),
- ht.push(pt, pt + 1, pt + 3, pt + 1, pt + 2, pt + 3),
- pt += 4,
- 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]),
- ft.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
- ut.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)
- }
- if (vt) {
- var Mt = [];
- gt = 0,
- St = 0,
- xt = 1,
- bt = $ / o,
- Mt[0] = [gt, St, xt, St, xt, bt, gt, bt],
- Mt[1] = [gt, St, xt, St, xt, bt, gt, bt],
- (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]),
- (e === Mesh.FLIP_TILE || e === Mesh.FLIP_ROW) && (Mt[1] = [1 - gt, St, 1 - xt, St, 1 - xt, bt, 1 - gt, bt]),
- (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]);
- for (var _t = 0; _t < _; _t++)
- st.push(-_e + _t * i + tt, at - $ + rt, 0),
- st.push(-_e + (_t + 1) * i + tt, at - $ + rt, 0),
- st.push(-_e + (_t + 1) * i + tt, at + rt, 0),
- st.push(-_e + _t * i + tt, at + rt, 0),
- ht.push(pt, pt + 1, pt + 3, pt + 1, pt + 2, pt + 3),
- pt += 4,
- 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]),
- ft.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
- ut.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)
- }
- if (yt) {
- var Pt = [];
- gt = 1 - b / i,
- St = 0,
- xt = 1,
- bt = 1,
- Pt[0] = [gt, St, xt, St, xt, bt, gt, bt],
- Pt[1] = [gt, St, xt, St, xt, bt, gt, bt],
- (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]),
- (e === Mesh.FLIP_TILE || e === Mesh.FLIP_ROW) && (Pt[1] = [1 - gt, St, 1 - xt, St, 1 - xt, bt, 1 - gt, bt]),
- (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]);
- for (var dt = 0; dt < j; dt++)
- st.push(it + tt, -et + dt * o + rt, 0),
- st.push(it + b + tt, -et + dt * o + rt, 0),
- st.push(it + b + tt, -et + (dt + 1) * o + rt, 0),
- st.push(it + tt, -et + (dt + 1) * o + rt, 0),
- ht.push(pt, pt + 1, pt + 3, pt + 1, pt + 2, pt + 3),
- pt += 4,
- 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]),
- ft.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
- ut.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)
- }
- if (Et) {
- var It = [];
- gt = 0,
- St = 0,
- xt = b / o,
- bt = 1,
- It[0] = [gt, St, xt, St, xt, bt, gt, bt],
- It[1] = [gt, St, xt, St, xt, bt, gt, bt],
- (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]),
- (e === Mesh.FLIP_TILE || e === Mesh.FLIP_ROW) && (It[1] = [1 - gt, St, 1 - xt, St, 1 - xt, bt, 1 - gt, bt]),
- (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]);
- for (var dt = 0; dt < j; dt++)
- st.push(ot - b + tt, -et + dt * o + rt, 0),
- st.push(ot + tt, -et + dt * o + rt, 0),
- st.push(ot + tt, -et + (dt + 1) * o + rt, 0),
- st.push(ot - b + tt, -et + (dt + 1) * o + rt, 0),
- ht.push(pt, pt + 1, pt + 3, pt + 1, pt + 2, pt + 3),
- pt += 4,
- 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]),
- ft.push(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
- ut.push(0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1)
- }
- }
- var Dt = a.sideOrientation === 0 ? 0 : a.sideOrientation || VertexData.DEFAULTSIDE;
- VertexData._ComputeSides(Dt, st, ht, ut, lt, a.frontUVs, a.backUVs);
- var Ct = new VertexData;
- Ct.indices = ht,
- Ct.positions = st,
- Ct.normals = ut,
- Ct.uvs = lt;
- var Ot = Dt === VertexData.DOUBLESIDE ? ft.concat(ft) : ft;
- return Ct.colors = Ot,
- Ct
- }
- function CreateTiledPlane(a, e, i) {
- i === void 0 && (i = null);
- var o = new Mesh(a,i);
- e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
- o._originalBuilderSideOrientation = e.sideOrientation;
- var s = CreateTiledPlaneVertexData(e);
- return s.applyToMesh(o, e.updatable),
- o
- }
- VertexData.CreateTiledPlane = CreateTiledPlaneVertexData;
- function CreateTiledBoxVertexData(a) {
- 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++)
- i[et] === void 0 && (i[et] = new Vector4(0,0,1,1)),
- o && o[et] === void 0 && (o[et] = new Color4(1,1,1,1));
- for (var tt = c / 2, rt = d / 2, it = _ / 2, nt = [], et = 0; et < 2; et++)
- nt[et] = CreateTiledPlaneVertexData({
- pattern: s,
- tileWidth: b,
- tileHeight: k,
- width: c,
- height: d,
- alignVertical: $,
- alignHorizontal: j,
- sideOrientation: _e
- });
- for (var et = 2; et < 4; et++)
- nt[et] = CreateTiledPlaneVertexData({
- pattern: s,
- tileWidth: b,
- tileHeight: k,
- width: _,
- height: d,
- alignVertical: $,
- alignHorizontal: j,
- sideOrientation: _e
- });
- var ot = $;
- $ === Mesh.BOTTOM ? ot = Mesh.TOP : $ === Mesh.TOP && (ot = Mesh.BOTTOM);
- for (var et = 4; et < 6; et++)
- nt[et] = CreateTiledPlaneVertexData({
- pattern: s,
- tileWidth: b,
- tileHeight: k,
- width: c,
- height: _,
- alignVertical: ot,
- alignHorizontal: j,
- sideOrientation: _e
- });
- for (var at = [], st = [], ut = [], ct = [], lt = [], ft = [], ht = [], pt = [], dt = 0, _t = 0, mt = 0, et = 0; et < e; et++) {
- var dt = nt[et].positions.length;
- ft[et] = [],
- ht[et] = [];
- for (var vt = 0; vt < dt / 3; vt++)
- ft[et].push(new Vector3(nt[et].positions[3 * vt],nt[et].positions[3 * vt + 1],nt[et].positions[3 * vt + 2])),
- ht[et].push(new Vector3(nt[et].normals[3 * vt],nt[et].normals[3 * vt + 1],nt[et].normals[3 * vt + 2]));
- _t = nt[et].uvs.length,
- pt[et] = [];
- for (var yt = 0; yt < _t; yt += 2)
- pt[et][yt] = i[et].x + (i[et].z - i[et].x) * nt[et].uvs[yt],
- pt[et][yt + 1] = i[et].y + (i[et].w - i[et].y) * nt[et].uvs[yt + 1];
- if (ut = ut.concat(pt[et]),
- ct = ct.concat(nt[et].indices.map(function(wt) {
- return wt + mt
- })),
- mt += ft[et].length,
- o)
- for (var Et = 0; Et < 4; Et++)
- lt.push(o[et].r, o[et].g, o[et].b, o[et].a)
- }
- var At = new Vector3(0,0,it)
- , gt = Matrix.RotationY(Math.PI);
- at = ft[0].map(function(Ct) {
- return Vector3.TransformNormal(Ct, gt).add(At)
- }).map(function(Ct) {
- return [Ct.x, Ct.y, Ct.z]
- }).reduce(function(Ct, Ot) {
- return Ct.concat(Ot)
- }, []),
- st = ht[0].map(function(Ct) {
- return Vector3.TransformNormal(Ct, gt)
- }).map(function(Ct) {
- return [Ct.x, Ct.y, Ct.z]
- }).reduce(function(Ct, Ot) {
- return Ct.concat(Ot)
- }, []),
- at = at.concat(ft[1].map(function(Ct) {
- return Ct.subtract(At)
- }).map(function(Ct) {
- return [Ct.x, Ct.y, Ct.z]
- }).reduce(function(Ct, Ot) {
- return Ct.concat(Ot)
- }, [])),
- st = st.concat(ht[1].map(function(Ct) {
- return [Ct.x, Ct.y, Ct.z]
- }).reduce(function(Ct, Ot) {
- return Ct.concat(Ot)
- }, []));
- var St = new Vector3(tt,0,0)
- , xt = Matrix.RotationY(-Math.PI / 2);
- at = at.concat(ft[2].map(function(Ct) {
- return Vector3.TransformNormal(Ct, xt).add(St)
- }).map(function(Ct) {
- return [Ct.x, Ct.y, Ct.z]
- }).reduce(function(Ct, Ot) {
- return Ct.concat(Ot)
- }, [])),
- st = st.concat(ht[2].map(function(Ct) {
- return Vector3.TransformNormal(Ct, xt)
- }).map(function(Ct) {
- return [Ct.x, Ct.y, Ct.z]
- }).reduce(function(Ct, Ot) {
- return Ct.concat(Ot)
- }, []));
- var bt = Matrix.RotationY(Math.PI / 2);
- at = at.concat(ft[3].map(function(Ct) {
- return Vector3.TransformNormal(Ct, bt).subtract(St)
- }).map(function(Ct) {
- return [Ct.x, Ct.y, Ct.z]
- }).reduce(function(Ct, Ot) {
- return Ct.concat(Ot)
- }, [])),
- st = st.concat(ht[3].map(function(Ct) {
- return Vector3.TransformNormal(Ct, bt)
- }).map(function(Ct) {
- return [Ct.x, Ct.y, Ct.z]
- }).reduce(function(Ct, Ot) {
- return Ct.concat(Ot)
- }, []));
- var Rt = new Vector3(0,rt,0)
- , Mt = Matrix.RotationX(Math.PI / 2);
- at = at.concat(ft[4].map(function(Ct) {
- return Vector3.TransformNormal(Ct, Mt).add(Rt)
- }).map(function(Ct) {
- return [Ct.x, Ct.y, Ct.z]
- }).reduce(function(Ct, Ot) {
- return Ct.concat(Ot)
- }, [])),
- st = st.concat(ht[4].map(function(Ct) {
- return Vector3.TransformNormal(Ct, Mt)
- }).map(function(Ct) {
- return [Ct.x, Ct.y, Ct.z]
- }).reduce(function(Ct, Ot) {
- return Ct.concat(Ot)
- }, []));
- var Pt = Matrix.RotationX(-Math.PI / 2);
- at = at.concat(ft[5].map(function(Ct) {
- return Vector3.TransformNormal(Ct, Pt).subtract(Rt)
- }).map(function(Ct) {
- return [Ct.x, Ct.y, Ct.z]
- }).reduce(function(Ct, Ot) {
- return Ct.concat(Ot)
- }, [])),
- st = st.concat(ht[5].map(function(Ct) {
- return Vector3.TransformNormal(Ct, Pt)
- }).map(function(Ct) {
- return [Ct.x, Ct.y, Ct.z]
- }).reduce(function(Ct, Ot) {
- return Ct.concat(Ot)
- }, [])),
- VertexData._ComputeSides(_e, at, ct, st, ut);
- var It = new VertexData;
- if (It.indices = ct,
- It.positions = at,
- It.normals = st,
- It.uvs = ut,
- o) {
- var Dt = _e === VertexData.DOUBLESIDE ? lt.concat(lt) : lt;
- It.colors = Dt
- }
- return It
- }
- function CreateTiledBox(a, e, i) {
- i === void 0 && (i = null);
- var o = new Mesh(a,i);
- e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
- o._originalBuilderSideOrientation = e.sideOrientation;
- var s = CreateTiledBoxVertexData(e);
- return s.applyToMesh(o, e.updatable),
- o
- }
- VertexData.CreateTiledBox = CreateTiledBoxVertexData;
- function CreateSphereVertexData(a) {
- 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++) {
- for (var nt = it / j, ot = nt * Math.PI * d, at = 0; at <= $; at++) {
- var st = at / $
- , ut = st * Math.PI * 2 * c
- , ct = Matrix.RotationZ(-ot)
- , lt = Matrix.RotationY(ut)
- , ft = Vector3.TransformCoordinates(Vector3.Up(), ct)
- , ht = Vector3.TransformCoordinates(ft, lt)
- , pt = ht.multiply(k)
- , dt = ht.divide(k).normalize();
- et.push(pt.x, pt.y, pt.z),
- tt.push(dt.x, dt.y, dt.z),
- rt.push(st, nt)
- }
- if (it > 0)
- for (var _t = et.length / 3, mt = _t - 2 * ($ + 1); mt + $ + 2 < _t; mt++)
- b ? (it > 1 && (_e.push(mt),
- _e.push(mt + 1),
- _e.push(mt + $ + 1)),
- (it < j || d < 1) && (_e.push(mt + $ + 1),
- _e.push(mt + 1),
- _e.push(mt + $ + 2))) : (_e.push(mt),
- _e.push(mt + 1),
- _e.push(mt + $ + 1),
- _e.push(mt + $ + 1),
- _e.push(mt + 1),
- _e.push(mt + $ + 2))
- }
- VertexData._ComputeSides(_, et, _e, tt, rt, a.frontUVs, a.backUVs);
- var vt = new VertexData;
- return vt.indices = _e,
- vt.positions = et,
- vt.normals = tt,
- vt.uvs = rt,
- vt
- }
- function CreateSphere(a, e, i) {
- e === void 0 && (e = {}),
- i === void 0 && (i = null);
- var o = new Mesh(a,i);
- e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
- o._originalBuilderSideOrientation = e.sideOrientation;
- var s = CreateSphereVertexData(e);
- return s.applyToMesh(o, e.updatable),
- o
- }
- VertexData.CreateSphere = CreateSphereVertexData;
- Mesh.CreateSphere = function(a, e, i, o, s, c) {
- var d = {
- segments: e,
- diameterX: i,
- diameterY: i,
- diameterZ: i,
- sideOrientation: c,
- updatable: s
- };
- return CreateSphere(a, d, o)
- }
- ;
- function CreateCylinderVertexData(a) {
- var e = a.height || 2
- , i = a.diameterTop === 0 ? 0 : a.diameterTop || a.diameter || 1
- , o = a.diameterBottom === 0 ? 0 : a.diameterBottom || a.diameter || 1;
- i = i || 1e-5,
- o = o || 1e-5;
- 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;
- for (it = 0; it < rt; it++)
- _e && _e[it] === void 0 && (_e[it] = new Color4(1,1,1,1));
- for (it = 0; it < rt; it++)
- $ && $[it] === void 0 && ($[it] = new Vector4(0,0,1,1));
- 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;
- for (At = 0; At <= c; At++)
- for (ft = At / c,
- ht = (ft * (i - o) + o) / 2,
- xt = d && At !== 0 && At !== c ? 2 : 1,
- St = 0; St < xt; St++) {
- for (d && (Pt += St),
- _ && (Pt += 2 * St),
- gt = 0; gt <= s; gt++)
- lt = gt * ct,
- dt.x = Math.cos(-lt) * ht,
- dt.y = -e / 2 + ft * e,
- dt.z = Math.sin(-lt) * ht,
- i === 0 && At === c ? (_t.x = at[at.length - (s + 1) * 3],
- _t.y = at[at.length - (s + 1) * 3 + 1],
- _t.z = at[at.length - (s + 1) * 3 + 2]) : (_t.x = dt.x,
- _t.z = dt.z,
- _t.y = Math.sqrt(_t.x * _t.x + _t.z * _t.z) * pt,
- _t.normalize()),
- gt === 0 && (mt.copyFrom(dt),
- vt.copyFrom(_t)),
- ot.push(dt.x, dt.y, dt.z),
- at.push(_t.x, _t.y, _t.z),
- d ? Rt = bt !== Pt ? $[Pt].y : $[Pt].w : Rt = $[Pt].y + ($[Pt].w - $[Pt].y) * ft,
- st.push($[Pt].x + ($[Pt].z - $[Pt].x) * gt / s, Rt),
- _e && ut.push(_e[Pt].r, _e[Pt].g, _e[Pt].b, _e[Pt].a);
- k !== 1 && _ && (ot.push(dt.x, dt.y, dt.z),
- ot.push(0, dt.y, 0),
- ot.push(0, dt.y, 0),
- ot.push(mt.x, mt.y, mt.z),
- Vector3.CrossToRef(Et, _t, yt),
- yt.normalize(),
- at.push(yt.x, yt.y, yt.z, yt.x, yt.y, yt.z),
- Vector3.CrossToRef(vt, Et, yt),
- yt.normalize(),
- at.push(yt.x, yt.y, yt.z, yt.x, yt.y, yt.z),
- d ? Rt = bt !== Pt ? $[Pt + 1].y : $[Pt + 1].w : Rt = $[Pt + 1].y + ($[Pt + 1].w - $[Pt + 1].y) * ft,
- st.push($[Pt + 1].x, Rt),
- st.push($[Pt + 1].z, Rt),
- d ? Rt = bt !== Pt ? $[Pt + 2].y : $[Pt + 2].w : Rt = $[Pt + 2].y + ($[Pt + 2].w - $[Pt + 2].y) * ft,
- st.push($[Pt + 2].x, Rt),
- st.push($[Pt + 2].z, Rt),
- _e && (ut.push(_e[Pt + 1].r, _e[Pt + 1].g, _e[Pt + 1].b, _e[Pt + 1].a),
- ut.push(_e[Pt + 1].r, _e[Pt + 1].g, _e[Pt + 1].b, _e[Pt + 1].a),
- ut.push(_e[Pt + 2].r, _e[Pt + 2].g, _e[Pt + 2].b, _e[Pt + 2].a),
- ut.push(_e[Pt + 2].r, _e[Pt + 2].g, _e[Pt + 2].b, _e[Pt + 2].a))),
- bt !== Pt && (bt = Pt)
- }
- var Mt = k !== 1 && _ ? s + 4 : s, Pt;
- for (At = 0,
- Pt = 0; Pt < c; Pt++) {
- var It = 0
- , Dt = 0
- , Ct = 0
- , Ot = 0;
- for (gt = 0; gt < s; gt++)
- It = At * (Mt + 1) + gt,
- Dt = (At + 1) * (Mt + 1) + gt,
- Ct = At * (Mt + 1) + (gt + 1),
- Ot = (At + 1) * (Mt + 1) + (gt + 1),
- nt.push(It, Dt, Ct),
- nt.push(Ot, Ct, Dt);
- k !== 1 && _ && (nt.push(It + 2, Dt + 2, Ct + 2),
- nt.push(Ot + 2, Ct + 2, Dt + 2),
- nt.push(It + 4, Dt + 4, Ct + 4),
- nt.push(Ot + 4, Ct + 4, Dt + 4)),
- At = d ? At + 2 : At + 1
- }
- var wt = function(Ft) {
- var Vt = Ft ? i / 2 : o / 2;
- if (Vt !== 0) {
- var Lt, kt, Bt, Ut = Ft ? $[rt - 1] : $[0], Gt = null;
- _e && (Gt = Ft ? _e[rt - 1] : _e[0]);
- var Ht = ot.length / 3
- , zt = Ft ? e / 2 : -e / 2
- , Wt = new Vector3(0,zt,0);
- ot.push(Wt.x, Wt.y, Wt.z),
- at.push(0, Ft ? 1 : -1, 0),
- st.push(Ut.x + (Ut.z - Ut.x) * .5, Ut.y + (Ut.w - Ut.y) * .5),
- Gt && ut.push(Gt.r, Gt.g, Gt.b, Gt.a);
- var Kt = new Vector2(.5,.5);
- for (Bt = 0; Bt <= s; Bt++) {
- Lt = Math.PI * 2 * Bt * k / s;
- var Qt = Math.cos(-Lt)
- , qt = Math.sin(-Lt);
- kt = new Vector3(Qt * Vt,zt,qt * Vt);
- var Yt = new Vector2(Qt * Kt.x + .5,qt * Kt.y + .5);
- ot.push(kt.x, kt.y, kt.z),
- at.push(0, Ft ? 1 : -1, 0),
- st.push(Ut.x + (Ut.z - Ut.x) * Yt.x, Ut.y + (Ut.w - Ut.y) * Yt.y),
- Gt && ut.push(Gt.r, Gt.g, Gt.b, Gt.a)
- }
- for (Bt = 0; Bt < s; Bt++)
- Ft ? (nt.push(Ht),
- nt.push(Ht + (Bt + 2)),
- nt.push(Ht + (Bt + 1))) : (nt.push(Ht),
- nt.push(Ht + (Bt + 1)),
- nt.push(Ht + (Bt + 2)))
- }
- };
- (b === Mesh.CAP_START || b === Mesh.CAP_ALL) && wt(!1),
- (b === Mesh.CAP_END || b === Mesh.CAP_ALL) && wt(!0),
- VertexData._ComputeSides(j, ot, nt, at, st, a.frontUVs, a.backUVs);
- var Nt = new VertexData;
- return Nt.indices = nt,
- Nt.positions = ot,
- Nt.normals = at,
- Nt.uvs = st,
- _e && (Nt.colors = ut),
- Nt
- }
- function CreateCylinder(a, e, i) {
- e === void 0 && (e = {});
- var o = new Mesh(a,i);
- e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
- o._originalBuilderSideOrientation = e.sideOrientation;
- var s = CreateCylinderVertexData(e);
- return s.applyToMesh(o, e.updatable),
- o
- }
- VertexData.CreateCylinder = CreateCylinderVertexData;
- Mesh.CreateCylinder = function(a, e, i, o, s, c, d, _, b) {
- (d === void 0 || !(d instanceof Scene)) && (d !== void 0 && (b = _ || Mesh.DEFAULTSIDE,
- _ = d),
- d = c,
- c = 1);
- var k = {
- height: e,
- diameterTop: i,
- diameterBottom: o,
- tessellation: s,
- subdivisions: c,
- sideOrientation: b,
- updatable: _
- };
- return CreateCylinder(a, k, d)
- }
- ;
- function CreateTorusVertexData(a) {
- 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++)
- 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++) {
- var rt = 1 - tt / _
- , it = tt * Math.PI * 2 / _ + Math.PI
- , nt = Math.cos(it)
- , ot = Math.sin(it)
- , at = new Vector3(nt,ot,0)
- , st = at.scale(d / 2)
- , ut = new Vector2($,rt);
- st = Vector3.TransformCoordinates(st, et),
- at = Vector3.TransformNormal(at, et),
- i.push(st.x, st.y, st.z),
- o.push(at.x, at.y, at.z),
- s.push(ut.x, ut.y);
- var ct = (j + 1) % k
- , lt = (tt + 1) % k;
- e.push(j * k + tt),
- e.push(j * k + lt),
- e.push(ct * k + tt),
- e.push(j * k + lt),
- e.push(ct * k + lt),
- e.push(ct * k + tt)
- }
- VertexData._ComputeSides(b, i, e, o, s, a.frontUVs, a.backUVs);
- var ft = new VertexData;
- return ft.indices = e,
- ft.positions = i,
- ft.normals = o,
- ft.uvs = s,
- ft
- }
- function CreateTorus(a, e, i) {
- e === void 0 && (e = {});
- var o = new Mesh(a,i);
- e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
- o._originalBuilderSideOrientation = e.sideOrientation;
- var s = CreateTorusVertexData(e);
- return s.applyToMesh(o, e.updatable),
- o
- }
- VertexData.CreateTorus = CreateTorusVertexData;
- Mesh.CreateTorus = function(a, e, i, o, s, c, d) {
- var _ = {
- diameter: e,
- thickness: i,
- tessellation: o,
- sideOrientation: d,
- updatable: c
- };
- return CreateTorus(a, _, s)
- }
- ;
- function CreateTorusKnotVertexData(a) {
- 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) {
- var At = Math.cos(Et)
- , gt = Math.sin(Et)
- , St = j / k * Et
- , xt = Math.cos(St)
- , bt = c * (2 + xt) * .5 * At
- , Rt = c * (2 + xt) * gt * .5
- , Mt = c * Math.sin(St) * .5;
- return new Vector3(bt,Rt,Mt)
- }, et, tt;
- for (et = 0; et <= _; et++) {
- var rt = et % _
- , it = rt / _ * 2 * k * Math.PI
- , nt = _e(it)
- , ot = _e(it + .01)
- , at = ot.subtract(nt)
- , st = ot.add(nt)
- , ut = Vector3.Cross(at, st);
- for (st = Vector3.Cross(ut, at),
- ut.normalize(),
- st.normalize(),
- tt = 0; tt < b; tt++) {
- var ct = tt % b
- , lt = ct / b * 2 * Math.PI
- , ft = -d * Math.cos(lt)
- , ht = d * Math.sin(lt);
- i.push(nt.x + ft * st.x + ht * ut.x),
- i.push(nt.y + ft * st.y + ht * ut.y),
- i.push(nt.z + ft * st.z + ht * ut.z),
- s.push(et / _),
- s.push(tt / b)
- }
- }
- for (et = 0; et < _; et++)
- for (tt = 0; tt < b; tt++) {
- var pt = (tt + 1) % b
- , dt = et * b + tt
- , _t = (et + 1) * b + tt
- , mt = (et + 1) * b + pt
- , vt = et * b + pt;
- e.push(vt),
- e.push(_t),
- e.push(dt),
- e.push(vt),
- e.push(mt),
- e.push(_t)
- }
- VertexData.ComputeNormals(i, e, o),
- VertexData._ComputeSides($, i, e, o, s, a.frontUVs, a.backUVs);
- var yt = new VertexData;
- return yt.indices = e,
- yt.positions = i,
- yt.normals = o,
- yt.uvs = s,
- yt
- }
- function CreateTorusKnot(a, e, i) {
- e === void 0 && (e = {});
- var o = new Mesh(a,i);
- e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
- o._originalBuilderSideOrientation = e.sideOrientation;
- var s = CreateTorusKnotVertexData(e);
- return s.applyToMesh(o, e.updatable),
- o
- }
- VertexData.CreateTorusKnot = CreateTorusKnotVertexData;
- Mesh.CreateTorusKnot = function(a, e, i, o, s, c, d, _, b, k) {
- var j = {
- radius: e,
- tube: i,
- radialSegments: o,
- tubularSegments: s,
- p: c,
- q: d,
- sideOrientation: k,
- updatable: b
- };
- return CreateTorusKnot(a, j, _)
- }
- ;
- Mesh._instancedMeshFactory = function(a, e) {
- var i = new InstancedMesh(a,e);
- if (e.instancedBuffers) {
- i.instancedBuffers = {};
- for (var o in e.instancedBuffers)
- i.instancedBuffers[o] = e.instancedBuffers[o]
- }
- return i
- }
- ;
- var InstancedMesh = function(a) {
- __extends(e, a);
- function e(i, o) {
- var s = a.call(this, i, o.getScene()) || this;
- s._indexInSourceMeshInstanceArray = -1,
- s._distanceToCamera = 0,
- o.addInstance(s),
- s._sourceMesh = o,
- s._unIndexed = o._unIndexed,
- s.position.copyFrom(o.position),
- s.rotation.copyFrom(o.rotation),
- s.scaling.copyFrom(o.scaling),
- o.rotationQuaternion && (s.rotationQuaternion = o.rotationQuaternion.clone()),
- s.animations = Tools.Slice(o.animations);
- for (var c = 0, d = o.getAnimationRanges(); c < d.length; c++) {
- var _ = d[c];
- _ != null && s.createAnimationRange(_.name, _.from, _.to)
- }
- return s.infiniteDistance = o.infiniteDistance,
- s.setPivotMatrix(o.getPivotMatrix()),
- s.refreshBoundingInfo(),
- s._syncSubMeshes(),
- s
- }
- return e.prototype.getClassName = function() {
- return "InstancedMesh"
- }
- ,
- Object.defineProperty(e.prototype, "lightSources", {
- get: function() {
- return this._sourceMesh._lightSources
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._resyncLightSources = function() {}
- ,
- e.prototype._resyncLightSource = function(i) {}
- ,
- e.prototype._removeLightSource = function(i, o) {}
- ,
- Object.defineProperty(e.prototype, "receiveShadows", {
- get: function() {
- return this._sourceMesh.receiveShadows
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "material", {
- get: function() {
- return this._sourceMesh.material
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "visibility", {
- get: function() {
- return this._sourceMesh.visibility
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "skeleton", {
- get: function() {
- return this._sourceMesh.skeleton
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "renderingGroupId", {
- get: function() {
- return this._sourceMesh.renderingGroupId
- },
- set: function(i) {
- !this._sourceMesh || i === this._sourceMesh.renderingGroupId || Logger$2.Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene")
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getTotalVertices = function() {
- return this._sourceMesh ? this._sourceMesh.getTotalVertices() : 0
- }
- ,
- e.prototype.getTotalIndices = function() {
- return this._sourceMesh.getTotalIndices()
- }
- ,
- Object.defineProperty(e.prototype, "sourceMesh", {
- get: function() {
- return this._sourceMesh
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.createInstance = function(i) {
- return this._sourceMesh.createInstance(i)
- }
- ,
- e.prototype.isReady = function(i) {
- return i === void 0 && (i = !1),
- this._sourceMesh.isReady(i, !0)
- }
- ,
- e.prototype.getVerticesData = function(i, o) {
- return this._sourceMesh.getVerticesData(i, o)
- }
- ,
- e.prototype.setVerticesData = function(i, o, s, c) {
- return this.sourceMesh && this.sourceMesh.setVerticesData(i, o, s, c),
- this.sourceMesh
- }
- ,
- e.prototype.updateVerticesData = function(i, o, s, c) {
- return this.sourceMesh && this.sourceMesh.updateVerticesData(i, o, s, c),
- this.sourceMesh
- }
- ,
- e.prototype.setIndices = function(i, o) {
- return o === void 0 && (o = null),
- this.sourceMesh && this.sourceMesh.setIndices(i, o),
- this.sourceMesh
- }
- ,
- e.prototype.isVerticesDataPresent = function(i) {
- return this._sourceMesh.isVerticesDataPresent(i)
- }
- ,
- e.prototype.getIndices = function() {
- return this._sourceMesh.getIndices()
- }
- ,
- Object.defineProperty(e.prototype, "_positions", {
- get: function() {
- return this._sourceMesh._positions
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.refreshBoundingInfo = function(i, o) {
- if (i === void 0 && (i = !1),
- o === void 0 && (o = !1),
- this.hasBoundingInfo && this.getBoundingInfo().isLocked)
- return this;
- var s = this._sourceMesh.geometry ? this._sourceMesh.geometry.boundingBias : null;
- return this._refreshBoundingInfo(this._sourceMesh._getPositionData(i, o), s),
- this
- }
- ,
- e.prototype._preActivate = function() {
- return this._currentLOD && this._currentLOD._preActivate(),
- this
- }
- ,
- e.prototype._activate = function(i, o) {
- if (this._sourceMesh.subMeshes || Logger$2.Warn("Instances should only be created for meshes with geometry."),
- this._currentLOD) {
- var s = this._currentLOD._getWorldMatrixDeterminant() > 0 != this._getWorldMatrixDeterminant() > 0;
- if (s)
- return this._internalAbstractMeshDataInfo._actAsRegularMesh = !0,
- !0;
- if (this._internalAbstractMeshDataInfo._actAsRegularMesh = !1,
- this._currentLOD._registerInstanceForRenderId(this, i),
- o) {
- if (!this._currentLOD._internalAbstractMeshDataInfo._isActiveIntermediate)
- return this._currentLOD._internalAbstractMeshDataInfo._onlyForInstancesIntermediate = !0,
- !0
- } else if (!this._currentLOD._internalAbstractMeshDataInfo._isActive)
- return this._currentLOD._internalAbstractMeshDataInfo._onlyForInstances = !0,
- !0
- }
- return !1
- }
- ,
- e.prototype._postActivate = function() {
- this._sourceMesh.edgesShareWithInstances && this._sourceMesh._edgesRenderer && this._sourceMesh._edgesRenderer.isEnabled && this._sourceMesh._renderingGroup ? (this._sourceMesh._renderingGroup._edgesRenderers.pushNoDuplicate(this._sourceMesh._edgesRenderer),
- this._sourceMesh._edgesRenderer.customInstances.push(this.getWorldMatrix())) : this._edgesRenderer && this._edgesRenderer.isEnabled && this._sourceMesh._renderingGroup && this._sourceMesh._renderingGroup._edgesRenderers.push(this._edgesRenderer)
- }
- ,
- e.prototype.getWorldMatrix = function() {
- if (this._currentLOD && this._currentLOD.billboardMode !== TransformNode.BILLBOARDMODE_NONE && this._currentLOD._masterMesh !== this) {
- this._billboardWorldMatrix || (this._billboardWorldMatrix = new Matrix);
- var i = this._currentLOD._masterMesh;
- return this._currentLOD._masterMesh = this,
- TmpVectors.Vector3[7].copyFrom(this._currentLOD.position),
- this._currentLOD.position.set(0, 0, 0),
- this._billboardWorldMatrix.copyFrom(this._currentLOD.computeWorldMatrix(!0)),
- this._currentLOD.position.copyFrom(TmpVectors.Vector3[7]),
- this._currentLOD._masterMesh = i,
- this._billboardWorldMatrix
- }
- return a.prototype.getWorldMatrix.call(this)
- }
- ,
- Object.defineProperty(e.prototype, "isAnInstance", {
- get: function() {
- return !0
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getLOD = function(i) {
- if (!i)
- return this;
- var o = this.getBoundingInfo();
- return this._currentLOD = this.sourceMesh.getLOD(i, o.boundingSphere),
- this._currentLOD === this.sourceMesh ? this.sourceMesh : this._currentLOD
- }
- ,
- e.prototype._preActivateForIntermediateRendering = function(i) {
- return this.sourceMesh._preActivateForIntermediateRendering(i)
- }
- ,
- e.prototype._syncSubMeshes = function() {
- if (this.releaseSubMeshes(),
- this._sourceMesh.subMeshes)
- for (var i = 0; i < this._sourceMesh.subMeshes.length; i++)
- this._sourceMesh.subMeshes[i].clone(this, this._sourceMesh);
- return this
- }
- ,
- e.prototype._generatePointsArray = function() {
- return this._sourceMesh._generatePointsArray()
- }
- ,
- e.prototype._updateBoundingInfo = function() {
- var i = this;
- return this.hasBoundingInfo ? this.getBoundingInfo().update(i.worldMatrixFromCache) : this.buildBoundingInfo(this.absolutePosition, this.absolutePosition, i.worldMatrixFromCache),
- this._updateSubMeshesBoundingInfo(i.worldMatrixFromCache),
- this
- }
- ,
- e.prototype.clone = function(i, o, s) {
- o === void 0 && (o = null);
- var c = this._sourceMesh.createInstance(i);
- 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"], []),
- this.refreshBoundingInfo(),
- o && (c.parent = o),
- !s)
- for (var d = 0; d < this.getScene().meshes.length; d++) {
- var _ = this.getScene().meshes[d];
- _.parent === this && _.clone(_.name, c)
- }
- return c.computeWorldMatrix(!0),
- this.onClonedObservable.notifyObservers(c),
- c
- }
- ,
- e.prototype.dispose = function(i, o) {
- o === void 0 && (o = !1),
- this._sourceMesh.removeInstance(this),
- a.prototype.dispose.call(this, i, o)
- }
- ,
- e
- }(AbstractMesh);
- Mesh.prototype.edgesShareWithInstances = !1;
- Mesh.prototype.registerInstancedBuffer = function(a, e) {
- var i, o;
- if ((o = (i = this._userInstancedBuffersStorage) === null || i === void 0 ? void 0 : i.vertexBuffers[a]) === null || o === void 0 || o.dispose(),
- !this.instancedBuffers) {
- this.instancedBuffers = {};
- for (var s = 0, c = this.instances; s < c.length; s++) {
- var d = c[s];
- d.instancedBuffers = {}
- }
- this._userInstancedBuffersStorage = {
- data: {},
- vertexBuffers: {},
- strides: {},
- sizes: {},
- vertexArrayObjects: this.getEngine().getCaps().vertexArrayObject ? {} : void 0
- }
- }
- this.instancedBuffers[a] = null,
- this._userInstancedBuffersStorage.strides[a] = e,
- this._userInstancedBuffersStorage.sizes[a] = e * 32,
- this._userInstancedBuffersStorage.data[a] = new Float32Array(this._userInstancedBuffersStorage.sizes[a]),
- this._userInstancedBuffersStorage.vertexBuffers[a] = new VertexBuffer(this.getEngine(),this._userInstancedBuffersStorage.data[a],a,!0,!1,e,!0);
- for (var _ = 0, b = this.instances; _ < b.length; _++) {
- var d = b[_];
- d.instancedBuffers[a] = null
- }
- this._invalidateInstanceVertexArrayObject()
- }
- ;
- Mesh.prototype._processInstancedBuffers = function(a, e) {
- var i = a.length;
- for (var o in this.instancedBuffers) {
- for (var s = this._userInstancedBuffersStorage.sizes[o], c = this._userInstancedBuffersStorage.strides[o], d = (i + 1) * c; s < d; )
- s *= 2;
- this._userInstancedBuffersStorage.data[o].length != s && (this._userInstancedBuffersStorage.data[o] = new Float32Array(s),
- this._userInstancedBuffersStorage.sizes[o] = s,
- this._userInstancedBuffersStorage.vertexBuffers[o] && (this._userInstancedBuffersStorage.vertexBuffers[o].dispose(),
- this._userInstancedBuffersStorage.vertexBuffers[o] = null));
- var _ = this._userInstancedBuffersStorage.data[o]
- , b = 0;
- if (e) {
- var k = this.instancedBuffers[o];
- k.toArray ? k.toArray(_, b) : k.copyToArray ? k.copyToArray(_, b) : _[b] = k,
- b += c
- }
- for (var j = 0; j < i; j++) {
- var $ = a[j]
- , k = $.instancedBuffers[o];
- k.toArray ? k.toArray(_, b) : k.copyToArray ? k.copyToArray(_, b) : _[b] = k,
- b += c
- }
- 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),
- this._invalidateInstanceVertexArrayObject())
- }
- }
- ;
- Mesh.prototype._invalidateInstanceVertexArrayObject = function() {
- if (!(!this._userInstancedBuffersStorage || this._userInstancedBuffersStorage.vertexArrayObjects === void 0)) {
- for (var a in this._userInstancedBuffersStorage.vertexArrayObjects)
- this.getEngine().releaseVertexArrayObject(this._userInstancedBuffersStorage.vertexArrayObjects[a]);
- this._userInstancedBuffersStorage.vertexArrayObjects = {}
- }
- }
- ;
- Mesh.prototype._disposeInstanceSpecificData = function() {
- for (this._instanceDataStorage.instancesBuffer && (this._instanceDataStorage.instancesBuffer.dispose(),
- this._instanceDataStorage.instancesBuffer = null); this.instances.length; )
- this.instances[0].dispose();
- for (var a in this.instancedBuffers)
- this._userInstancedBuffersStorage.vertexBuffers[a] && this._userInstancedBuffersStorage.vertexBuffers[a].dispose();
- this._invalidateInstanceVertexArrayObject(),
- this.instancedBuffers = {}
- }
- ;
- var name$1o = "colorPixelShader"
- , shader$1o = `#ifdef VERTEXCOLOR
- varying vec4 vColor;
- #else
- uniform vec4 color;
- #endif
- #include<clipPlaneFragmentDeclaration>
- void main(void) {
- #include<clipPlaneFragment>
- #ifdef VERTEXCOLOR
- gl_FragColor=vColor;
- #else
- gl_FragColor=color;
- #endif
- }`;
- ShaderStore.ShadersStore[name$1o] = shader$1o;
- var name$1n = "colorVertexShader"
- , shader$1n = `
- attribute vec3 position;
- #ifdef VERTEXCOLOR
- attribute vec4 color;
- #endif
- #include<bonesDeclaration>
- #include<bakedVertexAnimationDeclaration>
- #include<clipPlaneVertexDeclaration>
- #include<instancesDeclaration>
- uniform mat4 viewProjection;
- #ifdef MULTIVIEW
- uniform mat4 viewProjectionR;
- #endif
- #ifdef VERTEXCOLOR
- varying vec4 vColor;
- #endif
- void main(void) {
- #include<instancesVertex>
- #include<bonesVertex>
- #include<bakedVertexAnimation>
- vec4 worldPos=finalWorld*vec4(position,1.0);
- #ifdef MULTIVIEW
- if (gl_ViewID_OVR == 0u) {
- gl_Position=viewProjection*worldPos;
- } else {
- gl_Position=viewProjectionR*worldPos;
- }
- #else
- gl_Position=viewProjection*worldPos;
- #endif
- #include<clipPlaneVertex>
- #ifdef VERTEXCOLOR
- vColor=color;
- #endif
- }`;
- ShaderStore.ShadersStore[name$1n] = shader$1n;
- Mesh._LinesMeshParser = function(a, e) {
- return LinesMesh.Parse(a, e)
- }
- ;
- var LinesMesh = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _, b, k) {
- o === void 0 && (o = null),
- s === void 0 && (s = null),
- c === void 0 && (c = null);
- var j = a.call(this, i, o, s, c, d) || this;
- j.useVertexColor = _,
- j.useVertexAlpha = b,
- j.color = new Color3(1,1,1),
- j.alpha = 1,
- c && (j.color = c.color.clone(),
- j.alpha = c.alpha,
- j.useVertexColor = c.useVertexColor,
- j.useVertexAlpha = c.useVertexAlpha),
- j.intersectionThreshold = .1;
- var $ = []
- , _e = {
- attributes: [VertexBuffer.PositionKind],
- uniforms: ["vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "world", "viewProjection"],
- needAlphaBlending: !0,
- defines: $,
- useClipPlane: null
- };
- return b === !1 && (_e.needAlphaBlending = !1),
- _ ? (_e.defines.push("#define VERTEXCOLOR"),
- _e.attributes.push(VertexBuffer.ColorKind)) : (_e.uniforms.push("color"),
- j.color4 = new Color4),
- k ? j.material = k : j._lineMaterial = new ShaderMaterial("colorShader",j.getScene(),"color",_e,!1),
- j
- }
- return e.prototype._isShaderMaterial = function(i) {
- return i.getClassName() === "ShaderMaterial"
- }
- ,
- e.prototype.isReady = function() {
- return this._lineMaterial.isReady(this, !!this._userInstancedBuffersStorage) ? a.prototype.isReady.call(this) : !1
- }
- ,
- e.prototype.getClassName = function() {
- return "LinesMesh"
- }
- ,
- Object.defineProperty(e.prototype, "material", {
- get: function() {
- return this._lineMaterial
- },
- set: function(i) {
- this._lineMaterial = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "checkCollisions", {
- get: function() {
- return !1
- },
- set: function(i) {},
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._bind = function(i, o, s) {
- if (!this._geometry)
- return this;
- var c = this._lineMaterial.getEffect()
- , d = this.isUnIndexed ? null : this._geometry.getIndexBuffer();
- if (this._userInstancedBuffersStorage ? this._geometry._bind(c, d, this._userInstancedBuffersStorage.vertexBuffers, this._userInstancedBuffersStorage.vertexArrayObjects) : this._geometry._bind(c, d),
- !this.useVertexColor && this._isShaderMaterial(this._lineMaterial)) {
- var _ = this.color
- , b = _.r
- , k = _.g
- , j = _.b;
- this.color4.set(b, k, j, this.alpha),
- this._lineMaterial.setColor4("color", this.color4)
- }
- return this
- }
- ,
- e.prototype._draw = function(i, o, s) {
- if (!this._geometry || !this._geometry.getVertexBuffers() || !this._unIndexed && !this._geometry.getIndexBuffer())
- return this;
- var c = this.getScene().getEngine();
- return this._unIndexed ? c.drawArraysType(Material.LineListDrawMode, i.verticesStart, i.verticesCount, s) : c.drawElementsType(Material.LineListDrawMode, i.indexStart, i.indexCount, s),
- this
- }
- ,
- e.prototype.dispose = function(i) {
- this._lineMaterial.dispose(!1, !1, !0),
- a.prototype.dispose.call(this, i)
- }
- ,
- e.prototype.clone = function(i, o, s) {
- return o === void 0 && (o = null),
- new e(i,this.getScene(),o,this,s)
- }
- ,
- e.prototype.createInstance = function(i) {
- var o = new InstancedLinesMesh(i,this);
- if (this.instancedBuffers) {
- o.instancedBuffers = {};
- for (var s in this.instancedBuffers)
- o.instancedBuffers[s] = this.instancedBuffers[s]
- }
- return o
- }
- ,
- e.prototype.serialize = function(i) {
- a.prototype.serialize.call(this, i),
- i.color = this.color.asArray(),
- i.alpha = this.alpha
- }
- ,
- e.Parse = function(i, o) {
- var s = new e(i.name,o);
- return s.color = Color3.FromArray(i.color),
- s.alpha = i.alpha,
- s
- }
- ,
- e
- }(Mesh)
- , InstancedLinesMesh = function(a) {
- __extends(e, a);
- function e(i, o) {
- var s = a.call(this, i, o) || this;
- return s.intersectionThreshold = o.intersectionThreshold,
- s
- }
- return e.prototype.getClassName = function() {
- return "InstancedLinesMesh"
- }
- ,
- e
- }(InstancedMesh);
- function CreateLineSystemVertexData(a) {
- for (var e = [], i = [], o = a.lines, s = a.colors, c = [], d = 0, _ = 0; _ < o.length; _++)
- for (var b = o[_], k = 0; k < b.length; k++) {
- if (i.push(b[k].x, b[k].y, b[k].z),
- s) {
- var j = s[_];
- c.push(j[k].r, j[k].g, j[k].b, j[k].a)
- }
- k > 0 && (e.push(d - 1),
- e.push(d)),
- d++
- }
- var $ = new VertexData;
- return $.indices = e,
- $.positions = i,
- s && ($.colors = c),
- $
- }
- function CreateDashedLinesVertexData(a) {
- var e = a.dashSize || 3
- , i = a.gapSize || 1
- , o = a.dashNb || 200
- , s = a.points
- , c = new Array
- , d = new Array
- , _ = Vector3.Zero()
- , b = 0
- , k = 0
- , j = 0
- , $ = 0
- , _e = 0
- , et = 0
- , tt = 0;
- for (tt = 0; tt < s.length - 1; tt++)
- s[tt + 1].subtractToRef(s[tt], _),
- b += _.length();
- for (j = b / o,
- $ = e * j / (e + i),
- tt = 0; tt < s.length - 1; tt++) {
- s[tt + 1].subtractToRef(s[tt], _),
- k = Math.floor(_.length() / j),
- _.normalize();
- for (var rt = 0; rt < k; rt++)
- _e = j * rt,
- c.push(s[tt].x + _e * _.x, s[tt].y + _e * _.y, s[tt].z + _e * _.z),
- c.push(s[tt].x + (_e + $) * _.x, s[tt].y + (_e + $) * _.y, s[tt].z + (_e + $) * _.z),
- d.push(et, et + 1),
- et += 2
- }
- var it = new VertexData;
- return it.positions = c,
- it.indices = d,
- it
- }
- function CreateLineSystem(a, e, i) {
- var o = e.instance
- , s = e.lines
- , c = e.colors;
- if (o) {
- var d = o.getVerticesData(VertexBuffer.PositionKind), _, b;
- c && (_ = o.getVerticesData(VertexBuffer.ColorKind));
- for (var k = 0, j = 0, $ = 0; $ < s.length; $++)
- for (var _e = s[$], et = 0; et < _e.length; et++)
- d[k] = _e[et].x,
- d[k + 1] = _e[et].y,
- d[k + 2] = _e[et].z,
- c && _ && (b = c[$],
- _[j] = b[et].r,
- _[j + 1] = b[et].g,
- _[j + 2] = b[et].b,
- _[j + 3] = b[et].a,
- j += 4),
- k += 3;
- return o.updateVerticesData(VertexBuffer.PositionKind, d, !1, !1),
- c && _ && o.updateVerticesData(VertexBuffer.ColorKind, _, !1, !1),
- o
- }
- var tt = !!c
- , rt = new LinesMesh(a,i,null,void 0,void 0,tt,e.useVertexAlpha,e.material)
- , it = CreateLineSystemVertexData(e);
- return it.applyToMesh(rt, e.updatable),
- rt
- }
- function CreateLines(a, e, i) {
- i === void 0 && (i = null);
- var o = e.colors ? [e.colors] : null
- , s = CreateLineSystem(a, {
- lines: [e.points],
- updatable: e.updatable,
- instance: e.instance,
- colors: o,
- useVertexAlpha: e.useVertexAlpha,
- material: e.material
- }, i);
- return s
- }
- function CreateDashedLines(a, e, i) {
- i === void 0 && (i = null);
- var o = e.points
- , s = e.instance
- , c = e.gapSize || 1
- , d = e.dashSize || 3;
- if (s) {
- var _ = function(j) {
- var $ = Vector3.Zero()
- , _e = j.length / 6
- , et = 0
- , tt = 0
- , rt = 0
- , it = 0
- , nt = 0
- , ot = 0
- , at = 0
- , st = 0;
- for (at = 0; at < o.length - 1; at++)
- o[at + 1].subtractToRef(o[at], $),
- et += $.length();
- rt = et / _e;
- var ut = s._creationDataStorage.dashSize
- , ct = s._creationDataStorage.gapSize;
- for (it = ut * rt / (ut + ct),
- at = 0; at < o.length - 1; at++)
- for (o[at + 1].subtractToRef(o[at], $),
- tt = Math.floor($.length() / rt),
- $.normalize(),
- st = 0; st < tt && ot < j.length; )
- nt = rt * st,
- j[ot] = o[at].x + nt * $.x,
- j[ot + 1] = o[at].y + nt * $.y,
- j[ot + 2] = o[at].z + nt * $.z,
- j[ot + 3] = o[at].x + (nt + it) * $.x,
- j[ot + 4] = o[at].y + (nt + it) * $.y,
- j[ot + 5] = o[at].z + (nt + it) * $.z,
- ot += 6,
- st++;
- for (; ot < j.length; )
- j[ot] = o[at].x,
- j[ot + 1] = o[at].y,
- j[ot + 2] = o[at].z,
- ot += 3
- };
- return s.updateMeshPositions(_, !1),
- s
- }
- var b = new LinesMesh(a,i,null,void 0,void 0,void 0,e.useVertexAlpha,e.material)
- , k = CreateDashedLinesVertexData(e);
- return k.applyToMesh(b, e.updatable),
- b._creationDataStorage = new _CreationDataStorage,
- b._creationDataStorage.dashSize = d,
- b._creationDataStorage.gapSize = c,
- b
- }
- VertexData.CreateLineSystem = CreateLineSystemVertexData;
- VertexData.CreateDashedLines = CreateDashedLinesVertexData;
- Mesh.CreateLines = function(a, e, i, o, s) {
- i === void 0 && (i = null),
- o === void 0 && (o = !1),
- s === void 0 && (s = null);
- var c = {
- points: e,
- updatable: o,
- instance: s
- };
- return CreateLines(a, c, i)
- }
- ;
- Mesh.CreateDashedLines = function(a, e, i, o, s, c, d, _) {
- c === void 0 && (c = null);
- var b = {
- points: e,
- dashSize: i,
- gapSize: o,
- dashNb: s,
- updatable: d,
- instance: _
- };
- return CreateDashedLines(a, b, c)
- }
- ;
- var IndexedVector2 = function(a) {
- __extends(e, a);
- function e(i, o) {
- var s = a.call(this, i.x, i.y) || this;
- return s.index = o,
- s
- }
- return e
- }(Vector2)
- , PolygonPoints = function() {
- function a() {
- this.elements = new Array
- }
- return a.prototype.add = function(e) {
- var i = this
- , o = new Array;
- return e.forEach(function(s) {
- var c = new IndexedVector2(s,i.elements.length);
- o.push(c),
- i.elements.push(c)
- }),
- o
- }
- ,
- a.prototype.computeBounds = function() {
- var e = new Vector2(this.elements[0].x,this.elements[0].y)
- , i = new Vector2(this.elements[0].x,this.elements[0].y);
- return this.elements.forEach(function(o) {
- o.x < e.x ? e.x = o.x : o.x > i.x && (i.x = o.x),
- o.y < e.y ? e.y = o.y : o.y > i.y && (i.y = o.y)
- }),
- {
- min: e,
- max: i,
- width: i.x - e.x,
- height: i.y - e.y
- }
- }
- ,
- a
- }()
- , PolygonMeshBuilder = function() {
- function a(e, i, o, s) {
- s === void 0 && (s = earcut),
- this._points = new PolygonPoints,
- this._outlinepoints = new PolygonPoints,
- this._holes = new Array,
- this._epoints = new Array,
- this._eholes = new Array,
- this.bjsEarcut = s,
- this._name = e,
- this._scene = o || Engine.LastCreatedScene;
- var c;
- i instanceof Path2 ? c = i.getPoints() : c = i,
- this._addToepoint(c),
- this._points.add(c),
- this._outlinepoints.add(c),
- typeof this.bjsEarcut == "undefined" && Logger$2.Warn("Earcut was not found, the polygon will not be built.")
- }
- return a.prototype._addToepoint = function(e) {
- for (var i = 0, o = e; i < o.length; i++) {
- var s = o[i];
- this._epoints.push(s.x, s.y)
- }
- }
- ,
- a.prototype.addHole = function(e) {
- this._points.add(e);
- var i = new PolygonPoints;
- return i.add(e),
- this._holes.push(i),
- this._eholes.push(this._epoints.length / 2),
- this._addToepoint(e),
- this
- }
- ,
- a.prototype.build = function(e, i, o) {
- e === void 0 && (e = !1),
- i === void 0 && (i = 0),
- o === void 0 && (o = 2);
- var s = new Mesh(this._name,this._scene)
- , c = this.buildVertexData(i, o);
- return s.setVerticesData(VertexBuffer.PositionKind, c.positions, e),
- s.setVerticesData(VertexBuffer.NormalKind, c.normals, e),
- s.setVerticesData(VertexBuffer.UVKind, c.uvs, e),
- s.setIndices(c.indices),
- s
- }
- ,
- a.prototype.buildVertexData = function(e, i) {
- var o = this;
- e === void 0 && (e = 0),
- i === void 0 && (i = 2);
- var s = new VertexData
- , c = new Array
- , d = new Array
- , _ = new Array
- , b = this._points.computeBounds();
- this._points.elements.forEach(function(nt) {
- c.push(0, 1, 0),
- d.push(nt.x, 0, nt.y),
- _.push((nt.x - b.min.x) / b.width, (nt.y - b.min.y) / b.height)
- });
- for (var k = new Array, j = this.bjsEarcut(this._epoints, this._eholes, 2), $ = 0; $ < j.length; $++)
- k.push(j[$]);
- if (e > 0) {
- var _e = d.length / 3;
- this._points.elements.forEach(function(nt) {
- c.push(0, -1, 0),
- d.push(nt.x, -e, nt.y),
- _.push(1 - (nt.x - b.min.x) / b.width, 1 - (nt.y - b.min.y) / b.height)
- });
- for (var et = k.length, $ = 0; $ < et; $ += 3) {
- var tt = k[$ + 0]
- , rt = k[$ + 1]
- , it = k[$ + 2];
- k.push(it + _e),
- k.push(rt + _e),
- k.push(tt + _e)
- }
- this.addSide(d, c, _, k, b, this._outlinepoints, e, !1, i),
- this._holes.forEach(function(nt) {
- o.addSide(d, c, _, k, b, nt, e, !0, i)
- })
- }
- return s.indices = k,
- s.positions = d,
- s.normals = c,
- s.uvs = _,
- s
- }
- ,
- a.prototype.addSide = function(e, i, o, s, c, d, _, b, k) {
- for (var j = e.length / 3, $ = 0, _e = 0; _e < d.elements.length; _e++) {
- var et = d.elements[_e]
- , tt = d.elements[(_e + 1) % d.elements.length];
- e.push(et.x, 0, et.y),
- e.push(et.x, -_, et.y),
- e.push(tt.x, 0, tt.y),
- e.push(tt.x, -_, tt.y);
- var rt = d.elements[(_e + d.elements.length - 1) % d.elements.length]
- , it = d.elements[(_e + 2) % d.elements.length]
- , nt = new Vector3(-(tt.y - et.y),0,tt.x - et.x)
- , ot = new Vector3(-(et.y - rt.y),0,et.x - rt.x)
- , at = new Vector3(-(it.y - tt.y),0,it.x - tt.x);
- b || (nt = nt.scale(-1),
- ot = ot.scale(-1),
- at = at.scale(-1));
- var st = nt.normalizeToNew()
- , ut = ot.normalizeToNew()
- , ct = at.normalizeToNew()
- , lt = Vector3.Dot(ut, st);
- 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;
- var ft = Vector3.Dot(at, nt);
- 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,
- o.push($ / c.width, 0),
- o.push($ / c.width, 1),
- $ += nt.length(),
- o.push($ / c.width, 0),
- o.push($ / c.width, 1),
- i.push(ut.x, ut.y, ut.z),
- i.push(ut.x, ut.y, ut.z),
- i.push(ct.x, ct.y, ct.z),
- i.push(ct.x, ct.y, ct.z),
- b ? (s.push(j),
- s.push(j + 2),
- s.push(j + 1),
- s.push(j + 1),
- s.push(j + 2),
- s.push(j + 3)) : (s.push(j),
- s.push(j + 1),
- s.push(j + 2),
- s.push(j + 1),
- s.push(j + 3),
- s.push(j + 2)),
- j += 4
- }
- }
- ,
- a
- }();
- function CreatePolygonVertexData(a, e, i, o, s, c, d) {
- for (var _ = i || new Array(3), b = o, k = [], j = d || !1, $ = 0; $ < 3; $++)
- _[$] === void 0 && (_[$] = new Vector4(0,0,1,1)),
- b && b[$] === void 0 && (b[$] = new Color4(1,1,1,1));
- var _e = a.getVerticesData(VertexBuffer.PositionKind)
- , et = a.getVerticesData(VertexBuffer.NormalKind)
- , tt = a.getVerticesData(VertexBuffer.UVKind)
- , rt = a.getIndices()
- , it = _e.length / 9
- , nt = 0
- , ot = 0
- , at = 0
- , st = 0
- , ut = 0
- , ct = [0];
- if (j)
- for (var lt = it; lt < _e.length / 3; lt += 4)
- ot = _e[3 * (lt + 2)] - _e[3 * lt],
- at = _e[3 * (lt + 2) + 2] - _e[3 * lt + 2],
- st = Math.sqrt(ot * ot + at * at),
- ut += st,
- ct.push(ut);
- for (var lt = 0, ft = 0, ht = 0; ht < et.length; ht += 3)
- Math.abs(et[ht + 1]) < .001 && (ft = 1),
- Math.abs(et[ht + 1] - 1) < .001 && (ft = 0),
- Math.abs(et[ht + 1] + 1) < .001 && (ft = 2),
- lt = ht / 3,
- ft === 1 ? (nt = lt - it,
- 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,
- 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,
- tt[2 * lt + 1] = (1 - tt[2 * lt + 1]) * _[ft].y + tt[2 * lt + 1] * _[ft].w),
- b && k.push(b[ft].r, b[ft].g, b[ft].b, b[ft].a);
- VertexData._ComputeSides(e, _e, rt, et, tt, s, c);
- var pt = new VertexData;
- if (pt.indices = rt,
- pt.positions = _e,
- pt.normals = et,
- pt.uvs = tt,
- b) {
- var dt = e === VertexData.DOUBLESIDE ? k.concat(k) : k;
- pt.colors = dt
- }
- return pt
- }
- function CreatePolygon(a, e, i, o) {
- i === void 0 && (i = null),
- o === void 0 && (o = earcut),
- e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation);
- for (var s = e.shape, c = e.holes || [], d = e.depth || 0, _ = e.smoothingThreshold || 2, b = [], k = [], j = 0; j < s.length; j++)
- b[j] = new Vector2(s[j].x,s[j].z);
- var $ = 1e-8;
- b[0].equalsWithEpsilon(b[b.length - 1], $) && b.pop();
- for (var _e = new PolygonMeshBuilder(a,b,i || EngineStore.LastCreatedScene,o), et = 0; et < c.length; et++) {
- k = [];
- for (var tt = 0; tt < c[et].length; tt++)
- k.push(new Vector2(c[et][tt].x,c[et][tt].z));
- _e.addHole(k)
- }
- var rt = _e.build(e.updatable, d, _);
- rt._originalBuilderSideOrientation = e.sideOrientation;
- var it = CreatePolygonVertexData(rt, e.sideOrientation, e.faceUV, e.faceColors, e.frontUVs, e.backUVs, e.wrap);
- return it.applyToMesh(rt, e.updatable),
- rt
- }
- function ExtrudePolygon(a, e, i, o) {
- return i === void 0 && (i = null),
- o === void 0 && (o = earcut),
- CreatePolygon(a, e, i, o)
- }
- VertexData.CreatePolygon = CreatePolygonVertexData;
- Mesh.CreatePolygon = function(a, e, i, o, s, c, d) {
- d === void 0 && (d = earcut);
- var _ = {
- shape: e,
- holes: o,
- updatable: s,
- sideOrientation: c
- };
- return CreatePolygon(a, _, i, d)
- }
- ;
- Mesh.ExtrudePolygon = function(a, e, i, o, s, c, d, _) {
- _ === void 0 && (_ = earcut);
- var b = {
- shape: e,
- holes: s,
- depth: i,
- updatable: c,
- sideOrientation: d
- };
- return ExtrudePolygon(a, b, o, _)
- }
- ;
- function ExtrudeShape(a, e, i) {
- i === void 0 && (i = null);
- var o = e.path
- , s = e.shape
- , c = e.scale || 1
- , d = e.rotation || 0
- , _ = e.cap === 0 ? 0 : e.cap || Mesh.NO_CAP
- , b = e.updatable
- , k = Mesh._GetDefaultSideOrientation(e.sideOrientation)
- , j = e.instance || null
- , $ = e.invertUV || !1;
- return _ExtrudeShapeGeneric(a, s, o, c, d, null, null, !1, !1, _, !1, i, !!b, k, j, $, e.frontUVs || null, e.backUVs || null)
- }
- function ExtrudeShapeCustom(a, e, i) {
- i === void 0 && (i = null);
- var o = e.path
- , s = e.shape
- , c = e.scaleFunction || function() {
- return 1
- }
- , d = e.rotationFunction || function() {
- return 0
- }
- , _ = e.ribbonCloseArray || !1
- , b = e.ribbonClosePath || !1
- , k = e.cap === 0 ? 0 : e.cap || Mesh.NO_CAP
- , j = e.updatable
- , $ = Mesh._GetDefaultSideOrientation(e.sideOrientation)
- , _e = e.instance
- , et = e.invertUV || !1;
- return _ExtrudeShapeGeneric(a, s, o, null, null, c, d, _, b, k, !0, i, !!j, $, _e || null, et, e.frontUVs || null, e.backUVs || null)
- }
- function _ExtrudeShapeGeneric(a, e, i, o, s, c, d, _, b, k, j, $, _e, et, tt, rt, it, nt) {
- var ot = function(ft, ht, pt, dt, _t, mt, vt, yt, Et, At) {
- for (var gt = pt.getTangents(), St = pt.getNormals(), xt = pt.getBinormals(), bt = pt.getDistances(), Rt = 0, Mt = function() {
- return _t !== null ? _t : 1
- }, Pt = function() {
- return mt !== null ? mt : 0
- }, 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++) {
- for (var Nt = new Array, Ft = It(wt, bt[wt]), Vt = Dt(wt, bt[wt]), Lt = 0; Lt < ft.length; Lt++) {
- Matrix.RotationAxisToRef(gt[wt], Rt, Ot);
- var kt = gt[wt].scale(ft[Lt].z).add(St[wt].scale(ft[Lt].x)).add(xt[wt].scale(ft[Lt].y))
- , Bt = Nt[Lt] ? Nt[Lt] : Vector3.Zero();
- Vector3.TransformCoordinatesToRef(kt, Ot, Bt),
- Bt.scaleInPlace(Vt).addInPlace(ht[wt]),
- Nt[Lt] = Bt
- }
- dt[Ct] = Nt,
- Rt += Ft,
- Ct++
- }
- var Ut = function(Gt) {
- var Ht = Array(), zt = Vector3.Zero(), Wt;
- for (Wt = 0; Wt < Gt.length; Wt++)
- zt.addInPlace(Gt[Wt]);
- for (zt.scaleInPlace(1 / Gt.length),
- Wt = 0; Wt < Gt.length; Wt++)
- Ht.push(zt);
- return Ht
- };
- switch (Et) {
- case Mesh.NO_CAP:
- break;
- case Mesh.CAP_START:
- dt[0] = Ut(dt[2]),
- dt[1] = dt[2];
- break;
- case Mesh.CAP_END:
- dt[Ct] = dt[Ct - 1],
- dt[Ct + 1] = Ut(dt[Ct - 1]);
- break;
- case Mesh.CAP_ALL:
- dt[0] = Ut(dt[2]),
- dt[1] = dt[2],
- dt[Ct] = dt[Ct - 1],
- dt[Ct + 1] = Ut(dt[Ct - 1]);
- break
- }
- return dt
- }, at, st;
- if (tt) {
- var ut = tt._creationDataStorage;
- return at = ut.path3D.update(i),
- st = ot(e, i, ut.path3D, ut.pathArray, o, s, c, d, ut.cap, j),
- tt = CreateRibbon("", {
- pathArray: st,
- closeArray: !1,
- closePath: !1,
- offset: 0,
- updatable: !1,
- sideOrientation: 0,
- instance: tt
- }, $ || void 0),
- tt
- }
- at = new Path3D(i);
- var ct = new Array;
- k = k < 0 || k > 3 ? 0 : k,
- st = ot(e, i, at, ct, o, s, c, d, k, j);
- var lt = CreateRibbon(a, {
- pathArray: st,
- closeArray: _,
- closePath: b,
- updatable: _e,
- sideOrientation: et,
- invertUV: rt,
- frontUVs: it || void 0,
- backUVs: nt || void 0
- }, $);
- return lt._creationDataStorage.pathArray = st,
- lt._creationDataStorage.path3D = at,
- lt._creationDataStorage.cap = k,
- lt
- }
- Mesh.ExtrudeShape = function(a, e, i, o, s, c, d, _, b, k) {
- d === void 0 && (d = null);
- var j = {
- shape: e,
- path: i,
- scale: o,
- rotation: s,
- cap: c === 0 ? 0 : c || Mesh.NO_CAP,
- sideOrientation: b,
- instance: k,
- updatable: _
- };
- return ExtrudeShape(a, j, d)
- }
- ;
- Mesh.ExtrudeShapeCustom = function(a, e, i, o, s, c, d, _, b, k, j, $) {
- var _e = {
- shape: e,
- path: i,
- scaleFunction: o,
- rotationFunction: s,
- ribbonCloseArray: c,
- ribbonClosePath: d,
- cap: _ === 0 ? 0 : _ || Mesh.NO_CAP,
- sideOrientation: j,
- instance: $,
- updatable: k
- };
- return ExtrudeShapeCustom(a, _e, b)
- }
- ;
- function CreateLathe(a, e, i) {
- i === void 0 && (i = null);
- 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;
- for (rt = 0; rt <= _ - b; rt++) {
- var at = [];
- for (($ == Mesh.CAP_START || $ == Mesh.CAP_ALL) && (at.push(new Vector3(0,c[0].y,0)),
- at.push(new Vector3(Math.cos(rt * nt) * c[0].x * d,c[0].y,Math.sin(rt * nt) * c[0].x * d))),
- it = 0; it < c.length; it++)
- ot = new Vector3(Math.cos(rt * nt) * c[it].x * d,c[it].y,Math.sin(rt * nt) * c[it].x * d),
- at.push(ot);
- ($ == 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)),
- at.push(new Vector3(0,c[c.length - 1].y,0))),
- et.push(at)
- }
- var st = CreateRibbon(a, {
- pathArray: et,
- closeArray: s,
- sideOrientation: j,
- updatable: k,
- invertUV: tt,
- frontUVs: e.frontUVs,
- backUVs: e.backUVs
- }, i);
- return st
- }
- Mesh.CreateLathe = function(a, e, i, o, s, c, d) {
- var _ = {
- shape: e,
- radius: i,
- tessellation: o,
- sideOrientation: d,
- updatable: c
- };
- return CreateLathe(a, _, s)
- }
- ;
- function CreatePlaneVertexData(a) {
- var e = []
- , i = []
- , o = []
- , s = []
- , c = a.width || a.size || 1
- , d = a.height || a.size || 1
- , _ = a.sideOrientation === 0 ? 0 : a.sideOrientation || VertexData.DEFAULTSIDE
- , b = c / 2
- , k = d / 2;
- i.push(-b, -k, 0),
- o.push(0, 0, -1),
- s.push(0, 0),
- i.push(b, -k, 0),
- o.push(0, 0, -1),
- s.push(1, 0),
- i.push(b, k, 0),
- o.push(0, 0, -1),
- s.push(1, 1),
- i.push(-b, k, 0),
- o.push(0, 0, -1),
- s.push(0, 1),
- e.push(0),
- e.push(1),
- e.push(2),
- e.push(0),
- e.push(2),
- e.push(3),
- VertexData._ComputeSides(_, i, e, o, s, a.frontUVs, a.backUVs);
- var j = new VertexData;
- return j.indices = e,
- j.positions = i,
- j.normals = o,
- j.uvs = s,
- j
- }
- function CreatePlane(a, e, i) {
- e === void 0 && (e = {}),
- i === void 0 && (i = null);
- var o = new Mesh(a,i);
- e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
- o._originalBuilderSideOrientation = e.sideOrientation;
- var s = CreatePlaneVertexData(e);
- return s.applyToMesh(o, e.updatable),
- e.sourcePlane && (o.translate(e.sourcePlane.normal, -e.sourcePlane.d),
- o.setDirection(e.sourcePlane.normal.scale(-1))),
- o
- }
- VertexData.CreatePlane = CreatePlaneVertexData;
- Mesh.CreatePlane = function(a, e, i, o, s) {
- var c = {
- size: e,
- width: e,
- height: e,
- sideOrientation: s,
- updatable: o
- };
- return CreatePlane(a, c, i)
- }
- ;
- Mesh._GroundMeshParser = function(a, e) {
- return GroundMesh.Parse(a, e)
- }
- ;
- var GroundMesh = function(a) {
- __extends(e, a);
- function e(i, o) {
- var s = a.call(this, i, o) || this;
- return s.generateOctree = !1,
- s
- }
- return e.prototype.getClassName = function() {
- return "GroundMesh"
- }
- ,
- Object.defineProperty(e.prototype, "subdivisions", {
- get: function() {
- return Math.min(this._subdivisionsX, this._subdivisionsY)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "subdivisionsX", {
- get: function() {
- return this._subdivisionsX
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "subdivisionsY", {
- get: function() {
- return this._subdivisionsY
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.optimize = function(i, o) {
- o === void 0 && (o = 32),
- this._subdivisionsX = i,
- this._subdivisionsY = i,
- this.subdivide(i);
- var s = this;
- s.createOrUpdateSubmeshesOctree && s.createOrUpdateSubmeshesOctree(o)
- }
- ,
- e.prototype.getHeightAtCoordinates = function(i, o) {
- var s = this.getWorldMatrix()
- , c = TmpVectors.Matrix[5];
- s.invertToRef(c);
- var d = TmpVectors.Vector3[8];
- if (Vector3.TransformCoordinatesFromFloatsToRef(i, 0, o, c, d),
- i = d.x,
- o = d.z,
- i < this._minX || i > this._maxX || o < this._minZ || o > this._maxZ)
- return this.position.y;
- (!this._heightQuads || this._heightQuads.length == 0) && (this._initHeightQuads(),
- this._computeHeightQuads());
- var _ = this._getFacetAt(i, o)
- , b = -(_.x * i + _.z * o + _.w) / _.y;
- return Vector3.TransformCoordinatesFromFloatsToRef(0, b, 0, s, d),
- d.y
- }
- ,
- e.prototype.getNormalAtCoordinates = function(i, o) {
- var s = new Vector3(0,1,0);
- return this.getNormalAtCoordinatesToRef(i, o, s),
- s
- }
- ,
- e.prototype.getNormalAtCoordinatesToRef = function(i, o, s) {
- var c = this.getWorldMatrix()
- , d = TmpVectors.Matrix[5];
- c.invertToRef(d);
- var _ = TmpVectors.Vector3[8];
- if (Vector3.TransformCoordinatesFromFloatsToRef(i, 0, o, d, _),
- i = _.x,
- o = _.z,
- i < this._minX || i > this._maxX || o < this._minZ || o > this._maxZ)
- return this;
- (!this._heightQuads || this._heightQuads.length == 0) && (this._initHeightQuads(),
- this._computeHeightQuads());
- var b = this._getFacetAt(i, o);
- return Vector3.TransformNormalFromFloatsToRef(b.x, b.y, b.z, c, s),
- this
- }
- ,
- e.prototype.updateCoordinateHeights = function() {
- return (!this._heightQuads || this._heightQuads.length == 0) && this._initHeightQuads(),
- this._computeHeightQuads(),
- this
- }
- ,
- e.prototype._getFacetAt = function(i, o) {
- 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], _;
- return o < d.slope.x * i + d.slope.y ? _ = d.facet1 : _ = d.facet2,
- _
- }
- ,
- e.prototype._initHeightQuads = function() {
- var i = this._subdivisionsX
- , o = this._subdivisionsY;
- this._heightQuads = new Array;
- for (var s = 0; s < o; s++)
- for (var c = 0; c < i; c++) {
- var d = {
- slope: Vector2.Zero(),
- facet1: new Vector4(0,0,0,0),
- facet2: new Vector4(0,0,0,0)
- };
- this._heightQuads[s * i + c] = d
- }
- return this
- }
- ,
- e.prototype._computeHeightQuads = function() {
- var i = this.getVerticesData(VertexBuffer.PositionKind);
- if (!i)
- return this;
- 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++)
- for (var ct = 0; ct < at; ct++) {
- _e = ct * 3,
- et = ut * (at + 1) * 3,
- tt = (ut + 1) * (at + 1) * 3,
- o.x = i[et + _e],
- o.y = i[et + _e + 1],
- o.z = i[et + _e + 2],
- s.x = i[et + _e + 3],
- s.y = i[et + _e + 4],
- s.z = i[et + _e + 5],
- c.x = i[tt + _e],
- c.y = i[tt + _e + 1],
- c.z = i[tt + _e + 2],
- d.x = i[tt + _e + 3],
- d.y = i[tt + _e + 4],
- d.z = i[tt + _e + 5],
- rt = (d.z - o.z) / (d.x - o.x),
- it = o.z - rt * o.x,
- s.subtractToRef(o, _),
- c.subtractToRef(o, b),
- d.subtractToRef(o, k),
- Vector3.CrossToRef(k, b, j),
- Vector3.CrossToRef(_, k, $),
- j.normalize(),
- $.normalize(),
- nt = -(j.x * o.x + j.y * o.y + j.z * o.z),
- ot = -($.x * s.x + $.y * s.y + $.z * s.z);
- var lt = this._heightQuads[ut * at + ct];
- lt.slope.copyFromFloats(rt, it),
- lt.facet1.copyFromFloats(j.x, j.y, j.z, nt),
- lt.facet2.copyFromFloats($.x, $.y, $.z, ot)
- }
- return this
- }
- ,
- e.prototype.serialize = function(i) {
- a.prototype.serialize.call(this, i),
- i.subdivisionsX = this._subdivisionsX,
- i.subdivisionsY = this._subdivisionsY,
- i.minX = this._minX,
- i.maxX = this._maxX,
- i.minZ = this._minZ,
- i.maxZ = this._maxZ,
- i.width = this._width,
- i.height = this._height
- }
- ,
- e.Parse = function(i, o) {
- var s = new e(i.name,o);
- return s._subdivisionsX = i.subdivisionsX || 1,
- s._subdivisionsY = i.subdivisionsY || 1,
- s._minX = i.minX,
- s._maxX = i.maxX,
- s._minZ = i.minZ,
- s._maxZ = i.maxZ,
- s._width = i.width,
- s._height = i.height,
- s
- }
- ,
- e
- }(Mesh);
- function CreateGroundVertexData(a) {
- 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;
- for (c = 0; c <= j; c++)
- for (d = 0; d <= k; d++) {
- var $ = new Vector3(d * _ / k - _ / 2,0,(j - c) * b / j - b / 2)
- , _e = new Vector3(0,1,0);
- i.push($.x, $.y, $.z),
- o.push(_e.x, _e.y, _e.z),
- s.push(d / k, 1 - c / j)
- }
- for (c = 0; c < j; c++)
- for (d = 0; d < k; d++)
- e.push(d + 1 + (c + 1) * (k + 1)),
- e.push(d + 1 + c * (k + 1)),
- e.push(d + c * (k + 1)),
- e.push(d + (c + 1) * (k + 1)),
- e.push(d + 1 + (c + 1) * (k + 1)),
- e.push(d + c * (k + 1));
- var et = new VertexData;
- return et.indices = e,
- et.positions = i,
- et.normals = o,
- et.uvs = s,
- et
- }
- function CreateTiledGroundVertexData(a) {
- 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 || {
- w: 1,
- h: 1
- }, d = a.precision || {
- w: 1,
- h: 1
- }, _ = new Array, b = new Array, k = new Array, j = new Array, $, _e, et, tt;
- c.h = c.h < 1 ? 1 : c.h,
- c.w = c.w < 1 ? 1 : c.w,
- d.w = d.w < 1 ? 1 : d.w,
- d.h = d.h < 1 ? 1 : d.h;
- var rt = {
- w: (o - e) / c.w,
- h: (s - i) / c.h
- };
- function it(ot, at, st, ut) {
- var ct = b.length / 3
- , lt = d.w + 1;
- for ($ = 0; $ < d.h; $++)
- for (_e = 0; _e < d.w; _e++) {
- var ft = [ct + _e + $ * lt, ct + (_e + 1) + $ * lt, ct + (_e + 1) + ($ + 1) * lt, ct + _e + ($ + 1) * lt];
- _.push(ft[1]),
- _.push(ft[2]),
- _.push(ft[3]),
- _.push(ft[0]),
- _.push(ft[1]),
- _.push(ft[3])
- }
- var ht = Vector3.Zero()
- , pt = new Vector3(0,1,0);
- for ($ = 0; $ <= d.h; $++)
- for (ht.z = $ * (ut - at) / d.h + at,
- _e = 0; _e <= d.w; _e++)
- ht.x = _e * (st - ot) / d.w + ot,
- ht.y = 0,
- b.push(ht.x, ht.y, ht.z),
- k.push(pt.x, pt.y, pt.z),
- j.push(_e / d.w, $ / d.h)
- }
- for (et = 0; et < c.h; et++)
- for (tt = 0; tt < c.w; tt++)
- it(e + tt * rt.w, i + et * rt.h, e + (tt + 1) * rt.w, i + (et + 1) * rt.h);
- var nt = new VertexData;
- return nt.indices = _,
- nt.positions = b,
- nt.normals = k,
- nt.uvs = j,
- nt
- }
- function CreateGroundFromHeightMapVertexData(a) {
- var e = [], i = [], o = [], s = [], c, d, _ = a.colorFilter || new Color3(.3,.59,.11), b = a.alphaFilter || 0, k = !1;
- if (a.minHeight > a.maxHeight) {
- k = !0;
- var j = a.maxHeight;
- a.maxHeight = a.minHeight,
- a.minHeight = j
- }
- for (c = 0; c <= a.subdivisions; c++)
- for (d = 0; d <= a.subdivisions; d++) {
- var $ = new Vector3(d * a.width / a.subdivisions - a.width / 2,0,(a.subdivisions - c) * a.height / a.subdivisions - a.height / 2)
- , _e = ($.x + a.width / 2) / a.width * (a.bufferWidth - 1) | 0
- , et = (1 - ($.z + a.height / 2) / a.height) * (a.bufferHeight - 1) | 0
- , tt = (_e + et * a.bufferWidth) * 4
- , rt = a.buffer[tt] / 255
- , it = a.buffer[tt + 1] / 255
- , nt = a.buffer[tt + 2] / 255
- , ot = a.buffer[tt + 3] / 255;
- k && (rt = 1 - rt,
- it = 1 - it,
- nt = 1 - nt);
- var at = rt * _.r + it * _.g + nt * _.b;
- ot >= b ? $.y = a.minHeight + (a.maxHeight - a.minHeight) * at : $.y = a.minHeight - Epsilon,
- i.push($.x, $.y, $.z),
- o.push(0, 0, 0),
- s.push(d / a.subdivisions, 1 - c / a.subdivisions)
- }
- for (c = 0; c < a.subdivisions; c++)
- for (d = 0; d < a.subdivisions; d++) {
- var st = d + 1 + (c + 1) * (a.subdivisions + 1)
- , ut = d + 1 + c * (a.subdivisions + 1)
- , ct = d + c * (a.subdivisions + 1)
- , lt = d + (c + 1) * (a.subdivisions + 1)
- , ft = i[st * 3 + 1] >= a.minHeight
- , ht = i[ut * 3 + 1] >= a.minHeight
- , pt = i[ct * 3 + 1] >= a.minHeight;
- ft && ht && pt && (e.push(st),
- e.push(ut),
- e.push(ct));
- var dt = i[lt * 3 + 1] >= a.minHeight;
- dt && ft && pt && (e.push(lt),
- e.push(st),
- e.push(ct))
- }
- VertexData.ComputeNormals(i, e, o);
- var _t = new VertexData;
- return _t.indices = e,
- _t.positions = i,
- _t.normals = o,
- _t.uvs = s,
- _t
- }
- function CreateGround(a, e, i) {
- e === void 0 && (e = {});
- var o = new GroundMesh(a,i);
- o._setReady(!1),
- o._subdivisionsX = e.subdivisionsX || e.subdivisions || 1,
- o._subdivisionsY = e.subdivisionsY || e.subdivisions || 1,
- o._width = e.width || 1,
- o._height = e.height || 1,
- o._maxX = o._width / 2,
- o._maxZ = o._height / 2,
- o._minX = -o._maxX,
- o._minZ = -o._maxZ;
- var s = CreateGroundVertexData(e);
- return s.applyToMesh(o, e.updatable),
- o._setReady(!0),
- o
- }
- function CreateTiledGround(a, e, i) {
- i === void 0 && (i = null);
- var o = new Mesh(a,i)
- , s = CreateTiledGroundVertexData(e);
- return s.applyToMesh(o, e.updatable),
- o
- }
- function CreateGroundFromHeightMap(a, e, i, o) {
- i === void 0 && (i = {}),
- o === void 0 && (o = null);
- var s = i.width || 10
- , c = i.height || 10
- , d = i.subdivisions || 1
- , _ = i.minHeight || 0
- , b = i.maxHeight || 1
- , k = i.colorFilter || new Color3(.3,.59,.11)
- , j = i.alphaFilter || 0
- , $ = i.updatable
- , _e = i.onReady;
- o = o || EngineStore.LastCreatedScene;
- var et = new GroundMesh(a,o);
- et._subdivisionsX = d,
- et._subdivisionsY = d,
- et._width = s,
- et._height = c,
- et._maxX = et._width / 2,
- et._maxZ = et._height / 2,
- et._minX = -et._maxX,
- et._minZ = -et._maxZ,
- et._setReady(!1);
- var tt = function(rt) {
- var it = rt.width
- , nt = rt.height;
- if (!o.isDisposed) {
- var ot = o == null ? void 0 : o.getEngine().resizeImageBitmap(rt, it, nt)
- , at = CreateGroundFromHeightMapVertexData({
- width: s,
- height: c,
- subdivisions: d,
- minHeight: _,
- maxHeight: b,
- colorFilter: k,
- buffer: ot,
- bufferWidth: it,
- bufferHeight: nt,
- alphaFilter: j
- });
- at.applyToMesh(et, $),
- _e && _e(et),
- et._setReady(!0)
- }
- };
- return Tools.LoadImage(e, tt, function() {}, o.offlineProvider),
- et
- }
- VertexData.CreateGround = CreateGroundVertexData;
- VertexData.CreateTiledGround = CreateTiledGroundVertexData;
- VertexData.CreateGroundFromHeightMap = CreateGroundFromHeightMapVertexData;
- Mesh.CreateGround = function(a, e, i, o, s, c) {
- var d = {
- width: e,
- height: i,
- subdivisions: o,
- updatable: c
- };
- return CreateGround(a, d, s)
- }
- ;
- Mesh.CreateTiledGround = function(a, e, i, o, s, c, d, _, b) {
- var k = {
- xmin: e,
- zmin: i,
- xmax: o,
- zmax: s,
- subdivisions: c,
- precision: d,
- updatable: b
- };
- return CreateTiledGround(a, k, _)
- }
- ;
- Mesh.CreateGroundFromHeightMap = function(a, e, i, o, s, c, d, _, b, k, j) {
- var $ = {
- width: i,
- height: o,
- subdivisions: s,
- minHeight: c,
- maxHeight: d,
- updatable: b,
- onReady: k,
- alphaFilter: j
- };
- return CreateGroundFromHeightMap(a, e, $, _)
- }
- ;
- function CreateTube(a, e, i) {
- i === void 0 && (i = null);
- var o = e.path
- , s = e.instance
- , c = 1;
- e.radius !== void 0 ? c = e.radius : s && (c = s._creationDataStorage.radius);
- var d = e.tessellation || 64
- , _ = e.radiusFunction || null
- , b = e.cap || Mesh.NO_CAP
- , k = e.invertUV || !1
- , j = e.updatable
- , $ = Mesh._GetDefaultSideOrientation(e.sideOrientation);
- e.arc = e.arc && (e.arc <= 0 || e.arc > 1) ? 1 : e.arc || 1;
- var _e = function(at, st, ut, ct, lt, ft, ht, pt) {
- for (var dt = st.getTangents(), _t = st.getNormals(), mt = st.getDistances(), vt = Math.PI * 2, yt = vt / lt * pt, Et = function() {
- return ct
- }, 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++) {
- St = At(Pt, mt[Pt]),
- gt = Array(),
- xt = _t[Pt];
- for (var It = 0; It < lt; It++)
- Matrix.RotationAxisToRef(dt[Pt], yt * It, Rt),
- bt = gt[It] ? gt[It] : Vector3.Zero(),
- Vector3.TransformCoordinatesToRef(xt, Rt, bt),
- bt.scaleInPlace(St).addInPlace(at[Pt]),
- gt[It] = bt;
- ut[Mt] = gt,
- Mt++
- }
- var Dt = function(Ct, Ot) {
- for (var wt = Array(), Nt = 0; Nt < Ct; Nt++)
- wt.push(at[Ot]);
- return wt
- };
- switch (ht) {
- case Mesh.NO_CAP:
- break;
- case Mesh.CAP_START:
- ut[0] = Dt(lt, 0),
- ut[1] = ut[2].slice(0);
- break;
- case Mesh.CAP_END:
- ut[Mt] = ut[Mt - 1].slice(0),
- ut[Mt + 1] = Dt(lt, at.length - 1);
- break;
- case Mesh.CAP_ALL:
- ut[0] = Dt(lt, 0),
- ut[1] = ut[2].slice(0),
- ut[Mt] = ut[Mt - 1].slice(0),
- ut[Mt + 1] = Dt(lt, at.length - 1);
- break
- }
- return ut
- }, et, tt;
- if (s) {
- var rt = s._creationDataStorage
- , it = e.arc || rt.arc;
- return et = rt.path3D.update(o),
- tt = _e(o, et, rt.pathArray, c, rt.tessellation, _, rt.cap, it),
- s = CreateRibbon("", {
- pathArray: tt,
- instance: s
- }),
- rt.path3D = et,
- rt.pathArray = tt,
- rt.arc = it,
- rt.radius = c,
- s
- }
- et = new Path3D(o);
- var nt = new Array;
- b = b < 0 || b > 3 ? 0 : b,
- tt = _e(o, et, nt, c, d, _, b, e.arc);
- var ot = CreateRibbon(a, {
- pathArray: tt,
- closePath: !0,
- closeArray: !1,
- updatable: j,
- sideOrientation: $,
- invertUV: k,
- frontUVs: e.frontUVs,
- backUVs: e.backUVs
- }, i);
- return ot._creationDataStorage.pathArray = tt,
- ot._creationDataStorage.path3D = et,
- ot._creationDataStorage.tessellation = d,
- ot._creationDataStorage.cap = b,
- ot._creationDataStorage.arc = e.arc,
- ot._creationDataStorage.radius = c,
- ot
- }
- Mesh.CreateTube = function(a, e, i, o, s, c, d, _, b, k) {
- var j = {
- path: e,
- radius: i,
- tessellation: o,
- radiusFunction: s,
- arc: 1,
- cap: c,
- updatable: _,
- sideOrientation: b,
- instance: k
- };
- return CreateTube(a, j, d)
- }
- ;
- function CreatePolyhedronVertexData(a) {
- var e = [];
- e[0] = {
- vertex: [[0, 0, 1.732051], [1.632993, 0, -.5773503], [-.8164966, 1.414214, -.5773503], [-.8164966, -1.414214, -.5773503]],
- face: [[0, 1, 2], [0, 2, 3], [0, 3, 1], [1, 3, 2]]
- },
- e[1] = {
- 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]],
- 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]]
- },
- e[2] = {
- 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]],
- 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]]
- },
- e[3] = {
- 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]],
- 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]]
- },
- e[4] = {
- 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]],
- 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]]
- },
- e[5] = {
- vertex: [[0, 0, 1.322876], [1.309307, 0, .1889822], [-.9819805, .8660254, .1889822], [.1636634, -1.299038, .1889822], [.3273268, .8660254, -.9449112], [-.8183171, -.4330127, -.9449112]],
- face: [[0, 3, 1], [2, 4, 5], [0, 1, 4, 2], [0, 2, 5, 3], [1, 3, 5, 4]]
- },
- e[6] = {
- 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]],
- 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]]
- },
- e[7] = {
- 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]],
- 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]]
- },
- e[8] = {
- vertex: [[-.729665, .670121, .319155], [-.655235, -.29213, -.754096], [-.093922, -.607123, .537818], [.702196, .595691, .485187], [.776626, -.36656, -.588064]],
- face: [[1, 4, 2], [0, 1, 2], [3, 0, 2], [4, 3, 2], [4, 1, 0, 3]]
- },
- e[9] = {
- vertex: [[-.868849, -.100041, .61257], [-.329458, .976099, .28078], [-.26629, -.013796, -.477654], [-.13392, -1.034115, .229829], [.738834, .707117, -.307018], [.859683, -.535264, -.338508]],
- face: [[3, 0, 2], [5, 3, 2], [4, 5, 2], [1, 4, 2], [0, 1, 2], [0, 3, 5, 4, 1]]
- },
- e[10] = {
- vertex: [[-.610389, .243975, .531213], [-.187812, -.48795, -.664016], [-.187812, .9759, -.664016], [.187812, -.9759, .664016], [.798201, .243975, .132803]],
- face: [[1, 3, 0], [3, 4, 0], [3, 1, 4], [0, 2, 1], [0, 4, 2], [2, 4, 1]]
- },
- e[11] = {
- vertex: [[-1.028778, .392027, -.048786], [-.640503, -.646161, .621837], [-.125162, -.395663, -.540059], [.004683, .888447, -.651988], [.125161, .395663, .540059], [.632925, -.791376, .433102], [1.031672, .157063, -.354165]],
- 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]]
- },
- e[12] = {
- 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]],
- 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]]
- },
- e[13] = {
- 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]],
- 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]]
- },
- e[14] = {
- 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]],
- 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]]
- };
- 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;
- if ($)
- for (ct = 0; ct < b; ct++)
- j && j[ct] === void 0 && (j[ct] = new Color4(1,1,1,1)),
- k && k[ct] === void 0 && (k[ct] = new Vector4(0,0,1,1));
- if ($)
- for (ct = 0; ct < b; ct++) {
- var mt = _.face[ct].length;
- for (ht = 2 * Math.PI / mt,
- pt = .5 * Math.tan(ht / 2),
- dt = .5,
- ut = 0; ut < mt; ut++)
- et.push(_.vertex[_.face[ct][ut]][0] * s, _.vertex[_.face[ct][ut]][1] * c, _.vertex[_.face[ct][ut]][2] * d),
- st.push(ot),
- ot++,
- lt = k[ct].x + (k[ct].z - k[ct].x) * (.5 + pt),
- ft = k[ct].y + (k[ct].w - k[ct].y) * (dt - .5),
- it.push(lt, ft),
- _t = pt * Math.cos(ht) - dt * Math.sin(ht),
- dt = pt * Math.sin(ht) + dt * Math.cos(ht),
- pt = _t,
- j && nt.push(j[ct].r, j[ct].g, j[ct].b, j[ct].a);
- for (ut = 0; ut < mt - 2; ut++)
- tt.push(st[0 + at], st[ut + 2 + at], st[ut + 1 + at]);
- at += mt
- }
- else {
- for (ut = 0; ut < _.vertex.length; ut++)
- et.push(_.vertex[ut][0] * s, _.vertex[ut][1] * c, _.vertex[ut][2] * d),
- it.push(0, 0);
- for (ct = 0; ct < b; ct++)
- for (ut = 0; ut < _.face[ct].length - 2; ut++)
- tt.push(_.face[ct][0], _.face[ct][ut + 2], _.face[ct][ut + 1])
- }
- VertexData.ComputeNormals(et, tt, rt),
- VertexData._ComputeSides(_e, et, tt, rt, it, a.frontUVs, a.backUVs);
- var vt = new VertexData;
- return vt.positions = et,
- vt.indices = tt,
- vt.normals = rt,
- vt.uvs = it,
- j && $ && (vt.colors = nt),
- vt
- }
- function CreatePolyhedron(a, e, i) {
- e === void 0 && (e = {}),
- i === void 0 && (i = null);
- var o = new Mesh(a,i);
- e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
- o._originalBuilderSideOrientation = e.sideOrientation;
- var s = CreatePolyhedronVertexData(e);
- return s.applyToMesh(o, e.updatable),
- o
- }
- VertexData.CreatePolyhedron = CreatePolyhedronVertexData;
- Mesh.CreatePolyhedron = function(a, e, i) {
- return CreatePolyhedron(a, e, i)
- }
- ;
- function CreateIcoSphereVertexData(a) {
- 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;
- for (dt = 0; dt < 3; dt++)
- ht[dt] = Vector3.Zero(),
- pt[dt] = Vector2.Zero();
- for (var _t = 0; _t < 20; _t++) {
- for (dt = 0; dt < 3; dt++) {
- var mt = j[3 * _t + dt];
- ht[dt].copyFromFloats(k[3 * $[mt]], k[3 * $[mt] + 1], k[3 * $[mt] + 2]),
- ht[dt].normalize().scaleInPlace(i),
- pt[dt].copyFromFloats(_e[2 * mt] * et + rt + at[_t] * nt, _e[2 * mt + 1] * tt + it + at[_t] * ot)
- }
- for (var vt = function(gt, St, xt, bt) {
- var Rt = Vector3.Lerp(ht[0], ht[2], St / s)
- , Mt = Vector3.Lerp(ht[1], ht[2], St / s)
- , Pt = s === St ? ht[2] : Vector3.Lerp(Rt, Mt, gt / (s - St));
- Pt.normalize();
- var It;
- if (o) {
- var Dt = Vector3.Lerp(ht[0], ht[2], bt / s)
- , Ct = Vector3.Lerp(ht[1], ht[2], bt / s);
- It = Vector3.Lerp(Dt, Ct, xt / (s - bt))
- } else
- It = new Vector3(Pt.x,Pt.y,Pt.z);
- It.x /= c,
- It.y /= d,
- It.z /= _,
- It.normalize();
- var Ot = Vector2.Lerp(pt[0], pt[2], St / s)
- , wt = Vector2.Lerp(pt[1], pt[2], St / s)
- , Nt = s === St ? pt[2] : Vector2.Lerp(Ot, wt, gt / (s - St));
- ut.push(Pt.x * c, Pt.y * d, Pt.z * _),
- ct.push(It.x, It.y, It.z),
- lt.push(Nt.x, Nt.y),
- st.push(ft),
- ft++
- }, yt = 0; yt < s; yt++)
- for (var Et = 0; Et + yt < s; Et++)
- vt(Et, yt, Et + 1 / 3, yt + 1 / 3),
- vt(Et + 1, yt, Et + 1 / 3, yt + 1 / 3),
- vt(Et, yt + 1, Et + 1 / 3, yt + 1 / 3),
- Et + yt + 1 < s && (vt(Et + 1, yt, Et + 2 / 3, yt + 2 / 3),
- vt(Et + 1, yt + 1, Et + 2 / 3, yt + 2 / 3),
- vt(Et, yt + 1, Et + 2 / 3, yt + 2 / 3))
- }
- VertexData._ComputeSides(e, ut, st, ct, lt, a.frontUVs, a.backUVs);
- var At = new VertexData;
- return At.indices = st,
- At.positions = ut,
- At.normals = ct,
- At.uvs = lt,
- At
- }
- function CreateIcoSphere(a, e, i) {
- e === void 0 && (e = {}),
- i === void 0 && (i = null);
- var o = new Mesh(a,i);
- e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
- o._originalBuilderSideOrientation = e.sideOrientation;
- var s = CreateIcoSphereVertexData(e);
- return s.applyToMesh(o, e.updatable),
- o
- }
- VertexData.CreateIcoSphere = CreateIcoSphereVertexData;
- Mesh.CreateIcoSphere = function(a, e, i) {
- return CreateIcoSphere(a, e, i)
- }
- ;
- function CreateDecal(a, e, i) {
- var o = e.getIndices()
- , s = e.getVerticesData(VertexBuffer.PositionKind)
- , c = e.getVerticesData(VertexBuffer.NormalKind)
- , d = e.getVerticesData(VertexBuffer.UVKind)
- , _ = i.position || Vector3.Zero()
- , b = i.normal || Vector3.Up()
- , k = i.size || Vector3.One()
- , j = i.angle || 0;
- if (!b) {
- var $ = new Vector3(0,0,1)
- , _e = e.getScene().activeCamera
- , et = Vector3.TransformCoordinates($, _e.getWorldMatrix());
- b = _e.globalPosition.subtract(et)
- }
- var tt = -Math.atan2(b.z, b.x) - Math.PI / 2
- , rt = Math.sqrt(b.x * b.x + b.z * b.z)
- , it = Math.atan2(b.y, rt)
- , nt = Matrix.RotationYawPitchRoll(tt, it, j).multiply(Matrix.Translation(_.x, _.y, _.z))
- , ot = Matrix.Invert(nt)
- , at = e.getWorldMatrix()
- , st = at.multiply(ot)
- , ut = new VertexData;
- ut.indices = [],
- ut.positions = [],
- ut.normals = [],
- ut.uvs = [];
- for (var ct = 0, lt = function(vt) {
- var yt = new PositionNormalTextureVertex;
- if (!o || !s || !c)
- return yt;
- var Et = o[vt];
- return yt.position = new Vector3(s[Et * 3],s[Et * 3 + 1],s[Et * 3 + 2]),
- yt.position = Vector3.TransformCoordinates(yt.position, st),
- yt.normal = new Vector3(c[Et * 3],c[Et * 3 + 1],c[Et * 3 + 2]),
- yt.normal = Vector3.TransformNormal(yt.normal, st),
- i.captureUVS && d && (yt.uv = new Vector2(d[Et * 2],d[Et * 2 + 1])),
- yt
- }, ft = function(vt, yt) {
- if (vt.length === 0)
- return vt;
- for (var Et = .5 * Math.abs(Vector3.Dot(k, yt)), At = function(Ft, Vt) {
- var Lt = Vector3.GetClipFactor(Ft.position, Vt.position, yt, Et);
- return new PositionNormalTextureVertex(Vector3.Lerp(Ft.position, Vt.position, Lt),Vector3.Lerp(Ft.normal, Vt.normal, Lt))
- }, gt = new Array, St = 0; St < vt.length; St += 3) {
- 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;
- switch (xt = Ot > 0,
- bt = wt > 0,
- Rt = Nt > 0,
- Mt = (xt ? 1 : 0) + (bt ? 1 : 0) + (Rt ? 1 : 0),
- Mt) {
- case 0:
- gt.push(vt[St]),
- gt.push(vt[St + 1]),
- gt.push(vt[St + 2]);
- break;
- case 1:
- if (xt && (Pt = vt[St + 1],
- It = vt[St + 2],
- Dt = At(vt[St], Pt),
- Ct = At(vt[St], It)),
- bt) {
- Pt = vt[St],
- It = vt[St + 2],
- Dt = At(vt[St + 1], Pt),
- Ct = At(vt[St + 1], It),
- gt.push(Dt),
- gt.push(It.clone()),
- gt.push(Pt.clone()),
- gt.push(It.clone()),
- gt.push(Dt.clone()),
- gt.push(Ct);
- break
- }
- Rt && (Pt = vt[St],
- It = vt[St + 1],
- Dt = At(vt[St + 2], Pt),
- Ct = At(vt[St + 2], It)),
- Pt && It && Dt && Ct && (gt.push(Pt.clone()),
- gt.push(It.clone()),
- gt.push(Dt),
- gt.push(Ct),
- gt.push(Dt.clone()),
- gt.push(It.clone()));
- break;
- case 2:
- xt || (Pt = vt[St].clone(),
- It = At(Pt, vt[St + 1]),
- Dt = At(Pt, vt[St + 2]),
- gt.push(Pt),
- gt.push(It),
- gt.push(Dt)),
- bt || (Pt = vt[St + 1].clone(),
- It = At(Pt, vt[St + 2]),
- Dt = At(Pt, vt[St]),
- gt.push(Pt),
- gt.push(It),
- gt.push(Dt)),
- Rt || (Pt = vt[St + 2].clone(),
- It = At(Pt, vt[St]),
- Dt = At(Pt, vt[St + 1]),
- gt.push(Pt),
- gt.push(It),
- gt.push(Dt));
- break
- }
- }
- return gt
- }, ht = 0; ht < o.length; ht += 3) {
- var pt = new Array;
- if (pt.push(lt(ht)),
- pt.push(lt(ht + 1)),
- pt.push(lt(ht + 2)),
- pt = ft(pt, new Vector3(1,0,0)),
- pt = ft(pt, new Vector3(-1,0,0)),
- pt = ft(pt, new Vector3(0,1,0)),
- pt = ft(pt, new Vector3(0,-1,0)),
- pt = ft(pt, new Vector3(0,0,1)),
- pt = ft(pt, new Vector3(0,0,-1)),
- pt.length !== 0)
- for (var dt = 0; dt < pt.length; dt++) {
- var _t = pt[dt];
- ut.indices.push(ct),
- _t.position.toArray(ut.positions, ct * 3),
- _t.normal.toArray(ut.normals, ct * 3),
- i.captureUVS ? _t.uv.toArray(ut.uvs, ct * 2) : (ut.uvs.push(.5 + _t.position.x / k.x),
- ut.uvs.push(.5 + _t.position.y / k.y)),
- ct++
- }
- }
- var mt = new Mesh(a,e.getScene());
- return ut.applyToMesh(mt),
- mt.position = _.clone(),
- mt.rotation = new Vector3(it,tt,j),
- mt
- }
- Mesh.CreateDecal = function(a, e, i, o, s, c) {
- var d = {
- position: i,
- normal: o,
- size: s,
- angle: c
- };
- return CreateDecal(a, e, d)
- }
- ;
- function CreateCapsuleVertexData(a) {
- a === void 0 && (a = {
- subdivisions: 2,
- tessellation: 16,
- height: 1,
- radius: .25,
- capSubdivisions: 6
- });
- 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;
- for (ht = 0; ht <= et; ht++) {
- var At = []
- , gt = lt - rt * (ht / et);
- Et += b * rt / et;
- var St = Math.cos(gt)
- , xt = Math.sin(gt)
- , bt = St * b;
- for (ft = 0; ft <= d; ft++) {
- var Rt = ft / d
- , Mt = Rt * _e + $
- , Pt = Math.sin(Mt)
- , It = Math.cos(Mt);
- dt.x = bt * Pt,
- dt.y = ct + xt * b,
- dt.z = bt * It,
- nt.push(dt.x, dt.y, dt.z),
- pt.set(St * Pt, xt, St * It),
- ot.push(pt.x, pt.y, pt.z),
- at.push(Rt, 1 - Et / yt),
- At.push(st),
- st++
- }
- ut.push(At)
- }
- var Dt = o - b - k + _t * b - _t * k
- , Ct = mt * (k - b) / Dt;
- for (ht = 1; ht <= _; ht++) {
- var At = [];
- Et += vt / _;
- var bt = mt * (ht * (k - b) / _ + b);
- for (ft = 0; ft <= d; ft++) {
- var Rt = ft / d
- , Mt = Rt * _e + $
- , Pt = Math.sin(Mt)
- , It = Math.cos(Mt);
- dt.x = bt * Pt,
- dt.y = ct + _t * b - ht * Dt / _,
- dt.z = bt * It,
- nt.push(dt.x, dt.y, dt.z),
- pt.set(Pt, Ct, It).normalize(),
- ot.push(pt.x, pt.y, pt.z),
- at.push(Rt, 1 - Et / yt),
- At.push(st),
- st++
- }
- ut.push(At)
- }
- for (ht = 1; ht <= tt; ht++) {
- var At = []
- , gt = lt - rt - (Math.PI - rt) * (ht / tt);
- Et += k * rt / tt;
- var St = Math.cos(gt)
- , xt = Math.sin(gt)
- , bt = St * k;
- for (ft = 0; ft <= d; ft++) {
- var Rt = ft / d
- , Mt = Rt * _e + $
- , Pt = Math.sin(Mt)
- , It = Math.cos(Mt);
- dt.x = bt * Pt,
- dt.y = -ct + xt * k,
- dt.z = bt * It,
- nt.push(dt.x, dt.y, dt.z),
- pt.set(St * Pt, xt, St * It),
- ot.push(pt.x, pt.y, pt.z),
- at.push(Rt, 1 - Et / yt),
- At.push(st),
- st++
- }
- ut.push(At)
- }
- for (ft = 0; ft < d; ft++)
- for (ht = 0; ht < et + _ + tt; ht++) {
- var Ot = ut[ht][ft]
- , wt = ut[ht + 1][ft]
- , Nt = ut[ht + 1][ft + 1]
- , Ft = ut[ht][ft + 1];
- it.push(Ot),
- it.push(wt),
- it.push(Ft),
- it.push(wt),
- it.push(Nt),
- it.push(Ft)
- }
- if (it = it.reverse(),
- a.orientation && !a.orientation.equals(Vector3.Up())) {
- var Vt = new Matrix;
- a.orientation.clone().scale(Math.PI * .5).cross(Vector3.Up()).toQuaternion().toRotationMatrix(Vt);
- for (var Lt = Vector3.Zero(), kt = 0; kt < nt.length; kt += 3)
- Lt.set(nt[kt], nt[kt + 1], nt[kt + 2]),
- Vector3.TransformCoordinatesToRef(Lt.clone(), Vt, Lt),
- nt[kt] = Lt.x,
- nt[kt + 1] = Lt.y,
- nt[kt + 2] = Lt.z
- }
- var Bt = new VertexData;
- return Bt.positions = nt,
- Bt.normals = ot,
- Bt.uvs = at,
- Bt.indices = it,
- Bt
- }
- function CreateCapsule(a, e, i) {
- e === void 0 && (e = {
- orientation: Vector3.Up(),
- subdivisions: 2,
- tessellation: 16,
- height: 1,
- radius: .25,
- capSubdivisions: 6,
- updatable: !1
- }),
- i === void 0 && (i = null);
- var o = new Mesh(a,i)
- , s = CreateCapsuleVertexData(e);
- return s.applyToMesh(o, e.updatable),
- o
- }
- Mesh.CreateCapsule = function(a, e, i) {
- return CreateCapsule(a, e, i)
- }
- ;
- VertexData.CreateCapsule = CreateCapsuleVertexData;
- var _IsoVector = function() {
- function a(e, i) {
- e === void 0 && (e = 0),
- i === void 0 && (i = 0),
- this.x = e,
- this.y = i,
- e !== Math.floor(e) && Logger$2.Warn("x is not an integer, floor(x) used"),
- i !== Math.floor(i) && Logger$2.Warn("y is not an integer, floor(y) used")
- }
- return a.prototype.clone = function() {
- return new a(this.x,this.y)
- }
- ,
- a.prototype.rotate60About = function(e) {
- var i = this.x;
- return this.x = e.x + e.y - this.y,
- this.y = i + this.y - e.x,
- this
- }
- ,
- a.prototype.rotateNeg60About = function(e) {
- var i = this.x;
- return this.x = i + this.y - e.y,
- this.y = e.x + e.y - i,
- this
- }
- ,
- a.prototype.rotate120 = function(e, i) {
- e !== Math.floor(e) && Logger$2.Warn("m not an integer only floor(m) used"),
- i !== Math.floor(i) && Logger$2.Warn("n not an integer only floor(n) used");
- var o = this.x;
- return this.x = e - o - this.y,
- this.y = i + o,
- this
- }
- ,
- a.prototype.rotateNeg120 = function(e, i) {
- e !== Math.floor(e) && Logger$2.Warn("m is not an integer, floor(m) used"),
- i !== Math.floor(i) && Logger$2.Warn("n is not an integer, floor(n) used");
- var o = this.x;
- return this.x = this.y - i,
- this.y = e + i - o - this.y,
- this
- }
- ,
- a.prototype.toCartesianOrigin = function(e, i) {
- var o = Vector3.Zero();
- return o.x = e.x + 2 * this.x * i + this.y * i,
- o.y = e.y + Math.sqrt(3) * this.y * i,
- o
- }
- ,
- a.Zero = function() {
- return new a(0,0)
- }
- ,
- a
- }()
- , _PrimaryIsoTriangle = function() {
- function a() {
- this.cartesian = [],
- this.vertices = [],
- this.max = [],
- this.min = [],
- this.closestTo = [],
- this.innerFacets = [],
- this.isoVecsABOB = [],
- this.isoVecsOBOA = [],
- this.isoVecsBAOA = [],
- this.vertexTypes = [],
- 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]])
- }
- return a.prototype.setIndices = function() {
- var e = 12
- , i = {}
- , o = this.m
- , s = this.n
- , c = o
- , d = 1
- , _ = 0;
- s !== 0 && (c = Scalar.HCF(o, s)),
- d = o / c,
- _ = s / c;
- 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;
- 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"]];
- for (var pt = 0; pt < 20; pt++) {
- if (at = this.IDATA.face[pt],
- j = at[2],
- $ = at[1],
- _e = at[0],
- ct = et.x + "|" + et.y,
- st = pt + "|" + ct,
- st in i || (i[st] = j,
- ft[j] = [at[ht[ct][0]], ht[ct][1]]),
- ct = tt.x + "|" + tt.y,
- st = pt + "|" + ct,
- st in i || (i[st] = $,
- ft[$] = [at[ht[ct][0]], ht[ct][1]]),
- ct = rt.x + "|" + rt.y,
- st = pt + "|" + ct,
- st in i || (i[st] = _e,
- ft[_e] = [at[ht[ct][0]], ht[ct][1]]),
- b = this.IDATA.edgematch[pt][0],
- k = this.IDATA.edgematch[pt][1],
- k === "B")
- for (var dt = 1; dt < c; dt++)
- nt.x = o - dt * (d + _),
- nt.y = s + dt * d,
- ot.x = -dt * _,
- ot.y = dt * (d + _),
- ct = nt.x + "|" + nt.y,
- lt = ot.x + "|" + ot.y,
- _t(pt, b, ct, lt);
- if (k === "O")
- for (var dt = 1; dt < c; dt++)
- ot.x = -dt * _,
- ot.y = dt * (d + _),
- it.x = dt * d,
- it.y = dt * _,
- ct = ot.x + "|" + ot.y,
- lt = it.x + "|" + it.y,
- _t(pt, b, ct, lt);
- if (b = this.IDATA.edgematch[pt][2],
- k = this.IDATA.edgematch[pt][3],
- k && k === "A")
- for (var dt = 1; dt < c; dt++)
- it.x = dt * d,
- it.y = dt * _,
- nt.x = o - (c - dt) * (d + _),
- nt.y = s + (c - dt) * d,
- ct = it.x + "|" + it.y,
- lt = nt.x + "|" + nt.y,
- _t(pt, b, ct, lt);
- for (var dt = 0; dt < this.vertices.length; dt++)
- ct = this.vertices[dt].x + "|" + this.vertices[dt].y,
- st = pt + "|" + ct,
- st in i || (i[st] = e++,
- 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]])
- }
- function _t(mt, vt, yt, Et) {
- st = mt + "|" + yt,
- ut = vt + "|" + Et,
- 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,
- i[ut] = e,
- e++),
- 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]]
- }
- this.closestTo = ft,
- this.vecToIdx = i
- }
- ,
- a.prototype.calcCoeffs = function() {
- var e = this.m
- , i = this.n
- , o = Math.sqrt(3) / 3
- , s = e * e + i * i + e * i;
- this.coau = (e + i) / s,
- this.cobu = -i / s,
- this.coav = -o * (e - i) / s,
- this.cobv = o * (2 * e + i) / s
- }
- ,
- a.prototype.createInnerFacets = function() {
- for (var e = this.m, i = this.n, o = 0; o < i + e + 1; o++)
- for (var s = this.min[o]; s < this.max[o] + 1; s++)
- s < this.max[o] && s < this.max[o + 1] + 1 && this.innerFacets.push(["|" + s + "|" + o, "|" + s + "|" + (o + 1), "|" + (s + 1) + "|" + o]),
- 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)])
- }
- ,
- a.prototype.edgeVecsABOB = function() {
- for (var e = this.m, i = this.n, o = new _IsoVector(-i,e + i), s = 1; s < e + i; s++) {
- var c = new _IsoVector(this.min[s],s)
- , d = new _IsoVector(this.min[s - 1],s - 1)
- , _ = new _IsoVector(this.min[s + 1],s + 1)
- , b = c.clone()
- , k = d.clone()
- , j = _.clone();
- b.rotate60About(o),
- k.rotate60About(o),
- j.rotate60About(o);
- var $ = new _IsoVector(this.max[b.y],b.y)
- , _e = new _IsoVector(this.max[b.y - 1],b.y - 1)
- , et = new _IsoVector(this.max[b.y - 1] - 1,b.y - 1);
- (b.x !== $.x || b.y !== $.y) && (b.x !== _e.x ? (this.vertexTypes.push([1, 0, 0]),
- this.isoVecsABOB.push([c, _e, et]),
- this.vertexTypes.push([1, 0, 0]),
- this.isoVecsABOB.push([c, et, $])) : b.y === j.y ? (this.vertexTypes.push([1, 1, 0]),
- this.isoVecsABOB.push([c, d, _e]),
- this.vertexTypes.push([1, 0, 1]),
- this.isoVecsABOB.push([c, _e, _])) : (this.vertexTypes.push([1, 1, 0]),
- this.isoVecsABOB.push([c, d, _e]),
- this.vertexTypes.push([1, 0, 0]),
- this.isoVecsABOB.push([c, _e, $])))
- }
- }
- ,
- a.prototype.mapABOBtoOBOA = function() {
- for (var e = new _IsoVector(0,0), i = 0; i < this.isoVecsABOB.length; i++) {
- for (var o = [], s = 0; s < 3; s++)
- e.x = this.isoVecsABOB[i][s].x,
- e.y = this.isoVecsABOB[i][s].y,
- this.vertexTypes[i][s] === 0 && e.rotateNeg120(this.m, this.n),
- o.push(e.clone());
- this.isoVecsOBOA.push(o)
- }
- }
- ,
- a.prototype.mapABOBtoBAOA = function() {
- for (var e = new _IsoVector(0,0), i = 0; i < this.isoVecsABOB.length; i++) {
- for (var o = [], s = 0; s < 3; s++)
- e.x = this.isoVecsABOB[i][s].x,
- e.y = this.isoVecsABOB[i][s].y,
- this.vertexTypes[i][s] === 1 && e.rotate120(this.m, this.n),
- o.push(e.clone());
- this.isoVecsBAOA.push(o)
- }
- }
- ,
- a.prototype.MapToFace = function(e, i) {
- 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++)
- it = _e.scale(this.cartesian[nt].x).add(et.scale(this.cartesian[nt].y)).add(_),
- tt[nt] = [it.x, it.y, it.z],
- rt = e + "|" + this.vertices[nt].x + "|" + this.vertices[nt].y,
- i.vertex[this.vecToIdx[rt]] = [it.x, it.y, it.z]
- }
- ,
- a.prototype.build = function(e, i) {
- var o = new Array
- , s = _IsoVector.Zero()
- , c = new _IsoVector(e,i)
- , d = new _IsoVector(-i,e + i);
- o.push(s, c, d);
- for (var _ = i; _ < e + 1; _++)
- for (var b = 0; b < e + 1 - _; b++)
- o.push(new _IsoVector(b,_));
- if (i > 0) {
- for (var k = Scalar.HCF(e, i), j = e / k, $ = i / k, _e = 1; _e < k; _e++)
- o.push(new _IsoVector(_e * j,_e * $)),
- o.push(new _IsoVector(-_e * $,_e * (j + $))),
- o.push(new _IsoVector(e - _e * (j + $),i + _e * j));
- for (var et = e / i, tt = 1; tt < i; tt++)
- for (var rt = 0; rt < tt * et; rt++)
- o.push(new _IsoVector(rt,tt)),
- o.push(new _IsoVector(rt,tt).rotate120(e, i)),
- o.push(new _IsoVector(rt,tt).rotateNeg120(e, i))
- }
- o.sort(function(yt, Et) {
- return yt.x - Et.x
- }),
- o.sort(function(yt, Et) {
- return yt.y - Et.y
- });
- for (var it = new Array(e + i + 1), nt = new Array(e + i + 1), _e = 0; _e < it.length; _e++)
- it[_e] = 1 / 0,
- nt[_e] = -1 / 0;
- for (var ot = 0, at = 0, st = o.length, _e = 0; _e < st; _e++)
- at = o[_e].x,
- ot = o[_e].y,
- it[ot] = Math.min(at, it[ot]),
- nt[ot] = Math.max(at, nt[ot]);
- for (var ut = function(yt, Et) {
- var At = yt.clone();
- return Et === "A" && At.rotateNeg120(e, i),
- Et === "B" && At.rotate120(e, i),
- At.x < 0 ? At.y : At.x + At.y
- }, ct = [], lt = [], ft = [], ht = [], pt = {}, dt = [], _t = -1, mt = -1, _e = 0; _e < st; _e++)
- ct[_e] = o[_e].toCartesianOrigin(new _IsoVector(0,0), .5),
- lt[_e] = ut(o[_e], "O"),
- ft[_e] = ut(o[_e], "A"),
- ht[_e] = ut(o[_e], "B"),
- lt[_e] === ft[_e] && ft[_e] === ht[_e] ? (_t = 3,
- mt = lt[_e]) : lt[_e] === ft[_e] ? (_t = 4,
- mt = lt[_e]) : ft[_e] === ht[_e] ? (_t = 5,
- mt = ft[_e]) : ht[_e] === lt[_e] && (_t = 6,
- mt = lt[_e]),
- lt[_e] < ft[_e] && lt[_e] < ht[_e] && (_t = 2,
- mt = lt[_e]),
- ft[_e] < lt[_e] && ft[_e] < ht[_e] && (_t = 1,
- mt = ft[_e]),
- ht[_e] < ft[_e] && ht[_e] < lt[_e] && (_t = 0,
- mt = ht[_e]),
- dt.push([_t, mt, o[_e].x, o[_e].y]);
- dt.sort(function(yt, Et) {
- return yt[2] - Et[2]
- }),
- dt.sort(function(yt, Et) {
- return yt[3] - Et[3]
- }),
- dt.sort(function(yt, Et) {
- return yt[1] - Et[1]
- }),
- dt.sort(function(yt, Et) {
- return yt[0] - Et[0]
- });
- for (var vt = 0; vt < dt.length; vt++)
- pt[dt[vt][2] + "|" + dt[vt][3]] = [dt[vt][0], dt[vt][1], vt];
- return this.m = e,
- this.n = i,
- this.vertices = o,
- this.vertByDist = pt,
- this.cartesian = ct,
- this.min = it,
- this.max = nt,
- this
- }
- ,
- a
- }()
- , PolyhedronData = function() {
- function a(e, i, o, s) {
- this.name = e,
- this.category = i,
- this.vertex = o,
- this.face = s
- }
- return a
- }()
- , GeodesicData = function(a) {
- __extends(e, a);
- function e() {
- return a !== null && a.apply(this, arguments) || this
- }
- return e.prototype.innerToData = function(i, o) {
- for (var s = 0; s < o.innerFacets.length; s++)
- this.face.push(o.innerFacets[s].map(function(c) {
- return o.vecToIdx[i + c]
- }))
- }
- ,
- e.prototype.mapABOBtoDATA = function(i, o) {
- for (var s = o.IDATA.edgematch[i][0], c = 0; c < o.isoVecsABOB.length; c++) {
- for (var d = [], _ = 0; _ < 3; _++)
- 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);
- this.face.push([o.vecToIdx[d[0]], o.vecToIdx[d[1]], o.vecToIdx[d[2]]])
- }
- }
- ,
- e.prototype.mapOBOAtoDATA = function(i, o) {
- for (var s = o.IDATA.edgematch[i][0], c = 0; c < o.isoVecsOBOA.length; c++) {
- for (var d = [], _ = 0; _ < 3; _++)
- 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);
- this.face.push([o.vecToIdx[d[0]], o.vecToIdx[d[1]], o.vecToIdx[d[2]]])
- }
- }
- ,
- e.prototype.mapBAOAtoDATA = function(i, o) {
- for (var s = o.IDATA.edgematch[i][2], c = 0; c < o.isoVecsBAOA.length; c++) {
- for (var d = [], _ = 0; _ < 3; _++)
- 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);
- this.face.push([o.vecToIdx[d[0]], o.vecToIdx[d[1]], o.vecToIdx[d[2]]])
- }
- }
- ,
- e.prototype.orderData = function(i) {
- for (var o = [], s = 0; s < 13; s++)
- o[s] = [];
- for (var c = i.closestTo, s = 0; s < c.length; s++)
- c[s][0] > -1 ? c[s][1] > 0 && o[c[s][0]].push([s, c[s][1]]) : o[12].push([s, c[s][0]]);
- for (var d = [], s = 0; s < 12; s++)
- d[s] = s;
- for (var _ = 12, s = 0; s < 12; s++) {
- o[s].sort(function(j, $) {
- return j[1] - $[1]
- });
- for (var b = 0; b < o[s].length; b++)
- d[o[s][b][0]] = _++
- }
- for (var b = 0; b < o[12].length; b++)
- d[o[12][b][0]] = _++;
- for (var s = 0; s < this.vertex.length; s++)
- this.vertex[s].push(d[s]);
- this.vertex.sort(function(k, j) {
- return k[3] - j[3]
- });
- for (var s = 0; s < this.vertex.length; s++)
- this.vertex[s].pop();
- for (var s = 0; s < this.face.length; s++)
- for (var b = 0; b < this.face[s].length; b++)
- this.face[s][b] = d[this.face[s][b]];
- this.sharedNodes = o[12].length,
- this.poleNodes = this.vertex.length - this.sharedNodes
- }
- ,
- e.prototype.setOrder = function(i, o) {
- var s = []
- , c = []
- , d = o.pop();
- c.push(d);
- var _ = this.face[d].indexOf(i);
- _ = (_ + 2) % 3;
- var b = this.face[d][_];
- s.push(b);
- for (var k = 0; o.length > 0; )
- d = o[k],
- this.face[d].indexOf(b) > -1 ? (_ = (this.face[d].indexOf(b) + 1) % 3,
- b = this.face[d][_],
- s.push(b),
- c.push(d),
- o.splice(k, 1),
- k = 0) : k++;
- return this.adjacentFaces.push(s),
- c
- }
- ,
- e.prototype.toGoldbergData = function() {
- var i = this
- , o = new PolyhedronData("GeoDual","Goldberg",[],[]);
- o.name = "GD dual";
- for (var s = this.vertex.length, c = new Array(s), d = 0; d < s; d++)
- c[d] = [];
- for (var _ = 0; _ < this.face.length; _++)
- for (var b = 0; b < 3; b++)
- c[this.face[_][b]].push(_);
- var k = 0
- , j = 0
- , $ = 0
- , _e = []
- , et = [];
- this.adjacentFaces = [];
- for (var tt = 0; tt < c.length; tt++)
- o.face[tt] = this.setOrder(tt, c[tt].concat([])),
- c[tt].forEach(function(rt) {
- k = 0,
- j = 0,
- $ = 0,
- _e = i.face[rt];
- for (var it = 0; it < 3; it++)
- et = i.vertex[_e[it]],
- k += et[0],
- j += et[1],
- $ += et[2];
- o.vertex[rt] = [k / 3, j / 3, $ / 3]
- });
- return o
- }
- ,
- e.BuildGeodesicData = function(i) {
- 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]],[]);
- i.setIndices(),
- i.calcCoeffs(),
- i.createInnerFacets(),
- i.edgeVecsABOB(),
- i.mapABOBtoOBOA(),
- i.mapABOBtoBAOA();
- for (var s = 0; s < i.IDATA.face.length; s++)
- i.MapToFace(s, o),
- o.innerToData(s, i),
- i.IDATA.edgematch[s][1] === "B" && o.mapABOBtoDATA(s, i),
- i.IDATA.edgematch[s][1] === "O" && o.mapOBOAtoDATA(s, i),
- i.IDATA.edgematch[s][3] === "A" && o.mapBAOAtoDATA(s, i);
- o.orderData(i);
- var c = 1;
- return o.vertex = o.vertex.map(function(d) {
- var _ = d[0]
- , b = d[1]
- , k = d[2]
- , j = Math.sqrt(_ * _ + b * b + k * k);
- return d[0] *= c / j,
- d[1] *= c / j,
- d[2] *= c / j,
- d
- }),
- o
- }
- ,
- e
- }(PolyhedronData);
- function CreateGeodesic(a, e, i) {
- i === void 0 && (i = null);
- var o = e.m || 1;
- o !== Math.floor(o) && Logger$2.Warn("m not an integer only floor(m) used");
- var s = e.n || 0;
- if (s !== Math.floor(s) && Logger$2.Warn("n not an integer only floor(n) used"),
- s > o) {
- var c = s;
- s = o,
- o = c,
- Logger$2.Warn("n > m therefore m and n swapped")
- }
- var d = new _PrimaryIsoTriangle;
- d.build(o, s);
- var _ = GeodesicData.BuildGeodesicData(d)
- , b = {
- custom: _,
- size: e.size,
- sizeX: e.sizeX,
- sizeY: e.sizeY,
- sizeZ: e.sizeZ,
- faceUV: e.faceUV,
- faceColors: e.faceColors,
- flat: e.flat,
- updatable: e.updatable,
- sideOrientation: e.sideOrientation,
- frontUVs: e.frontUVs,
- backUVs: e.backUVs
- }
- , k = CreatePolyhedron(a, b, i);
- return k
- }
- function CreateGoldbergVertexData(a, e) {
- 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++)
- $ = Math.min($, e.vertex[rt][0] * o),
- _e = Math.max(_e, e.vertex[rt][0] * o),
- et = Math.min(et, e.vertex[rt][1] * s),
- tt = Math.max(tt, e.vertex[rt][1] * s);
- for (var it = 0, nt = 0; nt < e.face.length; nt++) {
- 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++) {
- k.push(ft.x, ft.y, ft.z);
- var ht = e.vertex[ot[rt]];
- _.push(ht[0] * o, ht[1] * s, ht[2] * c),
- j.push((ht[0] * o - $) / (_e - $), (ht[1] * s - et) / (tt - et))
- }
- for (var rt = 0; rt < ot.length - 2; rt++)
- b.push(it, it + rt + 2, it + rt + 1);
- it += ot.length
- }
- VertexData._ComputeSides(d, _, b, k, j);
- var pt = new VertexData;
- return pt.positions = _,
- pt.indices = b,
- pt.normals = k,
- pt.uvs = j,
- pt
- }
- function CreateGoldberg(a, e, i) {
- var o = e.m || 1;
- o !== Math.floor(o) && Logger$2.Warn("m not an integer only floor(m) used");
- var s = e.n || 0;
- if (s !== Math.floor(s) && Logger$2.Warn("n not an integer only floor(n) used"),
- s > o) {
- var c = s;
- s = o,
- o = c,
- Logger$2.Warn("n > m therefore m and n swapped")
- }
- var d = new _PrimaryIsoTriangle;
- d.build(o, s);
- var _ = GeodesicData.BuildGeodesicData(d)
- , b = _.toGoldbergData()
- , k = new GoldbergMesh(a);
- e.sideOrientation = Mesh._GetDefaultSideOrientation(e.sideOrientation),
- k._originalBuilderSideOrientation = e.sideOrientation;
- var j = CreateGoldbergVertexData(e, b);
- j.applyToMesh(k, e.updatable),
- k.nbSharedFaces = _.sharedNodes,
- k.nbUnsharedFaces = _.poleNodes,
- k.adjacentFaces = _.adjacentFaces,
- k.nbFaces = k.nbSharedFaces + k.nbUnsharedFaces,
- k.nbFacesAtPole = (k.nbUnsharedFaces - 12) / 12;
- for (var $ = 0; $ < _.vertex.length; $++)
- k.faceCenters.push(Vector3.FromArray(_.vertex[$])),
- k.faceColors.push(new Color4(1,1,1,1));
- for (var $ = 0; $ < b.face.length; $++) {
- var _e = b.face[$]
- , et = Vector3.FromArray(b.vertex[_e[0]])
- , tt = Vector3.FromArray(b.vertex[_e[2]])
- , rt = Vector3.FromArray(b.vertex[_e[1]])
- , it = tt.subtract(et)
- , nt = rt.subtract(et)
- , ot = Vector3.Cross(nt, it).normalize()
- , at = Vector3.Cross(nt, ot).normalize();
- k.faceXaxis.push(nt.normalize()),
- k.faceYaxis.push(ot),
- k.faceZaxis.push(at)
- }
- return k.setMetadata(),
- k
- }
- function GoldbergCreate(a) {
- return function(e) {
- __extends(i, e);
- function i() {
- var o = e !== null && e.apply(this, arguments) || this;
- return o.faceColors = [],
- o.faceCenters = [],
- o.faceZaxis = [],
- o.faceXaxis = [],
- o.faceYaxis = [],
- o
- }
- return i.prototype.setMetadata = function() {
- this.metadata = {
- nbSharedFaces: this.nbSharedFaces,
- nbUnsharedFaces: this.nbUnsharedFaces,
- nbFacesAtPole: this.nbFacesAtPole,
- nbFaces: this.nbFaces,
- faceCenters: this.faceCenters,
- faceXaxis: this.faceXaxis,
- faceYaxis: this.faceYaxis,
- faceZaxis: this.faceZaxis,
- adjacentFaces: this.adjacentFaces
- }
- }
- ,
- i.prototype.relFace = function(o, s) {
- return s === void 0 ? (o > this.nbUnsharedFaces - 1 && (Logger$2.Warn("Maximum number of unshared faces used"),
- o = this.nbUnsharedFaces - 1),
- this.nbUnsharedFaces + o) : (o > 11 && (Logger$2.Warn("Last pole used"),
- o = 11),
- s > this.nbFacesAtPole - 1 && (Logger$2.Warn("Maximum number of faces at a pole used"),
- s = this.nbFacesAtPole - 1),
- 12 + o * this.nbFacesAtPole + s)
- }
- ,
- i.prototype.refreshFaceData = function() {
- this.nbSharedFaces = this.metadata.nbSharedFaces,
- this.nbUnsharedFaces = this.metadata.nbUnsharedFaces,
- this.nbFacesAtPole = this.metadata.nbFacesAtPole,
- this.adjacentFaces = this.metadata.adjacentFaces,
- this.nbFaces = this.metadata.nbFaces,
- this.faceCenters = this.metadata.faceCenters,
- this.faceXaxis = this.metadata.faceXaxis,
- this.faceYaxis = this.metadata.faceYaxis,
- this.faceZaxis = this.metadata.faceZaxis
- }
- ,
- i.prototype.changeFaceColors = function(o) {
- for (var s = 0; s < o.length; s++)
- for (var c = o[s][0], d = o[s][1], _ = o[s][2], b = c; b < d + 1; b++)
- this.faceColors[b] = _;
- for (var k = [], b = 0; b < 12; b++)
- for (var s = 0; s < 5; s++)
- k.push(this.faceColors[b].r, this.faceColors[b].g, this.faceColors[b].b, this.faceColors[b].a);
- for (var b = 12; b < this.faceColors.length; b++)
- for (var s = 0; s < 6; s++)
- k.push(this.faceColors[b].r, this.faceColors[b].g, this.faceColors[b].b, this.faceColors[b].a);
- return k
- }
- ,
- i.prototype.setFaceColors = function(o) {
- var s = this.changeFaceColors(o);
- this.setVerticesData(VertexBuffer.ColorKind, s)
- }
- ,
- i.prototype.updateFaceColors = function(o) {
- var s = this.changeFaceColors(o);
- this.updateVerticesData(VertexBuffer.ColorKind, s)
- }
- ,
- i.prototype.changeFaceUVs = function(o) {
- for (var s = this.getVerticesData(VertexBuffer.UVKind), c = 0; c < o.length; c++) {
- 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++)
- et = b.x + k * Math.cos(j + rt * Math.PI / 2.5),
- tt = b.y + k * Math.sin(j + rt * Math.PI / 2.5),
- et < 0 && (et = 0),
- et > 1 && (et = 1),
- $.push(et, tt);
- for (var rt = 0; rt < 6; rt++)
- et = b.x + k * Math.cos(j + rt * Math.PI / 3),
- tt = b.y + k * Math.sin(j + rt * Math.PI / 3),
- et < 0 && (et = 0),
- et > 1 && (et = 1),
- _e.push(et, tt);
- for (var it = d; it < Math.min(12, _ + 1); it++)
- for (var rt = 0; rt < 5; rt++)
- s[10 * it + 2 * rt] = $[2 * rt],
- s[10 * it + 2 * rt + 1] = $[2 * rt + 1];
- for (var it = Math.max(12, d); it < _ + 1; it++)
- for (var rt = 0; rt < 6; rt++)
- s[12 * it - 24 + 2 * rt] = _e[2 * rt],
- s[12 * it - 23 + 2 * rt] = _e[2 * rt + 1]
- }
- return s
- }
- ,
- i.prototype.setFaceUVs = function(o) {
- var s = this.changeFaceUVs(o);
- this.setVerticesData(VertexBuffer.UVKind, s)
- }
- ,
- i.prototype.updateFaceUVs = function(o) {
- var s = this.changeFaceUVs(o);
- this.updateVerticesData(VertexBuffer.UVKind, s)
- }
- ,
- i.prototype.placeOnFaceAt = function(o, s, c) {
- var d = Vector3.RotationFromAxis(this.faceXaxis[s], this.faceYaxis[s], this.faceZaxis[s]);
- o.rotation = d,
- 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))
- }
- ,
- i
- }(a)
- }
- var GoldbergMesh = GoldbergCreate(Mesh)
- , MeshBuilder = {
- CreateBox,
- CreateTiledBox,
- CreateSphere,
- CreateDisc,
- CreateIcoSphere,
- CreateRibbon,
- CreateCylinder,
- CreateTorus,
- CreateTorusKnot,
- CreateLineSystem,
- CreateLines,
- CreateDashedLines,
- ExtrudeShape,
- ExtrudeShapeCustom,
- CreateLathe,
- CreateTiledPlane,
- CreatePlane,
- CreateGround,
- CreateTiledGround,
- CreateGroundFromHeightMap,
- CreatePolygon,
- ExtrudePolygon,
- CreateTube,
- CreatePolyhedron,
- CreateGeodesic,
- CreateGoldberg,
- CreateDecal,
- CreateCapsule
- }
- , Ray = function() {
- function a(e, i, o) {
- o === void 0 && (o = Number.MAX_VALUE),
- this.origin = e,
- this.direction = i,
- this.length = o
- }
- return a.prototype.clone = function() {
- return new a(this.origin.clone(),this.direction.clone(),this.length)
- }
- ,
- a.prototype.intersectsBoxMinMax = function(e, i, o) {
- o === void 0 && (o = 0);
- 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, $;
- if (Math.abs(this.direction.x) < 1e-7) {
- if (this.origin.x < s.x || this.origin.x > c.x)
- return !1
- } else if (b = 1 / this.direction.x,
- k = (s.x - this.origin.x) * b,
- j = (c.x - this.origin.x) * b,
- j === -1 / 0 && (j = 1 / 0),
- k > j && ($ = k,
- k = j,
- j = $),
- d = Math.max(k, d),
- _ = Math.min(j, _),
- d > _)
- return !1;
- if (Math.abs(this.direction.y) < 1e-7) {
- if (this.origin.y < s.y || this.origin.y > c.y)
- return !1
- } else if (b = 1 / this.direction.y,
- k = (s.y - this.origin.y) * b,
- j = (c.y - this.origin.y) * b,
- j === -1 / 0 && (j = 1 / 0),
- k > j && ($ = k,
- k = j,
- j = $),
- d = Math.max(k, d),
- _ = Math.min(j, _),
- d > _)
- return !1;
- if (Math.abs(this.direction.z) < 1e-7) {
- if (this.origin.z < s.z || this.origin.z > c.z)
- return !1
- } else if (b = 1 / this.direction.z,
- k = (s.z - this.origin.z) * b,
- j = (c.z - this.origin.z) * b,
- j === -1 / 0 && (j = 1 / 0),
- k > j && ($ = k,
- k = j,
- j = $),
- d = Math.max(k, d),
- _ = Math.min(j, _),
- d > _)
- return !1;
- return !0
- }
- ,
- a.prototype.intersectsBox = function(e, i) {
- return i === void 0 && (i = 0),
- this.intersectsBoxMinMax(e.minimum, e.maximum, i)
- }
- ,
- a.prototype.intersectsSphere = function(e, i) {
- i === void 0 && (i = 0);
- var o = e.center.x - this.origin.x
- , s = e.center.y - this.origin.y
- , c = e.center.z - this.origin.z
- , d = o * o + s * s + c * c
- , _ = e.radius + i
- , b = _ * _;
- if (d <= b)
- return !0;
- var k = o * this.direction.x + s * this.direction.y + c * this.direction.z;
- if (k < 0)
- return !1;
- var j = d - k * k;
- return j <= b
- }
- ,
- a.prototype.intersectsTriangle = function(e, i, o) {
- var s = a._TmpVector3[0]
- , c = a._TmpVector3[1]
- , d = a._TmpVector3[2]
- , _ = a._TmpVector3[3]
- , b = a._TmpVector3[4];
- i.subtractToRef(e, s),
- o.subtractToRef(e, c),
- Vector3.CrossToRef(this.direction, c, d);
- var k = Vector3.Dot(s, d);
- if (k === 0)
- return null;
- var j = 1 / k;
- this.origin.subtractToRef(e, _);
- var $ = Vector3.Dot(_, d) * j;
- if ($ < 0 || $ > 1)
- return null;
- Vector3.CrossToRef(_, s, b);
- var _e = Vector3.Dot(this.direction, b) * j;
- if (_e < 0 || $ + _e > 1)
- return null;
- var et = Vector3.Dot(c, b) * j;
- return et > this.length ? null : new IntersectionInfo(1 - $ - _e,$,et)
- }
- ,
- a.prototype.intersectsPlane = function(e) {
- var i, o = Vector3.Dot(e.normal, this.direction);
- if (Math.abs(o) < 999999997475243e-21)
- return null;
- var s = Vector3.Dot(e.normal, this.origin);
- return i = (-e.d - s) / o,
- i < 0 ? i < -999999997475243e-21 ? null : 0 : i
- }
- ,
- a.prototype.intersectsAxis = function(e, i) {
- switch (i === void 0 && (i = 0),
- e) {
- case "y":
- var o = (this.origin.y - i) / this.direction.y;
- return o > 0 ? null : new Vector3(this.origin.x + this.direction.x * -o,i,this.origin.z + this.direction.z * -o);
- case "x":
- var o = (this.origin.x - i) / this.direction.x;
- return o > 0 ? null : new Vector3(i,this.origin.y + this.direction.y * -o,this.origin.z + this.direction.z * -o);
- case "z":
- var o = (this.origin.z - i) / this.direction.z;
- return o > 0 ? null : new Vector3(this.origin.x + this.direction.x * -o,this.origin.y + this.direction.y * -o,i);
- default:
- return null
- }
- }
- ,
- a.prototype.intersectsMesh = function(e, i) {
- var o = TmpVectors.Matrix[0];
- return e.getWorldMatrix().invertToRef(o),
- this._tmpRay ? a.TransformToRef(this, o, this._tmpRay) : this._tmpRay = a.Transform(this, o),
- e.intersects(this._tmpRay, i)
- }
- ,
- a.prototype.intersectsMeshes = function(e, i, o) {
- o ? o.length = 0 : o = [];
- for (var s = 0; s < e.length; s++) {
- var c = this.intersectsMesh(e[s], i);
- c.hit && o.push(c)
- }
- return o.sort(this._comparePickingInfo),
- o
- }
- ,
- a.prototype._comparePickingInfo = function(e, i) {
- return e.distance < i.distance ? -1 : e.distance > i.distance ? 1 : 0
- }
- ,
- a.prototype.intersectionSegment = function(e, i, o) {
- var s = this.origin
- , c = TmpVectors.Vector3[0]
- , d = TmpVectors.Vector3[1]
- , _ = TmpVectors.Vector3[2]
- , b = TmpVectors.Vector3[3];
- i.subtractToRef(e, c),
- this.direction.scaleToRef(a.rayl, _),
- s.addToRef(_, d),
- e.subtractToRef(s, b);
- 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;
- tt < a.smallnum ? (it = 0,
- nt = 1,
- at = et,
- st = $) : (it = j * et - $ * _e,
- at = k * et - j * _e,
- it < 0 ? (it = 0,
- at = et,
- st = $) : it > nt && (it = nt,
- at = et + j,
- st = $)),
- at < 0 ? (at = 0,
- -_e < 0 ? it = 0 : -_e > k ? it = nt : (it = -_e,
- nt = k)) : at > st && (at = st,
- -_e + j < 0 ? it = 0 : -_e + j > k ? it = nt : (it = -_e + j,
- nt = k)),
- rt = Math.abs(it) < a.smallnum ? 0 : it / nt,
- ot = Math.abs(at) < a.smallnum ? 0 : at / st;
- var ut = TmpVectors.Vector3[4];
- _.scaleToRef(ot, ut);
- var ct = TmpVectors.Vector3[5];
- c.scaleToRef(rt, ct),
- ct.addInPlace(b);
- var lt = TmpVectors.Vector3[6];
- ct.subtractToRef(ut, lt);
- var ft = ot > 0 && ot <= this.length && lt.lengthSquared() < o * o;
- return ft ? ct.length() : -1
- }
- ,
- a.prototype.update = function(e, i, o, s, c, d, _) {
- return this.unprojectRayToRef(e, i, o, s, c, d, _),
- this
- }
- ,
- a.Zero = function() {
- return new a(Vector3.Zero(),Vector3.Zero())
- }
- ,
- a.CreateNew = function(e, i, o, s, c, d, _) {
- var b = a.Zero();
- return b.update(e, i, o, s, c, d, _)
- }
- ,
- a.CreateNewFromTo = function(e, i, o) {
- o === void 0 && (o = Matrix.IdentityReadOnly);
- var s = i.subtract(e)
- , c = Math.sqrt(s.x * s.x + s.y * s.y + s.z * s.z);
- return s.normalize(),
- a.Transform(new a(e,s,c), o)
- }
- ,
- a.Transform = function(e, i) {
- var o = new a(new Vector3(0,0,0),new Vector3(0,0,0));
- return a.TransformToRef(e, i, o),
- o
- }
- ,
- a.TransformToRef = function(e, i, o) {
- Vector3.TransformCoordinatesToRef(e.origin, i, o.origin),
- Vector3.TransformNormalToRef(e.direction, i, o.direction),
- o.length = e.length;
- var s = o.direction
- , c = s.length();
- if (!(c === 0 || c === 1)) {
- var d = 1 / c;
- s.x *= d,
- s.y *= d,
- s.z *= d,
- o.length *= c
- }
- }
- ,
- a.prototype.unprojectRayToRef = function(e, i, o, s, c, d, _) {
- var b = TmpVectors.Matrix[0];
- c.multiplyToRef(d, b),
- b.multiplyToRef(_, b),
- b.invert();
- var k = TmpVectors.Vector3[0];
- k.x = e / o * 2 - 1,
- k.y = -(i / s * 2 - 1),
- k.z = -1;
- var j = TmpVectors.Vector3[1].copyFromFloats(k.x, k.y, 1)
- , $ = TmpVectors.Vector3[2]
- , _e = TmpVectors.Vector3[3];
- Vector3._UnprojectFromInvertedMatrixToRef(k, b, $),
- Vector3._UnprojectFromInvertedMatrixToRef(j, b, _e),
- this.origin.copyFrom($),
- _e.subtractToRef($, this.direction),
- this.direction.normalize()
- }
- ,
- a._TmpVector3 = ArrayTools.BuildArray(6, Vector3.Zero),
- a.smallnum = 1e-8,
- a.rayl = 1e9,
- a
- }();
- Scene.prototype.createPickingRay = function(a, e, i, o, s) {
- s === void 0 && (s = !1);
- var c = Ray.Zero();
- return this.createPickingRayToRef(a, e, i, c, o, s),
- c
- }
- ;
- Scene.prototype.createPickingRayToRef = function(a, e, i, o, s, c) {
- c === void 0 && (c = !1);
- var d = this.getEngine();
- if (!s) {
- if (!this.activeCamera)
- return this;
- s = this.activeCamera
- }
- var _ = s.viewport
- , b = _.toGlobal(d.getRenderWidth(), d.getRenderHeight());
- return a = a / d.getHardwareScalingLevel() - b.x,
- e = e / d.getHardwareScalingLevel() - (d.getRenderHeight() - b.y - b.height),
- o.update(a, e, b.width, b.height, i || Matrix.IdentityReadOnly, c ? Matrix.IdentityReadOnly : s.getViewMatrix(), s.getProjectionMatrix()),
- this
- }
- ;
- Scene.prototype.createPickingRayInCameraSpace = function(a, e, i) {
- var o = Ray.Zero();
- return this.createPickingRayInCameraSpaceToRef(a, e, o, i),
- o
- }
- ;
- Scene.prototype.createPickingRayInCameraSpaceToRef = function(a, e, i, o) {
- if (!PickingInfo)
- return this;
- var s = this.getEngine();
- if (!o) {
- if (!this.activeCamera)
- throw new Error("Active camera not set");
- o = this.activeCamera
- }
- var c = o.viewport
- , d = c.toGlobal(s.getRenderWidth(), s.getRenderHeight())
- , _ = Matrix.Identity();
- return a = a / s.getHardwareScalingLevel() - d.x,
- e = e / s.getHardwareScalingLevel() - (s.getRenderHeight() - d.y - d.height),
- i.update(a, e, d.width, d.height, _, _, o.getProjectionMatrix()),
- this
- }
- ;
- Scene.prototype._internalPickForMesh = function(a, e, i, o, s, c, d, _) {
- var b = e(o)
- , k = i.intersects(b, s, d, c, o, _);
- return !k || !k.hit || !s && a != null && k.distance >= a.distance ? null : k
- }
- ;
- Scene.prototype._internalPick = function(a, e, i, o, s) {
- if (!PickingInfo)
- return null;
- for (var c = null, d = 0; d < this.meshes.length; d++) {
- var _ = this.meshes[d];
- if (e) {
- if (!e(_))
- continue
- } else if (!_.isEnabled() || !_.isVisible || !_.isPickable)
- continue;
- var b = _.skeleton && _.skeleton.overrideMesh ? _.skeleton.overrideMesh.getWorldMatrix() : _.getWorldMatrix();
- if (_.hasThinInstances && _.thinInstanceEnablePicking) {
- var k = this._internalPickForMesh(c, a, _, b, !0, !0, s);
- if (k) {
- if (o)
- return c;
- for (var j = TmpVectors.Matrix[1], $ = _.thinInstanceGetWorldMatrices(), _e = 0; _e < $.length; _e++) {
- var et = $[_e];
- et.multiplyToRef(b, j);
- var tt = this._internalPickForMesh(c, a, _, j, i, o, s, !0);
- if (tt && (c = tt,
- c.thinInstanceIndex = _e,
- i))
- return c
- }
- }
- } else {
- var k = this._internalPickForMesh(c, a, _, b, i, o, s);
- if (k && (c = k,
- i))
- return c
- }
- }
- return c || new PickingInfo
- }
- ;
- Scene.prototype._internalMultiPick = function(a, e, i) {
- if (!PickingInfo)
- return null;
- for (var o = new Array, s = 0; s < this.meshes.length; s++) {
- var c = this.meshes[s];
- if (e) {
- if (!e(c))
- continue
- } else if (!c.isEnabled() || !c.isVisible || !c.isPickable)
- continue;
- var d = c.skeleton && c.skeleton.overrideMesh ? c.skeleton.overrideMesh.getWorldMatrix() : c.getWorldMatrix();
- if (c.hasThinInstances && c.thinInstanceEnablePicking) {
- var _ = this._internalPickForMesh(null, a, c, d, !0, !0, i);
- if (_)
- for (var b = TmpVectors.Matrix[1], k = c.thinInstanceGetWorldMatrices(), j = 0; j < k.length; j++) {
- var $ = k[j];
- $.multiplyToRef(d, b);
- var _e = this._internalPickForMesh(null, a, c, b, !1, !1, i, !0);
- _e && (_e.thinInstanceIndex = j,
- o.push(_e))
- }
- } else {
- var _ = this._internalPickForMesh(null, a, c, d, !1, !1, i);
- _ && o.push(_)
- }
- }
- return o
- }
- ;
- Scene.prototype.pickWithBoundingInfo = function(a, e, i, o, s) {
- var c = this;
- if (!PickingInfo)
- return null;
- var d = this._internalPick(function(_) {
- return c._tempPickingRay || (c._tempPickingRay = Ray.Zero()),
- c.createPickingRayToRef(a, e, _, c._tempPickingRay, s || null),
- c._tempPickingRay
- }, i, o, !0);
- return d && (d.ray = this.createPickingRay(a, e, Matrix.Identity(), s || null)),
- d
- }
- ;
- Scene.prototype.pick = function(a, e, i, o, s, c) {
- var d = this;
- if (!PickingInfo)
- return null;
- var _ = this._internalPick(function(b) {
- return d._tempPickingRay || (d._tempPickingRay = Ray.Zero()),
- d.createPickingRayToRef(a, e, b, d._tempPickingRay, s || null),
- d._tempPickingRay
- }, i, o, !1, c);
- return _ && (_.ray = this.createPickingRay(a, e, Matrix.Identity(), s || null)),
- _
- }
- ;
- Scene.prototype.pickWithRay = function(a, e, i, o) {
- var s = this
- , c = this._internalPick(function(d) {
- return s._pickWithRayInverseMatrix || (s._pickWithRayInverseMatrix = Matrix.Identity()),
- d.invertToRef(s._pickWithRayInverseMatrix),
- s._cachedRayForTransform || (s._cachedRayForTransform = Ray.Zero()),
- Ray.TransformToRef(a, s._pickWithRayInverseMatrix, s._cachedRayForTransform),
- s._cachedRayForTransform
- }, e, i, !1, o);
- return c && (c.ray = a),
- c
- }
- ;
- Scene.prototype.multiPick = function(a, e, i, o, s) {
- var c = this;
- return this._internalMultiPick(function(d) {
- return c.createPickingRay(a, e, d, o || null)
- }, i, s)
- }
- ;
- Scene.prototype.multiPickWithRay = function(a, e, i) {
- var o = this;
- return this._internalMultiPick(function(s) {
- return o._pickWithRayInverseMatrix || (o._pickWithRayInverseMatrix = Matrix.Identity()),
- s.invertToRef(o._pickWithRayInverseMatrix),
- o._cachedRayForTransform || (o._cachedRayForTransform = Ray.Zero()),
- Ray.TransformToRef(a, o._pickWithRayInverseMatrix, o._cachedRayForTransform),
- o._cachedRayForTransform
- }, e, i)
- }
- ;
- Camera$1.prototype.getForwardRay = function(a, e, i) {
- return a === void 0 && (a = 100),
- this.getForwardRayToRef(new Ray(Vector3.Zero(),Vector3.Zero(),a), a, e, i)
- }
- ;
- Camera$1.prototype.getForwardRayToRef = function(a, e, i, o) {
- return e === void 0 && (e = 100),
- i || (i = this.getWorldMatrix()),
- a.length = e,
- o ? a.origin.copyFrom(o) : a.origin.copyFrom(this.position),
- TmpVectors.Vector3[2].set(0, 0, this._scene.useRightHandedSystem ? -1 : 1),
- Vector3.TransformNormalToRef(TmpVectors.Vector3[2], i, TmpVectors.Vector3[3]),
- Vector3.NormalizeToRef(TmpVectors.Vector3[3], a.direction),
- a
- }
- ;
- var ColorGradient = function() {
- function a(e, i, o) {
- this.gradient = e,
- this.color1 = i,
- this.color2 = o
- }
- return a.prototype.getColorToRef = function(e) {
- if (!this.color2) {
- e.copyFrom(this.color1);
- return
- }
- Color4.LerpToRef(this.color1, this.color2, Math.random(), e)
- }
- ,
- a
- }(), Color3Gradient = function() {
- function a(e, i) {
- this.gradient = e,
- this.color = i
- }
- return a
- }(), FactorGradient = function() {
- function a(e, i, o) {
- this.gradient = e,
- this.factor1 = i,
- this.factor2 = o
- }
- return a.prototype.getFactor = function() {
- return this.factor2 === void 0 || this.factor2 === this.factor1 ? this.factor1 : this.factor1 + (this.factor2 - this.factor1) * Math.random()
- }
- ,
- a
- }(), GradientHelper = function() {
- function a() {}
- return a.GetCurrentGradient = function(e, i, o) {
- if (i[0].gradient > e) {
- o(i[0], i[0], 1);
- return
- }
- for (var s = 0; s < i.length - 1; s++) {
- var c = i[s]
- , d = i[s + 1];
- if (e >= c.gradient && e <= d.gradient) {
- var _ = (e - c.gradient) / (d.gradient - c.gradient);
- o(c, d, _);
- return
- }
- }
- var b = i.length - 1;
- o(i[b], i[b], 1)
- }
- ,
- a
- }(), BoxParticleEmitter = function() {
- function a() {
- this.direction1 = new Vector3(0,1,0),
- this.direction2 = new Vector3(0,1,0),
- this.minEmitBox = new Vector3(-.5,-.5,-.5),
- this.maxEmitBox = new Vector3(.5,.5,.5)
- }
- return a.prototype.startDirectionFunction = function(e, i, o, s) {
- var c = Scalar.RandomRange(this.direction1.x, this.direction2.x)
- , d = Scalar.RandomRange(this.direction1.y, this.direction2.y)
- , _ = Scalar.RandomRange(this.direction1.z, this.direction2.z);
- if (s) {
- i.x = c,
- i.y = d,
- i.z = _;
- return
- }
- Vector3.TransformNormalFromFloatsToRef(c, d, _, e, i)
- }
- ,
- a.prototype.startPositionFunction = function(e, i, o, s) {
- var c = Scalar.RandomRange(this.minEmitBox.x, this.maxEmitBox.x)
- , d = Scalar.RandomRange(this.minEmitBox.y, this.maxEmitBox.y)
- , _ = Scalar.RandomRange(this.minEmitBox.z, this.maxEmitBox.z);
- if (s) {
- i.x = c,
- i.y = d,
- i.z = _;
- return
- }
- Vector3.TransformCoordinatesFromFloatsToRef(c, d, _, e, i)
- }
- ,
- a.prototype.clone = function() {
- var e = new a;
- return DeepCopier.DeepCopy(this, e),
- e
- }
- ,
- a.prototype.applyToShader = function(e) {
- e.setVector3("direction1", this.direction1),
- e.setVector3("direction2", this.direction2),
- e.setVector3("minEmitBox", this.minEmitBox),
- e.setVector3("maxEmitBox", this.maxEmitBox)
- }
- ,
- a.prototype.buildUniformLayout = function(e) {
- e.addUniform("direction1", 3),
- e.addUniform("direction2", 3),
- e.addUniform("minEmitBox", 3),
- e.addUniform("maxEmitBox", 3)
- }
- ,
- a.prototype.getEffectDefines = function() {
- return "#define BOXEMITTER"
- }
- ,
- a.prototype.getClassName = function() {
- return "BoxParticleEmitter"
- }
- ,
- a.prototype.serialize = function() {
- var e = {};
- return e.type = this.getClassName(),
- e.direction1 = this.direction1.asArray(),
- e.direction2 = this.direction2.asArray(),
- e.minEmitBox = this.minEmitBox.asArray(),
- e.maxEmitBox = this.maxEmitBox.asArray(),
- e
- }
- ,
- a.prototype.parse = function(e) {
- Vector3.FromArrayToRef(e.direction1, 0, this.direction1),
- Vector3.FromArrayToRef(e.direction2, 0, this.direction2),
- Vector3.FromArrayToRef(e.minEmitBox, 0, this.minEmitBox),
- Vector3.FromArrayToRef(e.maxEmitBox, 0, this.maxEmitBox)
- }
- ,
- a
- }(), ConeParticleEmitter = function() {
- function a(e, i, o) {
- e === void 0 && (e = 1),
- i === void 0 && (i = Math.PI),
- o === void 0 && (o = 0),
- this.directionRandomizer = o,
- this.radiusRange = 1,
- this.heightRange = 1,
- this.emitFromSpawnPointOnly = !1,
- this.angle = i,
- this.radius = e
- }
- return Object.defineProperty(a.prototype, "radius", {
- get: function() {
- return this._radius
- },
- set: function(e) {
- this._radius = e,
- this._buildHeight()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "angle", {
- get: function() {
- return this._angle
- },
- set: function(e) {
- this._angle = e,
- this._buildHeight()
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._buildHeight = function() {
- this._angle !== 0 ? this._height = this._radius / Math.tan(this._angle / 2) : this._height = 1
- }
- ,
- a.prototype.startDirectionFunction = function(e, i, o, s) {
- s ? TmpVectors.Vector3[0].copyFrom(o._localPosition).normalize() : o.position.subtractToRef(e.getTranslation(), TmpVectors.Vector3[0]).normalize();
- var c = Scalar.RandomRange(0, this.directionRandomizer)
- , d = Scalar.RandomRange(0, this.directionRandomizer)
- , _ = Scalar.RandomRange(0, this.directionRandomizer);
- i.x = TmpVectors.Vector3[0].x + c,
- i.y = TmpVectors.Vector3[0].y + d,
- i.z = TmpVectors.Vector3[0].z + _,
- i.normalize()
- }
- ,
- a.prototype.startPositionFunction = function(e, i, o, s) {
- var c = Scalar.RandomRange(0, Math.PI * 2), d;
- this.emitFromSpawnPointOnly ? d = 1e-4 : (d = Scalar.RandomRange(0, this.heightRange),
- d = 1 - d * d);
- var _ = this._radius - Scalar.RandomRange(0, this._radius * this.radiusRange);
- _ = _ * d;
- var b = _ * Math.sin(c)
- , k = _ * Math.cos(c)
- , j = d * this._height;
- if (s) {
- i.x = b,
- i.y = j,
- i.z = k;
- return
- }
- Vector3.TransformCoordinatesFromFloatsToRef(b, j, k, e, i)
- }
- ,
- a.prototype.clone = function() {
- var e = new a(this._radius,this._angle,this.directionRandomizer);
- return DeepCopier.DeepCopy(this, e),
- e
- }
- ,
- a.prototype.applyToShader = function(e) {
- e.setFloat2("radius", this._radius, this.radiusRange),
- e.setFloat("coneAngle", this._angle),
- e.setFloat2("height", this._height, this.heightRange),
- e.setFloat("directionRandomizer", this.directionRandomizer)
- }
- ,
- a.prototype.buildUniformLayout = function(e) {
- e.addUniform("radius", 2),
- e.addUniform("coneAngle", 1),
- e.addUniform("height", 2),
- e.addUniform("directionRandomizer", 1)
- }
- ,
- a.prototype.getEffectDefines = function() {
- var e = "#define CONEEMITTER";
- return this.emitFromSpawnPointOnly && (e += `
- #define CONEEMITTERSPAWNPOINT`),
- e
- }
- ,
- a.prototype.getClassName = function() {
- return "ConeParticleEmitter"
- }
- ,
- a.prototype.serialize = function() {
- var e = {};
- return e.type = this.getClassName(),
- e.radius = this._radius,
- e.angle = this._angle,
- e.directionRandomizer = this.directionRandomizer,
- e.radiusRange = this.radiusRange,
- e.heightRange = this.heightRange,
- e.emitFromSpawnPointOnly = this.emitFromSpawnPointOnly,
- e
- }
- ,
- a.prototype.parse = function(e) {
- this.radius = e.radius,
- this.angle = e.angle,
- this.directionRandomizer = e.directionRandomizer,
- this.radiusRange = e.radiusRange !== void 0 ? e.radiusRange : 1,
- this.heightRange = e.radiusRange !== void 0 ? e.heightRange : 1,
- this.emitFromSpawnPointOnly = e.emitFromSpawnPointOnly !== void 0 ? e.emitFromSpawnPointOnly : !1
- }
- ,
- a
- }(), CylinderParticleEmitter = function() {
- function a(e, i, o, s) {
- e === void 0 && (e = 1),
- i === void 0 && (i = 1),
- o === void 0 && (o = 1),
- s === void 0 && (s = 0),
- this.radius = e,
- this.height = i,
- this.radiusRange = o,
- this.directionRandomizer = s,
- this._tempVector = Vector3.Zero()
- }
- return a.prototype.startDirectionFunction = function(e, i, o, s, c) {
- o.position.subtractToRef(e.getTranslation(), this._tempVector),
- this._tempVector.normalize(),
- Vector3.TransformNormalToRef(this._tempVector, c, this._tempVector);
- var d = Scalar.RandomRange(-this.directionRandomizer / 2, this.directionRandomizer / 2)
- , _ = Math.atan2(this._tempVector.x, this._tempVector.z);
- if (_ += Scalar.RandomRange(-Math.PI / 2, Math.PI / 2) * this.directionRandomizer,
- this._tempVector.y = d,
- this._tempVector.x = Math.sin(_),
- this._tempVector.z = Math.cos(_),
- this._tempVector.normalize(),
- s) {
- i.copyFrom(this._tempVector);
- return
- }
- Vector3.TransformNormalFromFloatsToRef(this._tempVector.x, this._tempVector.y, this._tempVector.z, e, i)
- }
- ,
- a.prototype.startPositionFunction = function(e, i, o, s) {
- var c = Scalar.RandomRange(-this.height / 2, this.height / 2)
- , d = Scalar.RandomRange(0, 2 * Math.PI)
- , _ = Scalar.RandomRange((1 - this.radiusRange) * (1 - this.radiusRange), 1)
- , b = Math.sqrt(_) * this.radius
- , k = b * Math.cos(d)
- , j = b * Math.sin(d);
- if (s) {
- i.copyFromFloats(k, c, j);
- return
- }
- Vector3.TransformCoordinatesFromFloatsToRef(k, c, j, e, i)
- }
- ,
- a.prototype.clone = function() {
- var e = new a(this.radius,this.directionRandomizer);
- return DeepCopier.DeepCopy(this, e),
- e
- }
- ,
- a.prototype.applyToShader = function(e) {
- e.setFloat("radius", this.radius),
- e.setFloat("height", this.height),
- e.setFloat("radiusRange", this.radiusRange),
- e.setFloat("directionRandomizer", this.directionRandomizer)
- }
- ,
- a.prototype.buildUniformLayout = function(e) {
- e.addUniform("radius", 1),
- e.addUniform("height", 1),
- e.addUniform("radiusRange", 1),
- e.addUniform("directionRandomizer", 1)
- }
- ,
- a.prototype.getEffectDefines = function() {
- return "#define CYLINDEREMITTER"
- }
- ,
- a.prototype.getClassName = function() {
- return "CylinderParticleEmitter"
- }
- ,
- a.prototype.serialize = function() {
- var e = {};
- return e.type = this.getClassName(),
- e.radius = this.radius,
- e.height = this.height,
- e.radiusRange = this.radiusRange,
- e.directionRandomizer = this.directionRandomizer,
- e
- }
- ,
- a.prototype.parse = function(e) {
- this.radius = e.radius,
- this.height = e.height,
- this.radiusRange = e.radiusRange,
- this.directionRandomizer = e.directionRandomizer
- }
- ,
- a
- }(), CylinderDirectedParticleEmitter = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d) {
- i === void 0 && (i = 1),
- o === void 0 && (o = 1),
- s === void 0 && (s = 1),
- c === void 0 && (c = new Vector3(0,1,0)),
- d === void 0 && (d = new Vector3(0,1,0));
- var _ = a.call(this, i, o, s) || this;
- return _.direction1 = c,
- _.direction2 = d,
- _
- }
- return e.prototype.startDirectionFunction = function(i, o, s) {
- var c = Scalar.RandomRange(this.direction1.x, this.direction2.x)
- , d = Scalar.RandomRange(this.direction1.y, this.direction2.y)
- , _ = Scalar.RandomRange(this.direction1.z, this.direction2.z);
- Vector3.TransformNormalFromFloatsToRef(c, d, _, i, o)
- }
- ,
- e.prototype.clone = function() {
- var i = new e(this.radius,this.height,this.radiusRange,this.direction1,this.direction2);
- return DeepCopier.DeepCopy(this, i),
- i
- }
- ,
- e.prototype.applyToShader = function(i) {
- i.setFloat("radius", this.radius),
- i.setFloat("height", this.height),
- i.setFloat("radiusRange", this.radiusRange),
- i.setVector3("direction1", this.direction1),
- i.setVector3("direction2", this.direction2)
- }
- ,
- e.prototype.buildUniformLayout = function(i) {
- i.addUniform("radius", 1),
- i.addUniform("height", 1),
- i.addUniform("radiusRange", 1),
- i.addUniform("direction1", 3),
- i.addUniform("direction2", 3)
- }
- ,
- e.prototype.getEffectDefines = function() {
- return `#define CYLINDEREMITTER
- #define DIRECTEDCYLINDEREMITTER`
- }
- ,
- e.prototype.getClassName = function() {
- return "CylinderDirectedParticleEmitter"
- }
- ,
- e.prototype.serialize = function() {
- var i = a.prototype.serialize.call(this);
- return i.direction1 = this.direction1.asArray(),
- i.direction2 = this.direction2.asArray(),
- i
- }
- ,
- e.prototype.parse = function(i) {
- a.prototype.parse.call(this, i),
- this.direction1.copyFrom(i.direction1),
- this.direction2.copyFrom(i.direction2)
- }
- ,
- e
- }(CylinderParticleEmitter), HemisphericParticleEmitter = function() {
- function a(e, i, o) {
- e === void 0 && (e = 1),
- i === void 0 && (i = 1),
- o === void 0 && (o = 0),
- this.radius = e,
- this.radiusRange = i,
- this.directionRandomizer = o
- }
- return a.prototype.startDirectionFunction = function(e, i, o, s) {
- var c = o.position.subtract(e.getTranslation()).normalize()
- , d = Scalar.RandomRange(0, this.directionRandomizer)
- , _ = Scalar.RandomRange(0, this.directionRandomizer)
- , b = Scalar.RandomRange(0, this.directionRandomizer);
- if (c.x += d,
- c.y += _,
- c.z += b,
- c.normalize(),
- s) {
- i.copyFrom(c);
- return
- }
- Vector3.TransformNormalFromFloatsToRef(c.x, c.y, c.z, e, i)
- }
- ,
- a.prototype.startPositionFunction = function(e, i, o, s) {
- var c = this.radius - Scalar.RandomRange(0, this.radius * this.radiusRange)
- , d = Scalar.RandomRange(0, 1)
- , _ = Scalar.RandomRange(0, 2 * Math.PI)
- , b = Math.acos(2 * d - 1)
- , k = c * Math.cos(_) * Math.sin(b)
- , j = c * Math.cos(b)
- , $ = c * Math.sin(_) * Math.sin(b);
- if (s) {
- i.copyFromFloats(k, Math.abs(j), $);
- return
- }
- Vector3.TransformCoordinatesFromFloatsToRef(k, Math.abs(j), $, e, i)
- }
- ,
- a.prototype.clone = function() {
- var e = new a(this.radius,this.directionRandomizer);
- return DeepCopier.DeepCopy(this, e),
- e
- }
- ,
- a.prototype.applyToShader = function(e) {
- e.setFloat("radius", this.radius),
- e.setFloat("radiusRange", this.radiusRange),
- e.setFloat("directionRandomizer", this.directionRandomizer)
- }
- ,
- a.prototype.buildUniformLayout = function(e) {
- e.addUniform("radius", 1),
- e.addUniform("radiusRange", 1),
- e.addUniform("directionRandomizer", 1)
- }
- ,
- a.prototype.getEffectDefines = function() {
- return "#define HEMISPHERICEMITTER"
- }
- ,
- a.prototype.getClassName = function() {
- return "HemisphericParticleEmitter"
- }
- ,
- a.prototype.serialize = function() {
- var e = {};
- return e.type = this.getClassName(),
- e.radius = this.radius,
- e.radiusRange = this.radiusRange,
- e.directionRandomizer = this.directionRandomizer,
- e
- }
- ,
- a.prototype.parse = function(e) {
- this.radius = e.radius,
- this.radiusRange = e.radiusRange,
- this.directionRandomizer = e.directionRandomizer
- }
- ,
- a
- }(), PointParticleEmitter = function() {
- function a() {
- this.direction1 = new Vector3(0,1,0),
- this.direction2 = new Vector3(0,1,0)
- }
- return a.prototype.startDirectionFunction = function(e, i, o, s) {
- var c = Scalar.RandomRange(this.direction1.x, this.direction2.x)
- , d = Scalar.RandomRange(this.direction1.y, this.direction2.y)
- , _ = Scalar.RandomRange(this.direction1.z, this.direction2.z);
- if (s) {
- i.copyFromFloats(c, d, _);
- return
- }
- Vector3.TransformNormalFromFloatsToRef(c, d, _, e, i)
- }
- ,
- a.prototype.startPositionFunction = function(e, i, o, s) {
- if (s) {
- i.copyFromFloats(0, 0, 0);
- return
- }
- Vector3.TransformCoordinatesFromFloatsToRef(0, 0, 0, e, i)
- }
- ,
- a.prototype.clone = function() {
- var e = new a;
- return DeepCopier.DeepCopy(this, e),
- e
- }
- ,
- a.prototype.applyToShader = function(e) {
- e.setVector3("direction1", this.direction1),
- e.setVector3("direction2", this.direction2)
- }
- ,
- a.prototype.buildUniformLayout = function(e) {
- e.addUniform("direction1", 3),
- e.addUniform("direction2", 3)
- }
- ,
- a.prototype.getEffectDefines = function() {
- return "#define POINTEMITTER"
- }
- ,
- a.prototype.getClassName = function() {
- return "PointParticleEmitter"
- }
- ,
- a.prototype.serialize = function() {
- var e = {};
- return e.type = this.getClassName(),
- e.direction1 = this.direction1.asArray(),
- e.direction2 = this.direction2.asArray(),
- e
- }
- ,
- a.prototype.parse = function(e) {
- Vector3.FromArrayToRef(e.direction1, 0, this.direction1),
- Vector3.FromArrayToRef(e.direction2, 0, this.direction2)
- }
- ,
- a
- }(), SphereParticleEmitter = function() {
- function a(e, i, o) {
- e === void 0 && (e = 1),
- i === void 0 && (i = 1),
- o === void 0 && (o = 0),
- this.radius = e,
- this.radiusRange = i,
- this.directionRandomizer = o
- }
- return a.prototype.startDirectionFunction = function(e, i, o, s) {
- var c = o.position.subtract(e.getTranslation()).normalize()
- , d = Scalar.RandomRange(0, this.directionRandomizer)
- , _ = Scalar.RandomRange(0, this.directionRandomizer)
- , b = Scalar.RandomRange(0, this.directionRandomizer);
- if (c.x += d,
- c.y += _,
- c.z += b,
- c.normalize(),
- s) {
- i.copyFrom(c);
- return
- }
- Vector3.TransformNormalFromFloatsToRef(c.x, c.y, c.z, e, i)
- }
- ,
- a.prototype.startPositionFunction = function(e, i, o, s) {
- var c = this.radius - Scalar.RandomRange(0, this.radius * this.radiusRange)
- , d = Scalar.RandomRange(0, 1)
- , _ = Scalar.RandomRange(0, 2 * Math.PI)
- , b = Math.acos(2 * d - 1)
- , k = c * Math.cos(_) * Math.sin(b)
- , j = c * Math.cos(b)
- , $ = c * Math.sin(_) * Math.sin(b);
- if (s) {
- i.copyFromFloats(k, j, $);
- return
- }
- Vector3.TransformCoordinatesFromFloatsToRef(k, j, $, e, i)
- }
- ,
- a.prototype.clone = function() {
- var e = new a(this.radius,this.directionRandomizer);
- return DeepCopier.DeepCopy(this, e),
- e
- }
- ,
- a.prototype.applyToShader = function(e) {
- e.setFloat("radius", this.radius),
- e.setFloat("radiusRange", this.radiusRange),
- e.setFloat("directionRandomizer", this.directionRandomizer)
- }
- ,
- a.prototype.buildUniformLayout = function(e) {
- e.addUniform("radius", 1),
- e.addUniform("radiusRange", 1),
- e.addUniform("directionRandomizer", 1)
- }
- ,
- a.prototype.getEffectDefines = function() {
- return "#define SPHEREEMITTER"
- }
- ,
- a.prototype.getClassName = function() {
- return "SphereParticleEmitter"
- }
- ,
- a.prototype.serialize = function() {
- var e = {};
- return e.type = this.getClassName(),
- e.radius = this.radius,
- e.radiusRange = this.radiusRange,
- e.directionRandomizer = this.directionRandomizer,
- e
- }
- ,
- a.prototype.parse = function(e) {
- this.radius = e.radius,
- this.radiusRange = e.radiusRange,
- this.directionRandomizer = e.directionRandomizer
- }
- ,
- a
- }(), SphereDirectedParticleEmitter = function(a) {
- __extends(e, a);
- function e(i, o, s) {
- i === void 0 && (i = 1),
- o === void 0 && (o = new Vector3(0,1,0)),
- s === void 0 && (s = new Vector3(0,1,0));
- var c = a.call(this, i) || this;
- return c.direction1 = o,
- c.direction2 = s,
- c
- }
- return e.prototype.startDirectionFunction = function(i, o, s) {
- var c = Scalar.RandomRange(this.direction1.x, this.direction2.x)
- , d = Scalar.RandomRange(this.direction1.y, this.direction2.y)
- , _ = Scalar.RandomRange(this.direction1.z, this.direction2.z);
- Vector3.TransformNormalFromFloatsToRef(c, d, _, i, o)
- }
- ,
- e.prototype.clone = function() {
- var i = new e(this.radius,this.direction1,this.direction2);
- return DeepCopier.DeepCopy(this, i),
- i
- }
- ,
- e.prototype.applyToShader = function(i) {
- i.setFloat("radius", this.radius),
- i.setFloat("radiusRange", this.radiusRange),
- i.setVector3("direction1", this.direction1),
- i.setVector3("direction2", this.direction2)
- }
- ,
- e.prototype.buildUniformLayout = function(i) {
- i.addUniform("radius", 1),
- i.addUniform("radiusRange", 1),
- i.addUniform("direction1", 3),
- i.addUniform("direction2", 3)
- }
- ,
- e.prototype.getEffectDefines = function() {
- return `#define SPHEREEMITTER
- #define DIRECTEDSPHEREEMITTER`
- }
- ,
- e.prototype.getClassName = function() {
- return "SphereDirectedParticleEmitter"
- }
- ,
- e.prototype.serialize = function() {
- var i = a.prototype.serialize.call(this);
- return i.direction1 = this.direction1.asArray(),
- i.direction2 = this.direction2.asArray(),
- i
- }
- ,
- e.prototype.parse = function(i) {
- a.prototype.parse.call(this, i),
- this.direction1.copyFrom(i.direction1),
- this.direction2.copyFrom(i.direction2)
- }
- ,
- e
- }(SphereParticleEmitter), CustomParticleEmitter = function() {
- function a() {
- this.particlePositionGenerator = function() {}
- ,
- this.particleDestinationGenerator = function() {}
- }
- return a.prototype.startDirectionFunction = function(e, i, o, s) {
- var c = TmpVectors.Vector3[0];
- if (this.particleDestinationGenerator) {
- this.particleDestinationGenerator(-1, o, c);
- var d = TmpVectors.Vector3[1];
- c.subtractToRef(o.position, d),
- d.scaleToRef(1 / o.lifeTime, c)
- } else
- c.set(0, 0, 0);
- if (s) {
- i.copyFrom(c);
- return
- }
- Vector3.TransformNormalToRef(c, e, i)
- }
- ,
- a.prototype.startPositionFunction = function(e, i, o, s) {
- var c = TmpVectors.Vector3[0];
- if (this.particlePositionGenerator ? this.particlePositionGenerator(-1, o, c) : c.set(0, 0, 0),
- s) {
- i.copyFrom(c);
- return
- }
- Vector3.TransformCoordinatesToRef(c, e, i)
- }
- ,
- a.prototype.clone = function() {
- var e = new a;
- return DeepCopier.DeepCopy(this, e),
- e
- }
- ,
- a.prototype.applyToShader = function(e) {}
- ,
- a.prototype.buildUniformLayout = function(e) {}
- ,
- a.prototype.getEffectDefines = function() {
- return "#define CUSTOMEMITTER"
- }
- ,
- a.prototype.getClassName = function() {
- return "CustomParticleEmitter"
- }
- ,
- a.prototype.serialize = function() {
- var e = {};
- return e.type = this.getClassName(),
- e
- }
- ,
- a.prototype.parse = function(e) {}
- ,
- a
- }(), MeshParticleEmitter = function() {
- function a(e) {
- e === void 0 && (e = null),
- this._indices = null,
- this._positions = null,
- this._normals = null,
- this._storedNormal = Vector3.Zero(),
- this._mesh = null,
- this.direction1 = new Vector3(0,1,0),
- this.direction2 = new Vector3(0,1,0),
- this.useMeshNormalsForDirection = !0,
- this.mesh = e
- }
- return Object.defineProperty(a.prototype, "mesh", {
- get: function() {
- return this._mesh
- },
- set: function(e) {
- this._mesh !== e && (this._mesh = e,
- e ? (this._indices = e.getIndices(),
- this._positions = e.getVerticesData(VertexBuffer.PositionKind),
- this._normals = e.getVerticesData(VertexBuffer.NormalKind)) : (this._indices = null,
- this._positions = null,
- this._normals = null))
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.startDirectionFunction = function(e, i, o, s) {
- if (this.useMeshNormalsForDirection && this._normals) {
- Vector3.TransformNormalToRef(this._storedNormal, e, i);
- return
- }
- var c = Scalar.RandomRange(this.direction1.x, this.direction2.x)
- , d = Scalar.RandomRange(this.direction1.y, this.direction2.y)
- , _ = Scalar.RandomRange(this.direction1.z, this.direction2.z);
- if (s) {
- i.copyFromFloats(c, d, _);
- return
- }
- Vector3.TransformNormalFromFloatsToRef(c, d, _, e, i)
- }
- ,
- a.prototype.startPositionFunction = function(e, i, o, s) {
- if (!(!this._indices || !this._positions)) {
- var c = 3 * Math.random() * (this._indices.length / 3) | 0
- , d = Math.random()
- , _ = Math.random() * (1 - d)
- , b = 1 - d - _
- , k = this._indices[c]
- , j = this._indices[c + 1]
- , $ = this._indices[c + 2]
- , _e = TmpVectors.Vector3[0]
- , et = TmpVectors.Vector3[1]
- , tt = TmpVectors.Vector3[2]
- , rt = TmpVectors.Vector3[3];
- Vector3.FromArrayToRef(this._positions, k * 3, _e),
- Vector3.FromArrayToRef(this._positions, j * 3, et),
- Vector3.FromArrayToRef(this._positions, $ * 3, tt),
- rt.x = d * _e.x + _ * et.x + b * tt.x,
- rt.y = d * _e.y + _ * et.y + b * tt.y,
- rt.z = d * _e.z + _ * et.z + b * tt.z,
- s ? i.copyFromFloats(rt.x, rt.y, rt.z) : Vector3.TransformCoordinatesFromFloatsToRef(rt.x, rt.y, rt.z, e, i),
- this.useMeshNormalsForDirection && this._normals && (Vector3.FromArrayToRef(this._normals, k * 3, _e),
- Vector3.FromArrayToRef(this._normals, j * 3, et),
- Vector3.FromArrayToRef(this._normals, $ * 3, tt),
- this._storedNormal.x = d * _e.x + _ * et.x + b * tt.x,
- this._storedNormal.y = d * _e.y + _ * et.y + b * tt.y,
- this._storedNormal.z = d * _e.z + _ * et.z + b * tt.z)
- }
- }
- ,
- a.prototype.clone = function() {
- var e = new a(this.mesh);
- return DeepCopier.DeepCopy(this, e),
- e
- }
- ,
- a.prototype.applyToShader = function(e) {
- e.setVector3("direction1", this.direction1),
- e.setVector3("direction2", this.direction2)
- }
- ,
- a.prototype.buildUniformLayout = function(e) {
- e.addUniform("direction1", 3),
- e.addUniform("direction2", 3)
- }
- ,
- a.prototype.getEffectDefines = function() {
- return ""
- }
- ,
- a.prototype.getClassName = function() {
- return "MeshParticleEmitter"
- }
- ,
- a.prototype.serialize = function() {
- var e, i = {};
- return i.type = this.getClassName(),
- i.direction1 = this.direction1.asArray(),
- i.direction2 = this.direction2.asArray(),
- i.meshId = (e = this.mesh) === null || e === void 0 ? void 0 : e.id,
- i.useMeshNormalsForDirection = this.useMeshNormalsForDirection,
- i
- }
- ,
- a.prototype.parse = function(e, i) {
- Vector3.FromArrayToRef(e.direction1, 0, this.direction1),
- Vector3.FromArrayToRef(e.direction2, 0, this.direction2),
- e.meshId && i && (this.mesh = i.getLastMeshById(e.meshId)),
- this.useMeshNormalsForDirection = e.useMeshNormalsForDirection
- }
- ,
- a
- }(), BaseParticleSystem = function() {
- function a(e) {
- this.animations = [],
- this.renderingGroupId = 0,
- this.emitter = Vector3.Zero(),
- this.emitRate = 10,
- this.manualEmitCount = -1,
- this.updateSpeed = .01,
- this.targetStopDuration = 0,
- this.disposeOnStop = !1,
- this.minEmitPower = 1,
- this.maxEmitPower = 1,
- this.minLifeTime = 1,
- this.maxLifeTime = 1,
- this.minSize = 1,
- this.maxSize = 1,
- this.minScaleX = 1,
- this.maxScaleX = 1,
- this.minScaleY = 1,
- this.maxScaleY = 1,
- this.minInitialRotation = 0,
- this.maxInitialRotation = 0,
- this.minAngularSpeed = 0,
- this.maxAngularSpeed = 0,
- this.layerMask = 268435455,
- this.customShader = null,
- this.preventAutoStart = !1,
- this._rootUrl = "",
- this.noiseStrength = new Vector3(10,10,10),
- this.onAnimationEnd = null,
- this.blendMode = a.BLENDMODE_ONEONE,
- this.forceDepthWrite = !1,
- this.preWarmCycles = 0,
- this.preWarmStepOffset = 1,
- this.spriteCellChangeSpeed = 1,
- this.startSpriteCellID = 0,
- this.endSpriteCellID = 0,
- this.spriteCellWidth = 0,
- this.spriteCellHeight = 0,
- this.spriteCellLoop = !0,
- this.spriteRandomStartCell = !1,
- this.translationPivot = new Vector2(0,0),
- this.beginAnimationOnStart = !1,
- this.beginAnimationFrom = 0,
- this.beginAnimationTo = 60,
- this.beginAnimationLoop = !1,
- this.worldOffset = new Vector3(0,0,0),
- this.gravity = Vector3.Zero(),
- this._colorGradients = null,
- this._sizeGradients = null,
- this._lifeTimeGradients = null,
- this._angularSpeedGradients = null,
- this._velocityGradients = null,
- this._limitVelocityGradients = null,
- this._dragGradients = null,
- this._emitRateGradients = null,
- this._startSizeGradients = null,
- this._rampGradients = null,
- this._colorRemapGradients = null,
- this._alphaRemapGradients = null,
- this.startDelay = 0,
- this.limitVelocityDamping = .4,
- this.color1 = new Color4(1,1,1,1),
- this.color2 = new Color4(1,1,1,1),
- this.colorDead = new Color4(0,0,0,1),
- this.textureMask = new Color4(1,1,1,1),
- this._isSubEmitter = !1,
- this.billboardMode = 7,
- this._isBillboardBased = !0,
- this._imageProcessingConfigurationDefines = new ImageProcessingConfigurationDefines,
- this.id = e,
- this.name = e
- }
- return Object.defineProperty(a.prototype, "noiseTexture", {
- get: function() {
- return this._noiseTexture
- },
- set: function(e) {
- this._noiseTexture !== e && (this._noiseTexture = e,
- this._reset())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "isAnimationSheetEnabled", {
- get: function() {
- return this._isAnimationSheetEnabled
- },
- set: function(e) {
- this._isAnimationSheetEnabled != e && (this._isAnimationSheetEnabled = e,
- this._reset())
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.getScene = function() {
- return this._scene
- }
- ,
- a.prototype._hasTargetStopDurationDependantGradient = function() {
- return this._startSizeGradients && this._startSizeGradients.length > 0 || this._emitRateGradients && this._emitRateGradients.length > 0 || this._lifeTimeGradients && this._lifeTimeGradients.length > 0
- }
- ,
- a.prototype.getDragGradients = function() {
- return this._dragGradients
- }
- ,
- a.prototype.getLimitVelocityGradients = function() {
- return this._limitVelocityGradients
- }
- ,
- a.prototype.getColorGradients = function() {
- return this._colorGradients
- }
- ,
- a.prototype.getSizeGradients = function() {
- return this._sizeGradients
- }
- ,
- a.prototype.getColorRemapGradients = function() {
- return this._colorRemapGradients
- }
- ,
- a.prototype.getAlphaRemapGradients = function() {
- return this._alphaRemapGradients
- }
- ,
- a.prototype.getLifeTimeGradients = function() {
- return this._lifeTimeGradients
- }
- ,
- a.prototype.getAngularSpeedGradients = function() {
- return this._angularSpeedGradients
- }
- ,
- a.prototype.getVelocityGradients = function() {
- return this._velocityGradients
- }
- ,
- a.prototype.getStartSizeGradients = function() {
- return this._startSizeGradients
- }
- ,
- a.prototype.getEmitRateGradients = function() {
- return this._emitRateGradients
- }
- ,
- Object.defineProperty(a.prototype, "direction1", {
- get: function() {
- return this.particleEmitterType.direction1 ? this.particleEmitterType.direction1 : Vector3.Zero()
- },
- set: function(e) {
- this.particleEmitterType.direction1 && (this.particleEmitterType.direction1 = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "direction2", {
- get: function() {
- return this.particleEmitterType.direction2 ? this.particleEmitterType.direction2 : Vector3.Zero()
- },
- set: function(e) {
- this.particleEmitterType.direction2 && (this.particleEmitterType.direction2 = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "minEmitBox", {
- get: function() {
- return this.particleEmitterType.minEmitBox ? this.particleEmitterType.minEmitBox : Vector3.Zero()
- },
- set: function(e) {
- this.particleEmitterType.minEmitBox && (this.particleEmitterType.minEmitBox = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "maxEmitBox", {
- get: function() {
- return this.particleEmitterType.maxEmitBox ? this.particleEmitterType.maxEmitBox : Vector3.Zero()
- },
- set: function(e) {
- this.particleEmitterType.maxEmitBox && (this.particleEmitterType.maxEmitBox = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "isBillboardBased", {
- get: function() {
- return this._isBillboardBased
- },
- set: function(e) {
- this._isBillboardBased !== e && (this._isBillboardBased = e,
- this._reset())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "imageProcessingConfiguration", {
- get: function() {
- return this._imageProcessingConfiguration
- },
- set: function(e) {
- this._attachImageProcessingConfiguration(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._attachImageProcessingConfiguration = function(e) {
- e !== this._imageProcessingConfiguration && (!e && this._scene ? this._imageProcessingConfiguration = this._scene.imageProcessingConfiguration : this._imageProcessingConfiguration = e)
- }
- ,
- a.prototype._reset = function() {}
- ,
- a.prototype._removeGradientAndTexture = function(e, i, o) {
- if (!i)
- return this;
- for (var s = 0, c = 0, d = i; c < d.length; c++) {
- var _ = d[c];
- if (_.gradient === e) {
- i.splice(s, 1);
- break
- }
- s++
- }
- return o && o.dispose(),
- this
- }
- ,
- a.prototype.createPointEmitter = function(e, i) {
- var o = new PointParticleEmitter;
- return o.direction1 = e,
- o.direction2 = i,
- this.particleEmitterType = o,
- o
- }
- ,
- a.prototype.createHemisphericEmitter = function(e, i) {
- e === void 0 && (e = 1),
- i === void 0 && (i = 1);
- var o = new HemisphericParticleEmitter(e,i);
- return this.particleEmitterType = o,
- o
- }
- ,
- a.prototype.createSphereEmitter = function(e, i) {
- e === void 0 && (e = 1),
- i === void 0 && (i = 1);
- var o = new SphereParticleEmitter(e,i);
- return this.particleEmitterType = o,
- o
- }
- ,
- a.prototype.createDirectedSphereEmitter = function(e, i, o) {
- e === void 0 && (e = 1),
- i === void 0 && (i = new Vector3(0,1,0)),
- o === void 0 && (o = new Vector3(0,1,0));
- var s = new SphereDirectedParticleEmitter(e,i,o);
- return this.particleEmitterType = s,
- s
- }
- ,
- a.prototype.createCylinderEmitter = function(e, i, o, s) {
- e === void 0 && (e = 1),
- i === void 0 && (i = 1),
- o === void 0 && (o = 1),
- s === void 0 && (s = 0);
- var c = new CylinderParticleEmitter(e,i,o,s);
- return this.particleEmitterType = c,
- c
- }
- ,
- a.prototype.createDirectedCylinderEmitter = function(e, i, o, s, c) {
- e === void 0 && (e = 1),
- i === void 0 && (i = 1),
- o === void 0 && (o = 1),
- s === void 0 && (s = new Vector3(0,1,0)),
- c === void 0 && (c = new Vector3(0,1,0));
- var d = new CylinderDirectedParticleEmitter(e,i,o,s,c);
- return this.particleEmitterType = d,
- d
- }
- ,
- a.prototype.createConeEmitter = function(e, i) {
- e === void 0 && (e = 1),
- i === void 0 && (i = Math.PI / 4);
- var o = new ConeParticleEmitter(e,i);
- return this.particleEmitterType = o,
- o
- }
- ,
- a.prototype.createBoxEmitter = function(e, i, o, s) {
- var c = new BoxParticleEmitter;
- return this.particleEmitterType = c,
- this.direction1 = e,
- this.direction2 = i,
- this.minEmitBox = o,
- this.maxEmitBox = s,
- c
- }
- ,
- a.BLENDMODE_ONEONE = 0,
- a.BLENDMODE_STANDARD = 1,
- a.BLENDMODE_ADD = 2,
- a.BLENDMODE_MULTIPLY = 3,
- a.BLENDMODE_MULTIPLYADD = 4,
- a
- }(), Particle = function() {
- function a(e) {
- this.particleSystem = e,
- this.position = Vector3.Zero(),
- this.direction = Vector3.Zero(),
- this.color = new Color4(0,0,0,0),
- this.colorStep = new Color4(0,0,0,0),
- this.lifeTime = 1,
- this.age = 0,
- this.size = 0,
- this.scale = new Vector2(1,1),
- this.angle = 0,
- this.angularSpeed = 0,
- this.cellIndex = 0,
- this._attachedSubEmitters = null,
- this._currentColor1 = new Color4(0,0,0,0),
- this._currentColor2 = new Color4(0,0,0,0),
- this._currentSize1 = 0,
- this._currentSize2 = 0,
- this._currentAngularSpeed1 = 0,
- this._currentAngularSpeed2 = 0,
- this._currentVelocity1 = 0,
- this._currentVelocity2 = 0,
- this._currentLimitVelocity1 = 0,
- this._currentLimitVelocity2 = 0,
- this._currentDrag1 = 0,
- this._currentDrag2 = 0,
- this.id = a._Count++,
- this.particleSystem.isAnimationSheetEnabled && this.updateCellInfoFromSystem()
- }
- return a.prototype.updateCellInfoFromSystem = function() {
- this.cellIndex = this.particleSystem.startSpriteCellID
- }
- ,
- a.prototype.updateCellIndex = function() {
- var e = this.age
- , i = this.particleSystem.spriteCellChangeSpeed;
- this.particleSystem.spriteRandomStartCell && (this._randomCellOffset === void 0 && (this._randomCellOffset = Math.random() * this.lifeTime),
- i === 0 ? (i = 1,
- e = this._randomCellOffset) : e += this._randomCellOffset);
- var o = this._initialEndSpriteCellID - this._initialStartSpriteCellID, s;
- this._initialSpriteCellLoop ? s = Scalar.Clamp(e * i % this.lifeTime / this.lifeTime) : s = Scalar.Clamp(e * i / this.lifeTime),
- this.cellIndex = this._initialStartSpriteCellID + s * o | 0
- }
- ,
- a.prototype._inheritParticleInfoToSubEmitter = function(e) {
- if (e.particleSystem.emitter.position) {
- var i = e.particleSystem.emitter;
- if (i.position.copyFrom(this.position),
- e.inheritDirection) {
- var o = TmpVectors.Vector3[0];
- this.direction.normalizeToRef(o),
- i.setDirection(o, 0, Math.PI / 2)
- }
- } else {
- var s = e.particleSystem.emitter;
- s.copyFrom(this.position)
- }
- this.direction.scaleToRef(e.inheritedVelocityAmount / 2, TmpVectors.Vector3[0]),
- e.particleSystem._inheritedVelocityOffset.copyFrom(TmpVectors.Vector3[0])
- }
- ,
- a.prototype._inheritParticleInfoToSubEmitters = function() {
- var e = this;
- this._attachedSubEmitters && this._attachedSubEmitters.length > 0 && this._attachedSubEmitters.forEach(function(i) {
- e._inheritParticleInfoToSubEmitter(i)
- })
- }
- ,
- a.prototype._reset = function() {
- this.age = 0,
- this.id = a._Count++,
- this._currentColorGradient = null,
- this._currentSizeGradient = null,
- this._currentAngularSpeedGradient = null,
- this._currentVelocityGradient = null,
- this._currentLimitVelocityGradient = null,
- this._currentDragGradient = null,
- this.cellIndex = this.particleSystem.startSpriteCellID,
- this._randomCellOffset = void 0
- }
- ,
- a.prototype.copyTo = function(e) {
- e.position.copyFrom(this.position),
- this._initialDirection ? e._initialDirection ? e._initialDirection.copyFrom(this._initialDirection) : e._initialDirection = this._initialDirection.clone() : e._initialDirection = null,
- e.direction.copyFrom(this.direction),
- this._localPosition && (e._localPosition ? e._localPosition.copyFrom(this._localPosition) : e._localPosition = this._localPosition.clone()),
- e.color.copyFrom(this.color),
- e.colorStep.copyFrom(this.colorStep),
- e.lifeTime = this.lifeTime,
- e.age = this.age,
- e._randomCellOffset = this._randomCellOffset,
- e.size = this.size,
- e.scale.copyFrom(this.scale),
- e.angle = this.angle,
- e.angularSpeed = this.angularSpeed,
- e.particleSystem = this.particleSystem,
- e.cellIndex = this.cellIndex,
- e.id = this.id,
- e._attachedSubEmitters = this._attachedSubEmitters,
- this._currentColorGradient && (e._currentColorGradient = this._currentColorGradient,
- e._currentColor1.copyFrom(this._currentColor1),
- e._currentColor2.copyFrom(this._currentColor2)),
- this._currentSizeGradient && (e._currentSizeGradient = this._currentSizeGradient,
- e._currentSize1 = this._currentSize1,
- e._currentSize2 = this._currentSize2),
- this._currentAngularSpeedGradient && (e._currentAngularSpeedGradient = this._currentAngularSpeedGradient,
- e._currentAngularSpeed1 = this._currentAngularSpeed1,
- e._currentAngularSpeed2 = this._currentAngularSpeed2),
- this._currentVelocityGradient && (e._currentVelocityGradient = this._currentVelocityGradient,
- e._currentVelocity1 = this._currentVelocity1,
- e._currentVelocity2 = this._currentVelocity2),
- this._currentLimitVelocityGradient && (e._currentLimitVelocityGradient = this._currentLimitVelocityGradient,
- e._currentLimitVelocity1 = this._currentLimitVelocity1,
- e._currentLimitVelocity2 = this._currentLimitVelocity2),
- this._currentDragGradient && (e._currentDragGradient = this._currentDragGradient,
- e._currentDrag1 = this._currentDrag1,
- e._currentDrag2 = this._currentDrag2),
- this.particleSystem.isAnimationSheetEnabled && (e._initialStartSpriteCellID = this._initialStartSpriteCellID,
- e._initialEndSpriteCellID = this._initialEndSpriteCellID,
- e._initialSpriteCellLoop = this._initialSpriteCellLoop),
- this.particleSystem.useRampGradients && (e.remapData && this.remapData ? e.remapData.copyFrom(this.remapData) : e.remapData = new Vector4(0,0,0,0)),
- this._randomNoiseCoordinates1 && (e._randomNoiseCoordinates1 ? (e._randomNoiseCoordinates1.copyFrom(this._randomNoiseCoordinates1),
- e._randomNoiseCoordinates2.copyFrom(this._randomNoiseCoordinates2)) : (e._randomNoiseCoordinates1 = this._randomNoiseCoordinates1.clone(),
- e._randomNoiseCoordinates2 = this._randomNoiseCoordinates2.clone()))
- }
- ,
- a._Count = 0,
- a
- }(), SubEmitterType;
- (function(a) {
- a[a.ATTACHED = 0] = "ATTACHED",
- a[a.END = 1] = "END"
- }
- )(SubEmitterType || (SubEmitterType = {}));
- var SubEmitter = function() {
- function a(e) {
- if (this.particleSystem = e,
- this.type = SubEmitterType.END,
- this.inheritDirection = !1,
- this.inheritedVelocityAmount = 0,
- !e.emitter || !e.emitter.dispose) {
- var i = GetClass("BABYLON.AbstractMesh");
- e.emitter = new i("SubemitterSystemEmitter",e.getScene()),
- e._disposeEmitterOnDispose = !0
- }
- }
- return a.prototype.clone = function() {
- var e = this.particleSystem.emitter;
- if (!e)
- e = new Vector3;
- else if (e instanceof Vector3)
- e = e.clone();
- else if (e.getClassName().indexOf("Mesh") !== -1) {
- var i = GetClass("BABYLON.Mesh");
- e = new i("",e.getScene()),
- e.isVisible = !1
- }
- var o = new a(this.particleSystem.clone(this.particleSystem.name, e));
- return o.particleSystem.name += "Clone",
- o.type = this.type,
- o.inheritDirection = this.inheritDirection,
- o.inheritedVelocityAmount = this.inheritedVelocityAmount,
- o.particleSystem._disposeEmitterOnDispose = !0,
- o.particleSystem.disposeOnStop = !0,
- o
- }
- ,
- a.prototype.serialize = function(e) {
- e === void 0 && (e = !1);
- var i = {};
- return i.type = this.type,
- i.inheritDirection = this.inheritDirection,
- i.inheritedVelocityAmount = this.inheritedVelocityAmount,
- i.particleSystem = this.particleSystem.serialize(e),
- i
- }
- ,
- a._ParseParticleSystem = function(e, i, o, s) {
- throw _WarnImport("ParseParticle")
- }
- ,
- a.Parse = function(e, i, o) {
- var s = e.particleSystem
- , c = new a(a._ParseParticleSystem(s, i, o, !0));
- return c.type = e.type,
- c.inheritDirection = e.inheritDirection,
- c.inheritedVelocityAmount = e.inheritedVelocityAmount,
- c.particleSystem._isSubEmitter = !0,
- c
- }
- ,
- a.prototype.dispose = function() {
- this.particleSystem.dispose()
- }
- ,
- a
- }()
- , name$1m = "particlesPixelShader"
- , shader$1m = `
- varying vec2 vUV;
- varying vec4 vColor;
- uniform vec4 textureMask;
- uniform sampler2D diffuseSampler;
- #include<clipPlaneFragmentDeclaration>
- #include<imageProcessingDeclaration>
- #include<helperFunctions>
- #include<imageProcessingFunctions>
- #ifdef RAMPGRADIENT
- varying vec4 remapRanges;
- uniform sampler2D rampSampler;
- #endif
- void main(void) {
- #include<clipPlaneFragment>
- vec4 textureColor=texture2D(diffuseSampler,vUV);
- vec4 baseColor=(textureColor*textureMask+(vec4(1.,1.,1.,1.)-textureMask))*vColor;
- #ifdef RAMPGRADIENT
- float alpha=baseColor.a;
- float remappedColorIndex=clamp((alpha-remapRanges.x)/remapRanges.y,0.0,1.0);
- vec4 rampColor=texture2D(rampSampler,vec2(1.0-remappedColorIndex,0.));
- baseColor.rgb*=rampColor.rgb;
- float finalAlpha=baseColor.a;
- baseColor.a=clamp((alpha*rampColor.a-remapRanges.z)/remapRanges.w,0.0,1.0);
- #endif
- #ifdef BLENDMULTIPLYMODE
- float sourceAlpha=vColor.a*textureColor.a;
- baseColor.rgb=baseColor.rgb*sourceAlpha+vec3(1.0)*(1.0-sourceAlpha);
- #endif
- #ifdef IMAGEPROCESSINGPOSTPROCESS
- baseColor.rgb=toLinearSpace(baseColor.rgb);
- #else
- #ifdef IMAGEPROCESSING
- baseColor.rgb=toLinearSpace(baseColor.rgb);
- baseColor=applyImageProcessing(baseColor);
- #endif
- #endif
- gl_FragColor=baseColor;
- }`;
- ShaderStore.ShadersStore[name$1m] = shader$1m;
- var name$1l = "particlesVertexShader"
- , shader$1l = `
- attribute vec3 position;
- attribute vec4 color;
- attribute float angle;
- attribute vec2 size;
- #ifdef ANIMATESHEET
- attribute float cellIndex;
- #endif
- #ifndef BILLBOARD
- attribute vec3 direction;
- #endif
- #ifdef BILLBOARDSTRETCHED
- attribute vec3 direction;
- #endif
- #ifdef RAMPGRADIENT
- attribute vec4 remapData;
- #endif
- attribute vec2 offset;
- uniform mat4 view;
- uniform mat4 projection;
- uniform vec2 translationPivot;
- #ifdef ANIMATESHEET
- uniform vec3 particlesInfos;
- #endif
- varying vec2 vUV;
- varying vec4 vColor;
- varying vec3 vPositionW;
- #ifdef RAMPGRADIENT
- varying vec4 remapRanges;
- #endif
- #if defined(BILLBOARD) && !defined(BILLBOARDY) && !defined(BILLBOARDSTRETCHED)
- uniform mat4 invView;
- #endif
- #include<clipPlaneVertexDeclaration>
- #ifdef BILLBOARD
- uniform vec3 eyePosition;
- #endif
- vec3 rotate(vec3 yaxis,vec3 rotatedCorner) {
- vec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));
- vec3 zaxis=normalize(cross(yaxis,xaxis));
- vec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);
- vec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);
- vec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);
- mat3 rotMatrix=mat3(row0,row1,row2);
- vec3 alignedCorner=rotMatrix*rotatedCorner;
- return position+alignedCorner;
- }
- #ifdef BILLBOARDSTRETCHED
- vec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {
- vec3 normalizedToCamera=normalize(toCamera);
- vec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));
- vec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));
- vec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);
- vec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);
- vec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);
- mat3 rotMatrix=mat3(row0,row1,row2);
- vec3 alignedCorner=rotMatrix*rotatedCorner;
- return position+alignedCorner;
- }
- #endif
- void main(void) {
- vec2 cornerPos;
- cornerPos=(vec2(offset.x-0.5,offset.y-0.5)-translationPivot)*size+translationPivot;
- #ifdef BILLBOARD
- vec3 rotatedCorner;
- #ifdef BILLBOARDY
- rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
- rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
- rotatedCorner.y=0.;
- vec3 yaxis=position-eyePosition;
- yaxis.y=0.;
- vPositionW=rotate(normalize(yaxis),rotatedCorner);
- vec3 viewPos=(view*vec4(vPositionW,1.0)).xyz;
- #elif defined(BILLBOARDSTRETCHED)
- rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
- rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
- rotatedCorner.z=0.;
- vec3 toCamera=position-eyePosition;
- vPositionW=rotateAlign(toCamera,rotatedCorner);
- vec3 viewPos=(view*vec4(vPositionW,1.0)).xyz;
- #else
- rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
- rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
- rotatedCorner.z=0.;
- vec3 viewPos=(view*vec4(position,1.0)).xyz+rotatedCorner;
- vPositionW=(invView*vec4(viewPos,1)).xyz;
- #endif
- #ifdef RAMPGRADIENT
- remapRanges=remapData;
- #endif
- gl_Position=projection*vec4(viewPos,1.0);
- #else
- vec3 rotatedCorner;
- rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
- rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
- rotatedCorner.y=0.;
- vec3 yaxis=normalize(direction);
- vPositionW=rotate(yaxis,rotatedCorner);
- gl_Position=projection*view*vec4(vPositionW,1.0);
- #endif
- vColor=color;
- #ifdef ANIMATESHEET
- float rowOffset=floor(cellIndex*particlesInfos.z);
- float columnOffset=cellIndex-rowOffset/particlesInfos.z;
- vec2 uvScale=particlesInfos.xy;
- vec2 uvOffset=vec2(offset.x ,1.0-offset.y);
- vUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;
- #else
- vUV=offset;
- #endif
- #if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)
- vec4 worldPos=vec4(vPositionW,1.0);
- #endif
- #include<clipPlaneVertex>
- }`;
- ShaderStore.ShadersStore[name$1l] = shader$1l;
- var ParticleSystem = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _) {
- c === void 0 && (c = null),
- d === void 0 && (d = !1),
- _ === void 0 && (_ = .01);
- var b = a.call(this, i) || this;
- b._emitterInverseWorldMatrix = Matrix.Identity(),
- b._inheritedVelocityOffset = new Vector3,
- b.onDisposeObservable = new Observable,
- b.onStoppedObservable = new Observable,
- b._particles = new Array,
- b._stockParticles = new Array,
- b._newPartsExcess = 0,
- b._vertexBuffers = {},
- b._scaledColorStep = new Color4(0,0,0,0),
- b._colorDiff = new Color4(0,0,0,0),
- b._scaledDirection = Vector3.Zero(),
- b._scaledGravity = Vector3.Zero(),
- b._currentRenderId = -1,
- b._useInstancing = !1,
- b._started = !1,
- b._stopped = !1,
- b._actualFrame = 0,
- b._currentEmitRate1 = 0,
- b._currentEmitRate2 = 0,
- b._currentStartSize1 = 0,
- b._currentStartSize2 = 0,
- b._rawTextureWidth = 256,
- b._useRampGradients = !1,
- b._disposeEmitterOnDispose = !1,
- b.isLocal = !1,
- b._onBeforeDrawParticlesObservable = null,
- b.recycleParticle = function(j) {
- var $ = b._particles.pop();
- $ !== j && $.copyTo(j),
- b._stockParticles.push($)
- }
- ,
- b._createParticle = function() {
- var j;
- if (b._stockParticles.length !== 0 ? (j = b._stockParticles.pop(),
- j._reset()) : j = new Particle(b),
- b._subEmitters && b._subEmitters.length > 0) {
- var $ = b._subEmitters[Math.floor(Math.random() * b._subEmitters.length)];
- j._attachedSubEmitters = [],
- $.forEach(function(_e) {
- if (_e.type === SubEmitterType.ATTACHED) {
- var et = _e.clone();
- j._attachedSubEmitters.push(et),
- et.particleSystem.start()
- }
- })
- }
- return j
- }
- ,
- b._emitFromParticle = function(j) {
- if (!(!b._subEmitters || b._subEmitters.length === 0)) {
- var $ = Math.floor(Math.random() * b._subEmitters.length);
- b._subEmitters[$].forEach(function(_e) {
- if (_e.type === SubEmitterType.END) {
- var et = _e.clone();
- j._inheritParticleInfoToSubEmitter(et),
- et.particleSystem._rootParticleSystem = b,
- b.activeSubSystems.push(et.particleSystem),
- et.particleSystem.start()
- }
- })
- }
- }
- ,
- b._capacity = o,
- b._epsilon = _,
- b._isAnimationSheetEnabled = d,
- !s || s.getClassName() === "Scene" ? (b._scene = s || EngineStore.LastCreatedScene,
- b._engine = b._scene.getEngine(),
- b.uniqueId = b._scene.getUniqueId(),
- b._scene.particleSystems.push(b)) : (b._engine = s,
- b.defaultProjectionMatrix = Matrix.PerspectiveFovLH(.8, 1, .1, 100, b._engine.isNDCHalfZRange)),
- b._engine.getCaps().vertexArrayObject && (b._vertexArrayObject = null),
- b._attachImageProcessingConfiguration(null),
- b._customWrappers = {
- 0: new DrawWrapper(b._engine)
- },
- b._customWrappers[0].effect = c,
- b._drawWrappers = [],
- b._useInstancing = b._engine.getCaps().instancedArrays,
- b._createIndexBuffer(),
- b._createVertexBuffers(),
- b.particleEmitterType = new BoxParticleEmitter;
- var k = null;
- return b.updateFunction = function(j) {
- var $, _e = null;
- b.noiseTexture && (_e = b.noiseTexture.getSize(),
- ($ = b.noiseTexture.getContent()) === null || $ === void 0 || $.then(function(it) {
- k = it
- }));
- for (var et = function() {
- tt = j[rt];
- var it = b._scaledUpdateSpeed
- , nt = tt.age;
- if (tt.age += it,
- tt.age > tt.lifeTime) {
- var ot = tt.age - nt
- , at = tt.lifeTime - nt;
- it = at * it / ot,
- tt.age = tt.lifeTime
- }
- var st = tt.age / tt.lifeTime;
- b._colorGradients && b._colorGradients.length > 0 ? GradientHelper.GetCurrentGradient(st, b._colorGradients, function(dt, _t, mt) {
- dt !== tt._currentColorGradient && (tt._currentColor1.copyFrom(tt._currentColor2),
- _t.getColorToRef(tt._currentColor2),
- tt._currentColorGradient = dt),
- Color4.LerpToRef(tt._currentColor1, tt._currentColor2, mt, tt.color)
- }) : (tt.colorStep.scaleToRef(it, b._scaledColorStep),
- tt.color.addInPlace(b._scaledColorStep),
- tt.color.a < 0 && (tt.color.a = 0)),
- b._angularSpeedGradients && b._angularSpeedGradients.length > 0 && GradientHelper.GetCurrentGradient(st, b._angularSpeedGradients, function(dt, _t, mt) {
- dt !== tt._currentAngularSpeedGradient && (tt._currentAngularSpeed1 = tt._currentAngularSpeed2,
- tt._currentAngularSpeed2 = _t.getFactor(),
- tt._currentAngularSpeedGradient = dt),
- tt.angularSpeed = Scalar.Lerp(tt._currentAngularSpeed1, tt._currentAngularSpeed2, mt)
- }),
- tt.angle += tt.angularSpeed * it;
- var ut = it;
- if (b._velocityGradients && b._velocityGradients.length > 0 && GradientHelper.GetCurrentGradient(st, b._velocityGradients, function(dt, _t, mt) {
- dt !== tt._currentVelocityGradient && (tt._currentVelocity1 = tt._currentVelocity2,
- tt._currentVelocity2 = _t.getFactor(),
- tt._currentVelocityGradient = dt),
- ut *= Scalar.Lerp(tt._currentVelocity1, tt._currentVelocity2, mt)
- }),
- tt.direction.scaleToRef(ut, b._scaledDirection),
- b._limitVelocityGradients && b._limitVelocityGradients.length > 0 && GradientHelper.GetCurrentGradient(st, b._limitVelocityGradients, function(dt, _t, mt) {
- dt !== tt._currentLimitVelocityGradient && (tt._currentLimitVelocity1 = tt._currentLimitVelocity2,
- tt._currentLimitVelocity2 = _t.getFactor(),
- tt._currentLimitVelocityGradient = dt);
- var vt = Scalar.Lerp(tt._currentLimitVelocity1, tt._currentLimitVelocity2, mt)
- , yt = tt.direction.length();
- yt > vt && tt.direction.scaleInPlace(b.limitVelocityDamping)
- }),
- b._dragGradients && b._dragGradients.length > 0 && GradientHelper.GetCurrentGradient(st, b._dragGradients, function(dt, _t, mt) {
- dt !== tt._currentDragGradient && (tt._currentDrag1 = tt._currentDrag2,
- tt._currentDrag2 = _t.getFactor(),
- tt._currentDragGradient = dt);
- var vt = Scalar.Lerp(tt._currentDrag1, tt._currentDrag2, mt);
- b._scaledDirection.scaleInPlace(1 - vt)
- }),
- b.isLocal && tt._localPosition ? (tt._localPosition.addInPlace(b._scaledDirection),
- Vector3.TransformCoordinatesToRef(tt._localPosition, b._emitterWorldMatrix, tt.position)) : tt.position.addInPlace(b._scaledDirection),
- k && _e && tt._randomNoiseCoordinates1) {
- var ct = b._fetchR(tt._randomNoiseCoordinates1.x, tt._randomNoiseCoordinates1.y, _e.width, _e.height, k)
- , lt = b._fetchR(tt._randomNoiseCoordinates1.z, tt._randomNoiseCoordinates2.x, _e.width, _e.height, k)
- , ft = b._fetchR(tt._randomNoiseCoordinates2.y, tt._randomNoiseCoordinates2.z, _e.width, _e.height, k)
- , ht = TmpVectors.Vector3[0]
- , pt = TmpVectors.Vector3[1];
- ht.copyFromFloats((2 * ct - 1) * b.noiseStrength.x, (2 * lt - 1) * b.noiseStrength.y, (2 * ft - 1) * b.noiseStrength.z),
- ht.scaleToRef(it, pt),
- tt.direction.addInPlace(pt)
- }
- if (b.gravity.scaleToRef(it, b._scaledGravity),
- tt.direction.addInPlace(b._scaledGravity),
- b._sizeGradients && b._sizeGradients.length > 0 && GradientHelper.GetCurrentGradient(st, b._sizeGradients, function(dt, _t, mt) {
- dt !== tt._currentSizeGradient && (tt._currentSize1 = tt._currentSize2,
- tt._currentSize2 = _t.getFactor(),
- tt._currentSizeGradient = dt),
- tt.size = Scalar.Lerp(tt._currentSize1, tt._currentSize2, mt)
- }),
- b._useRampGradients && (b._colorRemapGradients && b._colorRemapGradients.length > 0 && GradientHelper.GetCurrentGradient(st, b._colorRemapGradients, function(dt, _t, mt) {
- var vt = Scalar.Lerp(dt.factor1, _t.factor1, mt)
- , yt = Scalar.Lerp(dt.factor2, _t.factor2, mt);
- tt.remapData.x = vt,
- tt.remapData.y = yt - vt
- }),
- b._alphaRemapGradients && b._alphaRemapGradients.length > 0 && GradientHelper.GetCurrentGradient(st, b._alphaRemapGradients, function(dt, _t, mt) {
- var vt = Scalar.Lerp(dt.factor1, _t.factor1, mt)
- , yt = Scalar.Lerp(dt.factor2, _t.factor2, mt);
- tt.remapData.z = vt,
- tt.remapData.w = yt - vt
- })),
- b._isAnimationSheetEnabled && tt.updateCellIndex(),
- tt._inheritParticleInfoToSubEmitters(),
- tt.age >= tt.lifeTime)
- return b._emitFromParticle(tt),
- tt._attachedSubEmitters && (tt._attachedSubEmitters.forEach(function(dt) {
- dt.particleSystem.disposeOnStop = !0,
- dt.particleSystem.stop()
- }),
- tt._attachedSubEmitters = null),
- b.recycleParticle(tt),
- rt--,
- "continue"
- }, tt, rt = 0; rt < j.length; rt++)
- et()
- }
- ,
- b
- }
- return Object.defineProperty(e.prototype, "onDispose", {
- set: function(i) {
- this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver),
- this._onDisposeObserver = this.onDisposeObservable.add(i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "useRampGradients", {
- get: function() {
- return this._useRampGradients
- },
- set: function(i) {
- this._useRampGradients !== i && (this._useRampGradients = i,
- this._resetEffect())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "particles", {
- get: function() {
- return this._particles
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getActiveCount = function() {
- return this._particles.length
- }
- ,
- e.prototype.getClassName = function() {
- return "ParticleSystem"
- }
- ,
- e.prototype.isStopping = function() {
- return this._stopped && this.isAlive()
- }
- ,
- e.prototype.getCustomEffect = function(i) {
- var o, s;
- return i === void 0 && (i = 0),
- (s = (o = this._customWrappers[i]) === null || o === void 0 ? void 0 : o.effect) !== null && s !== void 0 ? s : this._customWrappers[0].effect
- }
- ,
- e.prototype._getCustomDrawWrapper = function(i) {
- var o;
- return i === void 0 && (i = 0),
- (o = this._customWrappers[i]) !== null && o !== void 0 ? o : this._customWrappers[0]
- }
- ,
- e.prototype.setCustomEffect = function(i, o) {
- o === void 0 && (o = 0),
- this._customWrappers[o] = new DrawWrapper(this._engine),
- this._customWrappers[o].effect = i,
- this._customWrappers[o].drawContext && (this._customWrappers[o].drawContext.useInstancing = this._useInstancing)
- }
- ,
- Object.defineProperty(e.prototype, "onBeforeDrawParticlesObservable", {
- get: function() {
- return this._onBeforeDrawParticlesObservable || (this._onBeforeDrawParticlesObservable = new Observable),
- this._onBeforeDrawParticlesObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "vertexShaderName", {
- get: function() {
- return "particles"
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._addFactorGradient = function(i, o, s, c) {
- var d = new FactorGradient(o,s,c);
- i.push(d),
- i.sort(function(_, b) {
- return _.gradient < b.gradient ? -1 : _.gradient > b.gradient ? 1 : 0
- })
- }
- ,
- e.prototype._removeFactorGradient = function(i, o) {
- if (!!i)
- for (var s = 0, c = 0, d = i; c < d.length; c++) {
- var _ = d[c];
- if (_.gradient === o) {
- i.splice(s, 1);
- break
- }
- s++
- }
- }
- ,
- e.prototype.addLifeTimeGradient = function(i, o, s) {
- return this._lifeTimeGradients || (this._lifeTimeGradients = []),
- this._addFactorGradient(this._lifeTimeGradients, i, o, s),
- this
- }
- ,
- e.prototype.removeLifeTimeGradient = function(i) {
- return this._removeFactorGradient(this._lifeTimeGradients, i),
- this
- }
- ,
- e.prototype.addSizeGradient = function(i, o, s) {
- return this._sizeGradients || (this._sizeGradients = []),
- this._addFactorGradient(this._sizeGradients, i, o, s),
- this
- }
- ,
- e.prototype.removeSizeGradient = function(i) {
- return this._removeFactorGradient(this._sizeGradients, i),
- this
- }
- ,
- e.prototype.addColorRemapGradient = function(i, o, s) {
- return this._colorRemapGradients || (this._colorRemapGradients = []),
- this._addFactorGradient(this._colorRemapGradients, i, o, s),
- this
- }
- ,
- e.prototype.removeColorRemapGradient = function(i) {
- return this._removeFactorGradient(this._colorRemapGradients, i),
- this
- }
- ,
- e.prototype.addAlphaRemapGradient = function(i, o, s) {
- return this._alphaRemapGradients || (this._alphaRemapGradients = []),
- this._addFactorGradient(this._alphaRemapGradients, i, o, s),
- this
- }
- ,
- e.prototype.removeAlphaRemapGradient = function(i) {
- return this._removeFactorGradient(this._alphaRemapGradients, i),
- this
- }
- ,
- e.prototype.addAngularSpeedGradient = function(i, o, s) {
- return this._angularSpeedGradients || (this._angularSpeedGradients = []),
- this._addFactorGradient(this._angularSpeedGradients, i, o, s),
- this
- }
- ,
- e.prototype.removeAngularSpeedGradient = function(i) {
- return this._removeFactorGradient(this._angularSpeedGradients, i),
- this
- }
- ,
- e.prototype.addVelocityGradient = function(i, o, s) {
- return this._velocityGradients || (this._velocityGradients = []),
- this._addFactorGradient(this._velocityGradients, i, o, s),
- this
- }
- ,
- e.prototype.removeVelocityGradient = function(i) {
- return this._removeFactorGradient(this._velocityGradients, i),
- this
- }
- ,
- e.prototype.addLimitVelocityGradient = function(i, o, s) {
- return this._limitVelocityGradients || (this._limitVelocityGradients = []),
- this._addFactorGradient(this._limitVelocityGradients, i, o, s),
- this
- }
- ,
- e.prototype.removeLimitVelocityGradient = function(i) {
- return this._removeFactorGradient(this._limitVelocityGradients, i),
- this
- }
- ,
- e.prototype.addDragGradient = function(i, o, s) {
- return this._dragGradients || (this._dragGradients = []),
- this._addFactorGradient(this._dragGradients, i, o, s),
- this
- }
- ,
- e.prototype.removeDragGradient = function(i) {
- return this._removeFactorGradient(this._dragGradients, i),
- this
- }
- ,
- e.prototype.addEmitRateGradient = function(i, o, s) {
- return this._emitRateGradients || (this._emitRateGradients = []),
- this._addFactorGradient(this._emitRateGradients, i, o, s),
- this
- }
- ,
- e.prototype.removeEmitRateGradient = function(i) {
- return this._removeFactorGradient(this._emitRateGradients, i),
- this
- }
- ,
- e.prototype.addStartSizeGradient = function(i, o, s) {
- return this._startSizeGradients || (this._startSizeGradients = []),
- this._addFactorGradient(this._startSizeGradients, i, o, s),
- this
- }
- ,
- e.prototype.removeStartSizeGradient = function(i) {
- return this._removeFactorGradient(this._startSizeGradients, i),
- this
- }
- ,
- e.prototype._createRampGradientTexture = function() {
- if (!(!this._rampGradients || !this._rampGradients.length || this._rampGradientsTexture || !this._scene)) {
- for (var i = new Uint8Array(this._rawTextureWidth * 4), o = TmpColors.Color3[0], s = 0; s < this._rawTextureWidth; s++) {
- var c = s / this._rawTextureWidth;
- GradientHelper.GetCurrentGradient(c, this._rampGradients, function(d, _, b) {
- Color3.LerpToRef(d.color, _.color, b, o),
- i[s * 4] = o.r * 255,
- i[s * 4 + 1] = o.g * 255,
- i[s * 4 + 2] = o.b * 255,
- i[s * 4 + 3] = 255
- })
- }
- this._rampGradientsTexture = RawTexture.CreateRGBATexture(i, this._rawTextureWidth, 1, this._scene, !1, !1, 1)
- }
- }
- ,
- e.prototype.getRampGradients = function() {
- return this._rampGradients
- }
- ,
- e.prototype.forceRefreshGradients = function() {
- this._syncRampGradientTexture()
- }
- ,
- e.prototype._syncRampGradientTexture = function() {
- !this._rampGradients || (this._rampGradients.sort(function(i, o) {
- return i.gradient < o.gradient ? -1 : i.gradient > o.gradient ? 1 : 0
- }),
- this._rampGradientsTexture && (this._rampGradientsTexture.dispose(),
- this._rampGradientsTexture = null),
- this._createRampGradientTexture())
- }
- ,
- e.prototype.addRampGradient = function(i, o) {
- this._rampGradients || (this._rampGradients = []);
- var s = new Color3Gradient(i,o);
- return this._rampGradients.push(s),
- this._syncRampGradientTexture(),
- this
- }
- ,
- e.prototype.removeRampGradient = function(i) {
- return this._removeGradientAndTexture(i, this._rampGradients, this._rampGradientsTexture),
- this._rampGradientsTexture = null,
- this._rampGradients && this._rampGradients.length > 0 && this._createRampGradientTexture(),
- this
- }
- ,
- e.prototype.addColorGradient = function(i, o, s) {
- this._colorGradients || (this._colorGradients = []);
- var c = new ColorGradient(i,o,s);
- return this._colorGradients.push(c),
- this._colorGradients.sort(function(d, _) {
- return d.gradient < _.gradient ? -1 : d.gradient > _.gradient ? 1 : 0
- }),
- this
- }
- ,
- e.prototype.removeColorGradient = function(i) {
- if (!this._colorGradients)
- return this;
- for (var o = 0, s = 0, c = this._colorGradients; s < c.length; s++) {
- var d = c[s];
- if (d.gradient === i) {
- this._colorGradients.splice(o, 1);
- break
- }
- o++
- }
- return this
- }
- ,
- e.prototype.resetDrawCache = function() {
- for (var i = 0, o = this._drawWrappers; i < o.length; i++) {
- var s = o[i];
- if (s)
- for (var c = 0, d = s; c < d.length; c++) {
- var _ = d[c];
- _ == null || _.dispose()
- }
- }
- this._drawWrappers = []
- }
- ,
- e.prototype._fetchR = function(i, o, s, c, d) {
- i = Math.abs(i) * .5 + .5,
- o = Math.abs(o) * .5 + .5;
- var _ = i * s % s | 0
- , b = o * c % c | 0
- , k = (_ + b * s) * 4;
- return d[k] / 255
- }
- ,
- e.prototype._reset = function() {
- this._resetEffect()
- }
- ,
- e.prototype._resetEffect = function() {
- this._vertexBuffer && (this._vertexBuffer.dispose(),
- this._vertexBuffer = null),
- this._spriteBuffer && (this._spriteBuffer.dispose(),
- this._spriteBuffer = null),
- this._vertexArrayObject && (this._engine.releaseVertexArrayObject(this._vertexArrayObject),
- this._vertexArrayObject = null),
- this._createVertexBuffers()
- }
- ,
- e.prototype._createVertexBuffers = function() {
- this._vertexBufferSize = this._useInstancing ? 10 : 12,
- this._isAnimationSheetEnabled && (this._vertexBufferSize += 1),
- (!this._isBillboardBased || this.billboardMode === e.BILLBOARDMODE_STRETCHED) && (this._vertexBufferSize += 3),
- this._useRampGradients && (this._vertexBufferSize += 4);
- var i = this._engine;
- this._vertexData = new Float32Array(this._capacity * this._vertexBufferSize * (this._useInstancing ? 1 : 4)),
- this._vertexBuffer = new Buffer(i,this._vertexData,!0,this._vertexBufferSize);
- var o = 0
- , s = this._vertexBuffer.createVertexBuffer(VertexBuffer.PositionKind, o, 3, this._vertexBufferSize, this._useInstancing);
- this._vertexBuffers[VertexBuffer.PositionKind] = s,
- o += 3;
- var c = this._vertexBuffer.createVertexBuffer(VertexBuffer.ColorKind, o, 4, this._vertexBufferSize, this._useInstancing);
- this._vertexBuffers[VertexBuffer.ColorKind] = c,
- o += 4;
- var d = this._vertexBuffer.createVertexBuffer("angle", o, 1, this._vertexBufferSize, this._useInstancing);
- this._vertexBuffers.angle = d,
- o += 1;
- var _ = this._vertexBuffer.createVertexBuffer("size", o, 2, this._vertexBufferSize, this._useInstancing);
- if (this._vertexBuffers.size = _,
- o += 2,
- this._isAnimationSheetEnabled) {
- var b = this._vertexBuffer.createVertexBuffer("cellIndex", o, 1, this._vertexBufferSize, this._useInstancing);
- this._vertexBuffers.cellIndex = b,
- o += 1
- }
- if (!this._isBillboardBased || this.billboardMode === e.BILLBOARDMODE_STRETCHED) {
- var k = this._vertexBuffer.createVertexBuffer("direction", o, 3, this._vertexBufferSize, this._useInstancing);
- this._vertexBuffers.direction = k,
- o += 3
- }
- if (this._useRampGradients) {
- var j = this._vertexBuffer.createVertexBuffer("remapData", o, 4, this._vertexBufferSize, this._useInstancing);
- this._vertexBuffers.remapData = j,
- o += 4
- }
- var $;
- if (this._useInstancing) {
- var _e = new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]);
- this._spriteBuffer = new Buffer(i,_e,!1,2),
- $ = this._spriteBuffer.createVertexBuffer("offset", 0, 2)
- } else
- $ = this._vertexBuffer.createVertexBuffer("offset", o, 2, this._vertexBufferSize, this._useInstancing),
- o += 2;
- this._vertexBuffers.offset = $,
- this.resetDrawCache()
- }
- ,
- e.prototype._createIndexBuffer = function() {
- if (!this._useInstancing) {
- for (var i = [], o = 0, s = 0; s < this._capacity; s++)
- i.push(o),
- i.push(o + 1),
- i.push(o + 2),
- i.push(o),
- i.push(o + 2),
- i.push(o + 3),
- o += 4;
- this._indexBuffer = this._engine.createIndexBuffer(i)
- }
- }
- ,
- e.prototype.getCapacity = function() {
- return this._capacity
- }
- ,
- e.prototype.isAlive = function() {
- return this._alive
- }
- ,
- e.prototype.isStarted = function() {
- return this._started
- }
- ,
- e.prototype._prepareSubEmitterInternalArray = function() {
- var i = this;
- this._subEmitters = new Array,
- this.subEmitters && this.subEmitters.forEach(function(o) {
- o instanceof e ? i._subEmitters.push([new SubEmitter(o)]) : o instanceof SubEmitter ? i._subEmitters.push([o]) : o instanceof Array && i._subEmitters.push(o)
- })
- }
- ,
- e.prototype.start = function(i) {
- var o = this, s;
- if (i === void 0 && (i = this.startDelay),
- !this.targetStopDuration && this._hasTargetStopDurationDependantGradient())
- throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
- if (i) {
- setTimeout(function() {
- o.start(0)
- }, i);
- return
- }
- if (this._prepareSubEmitterInternalArray(),
- this._started = !0,
- this._stopped = !1,
- this._actualFrame = 0,
- this._subEmitters && this._subEmitters.length != 0 && (this.activeSubSystems = new Array),
- this._emitRateGradients && (this._emitRateGradients.length > 0 && (this._currentEmitRateGradient = this._emitRateGradients[0],
- this._currentEmitRate1 = this._currentEmitRateGradient.getFactor(),
- this._currentEmitRate2 = this._currentEmitRate1),
- this._emitRateGradients.length > 1 && (this._currentEmitRate2 = this._emitRateGradients[1].getFactor())),
- this._startSizeGradients && (this._startSizeGradients.length > 0 && (this._currentStartSizeGradient = this._startSizeGradients[0],
- this._currentStartSize1 = this._currentStartSizeGradient.getFactor(),
- this._currentStartSize2 = this._currentStartSize1),
- this._startSizeGradients.length > 1 && (this._currentStartSize2 = this._startSizeGradients[1].getFactor())),
- this.preWarmCycles) {
- ((s = this.emitter) === null || s === void 0 ? void 0 : s.getClassName().indexOf("Mesh")) !== -1 && this.emitter.computeWorldMatrix(!0);
- var c = this.noiseTexture;
- if (c && c.onGeneratedObservable)
- c.onGeneratedObservable.addOnce(function() {
- setTimeout(function() {
- for (var _ = 0; _ < o.preWarmCycles; _++)
- o.animate(!0),
- c.render()
- })
- });
- else
- for (var d = 0; d < this.preWarmCycles; d++)
- this.animate(!0)
- }
- this.beginAnimationOnStart && this.animations && this.animations.length > 0 && this._scene && this._scene.beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop)
- }
- ,
- e.prototype.stop = function(i) {
- i === void 0 && (i = !0),
- !this._stopped && (this.onStoppedObservable.notifyObservers(this),
- this._stopped = !0,
- i && this._stopSubEmitters())
- }
- ,
- e.prototype.reset = function() {
- this._stockParticles = [],
- this._particles = []
- }
- ,
- e.prototype._appendParticleVertex = function(i, o, s, c) {
- var d = i * this._vertexBufferSize;
- if (this._vertexData[d++] = o.position.x + this.worldOffset.x,
- this._vertexData[d++] = o.position.y + this.worldOffset.y,
- this._vertexData[d++] = o.position.z + this.worldOffset.z,
- this._vertexData[d++] = o.color.r,
- this._vertexData[d++] = o.color.g,
- this._vertexData[d++] = o.color.b,
- this._vertexData[d++] = o.color.a,
- this._vertexData[d++] = o.angle,
- this._vertexData[d++] = o.scale.x * o.size,
- this._vertexData[d++] = o.scale.y * o.size,
- this._isAnimationSheetEnabled && (this._vertexData[d++] = o.cellIndex),
- this._isBillboardBased)
- this.billboardMode === e.BILLBOARDMODE_STRETCHED && (this._vertexData[d++] = o.direction.x,
- this._vertexData[d++] = o.direction.y,
- this._vertexData[d++] = o.direction.z);
- else if (o._initialDirection) {
- var _ = o._initialDirection;
- this.isLocal && (Vector3.TransformNormalToRef(_, this._emitterWorldMatrix, TmpVectors.Vector3[0]),
- _ = TmpVectors.Vector3[0]),
- _.x === 0 && _.z === 0 && (_.x = .001),
- this._vertexData[d++] = _.x,
- this._vertexData[d++] = _.y,
- this._vertexData[d++] = _.z
- } else {
- var b = o.direction;
- this.isLocal && (Vector3.TransformNormalToRef(b, this._emitterWorldMatrix, TmpVectors.Vector3[0]),
- b = TmpVectors.Vector3[0]),
- b.x === 0 && b.z === 0 && (b.x = .001),
- this._vertexData[d++] = b.x,
- this._vertexData[d++] = b.y,
- this._vertexData[d++] = b.z
- }
- this._useRampGradients && o.remapData && (this._vertexData[d++] = o.remapData.x,
- this._vertexData[d++] = o.remapData.y,
- this._vertexData[d++] = o.remapData.z,
- this._vertexData[d++] = o.remapData.w),
- this._useInstancing || (this._isAnimationSheetEnabled && (s === 0 ? s = this._epsilon : s === 1 && (s = 1 - this._epsilon),
- c === 0 ? c = this._epsilon : c === 1 && (c = 1 - this._epsilon)),
- this._vertexData[d++] = s,
- this._vertexData[d++] = c)
- }
- ,
- e.prototype._stopSubEmitters = function() {
- !this.activeSubSystems || (this.activeSubSystems.forEach(function(i) {
- i.stop(!0)
- }),
- this.activeSubSystems = new Array)
- }
- ,
- e.prototype._removeFromRoot = function() {
- if (!!this._rootParticleSystem) {
- var i = this._rootParticleSystem.activeSubSystems.indexOf(this);
- i !== -1 && this._rootParticleSystem.activeSubSystems.splice(i, 1),
- this._rootParticleSystem = null
- }
- }
- ,
- e.prototype._update = function(i) {
- var o = this;
- if (this._alive = this._particles.length > 0,
- this.emitter.position) {
- var s = this.emitter;
- this._emitterWorldMatrix = s.getWorldMatrix()
- } else {
- var c = this.emitter;
- this._emitterWorldMatrix = Matrix.Translation(c.x, c.y, c.z)
- }
- this._emitterWorldMatrix.invertToRef(this._emitterInverseWorldMatrix),
- this.updateFunction(this._particles);
- for (var d, _ = function() {
- if (b._particles.length === b._capacity)
- return "break";
- if (d = b._createParticle(),
- b._particles.push(d),
- b.targetStopDuration && b._lifeTimeGradients && b._lifeTimeGradients.length > 0) {
- var _e = Scalar.Clamp(b._actualFrame / b.targetStopDuration);
- GradientHelper.GetCurrentGradient(_e, b._lifeTimeGradients, function(rt, it) {
- var nt = rt
- , ot = it
- , at = nt.getFactor()
- , st = ot.getFactor()
- , ut = (_e - nt.gradient) / (ot.gradient - nt.gradient);
- d.lifeTime = Scalar.Lerp(at, st, ut)
- })
- } else
- d.lifeTime = Scalar.RandomRange(b.minLifeTime, b.maxLifeTime);
- var et = Scalar.RandomRange(b.minEmitPower, b.maxEmitPower);
- if (b.startPositionFunction ? b.startPositionFunction(b._emitterWorldMatrix, d.position, d, b.isLocal) : b.particleEmitterType.startPositionFunction(b._emitterWorldMatrix, d.position, d, b.isLocal),
- b.isLocal && (d._localPosition ? d._localPosition.copyFrom(d.position) : d._localPosition = d.position.clone(),
- Vector3.TransformCoordinatesToRef(d._localPosition, b._emitterWorldMatrix, d.position)),
- b.startDirectionFunction ? b.startDirectionFunction(b._emitterWorldMatrix, d.direction, d, b.isLocal) : b.particleEmitterType.startDirectionFunction(b._emitterWorldMatrix, d.direction, d, b.isLocal, b._emitterInverseWorldMatrix),
- et === 0 ? d._initialDirection ? d._initialDirection.copyFrom(d.direction) : d._initialDirection = d.direction.clone() : d._initialDirection = null,
- d.direction.scaleInPlace(et),
- !b._sizeGradients || b._sizeGradients.length === 0 ? d.size = Scalar.RandomRange(b.minSize, b.maxSize) : (d._currentSizeGradient = b._sizeGradients[0],
- d._currentSize1 = d._currentSizeGradient.getFactor(),
- d.size = d._currentSize1,
- b._sizeGradients.length > 1 ? d._currentSize2 = b._sizeGradients[1].getFactor() : d._currentSize2 = d._currentSize1),
- d.scale.copyFromFloats(Scalar.RandomRange(b.minScaleX, b.maxScaleX), Scalar.RandomRange(b.minScaleY, b.maxScaleY)),
- b._startSizeGradients && b._startSizeGradients[0] && b.targetStopDuration) {
- var tt = b._actualFrame / b.targetStopDuration;
- GradientHelper.GetCurrentGradient(tt, b._startSizeGradients, function(rt, it, nt) {
- rt !== o._currentStartSizeGradient && (o._currentStartSize1 = o._currentStartSize2,
- o._currentStartSize2 = it.getFactor(),
- o._currentStartSizeGradient = rt);
- var ot = Scalar.Lerp(o._currentStartSize1, o._currentStartSize2, nt);
- d.scale.scaleInPlace(ot)
- })
- }
- !b._angularSpeedGradients || b._angularSpeedGradients.length === 0 ? d.angularSpeed = Scalar.RandomRange(b.minAngularSpeed, b.maxAngularSpeed) : (d._currentAngularSpeedGradient = b._angularSpeedGradients[0],
- d.angularSpeed = d._currentAngularSpeedGradient.getFactor(),
- d._currentAngularSpeed1 = d.angularSpeed,
- b._angularSpeedGradients.length > 1 ? d._currentAngularSpeed2 = b._angularSpeedGradients[1].getFactor() : d._currentAngularSpeed2 = d._currentAngularSpeed1),
- d.angle = Scalar.RandomRange(b.minInitialRotation, b.maxInitialRotation),
- b._velocityGradients && b._velocityGradients.length > 0 && (d._currentVelocityGradient = b._velocityGradients[0],
- d._currentVelocity1 = d._currentVelocityGradient.getFactor(),
- b._velocityGradients.length > 1 ? d._currentVelocity2 = b._velocityGradients[1].getFactor() : d._currentVelocity2 = d._currentVelocity1),
- b._limitVelocityGradients && b._limitVelocityGradients.length > 0 && (d._currentLimitVelocityGradient = b._limitVelocityGradients[0],
- d._currentLimitVelocity1 = d._currentLimitVelocityGradient.getFactor(),
- b._limitVelocityGradients.length > 1 ? d._currentLimitVelocity2 = b._limitVelocityGradients[1].getFactor() : d._currentLimitVelocity2 = d._currentLimitVelocity1),
- b._dragGradients && b._dragGradients.length > 0 && (d._currentDragGradient = b._dragGradients[0],
- d._currentDrag1 = d._currentDragGradient.getFactor(),
- b._dragGradients.length > 1 ? d._currentDrag2 = b._dragGradients[1].getFactor() : d._currentDrag2 = d._currentDrag1),
- !b._colorGradients || b._colorGradients.length === 0 ? (k = Scalar.RandomRange(0, 1),
- Color4.LerpToRef(b.color1, b.color2, k, d.color),
- b.colorDead.subtractToRef(d.color, b._colorDiff),
- b._colorDiff.scaleToRef(1 / d.lifeTime, d.colorStep)) : (d._currentColorGradient = b._colorGradients[0],
- d._currentColorGradient.getColorToRef(d.color),
- d._currentColor1.copyFrom(d.color),
- b._colorGradients.length > 1 ? b._colorGradients[1].getColorToRef(d._currentColor2) : d._currentColor2.copyFrom(d.color)),
- b._isAnimationSheetEnabled && (d._initialStartSpriteCellID = b.startSpriteCellID,
- d._initialEndSpriteCellID = b.endSpriteCellID,
- d._initialSpriteCellLoop = b.spriteCellLoop),
- d.direction.addInPlace(b._inheritedVelocityOffset),
- b._useRampGradients && (d.remapData = new Vector4(0,1,0,1)),
- b.noiseTexture && (d._randomNoiseCoordinates1 ? (d._randomNoiseCoordinates1.copyFromFloats(Math.random(), Math.random(), Math.random()),
- d._randomNoiseCoordinates2.copyFromFloats(Math.random(), Math.random(), Math.random())) : (d._randomNoiseCoordinates1 = new Vector3(Math.random(),Math.random(),Math.random()),
- d._randomNoiseCoordinates2 = new Vector3(Math.random(),Math.random(),Math.random()))),
- d._inheritParticleInfoToSubEmitters()
- }, b = this, k, j = 0; j < i; j++) {
- var $ = _();
- if ($ === "break")
- break
- }
- }
- ,
- e._GetAttributeNamesOrOptions = function(i, o, s) {
- i === void 0 && (i = !1),
- o === void 0 && (o = !1),
- s === void 0 && (s = !1);
- var c = [VertexBuffer.PositionKind, VertexBuffer.ColorKind, "angle", "offset", "size"];
- return i && c.push("cellIndex"),
- o || c.push("direction"),
- s && c.push("remapData"),
- c
- }
- ,
- e._GetEffectCreationOptions = function(i) {
- i === void 0 && (i = !1);
- var o = ["invView", "view", "projection", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "textureMask", "translationPivot", "eyePosition"];
- return i && o.push("particlesInfos"),
- o
- }
- ,
- e.prototype.fillDefines = function(i, o) {
- if (this._scene && (this._scene.clipPlane && i.push("#define CLIPPLANE"),
- this._scene.clipPlane2 && i.push("#define CLIPPLANE2"),
- this._scene.clipPlane3 && i.push("#define CLIPPLANE3"),
- this._scene.clipPlane4 && i.push("#define CLIPPLANE4"),
- this._scene.clipPlane5 && i.push("#define CLIPPLANE5"),
- this._scene.clipPlane6 && i.push("#define CLIPPLANE6")),
- this._isAnimationSheetEnabled && i.push("#define ANIMATESHEET"),
- o === e.BLENDMODE_MULTIPLY && i.push("#define BLENDMULTIPLYMODE"),
- this._useRampGradients && i.push("#define RAMPGRADIENT"),
- this._isBillboardBased)
- switch (i.push("#define BILLBOARD"),
- this.billboardMode) {
- case e.BILLBOARDMODE_Y:
- i.push("#define BILLBOARDY");
- break;
- case e.BILLBOARDMODE_STRETCHED:
- i.push("#define BILLBOARDSTRETCHED");
- break;
- case e.BILLBOARDMODE_ALL:
- i.push("#define BILLBOARDMODE_ALL");
- break
- }
- this._imageProcessingConfiguration && (this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines),
- i.push(this._imageProcessingConfigurationDefines.toString()))
- }
- ,
- e.prototype.fillUniformsAttributesAndSamplerNames = function(i, o, s) {
- o.push.apply(o, e._GetAttributeNamesOrOptions(this._isAnimationSheetEnabled, this._isBillboardBased && this.billboardMode !== e.BILLBOARDMODE_STRETCHED, this._useRampGradients)),
- i.push.apply(i, e._GetEffectCreationOptions(this._isAnimationSheetEnabled)),
- s.push("diffuseSampler", "rampSampler"),
- this._imageProcessingConfiguration && (ImageProcessingConfiguration.PrepareUniforms(i, this._imageProcessingConfigurationDefines),
- ImageProcessingConfiguration.PrepareSamplers(s, this._imageProcessingConfigurationDefines))
- }
- ,
- e.prototype._getWrapper = function(i) {
- var o = this._getCustomDrawWrapper(i);
- if (o != null && o.effect)
- return o;
- var s = [];
- this.fillDefines(s, i);
- var c = this._engine._features.supportRenderPasses ? this._engine.currentRenderPassId : 0
- , d = this._drawWrappers[c];
- d || (d = this._drawWrappers[c] = []);
- var _ = d[i];
- _ || (_ = new DrawWrapper(this._engine),
- _.drawContext && (_.drawContext.useInstancing = this._useInstancing),
- d[i] = _);
- var b = s.join(`
- `);
- if (_.defines !== b) {
- var k = []
- , j = []
- , $ = [];
- this.fillUniformsAttributesAndSamplerNames(j, k, $),
- _.setEffect(this._engine.createEffect("particles", k, j, $, b), b)
- }
- return _
- }
- ,
- e.prototype.animate = function(i) {
- var o = this, s;
- if (i === void 0 && (i = !1),
- !!this._started) {
- if (!i && this._scene) {
- if (!this.isReady() || this._currentRenderId === this._scene.getFrameId())
- return;
- this._currentRenderId = this._scene.getFrameId()
- }
- this._scaledUpdateSpeed = this.updateSpeed * (i ? this.preWarmStepOffset : ((s = this._scene) === null || s === void 0 ? void 0 : s.getAnimationRatio()) || 1);
- var c;
- if (this.manualEmitCount > -1)
- c = this.manualEmitCount,
- this._newPartsExcess = 0,
- this.manualEmitCount = 0;
- else {
- var d = this.emitRate;
- if (this._emitRateGradients && this._emitRateGradients.length > 0 && this.targetStopDuration) {
- var _ = this._actualFrame / this.targetStopDuration;
- GradientHelper.GetCurrentGradient(_, this._emitRateGradients, function($, _e, et) {
- $ !== o._currentEmitRateGradient && (o._currentEmitRate1 = o._currentEmitRate2,
- o._currentEmitRate2 = _e.getFactor(),
- o._currentEmitRateGradient = $),
- d = Scalar.Lerp(o._currentEmitRate1, o._currentEmitRate2, et)
- })
- }
- c = d * this._scaledUpdateSpeed >> 0,
- this._newPartsExcess += d * this._scaledUpdateSpeed - c
- }
- if (this._newPartsExcess > 1 && (c += this._newPartsExcess >> 0,
- this._newPartsExcess -= this._newPartsExcess >> 0),
- this._alive = !1,
- this._stopped ? c = 0 : (this._actualFrame += this._scaledUpdateSpeed,
- this.targetStopDuration && this._actualFrame >= this.targetStopDuration && this.stop()),
- this._update(c),
- this._stopped && (this._alive || (this._started = !1,
- this.onAnimationEnd && this.onAnimationEnd(),
- this.disposeOnStop && this._scene && this._scene._toBeDisposed.push(this))),
- !i) {
- for (var b = 0, k = 0; k < this._particles.length; k++) {
- var j = this._particles[k];
- this._appendParticleVertices(b, j),
- b += this._useInstancing ? 1 : 4
- }
- this._vertexBuffer && this._vertexBuffer.updateDirectly(this._vertexData, 0, this._particles.length)
- }
- this.manualEmitCount === 0 && this.disposeOnStop && this.stop()
- }
- }
- ,
- e.prototype._appendParticleVertices = function(i, o) {
- this._appendParticleVertex(i++, o, 0, 0),
- this._useInstancing || (this._appendParticleVertex(i++, o, 1, 0),
- this._appendParticleVertex(i++, o, 1, 1),
- this._appendParticleVertex(i++, o, 0, 1))
- }
- ,
- e.prototype.rebuild = function() {
- var i, o;
- this._engine.getCaps().vertexArrayObject && (this._vertexArrayObject = null),
- this._createIndexBuffer(),
- (i = this._spriteBuffer) === null || i === void 0 || i._rebuild(),
- (o = this._vertexBuffer) === null || o === void 0 || o._rebuild();
- for (var s in this._vertexBuffers)
- this._vertexBuffers[s]._rebuild();
- this.resetDrawCache()
- }
- ,
- e.prototype.isReady = function() {
- if (!this.emitter || this._imageProcessingConfiguration && !this._imageProcessingConfiguration.isReady() || !this.particleTexture || !this.particleTexture.isReady())
- return !1;
- if (this.blendMode !== e.BLENDMODE_MULTIPLYADD) {
- if (!this._getWrapper(this.blendMode).effect.isReady())
- return !1
- } else if (!this._getWrapper(e.BLENDMODE_MULTIPLY).effect.isReady() || !this._getWrapper(e.BLENDMODE_ADD).effect.isReady())
- return !1;
- return !0
- }
- ,
- e.prototype._render = function(i) {
- var o, s, c = this._getWrapper(i), d = c.effect, _ = this._engine;
- _.enableEffect(c);
- var b = (o = this.defaultViewMatrix) !== null && o !== void 0 ? o : this._scene.getViewMatrix();
- if (d.setTexture("diffuseSampler", this.particleTexture),
- d.setMatrix("view", b),
- d.setMatrix("projection", (s = this.defaultProjectionMatrix) !== null && s !== void 0 ? s : this._scene.getProjectionMatrix()),
- this._isAnimationSheetEnabled && this.particleTexture) {
- var k = this.particleTexture.getBaseSize();
- d.setFloat3("particlesInfos", this.spriteCellWidth / k.width, this.spriteCellHeight / k.height, this.spriteCellWidth / k.width)
- }
- if (d.setVector2("translationPivot", this.translationPivot),
- d.setFloat4("textureMask", this.textureMask.r, this.textureMask.g, this.textureMask.b, this.textureMask.a),
- this._isBillboardBased && this._scene) {
- var j = this._scene.activeCamera;
- d.setVector3("eyePosition", j.globalPosition)
- }
- this._rampGradientsTexture && ((!this._rampGradients || !this._rampGradients.length) && (this._rampGradientsTexture.dispose(),
- this._rampGradientsTexture = null),
- d.setTexture("rampSampler", this._rampGradientsTexture));
- var $ = d.defines;
- 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),
- $.indexOf("#define BILLBOARDMODE_ALL") >= 0 && (b.invertToRef(TmpVectors.Matrix[0]),
- d.setMatrix("invView", TmpVectors.Matrix[0])),
- this._vertexArrayObject !== void 0 ? (this._vertexArrayObject || (this._vertexArrayObject = this._engine.recordVertexArrayObject(this._vertexBuffers, this._indexBuffer, d)),
- this._engine.bindVertexArrayObject(this._vertexArrayObject, this._indexBuffer)) : _.bindBuffers(this._vertexBuffers, this._indexBuffer, d),
- this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess && this._imageProcessingConfiguration.bind(d),
- i) {
- case e.BLENDMODE_ADD:
- _.setAlphaMode(1);
- break;
- case e.BLENDMODE_ONEONE:
- _.setAlphaMode(6);
- break;
- case e.BLENDMODE_STANDARD:
- _.setAlphaMode(2);
- break;
- case e.BLENDMODE_MULTIPLY:
- _.setAlphaMode(4);
- break
- }
- return this._onBeforeDrawParticlesObservable && this._onBeforeDrawParticlesObservable.notifyObservers(d),
- this._useInstancing ? _.drawArraysType(7, 0, 4, this._particles.length) : _.drawElementsType(0, 0, this._particles.length * 6),
- this._particles.length
- }
- ,
- e.prototype.render = function() {
- if (!this.isReady() || !this._particles.length)
- return 0;
- var i = this._engine;
- i.setState && (i.setState(!1),
- this.forceDepthWrite && i.setDepthWrite(!0));
- var o = 0;
- return this.blendMode === e.BLENDMODE_MULTIPLYADD ? o = this._render(e.BLENDMODE_MULTIPLY) + this._render(e.BLENDMODE_ADD) : o = this._render(this.blendMode),
- this._engine.unbindInstanceAttributes(),
- this._engine.setAlphaMode(0),
- o
- }
- ,
- e.prototype.dispose = function(i) {
- if (i === void 0 && (i = !0),
- this.resetDrawCache(),
- this._vertexBuffer && (this._vertexBuffer.dispose(),
- this._vertexBuffer = null),
- this._spriteBuffer && (this._spriteBuffer.dispose(),
- this._spriteBuffer = null),
- this._indexBuffer && (this._engine._releaseBuffer(this._indexBuffer),
- this._indexBuffer = null),
- this._vertexArrayObject && (this._engine.releaseVertexArrayObject(this._vertexArrayObject),
- this._vertexArrayObject = null),
- i && this.particleTexture && (this.particleTexture.dispose(),
- this.particleTexture = null),
- i && this.noiseTexture && (this.noiseTexture.dispose(),
- this.noiseTexture = null),
- this._rampGradientsTexture && (this._rampGradientsTexture.dispose(),
- this._rampGradientsTexture = null),
- this._removeFromRoot(),
- this._subEmitters && this._subEmitters.length) {
- for (var o = 0; o < this._subEmitters.length; o++)
- for (var s = 0, c = this._subEmitters[o]; s < c.length; s++) {
- var d = c[s];
- d.dispose()
- }
- this._subEmitters = [],
- this.subEmitters = []
- }
- if (this._disposeEmitterOnDispose && this.emitter && this.emitter.dispose && this.emitter.dispose(!0),
- this._onBeforeDrawParticlesObservable && this._onBeforeDrawParticlesObservable.clear(),
- this._scene) {
- var o = this._scene.particleSystems.indexOf(this);
- o > -1 && this._scene.particleSystems.splice(o, 1),
- this._scene._activeParticleSystems.dispose()
- }
- this.onDisposeObservable.notifyObservers(this),
- this.onDisposeObservable.clear(),
- this.onStoppedObservable.clear(),
- this.reset()
- }
- ,
- e.prototype.clone = function(i, o) {
- var s = __assign({}, this._customWrappers)
- , c = null
- , d = this._engine;
- if (d.createEffectForParticles && this.customShader != null) {
- c = this.customShader;
- var _ = c.shaderOptions.defines.length > 0 ? c.shaderOptions.defines.join(`
- `) : "";
- s[0] = d.createEffectForParticles(c.shaderPath.fragmentElement, c.shaderOptions.uniforms, c.shaderOptions.samplers, _)
- }
- var b = this.serialize()
- , k = e.Parse(b, this._scene || this._engine, this._rootUrl);
- return k.name = i,
- k.customShader = c,
- k._customWrappers = s,
- o === void 0 && (o = this.emitter),
- this.noiseTexture && (k.noiseTexture = this.noiseTexture.clone()),
- k.emitter = o,
- this.preventAutoStart || k.start(),
- k
- }
- ,
- e.prototype.serialize = function(i) {
- i === void 0 && (i = !1);
- var o = {};
- if (e._Serialize(o, this, i),
- o.textureMask = this.textureMask.asArray(),
- o.customShader = this.customShader,
- o.preventAutoStart = this.preventAutoStart,
- this.subEmitters) {
- o.subEmitters = [],
- this._subEmitters || this._prepareSubEmitterInternalArray();
- for (var s = 0, c = this._subEmitters; s < c.length; s++) {
- for (var d = c[s], _ = [], b = 0, k = d; b < k.length; b++) {
- var j = k[b];
- _.push(j.serialize(i))
- }
- o.subEmitters.push(_)
- }
- }
- return o
- }
- ,
- e._Serialize = function(i, o, s) {
- if (i.name = o.name,
- i.id = o.id,
- i.capacity = o.getCapacity(),
- i.disposeOnStop = o.disposeOnStop,
- i.manualEmitCount = o.manualEmitCount,
- o.emitter.position) {
- var c = o.emitter;
- i.emitterId = c.id
- } else {
- var d = o.emitter;
- i.emitter = d.asArray()
- }
- o.particleEmitterType && (i.particleEmitterType = o.particleEmitterType.serialize()),
- o.particleTexture && (s ? i.texture = o.particleTexture.serialize() : (i.textureName = o.particleTexture.name,
- i.invertY = !!o.particleTexture._invertY)),
- i.isLocal = o.isLocal,
- SerializationHelper.AppendSerializedAnimations(o, i),
- i.beginAnimationOnStart = o.beginAnimationOnStart,
- i.beginAnimationFrom = o.beginAnimationFrom,
- i.beginAnimationTo = o.beginAnimationTo,
- i.beginAnimationLoop = o.beginAnimationLoop,
- i.startDelay = o.startDelay,
- i.renderingGroupId = o.renderingGroupId,
- i.isBillboardBased = o.isBillboardBased,
- i.billboardMode = o.billboardMode,
- i.minAngularSpeed = o.minAngularSpeed,
- i.maxAngularSpeed = o.maxAngularSpeed,
- i.minSize = o.minSize,
- i.maxSize = o.maxSize,
- i.minScaleX = o.minScaleX,
- i.maxScaleX = o.maxScaleX,
- i.minScaleY = o.minScaleY,
- i.maxScaleY = o.maxScaleY,
- i.minEmitPower = o.minEmitPower,
- i.maxEmitPower = o.maxEmitPower,
- i.minLifeTime = o.minLifeTime,
- i.maxLifeTime = o.maxLifeTime,
- i.emitRate = o.emitRate,
- i.gravity = o.gravity.asArray(),
- i.noiseStrength = o.noiseStrength.asArray(),
- i.color1 = o.color1.asArray(),
- i.color2 = o.color2.asArray(),
- i.colorDead = o.colorDead.asArray(),
- i.updateSpeed = o.updateSpeed,
- i.targetStopDuration = o.targetStopDuration,
- i.blendMode = o.blendMode,
- i.preWarmCycles = o.preWarmCycles,
- i.preWarmStepOffset = o.preWarmStepOffset,
- i.minInitialRotation = o.minInitialRotation,
- i.maxInitialRotation = o.maxInitialRotation,
- i.startSpriteCellID = o.startSpriteCellID,
- i.spriteCellLoop = o.spriteCellLoop,
- i.endSpriteCellID = o.endSpriteCellID,
- i.spriteCellChangeSpeed = o.spriteCellChangeSpeed,
- i.spriteCellWidth = o.spriteCellWidth,
- i.spriteCellHeight = o.spriteCellHeight,
- i.spriteRandomStartCell = o.spriteRandomStartCell,
- i.isAnimationSheetEnabled = o.isAnimationSheetEnabled;
- var _ = o.getColorGradients();
- if (_) {
- i.colorGradients = [];
- for (var b = 0, k = _; b < k.length; b++) {
- var j = k[b]
- , $ = {
- gradient: j.gradient,
- color1: j.color1.asArray()
- };
- j.color2 ? $.color2 = j.color2.asArray() : $.color2 = j.color1.asArray(),
- i.colorGradients.push($)
- }
- }
- var _e = o.getRampGradients();
- if (_e) {
- i.rampGradients = [];
- for (var et = 0, tt = _e; et < tt.length; et++) {
- var rt = tt[et]
- , $ = {
- gradient: rt.gradient,
- color: rt.color.asArray()
- };
- i.rampGradients.push($)
- }
- i.useRampGradients = o.useRampGradients
- }
- var it = o.getColorRemapGradients();
- if (it) {
- i.colorRemapGradients = [];
- for (var nt = 0, ot = it; nt < ot.length; nt++) {
- var at = ot[nt]
- , $ = {
- gradient: at.gradient,
- factor1: at.factor1
- };
- at.factor2 !== void 0 ? $.factor2 = at.factor2 : $.factor2 = at.factor1,
- i.colorRemapGradients.push($)
- }
- }
- var st = o.getAlphaRemapGradients();
- if (st) {
- i.alphaRemapGradients = [];
- for (var ut = 0, ct = st; ut < ct.length; ut++) {
- var lt = ct[ut]
- , $ = {
- gradient: lt.gradient,
- factor1: lt.factor1
- };
- lt.factor2 !== void 0 ? $.factor2 = lt.factor2 : $.factor2 = lt.factor1,
- i.alphaRemapGradients.push($)
- }
- }
- var ft = o.getSizeGradients();
- if (ft) {
- i.sizeGradients = [];
- for (var ht = 0, pt = ft; ht < pt.length; ht++) {
- var dt = pt[ht]
- , $ = {
- gradient: dt.gradient,
- factor1: dt.factor1
- };
- dt.factor2 !== void 0 ? $.factor2 = dt.factor2 : $.factor2 = dt.factor1,
- i.sizeGradients.push($)
- }
- }
- var _t = o.getAngularSpeedGradients();
- if (_t) {
- i.angularSpeedGradients = [];
- for (var mt = 0, vt = _t; mt < vt.length; mt++) {
- var yt = vt[mt]
- , $ = {
- gradient: yt.gradient,
- factor1: yt.factor1
- };
- yt.factor2 !== void 0 ? $.factor2 = yt.factor2 : $.factor2 = yt.factor1,
- i.angularSpeedGradients.push($)
- }
- }
- var Et = o.getVelocityGradients();
- if (Et) {
- i.velocityGradients = [];
- for (var At = 0, gt = Et; At < gt.length; At++) {
- var St = gt[At]
- , $ = {
- gradient: St.gradient,
- factor1: St.factor1
- };
- St.factor2 !== void 0 ? $.factor2 = St.factor2 : $.factor2 = St.factor1,
- i.velocityGradients.push($)
- }
- }
- var xt = o.getDragGradients();
- if (xt) {
- i.dragGradients = [];
- for (var bt = 0, Rt = xt; bt < Rt.length; bt++) {
- var Mt = Rt[bt]
- , $ = {
- gradient: Mt.gradient,
- factor1: Mt.factor1
- };
- Mt.factor2 !== void 0 ? $.factor2 = Mt.factor2 : $.factor2 = Mt.factor1,
- i.dragGradients.push($)
- }
- }
- var Pt = o.getEmitRateGradients();
- if (Pt) {
- i.emitRateGradients = [];
- for (var It = 0, Dt = Pt; It < Dt.length; It++) {
- var Ct = Dt[It]
- , $ = {
- gradient: Ct.gradient,
- factor1: Ct.factor1
- };
- Ct.factor2 !== void 0 ? $.factor2 = Ct.factor2 : $.factor2 = Ct.factor1,
- i.emitRateGradients.push($)
- }
- }
- var Ot = o.getStartSizeGradients();
- if (Ot) {
- i.startSizeGradients = [];
- for (var wt = 0, Nt = Ot; wt < Nt.length; wt++) {
- var Ft = Nt[wt]
- , $ = {
- gradient: Ft.gradient,
- factor1: Ft.factor1
- };
- Ft.factor2 !== void 0 ? $.factor2 = Ft.factor2 : $.factor2 = Ft.factor1,
- i.startSizeGradients.push($)
- }
- }
- var Vt = o.getLifeTimeGradients();
- if (Vt) {
- i.lifeTimeGradients = [];
- for (var Lt = 0, kt = Vt; Lt < kt.length; Lt++) {
- var Bt = kt[Lt]
- , $ = {
- gradient: Bt.gradient,
- factor1: Bt.factor1
- };
- Bt.factor2 !== void 0 ? $.factor2 = Bt.factor2 : $.factor2 = Bt.factor1,
- i.lifeTimeGradients.push($)
- }
- }
- var Ut = o.getLimitVelocityGradients();
- if (Ut) {
- i.limitVelocityGradients = [];
- for (var Gt = 0, Ht = Ut; Gt < Ht.length; Gt++) {
- var zt = Ht[Gt]
- , $ = {
- gradient: zt.gradient,
- factor1: zt.factor1
- };
- zt.factor2 !== void 0 ? $.factor2 = zt.factor2 : $.factor2 = zt.factor1,
- i.limitVelocityGradients.push($)
- }
- i.limitVelocityDamping = o.limitVelocityDamping
- }
- o.noiseTexture && (i.noiseTexture = o.noiseTexture.serialize())
- }
- ,
- e._Parse = function(i, o, s, c) {
- var d, _, b, k;
- s instanceof ThinEngine ? k = null : k = s;
- var j = GetClass("BABYLON.Texture");
- 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),
- o.particleTexture.name = i.textureName)),
- !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),
- o.isLocal = !!i.isLocal,
- i.renderingGroupId !== void 0 && (o.renderingGroupId = i.renderingGroupId),
- i.isBillboardBased !== void 0 && (o.isBillboardBased = i.isBillboardBased),
- i.billboardMode !== void 0 && (o.billboardMode = i.billboardMode),
- i.animations) {
- for (var $ = 0; $ < i.animations.length; $++) {
- var _e = i.animations[$]
- , et = GetClass("BABYLON.Animation");
- et && o.animations.push(et.Parse(_e))
- }
- o.beginAnimationOnStart = i.beginAnimationOnStart,
- o.beginAnimationFrom = i.beginAnimationFrom,
- o.beginAnimationTo = i.beginAnimationTo,
- o.beginAnimationLoop = i.beginAnimationLoop
- }
- if (i.autoAnimate && k && k.beginAnimation(o, i.autoAnimateFrom, i.autoAnimateTo, i.autoAnimateLoop, i.autoAnimateSpeed || 1),
- o.startDelay = i.startDelay | 0,
- o.minAngularSpeed = i.minAngularSpeed,
- o.maxAngularSpeed = i.maxAngularSpeed,
- o.minSize = i.minSize,
- o.maxSize = i.maxSize,
- i.minScaleX && (o.minScaleX = i.minScaleX,
- o.maxScaleX = i.maxScaleX,
- o.minScaleY = i.minScaleY,
- o.maxScaleY = i.maxScaleY),
- i.preWarmCycles !== void 0 && (o.preWarmCycles = i.preWarmCycles,
- o.preWarmStepOffset = i.preWarmStepOffset),
- i.minInitialRotation !== void 0 && (o.minInitialRotation = i.minInitialRotation,
- o.maxInitialRotation = i.maxInitialRotation),
- o.minLifeTime = i.minLifeTime,
- o.maxLifeTime = i.maxLifeTime,
- o.minEmitPower = i.minEmitPower,
- o.maxEmitPower = i.maxEmitPower,
- o.emitRate = i.emitRate,
- o.gravity = Vector3.FromArray(i.gravity),
- i.noiseStrength && (o.noiseStrength = Vector3.FromArray(i.noiseStrength)),
- o.color1 = Color4.FromArray(i.color1),
- o.color2 = Color4.FromArray(i.color2),
- o.colorDead = Color4.FromArray(i.colorDead),
- o.updateSpeed = i.updateSpeed,
- o.targetStopDuration = i.targetStopDuration,
- o.blendMode = i.blendMode,
- i.colorGradients)
- for (var tt = 0, rt = i.colorGradients; tt < rt.length; tt++) {
- var it = rt[tt];
- o.addColorGradient(it.gradient, Color4.FromArray(it.color1), it.color2 ? Color4.FromArray(it.color2) : void 0)
- }
- if (i.rampGradients) {
- for (var nt = 0, ot = i.rampGradients; nt < ot.length; nt++) {
- var at = ot[nt];
- o.addRampGradient(at.gradient, Color3.FromArray(at.color))
- }
- o.useRampGradients = i.useRampGradients
- }
- if (i.colorRemapGradients)
- for (var st = 0, ut = i.colorRemapGradients; st < ut.length; st++) {
- var ct = ut[st];
- o.addColorRemapGradient(ct.gradient, ct.factor1 !== void 0 ? ct.factor1 : ct.factor, ct.factor2)
- }
- if (i.alphaRemapGradients)
- for (var lt = 0, ft = i.alphaRemapGradients; lt < ft.length; lt++) {
- var ht = ft[lt];
- o.addAlphaRemapGradient(ht.gradient, ht.factor1 !== void 0 ? ht.factor1 : ht.factor, ht.factor2)
- }
- if (i.sizeGradients)
- for (var pt = 0, dt = i.sizeGradients; pt < dt.length; pt++) {
- var _t = dt[pt];
- o.addSizeGradient(_t.gradient, _t.factor1 !== void 0 ? _t.factor1 : _t.factor, _t.factor2)
- }
- if (i.angularSpeedGradients)
- for (var mt = 0, vt = i.angularSpeedGradients; mt < vt.length; mt++) {
- var yt = vt[mt];
- o.addAngularSpeedGradient(yt.gradient, yt.factor1 !== void 0 ? yt.factor1 : yt.factor, yt.factor2)
- }
- if (i.velocityGradients)
- for (var Et = 0, At = i.velocityGradients; Et < At.length; Et++) {
- var gt = At[Et];
- o.addVelocityGradient(gt.gradient, gt.factor1 !== void 0 ? gt.factor1 : gt.factor, gt.factor2)
- }
- if (i.dragGradients)
- for (var St = 0, xt = i.dragGradients; St < xt.length; St++) {
- var bt = xt[St];
- o.addDragGradient(bt.gradient, bt.factor1 !== void 0 ? bt.factor1 : bt.factor, bt.factor2)
- }
- if (i.emitRateGradients)
- for (var Rt = 0, Mt = i.emitRateGradients; Rt < Mt.length; Rt++) {
- var Pt = Mt[Rt];
- o.addEmitRateGradient(Pt.gradient, Pt.factor1 !== void 0 ? Pt.factor1 : Pt.factor, Pt.factor2)
- }
- if (i.startSizeGradients)
- for (var It = 0, Dt = i.startSizeGradients; It < Dt.length; It++) {
- var Ct = Dt[It];
- o.addStartSizeGradient(Ct.gradient, Ct.factor1 !== void 0 ? Ct.factor1 : Ct.factor, Ct.factor2)
- }
- if (i.lifeTimeGradients)
- for (var Ot = 0, wt = i.lifeTimeGradients; Ot < wt.length; Ot++) {
- var Nt = wt[Ot];
- o.addLifeTimeGradient(Nt.gradient, Nt.factor1 !== void 0 ? Nt.factor1 : Nt.factor, Nt.factor2)
- }
- if (i.limitVelocityGradients) {
- for (var Ft = 0, Vt = i.limitVelocityGradients; Ft < Vt.length; Ft++) {
- var Lt = Vt[Ft];
- o.addLimitVelocityGradient(Lt.gradient, Lt.factor1 !== void 0 ? Lt.factor1 : Lt.factor, Lt.factor2)
- }
- o.limitVelocityDamping = i.limitVelocityDamping
- }
- if (i.noiseTexture && k) {
- var kt = GetClass("BABYLON.ProceduralTexture");
- o.noiseTexture = kt.Parse(i.noiseTexture, k, c)
- }
- var Bt;
- if (i.particleEmitterType) {
- switch (i.particleEmitterType.type) {
- case "SphereParticleEmitter":
- Bt = new SphereParticleEmitter;
- break;
- case "SphereDirectedParticleEmitter":
- Bt = new SphereDirectedParticleEmitter;
- break;
- case "ConeEmitter":
- case "ConeParticleEmitter":
- Bt = new ConeParticleEmitter;
- break;
- case "CylinderParticleEmitter":
- Bt = new CylinderParticleEmitter;
- break;
- case "CylinderDirectedParticleEmitter":
- Bt = new CylinderDirectedParticleEmitter;
- break;
- case "HemisphericParticleEmitter":
- Bt = new HemisphericParticleEmitter;
- break;
- case "PointParticleEmitter":
- Bt = new PointParticleEmitter;
- break;
- case "MeshParticleEmitter":
- Bt = new MeshParticleEmitter;
- break;
- case "BoxEmitter":
- case "BoxParticleEmitter":
- default:
- Bt = new BoxParticleEmitter;
- break
- }
- Bt.parse(i.particleEmitterType, k)
- } else
- Bt = new BoxParticleEmitter,
- Bt.parse(i, k);
- o.particleEmitterType = Bt,
- o.startSpriteCellID = i.startSpriteCellID,
- o.endSpriteCellID = i.endSpriteCellID,
- o.spriteCellLoop = (d = i.spriteCellLoop) !== null && d !== void 0 ? d : !0,
- o.spriteCellWidth = i.spriteCellWidth,
- o.spriteCellHeight = i.spriteCellHeight,
- o.spriteCellChangeSpeed = i.spriteCellChangeSpeed,
- o.spriteRandomStartCell = i.spriteRandomStartCell,
- o.disposeOnStop = (_ = i.disposeOnStop) !== null && _ !== void 0 ? _ : !1,
- o.manualEmitCount = (b = i.manualEmitCount) !== null && b !== void 0 ? b : -1
- }
- ,
- e.Parse = function(i, o, s, c, d) {
- c === void 0 && (c = !1);
- var _ = i.name, b = null, k = null, j, $;
- if (o instanceof ThinEngine ? j = o : ($ = o,
- j = $.getEngine()),
- i.customShader && j.createEffectForParticles) {
- k = i.customShader;
- var _e = k.shaderOptions.defines.length > 0 ? k.shaderOptions.defines.join(`
- `) : "";
- b = j.createEffectForParticles(k.shaderPath.fragmentElement, k.shaderOptions.uniforms, k.shaderOptions.samplers, _e)
- }
- var et = new e(_,d || i.capacity,o,b,i.isAnimationSheetEnabled);
- if (et.customShader = k,
- et._rootUrl = s,
- i.id && (et.id = i.id),
- i.subEmitters) {
- et.subEmitters = [];
- for (var tt = 0, rt = i.subEmitters; tt < rt.length; tt++) {
- for (var it = rt[tt], nt = [], ot = 0, at = it; ot < at.length; ot++) {
- var st = at[ot];
- nt.push(SubEmitter.Parse(st, o, s))
- }
- et.subEmitters.push(nt)
- }
- }
- return e._Parse(i, et, o, s),
- i.textureMask && (et.textureMask = Color4.FromArray(i.textureMask)),
- i.preventAutoStart && (et.preventAutoStart = i.preventAutoStart),
- !c && !et.preventAutoStart && et.start(),
- et
- }
- ,
- e.BILLBOARDMODE_Y = 2,
- e.BILLBOARDMODE_ALL = 7,
- e.BILLBOARDMODE_STRETCHED = 8,
- e
- }(BaseParticleSystem);
- SubEmitter._ParseParticleSystem = ParticleSystem.Parse;
- var name$1k = "clipPlaneFragmentDeclaration2"
- , shader$1k = `#ifdef CLIPPLANE
- in float fClipDistance;
- #endif
- #ifdef CLIPPLANE2
- in float fClipDistance2;
- #endif
- #ifdef CLIPPLANE3
- in float fClipDistance3;
- #endif
- #ifdef CLIPPLANE4
- in float fClipDistance4;
- #endif
- #ifdef CLIPPLANE5
- in float fClipDistance5;
- #endif
- #ifdef CLIPPLANE6
- in float fClipDistance6;
- #endif`;
- ShaderStore.IncludesShadersStore[name$1k] = shader$1k;
- var name$1j = "gpuRenderParticlesPixelShader"
- , shader$1j = `precision highp float;
- uniform sampler2D diffuseSampler;
- varying vec2 vUV;
- varying vec4 vColor;
- #include<clipPlaneFragmentDeclaration2>
- #include<imageProcessingDeclaration>
- #include<helperFunctions>
- #include<imageProcessingFunctions>
- void main() {
- #include<clipPlaneFragment>
- vec4 textureColor=texture2D(diffuseSampler,vUV);
- gl_FragColor=textureColor*vColor;
- #ifdef BLENDMULTIPLYMODE
- float alpha=vColor.a*textureColor.a;
- gl_FragColor.rgb=gl_FragColor.rgb*alpha+vec3(1.0)*(1.0-alpha);
- #endif
- #ifdef IMAGEPROCESSINGPOSTPROCESS
- gl_FragColor.rgb=toLinearSpace(gl_FragColor.rgb);
- #else
- #ifdef IMAGEPROCESSING
- gl_FragColor.rgb=toLinearSpace(gl_FragColor.rgb);
- gl_FragColor=applyImageProcessing(gl_FragColor);
- #endif
- #endif
- }
- `;
- ShaderStore.ShadersStore[name$1j] = shader$1j;
- var name$1i = "clipPlaneVertexDeclaration2"
- , shader$1i = `#ifdef CLIPPLANE
- uniform vec4 vClipPlane;
- out float fClipDistance;
- #endif
- #ifdef CLIPPLANE2
- uniform vec4 vClipPlane2;
- out float fClipDistance2;
- #endif
- #ifdef CLIPPLANE3
- uniform vec4 vClipPlane3;
- out float fClipDistance3;
- #endif
- #ifdef CLIPPLANE4
- uniform vec4 vClipPlane4;
- out float fClipDistance4;
- #endif
- #ifdef CLIPPLANE5
- uniform vec4 vClipPlane5;
- out float fClipDistance5;
- #endif
- #ifdef CLIPPLANE6
- uniform vec4 vClipPlane6;
- out float fClipDistance6;
- #endif`;
- ShaderStore.IncludesShadersStore[name$1i] = shader$1i;
- var name$1h = "gpuRenderParticlesVertexShader"
- , shader$1h = `precision highp float;
- uniform mat4 view;
- uniform mat4 projection;
- uniform vec2 translationPivot;
- uniform vec3 worldOffset;
- #ifdef LOCAL
- uniform mat4 emitterWM;
- #endif
- attribute vec3 position;
- attribute float age;
- attribute float life;
- attribute vec3 size;
- #ifndef BILLBOARD
- attribute vec3 initialDirection;
- #endif
- #ifdef BILLBOARDSTRETCHED
- attribute vec3 direction;
- #endif
- attribute float angle;
- #ifdef ANIMATESHEET
- attribute float cellIndex;
- #endif
- attribute vec2 offset;
- attribute vec2 uv;
- varying vec2 vUV;
- varying vec4 vColor;
- varying vec3 vPositionW;
- #if defined(BILLBOARD) && !defined(BILLBOARDY) && !defined(BILLBOARDSTRETCHED)
- uniform mat4 invView;
- #endif
- #include<clipPlaneVertexDeclaration2>
- #ifdef COLORGRADIENTS
- uniform sampler2D colorGradientSampler;
- #else
- uniform vec4 colorDead;
- attribute vec4 color;
- #endif
- #ifdef ANIMATESHEET
- uniform vec3 sheetInfos;
- #endif
- #ifdef BILLBOARD
- uniform vec3 eyePosition;
- #endif
- vec3 rotate(vec3 yaxis,vec3 rotatedCorner) {
- vec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));
- vec3 zaxis=normalize(cross(yaxis,xaxis));
- vec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);
- vec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);
- vec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);
- mat3 rotMatrix=mat3(row0,row1,row2);
- vec3 alignedCorner=rotMatrix*rotatedCorner;
- #ifdef LOCAL
- return ((emitterWM*vec4(position,1.0)).xyz+worldOffset)+alignedCorner;
- #else
- return (position+worldOffset)+alignedCorner;
- #endif
- }
- #ifdef BILLBOARDSTRETCHED
- vec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {
- vec3 normalizedToCamera=normalize(toCamera);
- vec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));
- vec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));
- vec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);
- vec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);
- vec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);
- mat3 rotMatrix=mat3(row0,row1,row2);
- vec3 alignedCorner=rotMatrix*rotatedCorner;
- #ifdef LOCAL
- return ((emitterWM*vec4(position,1.0)).xyz+worldOffset)+alignedCorner;
- #else
- return (position+worldOffset)+alignedCorner;
- #endif
- }
- #endif
- void main() {
- #ifdef ANIMATESHEET
- float rowOffset=floor(cellIndex/sheetInfos.z);
- float columnOffset=cellIndex-rowOffset*sheetInfos.z;
- vec2 uvScale=sheetInfos.xy;
- vec2 uvOffset=vec2(uv.x ,1.0-uv.y);
- vUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;
- #else
- vUV=uv;
- #endif
- float ratio=age/life;
- #ifdef COLORGRADIENTS
- vColor=texture2D(colorGradientSampler,vec2(ratio,0));
- #else
- vColor=color*vec4(1.0-ratio)+colorDead*vec4(ratio);
- #endif
- vec2 cornerPos=(offset-translationPivot)*size.yz*size.x+translationPivot;
- #ifdef BILLBOARD
- vec4 rotatedCorner;
- rotatedCorner.w=0.;
- #ifdef BILLBOARDY
- rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
- rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
- rotatedCorner.y=0.;
- vec3 yaxis=(position+worldOffset)-eyePosition;
- yaxis.y=0.;
- vPositionW=rotate(normalize(yaxis),rotatedCorner.xyz);
- vec4 viewPosition=(view*vec4(vPositionW,1.0));
- #elif defined(BILLBOARDSTRETCHED)
- rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
- rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
- rotatedCorner.z=0.;
- vec3 toCamera=(position+worldOffset)-eyePosition;
- vPositionW=rotateAlign(toCamera,rotatedCorner.xyz);
- vec4 viewPosition=(view*vec4(vPositionW,1.0));
- #else
- rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
- rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
- rotatedCorner.z=0.;
- #ifdef LOCAL
- vec4 viewPosition=view*vec4(((emitterWM*vec4(position,1.0)).xyz+worldOffset),1.0)+rotatedCorner;
- #else
- vec4 viewPosition=view*vec4((position+worldOffset),1.0)+rotatedCorner;
- #endif
- vPositionW=(invView*viewPosition).xyz;
- #endif
- #else
- vec3 rotatedCorner;
- rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
- rotatedCorner.y=0.;
- rotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
- vec3 yaxis=normalize(initialDirection);
- vPositionW=rotate(yaxis,rotatedCorner);
- vec4 viewPosition=view*vec4(vPositionW,1.0);
- #endif
- gl_Position=projection*viewPosition;
- #if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)
- vec4 worldPos=vec4(vPositionW,1.0);
- #endif
- #include<clipPlaneVertex>
- }`;
- ShaderStore.ShadersStore[name$1h] = shader$1h;
- var GPUParticleSystem = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d) {
- c === void 0 && (c = null),
- d === void 0 && (d = !1);
- var _ = a.call(this, i) || this;
- if (_.layerMask = 268435455,
- _._accumulatedCount = 0,
- _._targetIndex = 0,
- _._currentRenderId = -1,
- _._currentRenderingCameraUniqueId = -1,
- _._started = !1,
- _._stopped = !1,
- _._timeDelta = 0,
- _._actualFrame = 0,
- _._rawTextureWidth = 256,
- _.onDisposeObservable = new Observable,
- _.onStoppedObservable = new Observable,
- _.forceDepthWrite = !1,
- _._preWarmDone = !1,
- _.isLocal = !1,
- _._onBeforeDrawParticlesObservable = null,
- !s || s.getClassName() === "Scene" ? (_._scene = s || EngineStore.LastCreatedScene,
- _._engine = _._scene.getEngine(),
- _.uniqueId = _._scene.getUniqueId(),
- _._scene.particleSystems.push(_)) : (_._engine = s,
- _.defaultProjectionMatrix = Matrix.PerspectiveFovLH(.8, 1, .1, 100, _._engine.isNDCHalfZRange)),
- _._engine.getCaps().supportComputeShaders) {
- if (!GetClass("BABYLON.ComputeShaderParticleSystem"))
- throw new Error("The ComputeShaderParticleSystem class is not available! Make sure you have imported it.");
- _._platform = new (GetClass("BABYLON.ComputeShaderParticleSystem"))(_,_._engine)
- } else {
- if (!GetClass("BABYLON.WebGL2ParticleSystem"))
- throw new Error("The WebGL2ParticleSystem class is not available! Make sure you have imported it.");
- _._platform = new (GetClass("BABYLON.WebGL2ParticleSystem"))(_,_._engine)
- }
- _._customWrappers = {
- 0: new DrawWrapper(_._engine)
- },
- _._customWrappers[0].effect = c,
- _._drawWrappers = {
- 0: new DrawWrapper(_._engine)
- },
- _._drawWrappers[0].drawContext && (_._drawWrappers[0].drawContext.useInstancing = !0),
- _._attachImageProcessingConfiguration(null),
- o = o != null ? o : {},
- o.randomTextureSize || delete o.randomTextureSize;
- var b = __assign({
- capacity: 5e4,
- randomTextureSize: _._engine.getCaps().maxTextureSize
- }, o)
- , k = o;
- isFinite(k) && (b.capacity = k),
- _._capacity = b.capacity,
- _._activeCount = b.capacity,
- _._currentActiveCount = 0,
- _._isAnimationSheetEnabled = d,
- _.particleEmitterType = new BoxParticleEmitter;
- for (var j = Math.min(_._engine.getCaps().maxTextureSize, b.randomTextureSize), $ = [], _e = 0; _e < j; ++_e)
- $.push(Math.random()),
- $.push(Math.random()),
- $.push(Math.random()),
- $.push(Math.random());
- _._randomTexture = new RawTexture(new Float32Array($),j,1,5,s,!1,!1,1,1),
- _._randomTexture.name = "GPUParticleSystem_random1",
- _._randomTexture.wrapU = 1,
- _._randomTexture.wrapV = 1,
- $ = [];
- for (var _e = 0; _e < j; ++_e)
- $.push(Math.random()),
- $.push(Math.random()),
- $.push(Math.random()),
- $.push(Math.random());
- return _._randomTexture2 = new RawTexture(new Float32Array($),j,1,5,s,!1,!1,1,1),
- _._randomTexture2.name = "GPUParticleSystem_random2",
- _._randomTexture2.wrapU = 1,
- _._randomTexture2.wrapV = 1,
- _._randomTextureSize = j,
- _
- }
- return Object.defineProperty(e, "IsSupported", {
- get: function() {
- return EngineStore.LastCreatedEngine ? EngineStore.LastCreatedEngine.name === "WebGL" && EngineStore.LastCreatedEngine.version > 1 || EngineStore.LastCreatedEngine.getCaps().supportComputeShaders : !1
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getCapacity = function() {
- return this._capacity
- }
- ,
- Object.defineProperty(e.prototype, "activeParticleCount", {
- get: function() {
- return this._activeCount
- },
- set: function(i) {
- this._activeCount = Math.min(i, this._capacity)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.isReady = function() {
- if (!this.emitter || this._imageProcessingConfiguration && !this._imageProcessingConfiguration.isReady() || !this.particleTexture || !this.particleTexture.isReady())
- return !1;
- if (this.blendMode !== ParticleSystem.BLENDMODE_MULTIPLYADD) {
- if (!this._getWrapper(this.blendMode).effect.isReady())
- return !1
- } else if (!this._getWrapper(ParticleSystem.BLENDMODE_MULTIPLY).effect.isReady() || !this._getWrapper(ParticleSystem.BLENDMODE_ADD).effect.isReady())
- return !1;
- return this._platform.isUpdateBufferCreated() ? this._platform.isUpdateBufferReady() : (this._recreateUpdateEffect(),
- !1)
- }
- ,
- e.prototype.isStarted = function() {
- return this._started
- }
- ,
- e.prototype.isStopped = function() {
- return this._stopped
- }
- ,
- e.prototype.isStopping = function() {
- return !1
- }
- ,
- e.prototype.getActiveCount = function() {
- return this._currentActiveCount
- }
- ,
- e.prototype.start = function(i) {
- var o = this;
- if (i === void 0 && (i = this.startDelay),
- !this.targetStopDuration && this._hasTargetStopDurationDependantGradient())
- throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
- if (i) {
- setTimeout(function() {
- o.start(0)
- }, i);
- return
- }
- this._started = !0,
- this._stopped = !1,
- this._preWarmDone = !1,
- this.beginAnimationOnStart && this.animations && this.animations.length > 0 && this._scene && this._scene.beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop)
- }
- ,
- e.prototype.stop = function() {
- this._stopped || (this._stopped = !0)
- }
- ,
- e.prototype.reset = function() {
- this._releaseBuffers(),
- this._platform.releaseVertexBuffers(),
- this._currentActiveCount = 0,
- this._targetIndex = 0
- }
- ,
- e.prototype.getClassName = function() {
- return "GPUParticleSystem"
- }
- ,
- e.prototype.getCustomEffect = function(i) {
- var o, s;
- return i === void 0 && (i = 0),
- (s = (o = this._customWrappers[i]) === null || o === void 0 ? void 0 : o.effect) !== null && s !== void 0 ? s : this._customWrappers[0].effect
- }
- ,
- e.prototype._getCustomDrawWrapper = function(i) {
- var o;
- return i === void 0 && (i = 0),
- (o = this._customWrappers[i]) !== null && o !== void 0 ? o : this._customWrappers[0]
- }
- ,
- e.prototype.setCustomEffect = function(i, o) {
- o === void 0 && (o = 0),
- this._customWrappers[o] = new DrawWrapper(this._engine),
- this._customWrappers[o].effect = i
- }
- ,
- Object.defineProperty(e.prototype, "onBeforeDrawParticlesObservable", {
- get: function() {
- return this._onBeforeDrawParticlesObservable || (this._onBeforeDrawParticlesObservable = new Observable),
- this._onBeforeDrawParticlesObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "vertexShaderName", {
- get: function() {
- return "gpuRenderParticles"
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._removeGradientAndTexture = function(i, o, s) {
- return a.prototype._removeGradientAndTexture.call(this, i, o, s),
- this._releaseBuffers(),
- this
- }
- ,
- e.prototype.addColorGradient = function(i, o, s) {
- this._colorGradients || (this._colorGradients = []);
- var c = new ColorGradient(i,o);
- return this._colorGradients.push(c),
- this._refreshColorGradient(!0),
- this._releaseBuffers(),
- this
- }
- ,
- e.prototype._refreshColorGradient = function(i) {
- i === void 0 && (i = !1),
- this._colorGradients && (i && this._colorGradients.sort(function(o, s) {
- return o.gradient < s.gradient ? -1 : o.gradient > s.gradient ? 1 : 0
- }),
- this._colorGradientsTexture && (this._colorGradientsTexture.dispose(),
- this._colorGradientsTexture = null))
- }
- ,
- e.prototype.forceRefreshGradients = function() {
- this._refreshColorGradient(),
- this._refreshFactorGradient(this._sizeGradients, "_sizeGradientsTexture"),
- this._refreshFactorGradient(this._angularSpeedGradients, "_angularSpeedGradientsTexture"),
- this._refreshFactorGradient(this._velocityGradients, "_velocityGradientsTexture"),
- this._refreshFactorGradient(this._limitVelocityGradients, "_limitVelocityGradientsTexture"),
- this._refreshFactorGradient(this._dragGradients, "_dragGradientsTexture"),
- this.reset()
- }
- ,
- e.prototype.removeColorGradient = function(i) {
- return this._removeGradientAndTexture(i, this._colorGradients, this._colorGradientsTexture),
- this._colorGradientsTexture = null,
- this
- }
- ,
- e.prototype.resetDrawCache = function() {
- var i;
- for (var o in this._drawWrappers) {
- var s = this._drawWrappers[o];
- (i = s.drawContext) === null || i === void 0 || i.reset()
- }
- }
- ,
- e.prototype._addFactorGradient = function(i, o, s) {
- var c = new FactorGradient(o,s);
- i.push(c),
- this._releaseBuffers()
- }
- ,
- e.prototype.addSizeGradient = function(i, o) {
- return this._sizeGradients || (this._sizeGradients = []),
- this._addFactorGradient(this._sizeGradients, i, o),
- this._refreshFactorGradient(this._sizeGradients, "_sizeGradientsTexture", !0),
- this._releaseBuffers(),
- this
- }
- ,
- e.prototype.removeSizeGradient = function(i) {
- return this._removeGradientAndTexture(i, this._sizeGradients, this._sizeGradientsTexture),
- this._sizeGradientsTexture = null,
- this
- }
- ,
- e.prototype._refreshFactorGradient = function(i, o, s) {
- if (s === void 0 && (s = !1),
- !!i) {
- s && i.sort(function(d, _) {
- return d.gradient < _.gradient ? -1 : d.gradient > _.gradient ? 1 : 0
- });
- var c = this;
- c[o] && (c[o].dispose(),
- c[o] = null)
- }
- }
- ,
- e.prototype.addAngularSpeedGradient = function(i, o) {
- return this._angularSpeedGradients || (this._angularSpeedGradients = []),
- this._addFactorGradient(this._angularSpeedGradients, i, o),
- this._refreshFactorGradient(this._angularSpeedGradients, "_angularSpeedGradientsTexture", !0),
- this._releaseBuffers(),
- this
- }
- ,
- e.prototype.removeAngularSpeedGradient = function(i) {
- return this._removeGradientAndTexture(i, this._angularSpeedGradients, this._angularSpeedGradientsTexture),
- this._angularSpeedGradientsTexture = null,
- this
- }
- ,
- e.prototype.addVelocityGradient = function(i, o) {
- return this._velocityGradients || (this._velocityGradients = []),
- this._addFactorGradient(this._velocityGradients, i, o),
- this._refreshFactorGradient(this._velocityGradients, "_velocityGradientsTexture", !0),
- this._releaseBuffers(),
- this
- }
- ,
- e.prototype.removeVelocityGradient = function(i) {
- return this._removeGradientAndTexture(i, this._velocityGradients, this._velocityGradientsTexture),
- this._velocityGradientsTexture = null,
- this
- }
- ,
- e.prototype.addLimitVelocityGradient = function(i, o) {
- return this._limitVelocityGradients || (this._limitVelocityGradients = []),
- this._addFactorGradient(this._limitVelocityGradients, i, o),
- this._refreshFactorGradient(this._limitVelocityGradients, "_limitVelocityGradientsTexture", !0),
- this._releaseBuffers(),
- this
- }
- ,
- e.prototype.removeLimitVelocityGradient = function(i) {
- return this._removeGradientAndTexture(i, this._limitVelocityGradients, this._limitVelocityGradientsTexture),
- this._limitVelocityGradientsTexture = null,
- this
- }
- ,
- e.prototype.addDragGradient = function(i, o) {
- return this._dragGradients || (this._dragGradients = []),
- this._addFactorGradient(this._dragGradients, i, o),
- this._refreshFactorGradient(this._dragGradients, "_dragGradientsTexture", !0),
- this._releaseBuffers(),
- this
- }
- ,
- e.prototype.removeDragGradient = function(i) {
- return this._removeGradientAndTexture(i, this._dragGradients, this._dragGradientsTexture),
- this._dragGradientsTexture = null,
- this
- }
- ,
- e.prototype.addEmitRateGradient = function(i, o, s) {
- return this
- }
- ,
- e.prototype.removeEmitRateGradient = function(i) {
- return this
- }
- ,
- e.prototype.addStartSizeGradient = function(i, o, s) {
- return this
- }
- ,
- e.prototype.removeStartSizeGradient = function(i) {
- return this
- }
- ,
- e.prototype.addColorRemapGradient = function(i, o, s) {
- return this
- }
- ,
- e.prototype.removeColorRemapGradient = function() {
- return this
- }
- ,
- e.prototype.addAlphaRemapGradient = function(i, o, s) {
- return this
- }
- ,
- e.prototype.removeAlphaRemapGradient = function() {
- return this
- }
- ,
- e.prototype.addRampGradient = function(i, o) {
- return this
- }
- ,
- e.prototype.removeRampGradient = function() {
- return this
- }
- ,
- e.prototype.getRampGradients = function() {
- return null
- }
- ,
- Object.defineProperty(e.prototype, "useRampGradients", {
- get: function() {
- return !1
- },
- set: function(i) {},
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.addLifeTimeGradient = function(i, o, s) {
- return this
- }
- ,
- e.prototype.removeLifeTimeGradient = function(i) {
- return this
- }
- ,
- e.prototype._reset = function() {
- this._releaseBuffers()
- }
- ,
- e.prototype._createVertexBuffers = function(i, o, s) {
- var c = {};
- c.position = o.createVertexBuffer("position", 0, 3, this._attributesStrideSize, !0);
- var d = 3;
- c.age = o.createVertexBuffer("age", d, 1, this._attributesStrideSize, !0),
- d += 1,
- c.size = o.createVertexBuffer("size", d, 3, this._attributesStrideSize, !0),
- d += 3,
- c.life = o.createVertexBuffer("life", d, 1, this._attributesStrideSize, !0),
- d += 1,
- d += 4,
- this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED && (c.direction = o.createVertexBuffer("direction", d, 3, this._attributesStrideSize, !0)),
- d += 3,
- this._platform.alignDataInBuffer && (d += 1),
- this.particleEmitterType instanceof CustomParticleEmitter && (d += 3,
- this._platform.alignDataInBuffer && (d += 1)),
- this._colorGradientsTexture || (c.color = o.createVertexBuffer("color", d, 4, this._attributesStrideSize, !0),
- d += 4),
- this._isBillboardBased || (c.initialDirection = o.createVertexBuffer("initialDirection", d, 3, this._attributesStrideSize, !0),
- d += 3,
- this._platform.alignDataInBuffer && (d += 1)),
- this.noiseTexture && (c.noiseCoordinates1 = o.createVertexBuffer("noiseCoordinates1", d, 3, this._attributesStrideSize, !0),
- d += 3,
- this._platform.alignDataInBuffer && (d += 1),
- c.noiseCoordinates2 = o.createVertexBuffer("noiseCoordinates2", d, 3, this._attributesStrideSize, !0),
- d += 3,
- this._platform.alignDataInBuffer && (d += 1)),
- c.angle = o.createVertexBuffer("angle", d, 1, this._attributesStrideSize, !0),
- this._angularSpeedGradientsTexture ? d++ : d += 2,
- this._isAnimationSheetEnabled && (c.cellIndex = o.createVertexBuffer("cellIndex", d, 1, this._attributesStrideSize, !0),
- d += 1,
- this.spriteRandomStartCell && (c.cellStartOffset = o.createVertexBuffer("cellStartOffset", d, 1, this._attributesStrideSize, !0),
- d += 1)),
- c.offset = s.createVertexBuffer("offset", 0, 2),
- c.uv = s.createVertexBuffer("uv", 2, 2),
- this._platform.createVertexBuffers(i, c),
- this.resetDrawCache()
- }
- ,
- e.prototype._initialize = function(i) {
- if (i === void 0 && (i = !1),
- !(this._buffer0 && !i)) {
- var o = this._engine
- , s = new Array;
- this._attributesStrideSize = 21,
- this._targetIndex = 0,
- this._platform.alignDataInBuffer && (this._attributesStrideSize += 1),
- this.particleEmitterType instanceof CustomParticleEmitter && (this._attributesStrideSize += 3,
- this._platform.alignDataInBuffer && (this._attributesStrideSize += 1)),
- this.isBillboardBased || (this._attributesStrideSize += 3,
- this._platform.alignDataInBuffer && (this._attributesStrideSize += 1)),
- this._colorGradientsTexture && (this._attributesStrideSize -= 4),
- this._angularSpeedGradientsTexture && (this._attributesStrideSize -= 1),
- this._isAnimationSheetEnabled && (this._attributesStrideSize += 1,
- this.spriteRandomStartCell && (this._attributesStrideSize += 1)),
- this.noiseTexture && (this._attributesStrideSize += 6,
- this._platform.alignDataInBuffer && (this._attributesStrideSize += 2)),
- this._platform.alignDataInBuffer && (this._attributesStrideSize += 3 - (this._attributesStrideSize + 3 & 3));
- for (var c = this.particleEmitterType instanceof CustomParticleEmitter, d = TmpVectors.Vector3[0], _ = 0, b = 0; b < this._capacity; b++)
- if (s.push(0),
- s.push(0),
- s.push(0),
- s.push(0),
- s.push(0),
- s.push(0),
- s.push(0),
- s.push(0),
- s.push(Math.random()),
- s.push(Math.random()),
- s.push(Math.random()),
- s.push(Math.random()),
- c ? (this.particleEmitterType.particleDestinationGenerator(b, null, d),
- s.push(d.x),
- s.push(d.y),
- s.push(d.z)) : (s.push(0),
- s.push(0),
- s.push(0)),
- this._platform.alignDataInBuffer && s.push(0),
- _ += 16,
- c && (this.particleEmitterType.particlePositionGenerator(b, null, d),
- s.push(d.x),
- s.push(d.y),
- s.push(d.z),
- this._platform.alignDataInBuffer && s.push(0),
- _ += 4),
- this._colorGradientsTexture || (s.push(0),
- s.push(0),
- s.push(0),
- s.push(0),
- _ += 4),
- this.isBillboardBased || (s.push(0),
- s.push(0),
- s.push(0),
- this._platform.alignDataInBuffer && s.push(0),
- _ += 4),
- this.noiseTexture && (s.push(Math.random()),
- s.push(Math.random()),
- s.push(Math.random()),
- this._platform.alignDataInBuffer && s.push(0),
- s.push(Math.random()),
- s.push(Math.random()),
- s.push(Math.random()),
- this._platform.alignDataInBuffer && s.push(0),
- _ += 8),
- s.push(0),
- _ += 1,
- this._angularSpeedGradientsTexture || (s.push(0),
- _ += 1),
- this._isAnimationSheetEnabled && (s.push(0),
- _ += 1,
- this.spriteRandomStartCell && (s.push(0),
- _ += 1)),
- this._platform.alignDataInBuffer) {
- var k = 3 - (_ + 3 & 3);
- for (_ += k; k-- > 0; )
- s.push(0)
- }
- var j = new Float32Array([.5, .5, 1, 1, -.5, .5, 0, 1, .5, -.5, 1, 0, -.5, -.5, 0, 0])
- , $ = this._platform.createParticleBuffer(s)
- , _e = this._platform.createParticleBuffer(s);
- this._buffer0 = new Buffer(o,$,!1,this._attributesStrideSize),
- this._buffer1 = new Buffer(o,_e,!1,this._attributesStrideSize),
- this._spriteBuffer = new Buffer(o,j,!1,4),
- this._createVertexBuffers(this._buffer0, this._buffer1, this._spriteBuffer),
- this._createVertexBuffers(this._buffer1, this._buffer0, this._spriteBuffer),
- this._sourceBuffer = this._buffer0,
- this._targetBuffer = this._buffer1
- }
- }
- ,
- e.prototype._recreateUpdateEffect = function() {
- var i = this.particleEmitterType ? this.particleEmitterType.getEffectDefines() : "";
- this._isBillboardBased && (i += `
- #define BILLBOARD`),
- this._colorGradientsTexture && (i += `
- #define COLORGRADIENTS`),
- this._sizeGradientsTexture && (i += `
- #define SIZEGRADIENTS`),
- this._angularSpeedGradientsTexture && (i += `
- #define ANGULARSPEEDGRADIENTS`),
- this._velocityGradientsTexture && (i += `
- #define VELOCITYGRADIENTS`),
- this._limitVelocityGradientsTexture && (i += `
- #define LIMITVELOCITYGRADIENTS`),
- this._dragGradientsTexture && (i += `
- #define DRAGGRADIENTS`),
- this.isAnimationSheetEnabled && (i += `
- #define ANIMATESHEET`,
- this.spriteRandomStartCell && (i += `
- #define ANIMATESHEETRANDOMSTART`)),
- this.noiseTexture && (i += `
- #define NOISE`),
- this.isLocal && (i += `
- #define LOCAL`),
- !(this._platform.isUpdateBufferCreated() && this._cachedUpdateDefines === i) && (this._cachedUpdateDefines = i,
- this._updateBuffer = this._platform.createUpdateBuffer(i))
- }
- ,
- e.prototype._getWrapper = function(i) {
- var o = this._getCustomDrawWrapper(i);
- if (o != null && o.effect)
- return o;
- var s = [];
- this.fillDefines(s, i);
- var c = this._drawWrappers[i];
- c || (c = new DrawWrapper(this._engine),
- c.drawContext && (c.drawContext.useInstancing = !0),
- this._drawWrappers[i] = c);
- var d = s.join(`
- `);
- if (c.defines !== d) {
- var _ = []
- , b = []
- , k = [];
- this.fillUniformsAttributesAndSamplerNames(b, _, k),
- c.setEffect(this._engine.createEffect("gpuRenderParticles", _, b, k, d), d)
- }
- return c
- }
- ,
- e._GetAttributeNamesOrOptions = function(i, o, s, c) {
- i === void 0 && (i = !1),
- o === void 0 && (o = !1),
- s === void 0 && (s = !1),
- c === void 0 && (c = !1);
- var d = [VertexBuffer.PositionKind, "age", "life", "size", "angle"];
- return i || d.push(VertexBuffer.ColorKind),
- o && d.push("cellIndex"),
- s || d.push("initialDirection"),
- c || d.push("direction"),
- d.push("offset", VertexBuffer.UVKind),
- d
- }
- ,
- e._GetEffectCreationOptions = function(i) {
- i === void 0 && (i = !1);
- var o = ["emitterWM", "worldOffset", "view", "projection", "colorDead", "invView", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "translationPivot", "eyePosition"];
- return i && o.push("sheetInfos"),
- o
- }
- ,
- e.prototype.fillDefines = function(i, o) {
- if (o === void 0 && (o = 0),
- this._scene && (this._scene.clipPlane && i.push("#define CLIPPLANE"),
- this._scene.clipPlane2 && i.push("#define CLIPPLANE2"),
- this._scene.clipPlane3 && i.push("#define CLIPPLANE3"),
- this._scene.clipPlane4 && i.push("#define CLIPPLANE4"),
- this._scene.clipPlane5 && i.push("#define CLIPPLANE5"),
- this._scene.clipPlane6 && i.push("#define CLIPPLANE6")),
- o === ParticleSystem.BLENDMODE_MULTIPLY && i.push("#define BLENDMULTIPLYMODE"),
- this.isLocal && i.push("#define LOCAL"),
- this._isBillboardBased)
- switch (i.push("#define BILLBOARD"),
- this.billboardMode) {
- case ParticleSystem.BILLBOARDMODE_Y:
- i.push("#define BILLBOARDY");
- break;
- case ParticleSystem.BILLBOARDMODE_STRETCHED:
- i.push("#define BILLBOARDSTRETCHED");
- break;
- case ParticleSystem.BILLBOARDMODE_ALL:
- i.push("#define BILLBOARDMODE_ALL");
- break
- }
- this._colorGradientsTexture && i.push("#define COLORGRADIENTS"),
- this.isAnimationSheetEnabled && i.push("#define ANIMATESHEET"),
- this._imageProcessingConfiguration && (this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines),
- i.push("" + this._imageProcessingConfigurationDefines.toString()))
- }
- ,
- e.prototype.fillUniformsAttributesAndSamplerNames = function(i, o, s) {
- o.push.apply(o, e._GetAttributeNamesOrOptions(!!this._colorGradientsTexture, this._isAnimationSheetEnabled, this._isBillboardBased, this._isBillboardBased && this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED)),
- i.push.apply(i, e._GetEffectCreationOptions(this._isAnimationSheetEnabled)),
- s.push("diffuseSampler", "colorGradientSampler"),
- this._imageProcessingConfiguration && (ImageProcessingConfiguration.PrepareUniforms(i, this._imageProcessingConfigurationDefines),
- ImageProcessingConfiguration.PrepareSamplers(s, this._imageProcessingConfigurationDefines))
- }
- ,
- e.prototype.animate = function(i) {
- var o;
- i === void 0 && (i = !1),
- this._timeDelta = this.updateSpeed * (i ? this.preWarmStepOffset : ((o = this._scene) === null || o === void 0 ? void 0 : o.getAnimationRatio()) || 1),
- this._actualFrame += this._timeDelta,
- this._stopped || this.targetStopDuration && this._actualFrame >= this.targetStopDuration && this.stop()
- }
- ,
- e.prototype._createFactorGradientTexture = function(i, o) {
- var s = this[o];
- if (!(!i || !i.length || s)) {
- for (var c = new Float32Array(this._rawTextureWidth), d = 0; d < this._rawTextureWidth; d++) {
- var _ = d / this._rawTextureWidth;
- GradientHelper.GetCurrentGradient(_, i, function(b, k, j) {
- c[d] = Scalar.Lerp(b.factor1, k.factor1, j)
- })
- }
- this[o] = RawTexture.CreateRTexture(c, this._rawTextureWidth, 1, this._scene || this._engine, !1, !1, 1)
- }
- }
- ,
- e.prototype._createSizeGradientTexture = function() {
- this._createFactorGradientTexture(this._sizeGradients, "_sizeGradientsTexture")
- }
- ,
- e.prototype._createAngularSpeedGradientTexture = function() {
- this._createFactorGradientTexture(this._angularSpeedGradients, "_angularSpeedGradientsTexture")
- }
- ,
- e.prototype._createVelocityGradientTexture = function() {
- this._createFactorGradientTexture(this._velocityGradients, "_velocityGradientsTexture")
- }
- ,
- e.prototype._createLimitVelocityGradientTexture = function() {
- this._createFactorGradientTexture(this._limitVelocityGradients, "_limitVelocityGradientsTexture")
- }
- ,
- e.prototype._createDragGradientTexture = function() {
- this._createFactorGradientTexture(this._dragGradients, "_dragGradientsTexture")
- }
- ,
- e.prototype._createColorGradientTexture = function() {
- if (!(!this._colorGradients || !this._colorGradients.length || this._colorGradientsTexture)) {
- for (var i = new Uint8Array(this._rawTextureWidth * 4), o = TmpColors.Color4[0], s = 0; s < this._rawTextureWidth; s++) {
- var c = s / this._rawTextureWidth;
- GradientHelper.GetCurrentGradient(c, this._colorGradients, function(d, _, b) {
- Color4.LerpToRef(d.color1, _.color1, b, o),
- i[s * 4] = o.r * 255,
- i[s * 4 + 1] = o.g * 255,
- i[s * 4 + 2] = o.b * 255,
- i[s * 4 + 3] = o.a * 255
- })
- }
- this._colorGradientsTexture = RawTexture.CreateRGBATexture(i, this._rawTextureWidth, 1, this._scene, !1, !1, 1)
- }
- }
- ,
- e.prototype._render = function(i, o) {
- var s, c, d = this._getWrapper(i), _ = d.effect;
- this._engine.enableEffect(d);
- var b = ((s = this._scene) === null || s === void 0 ? void 0 : s.getViewMatrix()) || Matrix.IdentityReadOnly;
- if (_.setMatrix("view", b),
- _.setMatrix("projection", (c = this.defaultProjectionMatrix) !== null && c !== void 0 ? c : this._scene.getProjectionMatrix()),
- _.setTexture("diffuseSampler", this.particleTexture),
- _.setVector2("translationPivot", this.translationPivot),
- _.setVector3("worldOffset", this.worldOffset),
- this.isLocal && _.setMatrix("emitterWM", o),
- this._colorGradientsTexture ? _.setTexture("colorGradientSampler", this._colorGradientsTexture) : _.setDirectColor4("colorDead", this.colorDead),
- this._isAnimationSheetEnabled && this.particleTexture) {
- var k = this.particleTexture.getBaseSize();
- _.setFloat3("sheetInfos", this.spriteCellWidth / k.width, this.spriteCellHeight / k.height, k.width / this.spriteCellWidth)
- }
- if (this._isBillboardBased && this._scene) {
- var j = this._scene.activeCamera;
- _.setVector3("eyePosition", j.globalPosition)
- }
- var $ = _.defines;
- 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),
- $.indexOf("#define BILLBOARDMODE_ALL") >= 0) {
- var _e = b.clone();
- _e.invert(),
- _.setMatrix("invView", _e)
- }
- switch (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess && this._imageProcessingConfiguration.bind(_),
- i) {
- case ParticleSystem.BLENDMODE_ADD:
- this._engine.setAlphaMode(1);
- break;
- case ParticleSystem.BLENDMODE_ONEONE:
- this._engine.setAlphaMode(6);
- break;
- case ParticleSystem.BLENDMODE_STANDARD:
- this._engine.setAlphaMode(2);
- break;
- case ParticleSystem.BLENDMODE_MULTIPLY:
- this._engine.setAlphaMode(4);
- break
- }
- return this._platform.bindDrawBuffers(this._targetIndex, _),
- this._onBeforeDrawParticlesObservable && this._onBeforeDrawParticlesObservable.notifyObservers(_),
- this._engine.drawArraysType(7, 0, 4, this._currentActiveCount),
- this._engine.setAlphaMode(0),
- this._currentActiveCount
- }
- ,
- e.prototype.render = function(i, o) {
- if (i === void 0 && (i = !1),
- o === void 0 && (o = !1),
- !this._started || (this._createColorGradientTexture(),
- this._createSizeGradientTexture(),
- this._createAngularSpeedGradientTexture(),
- this._createVelocityGradientTexture(),
- this._createLimitVelocityGradientTexture(),
- this._createDragGradientTexture(),
- this._recreateUpdateEffect(),
- !this.isReady()))
- return 0;
- if (!i && this._scene) {
- if (!this._preWarmDone && this.preWarmCycles) {
- for (var s = 0; s < this.preWarmCycles; s++)
- this.animate(!0),
- this.render(!0, !0);
- this._preWarmDone = !0
- }
- if (this._currentRenderId === this._scene.getFrameId() && (!this._scene.activeCamera || this._scene.activeCamera && this._currentRenderingCameraUniqueId === this._scene.activeCamera.uniqueId))
- return 0;
- this._currentRenderId = this._scene.getFrameId(),
- this._scene.activeCamera && (this._currentRenderingCameraUniqueId = this._scene.activeCamera.uniqueId)
- }
- if (this._initialize(),
- this._accumulatedCount += this.emitRate * this._timeDelta,
- this._accumulatedCount > 1) {
- var c = this._accumulatedCount | 0;
- this._accumulatedCount -= c,
- this._currentActiveCount = Math.min(this._activeCount, this._currentActiveCount + c)
- }
- if (!this._currentActiveCount)
- return 0;
- var d;
- if (this.emitter.position) {
- var _ = this.emitter;
- d = _.getWorldMatrix()
- } else {
- var b = this.emitter;
- d = Matrix.Translation(b.x, b.y, b.z)
- }
- var k = this._engine;
- this._platform.preUpdateParticleBuffer(),
- this._updateBuffer.setFloat("currentCount", this._currentActiveCount),
- this._updateBuffer.setFloat("timeDelta", this._timeDelta),
- this._updateBuffer.setFloat("stopFactor", this._stopped ? 0 : 1),
- this._updateBuffer.setInt("randomTextureSize", this._randomTextureSize),
- this._updateBuffer.setFloat2("lifeTime", this.minLifeTime, this.maxLifeTime),
- this._updateBuffer.setFloat2("emitPower", this.minEmitPower, this.maxEmitPower),
- this._colorGradientsTexture || (this._updateBuffer.setDirectColor4("color1", this.color1),
- this._updateBuffer.setDirectColor4("color2", this.color2)),
- this._updateBuffer.setFloat2("sizeRange", this.minSize, this.maxSize),
- this._updateBuffer.setFloat4("scaleRange", this.minScaleX, this.maxScaleX, this.minScaleY, this.maxScaleY),
- this._updateBuffer.setFloat4("angleRange", this.minAngularSpeed, this.maxAngularSpeed, this.minInitialRotation, this.maxInitialRotation),
- this._updateBuffer.setVector3("gravity", this.gravity),
- this._limitVelocityGradientsTexture && this._updateBuffer.setFloat("limitVelocityDamping", this.limitVelocityDamping),
- this.particleEmitterType && this.particleEmitterType.applyToShader(this._updateBuffer),
- this._isAnimationSheetEnabled && this._updateBuffer.setFloat4("cellInfos", this.startSpriteCellID, this.endSpriteCellID, this.spriteCellChangeSpeed, this.spriteCellLoop ? 1 : 0),
- this.noiseTexture && this._updateBuffer.setVector3("noiseStrength", this.noiseStrength),
- this.isLocal || this._updateBuffer.setMatrix("emitterWM", d),
- this._platform.updateParticleBuffer(this._targetIndex, this._targetBuffer, this._currentActiveCount);
- var j = 0;
- !i && !o && (k.setState(!1),
- this.forceDepthWrite && k.setDepthWrite(!0),
- this.blendMode === ParticleSystem.BLENDMODE_MULTIPLYADD ? j = this._render(ParticleSystem.BLENDMODE_MULTIPLY, d) + this._render(ParticleSystem.BLENDMODE_ADD, d) : j = this._render(this.blendMode, d),
- this._engine.setAlphaMode(0)),
- this._targetIndex++,
- this._targetIndex === 2 && (this._targetIndex = 0);
- var $ = this._sourceBuffer;
- return this._sourceBuffer = this._targetBuffer,
- this._targetBuffer = $,
- j
- }
- ,
- e.prototype.rebuild = function() {
- this._initialize(!0)
- }
- ,
- e.prototype._releaseBuffers = function() {
- this._buffer0 && (this._buffer0.dispose(),
- this._buffer0 = null),
- this._buffer1 && (this._buffer1.dispose(),
- this._buffer1 = null),
- this._spriteBuffer && (this._spriteBuffer.dispose(),
- this._spriteBuffer = null),
- this._platform.releaseBuffers()
- }
- ,
- e.prototype.dispose = function(i) {
- i === void 0 && (i = !0);
- for (var o in this._drawWrappers) {
- var s = this._drawWrappers[o];
- s.dispose()
- }
- if (this._drawWrappers = {},
- this._scene) {
- var c = this._scene.particleSystems.indexOf(this);
- c > -1 && this._scene.particleSystems.splice(c, 1)
- }
- this._releaseBuffers(),
- this._platform.releaseVertexBuffers(),
- this._colorGradientsTexture && (this._colorGradientsTexture.dispose(),
- this._colorGradientsTexture = null),
- this._sizeGradientsTexture && (this._sizeGradientsTexture.dispose(),
- this._sizeGradientsTexture = null),
- this._angularSpeedGradientsTexture && (this._angularSpeedGradientsTexture.dispose(),
- this._angularSpeedGradientsTexture = null),
- this._velocityGradientsTexture && (this._velocityGradientsTexture.dispose(),
- this._velocityGradientsTexture = null),
- this._limitVelocityGradientsTexture && (this._limitVelocityGradientsTexture.dispose(),
- this._limitVelocityGradientsTexture = null),
- this._dragGradientsTexture && (this._dragGradientsTexture.dispose(),
- this._dragGradientsTexture = null),
- this._randomTexture && (this._randomTexture.dispose(),
- this._randomTexture = null),
- this._randomTexture2 && (this._randomTexture2.dispose(),
- this._randomTexture2 = null),
- i && this.particleTexture && (this.particleTexture.dispose(),
- this.particleTexture = null),
- i && this.noiseTexture && (this.noiseTexture.dispose(),
- this.noiseTexture = null),
- this.onStoppedObservable.clear(),
- this.onDisposeObservable.notifyObservers(this),
- this.onDisposeObservable.clear()
- }
- ,
- e.prototype.clone = function(i, o) {
- var s = __assign({}, this._customWrappers)
- , c = null
- , d = this._engine;
- if (d.createEffectForParticles && this.customShader != null) {
- c = this.customShader;
- var _ = c.shaderOptions.defines.length > 0 ? c.shaderOptions.defines.join(`
- `) : "";
- s[0] = d.createEffectForParticles(c.shaderPath.fragmentElement, c.shaderOptions.uniforms, c.shaderOptions.samplers, _, void 0, void 0, void 0, this)
- }
- var b = this.serialize()
- , k = e.Parse(b, this._scene || this._engine, this._rootUrl);
- return k.name = i,
- k.customShader = c,
- k._customWrappers = s,
- o === void 0 && (o = this.emitter),
- this.noiseTexture && (k.noiseTexture = this.noiseTexture.clone()),
- k.emitter = o,
- k
- }
- ,
- e.prototype.serialize = function(i) {
- i === void 0 && (i = !1);
- var o = {};
- return ParticleSystem._Serialize(o, this, i),
- o.activeParticleCount = this.activeParticleCount,
- o.randomTextureSize = this._randomTextureSize,
- o.customShader = this.customShader,
- o
- }
- ,
- e.Parse = function(i, o, s, c, d) {
- c === void 0 && (c = !1);
- var _ = i.name, b, k;
- o instanceof ThinEngine ? b = o : (k = o,
- b = k.getEngine());
- var j = new e(_,{
- capacity: d || i.capacity,
- randomTextureSize: i.randomTextureSize
- },o,null,i.isAnimationSheetEnabled);
- if (j._rootUrl = s,
- i.customShader && b.createEffectForParticles) {
- var $ = i.customShader
- , _e = $.shaderOptions.defines.length > 0 ? $.shaderOptions.defines.join(`
- `) : ""
- , et = b.createEffectForParticles($.shaderPath.fragmentElement, $.shaderOptions.uniforms, $.shaderOptions.samplers, _e, void 0, void 0, void 0, j);
- j.setCustomEffect(et, 0),
- j.customShader = $
- }
- return i.id && (j.id = i.id),
- i.activeParticleCount && (j.activeParticleCount = i.activeParticleCount),
- ParticleSystem._Parse(i, j, o, s),
- i.preventAutoStart && (j.preventAutoStart = i.preventAutoStart),
- !c && !j.preventAutoStart && j.start(),
- j
- }
- ,
- e
- }(BaseParticleSystem)
- , ParticleSystemSet = function() {
- function a() {
- this._emitterNodeIsOwned = !0,
- this.systems = new Array
- }
- return Object.defineProperty(a.prototype, "emitterNode", {
- get: function() {
- return this._emitterNode
- },
- set: function(e) {
- this._emitterNodeIsOwned && this._emitterNode && (this._emitterNode.dispose && this._emitterNode.dispose(),
- this._emitterNodeIsOwned = !1);
- for (var i = 0, o = this.systems; i < o.length; i++) {
- var s = o[i];
- s.emitter = e
- }
- this._emitterNode = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.setEmitterAsSphere = function(e, i, o) {
- this._emitterNodeIsOwned && this._emitterNode && this._emitterNode.dispose && this._emitterNode.dispose(),
- this._emitterNodeIsOwned = !0,
- this._emitterCreationOptions = {
- kind: "Sphere",
- options: e,
- renderingGroupId: i
- };
- var s = CreateSphere("emitterSphere", {
- diameter: e.diameter,
- segments: e.segments
- }, o);
- s.renderingGroupId = i;
- var c = new StandardMaterial("emitterSphereMaterial",o);
- c.emissiveColor = e.color,
- s.material = c;
- for (var d = 0, _ = this.systems; d < _.length; d++) {
- var b = _[d];
- b.emitter = s
- }
- this._emitterNode = s
- }
- ,
- a.prototype.start = function(e) {
- for (var i = 0, o = this.systems; i < o.length; i++) {
- var s = o[i];
- e && (s.emitter = e),
- s.start()
- }
- }
- ,
- a.prototype.dispose = function() {
- for (var e = 0, i = this.systems; e < i.length; e++) {
- var o = i[e];
- o.dispose()
- }
- this.systems = [],
- this._emitterNode && (this._emitterNode.dispose && this._emitterNode.dispose(),
- this._emitterNode = null)
- }
- ,
- a.prototype.serialize = function(e) {
- e === void 0 && (e = !1);
- var i = {};
- i.systems = [];
- for (var o = 0, s = this.systems; o < s.length; o++) {
- var c = s[o];
- i.systems.push(c.serialize(e))
- }
- return this._emitterNode && (i.emitter = this._emitterCreationOptions),
- i
- }
- ,
- a.Parse = function(e, i, o, s) {
- o === void 0 && (o = !1);
- var c = new a
- , d = this.BaseAssetsUrl + "/textures/";
- i = i || EngineStore.LastCreatedScene;
- for (var _ = 0, b = e.systems; _ < b.length; _++) {
- var k = b[_];
- c.systems.push(o ? GPUParticleSystem.Parse(k, i, d, !0, s) : ParticleSystem.Parse(k, i, d, !0, s))
- }
- if (e.emitter) {
- var j = e.emitter.options;
- switch (e.emitter.kind) {
- case "Sphere":
- c.setEmitterAsSphere({
- diameter: j.diameter,
- segments: j.segments,
- color: Color3.FromArray(j.color)
- }, e.emitter.renderingGroupId, i);
- break
- }
- }
- return c
- }
- ,
- a.BaseAssetsUrl = "https://assets.babylonjs.com/particles",
- a
- }()
- , ProceduralTextureSceneComponent = function() {
- function a(e) {
- this.name = SceneComponentConstants.NAME_PROCEDURALTEXTURE,
- this.scene = e,
- this.scene.proceduralTextures = new Array
- }
- return a.prototype.register = function() {
- this.scene._beforeClearStage.registerStep(SceneComponentConstants.STEP_BEFORECLEAR_PROCEDURALTEXTURE, this, this._beforeClear)
- }
- ,
- a.prototype.rebuild = function() {}
- ,
- a.prototype.dispose = function() {}
- ,
- a.prototype._beforeClear = function() {
- if (this.scene.proceduralTexturesEnabled) {
- Tools.StartPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
- for (var e = 0; e < this.scene.proceduralTextures.length; e++) {
- var i = this.scene.proceduralTextures[e];
- i._shouldRender() && i.render()
- }
- Tools.EndPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0)
- }
- }
- ,
- a
- }()
- , name$1g = "proceduralVertexShader"
- , shader$1g = `
- attribute vec2 position;
- varying vec2 vPosition;
- varying vec2 vUV;
- const vec2 madd=vec2(0.5,0.5);
- void main(void) {
- vPosition=position;
- vUV=position*madd+madd;
- gl_Position=vec4(position,0.0,1.0);
- }`;
- ShaderStore.ShadersStore[name$1g] = shader$1g;
- var ProceduralTexture = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _, b, k) {
- d === void 0 && (d = null),
- _ === void 0 && (_ = !0),
- b === void 0 && (b = !1),
- k === void 0 && (k = 0);
- var j = a.call(this, null, c, !_) || this;
- j.isEnabled = !0,
- j.autoClear = !0,
- j.onGeneratedObservable = new Observable,
- j.onBeforeGenerationObservable = new Observable,
- j.nodeMaterialSource = null,
- j._textures = {},
- j._currentRefreshId = -1,
- j._frameId = -1,
- j._refreshRate = 1,
- j._vertexBuffers = {},
- j._uniforms = new Array,
- j._samplers = new Array,
- j._floats = {},
- j._ints = {},
- j._floatsArrays = {},
- j._colors3 = {},
- j._colors4 = {},
- j._vectors2 = {},
- j._vectors3 = {},
- j._matrices = {},
- j._fallbackTextureUsed = !1,
- j._cachedDefines = null,
- j._contentUpdateId = -1,
- j._rtWrapper = null,
- c = j.getScene() || EngineStore.LastCreatedScene;
- var $ = c._getComponent(SceneComponentConstants.NAME_PROCEDURALTEXTURE);
- $ || ($ = new ProceduralTextureSceneComponent(c),
- c._addComponent($)),
- c.proceduralTextures.push(j),
- j._fullEngine = c.getEngine(),
- j.name = i,
- j.isRenderTarget = !0,
- j._size = o,
- j._textureType = k,
- j._generateMipMaps = _,
- j._drawWrapper = new DrawWrapper(j._fullEngine),
- j.setFragment(s),
- j._fallbackTexture = d,
- b ? (j._rtWrapper = j._fullEngine.createRenderTargetCubeTexture(o, {
- generateMipMaps: _,
- generateDepthBuffer: !1,
- generateStencilBuffer: !1,
- type: k
- }),
- j.setFloat("face", 0)) : j._rtWrapper = j._fullEngine.createRenderTargetTexture(o, {
- generateMipMaps: _,
- generateDepthBuffer: !1,
- generateStencilBuffer: !1,
- type: k
- }),
- j._texture = j._rtWrapper.texture;
- var _e = [];
- return _e.push(1, 1),
- _e.push(-1, 1),
- _e.push(-1, -1),
- _e.push(1, -1),
- j._vertexBuffers[VertexBuffer.PositionKind] = new VertexBuffer(j._fullEngine,_e,VertexBuffer.PositionKind,!1,!1,2),
- j._createIndexBuffer(),
- j
- }
- return e.prototype.getEffect = function() {
- return this._drawWrapper.effect
- }
- ,
- e.prototype._setEffect = function(i) {
- this._drawWrapper.effect = i
- }
- ,
- e.prototype.getContent = function() {
- var i = this;
- return this._contentData && this._frameId === this._contentUpdateId ? this._contentData : (this._contentData ? this._contentData.then(function(o) {
- i._contentData = i.readPixels(0, 0, o),
- i._contentUpdateId = i._frameId
- }) : (this._contentData = this.readPixels(0, 0),
- this._contentUpdateId = this._frameId),
- this._contentData)
- }
- ,
- e.prototype._createIndexBuffer = function() {
- var i = this._fullEngine
- , o = [];
- o.push(0),
- o.push(1),
- o.push(2),
- o.push(0),
- o.push(2),
- o.push(3),
- this._indexBuffer = i.createIndexBuffer(o)
- }
- ,
- e.prototype._rebuild = function() {
- var i = this._vertexBuffers[VertexBuffer.PositionKind];
- i && i._rebuild(),
- this._createIndexBuffer(),
- this.refreshRate === RenderTargetTexture.REFRESHRATE_RENDER_ONCE && (this.refreshRate = RenderTargetTexture.REFRESHRATE_RENDER_ONCE)
- }
- ,
- e.prototype.reset = function() {
- var i;
- (i = this._drawWrapper.effect) === null || i === void 0 || i.dispose()
- }
- ,
- e.prototype._getDefines = function() {
- return ""
- }
- ,
- e.prototype.isReady = function() {
- var i = this, o = this._fullEngine, s;
- if (this.nodeMaterialSource)
- return this._drawWrapper.effect.isReady();
- if (!this._fragment)
- return !1;
- if (this._fallbackTextureUsed)
- return !0;
- var c = this._getDefines();
- return this._drawWrapper.effect && c === this._cachedDefines && this._drawWrapper.effect.isReady() ? !0 : (this._fragment.fragmentElement !== void 0 ? s = {
- vertex: "procedural",
- fragmentElement: this._fragment.fragmentElement
- } : s = {
- vertex: "procedural",
- fragment: this._fragment
- },
- this._cachedDefines !== c && (this._cachedDefines = c,
- this._drawWrapper.effect = o.createEffect(s, [VertexBuffer.PositionKind], this._uniforms, this._samplers, c, void 0, void 0, function() {
- var d;
- (d = i._rtWrapper) === null || d === void 0 || d.dispose(),
- i._rtWrapper = i._texture = null,
- i._fallbackTexture && (i._texture = i._fallbackTexture._texture,
- i._texture && i._texture.incrementReferences()),
- i._fallbackTextureUsed = !0
- })),
- this._drawWrapper.effect.isReady())
- }
- ,
- e.prototype.resetRefreshCounter = function() {
- this._currentRefreshId = -1
- }
- ,
- e.prototype.setFragment = function(i) {
- this._fragment = i
- }
- ,
- Object.defineProperty(e.prototype, "refreshRate", {
- get: function() {
- return this._refreshRate
- },
- set: function(i) {
- this._refreshRate = i,
- this.resetRefreshCounter()
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._shouldRender = function() {
- return !this.isEnabled || !this.isReady() || !this._texture ? (this._texture && (this._texture.isReady = !1),
- !1) : this._fallbackTextureUsed ? !1 : this._currentRefreshId === -1 ? (this._currentRefreshId = 1,
- this._frameId++,
- !0) : this.refreshRate === this._currentRefreshId ? (this._currentRefreshId = 1,
- this._frameId++,
- !0) : (this._currentRefreshId++,
- !1)
- }
- ,
- e.prototype.getRenderSize = function() {
- return this._size
- }
- ,
- e.prototype.resize = function(i, o) {
- var s;
- this._fallbackTextureUsed || ((s = this._rtWrapper) === null || s === void 0 || s.dispose(),
- this._rtWrapper = this._fullEngine.createRenderTargetTexture(i, {
- generateMipMaps: o,
- generateDepthBuffer: !1,
- generateStencilBuffer: !1,
- type: this._textureType
- }),
- this._texture = this._rtWrapper.texture,
- this._size = i,
- this._generateMipMaps = o)
- }
- ,
- e.prototype._checkUniform = function(i) {
- this._uniforms.indexOf(i) === -1 && this._uniforms.push(i)
- }
- ,
- e.prototype.setTexture = function(i, o) {
- return this._samplers.indexOf(i) === -1 && this._samplers.push(i),
- this._textures[i] = o,
- this
- }
- ,
- e.prototype.setFloat = function(i, o) {
- return this._checkUniform(i),
- this._floats[i] = o,
- this
- }
- ,
- e.prototype.setInt = function(i, o) {
- return this._checkUniform(i),
- this._ints[i] = o,
- this
- }
- ,
- e.prototype.setFloats = function(i, o) {
- return this._checkUniform(i),
- this._floatsArrays[i] = o,
- this
- }
- ,
- e.prototype.setColor3 = function(i, o) {
- return this._checkUniform(i),
- this._colors3[i] = o,
- this
- }
- ,
- e.prototype.setColor4 = function(i, o) {
- return this._checkUniform(i),
- this._colors4[i] = o,
- this
- }
- ,
- e.prototype.setVector2 = function(i, o) {
- return this._checkUniform(i),
- this._vectors2[i] = o,
- this
- }
- ,
- e.prototype.setVector3 = function(i, o) {
- return this._checkUniform(i),
- this._vectors3[i] = o,
- this
- }
- ,
- e.prototype.setMatrix = function(i, o) {
- return this._checkUniform(i),
- this._matrices[i] = o,
- this
- }
- ,
- e.prototype.render = function(i) {
- var o, s, c = this.getScene();
- if (!!c) {
- var d = this._fullEngine;
- if (d.enableEffect(this._drawWrapper),
- this.onBeforeGenerationObservable.notifyObservers(this),
- d.setState(!1),
- !this.nodeMaterialSource) {
- for (var _ in this._textures)
- this._drawWrapper.effect.setTexture(_, this._textures[_]);
- for (_ in this._ints)
- this._drawWrapper.effect.setInt(_, this._ints[_]);
- for (_ in this._floats)
- this._drawWrapper.effect.setFloat(_, this._floats[_]);
- for (_ in this._floatsArrays)
- this._drawWrapper.effect.setArray(_, this._floatsArrays[_]);
- for (_ in this._colors3)
- this._drawWrapper.effect.setColor3(_, this._colors3[_]);
- for (_ in this._colors4) {
- var b = this._colors4[_];
- this._drawWrapper.effect.setFloat4(_, b.r, b.g, b.b, b.a)
- }
- for (_ in this._vectors2)
- this._drawWrapper.effect.setVector2(_, this._vectors2[_]);
- for (_ in this._vectors3)
- this._drawWrapper.effect.setVector3(_, this._vectors3[_]);
- for (_ in this._matrices)
- this._drawWrapper.effect.setMatrix(_, this._matrices[_])
- }
- if (!(!this._texture || !this._rtWrapper)) {
- if ((o = d._debugPushGroup) === null || o === void 0 || o.call(d, "procedural texture generation for " + this.name, 1),
- this.isCube)
- for (var k = 0; k < 6; k++)
- d.bindFramebuffer(this._rtWrapper, k, void 0, void 0, !0),
- d.bindBuffers(this._vertexBuffers, this._indexBuffer, this._drawWrapper.effect),
- this._drawWrapper.effect.setFloat("face", k),
- this.autoClear && d.clear(c.clearColor, !0, !1, !1),
- d.drawElementsType(Material.TriangleFillMode, 0, 6);
- else
- d.bindFramebuffer(this._rtWrapper, 0, void 0, void 0, !0),
- d.bindBuffers(this._vertexBuffers, this._indexBuffer, this._drawWrapper.effect),
- this.autoClear && d.clear(c.clearColor, !0, !1, !1),
- d.drawElementsType(Material.TriangleFillMode, 0, 6);
- d.unBindFramebuffer(this._rtWrapper, this.isCube),
- this.isCube && d.generateMipMapsForCubemap(this._texture),
- (s = d._debugPopGroup) === null || s === void 0 || s.call(d, 1),
- this.onGenerated && this.onGenerated(),
- this.onGeneratedObservable.notifyObservers(this)
- }
- }
- }
- ,
- e.prototype.clone = function() {
- var i = this.getSize()
- , o = new e(this.name,i.width,this._fragment,this.getScene(),this._fallbackTexture,this._generateMipMaps);
- return o.hasAlpha = this.hasAlpha,
- o.level = this.level,
- o.coordinatesMode = this.coordinatesMode,
- o
- }
- ,
- e.prototype.dispose = function() {
- var i = this.getScene();
- if (!!i) {
- var o = i.proceduralTextures.indexOf(this);
- o >= 0 && i.proceduralTextures.splice(o, 1);
- var s = this._vertexBuffers[VertexBuffer.PositionKind];
- s && (s.dispose(),
- this._vertexBuffers[VertexBuffer.PositionKind] = null),
- this._indexBuffer && this._fullEngine._releaseBuffer(this._indexBuffer) && (this._indexBuffer = null),
- this.onGeneratedObservable.clear(),
- this.onBeforeGenerationObservable.clear(),
- a.prototype.dispose.call(this)
- }
- }
- ,
- __decorate([serialize()], e.prototype, "isEnabled", void 0),
- __decorate([serialize()], e.prototype, "autoClear", void 0),
- __decorate([serialize()], e.prototype, "_generateMipMaps", void 0),
- __decorate([serialize()], e.prototype, "_size", void 0),
- __decorate([serialize()], e.prototype, "refreshRate", null),
- e
- }(Texture);
- RegisterClass("BABYLON.ProceduralTexture", ProceduralTexture);
- var name$1f = "noisePixelShader"
- , shader$1f = `
- uniform float brightness;
- uniform float persistence;
- uniform float timeScale;
- varying vec2 vUV;
- vec2 hash22(vec2 p)
- {
- p=p*mat2(127.1,311.7,269.5,183.3);
- p=-1.0+2.0*fract(sin(p)*43758.5453123);
- return sin(p*6.283+timeScale);
- }
- float interpolationNoise(vec2 p)
- {
- vec2 pi=floor(p);
- vec2 pf=p-pi;
- vec2 w=pf*pf*(3.-2.*pf);
- float f00=dot(hash22(pi+vec2(.0,.0)),pf-vec2(.0,.0));
- float f01=dot(hash22(pi+vec2(.0,1.)),pf-vec2(.0,1.));
- float f10=dot(hash22(pi+vec2(1.0,0.)),pf-vec2(1.0,0.));
- float f11=dot(hash22(pi+vec2(1.0,1.)),pf-vec2(1.0,1.));
- float xm1=mix(f00,f10,w.x);
- float xm2=mix(f01,f11,w.x);
- float ym=mix(xm1,xm2,w.y);
- return ym;
- }
- float perlinNoise2D(float x,float y)
- {
- float sum=0.0;
- float frequency=0.0;
- float amplitude=0.0;
- for(int i=0; i<OCTAVES; i++)
- {
- frequency=pow(2.0,float(i));
- amplitude=pow(persistence,float(i));
- sum=sum+interpolationNoise(vec2(x*frequency,y*frequency))*amplitude;
- }
- return sum;
- }
- void main(void)
- {
- float x=abs(vUV.x);
- float y=abs(vUV.y);
- float noise=brightness+(1.0-brightness)*perlinNoise2D(x,y);
- gl_FragColor=vec4(noise,noise,noise,1.0);
- }
- `;
- ShaderStore.ShadersStore[name$1f] = shader$1f;
- var NoiseProceduralTexture = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d) {
- o === void 0 && (o = 256),
- s === void 0 && (s = EngineStore.LastCreatedScene);
- var _ = a.call(this, i, o, "noise", s, c, d) || this;
- return _.time = 0,
- _.brightness = .2,
- _.octaves = 3,
- _.persistence = .8,
- _.animationSpeedFactor = 1,
- _.autoClear = !1,
- _._updateShaderUniforms(),
- _
- }
- return e.prototype._updateShaderUniforms = function() {
- var i = this.getScene();
- !i || (this.time += i.getAnimationRatio() * this.animationSpeedFactor * .01,
- this.setFloat("brightness", this.brightness),
- this.setFloat("persistence", this.persistence),
- this.setFloat("timeScale", this.time))
- }
- ,
- e.prototype._getDefines = function() {
- return "#define OCTAVES " + (this.octaves | 0)
- }
- ,
- e.prototype.render = function(i) {
- this._updateShaderUniforms(),
- a.prototype.render.call(this, i)
- }
- ,
- e.prototype.serialize = function() {
- var i = {};
- return i.customType = "BABYLON.NoiseProceduralTexture",
- i.brightness = this.brightness,
- i.octaves = this.octaves,
- i.persistence = this.persistence,
- i.animationSpeedFactor = this.animationSpeedFactor,
- i.size = this.getSize().width,
- i.generateMipMaps = this._generateMipMaps,
- i.time = this.time,
- i
- }
- ,
- e.prototype.clone = function() {
- var i = this.getSize()
- , o = new e(this.name,i.width,this.getScene(),this._fallbackTexture ? this._fallbackTexture : void 0,this._generateMipMaps);
- return o.hasAlpha = this.hasAlpha,
- o.level = this.level,
- o.coordinatesMode = this.coordinatesMode,
- o.brightness = this.brightness,
- o.octaves = this.octaves,
- o.persistence = this.persistence,
- o.animationSpeedFactor = this.animationSpeedFactor,
- o.time = this.time,
- o
- }
- ,
- e.Parse = function(i, o) {
- var s, c = new e(i.name,i.size,o,void 0,i.generateMipMaps);
- return c.brightness = i.brightness,
- c.octaves = i.octaves,
- c.persistence = i.persistence,
- c.animationSpeedFactor = i.animationSpeedFactor,
- c.time = (s = i.time) !== null && s !== void 0 ? s : 0,
- c
- }
- ,
- e
- }(ProceduralTexture);
- RegisterClass("BABYLON.NoiseProceduralTexture", NoiseProceduralTexture);
- var NodeMaterialBlockTargets;
- (function(a) {
- a[a.Vertex = 1] = "Vertex",
- a[a.Fragment = 2] = "Fragment",
- a[a.Neutral = 4] = "Neutral",
- a[a.VertexAndFragment = 3] = "VertexAndFragment"
- }
- )(NodeMaterialBlockTargets || (NodeMaterialBlockTargets = {}));
- var NodeMaterialBlockConnectionPointTypes;
- (function(a) {
- a[a.Float = 1] = "Float",
- a[a.Int = 2] = "Int",
- a[a.Vector2 = 4] = "Vector2",
- a[a.Vector3 = 8] = "Vector3",
- a[a.Vector4 = 16] = "Vector4",
- a[a.Color3 = 32] = "Color3",
- a[a.Color4 = 64] = "Color4",
- a[a.Matrix = 128] = "Matrix",
- a[a.Object = 256] = "Object",
- a[a.AutoDetect = 1024] = "AutoDetect",
- a[a.BasedOnInput = 2048] = "BasedOnInput"
- }
- )(NodeMaterialBlockConnectionPointTypes || (NodeMaterialBlockConnectionPointTypes = {}));
- var NodeMaterialBlockConnectionPointMode;
- (function(a) {
- a[a.Uniform = 0] = "Uniform",
- a[a.Attribute = 1] = "Attribute",
- a[a.Varying = 2] = "Varying",
- a[a.Undefined = 3] = "Undefined"
- }
- )(NodeMaterialBlockConnectionPointMode || (NodeMaterialBlockConnectionPointMode = {}));
- var NodeMaterialSystemValues;
- (function(a) {
- a[a.World = 1] = "World",
- a[a.View = 2] = "View",
- a[a.Projection = 3] = "Projection",
- a[a.ViewProjection = 4] = "ViewProjection",
- a[a.WorldView = 5] = "WorldView",
- a[a.WorldViewProjection = 6] = "WorldViewProjection",
- a[a.CameraPosition = 7] = "CameraPosition",
- a[a.FogColor = 8] = "FogColor",
- a[a.DeltaTime = 9] = "DeltaTime",
- a[a.CameraParameters = 10] = "CameraParameters"
- }
- )(NodeMaterialSystemValues || (NodeMaterialSystemValues = {}));
- var NodeMaterialModes;
- (function(a) {
- a[a.Material = 0] = "Material",
- a[a.PostProcess = 1] = "PostProcess",
- a[a.Particle = 2] = "Particle",
- a[a.ProceduralTexture = 3] = "ProceduralTexture"
- }
- )(NodeMaterialModes || (NodeMaterialModes = {}));
- var NodeMaterialConnectionPointCompatibilityStates;
- (function(a) {
- a[a.Compatible = 0] = "Compatible",
- a[a.TypeIncompatible = 1] = "TypeIncompatible",
- a[a.TargetIncompatible = 2] = "TargetIncompatible",
- a[a.HierarchyIssue = 3] = "HierarchyIssue"
- }
- )(NodeMaterialConnectionPointCompatibilityStates || (NodeMaterialConnectionPointCompatibilityStates = {}));
- var NodeMaterialConnectionPointDirection;
- (function(a) {
- a[a.Input = 0] = "Input",
- a[a.Output = 1] = "Output"
- }
- )(NodeMaterialConnectionPointDirection || (NodeMaterialConnectionPointDirection = {}));
- var NodeMaterialConnectionPoint = function() {
- function a(e, i, o) {
- this._connectedPoint = null,
- this._endpoints = new Array,
- this._typeConnectionSource = null,
- this._defaultConnectionPointType = null,
- this._linkedConnectionSource = null,
- this._acceptedConnectionPointType = null,
- this._type = NodeMaterialBlockConnectionPointTypes.Float,
- this._enforceAssociatedVariableName = !1,
- this.needDualDirectionValidation = !1,
- this.acceptedConnectionPointTypes = new Array,
- this.excludedConnectionPointTypes = new Array,
- this.onConnectionObservable = new Observable,
- this.isExposedOnFrame = !1,
- this.exposedPortPosition = -1,
- this._prioritizeVertex = !1,
- this._target = NodeMaterialBlockTargets.VertexAndFragment,
- this._ownerBlock = i,
- this.name = e,
- this._direction = o
- }
- return a.AreEquivalentTypes = function(e, i) {
- switch (e) {
- case NodeMaterialBlockConnectionPointTypes.Vector3:
- {
- if (i === NodeMaterialBlockConnectionPointTypes.Color3)
- return !0;
- break
- }
- case NodeMaterialBlockConnectionPointTypes.Vector4:
- {
- if (i === NodeMaterialBlockConnectionPointTypes.Color4)
- return !0;
- break
- }
- case NodeMaterialBlockConnectionPointTypes.Color3:
- {
- if (i === NodeMaterialBlockConnectionPointTypes.Vector3)
- return !0;
- break
- }
- case NodeMaterialBlockConnectionPointTypes.Color4:
- {
- if (i === NodeMaterialBlockConnectionPointTypes.Vector4)
- return !0;
- break
- }
- }
- return !1
- }
- ,
- Object.defineProperty(a.prototype, "direction", {
- get: function() {
- return this._direction
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "associatedVariableName", {
- get: function() {
- return this._ownerBlock.isInput ? this._ownerBlock.associatedVariableName : (!this._enforceAssociatedVariableName || !this._associatedVariableName) && this._connectedPoint ? this._connectedPoint.associatedVariableName : this._associatedVariableName
- },
- set: function(e) {
- this._associatedVariableName = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "innerType", {
- get: function() {
- return this._linkedConnectionSource && this._linkedConnectionSource.isConnected ? this.type : this._type
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "type", {
- get: function() {
- if (this._type === NodeMaterialBlockConnectionPointTypes.AutoDetect) {
- if (this._ownerBlock.isInput)
- return this._ownerBlock.type;
- if (this._connectedPoint)
- return this._connectedPoint.type;
- if (this._linkedConnectionSource && this._linkedConnectionSource.isConnected)
- return this._linkedConnectionSource.type
- }
- if (this._type === NodeMaterialBlockConnectionPointTypes.BasedOnInput) {
- if (this._typeConnectionSource)
- return !this._typeConnectionSource.isConnected && this._defaultConnectionPointType ? this._defaultConnectionPointType : this._typeConnectionSource.type;
- if (this._defaultConnectionPointType)
- return this._defaultConnectionPointType
- }
- return this._type
- },
- set: function(e) {
- this._type = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "target", {
- get: function() {
- return !this._prioritizeVertex || !this._ownerBlock ? this._target : this._target !== NodeMaterialBlockTargets.VertexAndFragment ? this._target : this._ownerBlock.target === NodeMaterialBlockTargets.Fragment ? NodeMaterialBlockTargets.Fragment : NodeMaterialBlockTargets.Vertex
- },
- set: function(e) {
- this._target = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "isConnected", {
- get: function() {
- return this.connectedPoint !== null || this.hasEndpoints
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "isConnectedToInputBlock", {
- get: function() {
- return this.connectedPoint !== null && this.connectedPoint.ownerBlock.isInput
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "connectInputBlock", {
- get: function() {
- return this.isConnectedToInputBlock ? this.connectedPoint.ownerBlock : null
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "connectedPoint", {
- get: function() {
- return this._connectedPoint
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "ownerBlock", {
- get: function() {
- return this._ownerBlock
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "sourceBlock", {
- get: function() {
- return this._connectedPoint ? this._connectedPoint.ownerBlock : null
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "connectedBlocks", {
- get: function() {
- return this._endpoints.length === 0 ? [] : this._endpoints.map(function(e) {
- return e.ownerBlock
- })
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "endpoints", {
- get: function() {
- return this._endpoints
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "hasEndpoints", {
- get: function() {
- return this._endpoints && this._endpoints.length > 0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "isDirectlyConnectedToVertexOutput", {
- get: function() {
- if (!this.hasEndpoints)
- return !1;
- for (var e = 0, i = this._endpoints; e < i.length; e++) {
- var o = i[e];
- if (o.ownerBlock.target === NodeMaterialBlockTargets.Vertex || (o.ownerBlock.target === NodeMaterialBlockTargets.Neutral || o.ownerBlock.target === NodeMaterialBlockTargets.VertexAndFragment) && o.ownerBlock.outputs.some(function(s) {
- return s.isDirectlyConnectedToVertexOutput
- }))
- return !0
- }
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "isConnectedInVertexShader", {
- get: function() {
- if (this.target === NodeMaterialBlockTargets.Vertex)
- return !0;
- if (!this.hasEndpoints)
- return !1;
- for (var e = 0, i = this._endpoints; e < i.length; e++) {
- var o = i[e];
- 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) {
- return s.isConnectedInVertexShader
- }))
- return !0
- }
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "isConnectedInFragmentShader", {
- get: function() {
- if (this.target === NodeMaterialBlockTargets.Fragment)
- return !0;
- if (!this.hasEndpoints)
- return !1;
- for (var e = 0, i = this._endpoints; e < i.length; e++) {
- var o = i[e];
- if (o.ownerBlock.target === NodeMaterialBlockTargets.Fragment || (o.ownerBlock.target === NodeMaterialBlockTargets.Neutral || o.ownerBlock.target === NodeMaterialBlockTargets.VertexAndFragment) && o.ownerBlock.outputs.some(function(s) {
- return s.isConnectedInFragmentShader
- }))
- return !0
- }
- return !1
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.createCustomInputBlock = function() {
- return null
- }
- ,
- a.prototype.getClassName = function() {
- return "NodeMaterialConnectionPoint"
- }
- ,
- a.prototype.canConnectTo = function(e) {
- return this.checkCompatibilityState(e) === NodeMaterialConnectionPointCompatibilityStates.Compatible
- }
- ,
- a.prototype.checkCompatibilityState = function(e) {
- var i = this._ownerBlock
- , o = e.ownerBlock;
- if (i.target === NodeMaterialBlockTargets.Fragment) {
- if (o.target === NodeMaterialBlockTargets.Vertex)
- return NodeMaterialConnectionPointCompatibilityStates.TargetIncompatible;
- for (var s = 0, c = o.outputs; s < c.length; s++) {
- var d = c[s];
- if (d.ownerBlock.target != NodeMaterialBlockTargets.Neutral && d.isConnectedInVertexShader)
- return NodeMaterialConnectionPointCompatibilityStates.TargetIncompatible
- }
- }
- if (this.type !== e.type && e.innerType !== NodeMaterialBlockConnectionPointTypes.AutoDetect)
- 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;
- if (e.excludedConnectionPointTypes && e.excludedConnectionPointTypes.indexOf(this.type) !== -1)
- return NodeMaterialConnectionPointCompatibilityStates.TypeIncompatible;
- var _ = o
- , b = i;
- return this.direction === NodeMaterialConnectionPointDirection.Input && (_ = i,
- b = o),
- _.isAnAncestorOf(b) ? NodeMaterialConnectionPointCompatibilityStates.HierarchyIssue : NodeMaterialConnectionPointCompatibilityStates.Compatible
- }
- ,
- a.prototype.connectTo = function(e, i) {
- if (i === void 0 && (i = !1),
- !i && !this.canConnectTo(e))
- throw "Cannot connect these two connectors.";
- return this._endpoints.push(e),
- e._connectedPoint = this,
- this._enforceAssociatedVariableName = !1,
- this.onConnectionObservable.notifyObservers(e),
- e.onConnectionObservable.notifyObservers(this),
- this
- }
- ,
- a.prototype.disconnectFrom = function(e) {
- var i = this._endpoints.indexOf(e);
- return i === -1 ? this : (this._endpoints.splice(i, 1),
- e._connectedPoint = null,
- this._enforceAssociatedVariableName = !1,
- e._enforceAssociatedVariableName = !1,
- this)
- }
- ,
- a.prototype.serialize = function(e) {
- e === void 0 && (e = !0);
- var i = {};
- return i.name = this.name,
- i.displayName = this.displayName,
- e && this.connectedPoint && (i.inputName = this.name,
- i.targetBlockId = this.connectedPoint.ownerBlock.uniqueId,
- i.targetConnectionName = this.connectedPoint.name,
- i.isExposedOnFrame = !0,
- i.exposedPortPosition = this.exposedPortPosition),
- (this.isExposedOnFrame || this.exposedPortPosition >= 0) && (i.isExposedOnFrame = !0,
- i.exposedPortPosition = this.exposedPortPosition),
- i
- }
- ,
- a.prototype.dispose = function() {
- this.onConnectionObservable.clear()
- }
- ,
- a
- }()
- , NodeMaterialBlock = function() {
- function a(e, i, o, s) {
- i === void 0 && (i = NodeMaterialBlockTargets.Vertex),
- o === void 0 && (o = !1),
- s === void 0 && (s = !1),
- this._isFinalMerger = !1,
- this._isInput = !1,
- this._name = "",
- this._isUnique = !1,
- this.inputsAreExclusive = !1,
- this._codeVariableName = "",
- this._inputs = new Array,
- this._outputs = new Array,
- this.comments = "",
- this.visibleInInspector = !1,
- this.visibleOnFrame = !1,
- this._target = i,
- this._originalTargetIsNeutral = i === NodeMaterialBlockTargets.Neutral,
- this._isFinalMerger = o,
- this._isInput = s,
- this._name = e,
- this.uniqueId = UniqueIdGenerator.UniqueId
- }
- return Object.defineProperty(a.prototype, "name", {
- get: function() {
- return this._name
- },
- set: function(e) {
- !this.validateBlockName(e) || (this._name = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "isUnique", {
- get: function() {
- return this._isUnique
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "isFinalMerger", {
- get: function() {
- return this._isFinalMerger
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "isInput", {
- get: function() {
- return this._isInput
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "buildId", {
- get: function() {
- return this._buildId
- },
- set: function(e) {
- this._buildId = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "target", {
- get: function() {
- return this._target
- },
- set: function(e) {
- (this._target & e) === 0 && (this._target = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "inputs", {
- get: function() {
- return this._inputs
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "outputs", {
- get: function() {
- return this._outputs
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.getInputByName = function(e) {
- var i = this._inputs.filter(function(o) {
- return o.name === e
- });
- return i.length ? i[0] : null
- }
- ,
- a.prototype.getOutputByName = function(e) {
- var i = this._outputs.filter(function(o) {
- return o.name === e
- });
- return i.length ? i[0] : null
- }
- ,
- a.prototype.initialize = function(e) {}
- ,
- a.prototype.bind = function(e, i, o, s) {}
- ,
- a.prototype._declareOutput = function(e, i) {
- return i._getGLType(e.type) + " " + e.associatedVariableName
- }
- ,
- a.prototype._writeVariable = function(e) {
- var i = e.connectedPoint;
- return i ? "" + e.associatedVariableName : "0."
- }
- ,
- a.prototype._writeFloat = function(e) {
- var i = e.toString();
- return i.indexOf(".") === -1 && (i += ".0"),
- "" + i
- }
- ,
- a.prototype.getClassName = function() {
- return "NodeMaterialBlock"
- }
- ,
- a.prototype.registerInput = function(e, i, o, s, c) {
- return o === void 0 && (o = !1),
- c = c != null ? c : new NodeMaterialConnectionPoint(e,this,NodeMaterialConnectionPointDirection.Input),
- c.type = i,
- c.isOptional = o,
- s && (c.target = s),
- this._inputs.push(c),
- this
- }
- ,
- a.prototype.registerOutput = function(e, i, o, s) {
- return s = s != null ? s : new NodeMaterialConnectionPoint(e,this,NodeMaterialConnectionPointDirection.Output),
- s.type = i,
- o && (s.target = o),
- this._outputs.push(s),
- this
- }
- ,
- a.prototype.getFirstAvailableInput = function(e) {
- e === void 0 && (e = null);
- for (var i = 0, o = this._inputs; i < o.length; i++) {
- var s = o[i];
- if (!s.connectedPoint && (!e || e.type === s.type || s.type === NodeMaterialBlockConnectionPointTypes.AutoDetect))
- return s
- }
- return null
- }
- ,
- a.prototype.getFirstAvailableOutput = function(e) {
- e === void 0 && (e = null);
- for (var i = 0, o = this._outputs; i < o.length; i++) {
- var s = o[i];
- if (!e || !e.target || e.target === NodeMaterialBlockTargets.Neutral || (e.target & s.target) !== 0)
- return s
- }
- return null
- }
- ,
- a.prototype.getSiblingOutput = function(e) {
- var i = this._outputs.indexOf(e);
- return i === -1 || i >= this._outputs.length ? null : this._outputs[i + 1]
- }
- ,
- a.prototype.isAnAncestorOf = function(e) {
- for (var i = 0, o = this._outputs; i < o.length; i++) {
- var s = o[i];
- if (!!s.hasEndpoints)
- for (var c = 0, d = s.endpoints; c < d.length; c++) {
- var _ = d[c];
- if (_.ownerBlock === e || _.ownerBlock.isAnAncestorOf(e))
- return !0
- }
- }
- return !1
- }
- ,
- a.prototype.connectTo = function(e, i) {
- if (this._outputs.length !== 0) {
- for (var o = i && i.output ? this.getOutputByName(i.output) : this.getFirstAvailableOutput(e), s = !0; s; ) {
- var c = i && i.input ? e.getInputByName(i.input) : e.getFirstAvailableInput(o);
- if (o && c && o.canConnectTo(c))
- o.connectTo(c),
- s = !1;
- else if (o)
- o = this.getSiblingOutput(o);
- else
- throw "Unable to find a compatible match"
- }
- return this
- }
- }
- ,
- a.prototype._buildBlock = function(e) {}
- ,
- a.prototype.updateUniformsAndSamples = function(e, i, o, s) {}
- ,
- a.prototype.provideFallbacks = function(e, i) {}
- ,
- a.prototype.initializeDefines = function(e, i, o, s) {}
- ,
- a.prototype.prepareDefines = function(e, i, o, s, c) {}
- ,
- a.prototype.autoConfigure = function(e) {}
- ,
- a.prototype.replaceRepeatableContent = function(e, i, o, s) {}
- ,
- Object.defineProperty(a.prototype, "willBeGeneratedIntoVertexShaderFromFragmentShader", {
- get: function() {
- return this.isInput || this.isFinalMerger || this._outputs.some(function(e) {
- return e.isDirectlyConnectedToVertexOutput
- }) ? !1 : !!(this.target === NodeMaterialBlockTargets.Vertex || (this.target === NodeMaterialBlockTargets.VertexAndFragment || this.target === NodeMaterialBlockTargets.Neutral) && this._outputs.some(function(e) {
- return e.isConnectedInVertexShader
- }))
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.isReady = function(e, i, o, s) {
- return !0
- }
- ,
- a.prototype._linkConnectionTypes = function(e, i, o) {
- o === void 0 && (o = !1),
- o ? this._inputs[i]._acceptedConnectionPointType = this._inputs[e] : this._inputs[e]._linkedConnectionSource = this._inputs[i],
- this._inputs[i]._linkedConnectionSource = this._inputs[e]
- }
- ,
- a.prototype._processBuild = function(e, i, o, s) {
- e.build(i, s);
- var c = i._vertexState != null
- , d = e._buildTarget === NodeMaterialBlockTargets.Vertex && e.target !== NodeMaterialBlockTargets.VertexAndFragment;
- 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)) {
- var _ = o.connectedPoint;
- i._vertexState._emitVaryingFromString("v_" + _.associatedVariableName, i._getGLType(_.type)) && (i._vertexState.compilationString += "v_" + _.associatedVariableName + " = " + _.associatedVariableName + `;\r
- `),
- o.associatedVariableName = "v_" + _.associatedVariableName,
- o._enforceAssociatedVariableName = !0
- }
- }
- ,
- a.prototype.validateBlockName = function(e) {
- 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++) {
- var c = s[o];
- if (e === c)
- return !1
- }
- return !0
- }
- ,
- a.prototype.build = function(e, i) {
- if (this._buildId === e.sharedData.buildId)
- return !0;
- if (!this.isInput)
- for (var o = 0, s = this._outputs; o < s.length; o++) {
- var c = s[o];
- c.associatedVariableName || (c.associatedVariableName = e._getFreeVariableName(c.name))
- }
- for (var d = 0, _ = this._inputs; d < _.length; d++) {
- var b = _[d];
- if (!b.connectedPoint) {
- b.isOptional || e.sharedData.checks.notConnectedNonOptionalInputs.push(b);
- continue
- }
- if (!(this.target !== NodeMaterialBlockTargets.Neutral && ((b.target & this.target) === 0 || (b.target & e.target) === 0))) {
- var k = b.connectedPoint.ownerBlock;
- k && k !== this && this._processBuild(k, e, b, i)
- }
- }
- if (this._buildId === e.sharedData.buildId)
- return !0;
- if (e.sharedData.verbose && console.log((e.target === NodeMaterialBlockTargets.Vertex ? "Vertex shader" : "Fragment shader") + ": Building " + this.name + " [" + this.getClassName() + "]"),
- this.isFinalMerger)
- switch (e.target) {
- case NodeMaterialBlockTargets.Vertex:
- e.sharedData.checks.emitVertex = !0;
- break;
- case NodeMaterialBlockTargets.Fragment:
- e.sharedData.checks.emitFragment = !0;
- break
- }
- !this.isInput && e.sharedData.emitComments && (e.compilationString += `\r
- //` + this.name + `\r
- `),
- this._buildBlock(e),
- this._buildId = e.sharedData.buildId,
- this._buildTarget = e.target;
- for (var j = 0, $ = this._outputs; j < $.length; j++) {
- var c = $[j];
- if ((c.target & e.target) !== 0)
- for (var _e = 0, et = c.endpoints; _e < et.length; _e++) {
- var tt = et[_e]
- , k = tt.ownerBlock;
- k && (k.target & e.target) !== 0 && i.indexOf(k) !== -1 && this._processBuild(k, e, tt, i)
- }
- }
- return !1
- }
- ,
- a.prototype._inputRename = function(e) {
- return e
- }
- ,
- a.prototype._outputRename = function(e) {
- return e
- }
- ,
- a.prototype._dumpPropertiesCode = function() {
- var e = this._codeVariableName;
- return e + ".visibleInInspector = " + this.visibleInInspector + `;\r
- ` + e + ".visibleOnFrame = " + this.visibleOnFrame + `;\r
- ` + e + ".target = " + this.target + `;\r
- `
- }
- ,
- a.prototype._dumpCode = function(e, i) {
- i.push(this);
- var o, s = this.name.replace(/[^A-Za-z_]+/g, "");
- if (this._codeVariableName = s || this.getClassName() + "_" + this.uniqueId,
- e.indexOf(this._codeVariableName) !== -1) {
- var c = 0;
- do
- c++,
- this._codeVariableName = s + c;
- while (e.indexOf(this._codeVariableName) !== -1)
- }
- e.push(this._codeVariableName),
- o = `\r
- // ` + this.getClassName() + `\r
- `,
- this.comments && (o += "// " + this.comments + `\r
- `),
- o += "var " + this._codeVariableName + " = new BABYLON." + this.getClassName() + '("' + this.name + `");\r
- `,
- o += this._dumpPropertiesCode();
- for (var d = 0, _ = this.inputs; d < _.length; d++) {
- var b = _[d];
- if (!!b.isConnected) {
- var k = b.connectedPoint
- , j = k.ownerBlock;
- i.indexOf(j) === -1 && (o += j._dumpCode(e, i))
- }
- }
- for (var $ = 0, _e = this.outputs; $ < _e.length; $++) {
- var et = _e[$];
- if (!!et.hasEndpoints)
- for (var tt = 0, rt = et.endpoints; tt < rt.length; tt++) {
- var it = rt[tt]
- , j = it.ownerBlock;
- j && i.indexOf(j) === -1 && (o += j._dumpCode(e, i))
- }
- }
- return o
- }
- ,
- a.prototype._dumpCodeForOutputConnections = function(e) {
- var i = "";
- if (e.indexOf(this) !== -1)
- return i;
- e.push(this);
- for (var o = 0, s = this.inputs; o < s.length; o++) {
- var c = s[o];
- if (!!c.isConnected) {
- var d = c.connectedPoint
- , _ = d.ownerBlock;
- i += _._dumpCodeForOutputConnections(e),
- i += _._codeVariableName + "." + _._outputRename(d.name) + ".connectTo(" + this._codeVariableName + "." + this._inputRename(c.name) + `);\r
- `
- }
- }
- return i
- }
- ,
- a.prototype.clone = function(e, i) {
- i === void 0 && (i = "");
- var o = this.serialize()
- , s = GetClass(o.customType);
- if (s) {
- var c = new s;
- return c._deserialize(o, e, i),
- c
- }
- return null
- }
- ,
- a.prototype.serialize = function() {
- var e = {};
- e.customType = "BABYLON." + this.getClassName(),
- e.id = this.uniqueId,
- e.name = this.name,
- e.comments = this.comments,
- e.visibleInInspector = this.visibleInInspector,
- e.visibleOnFrame = this.visibleOnFrame,
- e.target = this.target,
- e.inputs = [],
- e.outputs = [];
- for (var i = 0, o = this.inputs; i < o.length; i++) {
- var s = o[i];
- e.inputs.push(s.serialize())
- }
- for (var c = 0, d = this.outputs; c < d.length; c++) {
- var _ = d[c];
- e.outputs.push(_.serialize(!1))
- }
- return e
- }
- ,
- a.prototype._deserialize = function(e, i, o) {
- var s;
- this.name = e.name,
- this.comments = e.comments,
- this.visibleInInspector = !!e.visibleInInspector,
- this.visibleOnFrame = !!e.visibleOnFrame,
- this._target = (s = e.target) !== null && s !== void 0 ? s : this.target,
- this._deserializePortDisplayNamesAndExposedOnFrame(e)
- }
- ,
- a.prototype._deserializePortDisplayNamesAndExposedOnFrame = function(e) {
- var i = this
- , o = e.inputs
- , s = e.outputs;
- o && o.forEach(function(c, d) {
- c.displayName && (i.inputs[d].displayName = c.displayName),
- c.isExposedOnFrame && (i.inputs[d].isExposedOnFrame = c.isExposedOnFrame,
- i.inputs[d].exposedPortPosition = c.exposedPortPosition)
- }),
- s && s.forEach(function(c, d) {
- c.displayName && (i.outputs[d].displayName = c.displayName),
- c.isExposedOnFrame && (i.outputs[d].isExposedOnFrame = c.isExposedOnFrame,
- i.outputs[d].exposedPortPosition = c.exposedPortPosition)
- })
- }
- ,
- a.prototype.dispose = function() {
- for (var e = 0, i = this.inputs; e < i.length; e++) {
- var o = i[e];
- o.dispose()
- }
- for (var s = 0, c = this.outputs; s < c.length; s++) {
- var d = c[s];
- d.dispose()
- }
- }
- ,
- a
- }()
- , NodeMaterialBuildState = function() {
- function a() {
- this.supportUniformBuffers = !1,
- this.attributes = new Array,
- this.uniforms = new Array,
- this.constants = new Array,
- this.samplers = new Array,
- this.functions = {},
- this.extensions = {},
- this.counters = {},
- this._attributeDeclaration = "",
- this._uniformDeclaration = "",
- this._constantDeclaration = "",
- this._samplerDeclaration = "",
- this._varyingTransfer = "",
- this._injectAtEnd = "",
- this._repeatableContentAnchorIndex = 0,
- this._builtCompilationString = "",
- this.compilationString = ""
- }
- return a.prototype.finalize = function(e) {
- var i = e.sharedData.emitComments
- , o = this.target === NodeMaterialBlockTargets.Fragment;
- this.compilationString = `\r
- ` + (i ? `//Entry point\r
- ` : "") + `void main(void) {\r
- ` + this.compilationString,
- this._constantDeclaration && (this.compilationString = `\r
- ` + (i ? `//Constants\r
- ` : "") + this._constantDeclaration + `\r
- ` + this.compilationString);
- var s = "";
- for (var c in this.functions)
- s += this.functions[c] + `\r
- `;
- this.compilationString = `\r
- ` + s + `\r
- ` + this.compilationString,
- !o && this._varyingTransfer && (this.compilationString = this.compilationString + `\r
- ` + this._varyingTransfer),
- this._injectAtEnd && (this.compilationString = this.compilationString + `\r
- ` + this._injectAtEnd),
- this.compilationString = this.compilationString + `\r
- }`,
- this.sharedData.varyingDeclaration && (this.compilationString = `\r
- ` + (i ? `//Varyings\r
- ` : "") + this.sharedData.varyingDeclaration + `\r
- ` + this.compilationString),
- this._samplerDeclaration && (this.compilationString = `\r
- ` + (i ? `//Samplers\r
- ` : "") + this._samplerDeclaration + `\r
- ` + this.compilationString),
- this._uniformDeclaration && (this.compilationString = `\r
- ` + (i ? `//Uniforms\r
- ` : "") + this._uniformDeclaration + `\r
- ` + this.compilationString),
- this._attributeDeclaration && !o && (this.compilationString = `\r
- ` + (i ? `//Attributes\r
- ` : "") + this._attributeDeclaration + `\r
- ` + this.compilationString),
- this.compilationString = `precision highp float;\r
- ` + this.compilationString;
- for (var d in this.extensions) {
- var _ = this.extensions[d];
- this.compilationString = `\r
- ` + _ + `\r
- ` + this.compilationString
- }
- this._builtCompilationString = this.compilationString
- }
- ,
- Object.defineProperty(a.prototype, "_repeatableContentAnchor", {
- get: function() {
- return "###___ANCHOR" + this._repeatableContentAnchorIndex++ + "___###"
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._getFreeVariableName = function(e) {
- return e = e.replace(/[^a-zA-Z_]+/g, ""),
- this.sharedData.variableNames[e] === void 0 ? (this.sharedData.variableNames[e] = 0,
- e === "output" || e === "texture" ? e + this.sharedData.variableNames[e] : e) : (this.sharedData.variableNames[e]++,
- e + this.sharedData.variableNames[e])
- }
- ,
- a.prototype._getFreeDefineName = function(e) {
- return this.sharedData.defineNames[e] === void 0 ? this.sharedData.defineNames[e] = 0 : this.sharedData.defineNames[e]++,
- e + this.sharedData.defineNames[e]
- }
- ,
- a.prototype._excludeVariableName = function(e) {
- this.sharedData.variableNames[e] = 0
- }
- ,
- a.prototype._emit2DSampler = function(e) {
- this.samplers.indexOf(e) < 0 && (this._samplerDeclaration += "uniform sampler2D " + e + `;\r
- `,
- this.samplers.push(e))
- }
- ,
- a.prototype._getGLType = function(e) {
- switch (e) {
- case NodeMaterialBlockConnectionPointTypes.Float:
- return "float";
- case NodeMaterialBlockConnectionPointTypes.Int:
- return "int";
- case NodeMaterialBlockConnectionPointTypes.Vector2:
- return "vec2";
- case NodeMaterialBlockConnectionPointTypes.Color3:
- case NodeMaterialBlockConnectionPointTypes.Vector3:
- return "vec3";
- case NodeMaterialBlockConnectionPointTypes.Color4:
- case NodeMaterialBlockConnectionPointTypes.Vector4:
- return "vec4";
- case NodeMaterialBlockConnectionPointTypes.Matrix:
- return "mat4"
- }
- return ""
- }
- ,
- a.prototype._emitExtension = function(e, i, o) {
- o === void 0 && (o = ""),
- !this.extensions[e] && (o && (i = "#if " + o + `\r
- ` + i + `\r
- #endif`),
- this.extensions[e] = i)
- }
- ,
- a.prototype._emitFunction = function(e, i, o) {
- this.functions[e] || (this.sharedData.emitComments && (i = o + `\r
- ` + i),
- this.functions[e] = i)
- }
- ,
- a.prototype._emitCodeFromInclude = function(e, i, o) {
- if (o && o.repeatKey)
- return "#include<" + e + ">[0.." + o.repeatKey + `]\r
- `;
- var s = Effect.IncludesShadersStore[e] + `\r
- `;
- if (this.sharedData.emitComments && (s = i + `\r
- ` + s),
- !o)
- return s;
- if (o.replaceStrings)
- for (var c = 0; c < o.replaceStrings.length; c++) {
- var d = o.replaceStrings[c];
- s = s.replace(d.search, d.replace)
- }
- return s
- }
- ,
- a.prototype._emitFunctionFromInclude = function(e, i, o, s) {
- s === void 0 && (s = "");
- var c = e + s;
- if (!this.functions[c]) {
- if (!o || !o.removeAttributes && !o.removeUniforms && !o.removeVaryings && !o.removeIfDef && !o.replaceStrings) {
- o && o.repeatKey ? this.functions[c] = "#include<" + e + ">[0.." + o.repeatKey + `]\r
- ` : this.functions[c] = "#include<" + e + `>\r
- `,
- this.sharedData.emitComments && (this.functions[c] = i + `\r
- ` + this.functions[c]);
- return
- }
- if (this.functions[c] = Effect.IncludesShadersStore[e],
- this.sharedData.emitComments && (this.functions[c] = i + `\r
- ` + this.functions[c]),
- o.removeIfDef && (this.functions[c] = this.functions[c].replace(/^\s*?#ifdef.+$/gm, ""),
- this.functions[c] = this.functions[c].replace(/^\s*?#endif.*$/gm, ""),
- this.functions[c] = this.functions[c].replace(/^\s*?#else.*$/gm, ""),
- this.functions[c] = this.functions[c].replace(/^\s*?#elif.*$/gm, "")),
- o.removeAttributes && (this.functions[c] = this.functions[c].replace(/^\s*?attribute.+$/gm, "")),
- o.removeUniforms && (this.functions[c] = this.functions[c].replace(/^\s*?uniform.+$/gm, "")),
- o.removeVaryings && (this.functions[c] = this.functions[c].replace(/^\s*?varying.+$/gm, "")),
- o.replaceStrings)
- for (var d = 0; d < o.replaceStrings.length; d++) {
- var _ = o.replaceStrings[d];
- this.functions[c] = this.functions[c].replace(_.search, _.replace)
- }
- }
- }
- ,
- a.prototype._registerTempVariable = function(e) {
- return this.sharedData.temps.indexOf(e) !== -1 ? !1 : (this.sharedData.temps.push(e),
- !0)
- }
- ,
- a.prototype._emitVaryingFromString = function(e, i, o, s) {
- return o === void 0 && (o = ""),
- s === void 0 && (s = !1),
- this.sharedData.varyings.indexOf(e) !== -1 ? !1 : (this.sharedData.varyings.push(e),
- o && (StartsWith(o, "defined(") ? this.sharedData.varyingDeclaration += "#if " + o + `\r
- ` : this.sharedData.varyingDeclaration += (s ? "#ifndef" : "#ifdef") + " " + o + `\r
- `),
- this.sharedData.varyingDeclaration += "varying " + i + " " + e + `;\r
- `,
- o && (this.sharedData.varyingDeclaration += `#endif\r
- `),
- !0)
- }
- ,
- a.prototype._emitUniformFromString = function(e, i, o, s) {
- o === void 0 && (o = ""),
- s === void 0 && (s = !1),
- this.uniforms.indexOf(e) === -1 && (this.uniforms.push(e),
- o && (StartsWith(o, "defined(") ? this._uniformDeclaration += "#if " + o + `\r
- ` : this._uniformDeclaration += (s ? "#ifndef" : "#ifdef") + " " + o + `\r
- `),
- this._uniformDeclaration += "uniform " + i + " " + e + `;\r
- `,
- o && (this._uniformDeclaration += `#endif\r
- `))
- }
- ,
- a.prototype._emitFloat = function(e) {
- return e.toString() === e.toFixed(0) ? e + ".0" : e.toString()
- }
- ,
- a
- }()
- , NodeMaterialBuildStateSharedData = function() {
- function a() {
- this.temps = new Array,
- this.varyings = new Array,
- this.varyingDeclaration = "",
- this.inputBlocks = new Array,
- this.textureBlocks = new Array,
- this.bindableBlocks = new Array,
- this.forcedBindableBlocks = new Array,
- this.blocksWithFallbacks = new Array,
- this.blocksWithDefines = new Array,
- this.repeatableContentBlocks = new Array,
- this.dynamicUniformBlocks = new Array,
- this.blockingBlocks = new Array,
- this.animatedInputs = new Array,
- this.variableNames = {},
- this.defineNames = {},
- this.hints = {
- needWorldViewMatrix: !1,
- needWorldViewProjectionMatrix: !1,
- needAlphaBlending: !1,
- needAlphaTesting: !1
- },
- this.checks = {
- emitVertex: !1,
- emitFragment: !1,
- notConnectedNonOptionalInputs: new Array
- },
- this.allowEmptyVertexProgram = !1,
- this.variableNames.position = 0,
- this.variableNames.normal = 0,
- this.variableNames.tangent = 0,
- this.variableNames.uv = 0,
- this.variableNames.uv2 = 0,
- this.variableNames.uv3 = 0,
- this.variableNames.uv4 = 0,
- this.variableNames.uv5 = 0,
- this.variableNames.uv6 = 0,
- this.variableNames.color = 0,
- this.variableNames.matricesIndices = 0,
- this.variableNames.matricesWeights = 0,
- this.variableNames.matricesIndicesExtra = 0,
- this.variableNames.matricesWeightsExtra = 0,
- this.variableNames.diffuseBase = 0,
- this.variableNames.specularBase = 0,
- this.variableNames.worldPos = 0,
- this.variableNames.shadow = 0,
- this.variableNames.view = 0,
- this.variableNames.vTBN = 0,
- this.defineNames.MAINUV0 = 0,
- this.defineNames.MAINUV1 = 0,
- this.defineNames.MAINUV2 = 0,
- this.defineNames.MAINUV3 = 0,
- this.defineNames.MAINUV4 = 0,
- this.defineNames.MAINUV5 = 0,
- this.defineNames.MAINUV6 = 0,
- this.defineNames.MAINUV7 = 0
- }
- return a.prototype.emitErrors = function() {
- var e = "";
- !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
- `),
- 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
- `);
- for (var i = 0, o = this.checks.notConnectedNonOptionalInputs; i < o.length; i++) {
- var s = o[i];
- e += "input " + s.name + " from block " + s.ownerBlock.name + "[" + s.ownerBlock.getClassName() + `] is not connected and is not optional.\r
- `
- }
- if (e)
- throw `Build of NodeMaterial failed:\r
- ` + e
- }
- ,
- a
- }()
- , TransformBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.complementW = 1,
- o.complementZ = 0,
- o.target = NodeMaterialBlockTargets.Vertex,
- o.registerInput("vector", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerInput("transform", NodeMaterialBlockConnectionPointTypes.Matrix),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector4),
- o.registerOutput("xyz", NodeMaterialBlockConnectionPointTypes.Vector3),
- o._inputs[0].onConnectionObservable.add(function(s) {
- if (s.ownerBlock.isInput) {
- var c = s.ownerBlock;
- (c.name === "normal" || c.name === "tangent") && (o.complementW = 0)
- }
- }),
- o
- }
- return e.prototype.getClassName = function() {
- return "TransformBlock"
- }
- ,
- Object.defineProperty(e.prototype, "vector", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "xyz", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "transform", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this.vector
- , s = this.transform;
- if (o.connectedPoint) {
- if (this.complementW === 0) {
- var c = "//" + this.name;
- i._emitFunctionFromInclude("helperFunctions", c),
- i.sharedData.blocksWithDefines.push(this);
- var d = i._getFreeVariableName(s.associatedVariableName + "_NUS");
- switch (i.compilationString += "mat3 " + d + " = mat3(" + s.associatedVariableName + `);\r
- `,
- i.compilationString += `#ifdef NONUNIFORMSCALING\r
- `,
- i.compilationString += d + " = transposeMat3(inverseMat3(" + d + `));\r
- `,
- i.compilationString += `#endif\r
- `,
- o.connectedPoint.type) {
- case NodeMaterialBlockConnectionPointTypes.Vector2:
- i.compilationString += this._declareOutput(this.output, i) + (" = vec4(" + d + " * vec3(" + o.associatedVariableName + ", " + this._writeFloat(this.complementZ) + "), " + this._writeFloat(this.complementW) + `);\r
- `);
- break;
- case NodeMaterialBlockConnectionPointTypes.Vector3:
- case NodeMaterialBlockConnectionPointTypes.Color3:
- i.compilationString += this._declareOutput(this.output, i) + (" = vec4(" + d + " * " + o.associatedVariableName + ", " + this._writeFloat(this.complementW) + `);\r
- `);
- break;
- default:
- i.compilationString += this._declareOutput(this.output, i) + (" = vec4(" + d + " * " + o.associatedVariableName + ".xyz, " + this._writeFloat(this.complementW) + `);\r
- `);
- break
- }
- } else {
- var d = s.associatedVariableName;
- switch (o.connectedPoint.type) {
- case NodeMaterialBlockConnectionPointTypes.Vector2:
- i.compilationString += this._declareOutput(this.output, i) + (" = " + d + " * vec4(" + o.associatedVariableName + ", " + this._writeFloat(this.complementZ) + ", " + this._writeFloat(this.complementW) + `);\r
- `);
- break;
- case NodeMaterialBlockConnectionPointTypes.Vector3:
- case NodeMaterialBlockConnectionPointTypes.Color3:
- i.compilationString += this._declareOutput(this.output, i) + (" = " + d + " * vec4(" + o.associatedVariableName + ", " + this._writeFloat(this.complementW) + `);\r
- `);
- break;
- default:
- i.compilationString += this._declareOutput(this.output, i) + (" = " + d + " * " + o.associatedVariableName + `;\r
- `);
- break
- }
- }
- this.xyz.hasEndpoints && (i.compilationString += this._declareOutput(this.xyz, i) + (" = " + this.output.associatedVariableName + `.xyz;\r
- `))
- }
- return this
- }
- ,
- e.prototype.prepareDefines = function(i, o, s, c, d) {
- i.nonUniformScaling && s.setValue("NONUNIFORMSCALING", !0)
- }
- ,
- e.prototype.serialize = function() {
- var i = a.prototype.serialize.call(this);
- return i.complementZ = this.complementZ,
- i.complementW = this.complementW,
- i
- }
- ,
- e.prototype._deserialize = function(i, o, s) {
- a.prototype._deserialize.call(this, i, o, s),
- this.complementZ = i.complementZ !== void 0 ? i.complementZ : 0,
- this.complementW = i.complementW !== void 0 ? i.complementW : 1
- }
- ,
- e.prototype._dumpPropertiesCode = function() {
- var i = a.prototype._dumpPropertiesCode.call(this) + (this._codeVariableName + ".complementZ = " + this.complementZ + `;\r
- `);
- return i += this._codeVariableName + ".complementW = " + this.complementW + `;\r
- `,
- i
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.TransformBlock", TransformBlock);
- var VertexOutputBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Vertex, !0) || this;
- return o.registerInput("vector", NodeMaterialBlockConnectionPointTypes.Vector4),
- o
- }
- return e.prototype.getClassName = function() {
- return "VertexOutputBlock"
- }
- ,
- Object.defineProperty(e.prototype, "vector", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._isLogarithmicDepthEnabled = function(i) {
- for (var o = 0, s = i; o < s.length; o++) {
- var c = s[o];
- if (c.useLogarithmicDepth)
- return !0
- }
- return !1
- }
- ,
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this.vector;
- return i.compilationString += "gl_Position = " + o.associatedVariableName + `;\r
- `,
- this._isLogarithmicDepthEnabled(i.sharedData.fragmentOutputNodes) && (i._emitUniformFromString("logarithmicDepthConstant", "float"),
- i._emitVaryingFromString("vFragmentDepth", "float"),
- i.compilationString += `vFragmentDepth = 1.0 + gl_Position.w;\r
- `,
- i.compilationString += `gl_Position.z = log2(max(0.000001, vFragmentDepth)) * logarithmicDepthConstant;\r
- `),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.VertexOutputBlock", VertexOutputBlock);
- var PropertyTypeForEdition;
- (function(a) {
- a[a.Boolean = 0] = "Boolean",
- a[a.Float = 1] = "Float",
- a[a.Int = 2] = "Int",
- a[a.Vector2 = 3] = "Vector2",
- a[a.List = 4] = "List"
- }
- )(PropertyTypeForEdition || (PropertyTypeForEdition = {}));
- function editableInPropertyPage(a, e, i, o) {
- return e === void 0 && (e = PropertyTypeForEdition.Boolean),
- i === void 0 && (i = "PROPERTIES"),
- function(s, c) {
- var d = s._propStore;
- d || (d = [],
- s._propStore = d),
- d.push({
- propertyName: c,
- displayName: a,
- type: e,
- groupName: i,
- options: o != null ? o : {}
- })
- }
- }
- var FragmentOutputBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Fragment, !0) || this;
- return o.convertToGammaSpace = !1,
- o.convertToLinearSpace = !1,
- o.useLogarithmicDepth = !1,
- o.registerInput("rgba", NodeMaterialBlockConnectionPointTypes.Color4, !0),
- o.registerInput("rgb", NodeMaterialBlockConnectionPointTypes.Color3, !0),
- o.registerInput("a", NodeMaterialBlockConnectionPointTypes.Float, !0),
- o.rgb.acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
- o
- }
- return e.prototype.getClassName = function() {
- return "FragmentOutputBlock"
- }
- ,
- e.prototype.initialize = function(i) {
- i._excludeVariableName("logarithmicDepthConstant"),
- i._excludeVariableName("vFragmentDepth")
- }
- ,
- Object.defineProperty(e.prototype, "rgba", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "rgb", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "a", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.prepareDefines = function(i, o, s) {
- s.setValue(this._linearDefineName, this.convertToLinearSpace, !0),
- s.setValue(this._gammaDefineName, this.convertToGammaSpace, !0)
- }
- ,
- e.prototype.bind = function(i, o, s) {
- this.useLogarithmicDepth && s && MaterialHelper.BindLogDepth(void 0, i, s.getScene())
- }
- ,
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this.rgba
- , s = this.rgb
- , c = this.a;
- i.sharedData.hints.needAlphaBlending = o.isConnected || c.isConnected,
- i.sharedData.blocksWithDefines.push(this),
- this.useLogarithmicDepth && (i._emitUniformFromString("logarithmicDepthConstant", "float"),
- i._emitVaryingFromString("vFragmentDepth", "float"),
- i.sharedData.bindableBlocks.push(this)),
- this._linearDefineName = i._getFreeDefineName("CONVERTTOLINEAR"),
- this._gammaDefineName = i._getFreeDefineName("CONVERTTOGAMMA");
- var d = "//" + this.name;
- if (i._emitFunctionFromInclude("helperFunctions", d),
- o.connectedPoint)
- c.isConnected ? i.compilationString += "gl_FragColor = vec4(" + o.associatedVariableName + ".rgb, " + c.associatedVariableName + `);\r
- ` : i.compilationString += "gl_FragColor = " + o.associatedVariableName + `;\r
- `;
- else if (s.connectedPoint) {
- var _ = "1.0";
- c.connectedPoint && (_ = c.associatedVariableName),
- s.connectedPoint.type === NodeMaterialBlockConnectionPointTypes.Float ? i.compilationString += "gl_FragColor = vec4(" + s.associatedVariableName + ", " + s.associatedVariableName + ", " + s.associatedVariableName + ", " + _ + `);\r
- ` : i.compilationString += "gl_FragColor = vec4(" + s.associatedVariableName + ", " + _ + `);\r
- `
- } else
- i.sharedData.checks.notConnectedNonOptionalInputs.push(o);
- return i.compilationString += "#ifdef " + this._linearDefineName + `\r
- `,
- i.compilationString += `gl_FragColor = toLinearSpace(gl_FragColor);\r
- `,
- i.compilationString += `#endif\r
- `,
- i.compilationString += "#ifdef " + this._gammaDefineName + `\r
- `,
- i.compilationString += `gl_FragColor = toGammaSpace(gl_FragColor);\r
- `,
- i.compilationString += `#endif\r
- `,
- this.useLogarithmicDepth && (i.compilationString += `gl_FragDepthEXT = log2(vFragmentDepth) * logarithmicDepthConstant * 0.5;\r
- `),
- this
- }
- ,
- e.prototype._dumpPropertiesCode = function() {
- var i = a.prototype._dumpPropertiesCode.call(this);
- return i += this._codeVariableName + ".convertToGammaSpace = " + this.convertToGammaSpace + `;\r
- `,
- i += this._codeVariableName + ".convertToLinearSpace = " + this.convertToLinearSpace + `;\r
- `,
- i += this._codeVariableName + ".useLogarithmicDepth = " + this.useLogarithmicDepth + `;\r
- `,
- i
- }
- ,
- e.prototype.serialize = function() {
- var i = a.prototype.serialize.call(this);
- return i.convertToGammaSpace = this.convertToGammaSpace,
- i.convertToLinearSpace = this.convertToLinearSpace,
- i.useLogarithmicDepth = this.useLogarithmicDepth,
- i
- }
- ,
- e.prototype._deserialize = function(i, o, s) {
- var c;
- a.prototype._deserialize.call(this, i, o, s),
- this.convertToGammaSpace = i.convertToGammaSpace,
- this.convertToLinearSpace = i.convertToLinearSpace,
- this.useLogarithmicDepth = (c = i.useLogarithmicDepth) !== null && c !== void 0 ? c : !1
- }
- ,
- __decorate([editableInPropertyPage("Convert to gamma space", PropertyTypeForEdition.Boolean, "PROPERTIES", {
- notifiers: {
- update: !0
- }
- })], e.prototype, "convertToGammaSpace", void 0),
- __decorate([editableInPropertyPage("Convert to linear space", PropertyTypeForEdition.Boolean, "PROPERTIES", {
- notifiers: {
- update: !0
- }
- })], e.prototype, "convertToLinearSpace", void 0),
- __decorate([editableInPropertyPage("Use logarithmic depth", PropertyTypeForEdition.Boolean, "PROPERTIES")], e.prototype, "useLogarithmicDepth", void 0),
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.FragmentOutputBlock", FragmentOutputBlock);
- var AnimatedInputBlockTypes;
- (function(a) {
- a[a.None = 0] = "None",
- a[a.Time = 1] = "Time"
- }
- )(AnimatedInputBlockTypes || (AnimatedInputBlockTypes = {}));
- var remapAttributeName = {
- position2d: "position",
- particle_uv: "vUV",
- particle_color: "vColor",
- particle_texturemask: "textureMask",
- particle_positionw: "vPositionW"
- }
- , attributeInFragmentOnly = {
- particle_uv: !0,
- particle_color: !0,
- particle_texturemask: !0,
- particle_positionw: !0
- }
- , attributeAsUniform = {
- particle_texturemask: !0
- }
- , InputBlock = function(a) {
- __extends(e, a);
- function e(i, o, s) {
- o === void 0 && (o = NodeMaterialBlockTargets.Vertex),
- s === void 0 && (s = NodeMaterialBlockConnectionPointTypes.AutoDetect);
- var c = a.call(this, i, o, !1, !0) || this;
- return c._mode = NodeMaterialBlockConnectionPointMode.Undefined,
- c._animationType = AnimatedInputBlockTypes.None,
- c.min = 0,
- c.max = 0,
- c.isBoolean = !1,
- c.matrixMode = 0,
- c._systemValue = null,
- c.isConstant = !1,
- c.groupInInspector = "",
- c.onValueChangedObservable = new Observable,
- c.convertToGammaSpace = !1,
- c.convertToLinearSpace = !1,
- c._type = s,
- c.setDefaultValue(),
- c.registerOutput("output", s),
- c
- }
- return Object.defineProperty(e.prototype, "type", {
- get: function() {
- if (this._type === NodeMaterialBlockConnectionPointTypes.AutoDetect) {
- if (this.isUniform && this.value != null) {
- if (!isNaN(this.value))
- return this._type = NodeMaterialBlockConnectionPointTypes.Float,
- this._type;
- switch (this.value.getClassName()) {
- case "Vector2":
- return this._type = NodeMaterialBlockConnectionPointTypes.Vector2,
- this._type;
- case "Vector3":
- return this._type = NodeMaterialBlockConnectionPointTypes.Vector3,
- this._type;
- case "Vector4":
- return this._type = NodeMaterialBlockConnectionPointTypes.Vector4,
- this._type;
- case "Color3":
- return this._type = NodeMaterialBlockConnectionPointTypes.Color3,
- this._type;
- case "Color4":
- return this._type = NodeMaterialBlockConnectionPointTypes.Color4,
- this._type;
- case "Matrix":
- return this._type = NodeMaterialBlockConnectionPointTypes.Matrix,
- this._type
- }
- }
- if (this.isAttribute)
- switch (this.name) {
- case "position":
- case "normal":
- case "tangent":
- case "particle_positionw":
- return this._type = NodeMaterialBlockConnectionPointTypes.Vector3,
- this._type;
- case "uv":
- case "uv2":
- case "uv3":
- case "uv4":
- case "uv5":
- case "uv6":
- case "position2d":
- case "particle_uv":
- return this._type = NodeMaterialBlockConnectionPointTypes.Vector2,
- this._type;
- case "matricesIndices":
- case "matricesWeights":
- case "world0":
- case "world1":
- case "world2":
- case "world3":
- return this._type = NodeMaterialBlockConnectionPointTypes.Vector4,
- this._type;
- case "color":
- case "particle_color":
- case "particle_texturemask":
- return this._type = NodeMaterialBlockConnectionPointTypes.Color4,
- this._type
- }
- if (this.isSystemValue)
- switch (this._systemValue) {
- case NodeMaterialSystemValues.World:
- case NodeMaterialSystemValues.WorldView:
- case NodeMaterialSystemValues.WorldViewProjection:
- case NodeMaterialSystemValues.View:
- case NodeMaterialSystemValues.ViewProjection:
- case NodeMaterialSystemValues.Projection:
- return this._type = NodeMaterialBlockConnectionPointTypes.Matrix,
- this._type;
- case NodeMaterialSystemValues.CameraPosition:
- return this._type = NodeMaterialBlockConnectionPointTypes.Vector3,
- this._type;
- case NodeMaterialSystemValues.FogColor:
- return this._type = NodeMaterialBlockConnectionPointTypes.Color3,
- this._type;
- case NodeMaterialSystemValues.DeltaTime:
- return this._type = NodeMaterialBlockConnectionPointTypes.Float,
- this._type;
- case NodeMaterialSystemValues.CameraParameters:
- return this._type = NodeMaterialBlockConnectionPointTypes.Vector4,
- this._type
- }
- }
- return this._type
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.validateBlockName = function(i) {
- return this.isAttribute ? !0 : a.prototype.validateBlockName.call(this, i)
- }
- ,
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.setAsAttribute = function(i) {
- return this._mode = NodeMaterialBlockConnectionPointMode.Attribute,
- i && (this.name = i),
- this
- }
- ,
- e.prototype.setAsSystemValue = function(i) {
- return this.systemValue = i,
- this
- }
- ,
- Object.defineProperty(e.prototype, "value", {
- get: function() {
- return this._storedValue
- },
- set: function(i) {
- this.type === NodeMaterialBlockConnectionPointTypes.Float && (this.isBoolean ? i = i ? 1 : 0 : this.min !== this.max && (i = Math.max(this.min, i),
- i = Math.min(this.max, i))),
- this._storedValue = i,
- this._mode = NodeMaterialBlockConnectionPointMode.Uniform,
- this.onValueChangedObservable.notifyObservers(this)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "valueCallback", {
- get: function() {
- return this._valueCallback
- },
- set: function(i) {
- this._valueCallback = i,
- this._mode = NodeMaterialBlockConnectionPointMode.Uniform
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "associatedVariableName", {
- get: function() {
- return this._associatedVariableName
- },
- set: function(i) {
- this._associatedVariableName = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "animationType", {
- get: function() {
- return this._animationType
- },
- set: function(i) {
- this._animationType = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isUndefined", {
- get: function() {
- return this._mode === NodeMaterialBlockConnectionPointMode.Undefined
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isUniform", {
- get: function() {
- return this._mode === NodeMaterialBlockConnectionPointMode.Uniform
- },
- set: function(i) {
- this._mode = i ? NodeMaterialBlockConnectionPointMode.Uniform : NodeMaterialBlockConnectionPointMode.Undefined,
- this.associatedVariableName = ""
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isAttribute", {
- get: function() {
- return this._mode === NodeMaterialBlockConnectionPointMode.Attribute
- },
- set: function(i) {
- this._mode = i ? NodeMaterialBlockConnectionPointMode.Attribute : NodeMaterialBlockConnectionPointMode.Undefined,
- this.associatedVariableName = ""
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isVarying", {
- get: function() {
- return this._mode === NodeMaterialBlockConnectionPointMode.Varying
- },
- set: function(i) {
- this._mode = i ? NodeMaterialBlockConnectionPointMode.Varying : NodeMaterialBlockConnectionPointMode.Undefined,
- this.associatedVariableName = ""
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isSystemValue", {
- get: function() {
- return this._systemValue != null
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "systemValue", {
- get: function() {
- return this._systemValue
- },
- set: function(i) {
- this._mode = NodeMaterialBlockConnectionPointMode.Uniform,
- this.associatedVariableName = "",
- this._systemValue = i
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getClassName = function() {
- return "InputBlock"
- }
- ,
- e.prototype.animate = function(i) {
- switch (this._animationType) {
- case AnimatedInputBlockTypes.Time:
- {
- this.type === NodeMaterialBlockConnectionPointTypes.Float && (this.value += i.getAnimationRatio() * .01);
- break
- }
- }
- }
- ,
- e.prototype._emitDefine = function(i) {
- return i[0] === "!" ? "#ifndef " + i.substring(1) + `\r
- ` : "#ifdef " + i + `\r
- `
- }
- ,
- e.prototype.initialize = function(i) {
- this.associatedVariableName = ""
- }
- ,
- e.prototype.setDefaultValue = function() {
- switch (this.type) {
- case NodeMaterialBlockConnectionPointTypes.Float:
- this.value = 0;
- break;
- case NodeMaterialBlockConnectionPointTypes.Vector2:
- this.value = Vector2.Zero();
- break;
- case NodeMaterialBlockConnectionPointTypes.Vector3:
- this.value = Vector3.Zero();
- break;
- case NodeMaterialBlockConnectionPointTypes.Vector4:
- this.value = Vector4.Zero();
- break;
- case NodeMaterialBlockConnectionPointTypes.Color3:
- this.value = Color3.White();
- break;
- case NodeMaterialBlockConnectionPointTypes.Color4:
- this.value = new Color4(1,1,1,1);
- break;
- case NodeMaterialBlockConnectionPointTypes.Matrix:
- this.value = Matrix.Identity();
- break
- }
- }
- ,
- e.prototype._emitConstant = function(i) {
- switch (this.type) {
- case NodeMaterialBlockConnectionPointTypes.Float:
- return "" + i._emitFloat(this.value);
- case NodeMaterialBlockConnectionPointTypes.Vector2:
- return "vec2(" + this.value.x + ", " + this.value.y + ")";
- case NodeMaterialBlockConnectionPointTypes.Vector3:
- return "vec3(" + this.value.x + ", " + this.value.y + ", " + this.value.z + ")";
- case NodeMaterialBlockConnectionPointTypes.Vector4:
- return "vec4(" + this.value.x + ", " + this.value.y + ", " + this.value.z + ", " + this.value.w + ")";
- case NodeMaterialBlockConnectionPointTypes.Color3:
- return TmpColors.Color3[0].set(this.value.r, this.value.g, this.value.b),
- this.convertToGammaSpace && TmpColors.Color3[0].toGammaSpaceToRef(TmpColors.Color3[0]),
- this.convertToLinearSpace && TmpColors.Color3[0].toLinearSpaceToRef(TmpColors.Color3[0]),
- "vec3(" + TmpColors.Color3[0].r + ", " + TmpColors.Color3[0].g + ", " + TmpColors.Color3[0].b + ")";
- case NodeMaterialBlockConnectionPointTypes.Color4:
- return TmpColors.Color4[0].set(this.value.r, this.value.g, this.value.b, this.value.a),
- this.convertToGammaSpace && TmpColors.Color4[0].toGammaSpaceToRef(TmpColors.Color4[0]),
- this.convertToLinearSpace && TmpColors.Color4[0].toLinearSpaceToRef(TmpColors.Color4[0]),
- "vec4(" + TmpColors.Color4[0].r + ", " + TmpColors.Color4[0].g + ", " + TmpColors.Color4[0].b + ", " + TmpColors.Color4[0].a + ")"
- }
- return ""
- }
- ,
- Object.defineProperty(e.prototype, "_noContextSwitch", {
- get: function() {
- return attributeInFragmentOnly[this.name]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._emit = function(i, o) {
- var s;
- if (this.isUniform) {
- if (this.associatedVariableName || (this.associatedVariableName = i._getFreeVariableName("u_" + this.name)),
- this.isConstant) {
- if (i.constants.indexOf(this.associatedVariableName) !== -1)
- return;
- i.constants.push(this.associatedVariableName),
- i._constantDeclaration += this._declareOutput(this.output, i) + (" = " + this._emitConstant(i) + `;\r
- `);
- return
- }
- if (i.uniforms.indexOf(this.associatedVariableName) !== -1)
- return;
- i.uniforms.push(this.associatedVariableName),
- o && (i._uniformDeclaration += this._emitDefine(o)),
- i._uniformDeclaration += "uniform " + i._getGLType(this.type) + " " + this.associatedVariableName + `;\r
- `,
- o && (i._uniformDeclaration += `#endif\r
- `);
- var c = i.sharedData.hints;
- if (this._systemValue !== null && this._systemValue !== void 0)
- switch (this._systemValue) {
- case NodeMaterialSystemValues.WorldView:
- c.needWorldViewMatrix = !0;
- break;
- case NodeMaterialSystemValues.WorldViewProjection:
- c.needWorldViewProjectionMatrix = !0;
- break
- }
- else
- this._animationType !== AnimatedInputBlockTypes.None && i.sharedData.animatedInputs.push(this);
- return
- }
- if (this.isAttribute) {
- if (this.associatedVariableName = (s = remapAttributeName[this.name]) !== null && s !== void 0 ? s : this.name,
- this.target === NodeMaterialBlockTargets.Vertex && i._vertexState) {
- 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);
- return
- }
- if (i.attributes.indexOf(this.associatedVariableName) !== -1)
- return;
- i.attributes.push(this.associatedVariableName),
- 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)),
- i._attributeDeclaration += "attribute " + i._getGLType(this.type) + " " + this.associatedVariableName + `;\r
- `,
- o && (i._attributeDeclaration += `#endif\r
- `))
- }
- }
- ,
- e.prototype._transmitWorld = function(i, o, s, c) {
- if (!!this._systemValue) {
- var d = this.associatedVariableName;
- switch (this._systemValue) {
- case NodeMaterialSystemValues.World:
- i.setMatrix(d, o);
- break;
- case NodeMaterialSystemValues.WorldView:
- i.setMatrix(d, s);
- break;
- case NodeMaterialSystemValues.WorldViewProjection:
- i.setMatrix(d, c);
- break
- }
- }
- }
- ,
- e.prototype._transmit = function(i, o) {
- if (!this.isAttribute) {
- var s = this.associatedVariableName;
- if (this._systemValue) {
- switch (this._systemValue) {
- case NodeMaterialSystemValues.World:
- case NodeMaterialSystemValues.WorldView:
- case NodeMaterialSystemValues.WorldViewProjection:
- return;
- case NodeMaterialSystemValues.View:
- i.setMatrix(s, o.getViewMatrix());
- break;
- case NodeMaterialSystemValues.Projection:
- i.setMatrix(s, o.getProjectionMatrix());
- break;
- case NodeMaterialSystemValues.ViewProjection:
- i.setMatrix(s, o.getTransformMatrix());
- break;
- case NodeMaterialSystemValues.CameraPosition:
- o.bindEyePosition(i, s, !0);
- break;
- case NodeMaterialSystemValues.FogColor:
- i.setColor3(s, o.fogColor);
- break;
- case NodeMaterialSystemValues.DeltaTime:
- i.setFloat(s, o.deltaTime / 1e3);
- case NodeMaterialSystemValues.CameraParameters:
- o.activeCamera && i.setFloat4(s, o.getEngine().hasOriginBottomLeft ? -1 : 1, o.activeCamera.minZ, o.activeCamera.maxZ, 1 / o.activeCamera.maxZ);
- break
- }
- return
- }
- var c = this._valueCallback ? this._valueCallback() : this._storedValue;
- if (c !== null)
- switch (this.type) {
- case NodeMaterialBlockConnectionPointTypes.Float:
- i.setFloat(s, c);
- break;
- case NodeMaterialBlockConnectionPointTypes.Int:
- i.setInt(s, c);
- break;
- case NodeMaterialBlockConnectionPointTypes.Color3:
- TmpColors.Color3[0].set(this.value.r, this.value.g, this.value.b),
- this.convertToGammaSpace && TmpColors.Color3[0].toGammaSpaceToRef(TmpColors.Color3[0]),
- this.convertToLinearSpace && TmpColors.Color3[0].toLinearSpaceToRef(TmpColors.Color3[0]),
- i.setColor3(s, TmpColors.Color3[0]);
- break;
- case NodeMaterialBlockConnectionPointTypes.Color4:
- TmpColors.Color4[0].set(this.value.r, this.value.g, this.value.b, this.value.a),
- this.convertToGammaSpace && TmpColors.Color4[0].toGammaSpaceToRef(TmpColors.Color4[0]),
- this.convertToLinearSpace && TmpColors.Color4[0].toLinearSpaceToRef(TmpColors.Color4[0]),
- i.setDirectColor4(s, TmpColors.Color4[0]);
- break;
- case NodeMaterialBlockConnectionPointTypes.Vector2:
- i.setVector2(s, c);
- break;
- case NodeMaterialBlockConnectionPointTypes.Vector3:
- i.setVector3(s, c);
- break;
- case NodeMaterialBlockConnectionPointTypes.Vector4:
- i.setVector4(s, c);
- break;
- case NodeMaterialBlockConnectionPointTypes.Matrix:
- i.setMatrix(s, c);
- break
- }
- }
- }
- ,
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i),
- (this.isUniform || this.isSystemValue) && i.sharedData.inputBlocks.push(this),
- this._emit(i)
- }
- ,
- e.prototype._dumpPropertiesCode = function() {
- var i = this._codeVariableName;
- if (this.isAttribute)
- return a.prototype._dumpPropertiesCode.call(this) + (i + '.setAsAttribute("' + this.name + `");\r
- `);
- if (this.isSystemValue)
- return a.prototype._dumpPropertiesCode.call(this) + (i + ".setAsSystemValue(BABYLON.NodeMaterialSystemValues." + NodeMaterialSystemValues[this._systemValue] + `);\r
- `);
- if (this.isUniform) {
- var o = []
- , s = "";
- switch (this.type) {
- case NodeMaterialBlockConnectionPointTypes.Float:
- s = "" + this.value;
- break;
- case NodeMaterialBlockConnectionPointTypes.Vector2:
- s = "new BABYLON.Vector2(" + this.value.x + ", " + this.value.y + ")";
- break;
- case NodeMaterialBlockConnectionPointTypes.Vector3:
- s = "new BABYLON.Vector3(" + this.value.x + ", " + this.value.y + ", " + this.value.z + ")";
- break;
- case NodeMaterialBlockConnectionPointTypes.Vector4:
- s = "new BABYLON.Vector4(" + this.value.x + ", " + this.value.y + ", " + this.value.z + ", " + this.value.w + ")";
- break;
- case NodeMaterialBlockConnectionPointTypes.Color3:
- s = "new BABYLON.Color3(" + this.value.r + ", " + this.value.g + ", " + this.value.b + ")",
- this.convertToGammaSpace && (s += ".toGammaSpace()"),
- this.convertToLinearSpace && (s += ".toLinearSpace()");
- break;
- case NodeMaterialBlockConnectionPointTypes.Color4:
- s = "new BABYLON.Color4(" + this.value.r + ", " + this.value.g + ", " + this.value.b + ", " + this.value.a + ")",
- this.convertToGammaSpace && (s += ".toGammaSpace()"),
- this.convertToLinearSpace && (s += ".toLinearSpace()");
- break;
- case NodeMaterialBlockConnectionPointTypes.Matrix:
- s = "BABYLON.Matrix.FromArray([" + this.value.m + "])";
- break
- }
- return o.push(i + ".value = " + s),
- 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]),
- o.push(i + ".isConstant = " + this.isConstant),
- o.push(""),
- a.prototype._dumpPropertiesCode.call(this) + o.join(`;\r
- `)
- }
- return a.prototype._dumpPropertiesCode.call(this)
- }
- ,
- e.prototype.dispose = function() {
- this.onValueChangedObservable.clear(),
- a.prototype.dispose.call(this)
- }
- ,
- e.prototype.serialize = function() {
- var i = a.prototype.serialize.call(this);
- return i.type = this.type,
- i.mode = this._mode,
- i.systemValue = this._systemValue,
- i.animationType = this._animationType,
- i.min = this.min,
- i.max = this.max,
- i.isBoolean = this.isBoolean,
- i.matrixMode = this.matrixMode,
- i.isConstant = this.isConstant,
- i.groupInInspector = this.groupInInspector,
- i.convertToGammaSpace = this.convertToGammaSpace,
- i.convertToLinearSpace = this.convertToLinearSpace,
- this._storedValue != null && this._mode === NodeMaterialBlockConnectionPointMode.Uniform && (this._storedValue.asArray ? (i.valueType = "BABYLON." + this._storedValue.getClassName(),
- i.value = this._storedValue.asArray()) : (i.valueType = "number",
- i.value = this._storedValue)),
- i
- }
- ,
- e.prototype._deserialize = function(i, o, s) {
- if (this._mode = i.mode,
- a.prototype._deserialize.call(this, i, o, s),
- this._type = i.type,
- this._systemValue = i.systemValue || i.wellKnownValue,
- this._animationType = i.animationType,
- this.min = i.min || 0,
- this.max = i.max || 0,
- this.isBoolean = !!i.isBoolean,
- this.matrixMode = i.matrixMode || 0,
- this.isConstant = !!i.isConstant,
- this.groupInInspector = i.groupInInspector || "",
- this.convertToGammaSpace = !!i.convertToGammaSpace,
- this.convertToLinearSpace = !!i.convertToLinearSpace,
- !!i.valueType)
- if (i.valueType === "number")
- this._storedValue = i.value;
- else {
- var c = GetClass(i.valueType);
- c && (this._storedValue = c.FromArray(i.value))
- }
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.InputBlock", InputBlock);
- var CurrentScreenBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.VertexAndFragment) || this;
- return o._samplerName = "textureSampler",
- o.convertToGammaSpace = !1,
- o.convertToLinearSpace = !1,
- o._isUnique = !1,
- o.registerInput("uv", NodeMaterialBlockConnectionPointTypes.Vector2, !1, NodeMaterialBlockTargets.VertexAndFragment),
- o.registerOutput("rgba", NodeMaterialBlockConnectionPointTypes.Color4, NodeMaterialBlockTargets.Neutral),
- o.registerOutput("rgb", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Neutral),
- o.registerOutput("r", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
- o.registerOutput("g", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
- o.registerOutput("b", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
- o.registerOutput("a", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
- o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector3),
- o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
- o._inputs[0]._prioritizeVertex = !1,
- o
- }
- return e.prototype.getClassName = function() {
- return "CurrentScreenBlock"
- }
- ,
- Object.defineProperty(e.prototype, "uv", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "rgba", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "rgb", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "r", {
- get: function() {
- return this._outputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "g", {
- get: function() {
- return this._outputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "b", {
- get: function() {
- return this._outputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "a", {
- get: function() {
- return this._outputs[5]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.initialize = function(i) {
- i._excludeVariableName("textureSampler")
- }
- ,
- Object.defineProperty(e.prototype, "target", {
- get: function() {
- return !this.uv.isConnected || this.uv.sourceBlock.isInput ? NodeMaterialBlockTargets.VertexAndFragment : NodeMaterialBlockTargets.Fragment
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.prepareDefines = function(i, o, s) {
- s.setValue(this._linearDefineName, this.convertToGammaSpace, !0),
- s.setValue(this._gammaDefineName, this.convertToLinearSpace, !0)
- }
- ,
- e.prototype.isReady = function() {
- return !(this.texture && !this.texture.isReadyOrNotBlocking())
- }
- ,
- e.prototype._injectVertexCode = function(i) {
- var o = this.uv;
- if (o.connectedPoint.ownerBlock.isInput) {
- var s = o.connectedPoint.ownerBlock;
- s.isAttribute || i._emitUniformFromString(o.associatedVariableName, "vec2")
- }
- if (this._mainUVName = "vMain" + o.associatedVariableName,
- i._emitVaryingFromString(this._mainUVName, "vec2"),
- i.compilationString += this._mainUVName + " = " + o.associatedVariableName + `.xy;\r
- `,
- !!this._outputs.some(function(b) {
- return b.isConnectedInVertexShader
- })) {
- this._writeTextureRead(i, !0);
- for (var c = 0, d = this._outputs; c < d.length; c++) {
- var _ = d[c];
- _.hasEndpoints && this._writeOutput(i, _, _.name, !0)
- }
- }
- }
- ,
- e.prototype._writeTextureRead = function(i, o) {
- o === void 0 && (o = !1);
- var s = this.uv;
- if (o) {
- if (i.target === NodeMaterialBlockTargets.Fragment)
- return;
- i.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + this._samplerName + ", " + s.associatedVariableName + `);\r
- `;
- return
- }
- if (this.uv.ownerBlock.target === NodeMaterialBlockTargets.Fragment) {
- i.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + this._samplerName + ", " + s.associatedVariableName + `);\r
- `;
- return
- }
- i.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + this._samplerName + ", " + this._mainUVName + `);\r
- `
- }
- ,
- e.prototype._writeOutput = function(i, o, s, c) {
- if (c === void 0 && (c = !1),
- c) {
- if (i.target === NodeMaterialBlockTargets.Fragment)
- return;
- i.compilationString += this._declareOutput(o, i) + " = " + this._tempTextureRead + "." + s + `;\r
- `;
- return
- }
- if (this.uv.ownerBlock.target === NodeMaterialBlockTargets.Fragment) {
- i.compilationString += this._declareOutput(o, i) + " = " + this._tempTextureRead + "." + s + `;\r
- `;
- return
- }
- i.compilationString += this._declareOutput(o, i) + " = " + this._tempTextureRead + "." + s + `;\r
- `,
- i.compilationString += "#ifdef " + this._linearDefineName + `\r
- `,
- i.compilationString += o.associatedVariableName + " = toGammaSpace(" + o.associatedVariableName + `);\r
- `,
- i.compilationString += `#endif\r
- `,
- i.compilationString += "#ifdef " + this._gammaDefineName + `\r
- `,
- i.compilationString += o.associatedVariableName + " = toLinearSpace(" + o.associatedVariableName + `);\r
- `,
- i.compilationString += `#endif\r
- `
- }
- ,
- e.prototype._buildBlock = function(i) {
- if (a.prototype._buildBlock.call(this, i),
- this._tempTextureRead = i._getFreeVariableName("tempTextureRead"),
- i.sharedData.blockingBlocks.indexOf(this) < 0 && i.sharedData.blockingBlocks.push(this),
- i.sharedData.textureBlocks.indexOf(this) < 0 && i.sharedData.textureBlocks.push(this),
- i.sharedData.blocksWithDefines.indexOf(this) < 0 && i.sharedData.blocksWithDefines.push(this),
- i.target !== NodeMaterialBlockTargets.Fragment) {
- i._emit2DSampler(this._samplerName),
- this._injectVertexCode(i);
- return
- }
- if (!!this._outputs.some(function(_) {
- return _.isConnectedInFragmentShader
- })) {
- i._emit2DSampler(this._samplerName),
- this._linearDefineName = i._getFreeDefineName("ISLINEAR"),
- this._gammaDefineName = i._getFreeDefineName("ISGAMMA");
- var o = "//" + this.name;
- i._emitFunctionFromInclude("helperFunctions", o),
- this._writeTextureRead(i);
- for (var s = 0, c = this._outputs; s < c.length; s++) {
- var d = c[s];
- d.hasEndpoints && this._writeOutput(i, d, d.name)
- }
- return this
- }
- }
- ,
- e.prototype.serialize = function() {
- var i = a.prototype.serialize.call(this);
- return i.convertToGammaSpace = this.convertToGammaSpace,
- i.convertToLinearSpace = this.convertToLinearSpace,
- this.texture && !this.texture.isRenderTarget && (i.texture = this.texture.serialize()),
- i
- }
- ,
- e.prototype._deserialize = function(i, o, s) {
- a.prototype._deserialize.call(this, i, o, s),
- this.convertToGammaSpace = i.convertToGammaSpace,
- this.convertToLinearSpace = !!i.convertToLinearSpace,
- i.texture && (s = i.texture.url.indexOf("data:") === 0 ? "" : s,
- this.texture = Texture.Parse(i.texture, o, s))
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.CurrentScreenBlock", CurrentScreenBlock);
- var ParticleTextureBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Fragment) || this;
- return o._samplerName = "diffuseSampler",
- o.convertToGammaSpace = !1,
- o.convertToLinearSpace = !1,
- o._isUnique = !1,
- o.registerInput("uv", NodeMaterialBlockConnectionPointTypes.Vector2, !1, NodeMaterialBlockTargets.VertexAndFragment),
- o.registerOutput("rgba", NodeMaterialBlockConnectionPointTypes.Color4, NodeMaterialBlockTargets.Neutral),
- o.registerOutput("rgb", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Neutral),
- o.registerOutput("r", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
- o.registerOutput("g", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
- o.registerOutput("b", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
- o.registerOutput("a", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
- o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector3),
- o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
- o
- }
- return e.prototype.getClassName = function() {
- return "ParticleTextureBlock"
- }
- ,
- Object.defineProperty(e.prototype, "uv", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "rgba", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "rgb", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "r", {
- get: function() {
- return this._outputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "g", {
- get: function() {
- return this._outputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "b", {
- get: function() {
- return this._outputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "a", {
- get: function() {
- return this._outputs[5]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.initialize = function(i) {
- i._excludeVariableName("diffuseSampler")
- }
- ,
- e.prototype.autoConfigure = function(i) {
- if (!this.uv.isConnected) {
- var o = i.getInputBlockByPredicate(function(s) {
- return s.isAttribute && s.name === "particle_uv"
- });
- o || (o = new InputBlock("uv"),
- o.setAsAttribute("particle_uv")),
- o.output.connectTo(this.uv)
- }
- }
- ,
- e.prototype.prepareDefines = function(i, o, s) {
- s.setValue(this._linearDefineName, this.convertToGammaSpace, !0),
- s.setValue(this._gammaDefineName, this.convertToLinearSpace, !0)
- }
- ,
- e.prototype.isReady = function() {
- return !(this.texture && !this.texture.isReadyOrNotBlocking())
- }
- ,
- e.prototype._writeOutput = function(i, o, s) {
- i.compilationString += this._declareOutput(o, i) + " = " + this._tempTextureRead + "." + s + `;\r
- `,
- i.compilationString += "#ifdef " + this._linearDefineName + `\r
- `,
- i.compilationString += o.associatedVariableName + " = toGammaSpace(" + o.associatedVariableName + `);\r
- `,
- i.compilationString += `#endif\r
- `,
- i.compilationString += "#ifdef " + this._gammaDefineName + `\r
- `,
- i.compilationString += o.associatedVariableName + " = toLinearSpace(" + o.associatedVariableName + `);\r
- `,
- i.compilationString += `#endif\r
- `
- }
- ,
- e.prototype._buildBlock = function(i) {
- if (a.prototype._buildBlock.call(this, i),
- i.target !== NodeMaterialBlockTargets.Vertex) {
- this._tempTextureRead = i._getFreeVariableName("tempTextureRead"),
- i._emit2DSampler(this._samplerName),
- i.sharedData.blockingBlocks.push(this),
- i.sharedData.textureBlocks.push(this),
- i.sharedData.blocksWithDefines.push(this),
- this._linearDefineName = i._getFreeDefineName("ISLINEAR"),
- this._gammaDefineName = i._getFreeDefineName("ISGAMMA");
- var o = "//" + this.name;
- i._emitFunctionFromInclude("helperFunctions", o),
- i.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + this._samplerName + ", " + this.uv.associatedVariableName + `);\r
- `;
- for (var s = 0, c = this._outputs; s < c.length; s++) {
- var d = c[s];
- d.hasEndpoints && this._writeOutput(i, d, d.name)
- }
- return this
- }
- }
- ,
- e.prototype.serialize = function() {
- var i = a.prototype.serialize.call(this);
- return i.convertToGammaSpace = this.convertToGammaSpace,
- i.convertToLinearSpace = this.convertToLinearSpace,
- this.texture && !this.texture.isRenderTarget && (i.texture = this.texture.serialize()),
- i
- }
- ,
- e.prototype._deserialize = function(i, o, s) {
- a.prototype._deserialize.call(this, i, o, s),
- this.convertToGammaSpace = i.convertToGammaSpace,
- this.convertToLinearSpace = !!i.convertToLinearSpace,
- i.texture && (s = i.texture.url.indexOf("data:") === 0 ? "" : s,
- this.texture = Texture.Parse(i.texture, o, s))
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.ParticleTextureBlock", ParticleTextureBlock);
- var ParticleRampGradientBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Fragment) || this;
- return o._isUnique = !0,
- o.registerInput("color", NodeMaterialBlockConnectionPointTypes.Color4, !1, NodeMaterialBlockTargets.Fragment),
- o.registerOutput("rampColor", NodeMaterialBlockConnectionPointTypes.Color4, NodeMaterialBlockTargets.Fragment),
- o
- }
- return e.prototype.getClassName = function() {
- return "ParticleRampGradientBlock"
- }
- ,
- Object.defineProperty(e.prototype, "color", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "rampColor", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.initialize = function(i) {
- i._excludeVariableName("remapRanges"),
- i._excludeVariableName("rampSampler"),
- i._excludeVariableName("baseColor"),
- i._excludeVariableName("alpha"),
- i._excludeVariableName("remappedColorIndex"),
- i._excludeVariableName("rampColor"),
- i._excludeVariableName("finalAlpha")
- }
- ,
- e.prototype._buildBlock = function(i) {
- if (a.prototype._buildBlock.call(this, i),
- i.target !== NodeMaterialBlockTargets.Vertex)
- return i._emit2DSampler("rampSampler"),
- i._emitVaryingFromString("remapRanges", "vec4", "RAMPGRADIENT"),
- i.compilationString += `
- #ifdef RAMPGRADIENT
- vec4 baseColor = ` + this.color.associatedVariableName + `;
- float alpha = ` + this.color.associatedVariableName + `.a;
- float remappedColorIndex = clamp((alpha - remapRanges.x) / remapRanges.y, 0.0, 1.0);
- vec4 rampColor = texture2D(rampSampler, vec2(1.0 - remappedColorIndex, 0.));
- baseColor.rgb *= rampColor.rgb;
- // Remapped alpha
- float finalAlpha = baseColor.a;
- baseColor.a = clamp((alpha * rampColor.a - remapRanges.z) / remapRanges.w, 0.0, 1.0);
- ` + this._declareOutput(this.rampColor, i) + ` = baseColor;
- #else
- ` + this._declareOutput(this.rampColor, i) + " = " + this.color.associatedVariableName + `;
- #endif
- `,
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.ParticleRampGradientBlock", ParticleRampGradientBlock);
- var ParticleBlendMultiplyBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Fragment) || this;
- return o._isUnique = !0,
- o.registerInput("color", NodeMaterialBlockConnectionPointTypes.Color4, !1, NodeMaterialBlockTargets.Fragment),
- o.registerInput("alphaTexture", NodeMaterialBlockConnectionPointTypes.Float, !1, NodeMaterialBlockTargets.Fragment),
- o.registerInput("alphaColor", NodeMaterialBlockConnectionPointTypes.Float, !1, NodeMaterialBlockTargets.Fragment),
- o.registerOutput("blendColor", NodeMaterialBlockConnectionPointTypes.Color4, NodeMaterialBlockTargets.Fragment),
- o
- }
- return e.prototype.getClassName = function() {
- return "ParticleBlendMultiplyBlock"
- }
- ,
- Object.defineProperty(e.prototype, "color", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "alphaTexture", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "alphaColor", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "blendColor", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.initialize = function(i) {
- i._excludeVariableName("sourceAlpha")
- }
- ,
- e.prototype._buildBlock = function(i) {
- if (a.prototype._buildBlock.call(this, i),
- i.target !== NodeMaterialBlockTargets.Vertex)
- return i.compilationString += `
- #ifdef BLENDMULTIPLYMODE
- ` + this._declareOutput(this.blendColor, i) + `;
- float sourceAlpha = ` + this.alphaColor.associatedVariableName + " * " + this.alphaTexture.associatedVariableName + `;
- ` + this.blendColor.associatedVariableName + ".rgb = " + this.color.associatedVariableName + `.rgb * sourceAlpha + vec3(1.0) * (1.0 - sourceAlpha);
- ` + this.blendColor.associatedVariableName + ".a = " + this.color.associatedVariableName + `.a;
- #else
- ` + this._declareOutput(this.blendColor, i) + " = " + this.color.associatedVariableName + `;
- #endif
- `,
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.ParticleBlendMultiplyBlock", ParticleBlendMultiplyBlock);
- var VectorMergerBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.xSwizzle = "x",
- o.ySwizzle = "y",
- o.zSwizzle = "z",
- o.wSwizzle = "w",
- o.registerInput("xyzw ", NodeMaterialBlockConnectionPointTypes.Vector4, !0),
- o.registerInput("xyz ", NodeMaterialBlockConnectionPointTypes.Vector3, !0),
- o.registerInput("xy ", NodeMaterialBlockConnectionPointTypes.Vector2, !0),
- o.registerInput("zw ", NodeMaterialBlockConnectionPointTypes.Vector2, !0),
- o.registerInput("x", NodeMaterialBlockConnectionPointTypes.Float, !0),
- o.registerInput("y", NodeMaterialBlockConnectionPointTypes.Float, !0),
- o.registerInput("z", NodeMaterialBlockConnectionPointTypes.Float, !0),
- o.registerInput("w", NodeMaterialBlockConnectionPointTypes.Float, !0),
- o.registerOutput("xyzw", NodeMaterialBlockConnectionPointTypes.Vector4),
- o.registerOutput("xyz", NodeMaterialBlockConnectionPointTypes.Vector3),
- o.registerOutput("xy", NodeMaterialBlockConnectionPointTypes.Vector2),
- o.registerOutput("zw", NodeMaterialBlockConnectionPointTypes.Vector2),
- o
- }
- return e.prototype.getClassName = function() {
- return "VectorMergerBlock"
- }
- ,
- Object.defineProperty(e.prototype, "xyzwIn", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "xyzIn", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "xyIn", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "zwIn", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "x", {
- get: function() {
- return this._inputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "y", {
- get: function() {
- return this._inputs[5]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "z", {
- get: function() {
- return this._inputs[6]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "w", {
- get: function() {
- return this._inputs[7]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "xyzw", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "xyzOut", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "xyOut", {
- get: function() {
- return this._outputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "zwOut", {
- get: function() {
- return this._outputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "xy", {
- get: function() {
- return this.xyOut
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "xyz", {
- get: function() {
- return this.xyzOut
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._inputRename = function(i) {
- return i === "xyzw " ? "xyzwIn" : i === "xyz " ? "xyzIn" : i === "xy " ? "xyIn" : i === "zw " ? "zwIn" : i
- }
- ,
- e.prototype._buildSwizzle = function(i) {
- var o = this.xSwizzle + this.ySwizzle + this.zSwizzle + this.wSwizzle;
- return "." + o.substr(0, i)
- }
- ,
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this.x
- , s = this.y
- , c = this.z
- , d = this.w
- , _ = this.xyIn
- , b = this.zwIn
- , k = this.xyzIn
- , j = this.xyzwIn
- , $ = this._outputs[0]
- , _e = this._outputs[1]
- , et = this._outputs[2]
- , tt = this._outputs[3];
- return j.isConnected ? ($.hasEndpoints && (i.compilationString += this._declareOutput($, i) + (" = " + j.associatedVariableName + this._buildSwizzle(4) + `;\r
- `)),
- _e.hasEndpoints && (i.compilationString += this._declareOutput(_e, i) + (" = " + j.associatedVariableName + this._buildSwizzle(3) + `;\r
- `)),
- et.hasEndpoints && (i.compilationString += this._declareOutput(et, i) + (" = " + j.associatedVariableName + this._buildSwizzle(2) + `;\r
- `))) : k.isConnected ? ($.hasEndpoints && (i.compilationString += this._declareOutput($, i) + (" = vec4(" + k.associatedVariableName + ", " + (d.isConnected ? this._writeVariable(d) : "0.0") + ")" + this._buildSwizzle(4) + `;\r
- `)),
- _e.hasEndpoints && (i.compilationString += this._declareOutput(_e, i) + (" = " + k.associatedVariableName + this._buildSwizzle(3) + `;\r
- `)),
- et.hasEndpoints && (i.compilationString += this._declareOutput(et, i) + (" = " + k.associatedVariableName + this._buildSwizzle(2) + `;\r
- `))) : _.isConnected ? ($.hasEndpoints && (b.isConnected ? i.compilationString += this._declareOutput($, i) + (" = vec4(" + _.associatedVariableName + ", " + b.associatedVariableName + ")" + this._buildSwizzle(4) + `;\r
- `) : 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
- `)),
- _e.hasEndpoints && (i.compilationString += this._declareOutput(_e, i) + (" = vec3(" + _.associatedVariableName + ", " + (c.isConnected ? this._writeVariable(c) : "0.0") + ")" + this._buildSwizzle(3) + `;\r
- `)),
- et.hasEndpoints && (i.compilationString += this._declareOutput(et, i) + (" = " + _.associatedVariableName + this._buildSwizzle(2) + `;\r
- `)),
- tt.hasEndpoints && (b.isConnected ? i.compilationString += this._declareOutput(tt, i) + (" = " + b.associatedVariableName + this._buildSwizzle(2) + `;\r
- `) : 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
- `))) : ($.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
- `) : 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
- `)),
- _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
- `)),
- 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
- `)),
- tt.hasEndpoints && (b.isConnected ? i.compilationString += this._declareOutput(tt, i) + (" = " + b.associatedVariableName + this._buildSwizzle(2) + `;\r
- `) : 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
- `))),
- this
- }
- ,
- e.prototype.serialize = function() {
- var i = a.prototype.serialize.call(this);
- return i.xSwizzle = this.xSwizzle,
- i.ySwizzle = this.ySwizzle,
- i.zSwizzle = this.zSwizzle,
- i.wSwizzle = this.wSwizzle,
- i
- }
- ,
- e.prototype._deserialize = function(i, o, s) {
- var c, d, _, b;
- a.prototype._deserialize.call(this, i, o, s),
- this.xSwizzle = (c = i.xSwizzle) !== null && c !== void 0 ? c : "x",
- this.ySwizzle = (d = i.ySwizzle) !== null && d !== void 0 ? d : "y",
- this.zSwizzle = (_ = i.zSwizzle) !== null && _ !== void 0 ? _ : "z",
- this.wSwizzle = (b = i.wSwizzle) !== null && b !== void 0 ? b : "w"
- }
- ,
- e.prototype._dumpPropertiesCode = function() {
- var i = a.prototype._dumpPropertiesCode.call(this);
- return i += this._codeVariableName + '.xSwizzle = "' + this.xSwizzle + `";\r
- `,
- i += this._codeVariableName + '.ySwizzle = "' + this.ySwizzle + `";\r
- `,
- i += this._codeVariableName + '.zSwizzle = "' + this.zSwizzle + `";\r
- `,
- i += this._codeVariableName + '.wSwizzle = "' + this.wSwizzle + `";\r
- `,
- i
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.VectorMergerBlock", VectorMergerBlock);
- var RemapBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.sourceRange = new Vector2(-1,1),
- o.targetRange = new Vector2(0,1),
- o.registerInput("input", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerInput("sourceMin", NodeMaterialBlockConnectionPointTypes.Float, !0),
- o.registerInput("sourceMax", NodeMaterialBlockConnectionPointTypes.Float, !0),
- o.registerInput("targetMin", NodeMaterialBlockConnectionPointTypes.Float, !0),
- o.registerInput("targetMax", NodeMaterialBlockConnectionPointTypes.Float, !0),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
- o._outputs[0]._typeConnectionSource = o._inputs[0],
- o
- }
- return e.prototype.getClassName = function() {
- return "RemapBlock"
- }
- ,
- Object.defineProperty(e.prototype, "input", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "sourceMin", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "sourceMax", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "targetMin", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "targetMax", {
- get: function() {
- return this._inputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0]
- , s = this.sourceMin.isConnected ? this.sourceMin.associatedVariableName : this._writeFloat(this.sourceRange.x)
- , c = this.sourceMax.isConnected ? this.sourceMax.associatedVariableName : this._writeFloat(this.sourceRange.y)
- , d = this.targetMin.isConnected ? this.targetMin.associatedVariableName : this._writeFloat(this.targetRange.x)
- , _ = this.targetMax.isConnected ? this.targetMax.associatedVariableName : this._writeFloat(this.targetRange.y);
- return i.compilationString += this._declareOutput(o, i) + (" = " + d + " + (" + this._inputs[0].associatedVariableName + " - " + s + ") * (" + _ + " - " + d + ") / (" + c + " - " + s + `);\r
- `),
- this
- }
- ,
- e.prototype._dumpPropertiesCode = function() {
- var i = a.prototype._dumpPropertiesCode.call(this) + (this._codeVariableName + ".sourceRange = new BABYLON.Vector2(" + this.sourceRange.x + ", " + this.sourceRange.y + `);\r
- `);
- return i += this._codeVariableName + ".targetRange = new BABYLON.Vector2(" + this.targetRange.x + ", " + this.targetRange.y + `);\r
- `,
- i
- }
- ,
- e.prototype.serialize = function() {
- var i = a.prototype.serialize.call(this);
- return i.sourceRange = this.sourceRange.asArray(),
- i.targetRange = this.targetRange.asArray(),
- i
- }
- ,
- e.prototype._deserialize = function(i, o, s) {
- a.prototype._deserialize.call(this, i, o, s),
- this.sourceRange = Vector2.FromArray(i.sourceRange),
- this.targetRange = Vector2.FromArray(i.targetRange)
- }
- ,
- __decorate([editableInPropertyPage("From", PropertyTypeForEdition.Vector2)], e.prototype, "sourceRange", void 0),
- __decorate([editableInPropertyPage("To", PropertyTypeForEdition.Vector2)], e.prototype, "targetRange", void 0),
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.RemapBlock", RemapBlock);
- var MultiplyBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
- o._outputs[0]._typeConnectionSource = o._inputs[0],
- o._linkConnectionTypes(0, 1),
- o
- }
- return e.prototype.getClassName = function() {
- return "MultiplyBlock"
- }
- ,
- Object.defineProperty(e.prototype, "left", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "right", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0];
- return i.compilationString += this._declareOutput(o, i) + (" = " + this.left.associatedVariableName + " * " + this.right.associatedVariableName + `;\r
- `),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.MultiplyBlock", MultiplyBlock);
- var ColorSplitterBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("rgba", NodeMaterialBlockConnectionPointTypes.Color4, !0),
- o.registerInput("rgb ", NodeMaterialBlockConnectionPointTypes.Color3, !0),
- o.registerOutput("rgb", NodeMaterialBlockConnectionPointTypes.Color3),
- o.registerOutput("r", NodeMaterialBlockConnectionPointTypes.Float),
- o.registerOutput("g", NodeMaterialBlockConnectionPointTypes.Float),
- o.registerOutput("b", NodeMaterialBlockConnectionPointTypes.Float),
- o.registerOutput("a", NodeMaterialBlockConnectionPointTypes.Float),
- o.inputsAreExclusive = !0,
- o
- }
- return e.prototype.getClassName = function() {
- return "ColorSplitterBlock"
- }
- ,
- Object.defineProperty(e.prototype, "rgba", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "rgbIn", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "rgbOut", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "r", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "g", {
- get: function() {
- return this._outputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "b", {
- get: function() {
- return this._outputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "a", {
- get: function() {
- return this._outputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._inputRename = function(i) {
- return i === "rgb " ? "rgbIn" : i
- }
- ,
- e.prototype._outputRename = function(i) {
- return i === "rgb" ? "rgbOut" : i
- }
- ,
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this.rgba.isConnected ? this.rgba : this.rgbIn;
- if (!!o.isConnected) {
- var s = this._outputs[0]
- , c = this._outputs[1]
- , d = this._outputs[2]
- , _ = this._outputs[3]
- , b = this._outputs[4];
- return s.hasEndpoints && (i.compilationString += this._declareOutput(s, i) + (" = " + o.associatedVariableName + `.rgb;\r
- `)),
- c.hasEndpoints && (i.compilationString += this._declareOutput(c, i) + (" = " + o.associatedVariableName + `.r;\r
- `)),
- d.hasEndpoints && (i.compilationString += this._declareOutput(d, i) + (" = " + o.associatedVariableName + `.g;\r
- `)),
- _.hasEndpoints && (i.compilationString += this._declareOutput(_, i) + (" = " + o.associatedVariableName + `.b;\r
- `)),
- b.hasEndpoints && (i.compilationString += this._declareOutput(b, i) + (" = " + o.associatedVariableName + `.a;\r
- `)),
- this
- }
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.ColorSplitterBlock", ColorSplitterBlock);
- var TrigonometryBlockOperations;
- (function(a) {
- a[a.Cos = 0] = "Cos",
- a[a.Sin = 1] = "Sin",
- a[a.Abs = 2] = "Abs",
- a[a.Exp = 3] = "Exp",
- a[a.Exp2 = 4] = "Exp2",
- a[a.Round = 5] = "Round",
- a[a.Floor = 6] = "Floor",
- a[a.Ceiling = 7] = "Ceiling",
- a[a.Sqrt = 8] = "Sqrt",
- a[a.Log = 9] = "Log",
- a[a.Tan = 10] = "Tan",
- a[a.ArcTan = 11] = "ArcTan",
- a[a.ArcCos = 12] = "ArcCos",
- a[a.ArcSin = 13] = "ArcSin",
- a[a.Fract = 14] = "Fract",
- a[a.Sign = 15] = "Sign",
- a[a.Radians = 16] = "Radians",
- a[a.Degrees = 17] = "Degrees"
- }
- )(TrigonometryBlockOperations || (TrigonometryBlockOperations = {}));
- var TrigonometryBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.operation = TrigonometryBlockOperations.Cos,
- o.registerInput("input", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
- o._outputs[0]._typeConnectionSource = o._inputs[0],
- o
- }
- return e.prototype.getClassName = function() {
- return "TrigonometryBlock"
- }
- ,
- Object.defineProperty(e.prototype, "input", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0]
- , s = "";
- switch (this.operation) {
- case TrigonometryBlockOperations.Cos:
- {
- s = "cos";
- break
- }
- case TrigonometryBlockOperations.Sin:
- {
- s = "sin";
- break
- }
- case TrigonometryBlockOperations.Abs:
- {
- s = "abs";
- break
- }
- case TrigonometryBlockOperations.Exp:
- {
- s = "exp";
- break
- }
- case TrigonometryBlockOperations.Exp2:
- {
- s = "exp2";
- break
- }
- case TrigonometryBlockOperations.Round:
- {
- s = "round";
- break
- }
- case TrigonometryBlockOperations.Floor:
- {
- s = "floor";
- break
- }
- case TrigonometryBlockOperations.Ceiling:
- {
- s = "ceil";
- break
- }
- case TrigonometryBlockOperations.Sqrt:
- {
- s = "sqrt";
- break
- }
- case TrigonometryBlockOperations.Log:
- {
- s = "log";
- break
- }
- case TrigonometryBlockOperations.Tan:
- {
- s = "tan";
- break
- }
- case TrigonometryBlockOperations.ArcTan:
- {
- s = "atan";
- break
- }
- case TrigonometryBlockOperations.ArcCos:
- {
- s = "acos";
- break
- }
- case TrigonometryBlockOperations.ArcSin:
- {
- s = "asin";
- break
- }
- case TrigonometryBlockOperations.Fract:
- {
- s = "fract";
- break
- }
- case TrigonometryBlockOperations.Sign:
- {
- s = "sign";
- break
- }
- case TrigonometryBlockOperations.Radians:
- {
- s = "radians";
- break
- }
- case TrigonometryBlockOperations.Degrees:
- {
- s = "degrees";
- break
- }
- }
- return i.compilationString += this._declareOutput(o, i) + (" = " + s + "(" + this.input.associatedVariableName + `);\r
- `),
- this
- }
- ,
- e.prototype.serialize = function() {
- var i = a.prototype.serialize.call(this);
- return i.operation = this.operation,
- i
- }
- ,
- e.prototype._deserialize = function(i, o, s) {
- a.prototype._deserialize.call(this, i, o, s),
- this.operation = i.operation
- }
- ,
- e.prototype._dumpPropertiesCode = function() {
- var i = a.prototype._dumpPropertiesCode.call(this) + (this._codeVariableName + ".operation = BABYLON.TrigonometryBlockOperations." + TrigonometryBlockOperations[this.operation] + `;\r
- `);
- return i
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.TrigonometryBlock", TrigonometryBlock);
- var onCreatedEffectParameters$1 = {
- effect: null,
- subMesh: null
- }
- , NodeMaterialDefines = function(a) {
- __extends(e, a);
- function e() {
- var i = a.call(this) || this;
- return i.NORMAL = !1,
- i.TANGENT = !1,
- i.UV1 = !1,
- i.UV2 = !1,
- i.UV3 = !1,
- i.UV4 = !1,
- i.UV5 = !1,
- i.UV6 = !1,
- i.NUM_BONE_INFLUENCERS = 0,
- i.BonesPerMesh = 0,
- i.BONETEXTURE = !1,
- i.MORPHTARGETS = !1,
- i.MORPHTARGETS_NORMAL = !1,
- i.MORPHTARGETS_TANGENT = !1,
- i.MORPHTARGETS_UV = !1,
- i.NUM_MORPH_INFLUENCERS = 0,
- i.MORPHTARGETS_TEXTURE = !1,
- i.IMAGEPROCESSING = !1,
- i.VIGNETTE = !1,
- i.VIGNETTEBLENDMODEMULTIPLY = !1,
- i.VIGNETTEBLENDMODEOPAQUE = !1,
- i.TONEMAPPING = !1,
- i.TONEMAPPING_ACES = !1,
- i.CONTRAST = !1,
- i.EXPOSURE = !1,
- i.COLORCURVES = !1,
- i.COLORGRADING = !1,
- i.COLORGRADING3D = !1,
- i.SAMPLER3DGREENDEPTH = !1,
- i.SAMPLER3DBGRMAP = !1,
- i.IMAGEPROCESSINGPOSTPROCESS = !1,
- i.SKIPFINALCOLORCLAMP = !1,
- i.BUMPDIRECTUV = 0,
- i.rebuild(),
- i
- }
- return e.prototype.setValue = function(i, o, s) {
- s === void 0 && (s = !1),
- this[i] === void 0 && this._keys.push(i),
- s && this[i] !== o && this.markAsUnprocessed(),
- this[i] = o
- }
- ,
- e
- }(MaterialDefines)
- , NodeMaterial = function(a) {
- __extends(e, a);
- function e(i, o, s) {
- s === void 0 && (s = {});
- var c = a.call(this, i, o || Engine.LastCreatedScene) || this;
- return c._buildId = e._BuildIdGenerator++,
- c._buildWasSuccessful = !1,
- c._cachedWorldViewMatrix = new Matrix,
- c._cachedWorldViewProjectionMatrix = new Matrix,
- c._optimizers = new Array,
- c._animationFrame = -1,
- c.BJSNODEMATERIALEDITOR = c._getGlobalNodeMaterialEditor(),
- c.editorData = null,
- c.ignoreAlpha = !1,
- c.maxSimultaneousLights = 4,
- c.onBuildObservable = new Observable,
- c._vertexOutputNodes = new Array,
- c._fragmentOutputNodes = new Array,
- c.attachedBlocks = new Array,
- c._mode = NodeMaterialModes.Material,
- c._options = __assign({
- emitComments: !1
- }, s),
- c._attachImageProcessingConfiguration(null),
- c
- }
- return e.prototype._getGlobalNodeMaterialEditor = function() {
- if (typeof NODEEDITOR != "undefined")
- return NODEEDITOR;
- if (typeof BABYLON != "undefined" && typeof BABYLON.NodeEditor != "undefined")
- return BABYLON
- }
- ,
- Object.defineProperty(e.prototype, "options", {
- get: function() {
- return this._options
- },
- set: function(i) {
- this._options = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "imageProcessingConfiguration", {
- get: function() {
- return this._imageProcessingConfiguration
- },
- set: function(i) {
- this._attachImageProcessingConfiguration(i),
- this._markAllSubMeshesAsTexturesDirty()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "mode", {
- get: function() {
- return this._mode
- },
- set: function(i) {
- this._mode = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "buildId", {
- get: function() {
- return this._buildId
- },
- set: function(i) {
- this._buildId = i
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getClassName = function() {
- return "NodeMaterial"
- }
- ,
- e.prototype._attachImageProcessingConfiguration = function(i) {
- var o = this;
- i !== this._imageProcessingConfiguration && (this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
- i ? this._imageProcessingConfiguration = i : this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration,
- this._imageProcessingConfiguration && (this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function() {
- o._markAllSubMeshesAsImageProcessingDirty()
- })))
- }
- ,
- e.prototype.getBlockByName = function(i) {
- for (var o = null, s = 0, c = this.attachedBlocks; s < c.length; s++) {
- var d = c[s];
- if (d.name === i)
- if (!o)
- o = d;
- else
- return Tools.Warn("More than one block was found with the name `" + i + "`"),
- o
- }
- return o
- }
- ,
- e.prototype.getBlockByPredicate = function(i) {
- for (var o = 0, s = this.attachedBlocks; o < s.length; o++) {
- var c = s[o];
- if (i(c))
- return c
- }
- return null
- }
- ,
- e.prototype.getInputBlockByPredicate = function(i) {
- for (var o = 0, s = this.attachedBlocks; o < s.length; o++) {
- var c = s[o];
- if (c.isInput && i(c))
- return c
- }
- return null
- }
- ,
- e.prototype.getInputBlocks = function() {
- for (var i = [], o = 0, s = this.attachedBlocks; o < s.length; o++) {
- var c = s[o];
- c.isInput && i.push(c)
- }
- return i
- }
- ,
- e.prototype.registerOptimizer = function(i) {
- var o = this._optimizers.indexOf(i);
- if (!(o > -1))
- return this._optimizers.push(i),
- this
- }
- ,
- e.prototype.unregisterOptimizer = function(i) {
- var o = this._optimizers.indexOf(i);
- if (o !== -1)
- return this._optimizers.splice(o, 1),
- this
- }
- ,
- e.prototype.addOutputNode = function(i) {
- if (i.target === null)
- throw "This node is not meant to be an output node. You may want to explicitly set its target value.";
- return (i.target & NodeMaterialBlockTargets.Vertex) !== 0 && this._addVertexOutputNode(i),
- (i.target & NodeMaterialBlockTargets.Fragment) !== 0 && this._addFragmentOutputNode(i),
- this
- }
- ,
- e.prototype.removeOutputNode = function(i) {
- return i.target === null ? this : ((i.target & NodeMaterialBlockTargets.Vertex) !== 0 && this._removeVertexOutputNode(i),
- (i.target & NodeMaterialBlockTargets.Fragment) !== 0 && this._removeFragmentOutputNode(i),
- this)
- }
- ,
- e.prototype._addVertexOutputNode = function(i) {
- if (this._vertexOutputNodes.indexOf(i) === -1)
- return i.target = NodeMaterialBlockTargets.Vertex,
- this._vertexOutputNodes.push(i),
- this
- }
- ,
- e.prototype._removeVertexOutputNode = function(i) {
- var o = this._vertexOutputNodes.indexOf(i);
- if (o !== -1)
- return this._vertexOutputNodes.splice(o, 1),
- this
- }
- ,
- e.prototype._addFragmentOutputNode = function(i) {
- if (this._fragmentOutputNodes.indexOf(i) === -1)
- return i.target = NodeMaterialBlockTargets.Fragment,
- this._fragmentOutputNodes.push(i),
- this
- }
- ,
- e.prototype._removeFragmentOutputNode = function(i) {
- var o = this._fragmentOutputNodes.indexOf(i);
- if (o !== -1)
- return this._fragmentOutputNodes.splice(o, 1),
- this
- }
- ,
- e.prototype.needAlphaBlending = function() {
- return this.ignoreAlpha ? !1 : this.alpha < 1 || this._sharedData && this._sharedData.hints.needAlphaBlending
- }
- ,
- e.prototype.needAlphaTesting = function() {
- return this._sharedData && this._sharedData.hints.needAlphaTesting
- }
- ,
- e.prototype._initializeBlock = function(i, o, s, c) {
- if (c === void 0 && (c = !0),
- i.initialize(o),
- c && i.autoConfigure(this),
- i._preparationId = this._buildId,
- this.attachedBlocks.indexOf(i) === -1) {
- if (i.isUnique)
- for (var d = i.getClassName(), _ = 0, b = this.attachedBlocks; _ < b.length; _++) {
- var k = b[_];
- if (k.getClassName() === d)
- throw "Cannot have multiple blocks of type " + d + " in the same NodeMaterial"
- }
- this.attachedBlocks.push(i)
- }
- for (var j = 0, $ = i.inputs; j < $.length; j++) {
- var _e = $[j];
- _e.associatedVariableName = "";
- var et = _e.connectedPoint;
- if (et) {
- var tt = et.ownerBlock;
- tt !== i && ((tt.target === NodeMaterialBlockTargets.VertexAndFragment || o.target === NodeMaterialBlockTargets.Fragment && tt.target === NodeMaterialBlockTargets.Vertex && tt._preparationId !== this._buildId) && s.push(tt),
- this._initializeBlock(tt, o, s, c))
- }
- }
- for (var rt = 0, it = i.outputs; rt < it.length; rt++) {
- var nt = it[rt];
- nt.associatedVariableName = ""
- }
- }
- ,
- e.prototype._resetDualBlocks = function(i, o) {
- i.target === NodeMaterialBlockTargets.VertexAndFragment && (i.buildId = o);
- for (var s = 0, c = i.inputs; s < c.length; s++) {
- var d = c[s]
- , _ = d.connectedPoint;
- if (_) {
- var b = _.ownerBlock;
- b !== i && this._resetDualBlocks(b, o)
- }
- }
- }
- ,
- e.prototype.removeBlock = function(i) {
- var o = this.attachedBlocks.indexOf(i);
- o > -1 && this.attachedBlocks.splice(o, 1),
- i.isFinalMerger && this.removeOutputNode(i)
- }
- ,
- e.prototype.build = function(i, o, s) {
- i === void 0 && (i = !1),
- o === void 0 && (o = !0),
- s === void 0 && (s = !0),
- this._buildWasSuccessful = !1;
- var c = this.getScene().getEngine()
- , d = this._mode === NodeMaterialModes.Particle;
- if (this._vertexOutputNodes.length === 0 && !d)
- throw "You must define at least one vertexOutputNode";
- if (this._fragmentOutputNodes.length === 0)
- throw "You must define at least one fragmentOutputNode";
- this._vertexCompilationState = new NodeMaterialBuildState,
- this._vertexCompilationState.supportUniformBuffers = c.supportsUniformBuffers,
- this._vertexCompilationState.target = NodeMaterialBlockTargets.Vertex,
- this._fragmentCompilationState = new NodeMaterialBuildState,
- this._fragmentCompilationState.supportUniformBuffers = c.supportsUniformBuffers,
- this._fragmentCompilationState.target = NodeMaterialBlockTargets.Fragment,
- this._sharedData = new NodeMaterialBuildStateSharedData,
- this._sharedData.fragmentOutputNodes = this._fragmentOutputNodes,
- this._vertexCompilationState.sharedData = this._sharedData,
- this._fragmentCompilationState.sharedData = this._sharedData,
- this._sharedData.buildId = this._buildId,
- this._sharedData.emitComments = this._options.emitComments,
- this._sharedData.verbose = i,
- this._sharedData.scene = this.getScene(),
- this._sharedData.allowEmptyVertexProgram = d;
- for (var _ = [], b = [], k = 0, j = this._vertexOutputNodes; k < j.length; k++) {
- var $ = j[k];
- _.push($),
- this._initializeBlock($, this._vertexCompilationState, b, s)
- }
- for (var _e = 0, et = this._fragmentOutputNodes; _e < et.length; _e++) {
- var tt = et[_e];
- b.push(tt),
- this._initializeBlock(tt, this._fragmentCompilationState, _, s)
- }
- this.optimize();
- for (var rt = 0, it = _; rt < it.length; rt++) {
- var $ = it[rt];
- $.build(this._vertexCompilationState, _)
- }
- this._fragmentCompilationState.uniforms = this._vertexCompilationState.uniforms.slice(0),
- this._fragmentCompilationState._uniformDeclaration = this._vertexCompilationState._uniformDeclaration,
- this._fragmentCompilationState._constantDeclaration = this._vertexCompilationState._constantDeclaration,
- this._fragmentCompilationState._vertexState = this._vertexCompilationState;
- for (var nt = 0, ot = b; nt < ot.length; nt++) {
- var tt = ot[nt];
- this._resetDualBlocks(tt, this._buildId - 1)
- }
- for (var at = 0, st = b; at < st.length; at++) {
- var tt = st[at];
- tt.build(this._fragmentCompilationState, b)
- }
- this._vertexCompilationState.finalize(this._vertexCompilationState),
- this._fragmentCompilationState.finalize(this._fragmentCompilationState),
- o && (this._buildId = e._BuildIdGenerator++),
- this._sharedData.emitErrors(),
- i && (console.log("Vertex shader:"),
- console.log(this._vertexCompilationState.compilationString),
- console.log("Fragment shader:"),
- console.log(this._fragmentCompilationState.compilationString)),
- this._buildWasSuccessful = !0,
- this.onBuildObservable.notifyObservers(this);
- for (var ut = this.getScene().meshes, ct = 0, lt = ut; ct < lt.length; ct++) {
- var ft = lt[ct];
- if (!!ft.subMeshes)
- for (var ht = 0, pt = ft.subMeshes; ht < pt.length; ht++) {
- var dt = pt[ht];
- if (dt.getMaterial() === this && !!dt.materialDefines) {
- var _t = dt.materialDefines;
- _t.markAllAsDirty(),
- _t.reset()
- }
- }
- }
- }
- ,
- e.prototype.optimize = function() {
- for (var i = 0, o = this._optimizers; i < o.length; i++) {
- var s = o[i];
- s.optimize(this._vertexOutputNodes, this._fragmentOutputNodes)
- }
- }
- ,
- e.prototype._prepareDefinesForAttributes = function(i, o) {
- var s = o.NORMAL
- , c = o.TANGENT;
- o.NORMAL = i.isVerticesDataPresent(VertexBuffer.NormalKind),
- o.TANGENT = i.isVerticesDataPresent(VertexBuffer.TangentKind);
- for (var d = !1, _ = 1; _ <= 6; ++_) {
- var b = o["UV" + _];
- o["UV" + _] = i.isVerticesDataPresent("uv" + (_ === 1 ? "" : _)),
- d = d || o["UV" + _] !== b
- }
- (s !== o.NORMAL || c !== o.TANGENT || d) && o.markAsAttributesDirty()
- }
- ,
- e.prototype.createPostProcess = function(i, o, s, c, d, _, b) {
- return o === void 0 && (o = 1),
- s === void 0 && (s = 1),
- _ === void 0 && (_ = 0),
- b === void 0 && (b = 5),
- this.mode !== NodeMaterialModes.PostProcess ? (console.log("Incompatible material mode"),
- null) : this._createEffectForPostProcess(null, i, o, s, c, d, _, b)
- }
- ,
- e.prototype.createEffectForPostProcess = function(i) {
- this._createEffectForPostProcess(i)
- }
- ,
- e.prototype._createEffectForPostProcess = function(i, o, s, c, d, _, b, k) {
- var j = this;
- s === void 0 && (s = 1),
- c === void 0 && (c = 1),
- b === void 0 && (b = 0),
- k === void 0 && (k = 5);
- var $ = this.name + this._buildId
- , _e = new NodeMaterialDefines
- , et = new AbstractMesh($ + "PostProcess",this.getScene())
- , tt = this._buildId;
- return this._processDefines(et, _e),
- Effect.RegisterShader($, this._fragmentCompilationState._builtCompilationString, this._vertexCompilationState._builtCompilationString),
- i ? i.updateEffect(_e.toString(), this._fragmentCompilationState.uniforms, this._fragmentCompilationState.samplers, {
- maxSimultaneousLights: this.maxSimultaneousLights
- }, void 0, void 0, $, $) : i = new PostProcess(this.name + "PostProcess",$,this._fragmentCompilationState.uniforms,this._fragmentCompilationState.samplers,s,o,c,d,_,_e.toString(),b,$,{
- maxSimultaneousLights: this.maxSimultaneousLights
- },!1,k),
- i.nodeMaterialSource = this,
- i.onApplyObservable.add(function(rt) {
- tt !== j._buildId && (delete Effect.ShadersStore[$ + "VertexShader"],
- delete Effect.ShadersStore[$ + "PixelShader"],
- $ = j.name + j._buildId,
- _e.markAllAsDirty(),
- tt = j._buildId);
- var it = j._processDefines(et, _e);
- it && (Effect.RegisterShader($, j._fragmentCompilationState._builtCompilationString, j._vertexCompilationState._builtCompilationString),
- TimingTools.SetImmediate(function() {
- return i.updateEffect(_e.toString(), j._fragmentCompilationState.uniforms, j._fragmentCompilationState.samplers, {
- maxSimultaneousLights: j.maxSimultaneousLights
- }, void 0, void 0, $, $)
- })),
- j._checkInternals(rt)
- }),
- i
- }
- ,
- e.prototype.createProceduralTexture = function(i, o) {
- var s = this;
- if (this.mode !== NodeMaterialModes.ProceduralTexture)
- return console.log("Incompatible material mode"),
- null;
- var c = this.name + this._buildId
- , d = new ProceduralTexture(c,i,null,o)
- , _ = new AbstractMesh(c + "Procedural",this.getScene());
- _.reservedDataStore = {
- hidden: !0
- };
- var b = new NodeMaterialDefines
- , k = this._processDefines(_, b);
- Effect.RegisterShader(c, this._fragmentCompilationState._builtCompilationString, this._vertexCompilationState._builtCompilationString);
- var j = this.getScene().getEngine().createEffect({
- vertexElement: c,
- fragmentElement: c
- }, [VertexBuffer.PositionKind], this._fragmentCompilationState.uniforms, this._fragmentCompilationState.samplers, b.toString(), k == null ? void 0 : k.fallbacks, void 0);
- d.nodeMaterialSource = this,
- d._setEffect(j);
- var $ = this._buildId;
- return d.onBeforeGenerationObservable.add(function() {
- $ !== s._buildId && (delete Effect.ShadersStore[c + "VertexShader"],
- delete Effect.ShadersStore[c + "PixelShader"],
- c = s.name + s._buildId,
- b.markAllAsDirty(),
- $ = s._buildId);
- var _e = s._processDefines(_, b);
- _e && (Effect.RegisterShader(c, s._fragmentCompilationState._builtCompilationString, s._vertexCompilationState._builtCompilationString),
- TimingTools.SetImmediate(function() {
- j = s.getScene().getEngine().createEffect({
- vertexElement: c,
- fragmentElement: c
- }, [VertexBuffer.PositionKind], s._fragmentCompilationState.uniforms, s._fragmentCompilationState.samplers, b.toString(), _e == null ? void 0 : _e.fallbacks, void 0),
- d._setEffect(j)
- })),
- s._checkInternals(j)
- }),
- d
- }
- ,
- e.prototype._createEffectForParticles = function(i, o, s, c, d, _, b, k) {
- var j = this;
- k === void 0 && (k = "");
- var $ = this.name + this._buildId + "_" + o;
- _ || (_ = new NodeMaterialDefines),
- b || (b = this.getScene().getMeshByName(this.name + "Particle"),
- b || (b = new AbstractMesh(this.name + "Particle",this.getScene()),
- b.reservedDataStore = {
- hidden: !0
- }));
- var _e = this._buildId
- , et = []
- , tt = k;
- if (!d) {
- var rt = this._processDefines(b, _);
- Effect.RegisterShader($, this._fragmentCompilationState._builtCompilationString),
- i.fillDefines(et, o),
- tt = et.join(`
- `),
- d = this.getScene().getEngine().createEffectForParticles($, this._fragmentCompilationState.uniforms, this._fragmentCompilationState.samplers, _.toString() + `
- ` + tt, rt == null ? void 0 : rt.fallbacks, s, c, i),
- i.setCustomEffect(d, o)
- }
- d.onBindObservable.add(function(it) {
- _e !== j._buildId && (delete Effect.ShadersStore[$ + "PixelShader"],
- $ = j.name + j._buildId + "_" + o,
- _.markAllAsDirty(),
- _e = j._buildId),
- et.length = 0,
- i.fillDefines(et, o);
- var nt = et.join(`
- `);
- nt !== tt && (_.markAllAsDirty(),
- tt = nt);
- var ot = j._processDefines(b, _);
- if (ot) {
- Effect.RegisterShader($, j._fragmentCompilationState._builtCompilationString),
- it = j.getScene().getEngine().createEffectForParticles($, j._fragmentCompilationState.uniforms, j._fragmentCompilationState.samplers, _.toString() + `
- ` + tt, ot == null ? void 0 : ot.fallbacks, s, c, i),
- i.setCustomEffect(it, o),
- j._createEffectForParticles(i, o, s, c, it, _, b, tt);
- return
- }
- j._checkInternals(it)
- })
- }
- ,
- e.prototype._checkInternals = function(i) {
- if (this._sharedData.animatedInputs) {
- var o = this.getScene()
- , s = o.getFrameId();
- if (this._animationFrame !== s) {
- for (var c = 0, d = this._sharedData.animatedInputs; c < d.length; c++) {
- var _ = d[c];
- _.animate(o)
- }
- this._animationFrame = s
- }
- }
- for (var b = 0, k = this._sharedData.bindableBlocks; b < k.length; b++) {
- var j = k[b];
- j.bind(i, this)
- }
- for (var $ = 0, _e = this._sharedData.inputBlocks; $ < _e.length; $++) {
- var et = _e[$];
- et._transmit(i, this.getScene())
- }
- }
- ,
- e.prototype.createEffectForParticles = function(i, o, s) {
- if (this.mode !== NodeMaterialModes.Particle) {
- console.log("Incompatible material mode");
- return
- }
- this._createEffectForParticles(i, BaseParticleSystem.BLENDMODE_ONEONE, o, s),
- this._createEffectForParticles(i, BaseParticleSystem.BLENDMODE_MULTIPLY, o, s)
- }
- ,
- e.prototype._processDefines = function(i, o, s, c) {
- var d = this;
- s === void 0 && (s = !1);
- var _ = null;
- if (this._sharedData.blocksWithDefines.forEach(function(et) {
- et.initializeDefines(i, d, o, s)
- }),
- this._sharedData.blocksWithDefines.forEach(function(et) {
- et.prepareDefines(i, d, o, s, c)
- }),
- o.isDirty) {
- var b = o._areLightsDisposed;
- o.markAsProcessed(),
- this._vertexCompilationState.compilationString = this._vertexCompilationState._builtCompilationString,
- this._fragmentCompilationState.compilationString = this._fragmentCompilationState._builtCompilationString,
- this._sharedData.repeatableContentBlocks.forEach(function(et) {
- et.replaceRepeatableContent(d._vertexCompilationState, d._fragmentCompilationState, i, o)
- });
- var k = [];
- this._sharedData.dynamicUniformBlocks.forEach(function(et) {
- et.updateUniformsAndSamples(d._vertexCompilationState, d, o, k)
- });
- var j = this._vertexCompilationState.uniforms;
- this._fragmentCompilationState.uniforms.forEach(function(et) {
- var tt = j.indexOf(et);
- tt === -1 && j.push(et)
- });
- var $ = this._vertexCompilationState.samplers;
- this._fragmentCompilationState.samplers.forEach(function(et) {
- var tt = $.indexOf(et);
- tt === -1 && $.push(et)
- });
- var _e = new EffectFallbacks;
- this._sharedData.blocksWithFallbacks.forEach(function(et) {
- et.provideFallbacks(i, _e)
- }),
- _ = {
- lightDisposed: b,
- uniformBuffers: k,
- mergedUniforms: j,
- mergedSamplers: $,
- fallbacks: _e
- }
- }
- return _
- }
- ,
- e.prototype.isReadyForSubMesh = function(i, o, s) {
- var c = this;
- if (s === void 0 && (s = !1),
- !this._buildWasSuccessful)
- return !1;
- var d = this.getScene();
- if (this._sharedData.animatedInputs) {
- var _ = d.getFrameId();
- if (this._animationFrame !== _) {
- for (var b = 0, k = this._sharedData.animatedInputs; b < k.length; b++) {
- var j = k[b];
- j.animate(d)
- }
- this._animationFrame = _
- }
- }
- if (o.effect && this.isFrozen && o.effect._wasPreviouslyReady)
- return !0;
- o.materialDefines || (o.materialDefines = new NodeMaterialDefines);
- var $ = o.materialDefines;
- if (this._isReadyForSubMesh(o))
- return !0;
- var _e = d.getEngine();
- if (this._prepareDefinesForAttributes(i, $),
- this._sharedData.blockingBlocks.some(function(nt) {
- return !nt.isReady(i, c, $, s)
- }))
- return !1;
- var et = this._processDefines(i, $, s, o);
- if (et) {
- var tt = o.effect
- , rt = $.toString()
- , it = _e.createEffect({
- vertex: "nodeMaterial" + this._buildId,
- fragment: "nodeMaterial" + this._buildId,
- vertexSource: this._vertexCompilationState.compilationString,
- fragmentSource: this._fragmentCompilationState.compilationString
- }, {
- attributes: this._vertexCompilationState.attributes,
- uniformsNames: et.mergedUniforms,
- uniformBuffersNames: et.uniformBuffers,
- samplers: et.mergedSamplers,
- defines: rt,
- fallbacks: et.fallbacks,
- onCompiled: this.onCompiled,
- onError: this.onError,
- indexParameters: {
- maxSimultaneousLights: this.maxSimultaneousLights,
- maxSimultaneousMorphTargets: $.NUM_MORPH_INFLUENCERS
- }
- }, _e);
- if (it)
- if (this._onEffectCreatedObservable && (onCreatedEffectParameters$1.effect = it,
- onCreatedEffectParameters$1.subMesh = o,
- this._onEffectCreatedObservable.notifyObservers(onCreatedEffectParameters$1)),
- this.allowShaderHotSwapping && tt && !it.isReady()) {
- if (it = tt,
- $.markAsUnprocessed(),
- et.lightDisposed)
- return $._areLightsDisposed = !0,
- !1
- } else
- d.resetCachedMaterial(),
- o.setEffect(it, $, this._materialContext)
- }
- return !o.effect || !o.effect.isReady() ? !1 : ($._renderId = d.getRenderId(),
- o.effect._wasPreviouslyReady = !0,
- !0)
- }
- ,
- Object.defineProperty(e.prototype, "compiledShaders", {
- get: function() {
- return `// Vertex shader\r
- ` + this._vertexCompilationState.compilationString + `\r
- \r
- // Fragment shader\r
- ` + this._fragmentCompilationState.compilationString
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.bindOnlyWorldMatrix = function(i) {
- var o = this.getScene();
- if (!!this._activeEffect) {
- var s = this._sharedData.hints;
- s.needWorldViewMatrix && i.multiplyToRef(o.getViewMatrix(), this._cachedWorldViewMatrix),
- s.needWorldViewProjectionMatrix && i.multiplyToRef(o.getTransformMatrix(), this._cachedWorldViewProjectionMatrix);
- for (var c = 0, d = this._sharedData.inputBlocks; c < d.length; c++) {
- var _ = d[c];
- _._transmitWorld(this._activeEffect, i, this._cachedWorldViewMatrix, this._cachedWorldViewProjectionMatrix)
- }
- }
- }
- ,
- e.prototype.bindForSubMesh = function(i, o, s) {
- var c = this.getScene()
- , d = s.effect;
- if (!!d) {
- this._activeEffect = d,
- this.bindOnlyWorldMatrix(i);
- var _ = this._mustRebind(c, d, o.visibility)
- , b = this._sharedData;
- if (_) {
- if (d) {
- for (var k = 0, j = b.bindableBlocks; k < j.length; k++) {
- var $ = j[k];
- $.bind(d, this, o, s)
- }
- for (var _e = 0, et = b.forcedBindableBlocks; _e < et.length; _e++) {
- var $ = et[_e];
- $.bind(d, this, o, s)
- }
- for (var tt = 0, rt = b.inputBlocks; tt < rt.length; tt++) {
- var it = rt[tt];
- it._transmit(d, c)
- }
- }
- } else if (!this.isFrozen)
- for (var nt = 0, ot = b.forcedBindableBlocks; nt < ot.length; nt++) {
- var $ = ot[nt];
- $.bind(d, this, o, s)
- }
- this._afterBind(o, this._activeEffect)
- }
- }
- ,
- e.prototype.getActiveTextures = function() {
- var i = a.prototype.getActiveTextures.call(this);
- return this._sharedData && i.push.apply(i, this._sharedData.textureBlocks.filter(function(o) {
- return o.texture
- }).map(function(o) {
- return o.texture
- })),
- i
- }
- ,
- e.prototype.getTextureBlocks = function() {
- return this._sharedData ? this._sharedData.textureBlocks : []
- }
- ,
- e.prototype.hasTexture = function(i) {
- if (a.prototype.hasTexture.call(this, i))
- return !0;
- if (!this._sharedData)
- return !1;
- for (var o = 0, s = this._sharedData.textureBlocks; o < s.length; o++) {
- var c = s[o];
- if (c.texture === i)
- return !0
- }
- return !1
- }
- ,
- e.prototype.dispose = function(i, o, s) {
- if (o && this._sharedData)
- for (var c = 0, d = this._sharedData.textureBlocks.filter(function($) {
- return $.texture
- }).map(function($) {
- return $.texture
- }); c < d.length; c++) {
- var _ = d[c];
- _.dispose()
- }
- for (var b = 0, k = this.attachedBlocks; b < k.length; b++) {
- var j = k[b];
- j.dispose()
- }
- this.attachedBlocks = [],
- this._sharedData = null,
- this._vertexCompilationState = null,
- this._fragmentCompilationState = null,
- this.attachedBlocks = [],
- this._sharedData = null,
- this._vertexCompilationState = null,
- this._fragmentCompilationState = null,
- this.onBuildObservable.clear(),
- this._imageProcessingObserver && (this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
- this._imageProcessingObserver = null),
- a.prototype.dispose.call(this, i, o, s)
- }
- ,
- e.prototype._createNodeEditor = function() {
- this.BJSNODEMATERIALEDITOR.NodeEditor.Show({
- nodeMaterial: this
- })
- }
- ,
- e.prototype.edit = function(i) {
- var o = this;
- return new Promise(function(s, c) {
- if (o.BJSNODEMATERIALEDITOR = o.BJSNODEMATERIALEDITOR || o._getGlobalNodeMaterialEditor(),
- typeof o.BJSNODEMATERIALEDITOR == "undefined") {
- var d = i && i.editorURL ? i.editorURL : e.EditorURL;
- Tools.LoadScript(d, function() {
- o.BJSNODEMATERIALEDITOR = o.BJSNODEMATERIALEDITOR || o._getGlobalNodeMaterialEditor(),
- o._createNodeEditor(),
- s()
- })
- } else
- o._createNodeEditor(),
- s()
- }
- )
- }
- ,
- e.prototype.clear = function() {
- this._vertexOutputNodes = [],
- this._fragmentOutputNodes = [],
- this.attachedBlocks = []
- }
- ,
- e.prototype.setToDefault = function() {
- this.clear(),
- this.editorData = null;
- var i = new InputBlock("Position");
- i.setAsAttribute("position");
- var o = new InputBlock("World");
- o.setAsSystemValue(NodeMaterialSystemValues.World);
- var s = new TransformBlock("WorldPos");
- i.connectTo(s),
- o.connectTo(s);
- var c = new InputBlock("ViewProjection");
- c.setAsSystemValue(NodeMaterialSystemValues.ViewProjection);
- var d = new TransformBlock("WorldPos * ViewProjectionTransform");
- s.connectTo(d),
- c.connectTo(d);
- var _ = new VertexOutputBlock("VertexOutput");
- d.connectTo(_);
- var b = new InputBlock("color");
- b.value = new Color4(.8,.8,.8,1);
- var k = new FragmentOutputBlock("FragmentOutput");
- b.connectTo(k),
- this.addOutputNode(_),
- this.addOutputNode(k),
- this._mode = NodeMaterialModes.Material
- }
- ,
- e.prototype.setToDefaultPostProcess = function() {
- this.clear(),
- this.editorData = null;
- var i = new InputBlock("Position");
- i.setAsAttribute("position2d");
- var o = new InputBlock("Constant1");
- o.isConstant = !0,
- o.value = 1;
- var s = new VectorMergerBlock("Position3D");
- i.connectTo(s),
- o.connectTo(s, {
- input: "w"
- });
- var c = new VertexOutputBlock("VertexOutput");
- s.connectTo(c);
- var d = new InputBlock("Scale");
- d.visibleInInspector = !0,
- d.value = new Vector2(1,1);
- var _ = new RemapBlock("uv0");
- i.connectTo(_);
- var b = new MultiplyBlock("UV scale");
- _.connectTo(b),
- d.connectTo(b);
- var k = new CurrentScreenBlock("CurrentScreen");
- b.connectTo(k),
- k.texture = new Texture("https://assets.babylonjs.com/nme/currentScreenPostProcess.png",this.getScene());
- var j = new FragmentOutputBlock("FragmentOutput");
- k.connectTo(j, {
- output: "rgba"
- }),
- this.addOutputNode(c),
- this.addOutputNode(j),
- this._mode = NodeMaterialModes.PostProcess
- }
- ,
- e.prototype.setToDefaultProceduralTexture = function() {
- this.clear(),
- this.editorData = null;
- var i = new InputBlock("Position");
- i.setAsAttribute("position2d");
- var o = new InputBlock("Constant1");
- o.isConstant = !0,
- o.value = 1;
- var s = new VectorMergerBlock("Position3D");
- i.connectTo(s),
- o.connectTo(s, {
- input: "w"
- });
- var c = new VertexOutputBlock("VertexOutput");
- s.connectTo(c);
- var d = new InputBlock("Time");
- d.value = 0,
- d.min = 0,
- d.max = 0,
- d.isBoolean = !1,
- d.matrixMode = 0,
- d.animationType = AnimatedInputBlockTypes.Time,
- d.isConstant = !1;
- var _ = new InputBlock("Color3");
- _.value = new Color3(1,1,1),
- _.isConstant = !1;
- var b = new FragmentOutputBlock("FragmentOutput")
- , k = new VectorMergerBlock("VectorMerger");
- k.visibleInInspector = !1;
- var j = new TrigonometryBlock("Cos");
- j.operation = TrigonometryBlockOperations.Cos,
- i.connectTo(k),
- d.output.connectTo(j.input),
- j.output.connectTo(k.z),
- k.xyzOut.connectTo(b.rgb),
- this.addOutputNode(c),
- this.addOutputNode(b),
- this._mode = NodeMaterialModes.ProceduralTexture
- }
- ,
- e.prototype.setToDefaultParticle = function() {
- this.clear(),
- this.editorData = null;
- var i = new InputBlock("uv");
- i.setAsAttribute("particle_uv");
- var o = new ParticleTextureBlock("ParticleTexture");
- i.connectTo(o);
- var s = new InputBlock("Color");
- s.setAsAttribute("particle_color");
- var c = new MultiplyBlock("Texture * Color");
- o.connectTo(c),
- s.connectTo(c);
- var d = new ParticleRampGradientBlock("ParticleRampGradient");
- c.connectTo(d);
- var _ = new ColorSplitterBlock("ColorSplitter");
- s.connectTo(_);
- var b = new ParticleBlendMultiplyBlock("ParticleBlendMultiply");
- d.connectTo(b),
- o.connectTo(b, {
- output: "a"
- }),
- _.connectTo(b, {
- output: "a"
- });
- var k = new FragmentOutputBlock("FragmentOutput");
- b.connectTo(k),
- this.addOutputNode(k),
- this._mode = NodeMaterialModes.Particle
- }
- ,
- e.prototype.loadAsync = function(i) {
- var o = this;
- return this.getScene()._loadFileAsync(i).then(function(s) {
- var c = JSON.parse(s);
- o.loadFromSerialization(c, "")
- })
- }
- ,
- e.prototype._gatherBlocks = function(i, o) {
- if (o.indexOf(i) === -1) {
- o.push(i);
- for (var s = 0, c = i.inputs; s < c.length; s++) {
- var d = c[s]
- , _ = d.connectedPoint;
- if (_) {
- var b = _.ownerBlock;
- b !== i && this._gatherBlocks(b, o)
- }
- }
- }
- }
- ,
- e.prototype.generateCode = function() {
- for (var i = [], o = [], s = ["const", "var", "let"], c = 0, d = this._vertexOutputNodes; c < d.length; c++) {
- var _ = d[c];
- this._gatherBlocks(_, o)
- }
- for (var b = [], k = 0, j = this._fragmentOutputNodes; k < j.length; k++) {
- var _ = j[k];
- this._gatherBlocks(_, b)
- }
- for (var $ = 'var nodeMaterial = new BABYLON.NodeMaterial("' + (this.name || "node material") + `");\r
- `, _e = 0, et = o; _e < et.length; _e++) {
- var tt = et[_e];
- tt.isInput && i.indexOf(tt) === -1 && ($ += tt._dumpCode(s, i))
- }
- for (var rt = 0, it = b; rt < it.length; rt++) {
- var tt = it[rt];
- tt.isInput && i.indexOf(tt) === -1 && ($ += tt._dumpCode(s, i))
- }
- i = [],
- $ += `\r
- // Connections\r
- `;
- for (var nt = 0, ot = this._vertexOutputNodes; nt < ot.length; nt++) {
- var tt = ot[nt];
- $ += tt._dumpCodeForOutputConnections(i)
- }
- for (var at = 0, st = this._fragmentOutputNodes; at < st.length; at++) {
- var tt = st[at];
- $ += tt._dumpCodeForOutputConnections(i)
- }
- $ += `\r
- // Output nodes\r
- `;
- for (var ut = 0, ct = this._vertexOutputNodes; ut < ct.length; ut++) {
- var tt = ct[ut];
- $ += "nodeMaterial.addOutputNode(" + tt._codeVariableName + `);\r
- `
- }
- for (var lt = 0, ft = this._fragmentOutputNodes; lt < ft.length; lt++) {
- var tt = ft[lt];
- $ += "nodeMaterial.addOutputNode(" + tt._codeVariableName + `);\r
- `
- }
- return $ += `nodeMaterial.build();\r
- `,
- $
- }
- ,
- e.prototype.serialize = function(i) {
- var o = i ? {} : SerializationHelper.Serialize(this);
- o.editorData = JSON.parse(JSON.stringify(this.editorData));
- var s = [];
- if (i)
- s = i;
- else {
- o.customType = "BABYLON.NodeMaterial",
- o.outputNodes = [];
- for (var c = 0, d = this._vertexOutputNodes; c < d.length; c++) {
- var _ = d[c];
- this._gatherBlocks(_, s),
- o.outputNodes.push(_.uniqueId)
- }
- for (var b = 0, k = this._fragmentOutputNodes; b < k.length; b++) {
- var _ = k[b];
- this._gatherBlocks(_, s),
- o.outputNodes.indexOf(_.uniqueId) === -1 && o.outputNodes.push(_.uniqueId)
- }
- }
- o.blocks = [];
- for (var j = 0, $ = s; j < $.length; j++) {
- var _e = $[j];
- o.blocks.push(_e.serialize())
- }
- if (!i)
- for (var et = 0, tt = this.attachedBlocks; et < tt.length; et++) {
- var _e = tt[et];
- s.indexOf(_e) === -1 && o.blocks.push(_e.serialize())
- }
- return o
- }
- ,
- e.prototype._restoreConnections = function(i, o, s) {
- for (var c = 0, d = i.outputs; c < d.length; c++)
- for (var _ = d[c], b = 0, k = o.blocks; b < k.length; b++) {
- var j = k[b]
- , $ = s[j.id];
- if (!!$)
- for (var _e = 0, et = j.inputs; _e < et.length; _e++) {
- var tt = et[_e];
- if (s[tt.targetBlockId] === i && tt.targetConnectionName === _.name) {
- var rt = $.getInputByName(tt.inputName);
- if (!rt || rt.isConnected)
- continue;
- _.connectTo(rt, !0),
- this._restoreConnections($, o, s);
- continue
- }
- }
- }
- }
- ,
- e.prototype.loadFromSerialization = function(i, o, s) {
- var c;
- o === void 0 && (o = ""),
- s === void 0 && (s = !1),
- s || this.clear();
- for (var d = {}, _ = 0, b = i.blocks; _ < b.length; _++) {
- var k = b[_]
- , j = GetClass(k.customType);
- if (j) {
- var $ = new j;
- $._deserialize(k, this.getScene(), o),
- d[k.id] = $,
- this.attachedBlocks.push($)
- }
- }
- for (var _e = 0; _e < i.blocks.length; _e++) {
- var et = i.blocks[_e]
- , $ = d[et.id];
- !$ || $.inputs.length && !s || this._restoreConnections($, i, d)
- }
- if (i.outputNodes)
- for (var tt = 0, rt = i.outputNodes; tt < rt.length; tt++) {
- var it = rt[tt];
- this.addOutputNode(d[it])
- }
- if (i.locations || i.editorData && i.editorData.locations) {
- for (var nt = i.locations || i.editorData.locations, ot = 0, at = nt; ot < at.length; ot++) {
- var st = at[ot];
- d[st.blockId] && (st.blockId = d[st.blockId].uniqueId)
- }
- s && this.editorData && this.editorData.locations && nt.concat(this.editorData.locations),
- i.locations ? this.editorData = {
- locations: nt
- } : (this.editorData = i.editorData,
- this.editorData.locations = nt);
- var ut = [];
- for (var ct in d)
- ut[ct] = d[ct].uniqueId;
- this.editorData.map = ut
- }
- this.comment = i.comment,
- s || (this._mode = (c = i.mode) !== null && c !== void 0 ? c : NodeMaterialModes.Material)
- }
- ,
- e.prototype.clone = function(i, o) {
- var s = this;
- o === void 0 && (o = !1);
- var c = this.serialize()
- , d = SerializationHelper.Clone(function() {
- return new e(i,s.getScene(),s.options)
- }, this);
- return d.id = i,
- d.name = i,
- d.loadFromSerialization(c),
- d._buildId = this._buildId,
- d.build(!1, !o),
- d
- }
- ,
- e.Parse = function(i, o, s) {
- s === void 0 && (s = "");
- var c = SerializationHelper.Parse(function() {
- return new e(i.name,o)
- }, i, o, s);
- return c.loadFromSerialization(i, s),
- c.build(),
- c
- }
- ,
- e.ParseFromFileAsync = function(i, o, s) {
- var c = new e(i,s);
- return new Promise(function(d, _) {
- return c.loadAsync(o).then(function() {
- c.build(),
- d(c)
- }).catch(_)
- }
- )
- }
- ,
- e.ParseFromSnippetAsync = function(i, o, s, c) {
- var d = this;
- return s === void 0 && (s = ""),
- i === "_BLANK" ? Promise.resolve(this.CreateDefault("blank", o)) : new Promise(function(_, b) {
- var k = new WebRequest;
- k.addEventListener("readystatechange", function() {
- if (k.readyState == 4)
- if (k.status == 200) {
- var j = JSON.parse(JSON.parse(k.responseText).jsonPayload)
- , $ = JSON.parse(j.nodeMaterial);
- c || (c = SerializationHelper.Parse(function() {
- return new e(i,o)
- }, $, o, s),
- c.uniqueId = o.getUniqueId()),
- c.loadFromSerialization($),
- c.snippetId = i;
- try {
- c.build(),
- _(c)
- } catch (_e) {
- b(_e)
- }
- } else
- b("Unable to load the snippet " + i)
- }),
- k.open("GET", d.SnippetUrl + "/" + i.replace(/#/g, "/")),
- k.send()
- }
- )
- }
- ,
- e.CreateDefault = function(i, o) {
- var s = new e(i,o);
- return s.setToDefault(),
- s.build(),
- s
- }
- ,
- e._BuildIdGenerator = 0,
- e.EditorURL = "https://unpkg.com/babylonjs-node-editor@" + Engine.Version + "/babylon.nodeEditor.js",
- e.SnippetUrl = "https://snippet.babylonjs.com",
- e.IgnoreTexturesAtLoadTime = !1,
- __decorate([serialize()], e.prototype, "ignoreAlpha", void 0),
- __decorate([serialize()], e.prototype, "maxSimultaneousLights", void 0),
- __decorate([serialize("mode")], e.prototype, "_mode", void 0),
- __decorate([serialize("comment")], e.prototype, "comment", void 0),
- e
- }(PushMaterial);
- RegisterClass("BABYLON.NodeMaterial", NodeMaterial);
- var BonesBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Vertex) || this;
- return o.registerInput("matricesIndices", NodeMaterialBlockConnectionPointTypes.Vector4),
- o.registerInput("matricesWeights", NodeMaterialBlockConnectionPointTypes.Vector4),
- o.registerInput("matricesIndicesExtra", NodeMaterialBlockConnectionPointTypes.Vector4, !0),
- o.registerInput("matricesWeightsExtra", NodeMaterialBlockConnectionPointTypes.Vector4, !0),
- o.registerInput("world", NodeMaterialBlockConnectionPointTypes.Matrix),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Matrix),
- o
- }
- return e.prototype.initialize = function(i) {
- i._excludeVariableName("boneSampler"),
- i._excludeVariableName("boneTextureWidth"),
- i._excludeVariableName("mBones"),
- i._excludeVariableName("BonesPerMesh")
- }
- ,
- e.prototype.getClassName = function() {
- return "BonesBlock"
- }
- ,
- Object.defineProperty(e.prototype, "matricesIndices", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "matricesWeights", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "matricesIndicesExtra", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "matricesWeightsExtra", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "world", {
- get: function() {
- return this._inputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.autoConfigure = function(i) {
- if (!this.matricesIndices.isConnected) {
- var o = i.getInputBlockByPredicate(function(d) {
- return d.isAttribute && d.name === "matricesIndices"
- });
- o || (o = new InputBlock("matricesIndices"),
- o.setAsAttribute("matricesIndices")),
- o.output.connectTo(this.matricesIndices)
- }
- if (!this.matricesWeights.isConnected) {
- var s = i.getInputBlockByPredicate(function(d) {
- return d.isAttribute && d.name === "matricesWeights"
- });
- s || (s = new InputBlock("matricesWeights"),
- s.setAsAttribute("matricesWeights")),
- s.output.connectTo(this.matricesWeights)
- }
- if (!this.world.isConnected) {
- var c = i.getInputBlockByPredicate(function(d) {
- return d.systemValue === NodeMaterialSystemValues.World
- });
- c || (c = new InputBlock("world"),
- c.setAsSystemValue(NodeMaterialSystemValues.World)),
- c.output.connectTo(this.world)
- }
- }
- ,
- e.prototype.provideFallbacks = function(i, o) {
- i && i.useBones && i.computeBonesUsingShaders && i.skeleton && o.addCPUSkinningFallback(0, i)
- }
- ,
- e.prototype.bind = function(i, o, s) {
- MaterialHelper.BindBonesParameters(s, i)
- }
- ,
- e.prototype.prepareDefines = function(i, o, s) {
- !s._areAttributesDirty || MaterialHelper.PrepareDefinesForBones(i, s)
- }
- ,
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i),
- i.sharedData.blocksWithFallbacks.push(this),
- i.sharedData.bindableBlocks.push(this),
- i.sharedData.blocksWithDefines.push(this),
- i.uniforms.push("boneTextureWidth"),
- i.uniforms.push("mBones"),
- i.samplers.push("boneSampler");
- var o = "//" + this.name;
- i._emitFunctionFromInclude("bonesDeclaration", o, {
- removeAttributes: !0,
- removeUniforms: !1,
- removeVaryings: !0,
- removeIfDef: !1
- });
- var s = i._getFreeVariableName("influence");
- i.compilationString += i._emitCodeFromInclude("bonesVertex", o, {
- replaceStrings: [{
- search: /finalWorld=finalWorld\*influence;/,
- replace: ""
- }, {
- search: /influence/gm,
- replace: s
- }]
- });
- var c = this._outputs[0]
- , d = this.world;
- return i.compilationString += `#if NUM_BONE_INFLUENCERS>0\r
- `,
- i.compilationString += this._declareOutput(c, i) + (" = " + d.associatedVariableName + " * " + s + `;\r
- `),
- i.compilationString += `#else\r
- `,
- i.compilationString += this._declareOutput(c, i) + (" = " + d.associatedVariableName + `;\r
- `),
- i.compilationString += `#endif\r
- `,
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.BonesBlock", BonesBlock);
- var InstancesBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Vertex) || this;
- return o.registerInput("world0", NodeMaterialBlockConnectionPointTypes.Vector4),
- o.registerInput("world1", NodeMaterialBlockConnectionPointTypes.Vector4),
- o.registerInput("world2", NodeMaterialBlockConnectionPointTypes.Vector4),
- o.registerInput("world3", NodeMaterialBlockConnectionPointTypes.Vector4),
- o.registerInput("world", NodeMaterialBlockConnectionPointTypes.Matrix, !0),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Matrix),
- o.registerOutput("instanceID", NodeMaterialBlockConnectionPointTypes.Float),
- o
- }
- return e.prototype.getClassName = function() {
- return "InstancesBlock"
- }
- ,
- Object.defineProperty(e.prototype, "world0", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "world1", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "world2", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "world3", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "world", {
- get: function() {
- return this._inputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "instanceID", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.autoConfigure = function(i) {
- if (!this.world0.connectedPoint) {
- var o = i.getInputBlockByPredicate(function(b) {
- return b.isAttribute && b.name === "world0"
- });
- o || (o = new InputBlock("world0"),
- o.setAsAttribute("world0")),
- o.output.connectTo(this.world0)
- }
- if (!this.world1.connectedPoint) {
- var s = i.getInputBlockByPredicate(function(b) {
- return b.isAttribute && b.name === "world1"
- });
- s || (s = new InputBlock("world1"),
- s.setAsAttribute("world1")),
- s.output.connectTo(this.world1)
- }
- if (!this.world2.connectedPoint) {
- var c = i.getInputBlockByPredicate(function(b) {
- return b.isAttribute && b.name === "world2"
- });
- c || (c = new InputBlock("world2"),
- c.setAsAttribute("world2")),
- c.output.connectTo(this.world2)
- }
- if (!this.world3.connectedPoint) {
- var d = i.getInputBlockByPredicate(function(b) {
- return b.isAttribute && b.name === "world3"
- });
- d || (d = new InputBlock("world3"),
- d.setAsAttribute("world3")),
- d.output.connectTo(this.world3)
- }
- if (!this.world.connectedPoint) {
- var _ = i.getInputBlockByPredicate(function(b) {
- return b.isAttribute && b.name === "world"
- });
- _ || (_ = new InputBlock("world"),
- _.setAsSystemValue(NodeMaterialSystemValues.World)),
- _.output.connectTo(this.world)
- }
- this.world.define = "!INSTANCES || THIN_INSTANCES"
- }
- ,
- e.prototype.prepareDefines = function(i, o, s, c, d) {
- c === void 0 && (c = !1);
- var _ = !1;
- s.INSTANCES !== c && (s.setValue("INSTANCES", c),
- _ = !0),
- d && s.THIN_INSTANCES !== !!(d != null && d.getRenderingMesh().hasThinInstances) && (s.setValue("THIN_INSTANCES", !!(d != null && d.getRenderingMesh().hasThinInstances)),
- _ = !0),
- _ && s.markAsUnprocessed()
- }
- ,
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = i.sharedData.scene.getEngine();
- i.sharedData.blocksWithDefines.push(this);
- var s = this._outputs[0]
- , c = this._outputs[1]
- , d = this.world0
- , _ = this.world1
- , b = this.world2
- , k = this.world3;
- return i.compilationString += `#ifdef INSTANCES\r
- `,
- i.compilationString += this._declareOutput(s, i) + (" = mat4(" + d.associatedVariableName + ", " + _.associatedVariableName + ", " + b.associatedVariableName + ", " + k.associatedVariableName + `);\r
- `),
- i.compilationString += `#ifdef THIN_INSTANCES\r
- `,
- i.compilationString += s.associatedVariableName + " = " + this.world.associatedVariableName + " * " + s.associatedVariableName + `;\r
- `,
- i.compilationString += `#endif\r
- `,
- o._caps.canUseGLInstanceID ? i.compilationString += this._declareOutput(c, i) + ` = float(gl_InstanceID);\r
- ` : i.compilationString += this._declareOutput(c, i) + ` = 0.0;\r
- `,
- i.compilationString += `#else\r
- `,
- i.compilationString += this._declareOutput(s, i) + (" = " + this.world.associatedVariableName + `;\r
- `),
- i.compilationString += this._declareOutput(c, i) + ` = 0.0;\r
- `,
- i.compilationString += `#endif\r
- `,
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.InstancesBlock", InstancesBlock);
- var MorphTargetsBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Vertex) || this;
- return o.registerInput("position", NodeMaterialBlockConnectionPointTypes.Vector3),
- o.registerInput("normal", NodeMaterialBlockConnectionPointTypes.Vector3),
- o.registerInput("tangent", NodeMaterialBlockConnectionPointTypes.Vector3),
- o.registerInput("uv", NodeMaterialBlockConnectionPointTypes.Vector2),
- o.registerOutput("positionOutput", NodeMaterialBlockConnectionPointTypes.Vector3),
- o.registerOutput("normalOutput", NodeMaterialBlockConnectionPointTypes.Vector3),
- o.registerOutput("tangentOutput", NodeMaterialBlockConnectionPointTypes.Vector3),
- o.registerOutput("uvOutput", NodeMaterialBlockConnectionPointTypes.Vector2),
- o
- }
- return e.prototype.getClassName = function() {
- return "MorphTargetsBlock"
- }
- ,
- Object.defineProperty(e.prototype, "position", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "normal", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "tangent", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "uv", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "positionOutput", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "normalOutput", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "tangentOutput", {
- get: function() {
- return this._outputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "uvOutput", {
- get: function() {
- return this._outputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.initialize = function(i) {
- i._excludeVariableName("morphTargetInfluences")
- }
- ,
- e.prototype.autoConfigure = function(i) {
- if (!this.position.isConnected) {
- var o = i.getInputBlockByPredicate(function(_) {
- return _.isAttribute && _.name === "position"
- });
- o || (o = new InputBlock("position"),
- o.setAsAttribute()),
- o.output.connectTo(this.position)
- }
- if (!this.normal.isConnected) {
- var s = i.getInputBlockByPredicate(function(_) {
- return _.isAttribute && _.name === "normal"
- });
- s || (s = new InputBlock("normal"),
- s.setAsAttribute("normal")),
- s.output.connectTo(this.normal)
- }
- if (!this.tangent.isConnected) {
- var c = i.getInputBlockByPredicate(function(_) {
- return _.isAttribute && _.name === "tangent"
- });
- c || (c = new InputBlock("tangent"),
- c.setAsAttribute("tangent")),
- c.output.connectTo(this.tangent)
- }
- if (!this.uv.isConnected) {
- var d = i.getInputBlockByPredicate(function(_) {
- return _.isAttribute && _.name === "uv"
- });
- d || (d = new InputBlock("uv"),
- d.setAsAttribute("uv")),
- d.output.connectTo(this.uv)
- }
- }
- ,
- e.prototype.prepareDefines = function(i, o, s) {
- if (i.morphTargetManager) {
- var c = i.morphTargetManager;
- (c == null ? void 0 : c.isUsingTextureForTargets) && c.numInfluencers !== s.NUM_MORPH_INFLUENCERS && s.markAsAttributesDirty()
- }
- !s._areAttributesDirty || MaterialHelper.PrepareDefinesForMorphTargets(i, s)
- }
- ,
- e.prototype.bind = function(i, o, s) {
- s && s.morphTargetManager && s.morphTargetManager.numInfluencers > 0 && (MaterialHelper.BindMorphTargetParameters(s, i),
- s.morphTargetManager.isUsingTextureForTargets && s.morphTargetManager._bind(i))
- }
- ,
- e.prototype.replaceRepeatableContent = function(i, o, s, c) {
- var d = this.position
- , _ = this.normal
- , b = this.tangent
- , k = this.uv
- , j = this.positionOutput
- , $ = this.normalOutput
- , _e = this.tangentOutput
- , et = this.uvOutput
- , tt = i
- , rt = c.NUM_MORPH_INFLUENCERS
- , it = s.morphTargetManager
- , nt = it && it.supportsNormals && c.NORMAL
- , ot = it && it.supportsTangents && c.TANGENT
- , at = it && it.supportsUVs && c.UV1
- , st = "";
- (it == null ? void 0 : it.isUsingTextureForTargets) && rt > 0 && (st += `float vertexID;\r
- `);
- for (var ut = 0; ut < rt; ut++)
- st += `#ifdef MORPHTARGETS\r
- `,
- it != null && it.isUsingTextureForTargets ? (st += `vertexID = float(gl_VertexID) * morphTargetTextureInfo.x;\r
- `,
- st += j.associatedVariableName + " += (readVector3FromRawSampler(" + ut + ", vertexID) - " + d.associatedVariableName + ") * morphTargetInfluences[" + ut + `];\r
- `,
- st += `vertexID += 1.0;\r
- `) : st += j.associatedVariableName + " += (position" + ut + " - " + d.associatedVariableName + ") * morphTargetInfluences[" + ut + `];\r
- `,
- nt && (st += `#ifdef MORPHTARGETS_NORMAL\r
- `,
- it != null && it.isUsingTextureForTargets ? (st += $.associatedVariableName + " += (readVector3FromRawSampler(" + ut + ", vertexID) - " + _.associatedVariableName + ") * morphTargetInfluences[" + ut + `];\r
- `,
- st += `vertexID += 1.0;\r
- `) : st += $.associatedVariableName + " += (normal" + ut + " - " + _.associatedVariableName + ") * morphTargetInfluences[" + ut + `];\r
- `,
- st += `#endif\r
- `),
- at && (st += `#ifdef MORPHTARGETS_UV\r
- `,
- it != null && it.isUsingTextureForTargets ? (st += et.associatedVariableName + " += (readVector3FromRawSampler(" + ut + ", vertexID).xy - " + k.associatedVariableName + ") * morphTargetInfluences[" + ut + `];\r
- `,
- st += `vertexID += 1.0;\r
- `) : st += et.associatedVariableName + ".xy += (uv_" + ut + " - " + k.associatedVariableName + ".xy) * morphTargetInfluences[" + ut + `];\r
- `,
- st += `#endif\r
- `),
- ot && (st += `#ifdef MORPHTARGETS_TANGENT\r
- `,
- it != null && it.isUsingTextureForTargets ? st += _e.associatedVariableName + " += (readVector3FromRawSampler(" + ut + ", vertexID) - " + b.associatedVariableName + ") * morphTargetInfluences[" + ut + `];\r
- ` : st += _e.associatedVariableName + ".xyz += (tangent" + ut + " - " + b.associatedVariableName + ".xyz) * morphTargetInfluences[" + ut + `];\r
- `,
- st += `#endif\r
- `),
- st += `#endif\r
- `;
- if (tt.compilationString = tt.compilationString.replace(this._repeatableContentAnchor, st),
- rt > 0)
- for (var ut = 0; ut < rt; ut++)
- tt.attributes.push(VertexBuffer.PositionKind + ut),
- nt && tt.attributes.push(VertexBuffer.NormalKind + ut),
- ot && tt.attributes.push(VertexBuffer.TangentKind + ut),
- at && tt.attributes.push(VertexBuffer.UVKind + "_" + ut)
- }
- ,
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i),
- i.sharedData.blocksWithDefines.push(this),
- i.sharedData.bindableBlocks.push(this),
- i.sharedData.repeatableContentBlocks.push(this);
- var o = this.position
- , s = this.normal
- , c = this.tangent
- , d = this.uv
- , _ = this.positionOutput
- , b = this.normalOutput
- , k = this.tangentOutput
- , j = this.uvOutput
- , $ = "//" + this.name;
- return i.uniforms.push("morphTargetInfluences"),
- i.uniforms.push("morphTargetTextureInfo"),
- i.uniforms.push("morphTargetTextureIndices"),
- i.samplers.push("morphTargets"),
- i._emitFunctionFromInclude("morphTargetsVertexGlobalDeclaration", $),
- i._emitFunctionFromInclude("morphTargetsVertexDeclaration", $, {
- repeatKey: "maxSimultaneousMorphTargets"
- }),
- i.compilationString += this._declareOutput(_, i) + " = " + o.associatedVariableName + `;\r
- `,
- i.compilationString += `#ifdef NORMAL\r
- `,
- i.compilationString += this._declareOutput(b, i) + " = " + s.associatedVariableName + `;\r
- `,
- i.compilationString += `#else\r
- `,
- i.compilationString += this._declareOutput(b, i) + ` = vec3(0., 0., 0.);\r
- `,
- i.compilationString += `#endif\r
- `,
- i.compilationString += `#ifdef TANGENT\r
- `,
- i.compilationString += this._declareOutput(k, i) + " = " + c.associatedVariableName + `;\r
- `,
- i.compilationString += `#else\r
- `,
- i.compilationString += this._declareOutput(k, i) + ` = vec3(0., 0., 0.);\r
- `,
- i.compilationString += `#endif\r
- `,
- i.compilationString += `#ifdef UV1\r
- `,
- i.compilationString += this._declareOutput(j, i) + " = " + d.associatedVariableName + `;\r
- `,
- i.compilationString += `#else\r
- `,
- i.compilationString += this._declareOutput(j, i) + ` = vec2(0., 0.);\r
- `,
- i.compilationString += `#endif\r
- `,
- this._repeatableContentAnchor = i._repeatableContentAnchor,
- i.compilationString += this._repeatableContentAnchor,
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.MorphTargetsBlock", MorphTargetsBlock);
- var LightInformationBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Vertex) || this;
- return o.registerInput("worldPosition", NodeMaterialBlockConnectionPointTypes.Vector4, !1, NodeMaterialBlockTargets.Vertex),
- o.registerOutput("direction", NodeMaterialBlockConnectionPointTypes.Vector3),
- o.registerOutput("color", NodeMaterialBlockConnectionPointTypes.Color3),
- o.registerOutput("intensity", NodeMaterialBlockConnectionPointTypes.Float),
- o
- }
- return e.prototype.getClassName = function() {
- return "LightInformationBlock"
- }
- ,
- Object.defineProperty(e.prototype, "worldPosition", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "direction", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "color", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "intensity", {
- get: function() {
- return this._outputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.bind = function(i, o, s) {
- if (!!s) {
- this.light && this.light.isDisposed && (this.light = null);
- var c = this.light
- , d = o.getScene();
- if (!c && d.lights.length && (c = this.light = d.lights[0],
- this._forcePrepareDefines = !0),
- !c || !c.isEnabled) {
- i.setFloat3(this._lightDataUniformName, 0, 0, 0),
- i.setFloat4(this._lightColorUniformName, 0, 0, 0, 0);
- return
- }
- c.transferToNodeMaterialEffect(i, this._lightDataUniformName),
- i.setColor4(this._lightColorUniformName, c.diffuse, c.intensity)
- }
- }
- ,
- e.prototype.prepareDefines = function(i, o, s) {
- if (!(!s._areLightsDirty && !this._forcePrepareDefines)) {
- this._forcePrepareDefines = !1;
- var c = this.light;
- s.setValue(this._lightTypeDefineName, !!(c && c instanceof PointLight), !0)
- }
- }
- ,
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i),
- i.sharedData.bindableBlocks.push(this),
- i.sharedData.blocksWithDefines.push(this);
- var o = this.direction
- , s = this.color
- , c = this.intensity;
- return this._lightDataUniformName = i._getFreeVariableName("lightData"),
- this._lightColorUniformName = i._getFreeVariableName("lightColor"),
- this._lightTypeDefineName = i._getFreeDefineName("LIGHTPOINTTYPE"),
- i._emitUniformFromString(this._lightDataUniformName, "vec3"),
- i._emitUniformFromString(this._lightColorUniformName, "vec4"),
- i.compilationString += "#ifdef " + this._lightTypeDefineName + `\r
- `,
- i.compilationString += this._declareOutput(o, i) + (" = normalize(" + this.worldPosition.associatedVariableName + ".xyz - " + this._lightDataUniformName + `);\r
- `),
- i.compilationString += `#else\r
- `,
- i.compilationString += this._declareOutput(o, i) + (" = " + this._lightDataUniformName + `;\r
- `),
- i.compilationString += `#endif\r
- `,
- i.compilationString += this._declareOutput(s, i) + (" = " + this._lightColorUniformName + `.rgb;\r
- `),
- i.compilationString += this._declareOutput(c, i) + (" = " + this._lightColorUniformName + `.a;\r
- `),
- this
- }
- ,
- e.prototype.serialize = function() {
- var i = a.prototype.serialize.call(this);
- return this.light && (i.lightId = this.light.id),
- i
- }
- ,
- e.prototype._deserialize = function(i, o, s) {
- a.prototype._deserialize.call(this, i, o, s),
- i.lightId && (this.light = o.getLightById(i.lightId))
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.LightInformationBlock", LightInformationBlock);
- var ImageProcessingBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Fragment) || this;
- return o.convertInputToLinearSpace = !0,
- o.registerInput("color", NodeMaterialBlockConnectionPointTypes.Color4),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Color4),
- o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color3),
- o
- }
- return e.prototype.getClassName = function() {
- return "ImageProcessingBlock"
- }
- ,
- Object.defineProperty(e.prototype, "color", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.initialize = function(i) {
- i._excludeVariableName("exposureLinear"),
- i._excludeVariableName("contrast"),
- i._excludeVariableName("vInverseScreenSize"),
- i._excludeVariableName("vignetteSettings1"),
- i._excludeVariableName("vignetteSettings2"),
- i._excludeVariableName("vCameraColorCurveNegative"),
- i._excludeVariableName("vCameraColorCurveNeutral"),
- i._excludeVariableName("vCameraColorCurvePositive"),
- i._excludeVariableName("txColorTransform"),
- i._excludeVariableName("colorTransformSettings")
- }
- ,
- e.prototype.isReady = function(i, o, s) {
- return !(s._areImageProcessingDirty && o.imageProcessingConfiguration && !o.imageProcessingConfiguration.isReady())
- }
- ,
- e.prototype.prepareDefines = function(i, o, s) {
- s._areImageProcessingDirty && o.imageProcessingConfiguration && o.imageProcessingConfiguration.prepareDefines(s)
- }
- ,
- e.prototype.bind = function(i, o, s) {
- !s || !o.imageProcessingConfiguration || o.imageProcessingConfiguration.bind(i)
- }
- ,
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i),
- i.sharedData.blocksWithDefines.push(this),
- i.sharedData.blockingBlocks.push(this),
- i.sharedData.bindableBlocks.push(this),
- i.uniforms.push("exposureLinear"),
- i.uniforms.push("contrast"),
- i.uniforms.push("vInverseScreenSize"),
- i.uniforms.push("vignetteSettings1"),
- i.uniforms.push("vignetteSettings2"),
- i.uniforms.push("vCameraColorCurveNegative"),
- i.uniforms.push("vCameraColorCurveNeutral"),
- i.uniforms.push("vCameraColorCurvePositive"),
- i.uniforms.push("txColorTransform"),
- i.uniforms.push("colorTransformSettings");
- var o = this.color
- , s = this._outputs[0]
- , c = "//" + this.name;
- return i._emitFunctionFromInclude("helperFunctions", c),
- i._emitFunctionFromInclude("imageProcessingDeclaration", c),
- i._emitFunctionFromInclude("imageProcessingFunctions", c),
- o.connectedPoint.type === NodeMaterialBlockConnectionPointTypes.Color4 || o.connectedPoint.type === NodeMaterialBlockConnectionPointTypes.Vector4 ? i.compilationString += this._declareOutput(s, i) + " = " + o.associatedVariableName + `;\r
- ` : i.compilationString += this._declareOutput(s, i) + " = vec4(" + o.associatedVariableName + `, 1.0);\r
- `,
- i.compilationString += `#ifdef IMAGEPROCESSINGPOSTPROCESS\r
- `,
- this.convertInputToLinearSpace && (i.compilationString += s.associatedVariableName + ".rgb = toLinearSpace(" + o.associatedVariableName + `.rgb);\r
- `),
- i.compilationString += `#else\r
- `,
- i.compilationString += `#ifdef IMAGEPROCESSING\r
- `,
- this.convertInputToLinearSpace && (i.compilationString += s.associatedVariableName + ".rgb = toLinearSpace(" + o.associatedVariableName + `.rgb);\r
- `),
- i.compilationString += s.associatedVariableName + " = applyImageProcessing(" + s.associatedVariableName + `);\r
- `,
- i.compilationString += `#endif\r
- `,
- i.compilationString += `#endif\r
- `,
- this
- }
- ,
- e.prototype._dumpPropertiesCode = function() {
- var i = a.prototype._dumpPropertiesCode.call(this);
- return i += this._codeVariableName + ".convertInputToLinearSpace = " + this.convertInputToLinearSpace + `;\r
- `,
- i
- }
- ,
- e.prototype.serialize = function() {
- var i = a.prototype.serialize.call(this);
- return i.convertInputToLinearSpace = this.convertInputToLinearSpace,
- i
- }
- ,
- e.prototype._deserialize = function(i, o, s) {
- var c;
- a.prototype._deserialize.call(this, i, o, s),
- this.convertInputToLinearSpace = (c = i.convertInputToLinearSpace) !== null && c !== void 0 ? c : !0
- }
- ,
- __decorate([editableInPropertyPage("Convert input to linear space", PropertyTypeForEdition.Boolean, "ADVANCED")], e.prototype, "convertInputToLinearSpace", void 0),
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.ImageProcessingBlock", ImageProcessingBlock);
- var PerturbNormalBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Fragment) || this;
- return o._tangentSpaceParameterName = "",
- o.invertX = !1,
- o.invertY = !1,
- o.useParallaxOcclusion = !1,
- o._isUnique = !0,
- o.registerInput("worldPosition", NodeMaterialBlockConnectionPointTypes.Vector4, !1),
- o.registerInput("worldNormal", NodeMaterialBlockConnectionPointTypes.Vector4, !1),
- o.registerInput("worldTangent", NodeMaterialBlockConnectionPointTypes.Vector4, !0),
- o.registerInput("uv", NodeMaterialBlockConnectionPointTypes.Vector2, !1),
- o.registerInput("normalMapColor", NodeMaterialBlockConnectionPointTypes.Color3, !1),
- o.registerInput("strength", NodeMaterialBlockConnectionPointTypes.Float, !1),
- o.registerInput("viewDirection", NodeMaterialBlockConnectionPointTypes.Vector3, !0),
- o.registerInput("parallaxScale", NodeMaterialBlockConnectionPointTypes.Float, !0),
- o.registerInput("parallaxHeight", NodeMaterialBlockConnectionPointTypes.Float, !0),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector4),
- o.registerOutput("uvOffset", NodeMaterialBlockConnectionPointTypes.Vector2),
- o
- }
- return e.prototype.getClassName = function() {
- return "PerturbNormalBlock"
- }
- ,
- Object.defineProperty(e.prototype, "worldPosition", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "worldNormal", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "worldTangent", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "uv", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "normalMapColor", {
- get: function() {
- return this._inputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "strength", {
- get: function() {
- return this._inputs[5]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "viewDirection", {
- get: function() {
- return this._inputs[6]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "parallaxScale", {
- get: function() {
- return this._inputs[7]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "parallaxHeight", {
- get: function() {
- return this._inputs[8]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "uvOffset", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.prepareDefines = function(i, o, s) {
- var c = this.normalMapColor.connectedPoint._ownerBlock.samplerName
- , d = this.viewDirection.isConnected && (this.useParallaxOcclusion && c || !this.useParallaxOcclusion && this.parallaxHeight.isConnected);
- s.setValue("BUMP", !0),
- s.setValue("PARALLAX", d, !0),
- s.setValue("PARALLAXOCCLUSION", this.useParallaxOcclusion, !0)
- }
- ,
- e.prototype.bind = function(i, o, s) {
- 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)
- }
- ,
- e.prototype.autoConfigure = function(i) {
- if (!this.uv.isConnected) {
- var o = i.getInputBlockByPredicate(function(c) {
- return c.isAttribute && c.name === "uv"
- });
- o || (o = new InputBlock("uv"),
- o.setAsAttribute()),
- o.output.connectTo(this.uv)
- }
- if (!this.strength.isConnected) {
- var s = new InputBlock("strength");
- s.value = 1,
- s.output.connectTo(this.strength)
- }
- }
- ,
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = "//" + this.name
- , s = this.uv
- , c = this.worldPosition
- , d = this.worldNormal
- , _ = this.worldTangent;
- i.sharedData.blocksWithDefines.push(this),
- i.sharedData.bindableBlocks.push(this),
- this._tangentSpaceParameterName = i._getFreeDefineName("tangentSpaceParameter"),
- i._emitUniformFromString(this._tangentSpaceParameterName, "vec2");
- var b = this.normalMapColor.connectedPoint._ownerBlock.samplerName
- , k = this.viewDirection.isConnected && (this.useParallaxOcclusion && b || !this.useParallaxOcclusion && this.parallaxHeight.isConnected)
- , j = this.parallaxScale.isConnectedToInputBlock ? this.parallaxScale.connectInputBlock.isConstant ? i._emitFloat(this.parallaxScale.connectInputBlock.value) : this.parallaxScale.associatedVariableName : "0.05"
- , $ = this.strength.isConnectedToInputBlock && this.strength.connectInputBlock.isConstant ? `\r
- #if !defined(NORMALXYSCALE)\r
- 1.0/\r
- #endif\r
- ` + i._emitFloat(this.strength.connectInputBlock.value) : `\r
- #if !defined(NORMALXYSCALE)\r
- 1.0/\r
- #endif\r
- ` + this.strength.associatedVariableName;
- i._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable");
- var _e = {
- search: /defined\(TANGENT\)/g,
- replace: _.isConnected ? "defined(TANGENT)" : "defined(IGNORE)"
- };
- _.isConnected && (i.compilationString += "vec3 tbnNormal = normalize(" + d.associatedVariableName + `.xyz);\r
- `,
- i.compilationString += "vec3 tbnTangent = normalize(" + _.associatedVariableName + `.xyz);\r
- `,
- i.compilationString += `vec3 tbnBitangent = cross(tbnNormal, tbnTangent);\r
- `,
- i.compilationString += `mat3 vTBN = mat3(tbnTangent, tbnBitangent, tbnNormal);\r
- `),
- i._emitFunctionFromInclude("bumpFragmentMainFunctions", o, {
- replaceStrings: [_e]
- }),
- i._emitFunctionFromInclude("bumpFragmentFunctions", o, {
- replaceStrings: [{
- search: /#include<samplerFragmentDeclaration>\(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_SAMPLERNAME_,bump\)/g,
- replace: ""
- }, {
- search: /uniform sampler2D bumpSampler;/g,
- replace: ""
- }, {
- search: /vec2 parallaxOcclusion\(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale\)/g,
- replace: `#define inline\r
- vec2 parallaxOcclusion(vec3 vViewDirCoT, vec3 vNormalCoT, vec2 texCoord, float parallaxScale, sampler2D bumpSampler)`
- }, {
- search: /vec2 parallaxOffset\(vec3 viewDir,float heightScale\)/g,
- replace: "vec2 parallaxOffset(vec3 viewDir, float heightScale, float height_)"
- }, {
- search: /texture2D\(bumpSampler,vBumpUV\)\.w/g,
- replace: "height_"
- }]
- });
- var et = !k || !b ? this.normalMapColor.associatedVariableName : "texture2D(" + b + ", " + s.associatedVariableName + " + uvOffset).xyz";
- return i.compilationString += this._declareOutput(this.output, i) + ` = vec4(0.);\r
- `,
- i.compilationString += i._emitCodeFromInclude("bumpFragment", o, {
- replaceStrings: [{
- search: /perturbNormal\(TBN,texture2D\(bumpSampler,vBumpUV\+uvOffset\).xyz,vBumpInfos.y\)/g,
- replace: "perturbNormal(TBN, " + et + ", vBumpInfos.y)"
- }, {
- search: /parallaxOcclusion\(invTBN\*-viewDirectionW,invTBN\*normalW,vBumpUV,vBumpInfos.z\)/g,
- replace: "parallaxOcclusion((invTBN * -viewDirectionW), (invTBN * normalW), vBumpUV, vBumpInfos.z, " + (k && this.useParallaxOcclusion ? b : "bumpSampler") + ")"
- }, {
- search: /parallaxOffset\(invTBN\*viewDirectionW,vBumpInfos\.z\)/g,
- replace: "parallaxOffset(invTBN * viewDirectionW, vBumpInfos.z, " + (k ? this.parallaxHeight.associatedVariableName : "0.") + ")"
- }, {
- search: /vTangentSpaceParams/g,
- replace: this._tangentSpaceParameterName
- }, {
- search: /vBumpInfos.y/g,
- replace: $
- }, {
- search: /vBumpInfos.z/g,
- replace: j
- }, {
- search: /vBumpUV/g,
- replace: s.associatedVariableName
- }, {
- search: /vPositionW/g,
- replace: c.associatedVariableName + ".xyz"
- }, {
- search: /normalW=/g,
- replace: this.output.associatedVariableName + ".xyz = "
- }, {
- search: /mat3\(normalMatrix\)\*normalW/g,
- replace: "mat3(normalMatrix) * " + this.output.associatedVariableName + ".xyz"
- }, {
- search: /normalW/g,
- replace: d.associatedVariableName + ".xyz"
- }, {
- search: /viewDirectionW/g,
- replace: k ? this.viewDirection.associatedVariableName : "vec3(0.)"
- }, _e]
- }),
- this
- }
- ,
- e.prototype._dumpPropertiesCode = function() {
- var i = a.prototype._dumpPropertiesCode.call(this) + (this._codeVariableName + ".invertX = " + this.invertX + `;\r
- `);
- return i += this._codeVariableName + ".invertY = " + this.invertY + `;\r
- `,
- i += this._codeVariableName + ".useParallaxOcclusion = " + this.useParallaxOcclusion + `;\r
- `,
- i
- }
- ,
- e.prototype.serialize = function() {
- var i = a.prototype.serialize.call(this);
- return i.invertX = this.invertX,
- i.invertY = this.invertY,
- i.useParallaxOcclusion = this.useParallaxOcclusion,
- i
- }
- ,
- e.prototype._deserialize = function(i, o, s) {
- a.prototype._deserialize.call(this, i, o, s),
- this.invertX = i.invertX,
- this.invertY = i.invertY,
- this.useParallaxOcclusion = !!i.useParallaxOcclusion
- }
- ,
- __decorate([editableInPropertyPage("Invert X axis", PropertyTypeForEdition.Boolean, "PROPERTIES", {
- notifiers: {
- update: !1
- }
- })], e.prototype, "invertX", void 0),
- __decorate([editableInPropertyPage("Invert Y axis", PropertyTypeForEdition.Boolean, "PROPERTIES", {
- notifiers: {
- update: !1
- }
- })], e.prototype, "invertY", void 0),
- __decorate([editableInPropertyPage("Use parallax occlusion", PropertyTypeForEdition.Boolean)], e.prototype, "useParallaxOcclusion", void 0),
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.PerturbNormalBlock", PerturbNormalBlock);
- var DiscardBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Fragment, !0) || this;
- return o.registerInput("value", NodeMaterialBlockConnectionPointTypes.Float, !0),
- o.registerInput("cutoff", NodeMaterialBlockConnectionPointTypes.Float, !0),
- o
- }
- return e.prototype.getClassName = function() {
- return "DiscardBlock"
- }
- ,
- Object.defineProperty(e.prototype, "value", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cutoff", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- if (a.prototype._buildBlock.call(this, i),
- i.sharedData.hints.needAlphaTesting = !0,
- !(!this.cutoff.isConnected || !this.value.isConnected))
- return i.compilationString += "if (" + this.value.associatedVariableName + " < " + this.cutoff.associatedVariableName + `) discard;\r
- `,
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.DiscardBlock", DiscardBlock);
- var FrontFacingBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Fragment) || this;
- return o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
- o
- }
- return e.prototype.getClassName = function() {
- return "FrontFacingBlock"
- }
- ,
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- if (a.prototype._buildBlock.call(this, i),
- i.target === NodeMaterialBlockTargets.Vertex)
- throw "FrontFacingBlock must only be used in a fragment shader";
- var o = this._outputs[0];
- return i.compilationString += this._declareOutput(o, i) + ` = gl_FrontFacing ? 1.0 : 0.0;\r
- `,
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.FrontFacingBlock", FrontFacingBlock);
- var DerivativeBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Fragment) || this;
- return o.registerInput("input", NodeMaterialBlockConnectionPointTypes.AutoDetect, !1),
- o.registerOutput("dx", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
- o.registerOutput("dy", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
- o._outputs[0]._typeConnectionSource = o._inputs[0],
- o._outputs[1]._typeConnectionSource = o._inputs[0],
- o
- }
- return e.prototype.getClassName = function() {
- return "DerivativeBlock"
- }
- ,
- Object.defineProperty(e.prototype, "input", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "dx", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "dy", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0]
- , s = this._outputs[1];
- return i._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable"),
- o.hasEndpoints && (i.compilationString += this._declareOutput(o, i) + (" = dFdx(" + this.input.associatedVariableName + `);\r
- `)),
- s.hasEndpoints && (i.compilationString += this._declareOutput(s, i) + (" = dFdy(" + this.input.associatedVariableName + `);\r
- `)),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.DerivativeBlock", DerivativeBlock);
- var FragCoordBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Fragment) || this;
- return o.registerOutput("xy", NodeMaterialBlockConnectionPointTypes.Vector2, NodeMaterialBlockTargets.Fragment),
- o.registerOutput("xyz", NodeMaterialBlockConnectionPointTypes.Vector3, NodeMaterialBlockTargets.Fragment),
- o.registerOutput("xyzw", NodeMaterialBlockConnectionPointTypes.Vector4, NodeMaterialBlockTargets.Fragment),
- o.registerOutput("x", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
- o.registerOutput("y", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
- o.registerOutput("z", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
- o.registerOutput("w", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
- o
- }
- return e.prototype.getClassName = function() {
- return "FragCoordBlock"
- }
- ,
- Object.defineProperty(e.prototype, "xy", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "xyz", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "xyzw", {
- get: function() {
- return this._outputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "x", {
- get: function() {
- return this._outputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "y", {
- get: function() {
- return this._outputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "z", {
- get: function() {
- return this._outputs[5]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[6]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.writeOutputs = function(i) {
- for (var o = "", s = 0, c = this._outputs; s < c.length; s++) {
- var d = c[s];
- d.hasEndpoints && (o += this._declareOutput(d, i) + " = gl_FragCoord." + d.name + `;\r
- `)
- }
- return o
- }
- ,
- e.prototype._buildBlock = function(i) {
- if (a.prototype._buildBlock.call(this, i),
- i.target === NodeMaterialBlockTargets.Vertex)
- throw "FragCoordBlock must only be used in a fragment shader";
- return i.compilationString += this.writeOutputs(i),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.FragCoordBlock", FragCoordBlock);
- var ScreenSizeBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Fragment) || this;
- return o.registerOutput("xy", NodeMaterialBlockConnectionPointTypes.Vector2, NodeMaterialBlockTargets.Fragment),
- o.registerOutput("x", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
- o.registerOutput("y", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
- o
- }
- return e.prototype.getClassName = function() {
- return "ScreenSizeBlock"
- }
- ,
- Object.defineProperty(e.prototype, "xy", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "x", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "y", {
- get: function() {
- return this._outputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.bind = function(i, o, s) {
- var c = this._scene.getEngine();
- i.setFloat2(this._varName, c.getRenderWidth(), c.getRenderHeight())
- }
- ,
- e.prototype.writeOutputs = function(i, o) {
- for (var s = "", c = 0, d = this._outputs; c < d.length; c++) {
- var _ = d[c];
- _.hasEndpoints && (s += this._declareOutput(_, i) + " = " + o + "." + _.name + `;\r
- `)
- }
- return s
- }
- ,
- e.prototype._buildBlock = function(i) {
- if (a.prototype._buildBlock.call(this, i),
- this._scene = i.sharedData.scene,
- i.target === NodeMaterialBlockTargets.Vertex)
- throw "ScreenSizeBlock must only be used in a fragment shader";
- return i.sharedData.bindableBlocks.push(this),
- this._varName = i._getFreeVariableName("screenSize"),
- i._emitUniformFromString(this._varName, "vec2"),
- i.compilationString += this.writeOutputs(i, this._varName),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.ScreenSizeBlock", ScreenSizeBlock);
- var ScreenSpaceBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Fragment) || this;
- return o.registerInput("vector", NodeMaterialBlockConnectionPointTypes.Vector3),
- o.registerInput("worldViewProjection", NodeMaterialBlockConnectionPointTypes.Matrix),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector2),
- o.registerOutput("x", NodeMaterialBlockConnectionPointTypes.Float),
- o.registerOutput("y", NodeMaterialBlockConnectionPointTypes.Float),
- o.inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
- o
- }
- return e.prototype.getClassName = function() {
- return "ScreenSpaceBlock"
- }
- ,
- Object.defineProperty(e.prototype, "vector", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "worldViewProjection", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "x", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "y", {
- get: function() {
- return this._outputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.autoConfigure = function(i) {
- if (!this.worldViewProjection.isConnected) {
- var o = i.getInputBlockByPredicate(function(s) {
- return s.systemValue === NodeMaterialSystemValues.WorldViewProjection
- });
- o || (o = new InputBlock("worldViewProjection"),
- o.setAsSystemValue(NodeMaterialSystemValues.WorldViewProjection)),
- o.output.connectTo(this.worldViewProjection)
- }
- }
- ,
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this.vector
- , s = this.worldViewProjection;
- if (!!o.connectedPoint) {
- var c = s.associatedVariableName
- , d = i._getFreeVariableName("screenSpaceTemp");
- switch (o.connectedPoint.type) {
- case NodeMaterialBlockConnectionPointTypes.Vector3:
- i.compilationString += "vec4 " + d + " = " + c + " * vec4(" + o.associatedVariableName + `, 1.0);\r
- `;
- break;
- case NodeMaterialBlockConnectionPointTypes.Vector4:
- i.compilationString += "vec4 " + d + " = " + c + " * " + o.associatedVariableName + `;\r
- `;
- break
- }
- return i.compilationString += d + ".xy /= " + d + ".w;",
- i.compilationString += d + ".xy = " + d + ".xy * 0.5 + vec2(0.5, 0.5);",
- this.output.hasEndpoints && (i.compilationString += this._declareOutput(this.output, i) + (" = " + d + `.xy;\r
- `)),
- this.x.hasEndpoints && (i.compilationString += this._declareOutput(this.x, i) + (" = " + d + `.x;\r
- `)),
- this.y.hasEndpoints && (i.compilationString += this._declareOutput(this.y, i) + (" = " + d + `.y;\r
- `)),
- this
- }
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.ScreenSpaceBlock", ScreenSpaceBlock);
- var TwirlBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Fragment) || this;
- return o.registerInput("input", NodeMaterialBlockConnectionPointTypes.Vector2),
- o.registerInput("strength", NodeMaterialBlockConnectionPointTypes.Float),
- o.registerInput("center", NodeMaterialBlockConnectionPointTypes.Vector2),
- o.registerInput("offset", NodeMaterialBlockConnectionPointTypes.Vector2),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector2),
- o.registerOutput("x", NodeMaterialBlockConnectionPointTypes.Float),
- o.registerOutput("y", NodeMaterialBlockConnectionPointTypes.Float),
- o
- }
- return e.prototype.getClassName = function() {
- return "TwirlBlock"
- }
- ,
- Object.defineProperty(e.prototype, "input", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "strength", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "center", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "offset", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "x", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "y", {
- get: function() {
- return this._outputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.autoConfigure = function(i) {
- if (!this.center.isConnected) {
- var o = new InputBlock("center");
- o.value = new Vector2(.5,.5),
- o.output.connectTo(this.center)
- }
- if (!this.strength.isConnected) {
- var s = new InputBlock("strength");
- s.value = 1,
- s.output.connectTo(this.strength)
- }
- if (!this.offset.isConnected) {
- var c = new InputBlock("offset");
- c.value = new Vector2(0,0),
- c.output.connectTo(this.offset)
- }
- }
- ,
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = i._getFreeVariableName("delta")
- , s = i._getFreeVariableName("angle")
- , c = i._getFreeVariableName("x")
- , d = i._getFreeVariableName("y")
- , _ = i._getFreeVariableName("result");
- return i.compilationString += `
- vec2 ` + o + " = " + this.input.associatedVariableName + " - " + this.center.associatedVariableName + `;
- float ` + s + " = " + this.strength.associatedVariableName + " * length(" + o + `);
- float ` + c + " = cos(" + s + ") * " + o + ".x - sin(" + s + ") * " + o + `.y;
- float ` + d + " = sin(" + s + ") * " + o + ".x + cos(" + s + ") * " + o + `.y;
- vec2 ` + _ + " = vec2(" + c + " + " + this.center.associatedVariableName + ".x + " + this.offset.associatedVariableName + ".x, " + d + " + " + this.center.associatedVariableName + ".y + " + this.offset.associatedVariableName + `.y);
- `,
- this.output.hasEndpoints && (i.compilationString += this._declareOutput(this.output, i) + (" = " + _ + `;\r
- `)),
- this.x.hasEndpoints && (i.compilationString += this._declareOutput(this.x, i) + (" = " + _ + `.x;\r
- `)),
- this.y.hasEndpoints && (i.compilationString += this._declareOutput(this.y, i) + (" = " + _ + `.y;\r
- `)),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.TwirlBlock", TwirlBlock);
- var FogBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.VertexAndFragment, !1) || this;
- return o.registerInput("worldPosition", NodeMaterialBlockConnectionPointTypes.Vector4, !1, NodeMaterialBlockTargets.Vertex),
- o.registerInput("view", NodeMaterialBlockConnectionPointTypes.Matrix, !1, NodeMaterialBlockTargets.Vertex),
- o.registerInput("input", NodeMaterialBlockConnectionPointTypes.Color3, !1, NodeMaterialBlockTargets.Fragment),
- o.registerInput("fogColor", NodeMaterialBlockConnectionPointTypes.Color3, !1, NodeMaterialBlockTargets.Fragment),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment),
- o.input.acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color4),
- o.fogColor.acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color4),
- o
- }
- return e.prototype.getClassName = function() {
- return "FogBlock"
- }
- ,
- Object.defineProperty(e.prototype, "worldPosition", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "view", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "input", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "fogColor", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.autoConfigure = function(i) {
- if (!this.view.isConnected) {
- var o = i.getInputBlockByPredicate(function(c) {
- return c.systemValue === NodeMaterialSystemValues.View
- });
- o || (o = new InputBlock("view"),
- o.setAsSystemValue(NodeMaterialSystemValues.View)),
- o.output.connectTo(this.view)
- }
- if (!this.fogColor.isConnected) {
- var s = i.getInputBlockByPredicate(function(c) {
- return c.systemValue === NodeMaterialSystemValues.FogColor
- });
- s || (s = new InputBlock("fogColor",void 0,NodeMaterialBlockConnectionPointTypes.Color3),
- s.setAsSystemValue(NodeMaterialSystemValues.FogColor)),
- s.output.connectTo(this.fogColor)
- }
- }
- ,
- e.prototype.prepareDefines = function(i, o, s) {
- var c = i.getScene();
- s.setValue("FOG", o.fogEnabled && MaterialHelper.GetFogState(i, c))
- }
- ,
- e.prototype.bind = function(i, o, s) {
- if (!!s) {
- var c = s.getScene();
- i.setFloat4(this._fogParameters, c.fogMode, c.fogStart, c.fogEnd, c.fogDensity)
- }
- }
- ,
- e.prototype._buildBlock = function(i) {
- if (a.prototype._buildBlock.call(this, i),
- i.target === NodeMaterialBlockTargets.Fragment) {
- i.sharedData.blocksWithDefines.push(this),
- i.sharedData.bindableBlocks.push(this),
- i._emitFunctionFromInclude("fogFragmentDeclaration", "//" + this.name, {
- removeUniforms: !0,
- removeVaryings: !0,
- removeIfDef: !1,
- replaceStrings: [{
- search: /float CalcFogFactor\(\)/,
- replace: "float CalcFogFactor(vec3 vFogDistance, vec4 vFogInfos)"
- }]
- });
- var o = i._getFreeVariableName("fog")
- , s = this.input
- , c = this.fogColor;
- this._fogParameters = i._getFreeVariableName("fogParameters");
- var d = this._outputs[0];
- i._emitUniformFromString(this._fogParameters, "vec4"),
- i.compilationString += `#ifdef FOG\r
- `,
- i.compilationString += "float " + o + " = CalcFogFactor(" + this._fogDistanceName + ", " + this._fogParameters + `);\r
- `,
- i.compilationString += this._declareOutput(d, i) + (" = " + o + " * " + s.associatedVariableName + ".rgb + (1.0 - " + o + ") * " + c.associatedVariableName + `.rgb;\r
- `),
- i.compilationString += `#else\r
- ` + this._declareOutput(d, i) + " = " + s.associatedVariableName + `.rgb;\r
- `,
- i.compilationString += `#endif\r
- `
- } else {
- var _ = this.worldPosition
- , b = this.view;
- this._fogDistanceName = i._getFreeVariableName("vFogDistance"),
- i._emitVaryingFromString(this._fogDistanceName, "vec3"),
- i.compilationString += this._fogDistanceName + " = (" + b.associatedVariableName + " * " + _.associatedVariableName + `).xyz;\r
- `
- }
- return this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.FogBlock", FogBlock);
- var LightBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.VertexAndFragment) || this;
- return o._isUnique = !0,
- o.registerInput("worldPosition", NodeMaterialBlockConnectionPointTypes.Vector4, !1, NodeMaterialBlockTargets.Vertex),
- o.registerInput("worldNormal", NodeMaterialBlockConnectionPointTypes.Vector4, !1, NodeMaterialBlockTargets.Fragment),
- o.registerInput("cameraPosition", NodeMaterialBlockConnectionPointTypes.Vector3, !1, NodeMaterialBlockTargets.Fragment),
- o.registerInput("glossiness", NodeMaterialBlockConnectionPointTypes.Float, !0, NodeMaterialBlockTargets.Fragment),
- o.registerInput("glossPower", NodeMaterialBlockConnectionPointTypes.Float, !0, NodeMaterialBlockTargets.Fragment),
- o.registerInput("diffuseColor", NodeMaterialBlockConnectionPointTypes.Color3, !0, NodeMaterialBlockTargets.Fragment),
- o.registerInput("specularColor", NodeMaterialBlockConnectionPointTypes.Color3, !0, NodeMaterialBlockTargets.Fragment),
- o.registerInput("view", NodeMaterialBlockConnectionPointTypes.Matrix, !0),
- o.registerOutput("diffuseOutput", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment),
- o.registerOutput("specularOutput", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment),
- o.registerOutput("shadow", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
- o
- }
- return e.prototype.getClassName = function() {
- return "LightBlock"
- }
- ,
- Object.defineProperty(e.prototype, "worldPosition", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "worldNormal", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cameraPosition", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "glossiness", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "glossPower", {
- get: function() {
- return this._inputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "diffuseColor", {
- get: function() {
- return this._inputs[5]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "specularColor", {
- get: function() {
- return this._inputs[6]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "view", {
- get: function() {
- return this._inputs[7]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "diffuseOutput", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "specularOutput", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "shadow", {
- get: function() {
- return this._outputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.autoConfigure = function(i) {
- if (!this.cameraPosition.isConnected) {
- var o = i.getInputBlockByPredicate(function(s) {
- return s.systemValue === NodeMaterialSystemValues.CameraPosition
- });
- o || (o = new InputBlock("cameraPosition"),
- o.setAsSystemValue(NodeMaterialSystemValues.CameraPosition)),
- o.output.connectTo(this.cameraPosition)
- }
- }
- ,
- e.prototype.prepareDefines = function(i, o, s) {
- if (!!s._areLightsDirty) {
- var c = i.getScene();
- if (!this.light)
- MaterialHelper.PrepareDefinesForLights(c, i, s, !0, o.maxSimultaneousLights);
- else {
- var d = {
- needNormals: !1,
- needRebuild: !1,
- lightmapMode: !1,
- shadowEnabled: !1,
- specularEnabled: !1
- };
- MaterialHelper.PrepareDefinesForLight(c, i, this.light, this._lightId, s, !0, d),
- d.needRebuild && s.rebuild()
- }
- }
- }
- ,
- e.prototype.updateUniformsAndSamples = function(i, o, s, c) {
- for (var d = 0; d < o.maxSimultaneousLights && s["LIGHT" + d]; d++) {
- var _ = i.uniforms.indexOf("vLightData" + d) >= 0;
- MaterialHelper.PrepareUniformsAndSamplersForLight(d, i.uniforms, i.samplers, s["PROJECTEDLIGHTTEXTURE" + d], c, _)
- }
- }
- ,
- e.prototype.bind = function(i, o, s) {
- if (!!s) {
- var c = s.getScene();
- this.light ? MaterialHelper.BindLight(this.light, this._lightId, c, i, !0) : MaterialHelper.BindLights(c, s, i, !0, o.maxSimultaneousLights)
- }
- }
- ,
- e.prototype._injectVertexCode = function(i) {
- var o = this.worldPosition
- , s = "//" + this.name;
- this.light ? (this._lightId = (i.counters.lightCounter !== void 0 ? i.counters.lightCounter : -1) + 1,
- i.counters.lightCounter = this._lightId,
- i._emitFunctionFromInclude(i.supportUniformBuffers ? "lightVxUboDeclaration" : "lightVxFragmentDeclaration", s, {
- replaceStrings: [{
- search: /{X}/g,
- replace: this._lightId.toString()
- }]
- }, this._lightId.toString())) : (i._emitFunctionFromInclude(i.supportUniformBuffers ? "lightVxUboDeclaration" : "lightVxFragmentDeclaration", s, {
- repeatKey: "maxSimultaneousLights"
- }),
- this._lightId = 0,
- i.sharedData.dynamicUniformBlocks.push(this));
- var c = "v_" + o.associatedVariableName;
- i._emitVaryingFromString(c, "vec4") && (i.compilationString += c + " = " + o.associatedVariableName + `;\r
- `),
- this.light ? i.compilationString += i._emitCodeFromInclude("shadowsVertex", s, {
- replaceStrings: [{
- search: /{X}/g,
- replace: this._lightId.toString()
- }, {
- search: /worldPos/g,
- replace: o.associatedVariableName
- }]
- }) : (i.compilationString += "vec4 worldPos = " + o.associatedVariableName + `;\r
- `,
- this.view.isConnected && (i.compilationString += "mat4 view = " + this.view.associatedVariableName + `;\r
- `),
- i.compilationString += i._emitCodeFromInclude("shadowsVertex", s, {
- repeatKey: "maxSimultaneousLights"
- }))
- }
- ,
- e.prototype._buildBlock = function(i) {
- if (a.prototype._buildBlock.call(this, i),
- i.target !== NodeMaterialBlockTargets.Fragment) {
- this._injectVertexCode(i);
- return
- }
- i.sharedData.forcedBindableBlocks.push(this),
- i.sharedData.blocksWithDefines.push(this);
- var o = "//" + this.name
- , s = this.worldPosition;
- i._emitFunctionFromInclude("helperFunctions", o),
- i._emitFunctionFromInclude("lightsFragmentFunctions", o, {
- replaceStrings: [{
- search: /vPositionW/g,
- replace: "v_" + s.associatedVariableName + ".xyz"
- }]
- }),
- i._emitFunctionFromInclude("shadowsFragmentFunctions", o, {
- replaceStrings: [{
- search: /vPositionW/g,
- replace: "v_" + s.associatedVariableName + ".xyz"
- }]
- }),
- this.light ? i._emitFunctionFromInclude(i.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", o, {
- replaceStrings: [{
- search: /{X}/g,
- replace: this._lightId.toString()
- }]
- }, this._lightId.toString()) : i._emitFunctionFromInclude(i.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", o, {
- repeatKey: "maxSimultaneousLights"
- }),
- this._lightId === 0 && (i._registerTempVariable("viewDirectionW") && (i.compilationString += "vec3 viewDirectionW = normalize(" + this.cameraPosition.associatedVariableName + " - " + ("v_" + s.associatedVariableName) + `.xyz);\r
- `),
- i.compilationString += `lightingInfo info;\r
- `,
- i.compilationString += `float shadow = 1.;\r
- `,
- i.compilationString += "float glossiness = " + (this.glossiness.isConnected ? this.glossiness.associatedVariableName : "1.0") + " * " + (this.glossPower.isConnected ? this.glossPower.associatedVariableName : "1024.0") + `;\r
- `,
- i.compilationString += `vec3 diffuseBase = vec3(0., 0., 0.);\r
- `,
- i.compilationString += `vec3 specularBase = vec3(0., 0., 0.);\r
- `,
- i.compilationString += "vec3 normalW = " + this.worldNormal.associatedVariableName + `.xyz;\r
- `),
- this.light ? i.compilationString += i._emitCodeFromInclude("lightFragment", o, {
- replaceStrings: [{
- search: /{X}/g,
- replace: this._lightId.toString()
- }]
- }) : i.compilationString += i._emitCodeFromInclude("lightFragment", o, {
- repeatKey: "maxSimultaneousLights"
- });
- var c = this.diffuseOutput
- , d = this.specularOutput;
- return i.compilationString += this._declareOutput(c, i) + (" = diffuseBase" + (this.diffuseColor.isConnected ? " * " + this.diffuseColor.associatedVariableName : "") + `;\r
- `),
- d.hasEndpoints && (i.compilationString += this._declareOutput(d, i) + (" = specularBase" + (this.specularColor.isConnected ? " * " + this.specularColor.associatedVariableName : "") + `;\r
- `)),
- this.shadow.hasEndpoints && (i.compilationString += this._declareOutput(this.shadow, i) + ` = shadow;\r
- `),
- this
- }
- ,
- e.prototype.serialize = function() {
- var i = a.prototype.serialize.call(this);
- return this.light && (i.lightId = this.light.id),
- i
- }
- ,
- e.prototype._deserialize = function(i, o, s) {
- a.prototype._deserialize.call(this, i, o, s),
- i.lightId && (this.light = o.getLightById(i.lightId))
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.LightBlock", LightBlock);
- var NodeMaterialConnectionPointCustomObject = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _) {
- var b = a.call(this, i, o, s) || this;
- return b._blockType = c,
- b._blockName = d,
- b._nameForCheking = _,
- b._nameForCheking || (b._nameForCheking = i),
- b.needDualDirectionValidation = !0,
- b
- }
- return e.prototype.checkCompatibilityState = function(i) {
- return i instanceof e && i.name === this._nameForCheking ? NodeMaterialConnectionPointCompatibilityStates.Compatible : NodeMaterialConnectionPointCompatibilityStates.TypeIncompatible
- }
- ,
- e.prototype.createCustomInputBlock = function() {
- return [new this._blockType(this._blockName), this.name]
- }
- ,
- e
- }(NodeMaterialConnectionPoint)
- , ImageSourceBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.VertexAndFragment) || this;
- return o.registerOutput("source", NodeMaterialBlockConnectionPointTypes.Object, NodeMaterialBlockTargets.VertexAndFragment, new NodeMaterialConnectionPointCustomObject("source",o,NodeMaterialConnectionPointDirection.Output,e,"ImageSourceBlock")),
- o
- }
- return Object.defineProperty(e.prototype, "texture", {
- get: function() {
- return this._texture
- },
- set: function(i) {
- var o = this, s;
- if (this._texture !== i) {
- var c = (s = i == null ? void 0 : i.getScene()) !== null && s !== void 0 ? s : Engine.LastCreatedScene;
- !i && c && c.markAllMaterialsAsDirty(1, function(d) {
- return d.hasTexture(o._texture)
- }),
- this._texture = i,
- i && c && c.markAllMaterialsAsDirty(1, function(d) {
- return d.hasTexture(i)
- })
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "samplerName", {
- get: function() {
- return this._samplerName
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.bind = function(i, o, s) {
- !this.texture || i.setTexture(this._samplerName, this.texture)
- }
- ,
- e.prototype.isReady = function() {
- return !(this.texture && !this.texture.isReadyOrNotBlocking())
- }
- ,
- e.prototype.getClassName = function() {
- return "ImageSourceBlock"
- }
- ,
- Object.defineProperty(e.prototype, "source", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- return a.prototype._buildBlock.call(this, i),
- i.target === NodeMaterialBlockTargets.Vertex && (this._samplerName = i._getFreeVariableName(this.name + "Sampler"),
- i.sharedData.blockingBlocks.push(this),
- i.sharedData.textureBlocks.push(this),
- i.sharedData.bindableBlocks.push(this)),
- i._emit2DSampler(this._samplerName),
- this
- }
- ,
- e.prototype._dumpPropertiesCode = function() {
- var i = a.prototype._dumpPropertiesCode.call(this);
- return this.texture && (i += this._codeVariableName + '.texture = new BABYLON.Texture("' + this.texture.name + '", null, ' + this.texture.noMipmap + ", " + this.texture.invertY + ", " + this.texture.samplingMode + `);\r
- `,
- i += this._codeVariableName + ".texture.wrapU = " + this.texture.wrapU + `;\r
- `,
- i += this._codeVariableName + ".texture.wrapV = " + this.texture.wrapV + `;\r
- `,
- i += this._codeVariableName + ".texture.uAng = " + this.texture.uAng + `;\r
- `,
- i += this._codeVariableName + ".texture.vAng = " + this.texture.vAng + `;\r
- `,
- i += this._codeVariableName + ".texture.wAng = " + this.texture.wAng + `;\r
- `,
- i += this._codeVariableName + ".texture.uOffset = " + this.texture.uOffset + `;\r
- `,
- i += this._codeVariableName + ".texture.vOffset = " + this.texture.vOffset + `;\r
- `,
- i += this._codeVariableName + ".texture.uScale = " + this.texture.uScale + `;\r
- `,
- i += this._codeVariableName + ".texture.vScale = " + this.texture.vScale + `;\r
- `,
- i += this._codeVariableName + ".texture.coordinatesMode = " + this.texture.coordinatesMode + `;\r
- `),
- i
- }
- ,
- e.prototype.serialize = function() {
- var i = a.prototype.serialize.call(this);
- return this.texture && !this.texture.isRenderTarget && this.texture.getClassName() !== "VideoTexture" && (i.texture = this.texture.serialize()),
- i
- }
- ,
- e.prototype._deserialize = function(i, o, s) {
- a.prototype._deserialize.call(this, i, o, s),
- i.texture && !NodeMaterial.IgnoreTexturesAtLoadTime && i.texture.url !== void 0 && (s = i.texture.url.indexOf("data:") === 0 ? "" : s,
- this.texture = Texture.Parse(i.texture, o, s))
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.ImageSourceBlock", ImageSourceBlock);
- var TextureBlock = function(a) {
- __extends(e, a);
- function e(i, o) {
- o === void 0 && (o = !1);
- var s = a.call(this, i, o ? NodeMaterialBlockTargets.Fragment : NodeMaterialBlockTargets.VertexAndFragment) || this;
- return s.convertToGammaSpace = !1,
- s.convertToLinearSpace = !1,
- s.disableLevelMultiplication = !1,
- s._fragmentOnly = o,
- s.registerInput("uv", NodeMaterialBlockConnectionPointTypes.Vector2, !1, NodeMaterialBlockTargets.VertexAndFragment),
- s.registerInput("source", NodeMaterialBlockConnectionPointTypes.Object, !0, NodeMaterialBlockTargets.VertexAndFragment, new NodeMaterialConnectionPointCustomObject("source",s,NodeMaterialConnectionPointDirection.Input,ImageSourceBlock,"ImageSourceBlock")),
- s.registerOutput("rgba", NodeMaterialBlockConnectionPointTypes.Color4, NodeMaterialBlockTargets.Neutral),
- s.registerOutput("rgb", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Neutral),
- s.registerOutput("r", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
- s.registerOutput("g", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
- s.registerOutput("b", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
- s.registerOutput("a", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
- s.registerOutput("level", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
- s._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector3),
- s._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
- s._inputs[0]._prioritizeVertex = !o,
- s
- }
- return Object.defineProperty(e.prototype, "texture", {
- get: function() {
- var i;
- return this.source.isConnected ? ((i = this.source.connectedPoint) === null || i === void 0 ? void 0 : i.ownerBlock).texture : this._texture
- },
- set: function(i) {
- var o = this, s;
- if (this._texture !== i) {
- var c = (s = i == null ? void 0 : i.getScene()) !== null && s !== void 0 ? s : Engine.LastCreatedScene;
- !i && c && c.markAllMaterialsAsDirty(1, function(d) {
- return d.hasTexture(o._texture)
- }),
- this._texture = i,
- i && c && c.markAllMaterialsAsDirty(1, function(d) {
- return d.hasTexture(i)
- })
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "samplerName", {
- get: function() {
- return this._imageSource ? this._imageSource.samplerName : this._samplerName
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "hasImageSource", {
- get: function() {
- return !!this._imageSource
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getClassName = function() {
- return "TextureBlock"
- }
- ,
- Object.defineProperty(e.prototype, "uv", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "source", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "rgba", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "rgb", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "r", {
- get: function() {
- return this._outputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "g", {
- get: function() {
- return this._outputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "b", {
- get: function() {
- return this._outputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "a", {
- get: function() {
- return this._outputs[5]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "level", {
- get: function() {
- return this._outputs[6]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "target", {
- get: function() {
- if (this._fragmentOnly)
- return NodeMaterialBlockTargets.Fragment;
- if (!this.uv.isConnected || this.uv.sourceBlock.isInput)
- return NodeMaterialBlockTargets.VertexAndFragment;
- for (var i = this.uv.connectedPoint; i; ) {
- if (i.target === NodeMaterialBlockTargets.Fragment)
- return NodeMaterialBlockTargets.Fragment;
- if (i.target === NodeMaterialBlockTargets.Vertex)
- return NodeMaterialBlockTargets.VertexAndFragment;
- if (i.target === NodeMaterialBlockTargets.Neutral || i.target === NodeMaterialBlockTargets.VertexAndFragment) {
- var o = i.ownerBlock;
- if (o.target === NodeMaterialBlockTargets.Fragment)
- return NodeMaterialBlockTargets.Fragment;
- i = null;
- for (var s = 0, c = o.inputs; s < c.length; s++) {
- var d = c[s];
- if (d.connectedPoint) {
- i = d.connectedPoint;
- break
- }
- }
- }
- }
- return NodeMaterialBlockTargets.VertexAndFragment
- },
- set: function(i) {},
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.autoConfigure = function(i) {
- if (!this.uv.isConnected)
- if (i.mode === NodeMaterialModes.PostProcess) {
- var o = i.getBlockByPredicate(function(c) {
- return c.name === "uv"
- });
- o && o.connectTo(this)
- } else {
- var s = i.mode === NodeMaterialModes.Particle ? "particle_uv" : "uv"
- , o = i.getInputBlockByPredicate(function(d) {
- return d.isAttribute && d.name === s
- });
- o || (o = new InputBlock("uv"),
- o.setAsAttribute(s)),
- o.output.connectTo(this.uv)
- }
- }
- ,
- e.prototype.initializeDefines = function(i, o, s, c) {
- !s._areTexturesDirty || this._mainUVDefineName !== void 0 && s.setValue(this._mainUVDefineName, !1, !0)
- }
- ,
- e.prototype.prepareDefines = function(i, o, s) {
- if (!!s._areTexturesDirty) {
- if (!this.texture || !this.texture.getTextureMatrix) {
- this._isMixed && (s.setValue(this._defineName, !1, !0),
- s.setValue(this._mainUVDefineName, !0, !0));
- return
- }
- s.setValue(this._linearDefineName, this.convertToGammaSpace, !0),
- s.setValue(this._gammaDefineName, this.convertToLinearSpace, !0),
- this._isMixed && (this.texture.getTextureMatrix().isIdentityAs3x2() ? (s.setValue(this._defineName, !1, !0),
- s.setValue(this._mainUVDefineName, !0, !0)) : (s.setValue(this._defineName, !0),
- s[this._mainUVDefineName] == null && s.setValue(this._mainUVDefineName, !1, !0)))
- }
- }
- ,
- e.prototype.isReady = function() {
- return !(this.texture && !this.texture.isReadyOrNotBlocking())
- }
- ,
- e.prototype.bind = function(i, o, s) {
- !this.texture || (this._isMixed && (i.setFloat(this._textureInfoName, this.texture.level),
- i.setMatrix(this._textureTransformName, this.texture.getTextureMatrix())),
- this._imageSource || i.setTexture(this._samplerName, this.texture))
- }
- ,
- Object.defineProperty(e.prototype, "_isMixed", {
- get: function() {
- return this.target !== NodeMaterialBlockTargets.Fragment
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._injectVertexCode = function(i) {
- var o = this.uv;
- if (this._defineName = i._getFreeDefineName("UVTRANSFORM"),
- this._mainUVDefineName = "VMAIN" + o.associatedVariableName.toUpperCase(),
- this._mainUVName = "vMain" + o.associatedVariableName,
- this._transformedUVName = i._getFreeVariableName("transformedUV"),
- this._textureTransformName = i._getFreeVariableName("textureTransform"),
- this._textureInfoName = i._getFreeVariableName("textureInfoName"),
- this.level.associatedVariableName = this._textureInfoName,
- i._emitVaryingFromString(this._transformedUVName, "vec2", this._defineName),
- i._emitVaryingFromString(this._mainUVName, "vec2", this._mainUVDefineName),
- i._emitUniformFromString(this._textureTransformName, "mat4", this._defineName),
- i.compilationString += "#ifdef " + this._defineName + `\r
- `,
- i.compilationString += this._transformedUVName + " = vec2(" + this._textureTransformName + " * vec4(" + o.associatedVariableName + `.xy, 1.0, 0.0));\r
- `,
- i.compilationString += "#elif defined(" + this._mainUVDefineName + `)\r
- `,
- i.compilationString += this._mainUVName + " = " + o.associatedVariableName + `.xy;\r
- `,
- i.compilationString += `#endif\r
- `,
- !!this._outputs.some(function(_) {
- return _.isConnectedInVertexShader
- })) {
- this._writeTextureRead(i, !0);
- for (var s = 0, c = this._outputs; s < c.length; s++) {
- var d = c[s];
- d.hasEndpoints && d.name !== "level" && this._writeOutput(i, d, d.name, !0)
- }
- }
- }
- ,
- e.prototype._generateTextureLookup = function(i) {
- var o = this.samplerName;
- i.compilationString += "#ifdef " + this._defineName + `\r
- `,
- i.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + o + ", " + this._transformedUVName + `);\r
- `,
- i.compilationString += "#elif defined(" + this._mainUVDefineName + `)\r
- `,
- i.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + o + ", " + (this._mainUVName ? this._mainUVName : this.uv.associatedVariableName) + `);\r
- `,
- i.compilationString += `#endif\r
- `
- }
- ,
- e.prototype._writeTextureRead = function(i, o) {
- o === void 0 && (o = !1);
- var s = this.uv;
- if (o) {
- if (i.target === NodeMaterialBlockTargets.Fragment)
- return;
- this._generateTextureLookup(i);
- return
- }
- if (this.uv.ownerBlock.target === NodeMaterialBlockTargets.Fragment) {
- i.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + this.samplerName + ", " + s.associatedVariableName + `);\r
- `;
- return
- }
- this._generateTextureLookup(i)
- }
- ,
- e.prototype._generateConversionCode = function(i, o, s) {
- s !== "a" && ((!this.texture || !this.texture.gammaSpace) && (i.compilationString += "#ifdef " + this._linearDefineName + `
- ` + o.associatedVariableName + " = toGammaSpace(" + o.associatedVariableName + `);
- #endif
- `),
- (!this.texture || this.texture.gammaSpace) && (i.compilationString += "#ifdef " + this._gammaDefineName + `
- ` + o.associatedVariableName + " = toLinearSpace(" + o.associatedVariableName + `);
- #endif
- `))
- }
- ,
- e.prototype._writeOutput = function(i, o, s, c) {
- if (c === void 0 && (c = !1),
- c) {
- if (i.target === NodeMaterialBlockTargets.Fragment)
- return;
- i.compilationString += this._declareOutput(o, i) + " = " + this._tempTextureRead + "." + s + `;\r
- `,
- this._generateConversionCode(i, o, s);
- return
- }
- if (this.uv.ownerBlock.target === NodeMaterialBlockTargets.Fragment) {
- i.compilationString += this._declareOutput(o, i) + " = " + this._tempTextureRead + "." + s + `;\r
- `,
- this._generateConversionCode(i, o, s);
- return
- }
- var d = "";
- this.disableLevelMultiplication || (d = " * " + this._textureInfoName),
- i.compilationString += this._declareOutput(o, i) + " = " + this._tempTextureRead + "." + s + d + `;\r
- `,
- this._generateConversionCode(i, o, s)
- }
- ,
- e.prototype._buildBlock = function(i) {
- if (a.prototype._buildBlock.call(this, i),
- this.source.isConnected ? this._imageSource = this.source.connectedPoint.ownerBlock : this._imageSource = null,
- (i.target === NodeMaterialBlockTargets.Vertex || this._fragmentOnly || i.target === NodeMaterialBlockTargets.Fragment && this._tempTextureRead === void 0) && (this._tempTextureRead = i._getFreeVariableName("tempTextureRead"),
- this._linearDefineName = i._getFreeDefineName("ISLINEAR"),
- this._gammaDefineName = i._getFreeDefineName("ISGAMMA")),
- (!this._isMixed && i.target === NodeMaterialBlockTargets.Fragment || this._isMixed && i.target === NodeMaterialBlockTargets.Vertex) && (this._imageSource || (this._samplerName = i._getFreeVariableName(this.name + "Sampler"),
- i._emit2DSampler(this._samplerName)),
- i.sharedData.blockingBlocks.push(this),
- i.sharedData.textureBlocks.push(this),
- i.sharedData.blocksWithDefines.push(this),
- i.sharedData.bindableBlocks.push(this)),
- i.target !== NodeMaterialBlockTargets.Fragment) {
- this._injectVertexCode(i);
- return
- }
- if (!!this._outputs.some(function(_) {
- return _.isConnectedInFragmentShader
- })) {
- this._isMixed && !this._imageSource && i._emit2DSampler(this._samplerName);
- var o = "//" + this.name;
- i._emitFunctionFromInclude("helperFunctions", o),
- this._isMixed && i._emitUniformFromString(this._textureInfoName, "float"),
- this._writeTextureRead(i);
- for (var s = 0, c = this._outputs; s < c.length; s++) {
- var d = c[s];
- d.hasEndpoints && d.name !== "level" && this._writeOutput(i, d, d.name)
- }
- return this
- }
- }
- ,
- e.prototype._dumpPropertiesCode = function() {
- var i = a.prototype._dumpPropertiesCode.call(this);
- return i += this._codeVariableName + ".convertToGammaSpace = " + this.convertToGammaSpace + `;\r
- `,
- i += this._codeVariableName + ".convertToLinearSpace = " + this.convertToLinearSpace + `;\r
- `,
- i += this._codeVariableName + ".disableLevelMultiplication = " + this.disableLevelMultiplication + `;\r
- `,
- this.texture && (i += this._codeVariableName + '.texture = new BABYLON.Texture("' + this.texture.name + '", null, ' + this.texture.noMipmap + ", " + this.texture.invertY + ", " + this.texture.samplingMode + `);\r
- `,
- i += this._codeVariableName + ".texture.wrapU = " + this.texture.wrapU + `;\r
- `,
- i += this._codeVariableName + ".texture.wrapV = " + this.texture.wrapV + `;\r
- `,
- i += this._codeVariableName + ".texture.uAng = " + this.texture.uAng + `;\r
- `,
- i += this._codeVariableName + ".texture.vAng = " + this.texture.vAng + `;\r
- `,
- i += this._codeVariableName + ".texture.wAng = " + this.texture.wAng + `;\r
- `,
- i += this._codeVariableName + ".texture.uOffset = " + this.texture.uOffset + `;\r
- `,
- i += this._codeVariableName + ".texture.vOffset = " + this.texture.vOffset + `;\r
- `,
- i += this._codeVariableName + ".texture.uScale = " + this.texture.uScale + `;\r
- `,
- i += this._codeVariableName + ".texture.vScale = " + this.texture.vScale + `;\r
- `,
- i += this._codeVariableName + ".texture.coordinatesMode = " + this.texture.coordinatesMode + `;\r
- `),
- i
- }
- ,
- e.prototype.serialize = function() {
- var i = a.prototype.serialize.call(this);
- return i.convertToGammaSpace = this.convertToGammaSpace,
- i.convertToLinearSpace = this.convertToLinearSpace,
- i.fragmentOnly = this._fragmentOnly,
- i.disableLevelMultiplication = this.disableLevelMultiplication,
- !this.hasImageSource && this.texture && !this.texture.isRenderTarget && this.texture.getClassName() !== "VideoTexture" && (i.texture = this.texture.serialize()),
- i
- }
- ,
- e.prototype._deserialize = function(i, o, s) {
- a.prototype._deserialize.call(this, i, o, s),
- this.convertToGammaSpace = i.convertToGammaSpace,
- this.convertToLinearSpace = !!i.convertToLinearSpace,
- this._fragmentOnly = !!i.fragmentOnly,
- this.disableLevelMultiplication = !!i.disableLevelMultiplication,
- i.texture && !NodeMaterial.IgnoreTexturesAtLoadTime && i.texture.url !== void 0 && (s = i.texture.url.indexOf("data:") === 0 ? "" : s,
- this.texture = Texture.Parse(i.texture, o, s))
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.TextureBlock", TextureBlock);
- var ReflectionTextureBaseBlock = function(a) {
- __extends(e, a);
- function e(i) {
- return a.call(this, i, NodeMaterialBlockTargets.VertexAndFragment) || this
- }
- return Object.defineProperty(e.prototype, "texture", {
- get: function() {
- return this._texture
- },
- set: function(i) {
- var o = this, s;
- if (this._texture !== i) {
- var c = (s = i == null ? void 0 : i.getScene()) !== null && s !== void 0 ? s : Engine.LastCreatedScene;
- !i && c && c.markAllMaterialsAsDirty(1, function(d) {
- return d.hasTexture(o._texture)
- }),
- this._texture = i,
- i && c && c.markAllMaterialsAsDirty(1, function(d) {
- return d.hasTexture(i)
- })
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getClassName = function() {
- return "ReflectionTextureBaseBlock"
- }
- ,
- e.prototype._getTexture = function() {
- return this.texture
- }
- ,
- e.prototype.autoConfigure = function(i) {
- if (!this.position.isConnected) {
- var o = i.getInputBlockByPredicate(function(d) {
- return d.isAttribute && d.name === "position"
- });
- o || (o = new InputBlock("position"),
- o.setAsAttribute()),
- o.output.connectTo(this.position)
- }
- if (!this.world.isConnected) {
- var s = i.getInputBlockByPredicate(function(d) {
- return d.systemValue === NodeMaterialSystemValues.World
- });
- s || (s = new InputBlock("world"),
- s.setAsSystemValue(NodeMaterialSystemValues.World)),
- s.output.connectTo(this.world)
- }
- if (this.view && !this.view.isConnected) {
- var c = i.getInputBlockByPredicate(function(d) {
- return d.systemValue === NodeMaterialSystemValues.View
- });
- c || (c = new InputBlock("view"),
- c.setAsSystemValue(NodeMaterialSystemValues.View)),
- c.output.connectTo(this.view)
- }
- }
- ,
- e.prototype.prepareDefines = function(i, o, s) {
- if (!!s._areTexturesDirty) {
- var c = this._getTexture();
- !c || !c.getTextureMatrix || (s.setValue(this._define3DName, c.isCube, !0),
- s.setValue(this._defineLocalCubicName, !!c.boundingBoxSize, !0),
- s.setValue(this._defineExplicitName, c.coordinatesMode === 0, !0),
- s.setValue(this._defineSkyboxName, c.coordinatesMode === 5, !0),
- s.setValue(this._defineCubicName, c.coordinatesMode === 3 || c.coordinatesMode === 6, !0),
- s.setValue("INVERTCUBICMAP", c.coordinatesMode === 6, !0),
- s.setValue(this._defineSphericalName, c.coordinatesMode === 1, !0),
- s.setValue(this._definePlanarName, c.coordinatesMode === 2, !0),
- s.setValue(this._defineProjectionName, c.coordinatesMode === 4, !0),
- s.setValue(this._defineEquirectangularName, c.coordinatesMode === 7, !0),
- s.setValue(this._defineEquirectangularFixedName, c.coordinatesMode === 8, !0),
- s.setValue(this._defineMirroredEquirectangularFixedName, c.coordinatesMode === 9, !0))
- }
- }
- ,
- e.prototype.isReady = function() {
- var i = this._getTexture();
- return !(i && !i.isReadyOrNotBlocking())
- }
- ,
- e.prototype.bind = function(i, o, s) {
- var c = this._getTexture();
- if (!(!s || !c) && (i.setMatrix(this._reflectionMatrixName, c.getReflectionTextureMatrix()),
- c.isCube ? i.setTexture(this._cubeSamplerName, c) : i.setTexture(this._2DSamplerName, c),
- c.boundingBoxSize)) {
- var d = c;
- i.setVector3(this._reflectionPositionName, d.boundingBoxPosition),
- i.setVector3(this._reflectionSizeName, d.boundingBoxSize)
- }
- }
- ,
- e.prototype.handleVertexSide = function(i) {
- this._define3DName = i._getFreeDefineName("REFLECTIONMAP_3D"),
- this._defineCubicName = i._getFreeDefineName("REFLECTIONMAP_CUBIC"),
- this._defineSphericalName = i._getFreeDefineName("REFLECTIONMAP_SPHERICAL"),
- this._definePlanarName = i._getFreeDefineName("REFLECTIONMAP_PLANAR"),
- this._defineProjectionName = i._getFreeDefineName("REFLECTIONMAP_PROJECTION"),
- this._defineExplicitName = i._getFreeDefineName("REFLECTIONMAP_EXPLICIT"),
- this._defineEquirectangularName = i._getFreeDefineName("REFLECTIONMAP_EQUIRECTANGULAR"),
- this._defineLocalCubicName = i._getFreeDefineName("USE_LOCAL_REFLECTIONMAP_CUBIC"),
- this._defineMirroredEquirectangularFixedName = i._getFreeDefineName("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"),
- this._defineEquirectangularFixedName = i._getFreeDefineName("REFLECTIONMAP_EQUIRECTANGULAR_FIXED"),
- this._defineSkyboxName = i._getFreeDefineName("REFLECTIONMAP_SKYBOX"),
- this._defineOppositeZ = i._getFreeDefineName("REFLECTIONMAP_OPPOSITEZ"),
- this._reflectionMatrixName = i._getFreeVariableName("reflectionMatrix"),
- i._emitUniformFromString(this._reflectionMatrixName, "mat4");
- var o = ""
- , s = "v_" + this.worldPosition.associatedVariableName;
- return i._emitVaryingFromString(s, "vec4") && (o += s + " = " + this.worldPosition.associatedVariableName + `;\r
- `),
- this._positionUVWName = i._getFreeVariableName("positionUVW"),
- this._directionWName = i._getFreeVariableName("directionW"),
- i._emitVaryingFromString(this._positionUVWName, "vec3", this._defineSkyboxName) && (o += "#ifdef " + this._defineSkyboxName + `\r
- `,
- o += this._positionUVWName + " = " + this.position.associatedVariableName + `.xyz;\r
- `,
- o += `#endif\r
- `),
- i._emitVaryingFromString(this._directionWName, "vec3", "defined(" + this._defineEquirectangularFixedName + ") || defined(" + this._defineMirroredEquirectangularFixedName + ")") && (o += "#if defined(" + this._defineEquirectangularFixedName + ") || defined(" + this._defineMirroredEquirectangularFixedName + `)\r
- `,
- o += this._directionWName + " = normalize(vec3(" + this.world.associatedVariableName + " * vec4(" + this.position.associatedVariableName + `.xyz, 0.0)));\r
- `,
- o += `#endif\r
- `),
- o
- }
- ,
- e.prototype.handleFragmentSideInits = function(i) {
- i.sharedData.blockingBlocks.push(this),
- i.sharedData.textureBlocks.push(this),
- this._cubeSamplerName = i._getFreeVariableName(this.name + "CubeSampler"),
- i.samplers.push(this._cubeSamplerName),
- this._2DSamplerName = i._getFreeVariableName(this.name + "2DSampler"),
- i.samplers.push(this._2DSamplerName),
- i._samplerDeclaration += "#ifdef " + this._define3DName + `\r
- `,
- i._samplerDeclaration += "uniform samplerCube " + this._cubeSamplerName + `;\r
- `,
- i._samplerDeclaration += `#else\r
- `,
- i._samplerDeclaration += "uniform sampler2D " + this._2DSamplerName + `;\r
- `,
- i._samplerDeclaration += `#endif\r
- `,
- i.sharedData.blocksWithDefines.push(this),
- i.sharedData.bindableBlocks.push(this);
- var o = "//" + this.name;
- i._emitFunction("ReciprocalPI", "#define RECIPROCAL_PI2 0.15915494", ""),
- i._emitFunctionFromInclude("helperFunctions", o),
- i._emitFunctionFromInclude("reflectionFunction", o, {
- replaceStrings: [{
- search: /vec3 computeReflectionCoords/g,
- replace: "void DUMMYFUNC"
- }]
- }),
- this._reflectionColorName = i._getFreeVariableName("reflectionColor"),
- this._reflectionVectorName = i._getFreeVariableName("reflectionUVW"),
- this._reflectionCoordsName = i._getFreeVariableName("reflectionCoords"),
- this._reflectionPositionName = i._getFreeVariableName("vReflectionPosition"),
- i._emitUniformFromString(this._reflectionPositionName, "vec3"),
- this._reflectionSizeName = i._getFreeVariableName("vReflectionPosition"),
- i._emitUniformFromString(this._reflectionSizeName, "vec3")
- }
- ,
- e.prototype.handleFragmentSideCodeReflectionCoords = function(i, o, s) {
- s === void 0 && (s = !1),
- o || (o = "v_" + this.worldPosition.associatedVariableName);
- var c = this._reflectionMatrixName
- , d = "normalize(" + this._directionWName + ")"
- , _ = "" + this._positionUVWName
- , b = "" + this.cameraPosition.associatedVariableName
- , k = "" + this.view.associatedVariableName;
- i += ".xyz";
- var j = `
- #ifdef ` + this._defineMirroredEquirectangularFixedName + `
- vec3 ` + this._reflectionVectorName + " = computeMirroredFixedEquirectangularCoords(" + o + ", " + i + ", " + d + `);
- #endif
- #ifdef ` + this._defineEquirectangularFixedName + `
- vec3 ` + this._reflectionVectorName + " = computeFixedEquirectangularCoords(" + o + ", " + i + ", " + d + `);
- #endif
- #ifdef ` + this._defineEquirectangularName + `
- vec3 ` + this._reflectionVectorName + " = computeEquirectangularCoords(" + o + ", " + i + ", " + b + ".xyz, " + c + `);
- #endif
- #ifdef ` + this._defineSphericalName + `
- vec3 ` + this._reflectionVectorName + " = computeSphericalCoords(" + o + ", " + i + ", " + k + ", " + c + `);
- #endif
- #ifdef ` + this._definePlanarName + `
- vec3 ` + this._reflectionVectorName + " = computePlanarCoords(" + o + ", " + i + ", " + b + ".xyz, " + c + `);
- #endif
- #ifdef ` + this._defineCubicName + `
- #ifdef ` + this._defineLocalCubicName + `
- vec3 ` + this._reflectionVectorName + " = computeCubicLocalCoords(" + o + ", " + i + ", " + b + ".xyz, " + c + ", " + this._reflectionSizeName + ", " + this._reflectionPositionName + `);
- #else
- vec3 ` + this._reflectionVectorName + " = computeCubicCoords(" + o + ", " + i + ", " + b + ".xyz, " + c + `);
- #endif
- #endif
- #ifdef ` + this._defineProjectionName + `
- vec3 ` + this._reflectionVectorName + " = computeProjectionCoords(" + o + ", " + k + ", " + c + `);
- #endif
- #ifdef ` + this._defineSkyboxName + `
- vec3 ` + this._reflectionVectorName + " = computeSkyBoxCoords(" + _ + ", " + c + `);
- #endif
- #ifdef ` + this._defineExplicitName + `
- vec3 ` + this._reflectionVectorName + ` = vec3(0, 0, 0);
- #endif
- #ifdef ` + this._defineOppositeZ + `
- ` + this._reflectionVectorName + `.z *= -1.0;
- #endif\r
- `;
- return s || (j += `
- #ifdef ` + this._define3DName + `
- vec3 ` + this._reflectionCoordsName + " = " + this._reflectionVectorName + `;
- #else
- vec2 ` + this._reflectionCoordsName + " = " + this._reflectionVectorName + `.xy;
- #ifdef ` + this._defineProjectionName + `
- ` + this._reflectionCoordsName + " /= " + this._reflectionVectorName + `.z;
- #endif
- ` + this._reflectionCoordsName + ".y = 1.0 - " + this._reflectionCoordsName + `.y;
- #endif\r
- `),
- j
- }
- ,
- e.prototype.handleFragmentSideCodeReflectionColor = function(i, o) {
- o === void 0 && (o = ".rgb");
- var s = "vec" + (o.length === 0 ? "4" : o.length - 1)
- , c = s + " " + this._reflectionColorName + `;
- #ifdef ` + this._define3DName + `\r
- `;
- return i ? c += this._reflectionColorName + " = textureCubeLodEXT(" + this._cubeSamplerName + ", " + this._reflectionVectorName + ", " + i + ")" + o + `;\r
- ` : c += this._reflectionColorName + " = textureCube(" + this._cubeSamplerName + ", " + this._reflectionVectorName + ")" + o + `;\r
- `,
- c += `
- #else\r
- `,
- i ? c += this._reflectionColorName + " = texture2DLodEXT(" + this._2DSamplerName + ", " + this._reflectionCoordsName + ", " + i + ")" + o + `;\r
- ` : c += this._reflectionColorName + " = texture2D(" + this._2DSamplerName + ", " + this._reflectionCoordsName + ")" + o + `;\r
- `,
- c += `#endif\r
- `,
- c
- }
- ,
- e.prototype.writeOutputs = function(i, o) {
- var s = "";
- if (i.target === NodeMaterialBlockTargets.Fragment)
- for (var c = 0, d = this._outputs; c < d.length; c++) {
- var _ = d[c];
- _.hasEndpoints && (s += this._declareOutput(_, i) + " = " + o + "." + _.name + `;\r
- `)
- }
- return s
- }
- ,
- e.prototype._buildBlock = function(i) {
- return a.prototype._buildBlock.call(this, i),
- this
- }
- ,
- e.prototype._dumpPropertiesCode = function() {
- var i = a.prototype._dumpPropertiesCode.call(this);
- if (!this.texture)
- return i;
- if (this.texture.isCube) {
- var o = this.texture.forcedExtension;
- 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
- `
- } else
- i += this._codeVariableName + '.texture = new BABYLON.Texture("' + this.texture.name + `", null);\r
- `;
- return i += this._codeVariableName + ".texture.coordinatesMode = " + this.texture.coordinatesMode + `;\r
- `,
- i
- }
- ,
- e.prototype.serialize = function() {
- var i = a.prototype.serialize.call(this);
- return this.texture && !this.texture.isRenderTarget && (i.texture = this.texture.serialize()),
- i
- }
- ,
- e.prototype._deserialize = function(i, o, s) {
- a.prototype._deserialize.call(this, i, o, s),
- i.texture && (s = i.texture.url.indexOf("data:") === 0 ? "" : s,
- i.texture.isCube ? this.texture = CubeTexture.Parse(i.texture, o, s) : this.texture = Texture.Parse(i.texture, o, s))
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.ReflectionTextureBaseBlock", ReflectionTextureBaseBlock);
- var ReflectionTextureBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i) || this;
- return o.registerInput("position", NodeMaterialBlockConnectionPointTypes.Vector3, !1, NodeMaterialBlockTargets.Vertex),
- o.registerInput("worldPosition", NodeMaterialBlockConnectionPointTypes.Vector4, !1, NodeMaterialBlockTargets.Vertex),
- o.registerInput("worldNormal", NodeMaterialBlockConnectionPointTypes.Vector4, !1, NodeMaterialBlockTargets.Fragment),
- o.registerInput("world", NodeMaterialBlockConnectionPointTypes.Matrix, !1, NodeMaterialBlockTargets.Vertex),
- o.registerInput("cameraPosition", NodeMaterialBlockConnectionPointTypes.Vector3, !1, NodeMaterialBlockTargets.Fragment),
- o.registerInput("view", NodeMaterialBlockConnectionPointTypes.Matrix, !1, NodeMaterialBlockTargets.Fragment),
- o.registerOutput("rgb", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment),
- o.registerOutput("rgba", NodeMaterialBlockConnectionPointTypes.Color4, NodeMaterialBlockTargets.Fragment),
- o.registerOutput("r", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
- o.registerOutput("g", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
- o.registerOutput("b", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
- o.registerOutput("a", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
- o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
- o
- }
- return e.prototype.getClassName = function() {
- return "ReflectionTextureBlock"
- }
- ,
- Object.defineProperty(e.prototype, "position", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "worldPosition", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "worldNormal", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "world", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cameraPosition", {
- get: function() {
- return this._inputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "view", {
- get: function() {
- return this._inputs[5]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "rgb", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "rgba", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "r", {
- get: function() {
- return this._outputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "g", {
- get: function() {
- return this._outputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "b", {
- get: function() {
- return this._outputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "a", {
- get: function() {
- return this._outputs[5]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.autoConfigure = function(i) {
- if (a.prototype.autoConfigure.call(this, i),
- !this.cameraPosition.isConnected) {
- var o = i.getInputBlockByPredicate(function(s) {
- return s.systemValue === NodeMaterialSystemValues.CameraPosition
- });
- o || (o = new InputBlock("cameraPosition"),
- o.setAsSystemValue(NodeMaterialSystemValues.CameraPosition)),
- o.output.connectTo(this.cameraPosition)
- }
- }
- ,
- e.prototype._buildBlock = function(i) {
- if (a.prototype._buildBlock.call(this, i),
- !this.texture)
- return i.compilationString += this.writeOutputs(i, "vec3(0.)"),
- this;
- if (i.target !== NodeMaterialBlockTargets.Fragment)
- return i.compilationString += this.handleVertexSide(i),
- this;
- this.handleFragmentSideInits(i);
- var o = i._getFreeVariableName("normalWUnit");
- return i.compilationString += "vec4 " + o + " = normalize(" + this.worldNormal.associatedVariableName + `);\r
- `,
- i.compilationString += this.handleFragmentSideCodeReflectionCoords(o),
- i.compilationString += this.handleFragmentSideCodeReflectionColor(void 0, ""),
- i.compilationString += this.writeOutputs(i, this._reflectionColorName),
- this
- }
- ,
- e
- }(ReflectionTextureBaseBlock);
- RegisterClass("BABYLON.ReflectionTextureBlock", ReflectionTextureBlock);
- var SceneDepthBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.VertexAndFragment) || this;
- return o._samplerName = "textureSampler",
- o.useNonLinearDepth = !1,
- o.force32itsFloat = !1,
- o._isUnique = !0,
- o.registerInput("uv", NodeMaterialBlockConnectionPointTypes.Vector2, !1, NodeMaterialBlockTargets.VertexAndFragment),
- o.registerOutput("depth", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Neutral),
- o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector3),
- o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
- o._inputs[0]._prioritizeVertex = !1,
- o
- }
- return e.prototype.getClassName = function() {
- return "SceneDepthBlock"
- }
- ,
- Object.defineProperty(e.prototype, "uv", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "depth", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.initialize = function(i) {
- i._excludeVariableName("textureSampler")
- }
- ,
- Object.defineProperty(e.prototype, "target", {
- get: function() {
- return !this.uv.isConnected || this.uv.sourceBlock.isInput ? NodeMaterialBlockTargets.VertexAndFragment : NodeMaterialBlockTargets.Fragment
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._getTexture = function(i) {
- var o = i.enableDepthRenderer(void 0, this.useNonLinearDepth, this.force32itsFloat);
- return o.getDepthMap()
- }
- ,
- e.prototype.bind = function(i, o, s) {
- var c = this._getTexture(o.getScene());
- i.setTexture(this._samplerName, c)
- }
- ,
- e.prototype._injectVertexCode = function(i) {
- var o = this.uv;
- if (o.connectedPoint.ownerBlock.isInput) {
- var s = o.connectedPoint.ownerBlock;
- s.isAttribute || i._emitUniformFromString(o.associatedVariableName, "vec" + (o.type === NodeMaterialBlockConnectionPointTypes.Vector3 ? "3" : o.type === NodeMaterialBlockConnectionPointTypes.Vector4 ? "4" : "2"))
- }
- if (this._mainUVName = "vMain" + o.associatedVariableName,
- i._emitVaryingFromString(this._mainUVName, "vec2"),
- i.compilationString += this._mainUVName + " = " + o.associatedVariableName + `.xy;\r
- `,
- !!this._outputs.some(function(b) {
- return b.isConnectedInVertexShader
- })) {
- this._writeTextureRead(i, !0);
- for (var c = 0, d = this._outputs; c < d.length; c++) {
- var _ = d[c];
- _.hasEndpoints && this._writeOutput(i, _, "r", !0)
- }
- }
- }
- ,
- e.prototype._writeTextureRead = function(i, o) {
- o === void 0 && (o = !1);
- var s = this.uv;
- if (o) {
- if (i.target === NodeMaterialBlockTargets.Fragment)
- return;
- i.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + this._samplerName + ", " + s.associatedVariableName + `.xy);\r
- `;
- return
- }
- if (this.uv.ownerBlock.target === NodeMaterialBlockTargets.Fragment) {
- i.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + this._samplerName + ", " + s.associatedVariableName + `.xy);\r
- `;
- return
- }
- i.compilationString += "vec4 " + this._tempTextureRead + " = texture2D(" + this._samplerName + ", " + this._mainUVName + `);\r
- `
- }
- ,
- e.prototype._writeOutput = function(i, o, s, c) {
- if (c === void 0 && (c = !1),
- c) {
- if (i.target === NodeMaterialBlockTargets.Fragment)
- return;
- i.compilationString += this._declareOutput(o, i) + " = " + this._tempTextureRead + "." + s + `;\r
- `;
- return
- }
- if (this.uv.ownerBlock.target === NodeMaterialBlockTargets.Fragment) {
- i.compilationString += this._declareOutput(o, i) + " = " + this._tempTextureRead + "." + s + `;\r
- `;
- return
- }
- i.compilationString += this._declareOutput(o, i) + " = " + this._tempTextureRead + "." + s + `;\r
- `
- }
- ,
- e.prototype._buildBlock = function(i) {
- if (a.prototype._buildBlock.call(this, i),
- this._tempTextureRead = i._getFreeVariableName("tempTextureRead"),
- i.sharedData.bindableBlocks.indexOf(this) < 0 && i.sharedData.bindableBlocks.push(this),
- i.target !== NodeMaterialBlockTargets.Fragment) {
- i._emit2DSampler(this._samplerName),
- this._injectVertexCode(i);
- return
- }
- if (!!this._outputs.some(function(d) {
- return d.isConnectedInFragmentShader
- })) {
- i._emit2DSampler(this._samplerName),
- this._writeTextureRead(i);
- for (var o = 0, s = this._outputs; o < s.length; o++) {
- var c = s[o];
- c.hasEndpoints && this._writeOutput(i, c, "r")
- }
- return this
- }
- }
- ,
- e.prototype.serialize = function() {
- var i = a.prototype.serialize.call(this);
- return i.useNonLinearDepth = this.useNonLinearDepth,
- i.force32itsFloat = this.force32itsFloat,
- i
- }
- ,
- e.prototype._deserialize = function(i, o, s) {
- a.prototype._deserialize.call(this, i, o, s),
- this.useNonLinearDepth = i.useNonLinearDepth,
- this.force32itsFloat = i.force32itsFloat
- }
- ,
- __decorate([editableInPropertyPage("Use non linear depth", PropertyTypeForEdition.Boolean, "ADVANCED", {
- notifiers: {
- activatePreviewCommand: !0,
- callback: function(i) {
- return i.disableDepthRenderer()
- }
- }
- })], e.prototype, "useNonLinearDepth", void 0),
- __decorate([editableInPropertyPage("Force 32 bits float", PropertyTypeForEdition.Boolean, "ADVANCED", {
- notifiers: {
- activatePreviewCommand: !0,
- callback: function(i) {
- return i.disableDepthRenderer()
- }
- }
- })], e.prototype, "force32itsFloat", void 0),
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.SceneDepthBlock", SceneDepthBlock);
- var AddBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
- o._outputs[0]._typeConnectionSource = o._inputs[0],
- o._linkConnectionTypes(0, 1),
- o
- }
- return e.prototype.getClassName = function() {
- return "AddBlock"
- }
- ,
- Object.defineProperty(e.prototype, "left", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "right", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0];
- return i.compilationString += this._declareOutput(o, i) + (" = " + this.left.associatedVariableName + " + " + this.right.associatedVariableName + `;\r
- `),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.AddBlock", AddBlock);
- var ScaleBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("input", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerInput("factor", NodeMaterialBlockConnectionPointTypes.Float),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
- o._outputs[0]._typeConnectionSource = o._inputs[0],
- o
- }
- return e.prototype.getClassName = function() {
- return "ScaleBlock"
- }
- ,
- Object.defineProperty(e.prototype, "input", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "factor", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0];
- return i.compilationString += this._declareOutput(o, i) + (" = " + this.input.associatedVariableName + " * " + this.factor.associatedVariableName + `;\r
- `),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.ScaleBlock", ScaleBlock);
- var ClampBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.minimum = 0,
- o.maximum = 1,
- o.registerInput("value", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
- o._outputs[0]._typeConnectionSource = o._inputs[0],
- o
- }
- return e.prototype.getClassName = function() {
- return "ClampBlock"
- }
- ,
- Object.defineProperty(e.prototype, "value", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0];
- return i.compilationString += this._declareOutput(o, i) + (" = clamp(" + this.value.associatedVariableName + ", " + this._writeFloat(this.minimum) + ", " + this._writeFloat(this.maximum) + `);\r
- `),
- this
- }
- ,
- e.prototype._dumpPropertiesCode = function() {
- var i = a.prototype._dumpPropertiesCode.call(this) + (this._codeVariableName + ".minimum = " + this.minimum + `;\r
- `);
- return i += this._codeVariableName + ".maximum = " + this.maximum + `;\r
- `,
- i
- }
- ,
- e.prototype.serialize = function() {
- var i = a.prototype.serialize.call(this);
- return i.minimum = this.minimum,
- i.maximum = this.maximum,
- i
- }
- ,
- e.prototype._deserialize = function(i, o, s) {
- a.prototype._deserialize.call(this, i, o, s),
- this.minimum = i.minimum,
- this.maximum = i.maximum
- }
- ,
- __decorate([editableInPropertyPage("Minimum", PropertyTypeForEdition.Float)], e.prototype, "minimum", void 0),
- __decorate([editableInPropertyPage("Maximum", PropertyTypeForEdition.Float)], e.prototype, "maximum", void 0),
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.ClampBlock", ClampBlock);
- var CrossBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector3),
- o._linkConnectionTypes(0, 1),
- o._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
- o._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
- o._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector2),
- o._inputs[1].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
- o._inputs[1].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
- o._inputs[1].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector2),
- o
- }
- return e.prototype.getClassName = function() {
- return "CrossBlock"
- }
- ,
- Object.defineProperty(e.prototype, "left", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "right", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0];
- return i.compilationString += this._declareOutput(o, i) + (" = cross(" + this.left.associatedVariableName + ".xyz, " + this.right.associatedVariableName + `.xyz);\r
- `),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.CrossBlock", CrossBlock);
- var CustomBlock = function(a) {
- __extends(e, a);
- function e(i) {
- return a.call(this, i) || this
- }
- return Object.defineProperty(e.prototype, "options", {
- get: function() {
- return this._options
- },
- set: function(i) {
- this._deserializeOptions(i)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getClassName = function() {
- return "CustomBlock"
- }
- ,
- e.prototype._buildBlock = function(i) {
- var o = this;
- a.prototype._buildBlock.call(this, i);
- var s = this._code
- , c = this._options.functionName;
- this._inputs.forEach(function(_) {
- var b = new RegExp("\\{TYPE_" + _.name + "\\}","gm")
- , k = i._getGLType(_.type);
- s = s.replace(b, k),
- c = c.replace(b, k)
- }),
- this._outputs.forEach(function(_) {
- var b = new RegExp("\\{TYPE_" + _.name + "\\}","gm")
- , k = i._getGLType(_.type);
- s = s.replace(b, k),
- c = c.replace(b, k)
- }),
- i._emitFunction(c, s, ""),
- this._outputs.forEach(function(_) {
- i.compilationString += o._declareOutput(_, i) + `;\r
- `
- }),
- i.compilationString += c + "(";
- var d = !1;
- return this._inputs.forEach(function(_, b) {
- b > 0 && (i.compilationString += ", "),
- i.compilationString += _.associatedVariableName,
- d = !0
- }),
- this._outputs.forEach(function(_, b) {
- (b > 0 || d) && (i.compilationString += ", "),
- i.compilationString += _.associatedVariableName
- }),
- i.compilationString += `);\r
- `,
- this
- }
- ,
- e.prototype._dumpPropertiesCode = function() {
- var i = a.prototype._dumpPropertiesCode.call(this);
- return i += this._codeVariableName + ".options = " + JSON.stringify(this._options) + `;\r
- `,
- i
- }
- ,
- e.prototype.serialize = function() {
- var i = a.prototype.serialize.call(this);
- return i.options = this._options,
- i
- }
- ,
- e.prototype._deserialize = function(i, o, s) {
- this._deserializeOptions(i.options),
- a.prototype._deserialize.call(this, i, o, s)
- }
- ,
- e.prototype._deserializeOptions = function(i) {
- var o = this, s, c, d;
- this._options = i,
- this._code = i.code.join(`\r
- `) + `\r
- `,
- this.name = this.name || i.name,
- this.target = NodeMaterialBlockTargets[i.target],
- (s = i.inParameters) === null || s === void 0 || s.forEach(function(_, b) {
- var k = NodeMaterialBlockConnectionPointTypes[_.type];
- o.registerInput(_.name, k),
- Object.defineProperty(o, _.name, {
- get: function() {
- return this._inputs[b]
- },
- enumerable: !0,
- configurable: !0
- })
- }),
- (c = i.outParameters) === null || c === void 0 || c.forEach(function(_, b) {
- o.registerOutput(_.name, NodeMaterialBlockConnectionPointTypes[_.type]),
- Object.defineProperty(o, _.name, {
- get: function() {
- return this._outputs[b]
- },
- enumerable: !0,
- configurable: !0
- }),
- _.type === "BasedOnInput" && (o._outputs[b]._typeConnectionSource = o._findInputByName(_.typeFromInput)[0])
- }),
- (d = i.inLinkedConnectionTypes) === null || d === void 0 || d.forEach(function(_) {
- o._linkConnectionTypes(o._findInputByName(_.input1)[1], o._findInputByName(_.input2)[1])
- })
- }
- ,
- e.prototype._findInputByName = function(i) {
- if (!i)
- return null;
- for (var o = 0; o < this._inputs.length; o++)
- if (this._inputs[o].name === i)
- return [this._inputs[o], o];
- return null
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.CustomBlock", CustomBlock);
- var DotBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Float),
- o._linkConnectionTypes(0, 1),
- o._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
- o._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
- o._inputs[1].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
- o._inputs[1].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
- o
- }
- return e.prototype.getClassName = function() {
- return "DotBlock"
- }
- ,
- Object.defineProperty(e.prototype, "left", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "right", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0];
- return i.compilationString += this._declareOutput(o, i) + (" = dot(" + this.left.associatedVariableName + ", " + this.right.associatedVariableName + `);\r
- `),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.DotBlock", DotBlock);
- var NormalizeBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("input", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
- o._outputs[0]._typeConnectionSource = o._inputs[0],
- o._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
- o._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
- o
- }
- return e.prototype.getClassName = function() {
- return "NormalizeBlock"
- }
- ,
- Object.defineProperty(e.prototype, "input", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0]
- , s = this._inputs[0];
- return i.compilationString += this._declareOutput(o, i) + (" = normalize(" + s.associatedVariableName + `);\r
- `),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.NormalizeBlock", NormalizeBlock);
- var ColorMergerBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.rSwizzle = "r",
- o.gSwizzle = "g",
- o.bSwizzle = "b",
- o.aSwizzle = "a",
- o.registerInput("rgb ", NodeMaterialBlockConnectionPointTypes.Color3, !0),
- o.registerInput("r", NodeMaterialBlockConnectionPointTypes.Float, !0),
- o.registerInput("g", NodeMaterialBlockConnectionPointTypes.Float, !0),
- o.registerInput("b", NodeMaterialBlockConnectionPointTypes.Float, !0),
- o.registerInput("a", NodeMaterialBlockConnectionPointTypes.Float, !0),
- o.registerOutput("rgba", NodeMaterialBlockConnectionPointTypes.Color4),
- o.registerOutput("rgb", NodeMaterialBlockConnectionPointTypes.Color3),
- o
- }
- return e.prototype.getClassName = function() {
- return "ColorMergerBlock"
- }
- ,
- Object.defineProperty(e.prototype, "rgbIn", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "r", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "g", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "b", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "a", {
- get: function() {
- return this._inputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "rgba", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "rgbOut", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "rgb", {
- get: function() {
- return this.rgbOut
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._inputRename = function(i) {
- return i === "rgb " ? "rgbIn" : i
- }
- ,
- e.prototype._buildSwizzle = function(i) {
- var o = this.rSwizzle + this.gSwizzle + this.bSwizzle + this.aSwizzle;
- return "." + o.substr(0, i)
- }
- ,
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this.r
- , s = this.g
- , c = this.b
- , d = this.a
- , _ = this.rgbIn
- , b = this._outputs[0]
- , k = this._outputs[1];
- return _.isConnected ? (b.hasEndpoints && (i.compilationString += this._declareOutput(b, i) + (" = vec4(" + _.associatedVariableName + ", " + (d.isConnected ? this._writeVariable(d) : "0.0") + ")" + this._buildSwizzle(4) + `;\r
- `)),
- k.hasEndpoints && (i.compilationString += this._declareOutput(k, i) + (" = " + _.associatedVariableName + this._buildSwizzle(3) + `;\r
- `))) : (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
- `)),
- 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
- `))),
- this
- }
- ,
- e.prototype.serialize = function() {
- var i = a.prototype.serialize.call(this);
- return i.rSwizzle = this.rSwizzle,
- i.gSwizzle = this.gSwizzle,
- i.bSwizzle = this.bSwizzle,
- i.aSwizzle = this.aSwizzle,
- i
- }
- ,
- e.prototype._deserialize = function(i, o, s) {
- var c, d, _, b;
- a.prototype._deserialize.call(this, i, o, s),
- this.rSwizzle = (c = i.rSwizzle) !== null && c !== void 0 ? c : "r",
- this.gSwizzle = (d = i.gSwizzle) !== null && d !== void 0 ? d : "g",
- this.bSwizzle = (_ = i.bSwizzle) !== null && _ !== void 0 ? _ : "b",
- this.aSwizzle = (b = i.aSwizzle) !== null && b !== void 0 ? b : "a"
- }
- ,
- e.prototype._dumpPropertiesCode = function() {
- var i = a.prototype._dumpPropertiesCode.call(this);
- return i += this._codeVariableName + ".rSwizzle = " + this.rSwizzle + `};\r
- `,
- i += this._codeVariableName + ".gSwizzle = " + this.gSwizzle + `};\r
- `,
- i += this._codeVariableName + ".bSwizzle = " + this.bSwizzle + `};\r
- `,
- i += this._codeVariableName + ".aSwizzle = " + this.aSwizzle + `};\r
- `,
- i
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.ColorMergerBlock", ColorMergerBlock);
- var VectorSplitterBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("xyzw", NodeMaterialBlockConnectionPointTypes.Vector4, !0),
- o.registerInput("xyz ", NodeMaterialBlockConnectionPointTypes.Vector3, !0),
- o.registerInput("xy ", NodeMaterialBlockConnectionPointTypes.Vector2, !0),
- o.registerOutput("xyz", NodeMaterialBlockConnectionPointTypes.Vector3),
- o.registerOutput("xy", NodeMaterialBlockConnectionPointTypes.Vector2),
- o.registerOutput("zw", NodeMaterialBlockConnectionPointTypes.Vector2),
- o.registerOutput("x", NodeMaterialBlockConnectionPointTypes.Float),
- o.registerOutput("y", NodeMaterialBlockConnectionPointTypes.Float),
- o.registerOutput("z", NodeMaterialBlockConnectionPointTypes.Float),
- o.registerOutput("w", NodeMaterialBlockConnectionPointTypes.Float),
- o.inputsAreExclusive = !0,
- o
- }
- return e.prototype.getClassName = function() {
- return "VectorSplitterBlock"
- }
- ,
- Object.defineProperty(e.prototype, "xyzw", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "xyzIn", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "xyIn", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "xyzOut", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "xyOut", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "zw", {
- get: function() {
- return this._outputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "x", {
- get: function() {
- return this._outputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "y", {
- get: function() {
- return this._outputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "z", {
- get: function() {
- return this._outputs[5]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "w", {
- get: function() {
- return this._outputs[6]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._inputRename = function(i) {
- switch (i) {
- case "xy ":
- return "xyIn";
- case "xyz ":
- return "xyzIn";
- default:
- return i
- }
- }
- ,
- e.prototype._outputRename = function(i) {
- switch (i) {
- case "xy":
- return "xyOut";
- case "xyz":
- return "xyzOut";
- default:
- return i
- }
- }
- ,
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this.xyzw.isConnected ? this.xyzw : this.xyzIn.isConnected ? this.xyzIn : this.xyIn
- , s = this._outputs[0]
- , c = this._outputs[1]
- , d = this._outputs[2]
- , _ = this._outputs[3]
- , b = this._outputs[4]
- , k = this._outputs[5]
- , j = this._outputs[6];
- return s.hasEndpoints && (o === this.xyIn ? i.compilationString += this._declareOutput(s, i) + (" = vec3(" + o.associatedVariableName + `, 0.0);\r
- `) : i.compilationString += this._declareOutput(s, i) + (" = " + o.associatedVariableName + `.xyz;\r
- `)),
- d.hasEndpoints && this.xyzw.isConnected && (i.compilationString += this._declareOutput(d, i) + (" = " + this.xyzw.associatedVariableName + `.zw;\r
- `)),
- c.hasEndpoints && (i.compilationString += this._declareOutput(c, i) + (" = " + o.associatedVariableName + `.xy;\r
- `)),
- _.hasEndpoints && (i.compilationString += this._declareOutput(_, i) + (" = " + o.associatedVariableName + `.x;\r
- `)),
- b.hasEndpoints && (i.compilationString += this._declareOutput(b, i) + (" = " + o.associatedVariableName + `.y;\r
- `)),
- k.hasEndpoints && (i.compilationString += this._declareOutput(k, i) + (" = " + o.associatedVariableName + `.z;\r
- `)),
- j.hasEndpoints && (i.compilationString += this._declareOutput(j, i) + (" = " + o.associatedVariableName + `.w;\r
- `)),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.VectorSplitterBlock", VectorSplitterBlock);
- var LerpBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerInput("gradient", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
- o._outputs[0]._typeConnectionSource = o._inputs[0],
- o._linkConnectionTypes(0, 1),
- o._linkConnectionTypes(1, 2, !0),
- o._inputs[2].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
- o
- }
- return e.prototype.getClassName = function() {
- return "LerpBlock"
- }
- ,
- Object.defineProperty(e.prototype, "left", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "right", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "gradient", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0];
- return i.compilationString += this._declareOutput(o, i) + (" = mix(" + this.left.associatedVariableName + " , " + this.right.associatedVariableName + ", " + this.gradient.associatedVariableName + `);\r
- `),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.LerpBlock", LerpBlock);
- var DivideBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
- o._outputs[0]._typeConnectionSource = o._inputs[0],
- o._linkConnectionTypes(0, 1),
- o
- }
- return e.prototype.getClassName = function() {
- return "DivideBlock"
- }
- ,
- Object.defineProperty(e.prototype, "left", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "right", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0];
- return i.compilationString += this._declareOutput(o, i) + (" = " + this.left.associatedVariableName + " / " + this.right.associatedVariableName + `;\r
- `),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.DivideBlock", DivideBlock);
- var SubtractBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
- o._outputs[0]._typeConnectionSource = o._inputs[0],
- o._linkConnectionTypes(0, 1),
- o
- }
- return e.prototype.getClassName = function() {
- return "SubtractBlock"
- }
- ,
- Object.defineProperty(e.prototype, "left", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "right", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0];
- return i.compilationString += this._declareOutput(o, i) + (" = " + this.left.associatedVariableName + " - " + this.right.associatedVariableName + `;\r
- `),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.SubtractBlock", SubtractBlock);
- var StepBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("value", NodeMaterialBlockConnectionPointTypes.Float),
- o.registerInput("edge", NodeMaterialBlockConnectionPointTypes.Float),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Float),
- o
- }
- return e.prototype.getClassName = function() {
- return "StepBlock"
- }
- ,
- Object.defineProperty(e.prototype, "value", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "edge", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0];
- return i.compilationString += this._declareOutput(o, i) + (" = step(" + this.edge.associatedVariableName + ", " + this.value.associatedVariableName + `);\r
- `),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.StepBlock", StepBlock);
- var OneMinusBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("input", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
- o._outputs[0]._typeConnectionSource = o._inputs[0],
- o._outputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
- o
- }
- return e.prototype.getClassName = function() {
- return "OneMinusBlock"
- }
- ,
- Object.defineProperty(e.prototype, "input", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0];
- return i.compilationString += this._declareOutput(o, i) + (" = 1. - " + this.input.associatedVariableName + `;\r
- `),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.OneMinusBlock", OneMinusBlock);
- RegisterClass("BABYLON.OppositeBlock", OneMinusBlock);
- var ViewDirectionBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("worldPosition", NodeMaterialBlockConnectionPointTypes.Vector4),
- o.registerInput("cameraPosition", NodeMaterialBlockConnectionPointTypes.Vector3),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector3),
- o
- }
- return e.prototype.getClassName = function() {
- return "ViewDirectionBlock"
- }
- ,
- Object.defineProperty(e.prototype, "worldPosition", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cameraPosition", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.autoConfigure = function(i) {
- if (!this.cameraPosition.isConnected) {
- var o = i.getInputBlockByPredicate(function(s) {
- return s.systemValue === NodeMaterialSystemValues.CameraPosition
- });
- o || (o = new InputBlock("cameraPosition"),
- o.setAsSystemValue(NodeMaterialSystemValues.CameraPosition)),
- o.output.connectTo(this.cameraPosition)
- }
- }
- ,
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0];
- return i.compilationString += this._declareOutput(o, i) + (" = normalize(" + this.cameraPosition.associatedVariableName + " - " + this.worldPosition.associatedVariableName + `.xyz);\r
- `),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.ViewDirectionBlock", ViewDirectionBlock);
- var FresnelBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("worldNormal", NodeMaterialBlockConnectionPointTypes.Vector4),
- o.registerInput("viewDirection", NodeMaterialBlockConnectionPointTypes.Vector3),
- o.registerInput("bias", NodeMaterialBlockConnectionPointTypes.Float),
- o.registerInput("power", NodeMaterialBlockConnectionPointTypes.Float),
- o.registerOutput("fresnel", NodeMaterialBlockConnectionPointTypes.Float),
- o
- }
- return e.prototype.getClassName = function() {
- return "FresnelBlock"
- }
- ,
- Object.defineProperty(e.prototype, "worldNormal", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "viewDirection", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "bias", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "power", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "fresnel", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.autoConfigure = function(i) {
- if (!this.viewDirection.isConnected) {
- var o = new ViewDirectionBlock("View direction");
- o.output.connectTo(this.viewDirection),
- o.autoConfigure(i)
- }
- if (!this.bias.isConnected) {
- var s = new InputBlock("bias");
- s.value = 0,
- s.output.connectTo(this.bias)
- }
- if (!this.power.isConnected) {
- var c = new InputBlock("power");
- c.value = 1,
- c.output.connectTo(this.power)
- }
- }
- ,
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = "//" + this.name;
- return i._emitFunctionFromInclude("fresnelFunction", o, {
- removeIfDef: !0
- }),
- i.compilationString += this._declareOutput(this.fresnel, i) + (" = computeFresnelTerm(" + this.viewDirection.associatedVariableName + ".xyz, " + this.worldNormal.associatedVariableName + ".xyz, " + this.bias.associatedVariableName + ", " + this.power.associatedVariableName + `);\r
- `),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.FresnelBlock", FresnelBlock);
- var MaxBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
- o._outputs[0]._typeConnectionSource = o._inputs[0],
- o._linkConnectionTypes(0, 1),
- o
- }
- return e.prototype.getClassName = function() {
- return "MaxBlock"
- }
- ,
- Object.defineProperty(e.prototype, "left", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "right", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0];
- return i.compilationString += this._declareOutput(o, i) + (" = max(" + this.left.associatedVariableName + ", " + this.right.associatedVariableName + `);\r
- `),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.MaxBlock", MaxBlock);
- var MinBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
- o._outputs[0]._typeConnectionSource = o._inputs[0],
- o._linkConnectionTypes(0, 1),
- o
- }
- return e.prototype.getClassName = function() {
- return "MinBlock"
- }
- ,
- Object.defineProperty(e.prototype, "left", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "right", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0];
- return i.compilationString += this._declareOutput(o, i) + (" = min(" + this.left.associatedVariableName + ", " + this.right.associatedVariableName + `);\r
- `),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.MinBlock", MinBlock);
- var DistanceBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Float),
- o._linkConnectionTypes(0, 1),
- o._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
- o._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
- o._inputs[1].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
- o._inputs[1].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
- o
- }
- return e.prototype.getClassName = function() {
- return "DistanceBlock"
- }
- ,
- Object.defineProperty(e.prototype, "left", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "right", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0];
- return i.compilationString += this._declareOutput(o, i) + (" = length(" + this.left.associatedVariableName + " - " + this.right.associatedVariableName + `);\r
- `),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.DistanceBlock", DistanceBlock);
- var LengthBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("value", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Float),
- o._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
- o._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
- o
- }
- return e.prototype.getClassName = function() {
- return "LengthBlock"
- }
- ,
- Object.defineProperty(e.prototype, "value", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0];
- return i.compilationString += this._declareOutput(o, i) + (" = length(" + this.value.associatedVariableName + `);\r
- `),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.LengthBlock", LengthBlock);
- var NegateBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("value", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
- o._outputs[0]._typeConnectionSource = o._inputs[0],
- o
- }
- return e.prototype.getClassName = function() {
- return "NegateBlock"
- }
- ,
- Object.defineProperty(e.prototype, "value", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0];
- return i.compilationString += this._declareOutput(o, i) + (" = -1.0 * " + this.value.associatedVariableName + `;\r
- `),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.NegateBlock", NegateBlock);
- var PowBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("value", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerInput("power", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
- o._outputs[0]._typeConnectionSource = o._inputs[0],
- o._linkConnectionTypes(0, 1),
- o
- }
- return e.prototype.getClassName = function() {
- return "PowBlock"
- }
- ,
- Object.defineProperty(e.prototype, "value", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "power", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0];
- return i.compilationString += this._declareOutput(o, i) + (" = pow(" + this.value.associatedVariableName + ", " + this.power.associatedVariableName + `);\r
- `),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.PowBlock", PowBlock);
- var RandomNumberBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("seed", NodeMaterialBlockConnectionPointTypes.Vector2),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Float),
- o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector3),
- o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
- o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color3),
- o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color4),
- o
- }
- return e.prototype.getClassName = function() {
- return "RandomNumberBlock"
- }
- ,
- Object.defineProperty(e.prototype, "seed", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0]
- , s = "//" + this.name;
- return i._emitFunctionFromInclude("helperFunctions", s),
- i.compilationString += this._declareOutput(o, i) + (" = getRand(" + this.seed.associatedVariableName + `.xy);\r
- `),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.RandomNumberBlock", RandomNumberBlock);
- var ArcTan2Block = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("x", NodeMaterialBlockConnectionPointTypes.Float),
- o.registerInput("y", NodeMaterialBlockConnectionPointTypes.Float),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Float),
- o
- }
- return e.prototype.getClassName = function() {
- return "ArcTan2Block"
- }
- ,
- Object.defineProperty(e.prototype, "x", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "y", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0];
- return i.compilationString += this._declareOutput(o, i) + (" = atan(" + this.x.associatedVariableName + ", " + this.y.associatedVariableName + `);\r
- `),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.ArcTan2Block", ArcTan2Block);
- var SmoothStepBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("value", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerInput("edge0", NodeMaterialBlockConnectionPointTypes.Float),
- o.registerInput("edge1", NodeMaterialBlockConnectionPointTypes.Float),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
- o._outputs[0]._typeConnectionSource = o._inputs[0],
- o
- }
- return e.prototype.getClassName = function() {
- return "SmoothStepBlock"
- }
- ,
- Object.defineProperty(e.prototype, "value", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "edge0", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "edge1", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0];
- return i.compilationString += this._declareOutput(o, i) + (" = smoothstep(" + this.edge0.associatedVariableName + ", " + this.edge1.associatedVariableName + ", " + this.value.associatedVariableName + `);\r
- `),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.SmoothStepBlock", SmoothStepBlock);
- var ReciprocalBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("input", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
- o._outputs[0]._typeConnectionSource = o._inputs[0],
- o._outputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
- o
- }
- return e.prototype.getClassName = function() {
- return "ReciprocalBlock"
- }
- ,
- Object.defineProperty(e.prototype, "input", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0];
- return i.compilationString += this._declareOutput(o, i) + (" = 1. / " + this.input.associatedVariableName + `;\r
- `),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.ReciprocalBlock", ReciprocalBlock);
- var ReplaceColorBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("value", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerInput("reference", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerInput("distance", NodeMaterialBlockConnectionPointTypes.Float),
- o.registerInput("replacement", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
- o._outputs[0]._typeConnectionSource = o._inputs[0],
- o._linkConnectionTypes(0, 1),
- o._linkConnectionTypes(0, 3),
- o._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
- o._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
- o._inputs[1].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
- o._inputs[1].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
- o._inputs[3].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
- o._inputs[3].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
- o
- }
- return e.prototype.getClassName = function() {
- return "ReplaceColorBlock"
- }
- ,
- Object.defineProperty(e.prototype, "value", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "reference", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "distance", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "replacement", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0];
- return i.compilationString += this._declareOutput(o, i) + `;\r
- `,
- i.compilationString += "if (length(" + this.value.associatedVariableName + " - " + this.reference.associatedVariableName + ") < " + this.distance.associatedVariableName + `) {\r
- `,
- i.compilationString += o.associatedVariableName + " = " + this.replacement.associatedVariableName + `;\r
- `,
- i.compilationString += `} else {\r
- `,
- i.compilationString += o.associatedVariableName + " = " + this.value.associatedVariableName + `;\r
- `,
- i.compilationString += `}\r
- `,
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.ReplaceColorBlock", ReplaceColorBlock);
- var PosterizeBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("value", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerInput("steps", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
- o._outputs[0]._typeConnectionSource = o._inputs[0],
- o._linkConnectionTypes(0, 1),
- o._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
- o._inputs[1].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
- o
- }
- return e.prototype.getClassName = function() {
- return "PosterizeBlock"
- }
- ,
- Object.defineProperty(e.prototype, "value", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "steps", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0];
- return i.compilationString += this._declareOutput(o, i) + (" = floor(" + this.value.associatedVariableName + " / (1.0 / " + this.steps.associatedVariableName + ")) * (1.0 / " + this.steps.associatedVariableName + `);\r
- `),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.PosterizeBlock", PosterizeBlock);
- var WaveBlockKind;
- (function(a) {
- a[a.SawTooth = 0] = "SawTooth",
- a[a.Square = 1] = "Square",
- a[a.Triangle = 2] = "Triangle"
- }
- )(WaveBlockKind || (WaveBlockKind = {}));
- var WaveBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.kind = WaveBlockKind.SawTooth,
- o.registerInput("input", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
- o._outputs[0]._typeConnectionSource = o._inputs[0],
- o._inputs[0].excludedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Matrix),
- o
- }
- return e.prototype.getClassName = function() {
- return "WaveBlock"
- }
- ,
- Object.defineProperty(e.prototype, "input", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0];
- switch (this.kind) {
- case WaveBlockKind.SawTooth:
- {
- i.compilationString += this._declareOutput(o, i) + (" = " + this.input.associatedVariableName + " - floor(0.5 + " + this.input.associatedVariableName + `);\r
- `);
- break
- }
- case WaveBlockKind.Square:
- {
- i.compilationString += this._declareOutput(o, i) + (" = 1.0 - 2.0 * round(fract(" + this.input.associatedVariableName + `));\r
- `);
- break
- }
- case WaveBlockKind.Triangle:
- {
- i.compilationString += this._declareOutput(o, i) + (" = 2.0 * abs(2.0 * (" + this.input.associatedVariableName + " - floor(0.5 + " + this.input.associatedVariableName + `))) - 1.0;\r
- `);
- break
- }
- }
- return this
- }
- ,
- e.prototype.serialize = function() {
- var i = a.prototype.serialize.call(this);
- return i.kind = this.kind,
- i
- }
- ,
- e.prototype._deserialize = function(i, o, s) {
- a.prototype._deserialize.call(this, i, o, s),
- this.kind = i.kind
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.WaveBlock", WaveBlock);
- var GradientBlockColorStep = function() {
- function a(e, i) {
- this.step = e,
- this.color = i
- }
- return Object.defineProperty(a.prototype, "step", {
- get: function() {
- return this._step
- },
- set: function(e) {
- this._step = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "color", {
- get: function() {
- return this._color
- },
- set: function(e) {
- this._color = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a
- }()
- , GradientBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.colorSteps = [new GradientBlockColorStep(0,Color3.Black()), new GradientBlockColorStep(1,Color3.White())],
- o.onValueChangedObservable = new Observable,
- o.registerInput("gradient", NodeMaterialBlockConnectionPointTypes.Float),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Color3),
- o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector2),
- o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector3),
- o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
- o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color3),
- o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color4),
- o
- }
- return e.prototype.colorStepsUpdated = function() {
- this.onValueChangedObservable.notifyObservers(this)
- }
- ,
- e.prototype.getClassName = function() {
- return "GradientBlock"
- }
- ,
- Object.defineProperty(e.prototype, "gradient", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._writeColorConstant = function(i) {
- var o = this.colorSteps[i];
- return "vec3(" + o.color.r + ", " + o.color.g + ", " + o.color.b + ")"
- }
- ,
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0];
- if (!this.colorSteps.length || !this.gradient.connectedPoint) {
- i.compilationString += this._declareOutput(o, i) + ` = vec3(0., 0., 0.);\r
- `;
- return
- }
- var s = i._getFreeVariableName("gradientTempColor")
- , c = i._getFreeVariableName("gradientTempPosition");
- i.compilationString += "vec3 " + s + " = " + this._writeColorConstant(0) + `;\r
- `,
- i.compilationString += "float " + c + `;\r
- `;
- var d = this.gradient.associatedVariableName;
- this.gradient.connectedPoint.type !== NodeMaterialBlockConnectionPointTypes.Float && (d += ".x");
- for (var _ = 1; _ < this.colorSteps.length; _++) {
- var b = this.colorSteps[_]
- , k = this.colorSteps[_ - 1];
- 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
- `,
- i.compilationString += s + " = mix(" + s + ", " + this._writeColorConstant(_) + ", " + c + `);\r
- `
- }
- return i.compilationString += this._declareOutput(o, i) + (" = " + s + `;\r
- `),
- this
- }
- ,
- e.prototype.serialize = function() {
- var i = a.prototype.serialize.call(this);
- i.colorSteps = [];
- for (var o = 0, s = this.colorSteps; o < s.length; o++) {
- var c = s[o];
- i.colorSteps.push({
- step: c.step,
- color: {
- r: c.color.r,
- g: c.color.g,
- b: c.color.b
- }
- })
- }
- return i
- }
- ,
- e.prototype._deserialize = function(i, o, s) {
- a.prototype._deserialize.call(this, i, o, s),
- this.colorSteps = [];
- for (var c = 0, d = i.colorSteps; c < d.length; c++) {
- var _ = d[c];
- this.colorSteps.push(new GradientBlockColorStep(_.step,new Color3(_.color.r,_.color.g,_.color.b)))
- }
- }
- ,
- e.prototype._dumpPropertiesCode = function() {
- var i = a.prototype._dumpPropertiesCode.call(this);
- i += this._codeVariableName + `.colorSteps = [];\r
- `;
- for (var o = 0, s = this.colorSteps; o < s.length; o++) {
- var c = s[o];
- i += this._codeVariableName + ".colorSteps.push(new BABYLON.GradientBlockColorStep(" + c.step + ", new BABYLON.Color3(" + c.color.r + ", " + c.color.g + ", " + c.color.b + `)));\r
- `
- }
- return i
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.GradientBlock", GradientBlock);
- var NLerpBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerInput("gradient", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
- o._outputs[0]._typeConnectionSource = o._inputs[0],
- o._linkConnectionTypes(0, 1),
- o._linkConnectionTypes(1, 2, !0),
- o._inputs[2].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Float),
- o
- }
- return e.prototype.getClassName = function() {
- return "NLerpBlock"
- }
- ,
- Object.defineProperty(e.prototype, "left", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "right", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "gradient", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0];
- return i.compilationString += this._declareOutput(o, i) + (" = normalize(mix(" + this.left.associatedVariableName + " , " + this.right.associatedVariableName + ", " + this.gradient.associatedVariableName + `));\r
- `),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.NLerpBlock", NLerpBlock);
- var WorleyNoise3DBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.manhattanDistance = !1,
- o.registerInput("seed", NodeMaterialBlockConnectionPointTypes.Vector3),
- o.registerInput("jitter", NodeMaterialBlockConnectionPointTypes.Float),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector2),
- o.registerOutput("x", NodeMaterialBlockConnectionPointTypes.Float),
- o.registerOutput("y", NodeMaterialBlockConnectionPointTypes.Float),
- o
- }
- return e.prototype.getClassName = function() {
- return "WorleyNoise3DBlock"
- }
- ,
- Object.defineProperty(e.prototype, "seed", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "jitter", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "x", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "y", {
- get: function() {
- return this._outputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- if (a.prototype._buildBlock.call(this, i),
- !!this.seed.isConnected && !(!this.output.hasEndpoints && !this.x.hasEndpoints && !this.y.hasEndpoints)) {
- var o = `vec3 permute(vec3 x){\r
- `;
- o += ` return mod((34.0 * x + 1.0) * x, 289.0);\r
- `,
- o += `}\r
- \r
- `,
- o += `vec3 dist(vec3 x, vec3 y, vec3 z, bool manhattanDistance){\r
- `,
- o += ` return manhattanDistance ? abs(x) + abs(y) + abs(z) : (x * x + y * y + z * z);\r
- `,
- o += `}\r
- \r
- `,
- o += `vec2 worley(vec3 P, float jitter, bool manhattanDistance){\r
- `,
- o += ` float K = 0.142857142857; // 1/7\r
- `,
- o += ` float Ko = 0.428571428571; // 1/2-K/2\r
- `,
- o += ` float K2 = 0.020408163265306; // 1/(7*7)\r
- `,
- o += ` float Kz = 0.166666666667; // 1/6\r
- `,
- o += ` float Kzo = 0.416666666667; // 1/2-1/6*2\r
- `,
- o += `\r
- `,
- o += ` vec3 Pi = mod(floor(P), 289.0);\r
- `,
- o += ` vec3 Pf = fract(P) - 0.5;\r
- `,
- o += `\r
- `,
- o += ` vec3 Pfx = Pf.x + vec3(1.0, 0.0, -1.0);\r
- `,
- o += ` vec3 Pfy = Pf.y + vec3(1.0, 0.0, -1.0);\r
- `,
- o += ` vec3 Pfz = Pf.z + vec3(1.0, 0.0, -1.0);\r
- `,
- o += `\r
- `,
- o += ` vec3 p = permute(Pi.x + vec3(-1.0, 0.0, 1.0));\r
- `,
- o += ` vec3 p1 = permute(p + Pi.y - 1.0);\r
- `,
- o += ` vec3 p2 = permute(p + Pi.y);\r
- `,
- o += ` vec3 p3 = permute(p + Pi.y + 1.0);\r
- `,
- o += `\r
- `,
- o += ` vec3 p11 = permute(p1 + Pi.z - 1.0);\r
- `,
- o += ` vec3 p12 = permute(p1 + Pi.z);\r
- `,
- o += ` vec3 p13 = permute(p1 + Pi.z + 1.0);\r
- `,
- o += `\r
- `,
- o += ` vec3 p21 = permute(p2 + Pi.z - 1.0);\r
- `,
- o += ` vec3 p22 = permute(p2 + Pi.z);\r
- `,
- o += ` vec3 p23 = permute(p2 + Pi.z + 1.0);\r
- `,
- o += `\r
- `,
- o += ` vec3 p31 = permute(p3 + Pi.z - 1.0);\r
- `,
- o += ` vec3 p32 = permute(p3 + Pi.z);\r
- `,
- o += ` vec3 p33 = permute(p3 + Pi.z + 1.0);\r
- `,
- o += `\r
- `,
- o += ` vec3 ox11 = fract(p11*K) - Ko;\r
- `,
- o += ` vec3 oy11 = mod(floor(p11*K), 7.0)*K - Ko;\r
- `,
- o += ` vec3 oz11 = floor(p11*K2)*Kz - Kzo; // p11 < 289 guaranteed\r
- `,
- o += `\r
- `,
- o += ` vec3 ox12 = fract(p12*K) - Ko;\r
- `,
- o += ` vec3 oy12 = mod(floor(p12*K), 7.0)*K - Ko;\r
- `,
- o += ` vec3 oz12 = floor(p12*K2)*Kz - Kzo;\r
- `,
- o += `\r
- `,
- o += ` vec3 ox13 = fract(p13*K) - Ko;\r
- `,
- o += ` vec3 oy13 = mod(floor(p13*K), 7.0)*K - Ko;\r
- `,
- o += ` vec3 oz13 = floor(p13*K2)*Kz - Kzo;\r
- `,
- o += `\r
- `,
- o += ` vec3 ox21 = fract(p21*K) - Ko;\r
- `,
- o += ` vec3 oy21 = mod(floor(p21*K), 7.0)*K - Ko;\r
- `,
- o += ` vec3 oz21 = floor(p21*K2)*Kz - Kzo;\r
- `,
- o += `\r
- `,
- o += ` vec3 ox22 = fract(p22*K) - Ko;\r
- `,
- o += ` vec3 oy22 = mod(floor(p22*K), 7.0)*K - Ko;\r
- `,
- o += ` vec3 oz22 = floor(p22*K2)*Kz - Kzo;\r
- `,
- o += `\r
- `,
- o += ` vec3 ox23 = fract(p23*K) - Ko;\r
- `,
- o += ` vec3 oy23 = mod(floor(p23*K), 7.0)*K - Ko;\r
- `,
- o += ` vec3 oz23 = floor(p23*K2)*Kz - Kzo;\r
- `,
- o += `\r
- `,
- o += ` vec3 ox31 = fract(p31*K) - Ko;\r
- `,
- o += ` vec3 oy31 = mod(floor(p31*K), 7.0)*K - Ko;\r
- `,
- o += ` vec3 oz31 = floor(p31*K2)*Kz - Kzo;\r
- `,
- o += `\r
- `,
- o += ` vec3 ox32 = fract(p32*K) - Ko;\r
- `,
- o += ` vec3 oy32 = mod(floor(p32*K), 7.0)*K - Ko;\r
- `,
- o += ` vec3 oz32 = floor(p32*K2)*Kz - Kzo;\r
- `,
- o += `\r
- `,
- o += ` vec3 ox33 = fract(p33*K) - Ko;\r
- `,
- o += ` vec3 oy33 = mod(floor(p33*K), 7.0)*K - Ko;\r
- `,
- o += ` vec3 oz33 = floor(p33*K2)*Kz - Kzo;\r
- `,
- o += `\r
- `,
- o += ` vec3 dx11 = Pfx + jitter*ox11;\r
- `,
- o += ` vec3 dy11 = Pfy.x + jitter*oy11;\r
- `,
- o += ` vec3 dz11 = Pfz.x + jitter*oz11;\r
- `,
- o += `\r
- `,
- o += ` vec3 dx12 = Pfx + jitter*ox12;\r
- `,
- o += ` vec3 dy12 = Pfy.x + jitter*oy12;\r
- `,
- o += ` vec3 dz12 = Pfz.y + jitter*oz12;\r
- `,
- o += `\r
- `,
- o += ` vec3 dx13 = Pfx + jitter*ox13;\r
- `,
- o += ` vec3 dy13 = Pfy.x + jitter*oy13;\r
- `,
- o += ` vec3 dz13 = Pfz.z + jitter*oz13;\r
- `,
- o += `\r
- `,
- o += ` vec3 dx21 = Pfx + jitter*ox21;\r
- `,
- o += ` vec3 dy21 = Pfy.y + jitter*oy21;\r
- `,
- o += ` vec3 dz21 = Pfz.x + jitter*oz21;\r
- `,
- o += `\r
- `,
- o += ` vec3 dx22 = Pfx + jitter*ox22;\r
- `,
- o += ` vec3 dy22 = Pfy.y + jitter*oy22;\r
- `,
- o += ` vec3 dz22 = Pfz.y + jitter*oz22;\r
- `,
- o += `\r
- `,
- o += ` vec3 dx23 = Pfx + jitter*ox23;\r
- `,
- o += ` vec3 dy23 = Pfy.y + jitter*oy23;\r
- `,
- o += ` vec3 dz23 = Pfz.z + jitter*oz23;\r
- `,
- o += `\r
- `,
- o += ` vec3 dx31 = Pfx + jitter*ox31;\r
- `,
- o += ` vec3 dy31 = Pfy.z + jitter*oy31;\r
- `,
- o += ` vec3 dz31 = Pfz.x + jitter*oz31;\r
- `,
- o += `\r
- `,
- o += ` vec3 dx32 = Pfx + jitter*ox32;\r
- `,
- o += ` vec3 dy32 = Pfy.z + jitter*oy32;\r
- `,
- o += ` vec3 dz32 = Pfz.y + jitter*oz32;\r
- `,
- o += `\r
- `,
- o += ` vec3 dx33 = Pfx + jitter*ox33;\r
- `,
- o += ` vec3 dy33 = Pfy.z + jitter*oy33;\r
- `,
- o += ` vec3 dz33 = Pfz.z + jitter*oz33;\r
- `,
- o += `\r
- `,
- o += ` vec3 d11 = dist(dx11, dy11, dz11, manhattanDistance);\r
- `,
- o += ` vec3 d12 =dist(dx12, dy12, dz12, manhattanDistance);\r
- `,
- o += ` vec3 d13 = dist(dx13, dy13, dz13, manhattanDistance);\r
- `,
- o += ` vec3 d21 = dist(dx21, dy21, dz21, manhattanDistance);\r
- `,
- o += ` vec3 d22 = dist(dx22, dy22, dz22, manhattanDistance);\r
- `,
- o += ` vec3 d23 = dist(dx23, dy23, dz23, manhattanDistance);\r
- `,
- o += ` vec3 d31 = dist(dx31, dy31, dz31, manhattanDistance);\r
- `,
- o += ` vec3 d32 = dist(dx32, dy32, dz32, manhattanDistance);\r
- `,
- o += ` vec3 d33 = dist(dx33, dy33, dz33, manhattanDistance);\r
- `,
- o += `\r
- `,
- o += ` vec3 d1a = min(d11, d12);\r
- `,
- o += ` d12 = max(d11, d12);\r
- `,
- o += ` d11 = min(d1a, d13); // Smallest now not in d12 or d13\r
- `,
- o += ` d13 = max(d1a, d13);\r
- `,
- o += ` d12 = min(d12, d13); // 2nd smallest now not in d13\r
- `,
- o += ` vec3 d2a = min(d21, d22);\r
- `,
- o += ` d22 = max(d21, d22);\r
- `,
- o += ` d21 = min(d2a, d23); // Smallest now not in d22 or d23\r
- `,
- o += ` d23 = max(d2a, d23);\r
- `,
- o += ` d22 = min(d22, d23); // 2nd smallest now not in d23\r
- `,
- o += ` vec3 d3a = min(d31, d32);\r
- `,
- o += ` d32 = max(d31, d32);\r
- `,
- o += ` d31 = min(d3a, d33); // Smallest now not in d32 or d33\r
- `,
- o += ` d33 = max(d3a, d33);\r
- `,
- o += ` d32 = min(d32, d33); // 2nd smallest now not in d33\r
- `,
- o += ` vec3 da = min(d11, d21);\r
- `,
- o += ` d21 = max(d11, d21);\r
- `,
- o += ` d11 = min(da, d31); // Smallest now in d11\r
- `,
- o += ` d31 = max(da, d31); // 2nd smallest now not in d31\r
- `,
- o += ` d11.xy = (d11.x < d11.y) ? d11.xy : d11.yx;\r
- `,
- o += ` d11.xz = (d11.x < d11.z) ? d11.xz : d11.zx; // d11.x now smallest\r
- `,
- o += ` d12 = min(d12, d21); // 2nd smallest now not in d21\r
- `,
- o += ` d12 = min(d12, d22); // nor in d22\r
- `,
- o += ` d12 = min(d12, d31); // nor in d31\r
- `,
- o += ` d12 = min(d12, d32); // nor in d32\r
- `,
- o += ` d11.yz = min(d11.yz,d12.xy); // nor in d12.yz\r
- `,
- o += ` d11.y = min(d11.y,d12.z); // Only two more to go\r
- `,
- o += ` d11.y = min(d11.y,d11.z); // Done! (Phew!)\r
- `,
- o += ` return sqrt(d11.xy); // F1, F2\r
- `,
- o += `}\r
- \r
- `,
- i._emitFunction("worley3D", o, "// Worley3D");
- var s = i._getFreeVariableName("worleyTemp");
- return i.compilationString += "vec2 " + s + " = worley(" + this.seed.associatedVariableName + ", " + this.jitter.associatedVariableName + ", " + this.manhattanDistance + `);\r
- `,
- this.output.hasEndpoints && (i.compilationString += this._declareOutput(this.output, i) + (" = " + s + `;\r
- `)),
- this.x.hasEndpoints && (i.compilationString += this._declareOutput(this.x, i) + (" = " + s + `.x;\r
- `)),
- this.y.hasEndpoints && (i.compilationString += this._declareOutput(this.y, i) + (" = " + s + `.y;\r
- `)),
- this
- }
- }
- ,
- e.prototype._dumpPropertiesCode = function() {
- var i = a.prototype._dumpPropertiesCode.call(this) + (this._codeVariableName + ".manhattanDistance = " + this.manhattanDistance + `;\r
- `);
- return i
- }
- ,
- e.prototype.serialize = function() {
- var i = a.prototype.serialize.call(this);
- return i.manhattanDistance = this.manhattanDistance,
- i
- }
- ,
- e.prototype._deserialize = function(i, o, s) {
- a.prototype._deserialize.call(this, i, o, s),
- this.manhattanDistance = i.manhattanDistance
- }
- ,
- __decorate([editableInPropertyPage("Use Manhattan Distance", PropertyTypeForEdition.Boolean, "PROPERTIES", {
- notifiers: {
- update: !1
- }
- })], e.prototype, "manhattanDistance", void 0),
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.WorleyNoise3DBlock", WorleyNoise3DBlock);
- var SimplexPerlin3DBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("seed", NodeMaterialBlockConnectionPointTypes.Vector3),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Float),
- o
- }
- return e.prototype.getClassName = function() {
- return "SimplexPerlin3DBlock"
- }
- ,
- Object.defineProperty(e.prototype, "seed", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- if (a.prototype._buildBlock.call(this, i),
- !!this.seed.isConnected && !!this._outputs[0].hasEndpoints) {
- var o = `const float SKEWFACTOR = 1.0/3.0;\r
- `;
- return o += `const float UNSKEWFACTOR = 1.0/6.0;\r
- `,
- o += `const float SIMPLEX_CORNER_POS = 0.5;\r
- `,
- o += `const float SIMPLEX_TETRAHADRON_HEIGHT = 0.70710678118654752440084436210485;\r
- `,
- o += `float SimplexPerlin3D( vec3 P ){\r
- `,
- o += ` P *= SIMPLEX_TETRAHADRON_HEIGHT;\r
- `,
- o += " vec3 Pi = floor( P + dot( P, vec3( SKEWFACTOR) ) );",
- o += ` vec3 x0 = P - Pi + dot(Pi, vec3( UNSKEWFACTOR ) );\r
- `,
- o += ` vec3 g = step(x0.yzx, x0.xyz);\r
- `,
- o += ` vec3 l = 1.0 - g;\r
- `,
- o += ` vec3 Pi_1 = min( g.xyz, l.zxy );\r
- `,
- o += ` vec3 Pi_2 = max( g.xyz, l.zxy );\r
- `,
- o += ` vec3 x1 = x0 - Pi_1 + UNSKEWFACTOR;\r
- `,
- o += ` vec3 x2 = x0 - Pi_2 + SKEWFACTOR;\r
- `,
- o += ` vec3 x3 = x0 - SIMPLEX_CORNER_POS;\r
- `,
- o += ` vec4 v1234_x = vec4( x0.x, x1.x, x2.x, x3.x );\r
- `,
- o += ` vec4 v1234_y = vec4( x0.y, x1.y, x2.y, x3.y );\r
- `,
- o += ` vec4 v1234_z = vec4( x0.z, x1.z, x2.z, x3.z );\r
- `,
- o += ` Pi.xyz = Pi.xyz - floor(Pi.xyz * ( 1.0 / 69.0 )) * 69.0;\r
- `,
- o += ` vec3 Pi_inc1 = step( Pi, vec3( 69.0 - 1.5 ) ) * ( Pi + 1.0 );\r
- `,
- o += ` vec4 Pt = vec4( Pi.xy, Pi_inc1.xy ) + vec2( 50.0, 161.0 ).xyxy;\r
- `,
- o += ` Pt *= Pt;\r
- `,
- o += ` vec4 V1xy_V2xy = mix( Pt.xyxy, Pt.zwzw, vec4( Pi_1.xy, Pi_2.xy ) );\r
- `,
- o += ` Pt = vec4( Pt.x, V1xy_V2xy.xz, Pt.z ) * vec4( Pt.y, V1xy_V2xy.yw, Pt.w );\r
- `,
- o += ` const vec3 SOMELARGEFLOATS = vec3( 635.298681, 682.357502, 668.926525 );\r
- `,
- o += ` const vec3 ZINC = vec3( 48.500388, 65.294118, 63.934599 );\r
- `,
- o += ` vec3 lowz_mods = vec3( 1.0 / ( SOMELARGEFLOATS.xyz + Pi.zzz * ZINC.xyz ) );\r
- `,
- o += ` vec3 highz_mods = vec3( 1.0 / ( SOMELARGEFLOATS.xyz + Pi_inc1.zzz * ZINC.xyz ) );\r
- `,
- o += ` Pi_1 = ( Pi_1.z < 0.5 ) ? lowz_mods : highz_mods;\r
- `,
- o += ` Pi_2 = ( Pi_2.z < 0.5 ) ? lowz_mods : highz_mods;\r
- `,
- o += ` vec4 hash_0 = fract( Pt * vec4( lowz_mods.x, Pi_1.x, Pi_2.x, highz_mods.x ) ) - 0.49999;\r
- `,
- o += ` vec4 hash_1 = fract( Pt * vec4( lowz_mods.y, Pi_1.y, Pi_2.y, highz_mods.y ) ) - 0.49999;\r
- `,
- o += ` vec4 hash_2 = fract( Pt * vec4( lowz_mods.z, Pi_1.z, Pi_2.z, highz_mods.z ) ) - 0.49999;\r
- `,
- 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
- `,
- o += ` const float FINAL_NORMALIZATION = 37.837227241611314102871574478976;\r
- `,
- o += ` vec4 kernel_weights = v1234_x * v1234_x + v1234_y * v1234_y + v1234_z * v1234_z;\r
- `,
- o += ` kernel_weights = max(0.5 - kernel_weights, 0.0);\r
- `,
- o += ` kernel_weights = kernel_weights*kernel_weights*kernel_weights;\r
- `,
- o += ` return dot( kernel_weights, grad_results ) * FINAL_NORMALIZATION;\r
- `,
- o += `}\r
- `,
- i._emitFunction("SimplexPerlin3D", o, "// SimplexPerlin3D"),
- i.compilationString += this._declareOutput(this._outputs[0], i) + (" = SimplexPerlin3D(" + this.seed.associatedVariableName + `);\r
- `),
- this
- }
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.SimplexPerlin3DBlock", SimplexPerlin3DBlock);
- var NormalBlendBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("normalMap0", NodeMaterialBlockConnectionPointTypes.Vector3),
- o.registerInput("normalMap1", NodeMaterialBlockConnectionPointTypes.Vector3),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector3),
- o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color3),
- o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color4),
- o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
- o._inputs[1].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color3),
- o._inputs[1].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color4),
- o._inputs[1].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
- o
- }
- return e.prototype.getClassName = function() {
- return "NormalBlendBlock"
- }
- ,
- Object.defineProperty(e.prototype, "normalMap0", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "normalMap1", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0]
- , s = this._inputs[0]
- , c = this._inputs[1]
- , d = i._getFreeVariableName("stepR")
- , _ = i._getFreeVariableName("stepG");
- return i.compilationString += "float " + d + " = step(0.5, " + s.associatedVariableName + `.r);\r
- `,
- i.compilationString += "float " + _ + " = step(0.5, " + s.associatedVariableName + `.g);\r
- `,
- i.compilationString += this._declareOutput(o, i) + `;\r
- `,
- 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
- `,
- 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
- `,
- i.compilationString += o.associatedVariableName + ".b = " + s.associatedVariableName + ".b * " + c.associatedVariableName + `.b;\r
- `,
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.NormalBlendBlock", NormalBlendBlock);
- var Rotate2dBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("input", NodeMaterialBlockConnectionPointTypes.Vector2),
- o.registerInput("angle", NodeMaterialBlockConnectionPointTypes.Float),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector2),
- o
- }
- return e.prototype.getClassName = function() {
- return "Rotate2dBlock"
- }
- ,
- Object.defineProperty(e.prototype, "input", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "angle", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.autoConfigure = function(i) {
- if (!this.angle.isConnected) {
- var o = new InputBlock("angle");
- o.value = 0,
- o.output.connectTo(this.angle)
- }
- }
- ,
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0]
- , s = this.angle
- , c = this.input;
- 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
- `),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.Rotate2dBlock", Rotate2dBlock);
- var ReflectBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("incident", NodeMaterialBlockConnectionPointTypes.Vector3),
- o.registerInput("normal", NodeMaterialBlockConnectionPointTypes.Vector3),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector3),
- o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
- o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color3),
- o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color4),
- o._inputs[1].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
- o._inputs[1].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color3),
- o._inputs[1].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color4),
- o
- }
- return e.prototype.getClassName = function() {
- return "ReflectBlock"
- }
- ,
- Object.defineProperty(e.prototype, "incident", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "normal", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0];
- return i.compilationString += this._declareOutput(o, i) + (" = reflect(" + this.incident.associatedVariableName + ".xyz, " + this.normal.associatedVariableName + `.xyz);\r
- `),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.ReflectBlock", ReflectBlock);
- var RefractBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("incident", NodeMaterialBlockConnectionPointTypes.Vector3),
- o.registerInput("normal", NodeMaterialBlockConnectionPointTypes.Vector3),
- o.registerInput("ior", NodeMaterialBlockConnectionPointTypes.Float),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Vector3),
- o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
- o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color3),
- o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color4),
- o._inputs[1].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector4),
- o._inputs[1].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color3),
- o._inputs[1].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Color4),
- o
- }
- return e.prototype.getClassName = function() {
- return "RefractBlock"
- }
- ,
- Object.defineProperty(e.prototype, "incident", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "normal", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "ior", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0];
- return i.compilationString += this._declareOutput(o, i) + (" = refract(" + this.incident.associatedVariableName + ".xyz, " + this.normal.associatedVariableName + ".xyz, " + this.ior.associatedVariableName + `);\r
- `),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.RefractBlock", RefractBlock);
- var DesaturateBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("color", NodeMaterialBlockConnectionPointTypes.Color3),
- o.registerInput("level", NodeMaterialBlockConnectionPointTypes.Float),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Color3),
- o
- }
- return e.prototype.getClassName = function() {
- return "DesaturateBlock"
- }
- ,
- Object.defineProperty(e.prototype, "color", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "level", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0]
- , s = this.color
- , c = s.associatedVariableName
- , d = i._getFreeVariableName("colorMin")
- , _ = i._getFreeVariableName("colorMax")
- , b = i._getFreeVariableName("colorMerge");
- return i.compilationString += "float " + d + " = min(min(" + c + ".x, " + c + ".y), " + c + `.z);\r
- `,
- i.compilationString += "float " + _ + " = max(max(" + c + ".x, " + c + ".y), " + c + `.z);\r
- `,
- i.compilationString += "float " + b + " = 0.5 * (" + d + " + " + _ + `);\r
- `,
- i.compilationString += this._declareOutput(o, i) + (" = mix(" + c + ", vec3(" + b + ", " + b + ", " + b + "), " + this.level.associatedVariableName + `);\r
- `),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.DesaturateBlock", DesaturateBlock);
- 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=="
- , _instanceNumber = 0
- , GetEnvironmentBRDFTexture = function(a) {
- if (!a.environmentBRDFTexture) {
- var e = a.useDelayedTextureLoading;
- a.useDelayedTextureLoading = !1;
- var i = a._blockEntityCollection;
- a._blockEntityCollection = !1;
- var o = Texture.CreateFromBase64String(_environmentBRDFBase64Texture, "EnvironmentBRDFTexture" + _instanceNumber++, a, !0, !1, Texture.BILINEAR_SAMPLINGMODE);
- a._blockEntityCollection = i;
- var s = a.getEngine().getLoadedTexturesCache()
- , c = s.indexOf(o.getInternalTexture());
- c !== -1 && s.splice(c, 1),
- o.isRGBD = !0,
- o.wrapU = Texture.CLAMP_ADDRESSMODE,
- o.wrapV = Texture.CLAMP_ADDRESSMODE,
- a.environmentBRDFTexture = o,
- a.useDelayedTextureLoading = e,
- RGBDTextureTools.ExpandRGBDTexture(o),
- a.getEngine().onContextRestoredObservable.add(function() {
- o.isRGBD = !0;
- var d = function() {
- o.isReady() ? RGBDTextureTools.ExpandRGBDTexture(o) : Tools.SetImmediate(d)
- };
- d()
- })
- }
- return a.environmentBRDFTexture
- }
- , PBRClearCoatConfiguration = function() {
- function a(e) {
- this._isEnabled = !1,
- this.isEnabled = !1,
- this.intensity = 1,
- this.roughness = 0,
- this._indexOfRefraction = a._DefaultIndexOfRefraction,
- this.indexOfRefraction = a._DefaultIndexOfRefraction,
- this._texture = null,
- this.texture = null,
- this._useRoughnessFromMainTexture = !0,
- this.useRoughnessFromMainTexture = !0,
- this._textureRoughness = null,
- this.textureRoughness = null,
- this._remapF0OnInterfaceChange = !0,
- this.remapF0OnInterfaceChange = !0,
- this._bumpTexture = null,
- this.bumpTexture = null,
- this._isTintEnabled = !1,
- this.isTintEnabled = !1,
- this.tintColor = Color3.White(),
- this.tintColorAtDistance = 1,
- this.tintThickness = 1,
- this._tintTexture = null,
- this.tintTexture = null,
- this._internalMarkAllSubMeshesAsTexturesDirty = e
- }
- return a.prototype._markAllSubMeshesAsTexturesDirty = function() {
- this._internalMarkAllSubMeshesAsTexturesDirty()
- }
- ,
- a.prototype.isReadyForSubMesh = function(e, i, o, s) {
- 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
- }
- ,
- a.prototype.prepareDefines = function(e, i) {
- var o;
- this._isEnabled ? (e.CLEARCOAT = !0,
- e.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE = this._useRoughnessFromMainTexture,
- 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),
- e.CLEARCOAT_REMAP_F0 = this._remapF0OnInterfaceChange,
- e._areTexturesDirty && i.texturesEnabled && (this._texture && MaterialFlags.ClearCoatTextureEnabled ? MaterialHelper.PrepareDefinesForMergedUV(this._texture, e, "CLEARCOAT_TEXTURE") : e.CLEARCOAT_TEXTURE = !1,
- this._textureRoughness && MaterialFlags.ClearCoatTextureEnabled ? MaterialHelper.PrepareDefinesForMergedUV(this._textureRoughness, e, "CLEARCOAT_TEXTURE_ROUGHNESS") : e.CLEARCOAT_TEXTURE_ROUGHNESS = !1,
- this._bumpTexture && MaterialFlags.ClearCoatBumpTextureEnabled ? MaterialHelper.PrepareDefinesForMergedUV(this._bumpTexture, e, "CLEARCOAT_BUMP") : e.CLEARCOAT_BUMP = !1,
- e.CLEARCOAT_DEFAULTIOR = this._indexOfRefraction === a._DefaultIndexOfRefraction,
- this._isTintEnabled ? (e.CLEARCOAT_TINT = !0,
- this._tintTexture && MaterialFlags.ClearCoatTintTextureEnabled ? (MaterialHelper.PrepareDefinesForMergedUV(this._tintTexture, e, "CLEARCOAT_TINT_TEXTURE"),
- e.CLEARCOAT_TINT_GAMMATEXTURE = this._tintTexture.gammaSpace) : e.CLEARCOAT_TINT_TEXTURE = !1) : (e.CLEARCOAT_TINT = !1,
- e.CLEARCOAT_TINT_TEXTURE = !1))) : (e.CLEARCOAT = !1,
- e.CLEARCOAT_TEXTURE = !1,
- e.CLEARCOAT_TEXTURE_ROUGHNESS = !1,
- e.CLEARCOAT_BUMP = !1,
- e.CLEARCOAT_TINT = !1,
- e.CLEARCOAT_TINT_TEXTURE = !1,
- e.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE = !1,
- e.CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL = !1)
- }
- ,
- a.prototype.bindForSubMesh = function(e, i, o, s, c, d, _, b) {
- var k, j, $, _e, et, tt, rt, it;
- if (!!this._isEnabled) {
- var nt = b.materialDefines
- , ot = nt.CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL;
- if (!e.useUbo || !c || !e.isSync) {
- ot && MaterialFlags.ClearCoatTextureEnabled ? (e.updateFloat4("vClearCoatInfos", this._texture.coordinatesIndex, this._texture.level, -1, -1),
- 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),
- this._texture && MaterialHelper.BindTextureMatrix(this._texture, e, "clearCoat"),
- this._textureRoughness && !ot && !nt.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE && MaterialHelper.BindTextureMatrix(this._textureRoughness, e, "clearCoatRoughness")),
- this._bumpTexture && o.getCaps().standardDerivatives && MaterialFlags.ClearCoatTextureEnabled && !s && (e.updateFloat2("vClearCoatBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level),
- MaterialHelper.BindTextureMatrix(this._bumpTexture, e, "clearCoatBump"),
- i._mirroredCameraPosition ? e.updateFloat2("vClearCoatTangentSpaceParams", d ? 1 : -1, _ ? 1 : -1) : e.updateFloat2("vClearCoatTangentSpaceParams", d ? -1 : 1, _ ? -1 : 1)),
- this._tintTexture && MaterialFlags.ClearCoatTintTextureEnabled && (e.updateFloat2("vClearCoatTintInfos", this._tintTexture.coordinatesIndex, this._tintTexture.level),
- MaterialHelper.BindTextureMatrix(this._tintTexture, e, "clearCoatTint")),
- e.updateFloat2("vClearCoatParams", this.intensity, this.roughness);
- var at = 1 - this._indexOfRefraction
- , st = 1 + this._indexOfRefraction
- , ut = Math.pow(-at / st, 2)
- , ct = 1 / this._indexOfRefraction;
- e.updateFloat4("vClearCoatRefractionParams", ut, ct, at, st),
- this._isTintEnabled && (e.updateFloat4("vClearCoatTintParams", this.tintColor.r, this.tintColor.g, this.tintColor.b, Math.max(1e-5, this.tintThickness)),
- e.updateFloat("clearCoatColorAtDistance", Math.max(1e-5, this.tintColorAtDistance)))
- }
- i.texturesEnabled && (this._texture && MaterialFlags.ClearCoatTextureEnabled && e.setTexture("clearCoatSampler", this._texture),
- this._textureRoughness && !ot && !nt.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE && MaterialFlags.ClearCoatTextureEnabled && e.setTexture("clearCoatRoughnessSampler", this._textureRoughness),
- this._bumpTexture && o.getCaps().standardDerivatives && MaterialFlags.ClearCoatBumpTextureEnabled && !s && e.setTexture("clearCoatBumpSampler", this._bumpTexture),
- this._isTintEnabled && this._tintTexture && MaterialFlags.ClearCoatTintTextureEnabled && e.setTexture("clearCoatTintSampler", this._tintTexture))
- }
- }
- ,
- a.prototype.hasTexture = function(e) {
- return this._texture === e || this._textureRoughness === e || this._bumpTexture === e || this._tintTexture === e
- }
- ,
- a.prototype.getActiveTextures = function(e) {
- this._texture && e.push(this._texture),
- this._textureRoughness && e.push(this._textureRoughness),
- this._bumpTexture && e.push(this._bumpTexture),
- this._tintTexture && e.push(this._tintTexture)
- }
- ,
- a.prototype.getAnimatables = function(e) {
- this._texture && this._texture.animations && this._texture.animations.length > 0 && e.push(this._texture),
- this._textureRoughness && this._textureRoughness.animations && this._textureRoughness.animations.length > 0 && e.push(this._textureRoughness),
- this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0 && e.push(this._bumpTexture),
- this._tintTexture && this._tintTexture.animations && this._tintTexture.animations.length > 0 && e.push(this._tintTexture)
- }
- ,
- a.prototype.dispose = function(e) {
- var i, o, s, c;
- e && ((i = this._texture) === null || i === void 0 || i.dispose(),
- (o = this._textureRoughness) === null || o === void 0 || o.dispose(),
- (s = this._bumpTexture) === null || s === void 0 || s.dispose(),
- (c = this._tintTexture) === null || c === void 0 || c.dispose())
- }
- ,
- a.prototype.getClassName = function() {
- return "PBRClearCoatConfiguration"
- }
- ,
- a.AddFallbacks = function(e, i, o) {
- return e.CLEARCOAT_BUMP && i.addFallback(o++, "CLEARCOAT_BUMP"),
- e.CLEARCOAT_TINT && i.addFallback(o++, "CLEARCOAT_TINT"),
- e.CLEARCOAT && i.addFallback(o++, "CLEARCOAT"),
- o
- }
- ,
- a.AddUniforms = function(e) {
- e.push("vClearCoatTangentSpaceParams", "vClearCoatParams", "vClearCoatRefractionParams", "vClearCoatTintParams", "clearCoatColorAtDistance", "clearCoatMatrix", "clearCoatRoughnessMatrix", "clearCoatBumpMatrix", "clearCoatTintMatrix", "vClearCoatInfos", "vClearCoatBumpInfos", "vClearCoatTintInfos")
- }
- ,
- a.AddSamplers = function(e) {
- e.push("clearCoatSampler", "clearCoatRoughnessSampler", "clearCoatBumpSampler", "clearCoatTintSampler")
- }
- ,
- a.PrepareUniformBuffer = function(e) {
- e.addUniform("vClearCoatParams", 2),
- e.addUniform("vClearCoatRefractionParams", 4),
- e.addUniform("vClearCoatInfos", 4),
- e.addUniform("clearCoatMatrix", 16),
- e.addUniform("clearCoatRoughnessMatrix", 16),
- e.addUniform("vClearCoatBumpInfos", 2),
- e.addUniform("vClearCoatTangentSpaceParams", 2),
- e.addUniform("clearCoatBumpMatrix", 16),
- e.addUniform("vClearCoatTintParams", 4),
- e.addUniform("clearCoatColorAtDistance", 1),
- e.addUniform("vClearCoatTintInfos", 2),
- e.addUniform("clearCoatTintMatrix", 16)
- }
- ,
- a.prototype.copyTo = function(e) {
- SerializationHelper.Clone(function() {
- return e
- }, this)
- }
- ,
- a.prototype.serialize = function() {
- return SerializationHelper.Serialize(this)
- }
- ,
- a.prototype.parse = function(e, i, o) {
- var s = this;
- SerializationHelper.Parse(function() {
- return s
- }, e, i, o)
- }
- ,
- a._DefaultIndexOfRefraction = 1.5,
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "isEnabled", void 0),
- __decorate([serialize()], a.prototype, "intensity", void 0),
- __decorate([serialize()], a.prototype, "roughness", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "indexOfRefraction", void 0),
- __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "texture", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "useRoughnessFromMainTexture", void 0),
- __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "textureRoughness", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "remapF0OnInterfaceChange", void 0),
- __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "bumpTexture", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "isTintEnabled", void 0),
- __decorate([serializeAsColor3()], a.prototype, "tintColor", void 0),
- __decorate([serialize()], a.prototype, "tintColorAtDistance", void 0),
- __decorate([serialize()], a.prototype, "tintThickness", void 0),
- __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "tintTexture", void 0),
- a
- }()
- , PBRAnisotropicConfiguration = function() {
- function a(e) {
- this._isEnabled = !1,
- this.isEnabled = !1,
- this.intensity = 1,
- this.direction = new Vector2(1,0),
- this._texture = null,
- this.texture = null,
- this._internalMarkAllSubMeshesAsTexturesDirty = e
- }
- return a.prototype._markAllSubMeshesAsTexturesDirty = function() {
- this._internalMarkAllSubMeshesAsTexturesDirty()
- }
- ,
- a.prototype.isReadyForSubMesh = function(e, i) {
- return this._isEnabled ? !(e._areTexturesDirty && i.texturesEnabled && this._texture && MaterialFlags.AnisotropicTextureEnabled && !this._texture.isReadyOrNotBlocking()) : !0
- }
- ,
- a.prototype.prepareDefines = function(e, i, o) {
- this._isEnabled ? (e.ANISOTROPIC = this._isEnabled,
- this._isEnabled && !i.isVerticesDataPresent(VertexBuffer.TangentKind) && (e._needUVs = !0,
- e.MAINUV1 = !0),
- e._areTexturesDirty && o.texturesEnabled && (this._texture && MaterialFlags.AnisotropicTextureEnabled ? MaterialHelper.PrepareDefinesForMergedUV(this._texture, e, "ANISOTROPIC_TEXTURE") : e.ANISOTROPIC_TEXTURE = !1)) : (e.ANISOTROPIC = !1,
- e.ANISOTROPIC_TEXTURE = !1)
- }
- ,
- a.prototype.bindForSubMesh = function(e, i, o) {
- !this._isEnabled || ((!e.useUbo || !o || !e.isSync) && (this._texture && MaterialFlags.AnisotropicTextureEnabled && (e.updateFloat2("vAnisotropyInfos", this._texture.coordinatesIndex, this._texture.level),
- MaterialHelper.BindTextureMatrix(this._texture, e, "anisotropy")),
- e.updateFloat3("vAnisotropy", this.direction.x, this.direction.y, this.intensity)),
- i.texturesEnabled && this._texture && MaterialFlags.AnisotropicTextureEnabled && e.setTexture("anisotropySampler", this._texture))
- }
- ,
- a.prototype.hasTexture = function(e) {
- return this._texture === e
- }
- ,
- a.prototype.getActiveTextures = function(e) {
- this._texture && e.push(this._texture)
- }
- ,
- a.prototype.getAnimatables = function(e) {
- this._texture && this._texture.animations && this._texture.animations.length > 0 && e.push(this._texture)
- }
- ,
- a.prototype.dispose = function(e) {
- e && this._texture && this._texture.dispose()
- }
- ,
- a.prototype.getClassName = function() {
- return "PBRAnisotropicConfiguration"
- }
- ,
- a.AddFallbacks = function(e, i, o) {
- return e.ANISOTROPIC && i.addFallback(o++, "ANISOTROPIC"),
- o
- }
- ,
- a.AddUniforms = function(e) {
- e.push("vAnisotropy", "vAnisotropyInfos", "anisotropyMatrix")
- }
- ,
- a.PrepareUniformBuffer = function(e) {
- e.addUniform("vAnisotropy", 3),
- e.addUniform("vAnisotropyInfos", 2),
- e.addUniform("anisotropyMatrix", 16)
- }
- ,
- a.AddSamplers = function(e) {
- e.push("anisotropySampler")
- }
- ,
- a.prototype.copyTo = function(e) {
- SerializationHelper.Clone(function() {
- return e
- }, this)
- }
- ,
- a.prototype.serialize = function() {
- return SerializationHelper.Serialize(this)
- }
- ,
- a.prototype.parse = function(e, i, o) {
- var s = this;
- SerializationHelper.Parse(function() {
- return s
- }, e, i, o)
- }
- ,
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "isEnabled", void 0),
- __decorate([serialize()], a.prototype, "intensity", void 0),
- __decorate([serializeAsVector2()], a.prototype, "direction", void 0),
- __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "texture", void 0),
- a
- }()
- , PBRBRDFConfiguration = function() {
- function a(e) {
- this._useEnergyConservation = a.DEFAULT_USE_ENERGY_CONSERVATION,
- this.useEnergyConservation = a.DEFAULT_USE_ENERGY_CONSERVATION,
- this._useSmithVisibilityHeightCorrelated = a.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,
- this.useSmithVisibilityHeightCorrelated = a.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,
- this._useSphericalHarmonics = a.DEFAULT_USE_SPHERICAL_HARMONICS,
- this.useSphericalHarmonics = a.DEFAULT_USE_SPHERICAL_HARMONICS,
- this._useSpecularGlossinessInputEnergyConservation = a.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,
- this.useSpecularGlossinessInputEnergyConservation = a.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,
- this._internalMarkAllSubMeshesAsMiscDirty = e
- }
- return a.prototype._markAllSubMeshesAsMiscDirty = function() {
- this._internalMarkAllSubMeshesAsMiscDirty()
- }
- ,
- a.prototype.prepareDefines = function(e) {
- e.BRDF_V_HEIGHT_CORRELATED = this._useSmithVisibilityHeightCorrelated,
- e.MS_BRDF_ENERGY_CONSERVATION = this._useEnergyConservation && this._useSmithVisibilityHeightCorrelated,
- e.SPHERICAL_HARMONICS = this._useSphericalHarmonics,
- e.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION = this._useSpecularGlossinessInputEnergyConservation
- }
- ,
- a.prototype.getClassName = function() {
- return "PBRBRDFConfiguration"
- }
- ,
- a.prototype.copyTo = function(e) {
- SerializationHelper.Clone(function() {
- return e
- }, this)
- }
- ,
- a.prototype.serialize = function() {
- return SerializationHelper.Serialize(this)
- }
- ,
- a.prototype.parse = function(e, i, o) {
- var s = this;
- SerializationHelper.Parse(function() {
- return s
- }, e, i, o)
- }
- ,
- a.DEFAULT_USE_ENERGY_CONSERVATION = !0,
- a.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED = !0,
- a.DEFAULT_USE_SPHERICAL_HARMONICS = !0,
- a.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION = !0,
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsMiscDirty")], a.prototype, "useEnergyConservation", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsMiscDirty")], a.prototype, "useSmithVisibilityHeightCorrelated", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsMiscDirty")], a.prototype, "useSphericalHarmonics", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsMiscDirty")], a.prototype, "useSpecularGlossinessInputEnergyConservation", void 0),
- a
- }()
- , PBRSheenConfiguration = function() {
- function a(e) {
- this._isEnabled = !1,
- this.isEnabled = !1,
- this._linkSheenWithAlbedo = !1,
- this.linkSheenWithAlbedo = !1,
- this.intensity = 1,
- this.color = Color3.White(),
- this._texture = null,
- this.texture = null,
- this._useRoughnessFromMainTexture = !0,
- this.useRoughnessFromMainTexture = !0,
- this._roughness = null,
- this.roughness = null,
- this._textureRoughness = null,
- this.textureRoughness = null,
- this._albedoScaling = !1,
- this.albedoScaling = !1,
- this._internalMarkAllSubMeshesAsTexturesDirty = e
- }
- return a.prototype._markAllSubMeshesAsTexturesDirty = function() {
- this._internalMarkAllSubMeshesAsTexturesDirty()
- }
- ,
- a.prototype.isReadyForSubMesh = function(e, i) {
- return this._isEnabled ? !(e._areTexturesDirty && i.texturesEnabled && (this._texture && MaterialFlags.SheenTextureEnabled && !this._texture.isReadyOrNotBlocking() || this._textureRoughness && MaterialFlags.SheenTextureEnabled && !this._textureRoughness.isReadyOrNotBlocking())) : !0
- }
- ,
- a.prototype.prepareDefines = function(e, i) {
- var o;
- this._isEnabled ? (e.SHEEN = this._isEnabled,
- e.SHEEN_LINKWITHALBEDO = this._linkSheenWithAlbedo,
- e.SHEEN_ROUGHNESS = this._roughness !== null,
- e.SHEEN_ALBEDOSCALING = this._albedoScaling,
- e.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE = this._useRoughnessFromMainTexture,
- 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),
- e._areTexturesDirty && i.texturesEnabled && (this._texture && MaterialFlags.SheenTextureEnabled ? (MaterialHelper.PrepareDefinesForMergedUV(this._texture, e, "SHEEN_TEXTURE"),
- e.SHEEN_GAMMATEXTURE = this._texture.gammaSpace) : e.SHEEN_TEXTURE = !1,
- this._textureRoughness && MaterialFlags.SheenTextureEnabled ? MaterialHelper.PrepareDefinesForMergedUV(this._textureRoughness, e, "SHEEN_TEXTURE_ROUGHNESS") : e.SHEEN_TEXTURE_ROUGHNESS = !1)) : (e.SHEEN = !1,
- e.SHEEN_TEXTURE = !1,
- e.SHEEN_TEXTURE_ROUGHNESS = !1,
- e.SHEEN_LINKWITHALBEDO = !1,
- e.SHEEN_ROUGHNESS = !1,
- e.SHEEN_ALBEDOSCALING = !1,
- e.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE = !1,
- e.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL = !1)
- }
- ,
- a.prototype.bindForSubMesh = function(e, i, o, s) {
- var c, d, _, b, k, j, $, _e;
- if (!!this._isEnabled) {
- var et = s.materialDefines
- , tt = et.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL;
- (!e.useUbo || !o || !e.isSync) && (tt && MaterialFlags.SheenTextureEnabled ? (e.updateFloat4("vSheenInfos", this._texture.coordinatesIndex, this._texture.level, -1, -1),
- 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),
- this._texture && MaterialHelper.BindTextureMatrix(this._texture, e, "sheen"),
- this._textureRoughness && !tt && !et.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE && MaterialHelper.BindTextureMatrix(this._textureRoughness, e, "sheenRoughness")),
- e.updateFloat4("vSheenColor", this.color.r, this.color.g, this.color.b, this.intensity),
- this._roughness !== null && e.updateFloat("vSheenRoughness", this._roughness)),
- i.texturesEnabled && (this._texture && MaterialFlags.SheenTextureEnabled && e.setTexture("sheenSampler", this._texture),
- this._textureRoughness && !tt && !et.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE && MaterialFlags.SheenTextureEnabled && e.setTexture("sheenRoughnessSampler", this._textureRoughness))
- }
- }
- ,
- a.prototype.hasTexture = function(e) {
- return this._texture === e || this._textureRoughness === e
- }
- ,
- a.prototype.getActiveTextures = function(e) {
- this._texture && e.push(this._texture),
- this._textureRoughness && e.push(this._textureRoughness)
- }
- ,
- a.prototype.getAnimatables = function(e) {
- this._texture && this._texture.animations && this._texture.animations.length > 0 && e.push(this._texture),
- this._textureRoughness && this._textureRoughness.animations && this._textureRoughness.animations.length > 0 && e.push(this._textureRoughness)
- }
- ,
- a.prototype.dispose = function(e) {
- var i, o;
- e && ((i = this._texture) === null || i === void 0 || i.dispose(),
- (o = this._textureRoughness) === null || o === void 0 || o.dispose())
- }
- ,
- a.prototype.getClassName = function() {
- return "PBRSheenConfiguration"
- }
- ,
- a.AddFallbacks = function(e, i, o) {
- return e.SHEEN && i.addFallback(o++, "SHEEN"),
- o
- }
- ,
- a.AddUniforms = function(e) {
- e.push("vSheenColor", "vSheenRoughness", "vSheenInfos", "sheenMatrix", "sheenRoughnessMatrix")
- }
- ,
- a.PrepareUniformBuffer = function(e) {
- e.addUniform("vSheenColor", 4),
- e.addUniform("vSheenRoughness", 1),
- e.addUniform("vSheenInfos", 4),
- e.addUniform("sheenMatrix", 16),
- e.addUniform("sheenRoughnessMatrix", 16)
- }
- ,
- a.AddSamplers = function(e) {
- e.push("sheenSampler"),
- e.push("sheenRoughnessSampler")
- }
- ,
- a.prototype.copyTo = function(e) {
- SerializationHelper.Clone(function() {
- return e
- }, this)
- }
- ,
- a.prototype.serialize = function() {
- return SerializationHelper.Serialize(this)
- }
- ,
- a.prototype.parse = function(e, i, o) {
- var s = this;
- SerializationHelper.Parse(function() {
- return s
- }, e, i, o)
- }
- ,
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "isEnabled", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "linkSheenWithAlbedo", void 0),
- __decorate([serialize()], a.prototype, "intensity", void 0),
- __decorate([serializeAsColor3()], a.prototype, "color", void 0),
- __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "texture", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "useRoughnessFromMainTexture", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "roughness", void 0),
- __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "textureRoughness", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "albedoScaling", void 0),
- a
- }()
- , PBRSubSurfaceConfiguration = function() {
- function a(e, i, o) {
- this._isRefractionEnabled = !1,
- this.isRefractionEnabled = !1,
- this._isTranslucencyEnabled = !1,
- this.isTranslucencyEnabled = !1,
- this._isScatteringEnabled = !1,
- this.isScatteringEnabled = !1,
- this._scatteringDiffusionProfileIndex = 0,
- this.refractionIntensity = 1,
- this.translucencyIntensity = 1,
- this.useAlbedoToTintRefraction = !1,
- this.useAlbedoToTintTranslucency = !1,
- this._thicknessTexture = null,
- this.thicknessTexture = null,
- this._refractionTexture = null,
- this.refractionTexture = null,
- this._indexOfRefraction = 1.5,
- this.indexOfRefraction = 1.5,
- this._volumeIndexOfRefraction = -1,
- this._invertRefractionY = !1,
- this.invertRefractionY = !1,
- this._linkRefractionWithTransparency = !1,
- this.linkRefractionWithTransparency = !1,
- this.minimumThickness = 0,
- this.maximumThickness = 1,
- this.useThicknessAsDepth = !1,
- this.tintColor = Color3.White(),
- this.tintColorAtDistance = 1,
- this.diffusionDistance = Color3.White(),
- this._useMaskFromThicknessTexture = !1,
- this.useMaskFromThicknessTexture = !1,
- this._refractionIntensityTexture = null,
- this.refractionIntensityTexture = null,
- this._translucencyIntensityTexture = null,
- this.translucencyIntensityTexture = null,
- this._useGltfStyleTextures = !1,
- this.useGltfStyleTextures = !1,
- this._internalMarkAllSubMeshesAsTexturesDirty = e,
- this._internalMarkScenePrePassDirty = i,
- this._scene = o
- }
- return Object.defineProperty(a.prototype, "scatteringDiffusionProfile", {
- get: function() {
- return this._scene.subSurfaceConfiguration ? this._scene.subSurfaceConfiguration.ssDiffusionProfileColors[this._scatteringDiffusionProfileIndex] : null
- },
- set: function(e) {
- !this._scene.enableSubSurfaceForPrePass() || e && (this._scatteringDiffusionProfileIndex = this._scene.subSurfaceConfiguration.addDiffusionProfile(e))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "volumeIndexOfRefraction", {
- get: function() {
- return this._volumeIndexOfRefraction >= 1 ? this._volumeIndexOfRefraction : this._indexOfRefraction
- },
- set: function(e) {
- e >= 1 ? this._volumeIndexOfRefraction = e : this._volumeIndexOfRefraction = -1
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._markAllSubMeshesAsTexturesDirty = function() {
- this._internalMarkAllSubMeshesAsTexturesDirty()
- }
- ,
- a.prototype._markScenePrePassDirty = function() {
- this._internalMarkAllSubMeshesAsTexturesDirty(),
- this._internalMarkScenePrePassDirty()
- }
- ,
- a.prototype.isReadyForSubMesh = function(e, i) {
- if (!this._isRefractionEnabled && !this._isTranslucencyEnabled && !this._isScatteringEnabled)
- return !0;
- if (e._areTexturesDirty && i.texturesEnabled) {
- if (this._thicknessTexture && MaterialFlags.ThicknessTextureEnabled && !this._thicknessTexture.isReadyOrNotBlocking())
- return !1;
- var o = this._getRefractionTexture(i);
- if (o && MaterialFlags.RefractionTextureEnabled && !o.isReadyOrNotBlocking())
- return !1
- }
- return !0
- }
- ,
- a.prototype.prepareDefines = function(e, i) {
- if (!this._isRefractionEnabled && !this._isTranslucencyEnabled && !this._isScatteringEnabled) {
- e.SUBSURFACE = !1,
- e.SS_TRANSLUCENCY = !1,
- e.SS_SCATTERING = !1,
- e.SS_REFRACTION = !1;
- return
- }
- if (e._areTexturesDirty) {
- if (e.SUBSURFACE = !1,
- e.SS_TRANSLUCENCY = this._isTranslucencyEnabled,
- e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_TEXTURE = !1,
- e.SS_SCATTERING = this._isScatteringEnabled,
- e.SS_THICKNESSANDMASK_TEXTURE = !1,
- e.SS_REFRACTIONINTENSITY_TEXTURE = !1,
- e.SS_TRANSLUCENCYINTENSITY_TEXTURE = !1,
- e.SS_HAS_THICKNESS = !1,
- e.SS_MASK_FROM_THICKNESS_TEXTURE = !1,
- e.SS_USE_GLTF_TEXTURES = !1,
- e.SS_REFRACTION = !1,
- e.SS_REFRACTION_USE_INTENSITY_FROM_TEXTURE = !1,
- e.SS_REFRACTIONMAP_3D = !1,
- e.SS_GAMMAREFRACTION = !1,
- e.SS_RGBDREFRACTION = !1,
- e.SS_LINEARSPECULARREFRACTION = !1,
- e.SS_REFRACTIONMAP_OPPOSITEZ = !1,
- e.SS_LODINREFRACTIONALPHA = !1,
- e.SS_LINKREFRACTIONTOTRANSPARENCY = !1,
- e.SS_ALBEDOFORREFRACTIONTINT = !1,
- e.SS_ALBEDOFORTRANSLUCENCYTINT = !1,
- e.SS_USE_LOCAL_REFRACTIONMAP_CUBIC = !1,
- e.SS_USE_THICKNESS_AS_DEPTH = !1,
- this._isRefractionEnabled || this._isTranslucencyEnabled || this._isScatteringEnabled) {
- e.SUBSURFACE = !0;
- var o = !!this._thicknessTexture && !!this._refractionIntensityTexture && this._refractionIntensityTexture.checkTransformsAreIdentical(this._thicknessTexture) && this._refractionIntensityTexture._texture === this._thicknessTexture._texture
- , s = !!this._thicknessTexture && !!this._translucencyIntensityTexture && this._translucencyIntensityTexture.checkTransformsAreIdentical(this._thicknessTexture) && this._translucencyIntensityTexture._texture === this._thicknessTexture._texture
- , c = (o || !this._refractionIntensityTexture) && (s || !this._translucencyIntensityTexture);
- e._areTexturesDirty && i.texturesEnabled && (this._thicknessTexture && MaterialFlags.ThicknessTextureEnabled && MaterialHelper.PrepareDefinesForMergedUV(this._thicknessTexture, e, "SS_THICKNESSANDMASK_TEXTURE"),
- this._refractionIntensityTexture && MaterialFlags.RefractionIntensityTextureEnabled && !c && MaterialHelper.PrepareDefinesForMergedUV(this._refractionIntensityTexture, e, "SS_REFRACTIONINTENSITY_TEXTURE"),
- this._translucencyIntensityTexture && MaterialFlags.TranslucencyIntensityTextureEnabled && !c && MaterialHelper.PrepareDefinesForMergedUV(this._translucencyIntensityTexture, e, "SS_TRANSLUCENCYINTENSITY_TEXTURE")),
- e.SS_HAS_THICKNESS = this.maximumThickness - this.minimumThickness !== 0,
- e.SS_MASK_FROM_THICKNESS_TEXTURE = (this._useMaskFromThicknessTexture || !!this._refractionIntensityTexture || !!this._translucencyIntensityTexture) && c,
- e.SS_USE_GLTF_TEXTURES = this._useGltfStyleTextures,
- e.SS_REFRACTION_USE_INTENSITY_FROM_TEXTURE = (this._useMaskFromThicknessTexture || !!this._refractionIntensityTexture) && c,
- e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_TEXTURE = (this._useMaskFromThicknessTexture || !!this._translucencyIntensityTexture) && c
- }
- if (this._isRefractionEnabled && i.texturesEnabled) {
- var d = this._getRefractionTexture(i);
- d && MaterialFlags.RefractionTextureEnabled && (e.SS_REFRACTION = !0,
- e.SS_REFRACTIONMAP_3D = d.isCube,
- e.SS_GAMMAREFRACTION = d.gammaSpace,
- e.SS_RGBDREFRACTION = d.isRGBD,
- e.SS_LINEARSPECULARREFRACTION = d.linearSpecularLOD,
- e.SS_REFRACTIONMAP_OPPOSITEZ = d.invertZ,
- e.SS_LODINREFRACTIONALPHA = d.lodLevelInAlpha,
- e.SS_LINKREFRACTIONTOTRANSPARENCY = this._linkRefractionWithTransparency,
- e.SS_ALBEDOFORREFRACTIONTINT = this.useAlbedoToTintRefraction,
- e.SS_USE_LOCAL_REFRACTIONMAP_CUBIC = d.isCube && d.boundingBoxSize,
- e.SS_USE_THICKNESS_AS_DEPTH = this.useThicknessAsDepth)
- }
- this._isTranslucencyEnabled && (e.SS_ALBEDOFORTRANSLUCENCYTINT = this.useAlbedoToTintTranslucency)
- }
- }
- ,
- a.prototype.hardBindForSubMesh = function(e, i, o, s, c, d, _) {
- if (!(!this._isRefractionEnabled && !this._isTranslucencyEnabled && !this._isScatteringEnabled)) {
- _.getRenderingMesh().getWorldMatrix().decompose(TmpVectors.Vector3[0]);
- var b = Math.max(Math.abs(TmpVectors.Vector3[0].x), Math.abs(TmpVectors.Vector3[0].y), Math.abs(TmpVectors.Vector3[0].z));
- e.updateFloat2("vThicknessParam", this.minimumThickness * b, (this.maximumThickness - this.minimumThickness) * b)
- }
- }
- ,
- a.prototype.bindForSubMesh = function(e, i, o, s, c, d, _) {
- if (!(!this._isRefractionEnabled && !this._isTranslucencyEnabled && !this._isScatteringEnabled)) {
- var b = _.materialDefines
- , k = this._getRefractionTexture(i);
- if (!e.useUbo || !s || !e.isSync) {
- if (this._thicknessTexture && MaterialFlags.ThicknessTextureEnabled && (e.updateFloat2("vThicknessInfos", this._thicknessTexture.coordinatesIndex, this._thicknessTexture.level),
- MaterialHelper.BindTextureMatrix(this._thicknessTexture, e, "thickness")),
- this._refractionIntensityTexture && MaterialFlags.RefractionIntensityTextureEnabled && b.SS_REFRACTIONINTENSITY_TEXTURE && (e.updateFloat2("vRefractionIntensityInfos", this._refractionIntensityTexture.coordinatesIndex, this._refractionIntensityTexture.level),
- MaterialHelper.BindTextureMatrix(this._refractionIntensityTexture, e, "refractionIntensity")),
- this._translucencyIntensityTexture && MaterialFlags.TranslucencyIntensityTextureEnabled && b.SS_TRANSLUCENCYINTENSITY_TEXTURE && (e.updateFloat2("vTranslucencyIntensityInfos", this._translucencyIntensityTexture.coordinatesIndex, this._translucencyIntensityTexture.level),
- MaterialHelper.BindTextureMatrix(this._translucencyIntensityTexture, e, "translucencyIntensity")),
- k && MaterialFlags.RefractionTextureEnabled) {
- e.updateMatrix("refractionMatrix", k.getReflectionTextureMatrix());
- var j = 1;
- k.isCube || k.depth && (j = k.depth);
- var $ = k.getSize().width
- , _e = this.volumeIndexOfRefraction;
- if (e.updateFloat4("vRefractionInfos", k.level, 1 / _e, j, this._invertRefractionY ? -1 : 1),
- e.updateFloat4("vRefractionMicrosurfaceInfos", $, k.lodGenerationScale, k.lodGenerationOffset, 1 / this.indexOfRefraction),
- d && e.updateFloat2("vRefractionFilteringInfo", $, Scalar.Log2($)),
- k.boundingBoxSize) {
- var et = k;
- e.updateVector3("vRefractionPosition", et.boundingBoxPosition),
- e.updateVector3("vRefractionSize", et.boundingBoxSize)
- }
- }
- this.isScatteringEnabled && e.updateFloat("scatteringDiffusionProfile", this._scatteringDiffusionProfileIndex),
- e.updateColor3("vDiffusionDistance", this.diffusionDistance),
- e.updateFloat4("vTintColor", this.tintColor.r, this.tintColor.g, this.tintColor.b, Math.max(1e-5, this.tintColorAtDistance)),
- e.updateFloat3("vSubSurfaceIntensity", this.refractionIntensity, this.translucencyIntensity, 0)
- }
- i.texturesEnabled && (this._thicknessTexture && MaterialFlags.ThicknessTextureEnabled && e.setTexture("thicknessSampler", this._thicknessTexture),
- this._refractionIntensityTexture && MaterialFlags.RefractionIntensityTextureEnabled && b.SS_REFRACTIONINTENSITY_TEXTURE && e.setTexture("refractionIntensitySampler", this._refractionIntensityTexture),
- this._translucencyIntensityTexture && MaterialFlags.TranslucencyIntensityTextureEnabled && b.SS_TRANSLUCENCYINTENSITY_TEXTURE && e.setTexture("translucencyIntensitySampler", this._translucencyIntensityTexture),
- k && MaterialFlags.RefractionTextureEnabled && (c ? e.setTexture("refractionSampler", k) : (e.setTexture("refractionSampler", k._lodTextureMid || k),
- e.setTexture("refractionSamplerLow", k._lodTextureLow || k),
- e.setTexture("refractionSamplerHigh", k._lodTextureHigh || k))))
- }
- }
- ,
- a.prototype.unbind = function(e) {
- return this._refractionTexture && this._refractionTexture.isRenderTarget ? (e.setTexture("refractionSampler", null),
- !0) : !1
- }
- ,
- a.prototype._getRefractionTexture = function(e) {
- return this._refractionTexture ? this._refractionTexture : this._isRefractionEnabled ? e.environmentTexture : null
- }
- ,
- Object.defineProperty(a.prototype, "disableAlphaBlending", {
- get: function() {
- return this.isRefractionEnabled && this._linkRefractionWithTransparency
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.fillRenderTargetTextures = function(e) {
- MaterialFlags.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget && e.push(this._refractionTexture)
- }
- ,
- a.prototype.hasTexture = function(e) {
- return this._thicknessTexture === e || this._refractionTexture === e
- }
- ,
- a.prototype.hasRenderTargetTextures = function() {
- return !!(MaterialFlags.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget)
- }
- ,
- a.prototype.getActiveTextures = function(e) {
- this._thicknessTexture && e.push(this._thicknessTexture),
- this._refractionTexture && e.push(this._refractionTexture)
- }
- ,
- a.prototype.getAnimatables = function(e) {
- this._thicknessTexture && this._thicknessTexture.animations && this._thicknessTexture.animations.length > 0 && e.push(this._thicknessTexture),
- this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0 && e.push(this._refractionTexture)
- }
- ,
- a.prototype.dispose = function(e) {
- e && (this._thicknessTexture && this._thicknessTexture.dispose(),
- this._refractionTexture && this._refractionTexture.dispose())
- }
- ,
- a.prototype.getClassName = function() {
- return "PBRSubSurfaceConfiguration"
- }
- ,
- a.AddFallbacks = function(e, i, o) {
- return e.SS_SCATTERING && i.addFallback(o++, "SS_SCATTERING"),
- e.SS_TRANSLUCENCY && i.addFallback(o++, "SS_TRANSLUCENCY"),
- o
- }
- ,
- a.AddUniforms = function(e) {
- e.push("vDiffusionDistance", "vTintColor", "vSubSurfaceIntensity", "vRefractionMicrosurfaceInfos", "vRefractionFilteringInfo", "vRefractionInfos", "vThicknessInfos", "vRefractionIntensityInfos", "vTranslucencyIntensityInfos", "vThicknessParam", "vRefractionPosition", "vRefractionSize", "refractionMatrix", "thicknessMatrix", "refractionIntensityMatrix", "translucencyIntensityMatrix", "scatteringDiffusionProfile")
- }
- ,
- a.AddSamplers = function(e) {
- e.push("thicknessSampler", "refractionIntensitySampler", "translucencyIntensitySampler", "refractionSampler", "refractionSamplerLow", "refractionSamplerHigh")
- }
- ,
- a.PrepareUniformBuffer = function(e) {
- e.addUniform("vRefractionMicrosurfaceInfos", 4),
- e.addUniform("vRefractionFilteringInfo", 2),
- e.addUniform("vTranslucencyIntensityInfos", 2),
- e.addUniform("vRefractionInfos", 4),
- e.addUniform("refractionMatrix", 16),
- e.addUniform("vThicknessInfos", 2),
- e.addUniform("vRefractionIntensityInfos", 2),
- e.addUniform("thicknessMatrix", 16),
- e.addUniform("refractionIntensityMatrix", 16),
- e.addUniform("translucencyIntensityMatrix", 16),
- e.addUniform("vThicknessParam", 2),
- e.addUniform("vDiffusionDistance", 3),
- e.addUniform("vTintColor", 4),
- e.addUniform("vSubSurfaceIntensity", 3),
- e.addUniform("vRefractionPosition", 3),
- e.addUniform("vRefractionSize", 3),
- e.addUniform("scatteringDiffusionProfile", 1)
- }
- ,
- a.prototype.copyTo = function(e) {
- SerializationHelper.Clone(function() {
- return e
- }, this)
- }
- ,
- a.prototype.serialize = function() {
- return SerializationHelper.Serialize(this)
- }
- ,
- a.prototype.parse = function(e, i, o) {
- var s = this;
- SerializationHelper.Parse(function() {
- return s
- }, e, i, o)
- }
- ,
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "isRefractionEnabled", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "isTranslucencyEnabled", void 0),
- __decorate([serialize(), expandToProperty("_markScenePrePassDirty")], a.prototype, "isScatteringEnabled", void 0),
- __decorate([serialize()], a.prototype, "_scatteringDiffusionProfileIndex", void 0),
- __decorate([serialize()], a.prototype, "refractionIntensity", void 0),
- __decorate([serialize()], a.prototype, "translucencyIntensity", void 0),
- __decorate([serialize()], a.prototype, "useAlbedoToTintRefraction", void 0),
- __decorate([serialize()], a.prototype, "useAlbedoToTintTranslucency", void 0),
- __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "thicknessTexture", void 0),
- __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "refractionTexture", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "indexOfRefraction", void 0),
- __decorate([serialize()], a.prototype, "_volumeIndexOfRefraction", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "volumeIndexOfRefraction", null),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "invertRefractionY", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "linkRefractionWithTransparency", void 0),
- __decorate([serialize()], a.prototype, "minimumThickness", void 0),
- __decorate([serialize()], a.prototype, "maximumThickness", void 0),
- __decorate([serialize()], a.prototype, "useThicknessAsDepth", void 0),
- __decorate([serializeAsColor3()], a.prototype, "tintColor", void 0),
- __decorate([serialize()], a.prototype, "tintColorAtDistance", void 0),
- __decorate([serializeAsColor3()], a.prototype, "diffusionDistance", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "useMaskFromThicknessTexture", void 0),
- __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "refractionIntensityTexture", void 0),
- __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "translucencyIntensityTexture", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], a.prototype, "useGltfStyleTextures", void 0),
- a
- }()
- , name$1e = "pbrFragmentDeclaration"
- , shader$1e = `uniform vec4 vEyePosition;
- uniform vec3 vReflectionColor;
- uniform vec4 vAlbedoColor;
- uniform vec4 vLightingIntensity;
- uniform vec4 vReflectivityColor;
- uniform vec4 vMetallicReflectanceFactors;
- uniform vec3 vEmissiveColor;
- uniform float visibility;
- uniform vec3 vAmbientColor;
- #ifdef ALBEDO
- uniform vec2 vAlbedoInfos;
- #endif
- #ifdef AMBIENT
- uniform vec4 vAmbientInfos;
- #endif
- #ifdef BUMP
- uniform vec3 vBumpInfos;
- uniform vec2 vTangentSpaceParams;
- #endif
- #ifdef OPACITY
- uniform vec2 vOpacityInfos;
- #endif
- #ifdef EMISSIVE
- uniform vec2 vEmissiveInfos;
- #endif
- #ifdef LIGHTMAP
- uniform vec2 vLightmapInfos;
- #endif
- #ifdef REFLECTIVITY
- uniform vec3 vReflectivityInfos;
- #endif
- #ifdef MICROSURFACEMAP
- uniform vec2 vMicroSurfaceSamplerInfos;
- #endif
- #if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(SS_REFRACTION) || defined(PREPASS)
- uniform mat4 view;
- #endif
- #ifdef REFLECTION
- uniform vec2 vReflectionInfos;
- #ifdef REALTIME_FILTERING
- uniform vec2 vReflectionFilteringInfo;
- #endif
- uniform mat4 reflectionMatrix;
- uniform vec3 vReflectionMicrosurfaceInfos;
- #if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)
- uniform vec3 vReflectionPosition;
- uniform vec3 vReflectionSize;
- #endif
- #endif
- #if defined(SS_REFRACTION) && defined(SS_USE_LOCAL_REFRACTIONMAP_CUBIC)
- uniform vec3 vRefractionPosition;
- uniform vec3 vRefractionSize;
- #endif
- #ifdef CLEARCOAT
- uniform vec2 vClearCoatParams;
- uniform vec4 vClearCoatRefractionParams;
- #if defined(CLEARCOAT_TEXTURE) || defined(CLEARCOAT_TEXTURE_ROUGHNESS)
- uniform vec4 vClearCoatInfos;
- #endif
- #ifdef CLEARCOAT_TEXTURE
- uniform mat4 clearCoatMatrix;
- #endif
- #ifdef CLEARCOAT_TEXTURE_ROUGHNESS
- uniform mat4 clearCoatRoughnessMatrix;
- #endif
- #ifdef CLEARCOAT_BUMP
- uniform vec2 vClearCoatBumpInfos;
- uniform vec2 vClearCoatTangentSpaceParams;
- uniform mat4 clearCoatBumpMatrix;
- #endif
- #ifdef CLEARCOAT_TINT
- uniform vec4 vClearCoatTintParams;
- uniform float clearCoatColorAtDistance;
- #ifdef CLEARCOAT_TINT_TEXTURE
- uniform vec2 vClearCoatTintInfos;
- uniform mat4 clearCoatTintMatrix;
- #endif
- #endif
- #endif
- #ifdef ANISOTROPIC
- uniform vec3 vAnisotropy;
- #ifdef ANISOTROPIC_TEXTURE
- uniform vec2 vAnisotropyInfos;
- uniform mat4 anisotropyMatrix;
- #endif
- #endif
- #ifdef SHEEN
- uniform vec4 vSheenColor;
- #ifdef SHEEN_ROUGHNESS
- uniform float vSheenRoughness;
- #endif
- #if defined(SHEEN_TEXTURE) || defined(SHEEN_TEXTURE_ROUGHNESS)
- uniform vec4 vSheenInfos;
- #endif
- #ifdef SHEEN_TEXTURE
- uniform mat4 sheenMatrix;
- #endif
- #ifdef SHEEN_TEXTURE_ROUGHNESS
- uniform mat4 sheenRoughnessMatrix;
- #endif
- #endif
- #ifdef SUBSURFACE
- #ifdef SS_REFRACTION
- uniform vec4 vRefractionMicrosurfaceInfos;
- uniform vec4 vRefractionInfos;
- uniform mat4 refractionMatrix;
- #ifdef REALTIME_FILTERING
- uniform vec2 vRefractionFilteringInfo;
- #endif
- #endif
- #ifdef SS_THICKNESSANDMASK_TEXTURE
- uniform vec2 vThicknessInfos;
- uniform mat4 thicknessMatrix;
- #endif
- #ifdef SS_REFRACTIONINTENSITY_TEXTURE
- uniform vec2 vRefractionIntensityInfos;
- uniform mat4 refractionIntensityMatrix;
- #endif
- #ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
- uniform vec2 vTranslucencyIntensityInfos;
- uniform mat4 translucencyIntensityMatrix;
- #endif
- uniform vec2 vThicknessParam;
- uniform vec3 vDiffusionDistance;
- uniform vec4 vTintColor;
- uniform vec3 vSubSurfaceIntensity;
- #endif
- #ifdef PREPASS
- #ifdef SS_SCATTERING
- uniform float scatteringDiffusionProfile;
- #endif
- #endif
- #if DEBUGMODE>0
- uniform vec2 vDebugMode;
- #endif
- #ifdef DETAIL
- uniform vec4 vDetailInfos;
- #endif
- #ifdef USESPHERICALFROMREFLECTIONMAP
- #ifdef SPHERICAL_HARMONICS
- uniform vec3 vSphericalL00;
- uniform vec3 vSphericalL1_1;
- uniform vec3 vSphericalL10;
- uniform vec3 vSphericalL11;
- uniform vec3 vSphericalL2_2;
- uniform vec3 vSphericalL2_1;
- uniform vec3 vSphericalL20;
- uniform vec3 vSphericalL21;
- uniform vec3 vSphericalL22;
- #else
- uniform vec3 vSphericalX;
- uniform vec3 vSphericalY;
- uniform vec3 vSphericalZ;
- uniform vec3 vSphericalXX_ZZ;
- uniform vec3 vSphericalYY_ZZ;
- uniform vec3 vSphericalZZ;
- uniform vec3 vSphericalXY;
- uniform vec3 vSphericalYZ;
- uniform vec3 vSphericalZX;
- #endif
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$1e] = shader$1e;
- var name$1d = "pbrUboDeclaration"
- , shader$1d = `layout(std140,column_major) uniform;
- uniform Material {
- vec2 vAlbedoInfos;
- vec4 vAmbientInfos;
- vec2 vOpacityInfos;
- vec2 vEmissiveInfos;
- vec2 vLightmapInfos;
- vec3 vReflectivityInfos;
- vec2 vMicroSurfaceSamplerInfos;
- vec2 vReflectionInfos;
- vec2 vReflectionFilteringInfo;
- vec3 vReflectionPosition;
- vec3 vReflectionSize;
- vec3 vBumpInfos;
- mat4 albedoMatrix;
- mat4 ambientMatrix;
- mat4 opacityMatrix;
- mat4 emissiveMatrix;
- mat4 lightmapMatrix;
- mat4 reflectivityMatrix;
- mat4 microSurfaceSamplerMatrix;
- mat4 bumpMatrix;
- vec2 vTangentSpaceParams;
- mat4 reflectionMatrix;
- vec3 vReflectionColor;
- vec4 vAlbedoColor;
- vec4 vLightingIntensity;
- vec3 vReflectionMicrosurfaceInfos;
- float pointSize;
- vec4 vReflectivityColor;
- vec3 vEmissiveColor;
- vec3 vAmbientColor;
- vec2 vDebugMode;
- vec4 vMetallicReflectanceFactors;
- vec2 vMetallicReflectanceInfos;
- mat4 metallicReflectanceMatrix;
- vec2 vReflectanceInfos;
- mat4 reflectanceMatrix;
- vec2 vClearCoatParams;
- vec4 vClearCoatRefractionParams;
- vec4 vClearCoatInfos;
- mat4 clearCoatMatrix;
- mat4 clearCoatRoughnessMatrix;
- vec2 vClearCoatBumpInfos;
- vec2 vClearCoatTangentSpaceParams;
- mat4 clearCoatBumpMatrix;
- vec4 vClearCoatTintParams;
- float clearCoatColorAtDistance;
- vec2 vClearCoatTintInfos;
- mat4 clearCoatTintMatrix;
- vec3 vAnisotropy;
- vec2 vAnisotropyInfos;
- mat4 anisotropyMatrix;
- vec4 vSheenColor;
- float vSheenRoughness;
- vec4 vSheenInfos;
- mat4 sheenMatrix;
- mat4 sheenRoughnessMatrix;
- vec4 vRefractionMicrosurfaceInfos;
- vec2 vRefractionFilteringInfo;
- vec2 vTranslucencyIntensityInfos;
- vec4 vRefractionInfos;
- mat4 refractionMatrix;
- vec2 vThicknessInfos;
- vec2 vRefractionIntensityInfos;
- mat4 thicknessMatrix;
- mat4 refractionIntensityMatrix;
- mat4 translucencyIntensityMatrix;
- vec2 vThicknessParam;
- vec3 vDiffusionDistance;
- vec4 vTintColor;
- vec3 vSubSurfaceIntensity;
- vec3 vRefractionPosition;
- vec3 vRefractionSize;
- float scatteringDiffusionProfile;
- vec4 vDetailInfos;
- mat4 detailMatrix;
- vec3 vSphericalL00;
- vec3 vSphericalL1_1;
- vec3 vSphericalL10;
- vec3 vSphericalL11;
- vec3 vSphericalL2_2;
- vec3 vSphericalL2_1;
- vec3 vSphericalL20;
- vec3 vSphericalL21;
- vec3 vSphericalL22;
- vec3 vSphericalX;
- vec3 vSphericalY;
- vec3 vSphericalZ;
- vec3 vSphericalXX_ZZ;
- vec3 vSphericalYY_ZZ;
- vec3 vSphericalZZ;
- vec3 vSphericalXY;
- vec3 vSphericalYZ;
- vec3 vSphericalZX;
- };
- #include<sceneUboDeclaration>
- #include<meshUboDeclaration>
- `;
- ShaderStore.IncludesShadersStore[name$1d] = shader$1d;
- var name$1c = "pbrFragmentExtraDeclaration"
- , shader$1c = `
- varying vec3 vPositionW;
- #if DEBUGMODE>0
- varying vec4 vClipSpacePosition;
- #endif
- #include<mainUVVaryingDeclaration>[1..7]
- #ifdef NORMAL
- varying vec3 vNormalW;
- #if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
- varying vec3 vEnvironmentIrradiance;
- #endif
- #endif
- #ifdef VERTEXCOLOR
- varying vec4 vColor;
- #endif`;
- ShaderStore.IncludesShadersStore[name$1c] = shader$1c;
- var name$1b = "samplerFragmentAlternateDeclaration"
- , shader$1b = `#ifdef _DEFINENAME_
- #if _DEFINENAME_DIRECTUV == 1
- #define v_VARYINGNAME_UV vMainUV1
- #elif _DEFINENAME_DIRECTUV == 2
- #define v_VARYINGNAME_UV vMainUV2
- #elif _DEFINENAME_DIRECTUV == 3
- #define v_VARYINGNAME_UV vMainUV3
- #elif _DEFINENAME_DIRECTUV == 4
- #define v_VARYINGNAME_UV vMainUV4
- #elif _DEFINENAME_DIRECTUV == 5
- #define v_VARYINGNAME_UV vMainUV5
- #elif _DEFINENAME_DIRECTUV == 6
- #define v_VARYINGNAME_UV vMainUV6
- #else
- varying vec2 v_VARYINGNAME_UV;
- #endif
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$1b] = shader$1b;
- var name$1a = "pbrFragmentSamplersDeclaration"
- , shader$1a = `#include<samplerFragmentDeclaration>(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo,_SAMPLERNAME_,albedo)
- #include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient)
- #include<samplerFragmentDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity)
- #include<samplerFragmentDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive)
- #include<samplerFragmentDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap)
- #include<samplerFragmentDeclaration>(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity,_SAMPLERNAME_,reflectivity)
- #include<samplerFragmentDeclaration>(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler,_SAMPLERNAME_,microSurface)
- #include<samplerFragmentDeclaration>(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance,_SAMPLERNAME_,metallicReflectance)
- #include<samplerFragmentDeclaration>(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance,_SAMPLERNAME_,reflectance)
- #ifdef CLEARCOAT
- #include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat,_SAMPLERNAME_,clearCoat)
- #include<samplerFragmentAlternateDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness)
- #if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL)
- uniform sampler2D clearCoatRoughnessSampler;
- #endif
- #include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump,_SAMPLERNAME_,clearCoatBump)
- #include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint,_SAMPLERNAME_,clearCoatTint)
- #endif
- #ifdef SHEEN
- #include<samplerFragmentDeclaration>(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen,_SAMPLERNAME_,sheen)
- #include<samplerFragmentAlternateDeclaration>(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness)
- #if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL)
- uniform sampler2D sheenRoughnessSampler;
- #endif
- #endif
- #ifdef ANISOTROPIC
- #include<samplerFragmentDeclaration>(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy,_SAMPLERNAME_,anisotropy)
- #endif
- #ifdef REFLECTION
- #ifdef REFLECTIONMAP_3D
- #define sampleReflection(s,c) textureCube(s,c)
- uniform samplerCube reflectionSampler;
- #ifdef LODBASEDMICROSFURACE
- #define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)
- #else
- uniform samplerCube reflectionSamplerLow;
- uniform samplerCube reflectionSamplerHigh;
- #endif
- #ifdef USEIRRADIANCEMAP
- uniform samplerCube irradianceSampler;
- #endif
- #else
- #define sampleReflection(s,c) texture2D(s,c)
- uniform sampler2D reflectionSampler;
- #ifdef LODBASEDMICROSFURACE
- #define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)
- #else
- uniform sampler2D reflectionSamplerLow;
- uniform sampler2D reflectionSamplerHigh;
- #endif
- #ifdef USEIRRADIANCEMAP
- uniform sampler2D irradianceSampler;
- #endif
- #endif
- #ifdef REFLECTIONMAP_SKYBOX
- varying vec3 vPositionUVW;
- #else
- #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
- varying vec3 vDirectionW;
- #endif
- #endif
- #endif
- #ifdef ENVIRONMENTBRDF
- uniform sampler2D environmentBrdfSampler;
- #endif
- #ifdef SUBSURFACE
- #ifdef SS_REFRACTION
- #ifdef SS_REFRACTIONMAP_3D
- #define sampleRefraction(s,c) textureCube(s,c)
- uniform samplerCube refractionSampler;
- #ifdef LODBASEDMICROSFURACE
- #define sampleRefractionLod(s,c,l) textureCubeLodEXT(s,c,l)
- #else
- uniform samplerCube refractionSamplerLow;
- uniform samplerCube refractionSamplerHigh;
- #endif
- #else
- #define sampleRefraction(s,c) texture2D(s,c)
- uniform sampler2D refractionSampler;
- #ifdef LODBASEDMICROSFURACE
- #define sampleRefractionLod(s,c,l) texture2DLodEXT(s,c,l)
- #else
- uniform sampler2D refractionSamplerLow;
- uniform sampler2D refractionSamplerHigh;
- #endif
- #endif
- #endif
- #include<samplerFragmentDeclaration>(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness,_SAMPLERNAME_,thickness)
- #include<samplerFragmentDeclaration>(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity,_SAMPLERNAME_,refractionIntensity)
- #include<samplerFragmentDeclaration>(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity,_SAMPLERNAME_,translucencyIntensity)
- #endif`;
- ShaderStore.IncludesShadersStore[name$1a] = shader$1a;
- var name$19 = "subSurfaceScatteringFunctions"
- , shader$19 = `bool testLightingForSSS(float diffusionProfile)
- {
- return diffusionProfile<1.;
- }`;
- ShaderStore.IncludesShadersStore[name$19] = shader$19;
- var name$18 = "importanceSampling"
- , shader$18 = `
- vec3 hemisphereCosSample(vec2 u) {
- float phi=2.*PI*u.x;
- float cosTheta2=1.-u.y;
- float cosTheta=sqrt(cosTheta2);
- float sinTheta=sqrt(1.-cosTheta2);
- return vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);
- }
- vec3 hemisphereImportanceSampleDggx(vec2 u,float a) {
- float phi=2.*PI*u.x;
- float cosTheta2=(1.-u.y)/(1.+(a+1.)*((a-1.)*u.y));
- float cosTheta=sqrt(cosTheta2);
- float sinTheta=sqrt(1.-cosTheta2);
- return vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);
- }
- vec3 hemisphereImportanceSampleDCharlie(vec2 u,float a) {
- float phi=2.*PI*u.x;
- float sinTheta=pow(u.y,a/(2.*a+1.));
- float cosTheta=sqrt(1.-sinTheta*sinTheta);
- return vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);
- }`;
- ShaderStore.IncludesShadersStore[name$18] = shader$18;
- var name$17 = "pbrHelperFunctions"
- , shader$17 = `
- #define RECIPROCAL_PI2 0.15915494
- #define RECIPROCAL_PI 0.31830988618
- #define MINIMUMVARIANCE 0.0005
- float convertRoughnessToAverageSlope(float roughness)
- {
- return square(roughness)+MINIMUMVARIANCE;
- }
- float fresnelGrazingReflectance(float reflectance0) {
- float reflectance90=saturate(reflectance0*25.0);
- return reflectance90;
- }
- vec2 getAARoughnessFactors(vec3 normalVector) {
- #ifdef SPECULARAA
- vec3 nDfdx=dFdx(normalVector.xyz);
- vec3 nDfdy=dFdy(normalVector.xyz);
- float slopeSquare=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy));
- float geometricRoughnessFactor=pow(saturate(slopeSquare),0.333);
- float geometricAlphaGFactor=sqrt(slopeSquare);
- geometricAlphaGFactor*=0.75;
- return vec2(geometricRoughnessFactor,geometricAlphaGFactor);
- #else
- return vec2(0.);
- #endif
- }
- #ifdef ANISOTROPIC
- vec2 getAnisotropicRoughness(float alphaG,float anisotropy) {
- float alphaT=max(alphaG*(1.0+anisotropy),MINIMUMVARIANCE);
- float alphaB=max(alphaG*(1.0-anisotropy),MINIMUMVARIANCE);
- return vec2(alphaT,alphaB);
- }
- vec3 getAnisotropicBentNormals(const vec3 T,const vec3 B,const vec3 N,const vec3 V,float anisotropy) {
- vec3 anisotropicFrameDirection=anisotropy>=0.0 ? B : T;
- vec3 anisotropicFrameTangent=cross(normalize(anisotropicFrameDirection),V);
- vec3 anisotropicFrameNormal=cross(anisotropicFrameTangent,anisotropicFrameDirection);
- vec3 anisotropicNormal=normalize(mix(N,anisotropicFrameNormal,abs(anisotropy)));
- return anisotropicNormal;
- }
- #endif
- #if defined(CLEARCOAT) || defined(SS_REFRACTION)
- vec3 cocaLambert(vec3 alpha,float distance) {
- return exp(-alpha*distance);
- }
- vec3 cocaLambert(float NdotVRefract,float NdotLRefract,vec3 alpha,float thickness) {
- return cocaLambert(alpha,(thickness*((NdotLRefract+NdotVRefract)/(NdotLRefract*NdotVRefract))));
- }
- vec3 computeColorAtDistanceInMedia(vec3 color,float distance) {
- return -log(color)/distance;
- }
- vec3 computeClearCoatAbsorption(float NdotVRefract,float NdotLRefract,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {
- vec3 clearCoatAbsorption=mix(vec3(1.0),
- cocaLambert(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness),
- clearCoatIntensity);
- return clearCoatAbsorption;
- }
- #endif
- #ifdef MICROSURFACEAUTOMATIC
- float computeDefaultMicroSurface(float microSurface,vec3 reflectivityColor)
- {
- const float kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95;
- float reflectivityLuminance=getLuminance(reflectivityColor);
- float reflectivityLuma=sqrt(reflectivityLuminance);
- microSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;
- return microSurface;
- }
- #endif`;
- ShaderStore.IncludesShadersStore[name$17] = shader$17;
- var name$16 = "harmonicsFunctions"
- , shader$16 = `#ifdef USESPHERICALFROMREFLECTIONMAP
- #ifdef SPHERICAL_HARMONICS
- vec3 computeEnvironmentIrradiance(vec3 normal) {
- return vSphericalL00
- +vSphericalL1_1*(normal.y)
- +vSphericalL10*(normal.z)
- +vSphericalL11*(normal.x)
- +vSphericalL2_2*(normal.y*normal.x)
- +vSphericalL2_1*(normal.y*normal.z)
- +vSphericalL20*((3.0*normal.z*normal.z)-1.0)
- +vSphericalL21*(normal.z*normal.x)
- +vSphericalL22*(normal.x*normal.x-(normal.y*normal.y));
- }
- #else
- vec3 computeEnvironmentIrradiance(vec3 normal) {
- float Nx=normal.x;
- float Ny=normal.y;
- float Nz=normal.z;
- vec3 C1=vSphericalZZ.rgb;
- vec3 Cx=vSphericalX.rgb;
- vec3 Cy=vSphericalY.rgb;
- vec3 Cz=vSphericalZ.rgb;
- vec3 Cxx_zz=vSphericalXX_ZZ.rgb;
- vec3 Cyy_zz=vSphericalYY_ZZ.rgb;
- vec3 Cxy=vSphericalXY.rgb;
- vec3 Cyz=vSphericalYZ.rgb;
- vec3 Czx=vSphericalZX.rgb;
- vec3 a1=Cyy_zz*Ny+Cy;
- vec3 a2=Cyz*Nz+a1;
- vec3 b1=Czx*Nz+Cx;
- vec3 b2=Cxy*Ny+b1;
- vec3 b3=Cxx_zz*Nx+b2;
- vec3 t1=Cz*Nz+C1;
- vec3 t2=a2*Ny+t1;
- vec3 t3=b3*Nx+t2;
- return t3;
- }
- #endif
- #endif`;
- ShaderStore.IncludesShadersStore[name$16] = shader$16;
- var name$15 = "pbrDirectLightingSetupFunctions"
- , shader$15 = `
- struct preLightingInfo
- {
- vec3 lightOffset;
- float lightDistanceSquared;
- float lightDistance;
- float attenuation;
- vec3 L;
- vec3 H;
- float NdotV;
- float NdotLUnclamped;
- float NdotL;
- float VdotH;
- float roughness;
- };
- preLightingInfo computePointAndSpotPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {
- preLightingInfo result;
- result.lightOffset=lightData.xyz-vPositionW;
- result.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);
- result.lightDistance=sqrt(result.lightDistanceSquared);
- result.L=normalize(result.lightOffset);
- result.H=normalize(V+result.L);
- result.VdotH=saturate(dot(V,result.H));
- result.NdotLUnclamped=dot(N,result.L);
- result.NdotL=saturateEps(result.NdotLUnclamped);
- return result;
- }
- preLightingInfo computeDirectionalPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {
- preLightingInfo result;
- result.lightDistance=length(-lightData.xyz);
- result.L=normalize(-lightData.xyz);
- result.H=normalize(V+result.L);
- result.VdotH=saturate(dot(V,result.H));
- result.NdotLUnclamped=dot(N,result.L);
- result.NdotL=saturateEps(result.NdotLUnclamped);
- return result;
- }
- preLightingInfo computeHemisphericPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {
- preLightingInfo result;
- result.NdotL=dot(N,lightData.xyz)*0.5+0.5;
- result.NdotL=saturateEps(result.NdotL);
- result.NdotLUnclamped=result.NdotL;
- #ifdef SPECULARTERM
- result.L=normalize(lightData.xyz);
- result.H=normalize(V+result.L);
- result.VdotH=saturate(dot(V,result.H));
- #endif
- return result;
- }`;
- ShaderStore.IncludesShadersStore[name$15] = shader$15;
- var name$14 = "pbrDirectLightingFalloffFunctions"
- , shader$14 = `float computeDistanceLightFalloff_Standard(vec3 lightOffset,float range)
- {
- return max(0.,1.0-length(lightOffset)/range);
- }
- float computeDistanceLightFalloff_Physical(float lightDistanceSquared)
- {
- return 1.0/maxEps(lightDistanceSquared);
- }
- float computeDistanceLightFalloff_GLTF(float lightDistanceSquared,float inverseSquaredRange)
- {
- float lightDistanceFalloff=1.0/maxEps(lightDistanceSquared);
- float factor=lightDistanceSquared*inverseSquaredRange;
- float attenuation=saturate(1.0-factor*factor);
- attenuation*=attenuation;
- lightDistanceFalloff*=attenuation;
- return lightDistanceFalloff;
- }
- float computeDistanceLightFalloff(vec3 lightOffset,float lightDistanceSquared,float range,float inverseSquaredRange)
- {
- #ifdef USEPHYSICALLIGHTFALLOFF
- return computeDistanceLightFalloff_Physical(lightDistanceSquared);
- #elif defined(USEGLTFLIGHTFALLOFF)
- return computeDistanceLightFalloff_GLTF(lightDistanceSquared,inverseSquaredRange);
- #else
- return computeDistanceLightFalloff_Standard(lightOffset,range);
- #endif
- }
- float computeDirectionalLightFalloff_Standard(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent)
- {
- float falloff=0.0;
- float cosAngle=maxEps(dot(-lightDirection,directionToLightCenterW));
- if (cosAngle>=cosHalfAngle)
- {
- falloff=max(0.,pow(cosAngle,exponent));
- }
- return falloff;
- }
- float computeDirectionalLightFalloff_Physical(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle)
- {
- const float kMinusLog2ConeAngleIntensityRatio=6.64385618977;
- float concentrationKappa=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);
- vec4 lightDirectionSpreadSG=vec4(-lightDirection*concentrationKappa,-concentrationKappa);
- float falloff=exp2(dot(vec4(directionToLightCenterW,1.0),lightDirectionSpreadSG));
- return falloff;
- }
- float computeDirectionalLightFalloff_GLTF(vec3 lightDirection,vec3 directionToLightCenterW,float lightAngleScale,float lightAngleOffset)
- {
- float cd=dot(-lightDirection,directionToLightCenterW);
- float falloff=saturate(cd*lightAngleScale+lightAngleOffset);
- falloff*=falloff;
- return falloff;
- }
- float computeDirectionalLightFalloff(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent,float lightAngleScale,float lightAngleOffset)
- {
- #ifdef USEPHYSICALLIGHTFALLOFF
- return computeDirectionalLightFalloff_Physical(lightDirection,directionToLightCenterW,cosHalfAngle);
- #elif defined(USEGLTFLIGHTFALLOFF)
- return computeDirectionalLightFalloff_GLTF(lightDirection,directionToLightCenterW,lightAngleScale,lightAngleOffset);
- #else
- return computeDirectionalLightFalloff_Standard(lightDirection,directionToLightCenterW,cosHalfAngle,exponent);
- #endif
- }`;
- ShaderStore.IncludesShadersStore[name$14] = shader$14;
- var name$13 = "pbrBRDFFunctions"
- , shader$13 = `
- #define FRESNEL_MAXIMUM_ON_ROUGH 0.25
- #ifdef MS_BRDF_ENERGY_CONSERVATION
- vec3 getEnergyConservationFactor(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {
- return 1.0+specularEnvironmentR0*(1.0/environmentBrdf.y-1.0);
- }
- #endif
- #ifdef ENVIRONMENTBRDF
- vec3 getBRDFLookup(float NdotV,float perceptualRoughness) {
- vec2 UV=vec2(NdotV,perceptualRoughness);
- vec4 brdfLookup=texture2D(environmentBrdfSampler,UV);
- #ifdef ENVIRONMENTBRDF_RGBD
- brdfLookup.rgb=fromRGBD(brdfLookup.rgba);
- #endif
- return brdfLookup.rgb;
- }
- vec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,const vec3 specularEnvironmentR90,const vec3 environmentBrdf) {
- #ifdef BRDF_V_HEIGHT_CORRELATED
- vec3 reflectance=(specularEnvironmentR90-specularEnvironmentR0)*environmentBrdf.x+specularEnvironmentR0*environmentBrdf.y;
- #else
- vec3 reflectance=specularEnvironmentR0*environmentBrdf.x+specularEnvironmentR90*environmentBrdf.y;
- #endif
- return reflectance;
- }
- vec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {
- #ifdef BRDF_V_HEIGHT_CORRELATED
- vec3 reflectance=mix(environmentBrdf.xxx,environmentBrdf.yyy,specularEnvironmentR0);
- #else
- vec3 reflectance=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;
- #endif
- return reflectance;
- }
- #endif
- #if !defined(ENVIRONMENTBRDF) || defined(REFLECTIONMAP_SKYBOX) || defined(ALPHAFRESNEL)
- vec3 getReflectanceFromAnalyticalBRDFLookup_Jones(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)
- {
- float weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);
- return reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));
- }
- #endif
- #if defined(SHEEN) && defined(ENVIRONMENTBRDF)
- vec3 getSheenReflectanceFromBRDFLookup(const vec3 reflectance0,const vec3 environmentBrdf) {
- vec3 sheenEnvironmentReflectance=reflectance0*environmentBrdf.b;
- return sheenEnvironmentReflectance;
- }
- #endif
- vec3 fresnelSchlickGGX(float VdotH,vec3 reflectance0,vec3 reflectance90)
- {
- return reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);
- }
- float fresnelSchlickGGX(float VdotH,float reflectance0,float reflectance90)
- {
- return reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);
- }
- #ifdef CLEARCOAT
- vec3 getR0RemappedForClearCoat(vec3 f0) {
- #ifdef CLEARCOAT_DEFAULTIOR
- #ifdef MOBILE
- return saturate(f0*(f0*0.526868+0.529324)-0.0482256);
- #else
- return saturate(f0*(f0*(0.941892-0.263008*f0)+0.346479)-0.0285998);
- #endif
- #else
- vec3 s=sqrt(f0);
- vec3 t=(vClearCoatRefractionParams.z+vClearCoatRefractionParams.w*s)/(vClearCoatRefractionParams.w+vClearCoatRefractionParams.z*s);
- return t*t;
- #endif
- }
- #endif
- float normalDistributionFunction_TrowbridgeReitzGGX(float NdotH,float alphaG)
- {
- float a2=square(alphaG);
- float d=NdotH*NdotH*(a2-1.0)+1.0;
- return a2/(PI*d*d);
- }
- #ifdef SHEEN
- float normalDistributionFunction_CharlieSheen(float NdotH,float alphaG)
- {
- float invR=1./alphaG;
- float cos2h=NdotH*NdotH;
- float sin2h=1.-cos2h;
- return (2.+invR)*pow(sin2h,invR*.5)/(2.*PI);
- }
- #endif
- #ifdef ANISOTROPIC
- float normalDistributionFunction_BurleyGGX_Anisotropic(float NdotH,float TdotH,float BdotH,const vec2 alphaTB) {
- float a2=alphaTB.x*alphaTB.y;
- vec3 v=vec3(alphaTB.y*TdotH,alphaTB.x*BdotH,a2*NdotH);
- float v2=dot(v,v);
- float w2=a2/v2;
- return a2*w2*w2*RECIPROCAL_PI;
- }
- #endif
- #ifdef BRDF_V_HEIGHT_CORRELATED
- float smithVisibility_GGXCorrelated(float NdotL,float NdotV,float alphaG) {
- #ifdef MOBILE
- float GGXV=NdotL*(NdotV*(1.0-alphaG)+alphaG);
- float GGXL=NdotV*(NdotL*(1.0-alphaG)+alphaG);
- return 0.5/(GGXV+GGXL);
- #else
- float a2=alphaG*alphaG;
- float GGXV=NdotL*sqrt(NdotV*(NdotV-a2*NdotV)+a2);
- float GGXL=NdotV*sqrt(NdotL*(NdotL-a2*NdotL)+a2);
- return 0.5/(GGXV+GGXL);
- #endif
- }
- #else
- float smithVisibilityG1_TrowbridgeReitzGGXFast(float dot,float alphaG)
- {
- #ifdef MOBILE
- return 1.0/(dot+alphaG+(1.0-alphaG)*dot ));
- #else
- float alphaSquared=alphaG*alphaG;
- return 1.0/(dot+sqrt(alphaSquared+(1.0-alphaSquared)*dot*dot));
- #endif
- }
- float smithVisibility_TrowbridgeReitzGGXFast(float NdotL,float NdotV,float alphaG)
- {
- float visibility=smithVisibilityG1_TrowbridgeReitzGGXFast(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGXFast(NdotV,alphaG);
- return visibility;
- }
- #endif
- #ifdef ANISOTROPIC
- float smithVisibility_GGXCorrelated_Anisotropic(float NdotL,float NdotV,float TdotV,float BdotV,float TdotL,float BdotL,const vec2 alphaTB) {
- float lambdaV=NdotL*length(vec3(alphaTB.x*TdotV,alphaTB.y*BdotV,NdotV));
- float lambdaL=NdotV*length(vec3(alphaTB.x*TdotL,alphaTB.y*BdotL,NdotL));
- float v=0.5/(lambdaV+lambdaL);
- return v;
- }
- #endif
- #ifdef CLEARCOAT
- float visibility_Kelemen(float VdotH) {
- return 0.25/(VdotH*VdotH);
- }
- #endif
- #ifdef SHEEN
- float visibility_Ashikhmin(float NdotL,float NdotV)
- {
- return 1./(4.*(NdotL+NdotV-NdotL*NdotV));
- }
- #endif
- float diffuseBRDF_Burley(float NdotL,float NdotV,float VdotH,float roughness) {
- float diffuseFresnelNV=pow5(saturateEps(1.0-NdotL));
- float diffuseFresnelNL=pow5(saturateEps(1.0-NdotV));
- float diffuseFresnel90=0.5+2.0*VdotH*VdotH*roughness;
- float fresnel =
- (1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) *
- (1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);
- return fresnel/PI;
- }
- #ifdef SS_TRANSLUCENCY
- vec3 transmittanceBRDF_Burley(const vec3 tintColor,const vec3 diffusionDistance,float thickness) {
- vec3 S=1./maxEps(diffusionDistance);
- vec3 temp=exp((-0.333333333*thickness)*S);
- return tintColor.rgb*0.25*(temp*temp*temp+3.0*temp);
- }
- float computeWrappedDiffuseNdotL(float NdotL,float w) {
- float t=1.0+w;
- float invt2=1.0/square(t);
- return saturate((NdotL+w)*invt2);
- }
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$13] = shader$13;
- var name$12 = "hdrFilteringFunctions"
- , shader$12 = `#ifdef NUM_SAMPLES
- #if NUM_SAMPLES>0
- #if defined(WEBGL2) || defined(WEBGPU)
- float radicalInverse_VdC(uint bits)
- {
- bits=(bits << 16u) | (bits >> 16u);
- bits=((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
- bits=((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
- bits=((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
- bits=((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
- return float(bits)*2.3283064365386963e-10;
- }
- vec2 hammersley(uint i,uint N)
- {
- return vec2(float(i)/float(N),radicalInverse_VdC(i));
- }
- #else
- float vanDerCorpus(int n,int base)
- {
- float invBase=1.0/float(base);
- float denom=1.0;
- float result=0.0;
- for(int i=0; i<32; ++i)
- {
- if(n>0)
- {
- denom=mod(float(n),2.0);
- result+=denom*invBase;
- invBase=invBase/2.0;
- n=int(float(n)/2.0);
- }
- }
- return result;
- }
- vec2 hammersley(int i,int N)
- {
- return vec2(float(i)/float(N),vanDerCorpus(i,2));
- }
- #endif
- float log4(float x) {
- return log2(x)/2.;
- }
- const float NUM_SAMPLES_FLOAT=float(NUM_SAMPLES);
- const float NUM_SAMPLES_FLOAT_INVERSED=1./NUM_SAMPLES_FLOAT;
- const float K=4.;
- #define inline
- vec3 irradiance(samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)
- {
- vec3 n=normalize(inputN);
- vec3 result=vec3(0.0);
- vec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);
- tangent=normalize(cross(tangent,n));
- vec3 bitangent=cross(n,tangent);
- mat3 tbn=mat3(tangent,bitangent,n);
- float maxLevel=filteringInfo.y;
- float dim0=filteringInfo.x;
- float omegaP=(4.*PI)/(6.*dim0*dim0);
- #if defined(WEBGL2) || defined(WEBGPU)
- for(uint i=0u; i<NUM_SAMPLES; ++i)
- #else
- for(int i=0; i<NUM_SAMPLES; ++i)
- #endif
- {
- vec2 Xi=hammersley(i,NUM_SAMPLES);
- vec3 Ls=hemisphereCosSample(Xi);
- Ls=normalize(Ls);
- vec3 Ns=vec3(0.,0.,1.);
- float NoL=dot(Ns,Ls);
- if (NoL>0.) {
- float pdf_inversed=PI/NoL;
- float omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;
- float l=log4(omegaS)-log4(omegaP)+log4(K);
- float mipLevel=clamp(l,0.0,maxLevel);
- vec3 c=textureCubeLodEXT(inputTexture,tbn*Ls,mipLevel).rgb;
- #ifdef GAMMA_INPUT
- c=toLinearSpace(c);
- #endif
- result+=c;
- }
- }
- result=result*NUM_SAMPLES_FLOAT_INVERSED;
- return result;
- }
- #define inline
- vec3 radiance(float alphaG,samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)
- {
- vec3 n=normalize(inputN);
- if (alphaG == 0.) {
- vec3 c=textureCube(inputTexture,n).rgb;
- #ifdef GAMMA_INPUT
- c=toLinearSpace(c);
- #endif
- return c;
- } else {
- vec3 result=vec3(0.);
- vec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);
- tangent=normalize(cross(tangent,n));
- vec3 bitangent=cross(n,tangent);
- mat3 tbn=mat3(tangent,bitangent,n);
- float maxLevel=filteringInfo.y;
- float dim0=filteringInfo.x;
- float omegaP=(4.*PI)/(6.*dim0*dim0);
- float weight=0.;
- #if defined(WEBGL2) || defined(WEBGPU)
- for(uint i=0u; i<NUM_SAMPLES; ++i)
- #else
- for(int i=0; i<NUM_SAMPLES; ++i)
- #endif
- {
- vec2 Xi=hammersley(i,NUM_SAMPLES);
- vec3 H=hemisphereImportanceSampleDggx(Xi,alphaG);
- float NoV=1.;
- float NoH=H.z;
- float NoH2=H.z*H.z;
- float NoL=2.*NoH2-1.;
- vec3 L=vec3(2.*NoH*H.x,2.*NoH*H.y,NoL);
- L=normalize(L);
- if (NoL>0.) {
- float pdf_inversed=4./normalDistributionFunction_TrowbridgeReitzGGX(NoH,alphaG);
- float omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;
- float l=log4(omegaS)-log4(omegaP)+log4(K);
- float mipLevel=clamp(float(l),0.0,maxLevel);
- weight+=NoL;
- vec3 c=textureCubeLodEXT(inputTexture,tbn*L,mipLevel).rgb;
- #ifdef GAMMA_INPUT
- c=toLinearSpace(c);
- #endif
- result+=c*NoL;
- }
- }
- result=result/weight;
- return result;
- }
- }
- #endif
- #endif`;
- ShaderStore.IncludesShadersStore[name$12] = shader$12;
- var name$11 = "pbrDirectLightingFunctions"
- , shader$11 = `#define CLEARCOATREFLECTANCE90 1.0
- struct lightingInfo
- {
- vec3 diffuse;
- #ifdef SPECULARTERM
- vec3 specular;
- #endif
- #ifdef CLEARCOAT
- vec4 clearCoat;
- #endif
- #ifdef SHEEN
- vec3 sheen;
- #endif
- };
- float adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance) {
- #if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF)
- float lightRoughness=lightRadius/lightDistance;
- float totalRoughness=saturate(lightRoughness+roughness);
- return totalRoughness;
- #else
- return roughness;
- #endif
- }
- vec3 computeHemisphericDiffuseLighting(preLightingInfo info,vec3 lightColor,vec3 groundColor) {
- return mix(groundColor,lightColor,info.NdotL);
- }
- vec3 computeDiffuseLighting(preLightingInfo info,vec3 lightColor) {
- float diffuseTerm=diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.roughness);
- return diffuseTerm*info.attenuation*info.NdotL*lightColor;
- }
- #define inline
- vec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){
- vec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);
- strq/=strq.w;
- vec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;
- return toLinearSpace(textureColor);
- }
- #ifdef SS_TRANSLUCENCY
- vec3 computeDiffuseAndTransmittedLighting(preLightingInfo info,vec3 lightColor,vec3 transmittance) {
- float NdotL=absEps(info.NdotLUnclamped);
- float wrapNdotL=computeWrappedDiffuseNdotL(NdotL,0.02);
- float trAdapt=step(0.,info.NdotLUnclamped);
- vec3 transmittanceNdotL=mix(transmittance*wrapNdotL,vec3(wrapNdotL),trAdapt);
- float diffuseTerm=diffuseBRDF_Burley(NdotL,info.NdotV,info.VdotH,info.roughness);
- return diffuseTerm*transmittanceNdotL*info.attenuation*lightColor;
- }
- #endif
- #ifdef SPECULARTERM
- vec3 computeSpecularLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {
- float NdotH=saturateEps(dot(N,info.H));
- float roughness=max(info.roughness,geometricRoughnessFactor);
- float alphaG=convertRoughnessToAverageSlope(roughness);
- vec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);
- float distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);
- #ifdef BRDF_V_HEIGHT_CORRELATED
- float smithVisibility=smithVisibility_GGXCorrelated(info.NdotL,info.NdotV,alphaG);
- #else
- float smithVisibility=smithVisibility_TrowbridgeReitzGGXFast(info.NdotL,info.NdotV,alphaG);
- #endif
- vec3 specTerm=fresnel*distribution*smithVisibility;
- return specTerm*info.attenuation*info.NdotL*lightColor;
- }
- #endif
- #ifdef ANISOTROPIC
- vec3 computeAnisotropicSpecularLighting(preLightingInfo info,vec3 V,vec3 N,vec3 T,vec3 B,float anisotropy,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {
- float NdotH=saturateEps(dot(N,info.H));
- float TdotH=dot(T,info.H);
- float BdotH=dot(B,info.H);
- float TdotV=dot(T,V);
- float BdotV=dot(B,V);
- float TdotL=dot(T,info.L);
- float BdotL=dot(B,info.L);
- float alphaG=convertRoughnessToAverageSlope(info.roughness);
- vec2 alphaTB=getAnisotropicRoughness(alphaG,anisotropy);
- alphaTB=max(alphaTB,square(geometricRoughnessFactor));
- vec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);
- float distribution=normalDistributionFunction_BurleyGGX_Anisotropic(NdotH,TdotH,BdotH,alphaTB);
- float smithVisibility=smithVisibility_GGXCorrelated_Anisotropic(info.NdotL,info.NdotV,TdotV,BdotV,TdotL,BdotL,alphaTB);
- vec3 specTerm=fresnel*distribution*smithVisibility;
- return specTerm*info.attenuation*info.NdotL*lightColor;
- }
- #endif
- #ifdef CLEARCOAT
- vec4 computeClearCoatLighting(preLightingInfo info,vec3 Ncc,float geometricRoughnessFactor,float clearCoatIntensity,vec3 lightColor) {
- float NccdotL=saturateEps(dot(Ncc,info.L));
- float NccdotH=saturateEps(dot(Ncc,info.H));
- float clearCoatRoughness=max(info.roughness,geometricRoughnessFactor);
- float alphaG=convertRoughnessToAverageSlope(clearCoatRoughness);
- float fresnel=fresnelSchlickGGX(info.VdotH,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);
- fresnel*=clearCoatIntensity;
- float distribution=normalDistributionFunction_TrowbridgeReitzGGX(NccdotH,alphaG);
- float kelemenVisibility=visibility_Kelemen(info.VdotH);
- float clearCoatTerm=fresnel*distribution*kelemenVisibility;
- return vec4(
- clearCoatTerm*info.attenuation*NccdotL*lightColor,
- 1.0-fresnel
- );
- }
- vec3 computeClearCoatLightingAbsorption(float NdotVRefract,vec3 L,vec3 Ncc,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {
- vec3 LRefract=-refract(L,Ncc,vClearCoatRefractionParams.y);
- float NdotLRefract=saturateEps(dot(Ncc,LRefract));
- vec3 absorption=computeClearCoatAbsorption(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);
- return absorption;
- }
- #endif
- #ifdef SHEEN
- vec3 computeSheenLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {
- float NdotH=saturateEps(dot(N,info.H));
- float roughness=max(info.roughness,geometricRoughnessFactor);
- float alphaG=convertRoughnessToAverageSlope(roughness);
- float fresnel=1.;
- float distribution=normalDistributionFunction_CharlieSheen(NdotH,alphaG);
- float visibility=visibility_Ashikhmin(info.NdotL,info.NdotV);
- float sheenTerm=fresnel*distribution*visibility;
- return sheenTerm*info.attenuation*info.NdotL*lightColor;
- }
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$11] = shader$11;
- var name$10 = "pbrIBLFunctions"
- , shader$10 = `#if defined(REFLECTION) || defined(SS_REFRACTION)
- float getLodFromAlphaG(float cubeMapDimensionPixels,float microsurfaceAverageSlope) {
- float microsurfaceAverageSlopeTexels=cubeMapDimensionPixels*microsurfaceAverageSlope;
- float lod=log2(microsurfaceAverageSlopeTexels);
- return lod;
- }
- float getLinearLodFromRoughness(float cubeMapDimensionPixels,float roughness) {
- float lod=log2(cubeMapDimensionPixels)*roughness;
- return lod;
- }
- #endif
- #if defined(ENVIRONMENTBRDF) && defined(RADIANCEOCCLUSION)
- float environmentRadianceOcclusion(float ambientOcclusion,float NdotVUnclamped) {
- float temp=NdotVUnclamped+ambientOcclusion;
- return saturate(square(temp)-1.0+ambientOcclusion);
- }
- #endif
- #if defined(ENVIRONMENTBRDF) && defined(HORIZONOCCLUSION)
- float environmentHorizonOcclusion(vec3 view,vec3 normal,vec3 geometricNormal) {
- vec3 reflection=reflect(view,normal);
- float temp=saturate(1.0+1.1*dot(reflection,geometricNormal));
- return square(temp);
- }
- #endif
- #if defined(LODINREFLECTIONALPHA) || defined(SS_LODINREFRACTIONALPHA)
- #define UNPACK_LOD(x) (1.0-x)*255.0
- float getLodFromAlphaG(float cubeMapDimensionPixels,float alphaG,float NdotV) {
- float microsurfaceAverageSlope=alphaG;
- microsurfaceAverageSlope*=sqrt(abs(NdotV));
- return getLodFromAlphaG(cubeMapDimensionPixels,microsurfaceAverageSlope);
- }
- #endif`;
- ShaderStore.IncludesShadersStore[name$10] = shader$10;
- var name$$ = "pbrBlockAlbedoOpacity"
- , shader$$ = `struct albedoOpacityOutParams
- {
- vec3 surfaceAlbedo;
- float alpha;
- };
- #define pbr_inline
- void albedoOpacityBlock(
- in vec4 vAlbedoColor,
- #ifdef ALBEDO
- in vec4 albedoTexture,
- in vec2 albedoInfos,
- #endif
- #ifdef OPACITY
- in vec4 opacityMap,
- in vec2 vOpacityInfos,
- #endif
- #ifdef DETAIL
- in vec4 detailColor,
- in vec4 vDetailInfos,
- #endif
- out albedoOpacityOutParams outParams
- )
- {
- vec3 surfaceAlbedo=vAlbedoColor.rgb;
- float alpha=vAlbedoColor.a;
- #ifdef ALBEDO
- #if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)
- alpha*=albedoTexture.a;
- #endif
- #ifdef GAMMAALBEDO
- surfaceAlbedo*=toLinearSpace(albedoTexture.rgb);
- #else
- surfaceAlbedo*=albedoTexture.rgb;
- #endif
- surfaceAlbedo*=albedoInfos.y;
- #endif
- #ifdef VERTEXCOLOR
- surfaceAlbedo*=vColor.rgb;
- #endif
- #ifdef DETAIL
- float detailAlbedo=2.0*mix(0.5,detailColor.r,vDetailInfos.y);
- surfaceAlbedo.rgb=surfaceAlbedo.rgb*detailAlbedo*detailAlbedo;
- #endif
- #define CUSTOM_FRAGMENT_UPDATE_ALBEDO
- #ifdef OPACITY
- #ifdef OPACITYRGB
- alpha=getLuminance(opacityMap.rgb);
- #else
- alpha*=opacityMap.a;
- #endif
- alpha*=vOpacityInfos.y;
- #endif
- #ifdef VERTEXALPHA
- alpha*=vColor.a;
- #endif
- #if !defined(SS_LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)
- #ifdef ALPHATEST
- if (alpha<ALPHATESTVALUE)
- discard;
- #ifndef ALPHABLEND
- alpha=1.0;
- #endif
- #endif
- #endif
- outParams.surfaceAlbedo=surfaceAlbedo;
- outParams.alpha=alpha;
- }
- `;
- ShaderStore.IncludesShadersStore[name$$] = shader$$;
- var name$_ = "pbrBlockReflectivity"
- , shader$_ = `struct reflectivityOutParams
- {
- float microSurface;
- float roughness;
- vec3 surfaceReflectivityColor;
- #ifdef METALLICWORKFLOW
- vec3 surfaceAlbedo;
- #endif
- #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
- vec3 ambientOcclusionColor;
- #endif
- #if DEBUGMODE>0
- vec4 surfaceMetallicColorMap;
- vec4 surfaceReflectivityColorMap;
- vec2 metallicRoughness;
- vec3 metallicF0;
- #endif
- };
- #define pbr_inline
- void reflectivityBlock(
- in vec4 vReflectivityColor,
- #ifdef METALLICWORKFLOW
- in vec3 surfaceAlbedo,
- in vec4 metallicReflectanceFactors,
- #endif
- #ifdef REFLECTIVITY
- in vec3 reflectivityInfos,
- in vec4 surfaceMetallicOrReflectivityColorMap,
- #endif
- #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
- in vec3 ambientOcclusionColorIn,
- #endif
- #ifdef MICROSURFACEMAP
- in vec4 microSurfaceTexel,
- #endif
- #ifdef DETAIL
- in vec4 detailColor,
- in vec4 vDetailInfos,
- #endif
- out reflectivityOutParams outParams
- )
- {
- float microSurface=vReflectivityColor.a;
- vec3 surfaceReflectivityColor=vReflectivityColor.rgb;
- #ifdef METALLICWORKFLOW
- vec2 metallicRoughness=surfaceReflectivityColor.rg;
- #ifdef REFLECTIVITY
- #if DEBUGMODE>0
- outParams.surfaceMetallicColorMap=surfaceMetallicOrReflectivityColorMap;
- #endif
- #ifdef AOSTOREINMETALMAPRED
- vec3 aoStoreInMetalMap=vec3(surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r);
- outParams.ambientOcclusionColor=mix(ambientOcclusionColorIn,aoStoreInMetalMap,reflectivityInfos.z);
- #endif
- #ifdef METALLNESSSTOREINMETALMAPBLUE
- metallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.b;
- #else
- metallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.r;
- #endif
- #ifdef ROUGHNESSSTOREINMETALMAPALPHA
- metallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.a;
- #else
- #ifdef ROUGHNESSSTOREINMETALMAPGREEN
- metallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.g;
- #endif
- #endif
- #endif
- #ifdef DETAIL
- float detailRoughness=mix(0.5,detailColor.b,vDetailInfos.w);
- float loLerp=mix(0.,metallicRoughness.g,detailRoughness*2.);
- float hiLerp=mix(metallicRoughness.g,1.,(detailRoughness-0.5)*2.);
- metallicRoughness.g=mix(loLerp,hiLerp,step(detailRoughness,0.5));
- #endif
- #ifdef MICROSURFACEMAP
- metallicRoughness.g*=microSurfaceTexel.r;
- #endif
- #if DEBUGMODE>0
- outParams.metallicRoughness=metallicRoughness;
- #endif
- #define CUSTOM_FRAGMENT_UPDATE_METALLICROUGHNESS
- microSurface=1.0-metallicRoughness.g;
- vec3 baseColor=surfaceAlbedo;
- #ifdef FROSTBITE_REFLECTANCE
- outParams.surfaceAlbedo=baseColor.rgb*(1.0-metallicRoughness.r);
- surfaceReflectivityColor=mix(0.16*reflectance*reflectance,baseColor,metallicRoughness.r);
- #else
- vec3 metallicF0=metallicReflectanceFactors.rgb;
- #if DEBUGMODE>0
- outParams.metallicF0=metallicF0;
- #endif
- outParams.surfaceAlbedo=mix(baseColor.rgb*(1.0-metallicF0),vec3(0.,0.,0.),metallicRoughness.r);
- surfaceReflectivityColor=mix(metallicF0,baseColor,metallicRoughness.r);
- #endif
- #else
- #ifdef REFLECTIVITY
- surfaceReflectivityColor*=surfaceMetallicOrReflectivityColorMap.rgb;
- #if DEBUGMODE>0
- outParams.surfaceReflectivityColorMap=surfaceMetallicOrReflectivityColorMap;
- #endif
- #ifdef MICROSURFACEFROMREFLECTIVITYMAP
- microSurface*=surfaceMetallicOrReflectivityColorMap.a;
- microSurface*=reflectivityInfos.z;
- #else
- #ifdef MICROSURFACEAUTOMATIC
- microSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);
- #endif
- #ifdef MICROSURFACEMAP
- microSurface*=microSurfaceTexel.r;
- #endif
- #define CUSTOM_FRAGMENT_UPDATE_MICROSURFACE
- #endif
- #endif
- #endif
- microSurface=saturate(microSurface);
- float roughness=1.-microSurface;
- outParams.microSurface=microSurface;
- outParams.roughness=roughness;
- outParams.surfaceReflectivityColor=surfaceReflectivityColor;
- }
- `;
- ShaderStore.IncludesShadersStore[name$_] = shader$_;
- var name$Z = "pbrBlockAmbientOcclusion"
- , shader$Z = `struct ambientOcclusionOutParams
- {
- vec3 ambientOcclusionColor;
- #if DEBUGMODE>0
- vec3 ambientOcclusionColorMap;
- #endif
- };
- #define pbr_inline
- void ambientOcclusionBlock(
- #ifdef AMBIENT
- in vec3 ambientOcclusionColorMap_,
- in vec4 vAmbientInfos,
- #endif
- out ambientOcclusionOutParams outParams
- )
- {
- vec3 ambientOcclusionColor=vec3(1.,1.,1.);
- #ifdef AMBIENT
- vec3 ambientOcclusionColorMap=ambientOcclusionColorMap_*vAmbientInfos.y;
- #ifdef AMBIENTINGRAYSCALE
- ambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);
- #endif
- ambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);
- #if DEBUGMODE>0
- outParams.ambientOcclusionColorMap=ambientOcclusionColorMap;
- #endif
- #endif
- outParams.ambientOcclusionColor=ambientOcclusionColor;
- }
- `;
- ShaderStore.IncludesShadersStore[name$Z] = shader$Z;
- var name$Y = "pbrBlockAlphaFresnel"
- , shader$Y = `#ifdef ALPHAFRESNEL
- #if defined(ALPHATEST) || defined(ALPHABLEND)
- struct alphaFresnelOutParams
- {
- float alpha;
- };
- #define pbr_inline
- void alphaFresnelBlock(
- in vec3 normalW,
- in vec3 viewDirectionW,
- in float alpha,
- in float microSurface,
- out alphaFresnelOutParams outParams
- )
- {
- float opacityPerceptual=alpha;
- #ifdef LINEARALPHAFRESNEL
- float opacity0=opacityPerceptual;
- #else
- float opacity0=opacityPerceptual*opacityPerceptual;
- #endif
- float opacity90=fresnelGrazingReflectance(opacity0);
- vec3 normalForward=faceforward(normalW,-viewDirectionW,normalW);
- outParams.alpha=getReflectanceFromAnalyticalBRDFLookup_Jones(saturate(dot(viewDirectionW,normalForward)),vec3(opacity0),vec3(opacity90),sqrt(microSurface)).x;
- #ifdef ALPHATEST
- if (outParams.alpha<ALPHATESTVALUE)
- discard;
- #ifndef ALPHABLEND
- outParams.alpha=1.0;
- #endif
- #endif
- }
- #endif
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$Y] = shader$Y;
- var name$X = "pbrBlockAnisotropic"
- , shader$X = `#ifdef ANISOTROPIC
- struct anisotropicOutParams
- {
- float anisotropy;
- vec3 anisotropicTangent;
- vec3 anisotropicBitangent;
- vec3 anisotropicNormal;
- #if DEBUGMODE>0
- vec3 anisotropyMapData;
- #endif
- };
- #define pbr_inline
- void anisotropicBlock(
- in vec3 vAnisotropy,
- #ifdef ANISOTROPIC_TEXTURE
- in vec3 anisotropyMapData,
- #endif
- in mat3 TBN,
- in vec3 normalW,
- in vec3 viewDirectionW,
- out anisotropicOutParams outParams
- )
- {
- float anisotropy=vAnisotropy.b;
- vec3 anisotropyDirection=vec3(vAnisotropy.xy,0.);
- #ifdef ANISOTROPIC_TEXTURE
- anisotropy*=anisotropyMapData.b;
- anisotropyDirection.rg*=anisotropyMapData.rg*2.0-1.0;
- #if DEBUGMODE>0
- outParams.anisotropyMapData=anisotropyMapData;
- #endif
- #endif
- mat3 anisoTBN=mat3(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2]));
- vec3 anisotropicTangent=normalize(anisoTBN*anisotropyDirection);
- vec3 anisotropicBitangent=normalize(cross(anisoTBN[2],anisotropicTangent));
- outParams.anisotropy=anisotropy;
- outParams.anisotropicTangent=anisotropicTangent;
- outParams.anisotropicBitangent=anisotropicBitangent;
- outParams.anisotropicNormal=getAnisotropicBentNormals(anisotropicTangent,anisotropicBitangent,normalW,viewDirectionW,anisotropy);
- }
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$X] = shader$X;
- var name$W = "pbrBlockReflection"
- , shader$W = `#ifdef REFLECTION
- struct reflectionOutParams
- {
- vec4 environmentRadiance;
- vec3 environmentIrradiance;
- #ifdef REFLECTIONMAP_3D
- vec3 reflectionCoords;
- #else
- vec2 reflectionCoords;
- #endif
- #ifdef SS_TRANSLUCENCY
- #ifdef USESPHERICALFROMREFLECTIONMAP
- #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
- vec3 irradianceVector;
- #endif
- #endif
- #endif
- };
- #define pbr_inline
- void createReflectionCoords(
- in vec3 vPositionW,
- in vec3 normalW,
- #ifdef ANISOTROPIC
- in anisotropicOutParams anisotropicOut,
- #endif
- #ifdef REFLECTIONMAP_3D
- out vec3 reflectionCoords
- #else
- out vec2 reflectionCoords
- #endif
- )
- {
- #ifdef ANISOTROPIC
- vec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),anisotropicOut.anisotropicNormal);
- #else
- vec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);
- #endif
- #ifdef REFLECTIONMAP_OPPOSITEZ
- reflectionVector.z*=-1.0;
- #endif
- #ifdef REFLECTIONMAP_3D
- reflectionCoords=reflectionVector;
- #else
- reflectionCoords=reflectionVector.xy;
- #ifdef REFLECTIONMAP_PROJECTION
- reflectionCoords/=reflectionVector.z;
- #endif
- reflectionCoords.y=1.0-reflectionCoords.y;
- #endif
- }
- #define pbr_inline
- #define inline
- void sampleReflectionTexture(
- in float alphaG,
- in vec3 vReflectionMicrosurfaceInfos,
- in vec2 vReflectionInfos,
- in vec3 vReflectionColor,
- #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
- in float NdotVUnclamped,
- #endif
- #ifdef LINEARSPECULARREFLECTION
- in float roughness,
- #endif
- #ifdef REFLECTIONMAP_3D
- in samplerCube reflectionSampler,
- const vec3 reflectionCoords,
- #else
- in sampler2D reflectionSampler,
- const vec2 reflectionCoords,
- #endif
- #ifndef LODBASEDMICROSFURACE
- #ifdef REFLECTIONMAP_3D
- in samplerCube reflectionSamplerLow,
- in samplerCube reflectionSamplerHigh,
- #else
- in sampler2D reflectionSamplerLow,
- in sampler2D reflectionSamplerHigh,
- #endif
- #endif
- #ifdef REALTIME_FILTERING
- in vec2 vReflectionFilteringInfo,
- #endif
- out vec4 environmentRadiance
- )
- {
- #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
- float reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);
- #elif defined(LINEARSPECULARREFLECTION)
- float reflectionLOD=getLinearLodFromRoughness(vReflectionMicrosurfaceInfos.x,roughness);
- #else
- float reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG);
- #endif
- #ifdef LODBASEDMICROSFURACE
- reflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;
- #ifdef LODINREFLECTIONALPHA
- float automaticReflectionLOD=UNPACK_LOD(sampleReflection(reflectionSampler,reflectionCoords).a);
- float requestedReflectionLOD=max(automaticReflectionLOD,reflectionLOD);
- #else
- float requestedReflectionLOD=reflectionLOD;
- #endif
- #ifdef REALTIME_FILTERING
- environmentRadiance=vec4(radiance(alphaG,reflectionSampler,reflectionCoords,vReflectionFilteringInfo),1.0);
- #else
- environmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);
- #endif
- #else
- float lodReflectionNormalized=saturate(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x));
- float lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;
- vec4 environmentMid=sampleReflection(reflectionSampler,reflectionCoords);
- if (lodReflectionNormalizedDoubled<1.0){
- environmentRadiance=mix(
- sampleReflection(reflectionSamplerHigh,reflectionCoords),
- environmentMid,
- lodReflectionNormalizedDoubled
- );
- } else {
- environmentRadiance=mix(
- environmentMid,
- sampleReflection(reflectionSamplerLow,reflectionCoords),
- lodReflectionNormalizedDoubled-1.0
- );
- }
- #endif
- #ifdef RGBDREFLECTION
- environmentRadiance.rgb=fromRGBD(environmentRadiance);
- #endif
- #ifdef GAMMAREFLECTION
- environmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb);
- #endif
- environmentRadiance.rgb*=vReflectionInfos.x;
- environmentRadiance.rgb*=vReflectionColor.rgb;
- }
- #define pbr_inline
- #define inline
- void reflectionBlock(
- in vec3 vPositionW,
- in vec3 normalW,
- in float alphaG,
- in vec3 vReflectionMicrosurfaceInfos,
- in vec2 vReflectionInfos,
- in vec3 vReflectionColor,
- #ifdef ANISOTROPIC
- in anisotropicOutParams anisotropicOut,
- #endif
- #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
- in float NdotVUnclamped,
- #endif
- #ifdef LINEARSPECULARREFLECTION
- in float roughness,
- #endif
- #ifdef REFLECTIONMAP_3D
- in samplerCube reflectionSampler,
- #else
- in sampler2D reflectionSampler,
- #endif
- #if defined(NORMAL) && defined(USESPHERICALINVERTEX)
- in vec3 vEnvironmentIrradiance,
- #endif
- #ifdef USESPHERICALFROMREFLECTIONMAP
- #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
- in mat4 reflectionMatrix,
- #endif
- #endif
- #ifdef USEIRRADIANCEMAP
- #ifdef REFLECTIONMAP_3D
- in samplerCube irradianceSampler,
- #else
- in sampler2D irradianceSampler,
- #endif
- #endif
- #ifndef LODBASEDMICROSFURACE
- #ifdef REFLECTIONMAP_3D
- in samplerCube reflectionSamplerLow,
- in samplerCube reflectionSamplerHigh,
- #else
- in sampler2D reflectionSamplerLow,
- in sampler2D reflectionSamplerHigh,
- #endif
- #endif
- #ifdef REALTIME_FILTERING
- in vec2 vReflectionFilteringInfo,
- #endif
- out reflectionOutParams outParams
- )
- {
- vec4 environmentRadiance=vec4(0.,0.,0.,0.);
- #ifdef REFLECTIONMAP_3D
- vec3 reflectionCoords=vec3(0.);
- #else
- vec2 reflectionCoords=vec2(0.);
- #endif
- createReflectionCoords(
- vPositionW,
- normalW,
- #ifdef ANISOTROPIC
- anisotropicOut,
- #endif
- reflectionCoords
- );
- sampleReflectionTexture(
- alphaG,
- vReflectionMicrosurfaceInfos,
- vReflectionInfos,
- vReflectionColor,
- #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
- NdotVUnclamped,
- #endif
- #ifdef LINEARSPECULARREFLECTION
- roughness,
- #endif
- #ifdef REFLECTIONMAP_3D
- reflectionSampler,
- reflectionCoords,
- #else
- reflectionSampler,
- reflectionCoords,
- #endif
- #ifndef LODBASEDMICROSFURACE
- reflectionSamplerLow,
- reflectionSamplerHigh,
- #endif
- #ifdef REALTIME_FILTERING
- vReflectionFilteringInfo,
- #endif
- environmentRadiance
- );
- vec3 environmentIrradiance=vec3(0.,0.,0.);
- #ifdef USESPHERICALFROMREFLECTIONMAP
- #if defined(NORMAL) && defined(USESPHERICALINVERTEX)
- environmentIrradiance=vEnvironmentIrradiance;
- #else
- #ifdef ANISOTROPIC
- vec3 irradianceVector=vec3(reflectionMatrix*vec4(anisotropicOut.anisotropicNormal,0)).xyz;
- #else
- vec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;
- #endif
- #ifdef REFLECTIONMAP_OPPOSITEZ
- irradianceVector.z*=-1.0;
- #endif
- #ifdef INVERTCUBICMAP
- irradianceVector.y*=-1.0;
- #endif
- #if defined(REALTIME_FILTERING)
- environmentIrradiance=irradiance(reflectionSampler,irradianceVector,vReflectionFilteringInfo);
- #else
- environmentIrradiance=computeEnvironmentIrradiance(irradianceVector);
- #endif
- #ifdef SS_TRANSLUCENCY
- outParams.irradianceVector=irradianceVector;
- #endif
- #endif
- #elif defined(USEIRRADIANCEMAP)
- vec4 environmentIrradiance4=sampleReflection(irradianceSampler,reflectionCoords);
- environmentIrradiance=environmentIrradiance4.rgb;
- #ifdef RGBDREFLECTION
- environmentIrradiance.rgb=fromRGBD(environmentIrradiance4);
- #endif
- #ifdef GAMMAREFLECTION
- environmentIrradiance.rgb=toLinearSpace(environmentIrradiance.rgb);
- #endif
- #endif
- environmentIrradiance*=vReflectionColor.rgb;
- outParams.environmentRadiance=environmentRadiance;
- outParams.environmentIrradiance=environmentIrradiance;
- outParams.reflectionCoords=reflectionCoords;
- }
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$W] = shader$W;
- var name$V = "pbrBlockSheen"
- , shader$V = `#ifdef SHEEN
- struct sheenOutParams
- {
- float sheenIntensity;
- vec3 sheenColor;
- float sheenRoughness;
- #ifdef SHEEN_LINKWITHALBEDO
- vec3 surfaceAlbedo;
- #endif
- #if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
- float sheenAlbedoScaling;
- #endif
- #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
- vec3 finalSheenRadianceScaled;
- #endif
- #if DEBUGMODE>0
- vec4 sheenMapData;
- vec3 sheenEnvironmentReflectance;
- #endif
- };
- #define pbr_inline
- #define inline
- void sheenBlock(
- in vec4 vSheenColor,
- #ifdef SHEEN_ROUGHNESS
- in float vSheenRoughness,
- #if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
- in vec4 sheenMapRoughnessData,
- #endif
- #endif
- in float roughness,
- #ifdef SHEEN_TEXTURE
- in vec4 sheenMapData,
- in float sheenMapLevel,
- #endif
- in float reflectance,
- #ifdef SHEEN_LINKWITHALBEDO
- in vec3 baseColor,
- in vec3 surfaceAlbedo,
- #endif
- #ifdef ENVIRONMENTBRDF
- in float NdotV,
- in vec3 environmentBrdf,
- #endif
- #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
- in vec2 AARoughnessFactors,
- in vec3 vReflectionMicrosurfaceInfos,
- in vec2 vReflectionInfos,
- in vec3 vReflectionColor,
- in vec4 vLightingIntensity,
- #ifdef REFLECTIONMAP_3D
- in samplerCube reflectionSampler,
- in vec3 reflectionCoords,
- #else
- in sampler2D reflectionSampler,
- in vec2 reflectionCoords,
- #endif
- in float NdotVUnclamped,
- #ifndef LODBASEDMICROSFURACE
- #ifdef REFLECTIONMAP_3D
- in samplerCube reflectionSamplerLow,
- in samplerCube reflectionSamplerHigh,
- #else
- in sampler2D reflectionSamplerLow,
- in sampler2D reflectionSamplerHigh,
- #endif
- #endif
- #ifdef REALTIME_FILTERING
- in vec2 vReflectionFilteringInfo,
- #endif
- #if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
- in float seo,
- #endif
- #if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
- in float eho,
- #endif
- #endif
- out sheenOutParams outParams
- )
- {
- float sheenIntensity=vSheenColor.a;
- #ifdef SHEEN_TEXTURE
- #if DEBUGMODE>0
- outParams.sheenMapData=sheenMapData;
- #endif
- #endif
- #ifdef SHEEN_LINKWITHALBEDO
- float sheenFactor=pow5(1.0-sheenIntensity);
- vec3 sheenColor=baseColor.rgb*(1.0-sheenFactor);
- float sheenRoughness=sheenIntensity;
- outParams.surfaceAlbedo=surfaceAlbedo*sheenFactor;
- #ifdef SHEEN_TEXTURE
- sheenIntensity*=sheenMapData.a;
- #endif
- #else
- vec3 sheenColor=vSheenColor.rgb;
- #ifdef SHEEN_TEXTURE
- #ifdef SHEEN_GAMMATEXTURE
- sheenColor.rgb*=toLinearSpace(sheenMapData.rgb);
- #else
- sheenColor.rgb*=sheenMapData.rgb;
- #endif
- sheenColor.rgb*=sheenMapLevel;
- #endif
- #ifdef SHEEN_ROUGHNESS
- float sheenRoughness=vSheenRoughness;
- #ifdef SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE
- #if defined(SHEEN_TEXTURE)
- sheenRoughness*=sheenMapData.a;
- #endif
- #elif defined(SHEEN_TEXTURE_ROUGHNESS)
- #ifdef SHEEN_TEXTURE_ROUGHNESS_IDENTICAL
- sheenRoughness*=sheenMapData.a;
- #else
- sheenRoughness*=sheenMapRoughnessData.a;
- #endif
- #endif
- #else
- float sheenRoughness=roughness;
- #ifdef SHEEN_TEXTURE
- sheenIntensity*=sheenMapData.a;
- #endif
- #endif
- #if !defined(SHEEN_ALBEDOSCALING)
- sheenIntensity*=(1.-reflectance);
- #endif
- sheenColor*=sheenIntensity;
- #endif
- #ifdef ENVIRONMENTBRDF
- #ifdef SHEEN_ROUGHNESS
- vec3 environmentSheenBrdf=getBRDFLookup(NdotV,sheenRoughness);
- #else
- vec3 environmentSheenBrdf=environmentBrdf;
- #endif
- #endif
- #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
- float sheenAlphaG=convertRoughnessToAverageSlope(sheenRoughness);
- #ifdef SPECULARAA
- sheenAlphaG+=AARoughnessFactors.y;
- #endif
- vec4 environmentSheenRadiance=vec4(0.,0.,0.,0.);
- sampleReflectionTexture(
- sheenAlphaG,
- vReflectionMicrosurfaceInfos,
- vReflectionInfos,
- vReflectionColor,
- #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
- NdotVUnclamped,
- #endif
- #ifdef LINEARSPECULARREFLECTION
- sheenRoughness,
- #endif
- reflectionSampler,
- reflectionCoords,
- #ifndef LODBASEDMICROSFURACE
- reflectionSamplerLow,
- reflectionSamplerHigh,
- #endif
- #ifdef REALTIME_FILTERING
- vReflectionFilteringInfo,
- #endif
- environmentSheenRadiance
- );
- vec3 sheenEnvironmentReflectance=getSheenReflectanceFromBRDFLookup(sheenColor,environmentSheenBrdf);
- #if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
- sheenEnvironmentReflectance*=seo;
- #endif
- #if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
- sheenEnvironmentReflectance*=eho;
- #endif
- #if DEBUGMODE>0
- outParams.sheenEnvironmentReflectance=sheenEnvironmentReflectance;
- #endif
- outParams.finalSheenRadianceScaled=
- environmentSheenRadiance.rgb *
- sheenEnvironmentReflectance *
- vLightingIntensity.z;
- #endif
- #if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
- outParams.sheenAlbedoScaling=1.0-sheenIntensity*max(max(sheenColor.r,sheenColor.g),sheenColor.b)*environmentSheenBrdf.b;
- #endif
- outParams.sheenIntensity=sheenIntensity;
- outParams.sheenColor=sheenColor;
- outParams.sheenRoughness=sheenRoughness;
- }
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$V] = shader$V;
- var name$U = "pbrBlockClearcoat"
- , shader$U = `struct clearcoatOutParams
- {
- vec3 specularEnvironmentR0;
- float conservationFactor;
- vec3 clearCoatNormalW;
- vec2 clearCoatAARoughnessFactors;
- float clearCoatIntensity;
- float clearCoatRoughness;
- #ifdef REFLECTION
- vec3 finalClearCoatRadianceScaled;
- #endif
- #ifdef CLEARCOAT_TINT
- vec3 absorption;
- float clearCoatNdotVRefract;
- vec3 clearCoatColor;
- float clearCoatThickness;
- #endif
- #if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
- vec3 energyConservationFactorClearCoat;
- #endif
- #if DEBUGMODE>0
- mat3 TBNClearCoat;
- vec2 clearCoatMapData;
- vec4 clearCoatTintMapData;
- vec4 environmentClearCoatRadiance;
- float clearCoatNdotV;
- vec3 clearCoatEnvironmentReflectance;
- #endif
- };
- #ifdef CLEARCOAT
- #define pbr_inline
- #define inline
- void clearcoatBlock(
- in vec3 vPositionW,
- in vec3 geometricNormalW,
- in vec3 viewDirectionW,
- in vec2 vClearCoatParams,
- #if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
- in vec4 clearCoatMapRoughnessData,
- #endif
- in vec3 specularEnvironmentR0,
- #ifdef CLEARCOAT_TEXTURE
- in vec2 clearCoatMapData,
- #endif
- #ifdef CLEARCOAT_TINT
- in vec4 vClearCoatTintParams,
- in float clearCoatColorAtDistance,
- in vec4 vClearCoatRefractionParams,
- #ifdef CLEARCOAT_TINT_TEXTURE
- in vec4 clearCoatTintMapData,
- #endif
- #endif
- #ifdef CLEARCOAT_BUMP
- in vec2 vClearCoatBumpInfos,
- in vec4 clearCoatBumpMapData,
- in vec2 vClearCoatBumpUV,
- #if defined(TANGENT) && defined(NORMAL)
- in mat3 vTBN,
- #else
- in vec2 vClearCoatTangentSpaceParams,
- #endif
- #ifdef OBJECTSPACE_NORMALMAP
- in mat4 normalMatrix,
- #endif
- #endif
- #if defined(FORCENORMALFORWARD) && defined(NORMAL)
- in vec3 faceNormal,
- #endif
- #ifdef REFLECTION
- in vec3 vReflectionMicrosurfaceInfos,
- in vec2 vReflectionInfos,
- in vec3 vReflectionColor,
- in vec4 vLightingIntensity,
- #ifdef REFLECTIONMAP_3D
- in samplerCube reflectionSampler,
- #else
- in sampler2D reflectionSampler,
- #endif
- #ifndef LODBASEDMICROSFURACE
- #ifdef REFLECTIONMAP_3D
- in samplerCube reflectionSamplerLow,
- in samplerCube reflectionSamplerHigh,
- #else
- in sampler2D reflectionSamplerLow,
- in sampler2D reflectionSamplerHigh,
- #endif
- #endif
- #ifdef REALTIME_FILTERING
- in vec2 vReflectionFilteringInfo,
- #endif
- #endif
- #if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
- #ifdef RADIANCEOCCLUSION
- in float ambientMonochrome,
- #endif
- #endif
- #if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)
- in float frontFacingMultiplier,
- #endif
- out clearcoatOutParams outParams
- )
- {
- float clearCoatIntensity=vClearCoatParams.x;
- float clearCoatRoughness=vClearCoatParams.y;
- #ifdef CLEARCOAT_TEXTURE
- clearCoatIntensity*=clearCoatMapData.x;
- #ifdef CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE
- clearCoatRoughness*=clearCoatMapData.y;
- #endif
- #if DEBUGMODE>0
- outParams.clearCoatMapData=clearCoatMapData;
- #endif
- #endif
- #if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
- #ifdef CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL
- clearCoatRoughness*=clearCoatMapData.y;
- #else
- clearCoatRoughness*=clearCoatMapRoughnessData.y;
- #endif
- #endif
- outParams.clearCoatIntensity=clearCoatIntensity;
- outParams.clearCoatRoughness=clearCoatRoughness;
- #ifdef CLEARCOAT_TINT
- vec3 clearCoatColor=vClearCoatTintParams.rgb;
- float clearCoatThickness=vClearCoatTintParams.a;
- #ifdef CLEARCOAT_TINT_TEXTURE
- #ifdef CLEARCOAT_TINT_GAMMATEXTURE
- clearCoatColor*=toLinearSpace(clearCoatTintMapData.rgb);
- #else
- clearCoatColor*=clearCoatTintMapData.rgb;
- #endif
- clearCoatThickness*=clearCoatTintMapData.a;
- #if DEBUGMODE>0
- outParams.clearCoatTintMapData=clearCoatTintMapData;
- #endif
- #endif
- outParams.clearCoatColor=computeColorAtDistanceInMedia(clearCoatColor,clearCoatColorAtDistance);
- outParams.clearCoatThickness=clearCoatThickness;
- #endif
- #ifdef CLEARCOAT_REMAP_F0
- vec3 specularEnvironmentR0Updated=getR0RemappedForClearCoat(specularEnvironmentR0);
- #else
- vec3 specularEnvironmentR0Updated=specularEnvironmentR0;
- #endif
- outParams.specularEnvironmentR0=mix(specularEnvironmentR0,specularEnvironmentR0Updated,clearCoatIntensity);
- vec3 clearCoatNormalW=geometricNormalW;
- #ifdef CLEARCOAT_BUMP
- #ifdef NORMALXYSCALE
- float clearCoatNormalScale=1.0;
- #else
- float clearCoatNormalScale=vClearCoatBumpInfos.y;
- #endif
- #if defined(TANGENT) && defined(NORMAL)
- mat3 TBNClearCoat=vTBN;
- #else
- vec2 TBNClearCoatUV=vClearCoatBumpUV*frontFacingMultiplier;
- mat3 TBNClearCoat=cotangent_frame(clearCoatNormalW*clearCoatNormalScale,vPositionW,TBNClearCoatUV,vClearCoatTangentSpaceParams);
- #endif
- #if DEBUGMODE>0
- outParams.TBNClearCoat=TBNClearCoat;
- #endif
- #ifdef OBJECTSPACE_NORMALMAP
- clearCoatNormalW=normalize(clearCoatBumpMapData.xyz*2.0-1.0);
- clearCoatNormalW=normalize(mat3(normalMatrix)*clearCoatNormalW);
- #else
- clearCoatNormalW=perturbNormal(TBNClearCoat,clearCoatBumpMapData.xyz,vClearCoatBumpInfos.y);
- #endif
- #endif
- #if defined(FORCENORMALFORWARD) && defined(NORMAL)
- clearCoatNormalW*=sign(dot(clearCoatNormalW,faceNormal));
- #endif
- #if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
- clearCoatNormalW=clearCoatNormalW*frontFacingMultiplier;
- #endif
- outParams.clearCoatNormalW=clearCoatNormalW;
- outParams.clearCoatAARoughnessFactors=getAARoughnessFactors(clearCoatNormalW.xyz);
- float clearCoatNdotVUnclamped=dot(clearCoatNormalW,viewDirectionW);
- float clearCoatNdotV=absEps(clearCoatNdotVUnclamped);
- #if DEBUGMODE>0
- outParams.clearCoatNdotV=clearCoatNdotV;
- #endif
- #ifdef CLEARCOAT_TINT
- vec3 clearCoatVRefract=-refract(vPositionW,clearCoatNormalW,vClearCoatRefractionParams.y);
- outParams.clearCoatNdotVRefract=absEps(dot(clearCoatNormalW,clearCoatVRefract));
- #endif
- #if defined(ENVIRONMENTBRDF) && (!defined(REFLECTIONMAP_SKYBOX) || defined(MS_BRDF_ENERGY_CONSERVATION))
- vec3 environmentClearCoatBrdf=getBRDFLookup(clearCoatNdotV,clearCoatRoughness);
- #endif
- #if defined(REFLECTION)
- float clearCoatAlphaG=convertRoughnessToAverageSlope(clearCoatRoughness);
- #ifdef SPECULARAA
- clearCoatAlphaG+=outParams.clearCoatAARoughnessFactors.y;
- #endif
- vec4 environmentClearCoatRadiance=vec4(0.,0.,0.,0.);
- vec3 clearCoatReflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),clearCoatNormalW);
- #ifdef REFLECTIONMAP_OPPOSITEZ
- clearCoatReflectionVector.z*=-1.0;
- #endif
- #ifdef REFLECTIONMAP_3D
- vec3 clearCoatReflectionCoords=clearCoatReflectionVector;
- #else
- vec2 clearCoatReflectionCoords=clearCoatReflectionVector.xy;
- #ifdef REFLECTIONMAP_PROJECTION
- clearCoatReflectionCoords/=clearCoatReflectionVector.z;
- #endif
- clearCoatReflectionCoords.y=1.0-clearCoatReflectionCoords.y;
- #endif
- sampleReflectionTexture(
- clearCoatAlphaG,
- vReflectionMicrosurfaceInfos,
- vReflectionInfos,
- vReflectionColor,
- #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
- clearCoatNdotVUnclamped,
- #endif
- #ifdef LINEARSPECULARREFLECTION
- clearCoatRoughness,
- #endif
- reflectionSampler,
- clearCoatReflectionCoords,
- #ifndef LODBASEDMICROSFURACE
- reflectionSamplerLow,
- reflectionSamplerHigh,
- #endif
- #ifdef REALTIME_FILTERING
- vReflectionFilteringInfo,
- #endif
- environmentClearCoatRadiance
- );
- #if DEBUGMODE>0
- outParams.environmentClearCoatRadiance=environmentClearCoatRadiance;
- #endif
- #if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
- vec3 clearCoatEnvironmentReflectance=getReflectanceFromBRDFLookup(vec3(vClearCoatRefractionParams.x),environmentClearCoatBrdf);
- #ifdef RADIANCEOCCLUSION
- float clearCoatSeo=environmentRadianceOcclusion(ambientMonochrome,clearCoatNdotVUnclamped);
- clearCoatEnvironmentReflectance*=clearCoatSeo;
- #endif
- #ifdef HORIZONOCCLUSION
- #ifdef BUMP
- #ifdef REFLECTIONMAP_3D
- float clearCoatEho=environmentHorizonOcclusion(-viewDirectionW,clearCoatNormalW,geometricNormalW);
- clearCoatEnvironmentReflectance*=clearCoatEho;
- #endif
- #endif
- #endif
- #else
- vec3 clearCoatEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(clearCoatNdotV,vec3(1.),vec3(1.),sqrt(1.-clearCoatRoughness));
- #endif
- clearCoatEnvironmentReflectance*=clearCoatIntensity;
- #if DEBUGMODE>0
- outParams.clearCoatEnvironmentReflectance=clearCoatEnvironmentReflectance;
- #endif
- outParams.finalClearCoatRadianceScaled=
- environmentClearCoatRadiance.rgb *
- clearCoatEnvironmentReflectance *
- vLightingIntensity.z;
- #endif
- #if defined(CLEARCOAT_TINT)
- outParams.absorption=computeClearCoatAbsorption(outParams.clearCoatNdotVRefract,outParams.clearCoatNdotVRefract,outParams.clearCoatColor,clearCoatThickness,clearCoatIntensity);
- #endif
- float fresnelIBLClearCoat=fresnelSchlickGGX(clearCoatNdotV,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);
- fresnelIBLClearCoat*=clearCoatIntensity;
- outParams.conservationFactor=(1.-fresnelIBLClearCoat);
- #if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
- outParams.energyConservationFactorClearCoat=getEnergyConservationFactor(outParams.specularEnvironmentR0,environmentClearCoatBrdf);
- #endif
- }
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$U] = shader$U;
- var name$T = "pbrBlockSubSurface"
- , shader$T = `struct subSurfaceOutParams
- {
- vec3 specularEnvironmentReflectance;
- #ifdef SS_REFRACTION
- vec3 finalRefraction;
- vec3 surfaceAlbedo;
- #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
- float alpha;
- #endif
- #ifdef REFLECTION
- float refractionFactorForIrradiance;
- #endif
- #endif
- #ifdef SS_TRANSLUCENCY
- vec3 transmittance;
- float translucencyIntensity;
- #ifdef REFLECTION
- vec3 refractionIrradiance;
- #endif
- #endif
- #if DEBUGMODE>0
- vec4 thicknessMap;
- vec4 environmentRefraction;
- vec3 refractionTransmittance;
- #endif
- };
- #ifdef SUBSURFACE
- #define pbr_inline
- #define inline
- void subSurfaceBlock(
- in vec3 vSubSurfaceIntensity,
- in vec2 vThicknessParam,
- in vec4 vTintColor,
- in vec3 normalW,
- in vec3 specularEnvironmentReflectance,
- #ifdef SS_THICKNESSANDMASK_TEXTURE
- in vec4 thicknessMap,
- #endif
- #ifdef SS_REFRACTIONINTENSITY_TEXTURE
- in vec4 refractionIntensityMap,
- #endif
- #ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
- in vec4 translucencyIntensityMap,
- #endif
- #ifdef REFLECTION
- #ifdef SS_TRANSLUCENCY
- in mat4 reflectionMatrix,
- #ifdef USESPHERICALFROMREFLECTIONMAP
- #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
- in vec3 irradianceVector_,
- #endif
- #if defined(REALTIME_FILTERING)
- in samplerCube reflectionSampler,
- in vec2 vReflectionFilteringInfo,
- #endif
- #endif
- #ifdef USEIRRADIANCEMAP
- #ifdef REFLECTIONMAP_3D
- in samplerCube irradianceSampler,
- #else
- in sampler2D irradianceSampler,
- #endif
- #endif
- #endif
- #endif
- #if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)
- in vec3 surfaceAlbedo,
- #endif
- #ifdef SS_REFRACTION
- in vec3 vPositionW,
- in vec3 viewDirectionW,
- in mat4 view,
- in vec4 vRefractionInfos,
- in mat4 refractionMatrix,
- in vec4 vRefractionMicrosurfaceInfos,
- in vec4 vLightingIntensity,
- #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
- in float alpha,
- #endif
- #ifdef SS_LODINREFRACTIONALPHA
- in float NdotVUnclamped,
- #endif
- #ifdef SS_LINEARSPECULARREFRACTION
- in float roughness,
- #endif
- in float alphaG,
- #ifdef SS_REFRACTIONMAP_3D
- in samplerCube refractionSampler,
- #ifndef LODBASEDMICROSFURACE
- in samplerCube refractionSamplerLow,
- in samplerCube refractionSamplerHigh,
- #endif
- #else
- in sampler2D refractionSampler,
- #ifndef LODBASEDMICROSFURACE
- in sampler2D refractionSamplerLow,
- in sampler2D refractionSamplerHigh,
- #endif
- #endif
- #ifdef ANISOTROPIC
- in anisotropicOutParams anisotropicOut,
- #endif
- #ifdef REALTIME_FILTERING
- in vec2 vRefractionFilteringInfo,
- #endif
- #ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
- in vec3 refractionPosition,
- in vec3 refractionSize,
- #endif
- #endif
- #ifdef SS_TRANSLUCENCY
- in vec3 vDiffusionDistance,
- #endif
- out subSurfaceOutParams outParams
- )
- {
- outParams.specularEnvironmentReflectance=specularEnvironmentReflectance;
- #ifdef SS_REFRACTION
- float refractionIntensity=vSubSurfaceIntensity.x;
- #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
- refractionIntensity*=(1.0-alpha);
- outParams.alpha=1.0;
- #endif
- #endif
- #ifdef SS_TRANSLUCENCY
- float translucencyIntensity=vSubSurfaceIntensity.y;
- #endif
- #ifdef SS_THICKNESSANDMASK_TEXTURE
- #if defined(SS_USE_GLTF_TEXTURES)
- float thickness=thicknessMap.g*vThicknessParam.y+vThicknessParam.x;
- #else
- float thickness=thicknessMap.r*vThicknessParam.y+vThicknessParam.x;
- #endif
- #if DEBUGMODE>0
- outParams.thicknessMap=thicknessMap;
- #endif
- #ifdef SS_MASK_FROM_THICKNESS_TEXTURE
- #if defined(SS_REFRACTION) && defined(SS_REFRACTION_USE_INTENSITY_FROM_TEXTURE)
- #if defined(SS_USE_GLTF_TEXTURES)
- refractionIntensity*=thicknessMap.r;
- #else
- refractionIntensity*=thicknessMap.g;
- #endif
- #endif
- #if defined(SS_TRANSLUCENCY) && defined(SS_TRANSLUCENCY_USE_INTENSITY_FROM_TEXTURE)
- translucencyIntensity*=thicknessMap.b;
- #endif
- #endif
- #else
- float thickness=vThicknessParam.y;
- #endif
- #ifdef SS_REFRACTIONINTENSITY_TEXTURE
- #ifdef SS_USE_GLTF_TEXTURES
- refractionIntensity*=refractionIntensityMap.r;
- #else
- refractionIntensity*=refractionIntensityMap.g;
- #endif
- #endif
- #ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
- translucencyIntensity*=translucencyIntensityMap.b;
- #endif
- #ifdef SS_TRANSLUCENCY
- thickness=maxEps(thickness);
- vec3 transmittance=transmittanceBRDF_Burley(vTintColor.rgb,vDiffusionDistance,thickness);
- transmittance*=translucencyIntensity;
- outParams.transmittance=transmittance;
- outParams.translucencyIntensity=translucencyIntensity;
- #endif
- #ifdef SS_REFRACTION
- vec4 environmentRefraction=vec4(0.,0.,0.,0.);
- #ifdef ANISOTROPIC
- vec3 refractionVector=refract(-viewDirectionW,anisotropicOut.anisotropicNormal,vRefractionInfos.y);
- #else
- vec3 refractionVector=refract(-viewDirectionW,normalW,vRefractionInfos.y);
- #endif
- #ifdef SS_REFRACTIONMAP_OPPOSITEZ
- refractionVector.z*=-1.0;
- #endif
- #ifdef SS_REFRACTIONMAP_3D
- #ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
- refractionVector=parallaxCorrectNormal(vPositionW,refractionVector,refractionSize,refractionPosition);
- #endif
- refractionVector.y=refractionVector.y*vRefractionInfos.w;
- vec3 refractionCoords=refractionVector;
- refractionCoords=vec3(refractionMatrix*vec4(refractionCoords,0));
- #else
- #ifdef SS_USE_THICKNESS_AS_DEPTH
- vec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*thickness,1.0)));
- #else
- vec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));
- #endif
- vec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;
- refractionCoords.y=1.0-refractionCoords.y;
- #endif
- #ifdef SS_HAS_THICKNESS
- float ior=vRefractionInfos.y;
- #else
- float ior=vRefractionMicrosurfaceInfos.w;
- #endif
- #ifdef SS_LODINREFRACTIONALPHA
- float refractionAlphaG=alphaG;
- refractionAlphaG=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));
- float refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,refractionAlphaG,NdotVUnclamped);
- #elif defined(SS_LINEARSPECULARREFRACTION)
- float refractionRoughness=alphaG;
- refractionRoughness=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));
- float refractionLOD=getLinearLodFromRoughness(vRefractionMicrosurfaceInfos.x,refractionRoughness);
- #else
- float refractionAlphaG=alphaG;
- refractionAlphaG=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));
- float refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,refractionAlphaG);
- #endif
- #ifdef LODBASEDMICROSFURACE
- refractionLOD=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z;
- #ifdef SS_LODINREFRACTIONALPHA
- float automaticRefractionLOD=UNPACK_LOD(sampleRefraction(refractionSampler,refractionCoords).a);
- float requestedRefractionLOD=max(automaticRefractionLOD,refractionLOD);
- #else
- float requestedRefractionLOD=refractionLOD;
- #endif
- #ifdef REALTIME_FILTERING
- environmentRefraction=vec4(radiance(alphaG,refractionSampler,refractionCoords,vRefractionFilteringInfo),1.0);
- #else
- environmentRefraction=sampleRefractionLod(refractionSampler,refractionCoords,requestedRefractionLOD);
- #endif
- #else
- float lodRefractionNormalized=saturate(refractionLOD/log2(vRefractionMicrosurfaceInfos.x));
- float lodRefractionNormalizedDoubled=lodRefractionNormalized*2.0;
- vec4 environmentRefractionMid=sampleRefraction(refractionSampler,refractionCoords);
- if (lodRefractionNormalizedDoubled<1.0){
- environmentRefraction=mix(
- sampleRefraction(refractionSamplerHigh,refractionCoords),
- environmentRefractionMid,
- lodRefractionNormalizedDoubled
- );
- } else {
- environmentRefraction=mix(
- environmentRefractionMid,
- sampleRefraction(refractionSamplerLow,refractionCoords),
- lodRefractionNormalizedDoubled-1.0
- );
- }
- #endif
- #ifdef SS_RGBDREFRACTION
- environmentRefraction.rgb=fromRGBD(environmentRefraction);
- #endif
- #ifdef SS_GAMMAREFRACTION
- environmentRefraction.rgb=toLinearSpace(environmentRefraction.rgb);
- #endif
- environmentRefraction.rgb*=vRefractionInfos.x;
- #endif
- #ifdef SS_REFRACTION
- vec3 refractionTransmittance=vec3(refractionIntensity);
- #ifdef SS_THICKNESSANDMASK_TEXTURE
- vec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);
- refractionTransmittance*=cocaLambert(volumeAlbedo,thickness);
- #elif defined(SS_LINKREFRACTIONTOTRANSPARENCY)
- float maxChannel=max(max(surfaceAlbedo.r,surfaceAlbedo.g),surfaceAlbedo.b);
- vec3 volumeAlbedo=saturate(maxChannel*surfaceAlbedo);
- environmentRefraction.rgb*=volumeAlbedo;
- #else
- vec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);
- refractionTransmittance*=cocaLambert(volumeAlbedo,vThicknessParam.y);
- #endif
- #ifdef SS_ALBEDOFORREFRACTIONTINT
- environmentRefraction.rgb*=surfaceAlbedo.rgb;
- #endif
- outParams.surfaceAlbedo=surfaceAlbedo*(1.-refractionIntensity);
- #ifdef REFLECTION
- outParams.refractionFactorForIrradiance=(1.-refractionIntensity);
- #endif
- #ifdef UNUSED_MULTIPLEBOUNCES
- vec3 bounceSpecularEnvironmentReflectance=(2.0*specularEnvironmentReflectance)/(1.0+specularEnvironmentReflectance);
- outParams.specularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,specularEnvironmentReflectance,refractionIntensity);
- #endif
- refractionTransmittance*=1.0-outParams.specularEnvironmentReflectance;
- #if DEBUGMODE>0
- outParams.refractionTransmittance=refractionTransmittance;
- #endif
- outParams.finalRefraction=environmentRefraction.rgb*refractionTransmittance*vLightingIntensity.z;
- #if DEBUGMODE>0
- outParams.environmentRefraction=environmentRefraction;
- #endif
- #endif
- #if defined(REFLECTION) && defined(SS_TRANSLUCENCY)
- #if defined(NORMAL) && defined(USESPHERICALINVERTEX) || !defined(USESPHERICALFROMREFLECTIONMAP)
- vec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;
- #ifdef REFLECTIONMAP_OPPOSITEZ
- irradianceVector.z*=-1.0;
- #endif
- #ifdef INVERTCUBICMAP
- irradianceVector.y*=-1.0;
- #endif
- #else
- vec3 irradianceVector=irradianceVector_;
- #endif
- #if defined(USESPHERICALFROMREFLECTIONMAP)
- #if defined(REALTIME_FILTERING)
- vec3 refractionIrradiance=irradiance(reflectionSampler,-irradianceVector,vReflectionFilteringInfo);
- #else
- vec3 refractionIrradiance=computeEnvironmentIrradiance(-irradianceVector);
- #endif
- #elif defined(USEIRRADIANCEMAP)
- #ifdef REFLECTIONMAP_3D
- vec3 irradianceCoords=irradianceVector;
- #else
- vec2 irradianceCoords=irradianceVector.xy;
- #ifdef REFLECTIONMAP_PROJECTION
- irradianceCoords/=irradianceVector.z;
- #endif
- irradianceCoords.y=1.0-irradianceCoords.y;
- #endif
- vec4 refractionIrradiance=sampleReflection(irradianceSampler,-irradianceCoords);
- #ifdef RGBDREFLECTION
- refractionIrradiance.rgb=fromRGBD(refractionIrradiance);
- #endif
- #ifdef GAMMAREFLECTION
- refractionIrradiance.rgb=toLinearSpace(refractionIrradiance.rgb);
- #endif
- #else
- vec4 refractionIrradiance=vec4(0.);
- #endif
- refractionIrradiance.rgb*=transmittance;
- #ifdef SS_ALBEDOFORTRANSLUCENCYTINT
- refractionIrradiance.rgb*=surfaceAlbedo.rgb;
- #endif
- outParams.refractionIrradiance=refractionIrradiance.rgb;
- #endif
- }
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$T] = shader$T;
- var name$S = "pbrBlockNormalGeometric"
- , shader$S = `vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);
- #ifdef NORMAL
- vec3 normalW=normalize(vNormalW);
- #else
- vec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;
- #endif
- vec3 geometricNormalW=normalW;
- #if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
- geometricNormalW=gl_FrontFacing ? geometricNormalW : -geometricNormalW;
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$S] = shader$S;
- var name$R = "pbrBlockNormalFinal"
- , shader$R = `#if defined(FORCENORMALFORWARD) && defined(NORMAL)
- vec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;
- #if defined(TWOSIDEDLIGHTING)
- faceNormal=gl_FrontFacing ? faceNormal : -faceNormal;
- #endif
- normalW*=sign(dot(normalW,faceNormal));
- #endif
- #if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
- normalW=gl_FrontFacing ? normalW : -normalW;
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$R] = shader$R;
- var name$Q = "pbrBlockLightmapInit"
- , shader$Q = `#ifdef LIGHTMAP
- vec4 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset);
- #ifdef RGBDLIGHTMAP
- lightmapColor.rgb=fromRGBD(lightmapColor);
- #endif
- #ifdef GAMMALIGHTMAP
- lightmapColor.rgb=toLinearSpace(lightmapColor.rgb);
- #endif
- lightmapColor.rgb*=vLightmapInfos.y;
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$Q] = shader$Q;
- var name$P = "pbrBlockGeometryInfo"
- , shader$P = `float NdotVUnclamped=dot(normalW,viewDirectionW);
- float NdotV=absEps(NdotVUnclamped);
- float alphaG=convertRoughnessToAverageSlope(roughness);
- vec2 AARoughnessFactors=getAARoughnessFactors(normalW.xyz);
- #ifdef SPECULARAA
- alphaG+=AARoughnessFactors.y;
- #endif
- #if defined(ENVIRONMENTBRDF)
- vec3 environmentBrdf=getBRDFLookup(NdotV,roughness);
- #endif
- #if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
- #ifdef RADIANCEOCCLUSION
- #ifdef AMBIENTINGRAYSCALE
- float ambientMonochrome=aoOut.ambientOcclusionColor.r;
- #else
- float ambientMonochrome=getLuminance(aoOut.ambientOcclusionColor);
- #endif
- float seo=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);
- #endif
- #ifdef HORIZONOCCLUSION
- #ifdef BUMP
- #ifdef REFLECTIONMAP_3D
- float eho=environmentHorizonOcclusion(-viewDirectionW,normalW,geometricNormalW);
- #endif
- #endif
- #endif
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$P] = shader$P;
- var name$O = "pbrBlockReflectance0"
- , shader$O = `float reflectance=max(max(reflectivityOut.surfaceReflectivityColor.r,reflectivityOut.surfaceReflectivityColor.g),reflectivityOut.surfaceReflectivityColor.b);
- vec3 specularEnvironmentR0=reflectivityOut.surfaceReflectivityColor.rgb;
- #ifdef METALLICWORKFLOW
- vec3 specularEnvironmentR90=vec3(metallicReflectanceFactors.a);
- #else
- vec3 specularEnvironmentR90=vec3(1.0,1.0,1.0);
- #endif
- #ifdef ALPHAFRESNEL
- float reflectance90=fresnelGrazingReflectance(reflectance);
- specularEnvironmentR90=specularEnvironmentR90*reflectance90;
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$O] = shader$O;
- var name$N = "pbrBlockReflectance"
- , shader$N = `#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
- vec3 specularEnvironmentReflectance=getReflectanceFromBRDFLookup(clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,environmentBrdf);
- #ifdef RADIANCEOCCLUSION
- specularEnvironmentReflectance*=seo;
- #endif
- #ifdef HORIZONOCCLUSION
- #ifdef BUMP
- #ifdef REFLECTIONMAP_3D
- specularEnvironmentReflectance*=eho;
- #endif
- #endif
- #endif
- #else
- vec3 specularEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(NdotV,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));
- #endif
- #ifdef CLEARCOAT
- specularEnvironmentReflectance*=clearcoatOut.conservationFactor;
- #if defined(CLEARCOAT_TINT)
- specularEnvironmentReflectance*=clearcoatOut.absorption;
- #endif
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$N] = shader$N;
- var name$M = "pbrBlockDirectLighting"
- , shader$M = `vec3 diffuseBase=vec3(0.,0.,0.);
- #ifdef SPECULARTERM
- vec3 specularBase=vec3(0.,0.,0.);
- #endif
- #ifdef CLEARCOAT
- vec3 clearCoatBase=vec3(0.,0.,0.);
- #endif
- #ifdef SHEEN
- vec3 sheenBase=vec3(0.,0.,0.);
- #endif
- preLightingInfo preInfo;
- lightingInfo info;
- float shadow=1.;
- #if defined(CLEARCOAT) && defined(CLEARCOAT_TINT)
- vec3 absorption=vec3(0.);
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$M] = shader$M;
- var name$L = "pbrBlockFinalLitComponents"
- , shader$L = `
- #if defined(ENVIRONMENTBRDF)
- #ifdef MS_BRDF_ENERGY_CONSERVATION
- vec3 energyConservationFactor=getEnergyConservationFactor(clearcoatOut.specularEnvironmentR0,environmentBrdf);
- #endif
- #endif
- #ifndef METALLICWORKFLOW
- #ifdef SPECULAR_GLOSSINESS_ENERGY_CONSERVATION
- surfaceAlbedo.rgb=(1.-reflectance)*surfaceAlbedo.rgb;
- #endif
- #endif
- #if defined(SHEEN) && defined(SHEEN_ALBEDOSCALING) && defined(ENVIRONMENTBRDF)
- surfaceAlbedo.rgb=sheenOut.sheenAlbedoScaling*surfaceAlbedo.rgb;
- #endif
- #ifdef REFLECTION
- vec3 finalIrradiance=reflectionOut.environmentIrradiance;
- #if defined(CLEARCOAT)
- finalIrradiance*=clearcoatOut.conservationFactor;
- #if defined(CLEARCOAT_TINT)
- finalIrradiance*=clearcoatOut.absorption;
- #endif
- #endif
- #if defined(SS_REFRACTION)
- finalIrradiance*=subSurfaceOut.refractionFactorForIrradiance;
- #endif
- #if defined(SS_TRANSLUCENCY)
- finalIrradiance*=(1.0-subSurfaceOut.translucencyIntensity);
- finalIrradiance+=subSurfaceOut.refractionIrradiance;
- #endif
- finalIrradiance*=surfaceAlbedo.rgb;
- finalIrradiance*=vLightingIntensity.z;
- finalIrradiance*=aoOut.ambientOcclusionColor;
- #endif
- #ifdef SPECULARTERM
- vec3 finalSpecular=specularBase;
- finalSpecular=max(finalSpecular,0.0);
- vec3 finalSpecularScaled=finalSpecular*vLightingIntensity.x*vLightingIntensity.w;
- #if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
- finalSpecularScaled*=energyConservationFactor;
- #endif
- #if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
- finalSpecularScaled*=sheenOut.sheenAlbedoScaling;
- #endif
- #endif
- #ifdef REFLECTION
- vec3 finalRadiance=reflectionOut.environmentRadiance.rgb;
- finalRadiance*=subSurfaceOut.specularEnvironmentReflectance;
- vec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z;
- #if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
- finalRadianceScaled*=energyConservationFactor;
- #endif
- #if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
- finalRadianceScaled*=sheenOut.sheenAlbedoScaling;
- #endif
- #endif
- #ifdef SHEEN
- vec3 finalSheen=sheenBase*sheenOut.sheenColor;
- finalSheen=max(finalSheen,0.0);
- vec3 finalSheenScaled=finalSheen*vLightingIntensity.x*vLightingIntensity.w;
- #if defined(CLEARCOAT) && defined(REFLECTION) && defined(ENVIRONMENTBRDF)
- sheenOut.finalSheenRadianceScaled*=clearcoatOut.conservationFactor;
- #if defined(CLEARCOAT_TINT)
- sheenOut.finalSheenRadianceScaled*=clearcoatOut.absorption;
- #endif
- #endif
- #endif
- #ifdef CLEARCOAT
- vec3 finalClearCoat=clearCoatBase;
- finalClearCoat=max(finalClearCoat,0.0);
- vec3 finalClearCoatScaled=finalClearCoat*vLightingIntensity.x*vLightingIntensity.w;
- #if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
- finalClearCoatScaled*=clearcoatOut.energyConservationFactorClearCoat;
- #endif
- #ifdef SS_REFRACTION
- subSurfaceOut.finalRefraction*=clearcoatOut.conservationFactor;
- #ifdef CLEARCOAT_TINT
- subSurfaceOut.finalRefraction*=clearcoatOut.absorption;
- #endif
- #endif
- #endif
- #ifdef ALPHABLEND
- float luminanceOverAlpha=0.0;
- #if defined(REFLECTION) && defined(RADIANCEOVERALPHA)
- luminanceOverAlpha+=getLuminance(finalRadianceScaled);
- #if defined(CLEARCOAT)
- luminanceOverAlpha+=getLuminance(clearcoatOut.finalClearCoatRadianceScaled);
- #endif
- #endif
- #if defined(SPECULARTERM) && defined(SPECULAROVERALPHA)
- luminanceOverAlpha+=getLuminance(finalSpecularScaled);
- #endif
- #if defined(CLEARCOAT) && defined(CLEARCOATOVERALPHA)
- luminanceOverAlpha+=getLuminance(finalClearCoatScaled);
- #endif
- #if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA) || defined(CLEARCOATOVERALPHA)
- alpha=saturate(alpha+luminanceOverAlpha*luminanceOverAlpha);
- #endif
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$L] = shader$L;
- var name$K = "pbrBlockFinalUnlitComponents"
- , shader$K = `
- vec3 finalDiffuse=diffuseBase;
- finalDiffuse*=surfaceAlbedo.rgb;
- finalDiffuse=max(finalDiffuse,0.0);
- finalDiffuse*=vLightingIntensity.x;
- vec3 finalAmbient=vAmbientColor;
- finalAmbient*=surfaceAlbedo.rgb;
- vec3 finalEmissive=vEmissiveColor;
- #ifdef EMISSIVE
- vec3 emissiveColorTex=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb;
- #ifdef GAMMAEMISSIVE
- finalEmissive*=toLinearSpace(emissiveColorTex.rgb);
- #else
- finalEmissive*=emissiveColorTex.rgb;
- #endif
- finalEmissive*=vEmissiveInfos.y;
- #endif
- finalEmissive*=vLightingIntensity.y;
- #ifdef AMBIENT
- vec3 ambientOcclusionForDirectDiffuse=mix(vec3(1.),aoOut.ambientOcclusionColor,vAmbientInfos.w);
- #else
- vec3 ambientOcclusionForDirectDiffuse=aoOut.ambientOcclusionColor;
- #endif
- finalAmbient*=aoOut.ambientOcclusionColor;
- finalDiffuse*=ambientOcclusionForDirectDiffuse;
- `;
- ShaderStore.IncludesShadersStore[name$K] = shader$K;
- var name$J = "pbrBlockFinalColorComposition"
- , shader$J = `vec4 finalColor=vec4(
- finalAmbient +
- finalDiffuse +
- #ifndef UNLIT
- #ifdef REFLECTION
- finalIrradiance +
- #endif
- #ifdef SPECULARTERM
- finalSpecularScaled +
- #endif
- #ifdef SHEEN
- finalSheenScaled +
- #endif
- #ifdef CLEARCOAT
- finalClearCoatScaled +
- #endif
- #ifdef REFLECTION
- finalRadianceScaled +
- #if defined(SHEEN) && defined(ENVIRONMENTBRDF)
- sheenOut.finalSheenRadianceScaled +
- #endif
- #ifdef CLEARCOAT
- clearcoatOut.finalClearCoatRadianceScaled +
- #endif
- #endif
- #ifdef SS_REFRACTION
- subSurfaceOut.finalRefraction +
- #endif
- #endif
- finalEmissive,
- alpha);
- #ifdef LIGHTMAP
- #ifndef LIGHTMAPEXCLUDED
- #ifdef USELIGHTMAPASSHADOWMAP
- finalColor.rgb*=lightmapColor.rgb;
- #else
- finalColor.rgb+=lightmapColor.rgb;
- #endif
- #endif
- #endif
- #define CUSTOM_FRAGMENT_BEFORE_FOG
- finalColor=max(finalColor,0.0);
- `;
- ShaderStore.IncludesShadersStore[name$J] = shader$J;
- var name$I = "pbrBlockImageProcessing"
- , shader$I = `#if defined(IMAGEPROCESSINGPOSTPROCESS) || defined(SS_SCATTERING)
- #if !defined(SKIPFINALCOLORCLAMP)
- finalColor.rgb=clamp(finalColor.rgb,0.,30.0);
- #endif
- #else
- finalColor=applyImageProcessing(finalColor);
- #endif
- finalColor.a*=visibility;
- #ifdef PREMULTIPLYALPHA
- finalColor.rgb*=finalColor.a;
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$I] = shader$I;
- var name$H = "pbrDebug"
- , shader$H = `#if DEBUGMODE>0
- if (vClipSpacePosition.x/vClipSpacePosition.w>=vDebugMode.x) {
- #if DEBUGMODE == 1
- gl_FragColor.rgb=vPositionW.rgb;
- #define DEBUGMODE_NORMALIZE
- #elif DEBUGMODE == 2 && defined(NORMAL)
- gl_FragColor.rgb=vNormalW.rgb;
- #define DEBUGMODE_NORMALIZE
- #elif DEBUGMODE == 3 && defined(BUMP) || DEBUGMODE == 3 && defined(PARALLAX) || DEBUGMODE == 3 && defined(ANISOTROPIC)
- gl_FragColor.rgb=TBN[0];
- #define DEBUGMODE_NORMALIZE
- #elif DEBUGMODE == 4 && defined(BUMP) || DEBUGMODE == 4 && defined(PARALLAX) || DEBUGMODE == 4 && defined(ANISOTROPIC)
- gl_FragColor.rgb=TBN[1];
- #define DEBUGMODE_NORMALIZE
- #elif DEBUGMODE == 5
- gl_FragColor.rgb=normalW;
- #define DEBUGMODE_NORMALIZE
- #elif DEBUGMODE == 6 && defined(MAINUV1)
- gl_FragColor.rgb=vec3(vMainUV1,0.0);
- #elif DEBUGMODE == 7 && defined(MAINUV2)
- gl_FragColor.rgb=vec3(vMainUV2,0.0);
- #elif DEBUGMODE == 8 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)
- gl_FragColor.rgb=clearcoatOut.TBNClearCoat[0];
- #define DEBUGMODE_NORMALIZE
- #elif DEBUGMODE == 9 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)
- gl_FragColor.rgb=clearcoatOut.TBNClearCoat[1];
- #define DEBUGMODE_NORMALIZE
- #elif DEBUGMODE == 10 && defined(CLEARCOAT)
- gl_FragColor.rgb=clearcoatOut.clearCoatNormalW;
- #define DEBUGMODE_NORMALIZE
- #elif DEBUGMODE == 11 && defined(ANISOTROPIC)
- gl_FragColor.rgb=anisotropicOut.anisotropicNormal;
- #define DEBUGMODE_NORMALIZE
- #elif DEBUGMODE == 12 && defined(ANISOTROPIC)
- gl_FragColor.rgb=anisotropicOut.anisotropicTangent;
- #define DEBUGMODE_NORMALIZE
- #elif DEBUGMODE == 13 && defined(ANISOTROPIC)
- gl_FragColor.rgb=anisotropicOut.anisotropicBitangent;
- #define DEBUGMODE_NORMALIZE
- #elif DEBUGMODE == 20 && defined(ALBEDO)
- gl_FragColor.rgb=albedoTexture.rgb;
- #elif DEBUGMODE == 21 && defined(AMBIENT)
- gl_FragColor.rgb=aoOut.ambientOcclusionColorMap.rgb;
- #elif DEBUGMODE == 22 && defined(OPACITY)
- gl_FragColor.rgb=opacityMap.rgb;
- #elif DEBUGMODE == 23 && defined(EMISSIVE)
- gl_FragColor.rgb=emissiveColorTex.rgb;
- #define DEBUGMODE_GAMMA
- #elif DEBUGMODE == 24 && defined(LIGHTMAP)
- gl_FragColor.rgb=lightmapColor.rgb;
- #define DEBUGMODE_GAMMA
- #elif DEBUGMODE == 25 && defined(REFLECTIVITY) && defined(METALLICWORKFLOW)
- gl_FragColor.rgb=reflectivityOut.surfaceMetallicColorMap.rgb;
- #elif DEBUGMODE == 26 && defined(REFLECTIVITY) && !defined(METALLICWORKFLOW)
- gl_FragColor.rgb=reflectivityOut.surfaceReflectivityColorMap.rgb;
- #define DEBUGMODE_GAMMA
- #elif DEBUGMODE == 27 && defined(CLEARCOAT) && defined(CLEARCOAT_TEXTURE)
- gl_FragColor.rgb=vec3(clearcoatOut.clearCoatMapData.rg,0.0);
- #elif DEBUGMODE == 28 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
- gl_FragColor.rgb=clearcoatOut.clearCoatTintMapData.rgb;
- #elif DEBUGMODE == 29 && defined(SHEEN) && defined(SHEEN_TEXTURE)
- gl_FragColor.rgb=sheenOut.sheenMapData.rgb;
- #elif DEBUGMODE == 30 && defined(ANISOTROPIC) && defined(ANISOTROPIC_TEXTURE)
- gl_FragColor.rgb=anisotropicOut.anisotropyMapData.rgb;
- #elif DEBUGMODE == 31 && defined(SUBSURFACE) && defined(SS_THICKNESSANDMASK_TEXTURE)
- gl_FragColor.rgb=subSurfaceOut.thicknessMap.rgb;
- #elif DEBUGMODE == 40 && defined(SS_REFRACTION)
- gl_FragColor.rgb=subSurfaceOut.environmentRefraction.rgb;
- #define DEBUGMODE_GAMMA
- #elif DEBUGMODE == 41 && defined(REFLECTION)
- gl_FragColor.rgb=reflectionOut.environmentRadiance.rgb;
- #define DEBUGMODE_GAMMA
- #elif DEBUGMODE == 42 && defined(CLEARCOAT) && defined(REFLECTION)
- gl_FragColor.rgb=clearcoatOut.environmentClearCoatRadiance.rgb;
- #define DEBUGMODE_GAMMA
- #elif DEBUGMODE == 50
- gl_FragColor.rgb=diffuseBase.rgb;
- #define DEBUGMODE_GAMMA
- #elif DEBUGMODE == 51 && defined(SPECULARTERM)
- gl_FragColor.rgb=specularBase.rgb;
- #define DEBUGMODE_GAMMA
- #elif DEBUGMODE == 52 && defined(CLEARCOAT)
- gl_FragColor.rgb=clearCoatBase.rgb;
- #define DEBUGMODE_GAMMA
- #elif DEBUGMODE == 53 && defined(SHEEN)
- gl_FragColor.rgb=sheenBase.rgb;
- #define DEBUGMODE_GAMMA
- #elif DEBUGMODE == 54 && defined(REFLECTION)
- gl_FragColor.rgb=reflectionOut.environmentIrradiance.rgb;
- #define DEBUGMODE_GAMMA
- #elif DEBUGMODE == 60
- gl_FragColor.rgb=surfaceAlbedo.rgb;
- #define DEBUGMODE_GAMMA
- #elif DEBUGMODE == 61
- gl_FragColor.rgb=clearcoatOut.specularEnvironmentR0;
- #define DEBUGMODE_GAMMA
- #elif DEBUGMODE == 62 && defined(METALLICWORKFLOW)
- gl_FragColor.rgb=vec3(reflectivityOut.metallicRoughness.r);
- #elif DEBUGMODE == 71 && defined(METALLICWORKFLOW)
- gl_FragColor.rgb=reflectivityOut.metallicF0;
- #elif DEBUGMODE == 63
- gl_FragColor.rgb=vec3(roughness);
- #elif DEBUGMODE == 64
- gl_FragColor.rgb=vec3(alphaG);
- #elif DEBUGMODE == 65
- gl_FragColor.rgb=vec3(NdotV);
- #elif DEBUGMODE == 66 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT)
- gl_FragColor.rgb=clearcoatOut.clearCoatColor.rgb;
- #define DEBUGMODE_GAMMA
- #elif DEBUGMODE == 67 && defined(CLEARCOAT)
- gl_FragColor.rgb=vec3(clearcoatOut.clearCoatRoughness);
- #elif DEBUGMODE == 68 && defined(CLEARCOAT)
- gl_FragColor.rgb=vec3(clearcoatOut.clearCoatNdotV);
- #elif DEBUGMODE == 69 && defined(SUBSURFACE) && defined(SS_TRANSLUCENCY)
- gl_FragColor.rgb=subSurfaceOut.transmittance;
- #elif DEBUGMODE == 70 && defined(SUBSURFACE) && defined(SS_REFRACTION)
- gl_FragColor.rgb=subSurfaceOut.refractionTransmittance;
- #elif DEBUGMODE == 80 && defined(RADIANCEOCCLUSION)
- gl_FragColor.rgb=vec3(seo);
- #elif DEBUGMODE == 81 && defined(HORIZONOCCLUSION)
- gl_FragColor.rgb=vec3(eho);
- #elif DEBUGMODE == 82 && defined(MS_BRDF_ENERGY_CONSERVATION)
- gl_FragColor.rgb=vec3(energyConservationFactor);
- #elif DEBUGMODE == 83 && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
- gl_FragColor.rgb=specularEnvironmentReflectance;
- #define DEBUGMODE_GAMMA
- #elif DEBUGMODE == 84 && defined(CLEARCOAT) && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
- gl_FragColor.rgb=clearcoatOut.clearCoatEnvironmentReflectance;
- #define DEBUGMODE_GAMMA
- #elif DEBUGMODE == 85 && defined(SHEEN) && defined(REFLECTION)
- gl_FragColor.rgb=sheenOut.sheenEnvironmentReflectance;
- #define DEBUGMODE_GAMMA
- #elif DEBUGMODE == 86 && defined(ALPHABLEND)
- gl_FragColor.rgb=vec3(luminanceOverAlpha);
- #elif DEBUGMODE == 87
- gl_FragColor.rgb=vec3(alpha);
- #endif
- gl_FragColor.rgb*=vDebugMode.y;
- #ifdef DEBUGMODE_NORMALIZE
- gl_FragColor.rgb=normalize(gl_FragColor.rgb)*0.5+0.5;
- #endif
- #ifdef DEBUGMODE_GAMMA
- gl_FragColor.rgb=toGammaSpace(gl_FragColor.rgb);
- #endif
- gl_FragColor.a=1.0;
- #ifdef PREPASS
- gl_FragData[0]=toLinearSpace(gl_FragColor);
- gl_FragData[1]=vec4(0.,0.,0.,0.);
- #endif
- return;
- }
- #endif`;
- ShaderStore.IncludesShadersStore[name$H] = shader$H;
- var name$G = "pbrPixelShader"
- , shader$G = `#if defined(BUMP) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)
- #extension GL_OES_standard_derivatives : enable
- #endif
- #ifdef LODBASEDMICROSFURACE
- #extension GL_EXT_shader_texture_lod : enable
- #endif
- #define CUSTOM_FRAGMENT_BEGIN
- #ifdef LOGARITHMICDEPTH
- #extension GL_EXT_frag_depth : enable
- #endif
- #include<prePassDeclaration>[SCENE_MRT_COUNT]
- precision highp float;
- #include<oitDeclaration>
- #ifndef FROMLINEARSPACE
- #define FROMLINEARSPACE
- #endif
- #include<__decl__pbrFragment>
- #include<pbrFragmentExtraDeclaration>
- #include<__decl__lightFragment>[0..maxSimultaneousLights]
- #include<pbrFragmentSamplersDeclaration>
- #include<imageProcessingDeclaration>
- #include<clipPlaneFragmentDeclaration>
- #include<logDepthDeclaration>
- #include<fogFragmentDeclaration>
- #include<helperFunctions>
- #include<subSurfaceScatteringFunctions>
- #include<importanceSampling>
- #include<pbrHelperFunctions>
- #include<imageProcessingFunctions>
- #include<shadowsFragmentFunctions>
- #include<harmonicsFunctions>
- #include<pbrDirectLightingSetupFunctions>
- #include<pbrDirectLightingFalloffFunctions>
- #include<pbrBRDFFunctions>
- #include<hdrFilteringFunctions>
- #include<pbrDirectLightingFunctions>
- #include<pbrIBLFunctions>
- #include<bumpFragmentMainFunctions>
- #include<bumpFragmentFunctions>
- #ifdef REFLECTION
- #include<reflectionFunction>
- #endif
- #define CUSTOM_FRAGMENT_DEFINITIONS
- #include<pbrBlockAlbedoOpacity>
- #include<pbrBlockReflectivity>
- #include<pbrBlockAmbientOcclusion>
- #include<pbrBlockAlphaFresnel>
- #include<pbrBlockAnisotropic>
- #include<pbrBlockReflection>
- #include<pbrBlockSheen>
- #include<pbrBlockClearcoat>
- #include<pbrBlockSubSurface>
- void main(void) {
- #define CUSTOM_FRAGMENT_MAIN_BEGIN
- #include<oitFragment>
- #include<clipPlaneFragment>
- #include<pbrBlockNormalGeometric>
- #include<bumpFragment>
- #include<pbrBlockNormalFinal>
- albedoOpacityOutParams albedoOpacityOut;
- #ifdef ALBEDO
- vec4 albedoTexture=texture2D(albedoSampler,vAlbedoUV+uvOffset);
- #endif
- #ifdef OPACITY
- vec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);
- #endif
- albedoOpacityBlock(
- vAlbedoColor,
- #ifdef ALBEDO
- albedoTexture,
- vAlbedoInfos,
- #endif
- #ifdef OPACITY
- opacityMap,
- vOpacityInfos,
- #endif
- #ifdef DETAIL
- detailColor,
- vDetailInfos,
- #endif
- albedoOpacityOut
- );
- vec3 surfaceAlbedo=albedoOpacityOut.surfaceAlbedo;
- float alpha=albedoOpacityOut.alpha;
- #define CUSTOM_FRAGMENT_UPDATE_ALPHA
- #include<depthPrePass>
- #define CUSTOM_FRAGMENT_BEFORE_LIGHTS
- ambientOcclusionOutParams aoOut;
- #ifdef AMBIENT
- vec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb;
- #endif
- ambientOcclusionBlock(
- #ifdef AMBIENT
- ambientOcclusionColorMap,
- vAmbientInfos,
- #endif
- aoOut
- );
- #include<pbrBlockLightmapInit>
- #ifdef UNLIT
- vec3 diffuseBase=vec3(1.,1.,1.);
- #else
- vec3 baseColor=surfaceAlbedo;
- reflectivityOutParams reflectivityOut;
- #if defined(REFLECTIVITY)
- vec4 surfaceMetallicOrReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);
- vec4 baseReflectivity=surfaceMetallicOrReflectivityColorMap;
- #ifndef METALLICWORKFLOW
- #ifdef REFLECTIVITY_GAMMA
- surfaceMetallicOrReflectivityColorMap=toLinearSpace(surfaceMetallicOrReflectivityColorMap);
- #endif
- surfaceMetallicOrReflectivityColorMap.rgb*=vReflectivityInfos.y;
- #endif
- #endif
- #if defined(MICROSURFACEMAP)
- vec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;
- #endif
- #ifdef METALLICWORKFLOW
- vec4 metallicReflectanceFactors=vMetallicReflectanceFactors;
- #ifdef REFLECTANCE
- vec4 reflectanceFactorsMap=texture2D(reflectanceSampler,vReflectanceUV+uvOffset);
- #ifdef REFLECTANCE_GAMMA
- reflectanceFactorsMap=toLinearSpace(reflectanceFactorsMap);
- #endif
- metallicReflectanceFactors.rgb*=reflectanceFactorsMap.rgb;
- #endif
- #ifdef METALLIC_REFLECTANCE
- vec4 metallicReflectanceFactorsMap=texture2D(metallicReflectanceSampler,vMetallicReflectanceUV+uvOffset);
- #ifdef METALLIC_REFLECTANCE_GAMMA
- metallicReflectanceFactorsMap=toLinearSpace(metallicReflectanceFactorsMap);
- #endif
- #ifndef METALLIC_REFLECTANCE_USE_ALPHA_ONLY
- metallicReflectanceFactors.rgb*=metallicReflectanceFactorsMap.rgb;
- #endif
- metallicReflectanceFactors*=metallicReflectanceFactorsMap.a;
- #endif
- #endif
- reflectivityBlock(
- vReflectivityColor,
- #ifdef METALLICWORKFLOW
- surfaceAlbedo,
- metallicReflectanceFactors,
- #endif
- #ifdef REFLECTIVITY
- vReflectivityInfos,
- surfaceMetallicOrReflectivityColorMap,
- #endif
- #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
- aoOut.ambientOcclusionColor,
- #endif
- #ifdef MICROSURFACEMAP
- microSurfaceTexel,
- #endif
- #ifdef DETAIL
- detailColor,
- vDetailInfos,
- #endif
- reflectivityOut
- );
- float microSurface=reflectivityOut.microSurface;
- float roughness=reflectivityOut.roughness;
- #ifdef METALLICWORKFLOW
- surfaceAlbedo=reflectivityOut.surfaceAlbedo;
- #endif
- #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
- aoOut.ambientOcclusionColor=reflectivityOut.ambientOcclusionColor;
- #endif
- #ifdef ALPHAFRESNEL
- #if defined(ALPHATEST) || defined(ALPHABLEND)
- alphaFresnelOutParams alphaFresnelOut;
- alphaFresnelBlock(
- normalW,
- viewDirectionW,
- alpha,
- microSurface,
- alphaFresnelOut
- );
- alpha=alphaFresnelOut.alpha;
- #endif
- #endif
- #include<pbrBlockGeometryInfo>
- #ifdef ANISOTROPIC
- anisotropicOutParams anisotropicOut;
- #ifdef ANISOTROPIC_TEXTURE
- vec3 anisotropyMapData=texture2D(anisotropySampler,vAnisotropyUV+uvOffset).rgb*vAnisotropyInfos.y;
- #endif
- anisotropicBlock(
- vAnisotropy,
- #ifdef ANISOTROPIC_TEXTURE
- anisotropyMapData,
- #endif
- TBN,
- normalW,
- viewDirectionW,
- anisotropicOut
- );
- #endif
- #ifdef REFLECTION
- reflectionOutParams reflectionOut;
- reflectionBlock(
- vPositionW,
- normalW,
- alphaG,
- vReflectionMicrosurfaceInfos,
- vReflectionInfos,
- vReflectionColor,
- #ifdef ANISOTROPIC
- anisotropicOut,
- #endif
- #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
- NdotVUnclamped,
- #endif
- #ifdef LINEARSPECULARREFLECTION
- roughness,
- #endif
- reflectionSampler,
- #if defined(NORMAL) && defined(USESPHERICALINVERTEX)
- vEnvironmentIrradiance,
- #endif
- #ifdef USESPHERICALFROMREFLECTIONMAP
- #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
- reflectionMatrix,
- #endif
- #endif
- #ifdef USEIRRADIANCEMAP
- irradianceSampler,
- #endif
- #ifndef LODBASEDMICROSFURACE
- reflectionSamplerLow,
- reflectionSamplerHigh,
- #endif
- #ifdef REALTIME_FILTERING
- vReflectionFilteringInfo,
- #endif
- reflectionOut
- );
- #endif
- #include<pbrBlockReflectance0>
- #ifdef SHEEN
- sheenOutParams sheenOut;
- #ifdef SHEEN_TEXTURE
- vec4 sheenMapData=texture2D(sheenSampler,vSheenUV+uvOffset);
- #endif
- #if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
- vec4 sheenMapRoughnessData=texture2D(sheenRoughnessSampler,vSheenRoughnessUV+uvOffset)*vSheenInfos.w;
- #endif
- sheenBlock(
- vSheenColor,
- #ifdef SHEEN_ROUGHNESS
- vSheenRoughness,
- #if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
- sheenMapRoughnessData,
- #endif
- #endif
- roughness,
- #ifdef SHEEN_TEXTURE
- sheenMapData,
- vSheenInfos.y,
- #endif
- reflectance,
- #ifdef SHEEN_LINKWITHALBEDO
- baseColor,
- surfaceAlbedo,
- #endif
- #ifdef ENVIRONMENTBRDF
- NdotV,
- environmentBrdf,
- #endif
- #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
- AARoughnessFactors,
- vReflectionMicrosurfaceInfos,
- vReflectionInfos,
- vReflectionColor,
- vLightingIntensity,
- reflectionSampler,
- reflectionOut.reflectionCoords,
- NdotVUnclamped,
- #ifndef LODBASEDMICROSFURACE
- reflectionSamplerLow,
- reflectionSamplerHigh,
- #endif
- #ifdef REALTIME_FILTERING
- vReflectionFilteringInfo,
- #endif
- #if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
- seo,
- #endif
- #if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
- eho,
- #endif
- #endif
- sheenOut
- );
- #ifdef SHEEN_LINKWITHALBEDO
- surfaceAlbedo=sheenOut.surfaceAlbedo;
- #endif
- #endif
- clearcoatOutParams clearcoatOut;
- #ifdef CLEARCOAT
- #ifdef CLEARCOAT_TEXTURE
- vec2 clearCoatMapData=texture2D(clearCoatSampler,vClearCoatUV+uvOffset).rg*vClearCoatInfos.y;
- #endif
- #if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
- vec4 clearCoatMapRoughnessData=texture2D(clearCoatRoughnessSampler,vClearCoatRoughnessUV+uvOffset)*vClearCoatInfos.w;
- #endif
- #if defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
- vec4 clearCoatTintMapData=texture2D(clearCoatTintSampler,vClearCoatTintUV+uvOffset);
- #endif
- #ifdef CLEARCOAT_BUMP
- vec4 clearCoatBumpMapData=texture2D(clearCoatBumpSampler,vClearCoatBumpUV+uvOffset);
- #endif
- clearcoatBlock(
- vPositionW,
- geometricNormalW,
- viewDirectionW,
- vClearCoatParams,
- #if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
- clearCoatMapRoughnessData,
- #endif
- specularEnvironmentR0,
- #ifdef CLEARCOAT_TEXTURE
- clearCoatMapData,
- #endif
- #ifdef CLEARCOAT_TINT
- vClearCoatTintParams,
- clearCoatColorAtDistance,
- vClearCoatRefractionParams,
- #ifdef CLEARCOAT_TINT_TEXTURE
- clearCoatTintMapData,
- #endif
- #endif
- #ifdef CLEARCOAT_BUMP
- vClearCoatBumpInfos,
- clearCoatBumpMapData,
- vClearCoatBumpUV,
- #if defined(TANGENT) && defined(NORMAL)
- vTBN,
- #else
- vClearCoatTangentSpaceParams,
- #endif
- #ifdef OBJECTSPACE_NORMALMAP
- normalMatrix,
- #endif
- #endif
- #if defined(FORCENORMALFORWARD) && defined(NORMAL)
- faceNormal,
- #endif
- #ifdef REFLECTION
- vReflectionMicrosurfaceInfos,
- vReflectionInfos,
- vReflectionColor,
- vLightingIntensity,
- reflectionSampler,
- #ifndef LODBASEDMICROSFURACE
- reflectionSamplerLow,
- reflectionSamplerHigh,
- #endif
- #ifdef REALTIME_FILTERING
- vReflectionFilteringInfo,
- #endif
- #endif
- #if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
- #ifdef RADIANCEOCCLUSION
- ambientMonochrome,
- #endif
- #endif
- #if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)
- (gl_FrontFacing ? 1. : -1.),
- #endif
- clearcoatOut
- );
- #else
- clearcoatOut.specularEnvironmentR0=specularEnvironmentR0;
- #endif
- #include<pbrBlockReflectance>
- subSurfaceOutParams subSurfaceOut;
- #ifdef SUBSURFACE
- #ifdef SS_THICKNESSANDMASK_TEXTURE
- vec4 thicknessMap=texture2D(thicknessSampler,vThicknessUV+uvOffset);
- #endif
- #ifdef SS_REFRACTIONINTENSITY_TEXTURE
- vec4 refractionIntensityMap=texture2D(refractionIntensitySampler,vRefractionIntensityUV+uvOffset);
- #endif
- #ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
- vec4 translucencyIntensityMap=texture2D(translucencyIntensitySampler,vTranslucencyIntensityUV+uvOffset);
- #endif
- subSurfaceBlock(
- vSubSurfaceIntensity,
- vThicknessParam,
- vTintColor,
- normalW,
- specularEnvironmentReflectance,
- #ifdef SS_THICKNESSANDMASK_TEXTURE
- thicknessMap,
- #endif
- #ifdef SS_REFRACTIONINTENSITY_TEXTURE
- refractionIntensityMap,
- #endif
- #ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
- translucencyIntensityMap,
- #endif
- #ifdef REFLECTION
- #ifdef SS_TRANSLUCENCY
- reflectionMatrix,
- #ifdef USESPHERICALFROMREFLECTIONMAP
- #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
- reflectionOut.irradianceVector,
- #endif
- #if defined(REALTIME_FILTERING)
- reflectionSampler,
- vReflectionFilteringInfo,
- #endif
- #endif
- #ifdef USEIRRADIANCEMAP
- irradianceSampler,
- #endif
- #endif
- #endif
- #if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)
- surfaceAlbedo,
- #endif
- #ifdef SS_REFRACTION
- vPositionW,
- viewDirectionW,
- view,
- vRefractionInfos,
- refractionMatrix,
- vRefractionMicrosurfaceInfos,
- vLightingIntensity,
- #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
- alpha,
- #endif
- #ifdef SS_LODINREFRACTIONALPHA
- NdotVUnclamped,
- #endif
- #ifdef SS_LINEARSPECULARREFRACTION
- roughness,
- #endif
- alphaG,
- refractionSampler,
- #ifndef LODBASEDMICROSFURACE
- refractionSamplerLow,
- refractionSamplerHigh,
- #endif
- #ifdef ANISOTROPIC
- anisotropicOut,
- #endif
- #ifdef REALTIME_FILTERING
- vRefractionFilteringInfo,
- #endif
- #ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
- vRefractionPosition,
- vRefractionSize,
- #endif
- #endif
- #ifdef SS_TRANSLUCENCY
- vDiffusionDistance,
- #endif
- subSurfaceOut
- );
- #ifdef SS_REFRACTION
- surfaceAlbedo=subSurfaceOut.surfaceAlbedo;
- #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
- alpha=subSurfaceOut.alpha;
- #endif
- #endif
- #else
- subSurfaceOut.specularEnvironmentReflectance=specularEnvironmentReflectance;
- #endif
- #include<pbrBlockDirectLighting>
- #include<lightFragment>[0..maxSimultaneousLights]
- #include<pbrBlockFinalLitComponents>
- #endif
- #include<pbrBlockFinalUnlitComponents>
- #define CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION
- #include<pbrBlockFinalColorComposition>
- #include<logDepthFragment>
- #include<fogFragment>(color,finalColor)
- #include<pbrBlockImageProcessing>
- #define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR
- #ifdef PREPASS
- float writeGeometryInfo=finalColor.a>0.4 ? 1.0 : 0.0;
- #ifdef PREPASS_POSITION
- gl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,writeGeometryInfo);
- #endif
- #ifdef PREPASS_VELOCITY
- vec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;
- vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;
- vec2 velocity=abs(a-b);
- velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;
- gl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,writeGeometryInfo);
- #endif
- #ifdef PREPASS_ALBEDO_SQRT
- vec3 sqAlbedo=sqrt(surfaceAlbedo);
- #endif
- #ifdef PREPASS_IRRADIANCE
- vec3 irradiance=finalDiffuse;
- #ifndef UNLIT
- #ifdef REFLECTION
- irradiance+=finalIrradiance;
- #endif
- #endif
- #ifdef SS_SCATTERING
- gl_FragData[0]=vec4(finalColor.rgb-irradiance,finalColor.a);
- irradiance/=sqAlbedo;
- #else
- gl_FragData[0]=finalColor;
- float scatteringDiffusionProfile=255.;
- #endif
- gl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(clamp(irradiance,vec3(0.),vec3(1.)),writeGeometryInfo*scatteringDiffusionProfile/255.);
- #else
- gl_FragData[0]=vec4(finalColor.rgb,finalColor.a);
- #endif
- #ifdef PREPASS_DEPTH
- gl_FragData[PREPASS_DEPTH_INDEX]=vec4(vViewPos.z,0.0,0.0,writeGeometryInfo);
- #endif
- #ifdef PREPASS_NORMAL
- gl_FragData[PREPASS_NORMAL_INDEX]=vec4((view*vec4(normalW,0.0)).rgb,writeGeometryInfo);
- #endif
- #ifdef PREPASS_ALBEDO_SQRT
- gl_FragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4(sqAlbedo,writeGeometryInfo);
- #endif
- #ifdef PREPASS_REFLECTIVITY
- #if defined(REFLECTIVITY)
- gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(baseReflectivity.rgb,baseReflectivity.a*writeGeometryInfo);
- #else
- gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo);
- #endif
- #endif
- #endif
- #if !defined(PREPASS) || defined(WEBGL2)
- gl_FragColor=finalColor;
- #endif
- #if ORDER_INDEPENDENT_TRANSPARENCY
- if (fragDepth == nearestDepth) {
- frontColor.rgb+=finalColor.rgb*finalColor.a*alphaMultiplier;
- frontColor.a=1.0-alphaMultiplier*(1.0-finalColor.a);
- } else {
- backColor+=finalColor;
- }
- #endif
- #include<pbrDebug>
- }
- `;
- ShaderStore.ShadersStore[name$G] = shader$G;
- var name$F = "pbrVertexDeclaration"
- , shader$F = `uniform mat4 view;
- uniform mat4 viewProjection;
- #ifdef ALBEDO
- uniform mat4 albedoMatrix;
- uniform vec2 vAlbedoInfos;
- #endif
- #ifdef AMBIENT
- uniform mat4 ambientMatrix;
- uniform vec4 vAmbientInfos;
- #endif
- #ifdef OPACITY
- uniform mat4 opacityMatrix;
- uniform vec2 vOpacityInfos;
- #endif
- #ifdef EMISSIVE
- uniform vec2 vEmissiveInfos;
- uniform mat4 emissiveMatrix;
- #endif
- #ifdef LIGHTMAP
- uniform vec2 vLightmapInfos;
- uniform mat4 lightmapMatrix;
- #endif
- #ifdef REFLECTIVITY
- uniform vec3 vReflectivityInfos;
- uniform mat4 reflectivityMatrix;
- #endif
- #ifdef METALLIC_REFLECTANCE
- uniform vec2 vMetallicReflectanceInfos;
- uniform mat4 metallicReflectanceMatrix;
- #endif
- #ifdef REFLECTANCE
- uniform vec2 vReflectanceInfos;
- uniform mat4 reflectanceMatrix;
- #endif
- #ifdef MICROSURFACEMAP
- uniform vec2 vMicroSurfaceSamplerInfos;
- uniform mat4 microSurfaceSamplerMatrix;
- #endif
- #ifdef BUMP
- uniform vec3 vBumpInfos;
- uniform mat4 bumpMatrix;
- #endif
- #ifdef POINTSIZE
- uniform float pointSize;
- #endif
- #ifdef REFLECTION
- uniform vec2 vReflectionInfos;
- uniform mat4 reflectionMatrix;
- #endif
- #ifdef CLEARCOAT
- #if defined(CLEARCOAT_TEXTURE) || defined(CLEARCOAT_TEXTURE_ROUGHNESS)
- uniform vec4 vClearCoatInfos;
- #endif
- #ifdef CLEARCOAT_TEXTURE
- uniform mat4 clearCoatMatrix;
- #endif
- #ifdef CLEARCOAT_TEXTURE_ROUGHNESS
- uniform mat4 clearCoatRoughnessMatrix;
- #endif
- #ifdef CLEARCOAT_BUMP
- uniform vec2 vClearCoatBumpInfos;
- uniform mat4 clearCoatBumpMatrix;
- #endif
- #ifdef CLEARCOAT_TINT_TEXTURE
- uniform vec2 vClearCoatTintInfos;
- uniform mat4 clearCoatTintMatrix;
- #endif
- #endif
- #ifdef ANISOTROPIC
- #ifdef ANISOTROPIC_TEXTURE
- uniform vec2 vAnisotropyInfos;
- uniform mat4 anisotropyMatrix;
- #endif
- #endif
- #ifdef SHEEN
- #if defined(SHEEN_TEXTURE) || defined(SHEEN_TEXTURE_ROUGHNESS)
- uniform vec4 vSheenInfos;
- #endif
- #ifdef SHEEN_TEXTURE
- uniform mat4 sheenMatrix;
- #endif
- #ifdef SHEEN_TEXTURE_ROUGHNESS
- uniform mat4 sheenRoughnessMatrix;
- #endif
- #endif
- #ifdef SUBSURFACE
- #ifdef SS_REFRACTION
- uniform vec4 vRefractionInfos;
- uniform mat4 refractionMatrix;
- #endif
- #ifdef SS_THICKNESSANDMASK_TEXTURE
- uniform vec2 vThicknessInfos;
- uniform mat4 thicknessMatrix;
- #endif
- #ifdef SS_REFRACTIONINTENSITY_TEXTURE
- uniform vec2 vRefractionIntensityInfos;
- uniform mat4 refractionIntensityMatrix;
- #endif
- #ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
- uniform vec2 vTranslucencyIntensityInfos;
- uniform mat4 translucencyIntensityMatrix;
- #endif
- #endif
- #ifdef NORMAL
- #if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
- #ifdef USESPHERICALFROMREFLECTIONMAP
- #ifdef SPHERICAL_HARMONICS
- uniform vec3 vSphericalL00;
- uniform vec3 vSphericalL1_1;
- uniform vec3 vSphericalL10;
- uniform vec3 vSphericalL11;
- uniform vec3 vSphericalL2_2;
- uniform vec3 vSphericalL2_1;
- uniform vec3 vSphericalL20;
- uniform vec3 vSphericalL21;
- uniform vec3 vSphericalL22;
- #else
- uniform vec3 vSphericalX;
- uniform vec3 vSphericalY;
- uniform vec3 vSphericalZ;
- uniform vec3 vSphericalXX_ZZ;
- uniform vec3 vSphericalYY_ZZ;
- uniform vec3 vSphericalZZ;
- uniform vec3 vSphericalXY;
- uniform vec3 vSphericalYZ;
- uniform vec3 vSphericalZX;
- #endif
- #endif
- #endif
- #endif
- #ifdef DETAIL
- uniform vec4 vDetailInfos;
- uniform mat4 detailMatrix;
- #endif`;
- ShaderStore.IncludesShadersStore[name$F] = shader$F;
- var name$E = "pbrVertexShader"
- , shader$E = `precision highp float;
- #include<__decl__pbrVertex>
- #define CUSTOM_VERTEX_BEGIN
- attribute vec3 position;
- #ifdef NORMAL
- attribute vec3 normal;
- #endif
- #ifdef TANGENT
- attribute vec4 tangent;
- #endif
- #ifdef UV1
- attribute vec2 uv;
- #endif
- #include<uvAttributeDeclaration>[2..7]
- #include<mainUVVaryingDeclaration>[1..7]
- #ifdef VERTEXCOLOR
- attribute vec4 color;
- #endif
- #include<helperFunctions>
- #include<bonesDeclaration>
- #include<bakedVertexAnimationDeclaration>
- #include<instancesDeclaration>
- #include<prePassVertexDeclaration>
- #include<samplerVertexDeclaration>(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo)
- #include<samplerVertexDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail)
- #include<samplerVertexDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient)
- #include<samplerVertexDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity)
- #include<samplerVertexDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive)
- #include<samplerVertexDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap)
- #include<samplerVertexDeclaration>(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity)
- #include<samplerVertexDeclaration>(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler)
- #include<samplerVertexDeclaration>(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance)
- #include<samplerVertexDeclaration>(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance)
- #include<samplerVertexDeclaration>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump)
- #ifdef CLEARCOAT
- #include<samplerVertexDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat)
- #include<samplerVertexDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness)
- #include<samplerVertexDeclaration>(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump)
- #include<samplerVertexDeclaration>(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint)
- #endif
- #ifdef SHEEN
- #include<samplerVertexDeclaration>(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen)
- #include<samplerVertexDeclaration>(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness)
- #endif
- #ifdef ANISOTROPIC
- #include<samplerVertexDeclaration>(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy)
- #endif
- #ifdef SUBSURFACE
- #include<samplerVertexDeclaration>(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness)
- #include<samplerVertexDeclaration>(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity)
- #include<samplerVertexDeclaration>(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity)
- #endif
- varying vec3 vPositionW;
- #if DEBUGMODE>0
- varying vec4 vClipSpacePosition;
- #endif
- #ifdef NORMAL
- varying vec3 vNormalW;
- #if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
- varying vec3 vEnvironmentIrradiance;
- #include<harmonicsFunctions>
- #endif
- #endif
- #ifdef VERTEXCOLOR
- varying vec4 vColor;
- #endif
- #include<bumpVertexDeclaration>
- #include<clipPlaneVertexDeclaration>
- #include<fogVertexDeclaration>
- #include<__decl__lightVxFragment>[0..maxSimultaneousLights]
- #include<morphTargetsVertexGlobalDeclaration>
- #include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
- #ifdef REFLECTIONMAP_SKYBOX
- varying vec3 vPositionUVW;
- #endif
- #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
- varying vec3 vDirectionW;
- #endif
- #include<logDepthDeclaration>
- #define CUSTOM_VERTEX_DEFINITIONS
- void main(void) {
- #define CUSTOM_VERTEX_MAIN_BEGIN
- vec3 positionUpdated=position;
- #ifdef NORMAL
- vec3 normalUpdated=normal;
- #endif
- #ifdef TANGENT
- vec4 tangentUpdated=tangent;
- #endif
- #ifdef UV1
- vec2 uvUpdated=uv;
- #endif
- #include<morphTargetsVertexGlobal>
- #include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
- #ifdef REFLECTIONMAP_SKYBOX
- vPositionUVW=positionUpdated;
- #endif
- #define CUSTOM_VERTEX_UPDATE_POSITION
- #define CUSTOM_VERTEX_UPDATE_NORMAL
- #include<instancesVertex>
- #if defined(PREPASS) && defined(PREPASS_VELOCITY) && !defined(BONES_VELOCITY_ENABLED)
- vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);
- vPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0);
- #endif
- #include<bonesVertex>
- #include<bakedVertexAnimation>
- vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);
- vPositionW=vec3(worldPos);
- #include<prePassVertex>
- #ifdef NORMAL
- mat3 normalWorld=mat3(finalWorld);
- #if defined(INSTANCES) && defined(THIN_INSTANCES)
- vNormalW=normalUpdated/vec3(dot(normalWorld[0],normalWorld[0]),dot(normalWorld[1],normalWorld[1]),dot(normalWorld[2],normalWorld[2]));
- vNormalW=normalize(normalWorld*vNormalW);
- #else
- #ifdef NONUNIFORMSCALING
- normalWorld=transposeMat3(inverseMat3(normalWorld));
- #endif
- vNormalW=normalize(normalWorld*normalUpdated);
- #endif
- #if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
- vec3 reflectionVector=vec3(reflectionMatrix*vec4(vNormalW,0)).xyz;
- #ifdef REFLECTIONMAP_OPPOSITEZ
- reflectionVector.z*=-1.0;
- #endif
- vEnvironmentIrradiance=computeEnvironmentIrradiance(reflectionVector);
- #endif
- #endif
- #define CUSTOM_VERTEX_UPDATE_WORLDPOS
- #ifdef MULTIVIEW
- if (gl_ViewID_OVR == 0u) {
- gl_Position=viewProjection*worldPos;
- } else {
- gl_Position=viewProjectionR*worldPos;
- }
- #else
- gl_Position=viewProjection*worldPos;
- #endif
- #if DEBUGMODE>0
- vClipSpacePosition=gl_Position;
- #endif
- #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
- vDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));
- #endif
- #ifndef UV1
- vec2 uvUpdated=vec2(0.,0.);
- #endif
- #ifdef MAINUV1
- vMainUV1=uvUpdated;
- #endif
- #include<uvVariableDeclaration>[2..7]
- #include<samplerVertexImplementation>(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo,_MATRIXNAME_,albedo,_INFONAME_,AlbedoInfos.x)
- #include<samplerVertexImplementation>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_MATRIXNAME_,detail,_INFONAME_,DetailInfos.x)
- #include<samplerVertexImplementation>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_MATRIXNAME_,ambient,_INFONAME_,AmbientInfos.x)
- #include<samplerVertexImplementation>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_MATRIXNAME_,opacity,_INFONAME_,OpacityInfos.x)
- #include<samplerVertexImplementation>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_MATRIXNAME_,emissive,_INFONAME_,EmissiveInfos.x)
- #include<samplerVertexImplementation>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_MATRIXNAME_,lightmap,_INFONAME_,LightmapInfos.x)
- #include<samplerVertexImplementation>(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity,_MATRIXNAME_,reflectivity,_INFONAME_,ReflectivityInfos.x)
- #include<samplerVertexImplementation>(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler,_MATRIXNAME_,microSurfaceSampler,_INFONAME_,MicroSurfaceSamplerInfos.x)
- #include<samplerVertexImplementation>(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance,_MATRIXNAME_,metallicReflectance,_INFONAME_,MetallicReflectanceInfos.x)
- #include<samplerVertexImplementation>(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance,_MATRIXNAME_,reflectance,_INFONAME_,ReflectanceInfos.x)
- #include<samplerVertexImplementation>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_MATRIXNAME_,bump,_INFONAME_,BumpInfos.x)
- #ifdef CLEARCOAT
- #include<samplerVertexImplementation>(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat,_MATRIXNAME_,clearCoat,_INFONAME_,ClearCoatInfos.x)
- #include<samplerVertexImplementation>(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness,_MATRIXNAME_,clearCoatRoughness,_INFONAME_,ClearCoatInfos.z)
- #include<samplerVertexImplementation>(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump,_MATRIXNAME_,clearCoatBump,_INFONAME_,ClearCoatBumpInfos.x)
- #include<samplerVertexImplementation>(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint,_MATRIXNAME_,clearCoatTint,_INFONAME_,ClearCoatTintInfos.x)
- #endif
- #ifdef SHEEN
- #include<samplerVertexImplementation>(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen,_MATRIXNAME_,sheen,_INFONAME_,SheenInfos.x)
- #include<samplerVertexImplementation>(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness,_MATRIXNAME_,sheen,_INFONAME_,SheenInfos.z)
- #endif
- #ifdef ANISOTROPIC
- #include<samplerVertexImplementation>(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy,_MATRIXNAME_,anisotropy,_INFONAME_,AnisotropyInfos.x)
- #endif
- #ifdef SUBSURFACE
- #include<samplerVertexImplementation>(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness,_MATRIXNAME_,thickness,_INFONAME_,ThicknessInfos.x)
- #include<samplerVertexImplementation>(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity,_MATRIXNAME_,refractionIntensity,_INFONAME_,RefractionIntensityInfos.x)
- #include<samplerVertexImplementation>(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity,_MATRIXNAME_,translucencyIntensity,_INFONAME_,TranslucencyIntensityInfos.x)
- #endif
- #include<bumpVertex>
- #include<clipPlaneVertex>
- #include<fogVertex>
- #include<shadowsVertex>[0..maxSimultaneousLights]
- #ifdef VERTEXCOLOR
- vColor=color;
- #endif
- #ifdef POINTSIZE
- gl_PointSize=pointSize;
- #endif
- #include<logDepthVertex>
- #define CUSTOM_VERTEX_MAIN_END
- }`;
- ShaderStore.ShadersStore[name$E] = shader$E;
- var onCreatedEffectParameters = {
- effect: null,
- subMesh: null
- }
- , PBRMaterialDefines = function(a) {
- __extends(e, a);
- function e() {
- var i = a.call(this) || this;
- return i.PBR = !0,
- i.NUM_SAMPLES = "0",
- i.REALTIME_FILTERING = !1,
- i.MAINUV1 = !1,
- i.MAINUV2 = !1,
- i.MAINUV3 = !1,
- i.MAINUV4 = !1,
- i.MAINUV5 = !1,
- i.MAINUV6 = !1,
- i.UV1 = !1,
- i.UV2 = !1,
- i.UV3 = !1,
- i.UV4 = !1,
- i.UV5 = !1,
- i.UV6 = !1,
- i.ALBEDO = !1,
- i.GAMMAALBEDO = !1,
- i.ALBEDODIRECTUV = 0,
- i.VERTEXCOLOR = !1,
- i.DETAIL = !1,
- i.DETAILDIRECTUV = 0,
- i.DETAIL_NORMALBLENDMETHOD = 0,
- i.BAKED_VERTEX_ANIMATION_TEXTURE = !1,
- i.AMBIENT = !1,
- i.AMBIENTDIRECTUV = 0,
- i.AMBIENTINGRAYSCALE = !1,
- i.OPACITY = !1,
- i.VERTEXALPHA = !1,
- i.OPACITYDIRECTUV = 0,
- i.OPACITYRGB = !1,
- i.ALPHATEST = !1,
- i.DEPTHPREPASS = !1,
- i.ALPHABLEND = !1,
- i.ALPHAFROMALBEDO = !1,
- i.ALPHATESTVALUE = "0.5",
- i.SPECULAROVERALPHA = !1,
- i.RADIANCEOVERALPHA = !1,
- i.ALPHAFRESNEL = !1,
- i.LINEARALPHAFRESNEL = !1,
- i.PREMULTIPLYALPHA = !1,
- i.EMISSIVE = !1,
- i.EMISSIVEDIRECTUV = 0,
- i.GAMMAEMISSIVE = !1,
- i.REFLECTIVITY = !1,
- i.REFLECTIVITY_GAMMA = !1,
- i.REFLECTIVITYDIRECTUV = 0,
- i.SPECULARTERM = !1,
- i.MICROSURFACEFROMREFLECTIVITYMAP = !1,
- i.MICROSURFACEAUTOMATIC = !1,
- i.LODBASEDMICROSFURACE = !1,
- i.MICROSURFACEMAP = !1,
- i.MICROSURFACEMAPDIRECTUV = 0,
- i.METALLICWORKFLOW = !1,
- i.ROUGHNESSSTOREINMETALMAPALPHA = !1,
- i.ROUGHNESSSTOREINMETALMAPGREEN = !1,
- i.METALLNESSSTOREINMETALMAPBLUE = !1,
- i.AOSTOREINMETALMAPRED = !1,
- i.METALLIC_REFLECTANCE = !1,
- i.METALLIC_REFLECTANCE_GAMMA = !1,
- i.METALLIC_REFLECTANCEDIRECTUV = 0,
- i.METALLIC_REFLECTANCE_USE_ALPHA_ONLY = !1,
- i.REFLECTANCE = !1,
- i.REFLECTANCE_GAMMA = !1,
- i.REFLECTANCEDIRECTUV = 0,
- i.ENVIRONMENTBRDF = !1,
- i.ENVIRONMENTBRDF_RGBD = !1,
- i.NORMAL = !1,
- i.TANGENT = !1,
- i.BUMP = !1,
- i.BUMPDIRECTUV = 0,
- i.OBJECTSPACE_NORMALMAP = !1,
- i.PARALLAX = !1,
- i.PARALLAXOCCLUSION = !1,
- i.NORMALXYSCALE = !0,
- i.LIGHTMAP = !1,
- i.LIGHTMAPDIRECTUV = 0,
- i.USELIGHTMAPASSHADOWMAP = !1,
- i.GAMMALIGHTMAP = !1,
- i.RGBDLIGHTMAP = !1,
- i.REFLECTION = !1,
- i.REFLECTIONMAP_3D = !1,
- i.REFLECTIONMAP_SPHERICAL = !1,
- i.REFLECTIONMAP_PLANAR = !1,
- i.REFLECTIONMAP_CUBIC = !1,
- i.USE_LOCAL_REFLECTIONMAP_CUBIC = !1,
- i.REFLECTIONMAP_PROJECTION = !1,
- i.REFLECTIONMAP_SKYBOX = !1,
- i.REFLECTIONMAP_EXPLICIT = !1,
- i.REFLECTIONMAP_EQUIRECTANGULAR = !1,
- i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1,
- i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1,
- i.INVERTCUBICMAP = !1,
- i.USESPHERICALFROMREFLECTIONMAP = !1,
- i.USEIRRADIANCEMAP = !1,
- i.SPHERICAL_HARMONICS = !1,
- i.USESPHERICALINVERTEX = !1,
- i.REFLECTIONMAP_OPPOSITEZ = !1,
- i.LODINREFLECTIONALPHA = !1,
- i.GAMMAREFLECTION = !1,
- i.RGBDREFLECTION = !1,
- i.LINEARSPECULARREFLECTION = !1,
- i.RADIANCEOCCLUSION = !1,
- i.HORIZONOCCLUSION = !1,
- i.INSTANCES = !1,
- i.THIN_INSTANCES = !1,
- i.PREPASS = !1,
- i.PREPASS_IRRADIANCE = !1,
- i.PREPASS_IRRADIANCE_INDEX = -1,
- i.PREPASS_ALBEDO_SQRT = !1,
- i.PREPASS_ALBEDO_SQRT_INDEX = -1,
- i.PREPASS_DEPTH = !1,
- i.PREPASS_DEPTH_INDEX = -1,
- i.PREPASS_NORMAL = !1,
- i.PREPASS_NORMAL_INDEX = -1,
- i.PREPASS_POSITION = !1,
- i.PREPASS_POSITION_INDEX = -1,
- i.PREPASS_VELOCITY = !1,
- i.PREPASS_VELOCITY_INDEX = -1,
- i.PREPASS_REFLECTIVITY = !1,
- i.PREPASS_REFLECTIVITY_INDEX = -1,
- i.SCENE_MRT_COUNT = 0,
- i.NUM_BONE_INFLUENCERS = 0,
- i.BonesPerMesh = 0,
- i.BONETEXTURE = !1,
- i.BONES_VELOCITY_ENABLED = !1,
- i.NONUNIFORMSCALING = !1,
- i.MORPHTARGETS = !1,
- i.MORPHTARGETS_NORMAL = !1,
- i.MORPHTARGETS_TANGENT = !1,
- i.MORPHTARGETS_UV = !1,
- i.NUM_MORPH_INFLUENCERS = 0,
- i.MORPHTARGETS_TEXTURE = !1,
- i.IMAGEPROCESSING = !1,
- i.VIGNETTE = !1,
- i.VIGNETTEBLENDMODEMULTIPLY = !1,
- i.VIGNETTEBLENDMODEOPAQUE = !1,
- i.TONEMAPPING = !1,
- i.TONEMAPPING_ACES = !1,
- i.CONTRAST = !1,
- i.COLORCURVES = !1,
- i.COLORGRADING = !1,
- i.COLORGRADING3D = !1,
- i.SAMPLER3DGREENDEPTH = !1,
- i.SAMPLER3DBGRMAP = !1,
- i.IMAGEPROCESSINGPOSTPROCESS = !1,
- i.SKIPFINALCOLORCLAMP = !1,
- i.EXPOSURE = !1,
- i.MULTIVIEW = !1,
- i.ORDER_INDEPENDENT_TRANSPARENCY = !1,
- i.ORDER_INDEPENDENT_TRANSPARENCY_16BITS = !1,
- i.USEPHYSICALLIGHTFALLOFF = !1,
- i.USEGLTFLIGHTFALLOFF = !1,
- i.TWOSIDEDLIGHTING = !1,
- i.SHADOWFLOAT = !1,
- i.CLIPPLANE = !1,
- i.CLIPPLANE2 = !1,
- i.CLIPPLANE3 = !1,
- i.CLIPPLANE4 = !1,
- i.CLIPPLANE5 = !1,
- i.CLIPPLANE6 = !1,
- i.POINTSIZE = !1,
- i.FOG = !1,
- i.LOGARITHMICDEPTH = !1,
- i.FORCENORMALFORWARD = !1,
- i.SPECULARAA = !1,
- i.CLEARCOAT = !1,
- i.CLEARCOAT_DEFAULTIOR = !1,
- i.CLEARCOAT_TEXTURE = !1,
- i.CLEARCOAT_TEXTURE_ROUGHNESS = !1,
- i.CLEARCOAT_TEXTUREDIRECTUV = 0,
- i.CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV = 0,
- i.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE = !1,
- i.CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL = !1,
- i.CLEARCOAT_BUMP = !1,
- i.CLEARCOAT_BUMPDIRECTUV = 0,
- i.CLEARCOAT_REMAP_F0 = !0,
- i.CLEARCOAT_TINT = !1,
- i.CLEARCOAT_TINT_TEXTURE = !1,
- i.CLEARCOAT_TINT_GAMMATEXTURE = !1,
- i.CLEARCOAT_TINT_TEXTUREDIRECTUV = 0,
- i.ANISOTROPIC = !1,
- i.ANISOTROPIC_TEXTURE = !1,
- i.ANISOTROPIC_TEXTUREDIRECTUV = 0,
- i.BRDF_V_HEIGHT_CORRELATED = !1,
- i.MS_BRDF_ENERGY_CONSERVATION = !1,
- i.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION = !1,
- i.SHEEN = !1,
- i.SHEEN_TEXTURE = !1,
- i.SHEEN_GAMMATEXTURE = !1,
- i.SHEEN_TEXTURE_ROUGHNESS = !1,
- i.SHEEN_TEXTUREDIRECTUV = 0,
- i.SHEEN_TEXTURE_ROUGHNESSDIRECTUV = 0,
- i.SHEEN_LINKWITHALBEDO = !1,
- i.SHEEN_ROUGHNESS = !1,
- i.SHEEN_ALBEDOSCALING = !1,
- i.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE = !1,
- i.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL = !1,
- i.SUBSURFACE = !1,
- i.SS_REFRACTION = !1,
- i.SS_REFRACTION_USE_INTENSITY_FROM_TEXTURE = !1,
- i.SS_TRANSLUCENCY = !1,
- i.SS_TRANSLUCENCY_USE_INTENSITY_FROM_TEXTURE = !1,
- i.SS_SCATTERING = !1,
- i.SS_THICKNESSANDMASK_TEXTURE = !1,
- i.SS_THICKNESSANDMASK_TEXTUREDIRECTUV = 0,
- i.SS_HAS_THICKNESS = !1,
- i.SS_REFRACTIONINTENSITY_TEXTURE = !1,
- i.SS_REFRACTIONINTENSITY_TEXTUREDIRECTUV = 0,
- i.SS_TRANSLUCENCYINTENSITY_TEXTURE = !1,
- i.SS_TRANSLUCENCYINTENSITY_TEXTUREDIRECTUV = 0,
- i.SS_REFRACTIONMAP_3D = !1,
- i.SS_REFRACTIONMAP_OPPOSITEZ = !1,
- i.SS_LODINREFRACTIONALPHA = !1,
- i.SS_GAMMAREFRACTION = !1,
- i.SS_RGBDREFRACTION = !1,
- i.SS_LINEARSPECULARREFRACTION = !1,
- i.SS_LINKREFRACTIONTOTRANSPARENCY = !1,
- i.SS_ALBEDOFORREFRACTIONTINT = !1,
- i.SS_ALBEDOFORTRANSLUCENCYTINT = !1,
- i.SS_USE_LOCAL_REFRACTIONMAP_CUBIC = !1,
- i.SS_USE_THICKNESS_AS_DEPTH = !1,
- i.SS_MASK_FROM_THICKNESS_TEXTURE = !1,
- i.SS_USE_GLTF_TEXTURES = !1,
- i.UNLIT = !1,
- i.DEBUGMODE = 0,
- i.rebuild(),
- i
- }
- return e.prototype.reset = function() {
- a.prototype.reset.call(this),
- this.ALPHATESTVALUE = "0.5",
- this.PBR = !0,
- this.NORMALXYSCALE = !0
- }
- ,
- e
- }(MaterialDefines)
- , PBRBaseMaterial = function(a) {
- __extends(e, a);
- function e(i, o) {
- var s = a.call(this, i, o) || this;
- return s._directIntensity = 1,
- s._emissiveIntensity = 1,
- s._environmentIntensity = 1,
- s._specularIntensity = 1,
- s._lightingInfos = new Vector4(s._directIntensity,s._emissiveIntensity,s._environmentIntensity,s._specularIntensity),
- s._disableBumpMap = !1,
- s._albedoTexture = null,
- s._ambientTexture = null,
- s._ambientTextureStrength = 1,
- s._ambientTextureImpactOnAnalyticalLights = e.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,
- s._opacityTexture = null,
- s._reflectionTexture = null,
- s._emissiveTexture = null,
- s._reflectivityTexture = null,
- s._metallicTexture = null,
- s._metallic = null,
- s._roughness = null,
- s._metallicF0Factor = 1,
- s._metallicReflectanceColor = Color3.White(),
- s._useOnlyMetallicFromMetallicReflectanceTexture = !1,
- s._metallicReflectanceTexture = null,
- s._reflectanceTexture = null,
- s._microSurfaceTexture = null,
- s._bumpTexture = null,
- s._lightmapTexture = null,
- s._ambientColor = new Color3(0,0,0),
- s._albedoColor = new Color3(1,1,1),
- s._reflectivityColor = new Color3(1,1,1),
- s._reflectionColor = new Color3(1,1,1),
- s._emissiveColor = new Color3(0,0,0),
- s._microSurface = .9,
- s._useLightmapAsShadowmap = !1,
- s._useHorizonOcclusion = !0,
- s._useRadianceOcclusion = !0,
- s._useAlphaFromAlbedoTexture = !1,
- s._useSpecularOverAlpha = !0,
- s._useMicroSurfaceFromReflectivityMapAlpha = !1,
- s._useRoughnessFromMetallicTextureAlpha = !0,
- s._useRoughnessFromMetallicTextureGreen = !1,
- s._useMetallnessFromMetallicTextureBlue = !1,
- s._useAmbientOcclusionFromMetallicTextureRed = !1,
- s._useAmbientInGrayScale = !1,
- s._useAutoMicroSurfaceFromReflectivityMap = !1,
- s._lightFalloff = e.LIGHTFALLOFF_PHYSICAL,
- s._useRadianceOverAlpha = !0,
- s._useObjectSpaceNormalMap = !1,
- s._useParallax = !1,
- s._useParallaxOcclusion = !1,
- s._parallaxScaleBias = .05,
- s._disableLighting = !1,
- s._maxSimultaneousLights = 4,
- s._invertNormalMapX = !1,
- s._invertNormalMapY = !1,
- s._twoSidedLighting = !1,
- s._alphaCutOff = .4,
- s._forceAlphaTest = !1,
- s._useAlphaFresnel = !1,
- s._useLinearAlphaFresnel = !1,
- s._environmentBRDFTexture = null,
- s._forceIrradianceInFragment = !1,
- s._realTimeFiltering = !1,
- s._realTimeFilteringQuality = 8,
- s._forceNormalForward = !1,
- s._enableSpecularAntiAliasing = !1,
- s._imageProcessingObserver = null,
- s._renderTargets = new SmartArray(16),
- s._globalAmbientColor = new Color3(0,0,0),
- s._useLogarithmicDepth = !1,
- s._unlit = !1,
- s._debugMode = 0,
- s.debugMode = 0,
- s.debugLimit = -1,
- s.debugFactor = 1,
- s.clearCoat = new PBRClearCoatConfiguration(s._markAllSubMeshesAsTexturesDirty.bind(s)),
- s.anisotropy = new PBRAnisotropicConfiguration(s._markAllSubMeshesAsTexturesDirty.bind(s)),
- s.brdf = new PBRBRDFConfiguration(s._markAllSubMeshesAsMiscDirty.bind(s)),
- s.sheen = new PBRSheenConfiguration(s._markAllSubMeshesAsTexturesDirty.bind(s)),
- s.detailMap = new DetailMapConfiguration(s._markAllSubMeshesAsTexturesDirty.bind(s)),
- s.buildUniformLayout(),
- s._attachImageProcessingConfiguration(null),
- s.getRenderTargetTextures = function() {
- return s._renderTargets.reset(),
- MaterialFlags.ReflectionTextureEnabled && s._reflectionTexture && s._reflectionTexture.isRenderTarget && s._renderTargets.push(s._reflectionTexture),
- s.subSurface.fillRenderTargetTextures(s._renderTargets),
- s._renderTargets
- }
- ,
- s._environmentBRDFTexture = GetEnvironmentBRDFTexture(o),
- s.subSurface = new PBRSubSurfaceConfiguration(s._markAllSubMeshesAsTexturesDirty.bind(s),s._markScenePrePassDirty.bind(s),o),
- s.prePassConfiguration = new PrePassConfiguration,
- s
- }
- return Object.defineProperty(e.prototype, "realTimeFiltering", {
- get: function() {
- return this._realTimeFiltering
- },
- set: function(i) {
- this._realTimeFiltering = i,
- this.markAsDirty(1)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "realTimeFilteringQuality", {
- get: function() {
- return this._realTimeFilteringQuality
- },
- set: function(i) {
- this._realTimeFilteringQuality = i,
- this.markAsDirty(1)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "canRenderToMRT", {
- get: function() {
- return !0
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._attachImageProcessingConfiguration = function(i) {
- var o = this;
- i !== this._imageProcessingConfiguration && (this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
- i ? this._imageProcessingConfiguration = i : this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration,
- this._imageProcessingConfiguration && (this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function() {
- o._markAllSubMeshesAsImageProcessingDirty()
- })))
- }
- ,
- Object.defineProperty(e.prototype, "hasRenderTargetTextures", {
- get: function() {
- return MaterialFlags.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget ? !0 : this.subSurface.hasRenderTargetTextures()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isPrePassCapable", {
- get: function() {
- return !this.disableDepthWrite
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getClassName = function() {
- return "PBRBaseMaterial"
- }
- ,
- Object.defineProperty(e.prototype, "useLogarithmicDepth", {
- get: function() {
- return this._useLogarithmicDepth
- },
- set: function(i) {
- this._useLogarithmicDepth = i && this.getScene().getEngine().getCaps().fragmentDepthSupported
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "_disableAlphaBlending", {
- get: function() {
- return this.subSurface.disableAlphaBlending || this._transparencyMode === e.PBRMATERIAL_OPAQUE || this._transparencyMode === e.PBRMATERIAL_ALPHATEST
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.needAlphaBlending = function() {
- return this._disableAlphaBlending ? !1 : this.alpha < 1 || this._opacityTexture != null || this._shouldUseAlphaFromAlbedoTexture()
- }
- ,
- e.prototype.needAlphaTesting = function() {
- return this._forceAlphaTest ? !0 : this.subSurface.disableAlphaBlending ? !1 : this._hasAlphaChannel() && (this._transparencyMode == null || this._transparencyMode === e.PBRMATERIAL_ALPHATEST)
- }
- ,
- e.prototype._shouldUseAlphaFromAlbedoTexture = function() {
- return this._albedoTexture != null && this._albedoTexture.hasAlpha && this._useAlphaFromAlbedoTexture && this._transparencyMode !== e.PBRMATERIAL_OPAQUE
- }
- ,
- e.prototype._hasAlphaChannel = function() {
- return this._albedoTexture != null && this._albedoTexture.hasAlpha || this._opacityTexture != null
- }
- ,
- e.prototype.getAlphaTestTexture = function() {
- return this._albedoTexture
- }
- ,
- e.prototype.isReadyForSubMesh = function(i, o, s) {
- if (o.effect && this.isFrozen && o.effect._wasPreviouslyReady)
- return !0;
- o.materialDefines || (o.materialDefines = new PBRMaterialDefines);
- var c = o.materialDefines;
- if (this._isReadyForSubMesh(o))
- return !0;
- var d = this.getScene()
- , _ = d.getEngine();
- if (c._areTexturesDirty && d.texturesEnabled) {
- if (this._albedoTexture && MaterialFlags.DiffuseTextureEnabled && !this._albedoTexture.isReadyOrNotBlocking() || this._ambientTexture && MaterialFlags.AmbientTextureEnabled && !this._ambientTexture.isReadyOrNotBlocking() || this._opacityTexture && MaterialFlags.OpacityTextureEnabled && !this._opacityTexture.isReadyOrNotBlocking())
- return !1;
- var b = this._getReflectionTexture();
- 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())
- return !1;
- if (MaterialFlags.SpecularTextureEnabled) {
- if (this._metallicTexture) {
- if (!this._metallicTexture.isReadyOrNotBlocking())
- return !1
- } else if (this._reflectivityTexture && !this._reflectivityTexture.isReadyOrNotBlocking())
- return !1;
- if (this._metallicReflectanceTexture && !this._metallicReflectanceTexture.isReadyOrNotBlocking() || this._reflectanceTexture && !this._reflectanceTexture.isReadyOrNotBlocking() || this._microSurfaceTexture && !this._microSurfaceTexture.isReadyOrNotBlocking())
- return !1
- }
- if (_.getCaps().standardDerivatives && this._bumpTexture && MaterialFlags.BumpTextureEnabled && !this._disableBumpMap && !this._bumpTexture.isReady() || this._environmentBRDFTexture && MaterialFlags.ReflectionTextureEnabled && !this._environmentBRDFTexture.isReady())
- return !1
- }
- 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())
- return !1;
- !_.getCaps().standardDerivatives && !i.isVerticesDataPresent(VertexBuffer.NormalKind) && (i.createNormals(!0),
- Logger$2.Warn("PBRMaterial: Normals have been created for the mesh: " + i.name));
- var k = o.effect
- , j = c._areLightsDisposed
- , $ = this._prepareEffect(i, c, this.onCompiled, this.onError, s, null, o.getRenderingMesh().hasThinInstances);
- if ($)
- if (this._onEffectCreatedObservable && (onCreatedEffectParameters.effect = $,
- onCreatedEffectParameters.subMesh = o,
- this._onEffectCreatedObservable.notifyObservers(onCreatedEffectParameters)),
- this.allowShaderHotSwapping && k && !$.isReady()) {
- if ($ = k,
- c.markAsUnprocessed(),
- j)
- return c._areLightsDisposed = !0,
- !1
- } else
- d.resetCachedMaterial(),
- o.setEffect($, c, this._materialContext);
- return !o.effect || !o.effect.isReady() ? !1 : (c._renderId = d.getRenderId(),
- o.effect._wasPreviouslyReady = !0,
- !0)
- }
- ,
- e.prototype.isMetallicWorkflow = function() {
- return !!(this._metallic != null || this._roughness != null || this._metallicTexture)
- }
- ,
- e.prototype._prepareEffect = function(i, o, s, c, d, _, b) {
- if (s === void 0 && (s = null),
- c === void 0 && (c = null),
- d === void 0 && (d = null),
- _ === void 0 && (_ = null),
- this._prepareDefines(i, o, d, _, b),
- !o.isDirty)
- return null;
- o.markAsProcessed();
- var k = this.getScene()
- , j = k.getEngine()
- , $ = new EffectFallbacks
- , _e = 0;
- o.USESPHERICALINVERTEX && $.addFallback(_e++, "USESPHERICALINVERTEX"),
- o.FOG && $.addFallback(_e, "FOG"),
- o.SPECULARAA && $.addFallback(_e, "SPECULARAA"),
- o.POINTSIZE && $.addFallback(_e, "POINTSIZE"),
- o.LOGARITHMICDEPTH && $.addFallback(_e, "LOGARITHMICDEPTH"),
- o.PARALLAX && $.addFallback(_e, "PARALLAX"),
- o.PARALLAXOCCLUSION && $.addFallback(_e++, "PARALLAXOCCLUSION"),
- _e = PBRClearCoatConfiguration.AddFallbacks(o, $, _e),
- _e = PBRAnisotropicConfiguration.AddFallbacks(o, $, _e),
- _e = PBRSubSurfaceConfiguration.AddFallbacks(o, $, _e),
- _e = PBRSheenConfiguration.AddFallbacks(o, $, _e),
- o.ENVIRONMENTBRDF && $.addFallback(_e++, "ENVIRONMENTBRDF"),
- o.TANGENT && $.addFallback(_e++, "TANGENT"),
- o.BUMP && $.addFallback(_e++, "BUMP"),
- _e = MaterialHelper.HandleFallbacksForShadows(o, $, this._maxSimultaneousLights, _e++),
- o.SPECULARTERM && $.addFallback(_e++, "SPECULARTERM"),
- o.USESPHERICALFROMREFLECTIONMAP && $.addFallback(_e++, "USESPHERICALFROMREFLECTIONMAP"),
- o.USEIRRADIANCEMAP && $.addFallback(_e++, "USEIRRADIANCEMAP"),
- o.LIGHTMAP && $.addFallback(_e++, "LIGHTMAP"),
- o.NORMAL && $.addFallback(_e++, "NORMAL"),
- o.AMBIENT && $.addFallback(_e++, "AMBIENT"),
- o.EMISSIVE && $.addFallback(_e++, "EMISSIVE"),
- o.VERTEXCOLOR && $.addFallback(_e++, "VERTEXCOLOR"),
- o.MORPHTARGETS && $.addFallback(_e++, "MORPHTARGETS"),
- o.MULTIVIEW && $.addFallback(0, "MULTIVIEW");
- var et = [VertexBuffer.PositionKind];
- o.NORMAL && et.push(VertexBuffer.NormalKind),
- o.TANGENT && et.push(VertexBuffer.TangentKind);
- for (var tt = 1; tt <= 6; ++tt)
- o["UV" + tt] && et.push("uv" + (tt === 1 ? "" : tt));
- o.VERTEXCOLOR && et.push(VertexBuffer.ColorKind),
- MaterialHelper.PrepareAttributesForBones(et, i, o, $),
- MaterialHelper.PrepareAttributesForInstances(et, o),
- MaterialHelper.PrepareAttributesForMorphTargets(et, i, o),
- MaterialHelper.PrepareAttributesForBakedVertexAnimation(et, i, o);
- var rt = "pbr"
- , 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"]
- , nt = ["albedoSampler", "reflectivitySampler", "ambientSampler", "emissiveSampler", "bumpSampler", "lightmapSampler", "opacitySampler", "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh", "irradianceSampler", "microSurfaceSampler", "environmentBrdfSampler", "boneSampler", "metallicReflectanceSampler", "reflectanceSampler", "morphTargets", "oitDepthSampler", "oitFrontColorSampler"]
- , ot = ["Material", "Scene", "Mesh"];
- DetailMapConfiguration.AddUniforms(it),
- DetailMapConfiguration.AddSamplers(nt),
- PBRSubSurfaceConfiguration.AddUniforms(it),
- PBRSubSurfaceConfiguration.AddSamplers(nt),
- PBRClearCoatConfiguration.AddUniforms(it),
- PBRClearCoatConfiguration.AddSamplers(nt),
- PBRAnisotropicConfiguration.AddUniforms(it),
- PBRAnisotropicConfiguration.AddSamplers(nt),
- PBRSheenConfiguration.AddUniforms(it),
- PBRSheenConfiguration.AddSamplers(nt),
- PrePassConfiguration.AddUniforms(it),
- PrePassConfiguration.AddSamplers(nt),
- ImageProcessingConfiguration && (ImageProcessingConfiguration.PrepareUniforms(it, o),
- ImageProcessingConfiguration.PrepareSamplers(nt, o)),
- MaterialHelper.PrepareUniformsAndSamplersList({
- uniformsNames: it,
- uniformBuffersNames: ot,
- samplers: nt,
- defines: o,
- maxSimultaneousLights: this._maxSimultaneousLights
- });
- var at = {};
- this.customShaderNameResolve && (rt = this.customShaderNameResolve(rt, it, ot, nt, o, et, at));
- var st = o.toString();
- return j.createEffect(rt, {
- attributes: et,
- uniformsNames: it,
- uniformBuffersNames: ot,
- samplers: nt,
- defines: st,
- fallbacks: $,
- onCompiled: s,
- onError: c,
- indexParameters: {
- maxSimultaneousLights: this._maxSimultaneousLights,
- maxSimultaneousMorphTargets: o.NUM_MORPH_INFLUENCERS
- },
- processFinalCode: at.processFinalCode,
- multiTarget: o.PREPASS
- }, j)
- }
- ,
- e.prototype._prepareDefines = function(i, o, s, c, d) {
- var _;
- s === void 0 && (s = null),
- c === void 0 && (c = null),
- d === void 0 && (d = !1);
- var b = this.getScene()
- , k = b.getEngine();
- MaterialHelper.PrepareDefinesForLights(b, i, o, !0, this._maxSimultaneousLights, this._disableLighting),
- o._needNormals = !0,
- MaterialHelper.PrepareDefinesForMultiview(b, o);
- var j = this.needAlphaBlendingForMesh(i) && this.getScene().useOrderIndependentTransparency;
- if (MaterialHelper.PrepareDefinesForPrePass(b, o, this.canRenderToMRT && !j),
- MaterialHelper.PrepareDefinesForOIT(b, o, j),
- o.METALLICWORKFLOW = this.isMetallicWorkflow(),
- o._areTexturesDirty) {
- if (o._needUVs = !1,
- b.texturesEnabled) {
- b.getEngine().getCaps().textureLOD && (o.LODBASEDMICROSFURACE = !0),
- this._albedoTexture && MaterialFlags.DiffuseTextureEnabled ? (MaterialHelper.PrepareDefinesForMergedUV(this._albedoTexture, o, "ALBEDO"),
- o.GAMMAALBEDO = this._albedoTexture.gammaSpace) : o.ALBEDO = !1,
- this._ambientTexture && MaterialFlags.AmbientTextureEnabled ? (MaterialHelper.PrepareDefinesForMergedUV(this._ambientTexture, o, "AMBIENT"),
- o.AMBIENTINGRAYSCALE = this._useAmbientInGrayScale) : o.AMBIENT = !1,
- this._opacityTexture && MaterialFlags.OpacityTextureEnabled ? (MaterialHelper.PrepareDefinesForMergedUV(this._opacityTexture, o, "OPACITY"),
- o.OPACITYRGB = this._opacityTexture.getAlphaFromRGB) : o.OPACITY = !1;
- var $ = this._getReflectionTexture();
- if ($ && MaterialFlags.ReflectionTextureEnabled) {
- switch (o.REFLECTION = !0,
- o.GAMMAREFLECTION = $.gammaSpace,
- o.RGBDREFLECTION = $.isRGBD,
- o.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !$.invertZ : $.invertZ,
- o.LODINREFLECTIONALPHA = $.lodLevelInAlpha,
- o.LINEARSPECULARREFLECTION = $.linearSpecularLOD,
- this.realTimeFiltering && this.realTimeFilteringQuality > 0 ? (o.NUM_SAMPLES = "" + this.realTimeFilteringQuality,
- k._features.needTypeSuffixInShaderConstants && (o.NUM_SAMPLES = o.NUM_SAMPLES + "u"),
- o.REALTIME_FILTERING = !0) : o.REALTIME_FILTERING = !1,
- $.coordinatesMode === Texture.INVCUBIC_MODE && (o.INVERTCUBICMAP = !0),
- o.REFLECTIONMAP_3D = $.isCube,
- o.REFLECTIONMAP_CUBIC = !1,
- o.REFLECTIONMAP_EXPLICIT = !1,
- o.REFLECTIONMAP_PLANAR = !1,
- o.REFLECTIONMAP_PROJECTION = !1,
- o.REFLECTIONMAP_SKYBOX = !1,
- o.REFLECTIONMAP_SPHERICAL = !1,
- o.REFLECTIONMAP_EQUIRECTANGULAR = !1,
- o.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1,
- o.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1,
- $.coordinatesMode) {
- case Texture.EXPLICIT_MODE:
- o.REFLECTIONMAP_EXPLICIT = !0;
- break;
- case Texture.PLANAR_MODE:
- o.REFLECTIONMAP_PLANAR = !0;
- break;
- case Texture.PROJECTION_MODE:
- o.REFLECTIONMAP_PROJECTION = !0;
- break;
- case Texture.SKYBOX_MODE:
- o.REFLECTIONMAP_SKYBOX = !0;
- break;
- case Texture.SPHERICAL_MODE:
- o.REFLECTIONMAP_SPHERICAL = !0;
- break;
- case Texture.EQUIRECTANGULAR_MODE:
- o.REFLECTIONMAP_EQUIRECTANGULAR = !0;
- break;
- case Texture.FIXED_EQUIRECTANGULAR_MODE:
- o.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !0;
- break;
- case Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
- o.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !0;
- break;
- case Texture.CUBIC_MODE:
- case Texture.INVCUBIC_MODE:
- default:
- o.REFLECTIONMAP_CUBIC = !0,
- o.USE_LOCAL_REFLECTIONMAP_CUBIC = !!$.boundingBoxSize;
- break
- }
- $.coordinatesMode !== Texture.SKYBOX_MODE && ($.irradianceTexture ? (o.USEIRRADIANCEMAP = !0,
- o.USESPHERICALFROMREFLECTIONMAP = !1) : $.isCube && (o.USESPHERICALFROMREFLECTIONMAP = !0,
- o.USEIRRADIANCEMAP = !1,
- this._forceIrradianceInFragment || this.realTimeFiltering || b.getEngine().getCaps().maxVaryingVectors <= 8 ? o.USESPHERICALINVERTEX = !1 : o.USESPHERICALINVERTEX = !0))
- } else
- o.REFLECTION = !1,
- o.REFLECTIONMAP_3D = !1,
- o.REFLECTIONMAP_SPHERICAL = !1,
- o.REFLECTIONMAP_PLANAR = !1,
- o.REFLECTIONMAP_CUBIC = !1,
- o.USE_LOCAL_REFLECTIONMAP_CUBIC = !1,
- o.REFLECTIONMAP_PROJECTION = !1,
- o.REFLECTIONMAP_SKYBOX = !1,
- o.REFLECTIONMAP_EXPLICIT = !1,
- o.REFLECTIONMAP_EQUIRECTANGULAR = !1,
- o.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1,
- o.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1,
- o.INVERTCUBICMAP = !1,
- o.USESPHERICALFROMREFLECTIONMAP = !1,
- o.USEIRRADIANCEMAP = !1,
- o.USESPHERICALINVERTEX = !1,
- o.REFLECTIONMAP_OPPOSITEZ = !1,
- o.LODINREFLECTIONALPHA = !1,
- o.GAMMAREFLECTION = !1,
- o.RGBDREFLECTION = !1,
- o.LINEARSPECULARREFLECTION = !1;
- if (this._lightmapTexture && MaterialFlags.LightmapTextureEnabled ? (MaterialHelper.PrepareDefinesForMergedUV(this._lightmapTexture, o, "LIGHTMAP"),
- o.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap,
- o.GAMMALIGHTMAP = this._lightmapTexture.gammaSpace,
- o.RGBDLIGHTMAP = this._lightmapTexture.isRGBD) : o.LIGHTMAP = !1,
- this._emissiveTexture && MaterialFlags.EmissiveTextureEnabled ? (MaterialHelper.PrepareDefinesForMergedUV(this._emissiveTexture, o, "EMISSIVE"),
- o.GAMMAEMISSIVE = this._emissiveTexture.gammaSpace) : o.EMISSIVE = !1,
- MaterialFlags.SpecularTextureEnabled) {
- if (this._metallicTexture ? (MaterialHelper.PrepareDefinesForMergedUV(this._metallicTexture, o, "REFLECTIVITY"),
- o.ROUGHNESSSTOREINMETALMAPALPHA = this._useRoughnessFromMetallicTextureAlpha,
- o.ROUGHNESSSTOREINMETALMAPGREEN = !this._useRoughnessFromMetallicTextureAlpha && this._useRoughnessFromMetallicTextureGreen,
- o.METALLNESSSTOREINMETALMAPBLUE = this._useMetallnessFromMetallicTextureBlue,
- o.AOSTOREINMETALMAPRED = this._useAmbientOcclusionFromMetallicTextureRed,
- o.REFLECTIVITY_GAMMA = !1) : this._reflectivityTexture ? (MaterialHelper.PrepareDefinesForMergedUV(this._reflectivityTexture, o, "REFLECTIVITY"),
- o.MICROSURFACEFROMREFLECTIVITYMAP = this._useMicroSurfaceFromReflectivityMapAlpha,
- o.MICROSURFACEAUTOMATIC = this._useAutoMicroSurfaceFromReflectivityMap,
- o.REFLECTIVITY_GAMMA = this._reflectivityTexture.gammaSpace) : o.REFLECTIVITY = !1,
- this._metallicReflectanceTexture || this._reflectanceTexture) {
- var _e = this._metallicReflectanceTexture !== null && this._metallicReflectanceTexture._texture === ((_ = this._reflectanceTexture) === null || _ === void 0 ? void 0 : _._texture) && this._metallicReflectanceTexture.checkTransformsAreIdentical(this._reflectanceTexture);
- o.METALLIC_REFLECTANCE_USE_ALPHA_ONLY = this._useOnlyMetallicFromMetallicReflectanceTexture && !_e,
- this._metallicReflectanceTexture ? (MaterialHelper.PrepareDefinesForMergedUV(this._metallicReflectanceTexture, o, "METALLIC_REFLECTANCE"),
- o.METALLIC_REFLECTANCE_GAMMA = this._metallicReflectanceTexture.gammaSpace) : o.METALLIC_REFLECTANCE = !1,
- this._reflectanceTexture && !_e && (!this._metallicReflectanceTexture || this._metallicReflectanceTexture && this._useOnlyMetallicFromMetallicReflectanceTexture) ? (MaterialHelper.PrepareDefinesForMergedUV(this._reflectanceTexture, o, "REFLECTANCE"),
- o.REFLECTANCE_GAMMA = this._reflectanceTexture.gammaSpace) : o.REFLECTANCE = !1
- } else
- o.METALLIC_REFLECTANCE = !1,
- o.REFLECTANCE = !1;
- this._microSurfaceTexture ? MaterialHelper.PrepareDefinesForMergedUV(this._microSurfaceTexture, o, "MICROSURFACEMAP") : o.MICROSURFACEMAP = !1
- } else
- o.REFLECTIVITY = !1,
- o.MICROSURFACEMAP = !1;
- b.getEngine().getCaps().standardDerivatives && this._bumpTexture && MaterialFlags.BumpTextureEnabled && !this._disableBumpMap ? (MaterialHelper.PrepareDefinesForMergedUV(this._bumpTexture, o, "BUMP"),
- this._useParallax && this._albedoTexture && MaterialFlags.DiffuseTextureEnabled ? (o.PARALLAX = !0,
- o.PARALLAXOCCLUSION = !!this._useParallaxOcclusion) : o.PARALLAX = !1,
- o.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap) : o.BUMP = !1,
- this._environmentBRDFTexture && MaterialFlags.ReflectionTextureEnabled ? (o.ENVIRONMENTBRDF = !0,
- o.ENVIRONMENTBRDF_RGBD = this._environmentBRDFTexture.isRGBD) : (o.ENVIRONMENTBRDF = !1,
- o.ENVIRONMENTBRDF_RGBD = !1),
- this._shouldUseAlphaFromAlbedoTexture() ? o.ALPHAFROMALBEDO = !0 : o.ALPHAFROMALBEDO = !1
- }
- o.SPECULAROVERALPHA = this._useSpecularOverAlpha,
- this._lightFalloff === e.LIGHTFALLOFF_STANDARD ? (o.USEPHYSICALLIGHTFALLOFF = !1,
- o.USEGLTFLIGHTFALLOFF = !1) : this._lightFalloff === e.LIGHTFALLOFF_GLTF ? (o.USEPHYSICALLIGHTFALLOFF = !1,
- o.USEGLTFLIGHTFALLOFF = !0) : (o.USEPHYSICALLIGHTFALLOFF = !0,
- o.USEGLTFLIGHTFALLOFF = !1),
- o.RADIANCEOVERALPHA = this._useRadianceOverAlpha,
- !this.backFaceCulling && this._twoSidedLighting ? o.TWOSIDEDLIGHTING = !0 : o.TWOSIDEDLIGHTING = !1,
- o.SPECULARAA = b.getEngine().getCaps().standardDerivatives && this._enableSpecularAntiAliasing
- }
- (o._areTexturesDirty || o._areMiscDirty) && (o.ALPHATESTVALUE = "" + this._alphaCutOff + (this._alphaCutOff % 1 === 0 ? "." : ""),
- o.PREMULTIPLYALPHA = this.alphaMode === 7 || this.alphaMode === 8,
- o.ALPHABLEND = this.needAlphaBlendingForMesh(i),
- o.ALPHAFRESNEL = this._useAlphaFresnel || this._useLinearAlphaFresnel,
- o.LINEARALPHAFRESNEL = this._useLinearAlphaFresnel),
- o._areImageProcessingDirty && this._imageProcessingConfiguration && this._imageProcessingConfiguration.prepareDefines(o),
- o.FORCENORMALFORWARD = this._forceNormalForward,
- o.RADIANCEOCCLUSION = this._useRadianceOcclusion,
- o.HORIZONOCCLUSION = this._useHorizonOcclusion,
- o._areMiscDirty && (MaterialHelper.PrepareDefinesForMisc(i, b, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(i) || this._forceAlphaTest, o),
- o.UNLIT = this._unlit || (this.pointsCloud || this.wireframe) && !i.isVerticesDataPresent(VertexBuffer.NormalKind),
- o.DEBUGMODE = this._debugMode),
- this.detailMap.prepareDefines(o, b),
- this.subSurface.prepareDefines(o, b),
- this.clearCoat.prepareDefines(o, b),
- this.anisotropy.prepareDefines(o, i, b),
- this.brdf.prepareDefines(o),
- this.sheen.prepareDefines(o, b),
- MaterialHelper.PrepareDefinesForFrameBoundValues(b, k, o, !!s, c, d),
- MaterialHelper.PrepareDefinesForAttributes(i, o, !0, !0, !0, this._transparencyMode !== e.PBRMATERIAL_OPAQUE)
- }
- ,
- e.prototype.forceCompilation = function(i, o, s) {
- var c = this
- , d = __assign({
- clipPlane: !1,
- useInstances: !1
- }, s)
- , _ = new PBRMaterialDefines
- , b = this._prepareEffect(i, _, void 0, void 0, d.useInstances, d.clipPlane, i.hasThinInstances);
- this._onEffectCreatedObservable && (onCreatedEffectParameters.effect = b,
- onCreatedEffectParameters.subMesh = null,
- this._onEffectCreatedObservable.notifyObservers(onCreatedEffectParameters)),
- b.isReady() ? o && o(this) : b.onCompileObservable.add(function() {
- o && o(c)
- })
- }
- ,
- e.prototype.buildUniformLayout = function() {
- var i = this._uniformBuffer;
- i.addUniform("vAlbedoInfos", 2),
- i.addUniform("vAmbientInfos", 4),
- i.addUniform("vOpacityInfos", 2),
- i.addUniform("vEmissiveInfos", 2),
- i.addUniform("vLightmapInfos", 2),
- i.addUniform("vReflectivityInfos", 3),
- i.addUniform("vMicroSurfaceSamplerInfos", 2),
- i.addUniform("vReflectionInfos", 2),
- i.addUniform("vReflectionFilteringInfo", 2),
- i.addUniform("vReflectionPosition", 3),
- i.addUniform("vReflectionSize", 3),
- i.addUniform("vBumpInfos", 3),
- i.addUniform("albedoMatrix", 16),
- i.addUniform("ambientMatrix", 16),
- i.addUniform("opacityMatrix", 16),
- i.addUniform("emissiveMatrix", 16),
- i.addUniform("lightmapMatrix", 16),
- i.addUniform("reflectivityMatrix", 16),
- i.addUniform("microSurfaceSamplerMatrix", 16),
- i.addUniform("bumpMatrix", 16),
- i.addUniform("vTangentSpaceParams", 2),
- i.addUniform("reflectionMatrix", 16),
- i.addUniform("vReflectionColor", 3),
- i.addUniform("vAlbedoColor", 4),
- i.addUniform("vLightingIntensity", 4),
- i.addUniform("vReflectionMicrosurfaceInfos", 3),
- i.addUniform("pointSize", 1),
- i.addUniform("vReflectivityColor", 4),
- i.addUniform("vEmissiveColor", 3),
- i.addUniform("vAmbientColor", 3),
- i.addUniform("vDebugMode", 2),
- i.addUniform("vMetallicReflectanceFactors", 4),
- i.addUniform("vMetallicReflectanceInfos", 2),
- i.addUniform("metallicReflectanceMatrix", 16),
- i.addUniform("vReflectanceInfos", 2),
- i.addUniform("reflectanceMatrix", 16),
- PBRClearCoatConfiguration.PrepareUniformBuffer(i),
- PBRAnisotropicConfiguration.PrepareUniformBuffer(i),
- PBRSheenConfiguration.PrepareUniformBuffer(i),
- PBRSubSurfaceConfiguration.PrepareUniformBuffer(i),
- DetailMapConfiguration.PrepareUniformBuffer(i),
- i.addUniform("vSphericalL00", 3),
- i.addUniform("vSphericalL1_1", 3),
- i.addUniform("vSphericalL10", 3),
- i.addUniform("vSphericalL11", 3),
- i.addUniform("vSphericalL2_2", 3),
- i.addUniform("vSphericalL2_1", 3),
- i.addUniform("vSphericalL20", 3),
- i.addUniform("vSphericalL21", 3),
- i.addUniform("vSphericalL22", 3),
- i.addUniform("vSphericalX", 3),
- i.addUniform("vSphericalY", 3),
- i.addUniform("vSphericalZ", 3),
- i.addUniform("vSphericalXX_ZZ", 3),
- i.addUniform("vSphericalYY_ZZ", 3),
- i.addUniform("vSphericalZZ", 3),
- i.addUniform("vSphericalXY", 3),
- i.addUniform("vSphericalYZ", 3),
- i.addUniform("vSphericalZX", 3),
- i.create()
- }
- ,
- e.prototype.unbind = function() {
- if (this._activeEffect && !this.getScene().getEngine()._features.needToAlwaysBindUniformBuffers) {
- var i = !1;
- this._reflectionTexture && this._reflectionTexture.isRenderTarget && (this._activeEffect.setTexture("reflection2DSampler", null),
- i = !0),
- this.subSurface.unbind(this._activeEffect) && (i = !0),
- i && this._markAllSubMeshesAsTexturesDirty()
- }
- a.prototype.unbind.call(this)
- }
- ,
- e.prototype.bindForSubMesh = function(i, o, s) {
- var c, d = this.getScene(), _ = s.materialDefines;
- if (!!_) {
- var b = s.effect;
- if (!!b) {
- this._activeEffect = b,
- o.getMeshUniformBuffer().bindToEffect(b, "Mesh"),
- o.transferToEffect(i);
- var k = d.getEngine();
- this._uniformBuffer.bindToEffect(b, "Material"),
- this.subSurface.hardBindForSubMesh(this._uniformBuffer, d, k, this.isFrozen, _.LODBASEDMICROSFURACE, this.realTimeFiltering, s),
- this.prePassConfiguration.bindForSubMesh(this._activeEffect, d, o, i, this.isFrozen),
- _.OBJECTSPACE_NORMALMAP && (i.toNormalMatrix(this._normalMatrix),
- this.bindOnlyNormalMatrix(this._normalMatrix));
- var j = this._mustRebind(d, b, o.visibility);
- MaterialHelper.BindBonesParameters(o, this._activeEffect, this.prePassConfiguration);
- var $ = null
- , _e = this._uniformBuffer;
- if (j) {
- if (this.bindViewProjection(b),
- $ = this._getReflectionTexture(),
- !_e.useUbo || !this.isFrozen || !_e.isSync) {
- if (d.texturesEnabled) {
- if (this._albedoTexture && MaterialFlags.DiffuseTextureEnabled && (_e.updateFloat2("vAlbedoInfos", this._albedoTexture.coordinatesIndex, this._albedoTexture.level),
- MaterialHelper.BindTextureMatrix(this._albedoTexture, _e, "albedo")),
- this._ambientTexture && MaterialFlags.AmbientTextureEnabled && (_e.updateFloat4("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level, this._ambientTextureStrength, this._ambientTextureImpactOnAnalyticalLights),
- MaterialHelper.BindTextureMatrix(this._ambientTexture, _e, "ambient")),
- this._opacityTexture && MaterialFlags.OpacityTextureEnabled && (_e.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level),
- MaterialHelper.BindTextureMatrix(this._opacityTexture, _e, "opacity")),
- $ && MaterialFlags.ReflectionTextureEnabled) {
- if (_e.updateMatrix("reflectionMatrix", $.getReflectionTextureMatrix()),
- _e.updateFloat2("vReflectionInfos", $.level, 0),
- $.boundingBoxSize) {
- var et = $;
- _e.updateVector3("vReflectionPosition", et.boundingBoxPosition),
- _e.updateVector3("vReflectionSize", et.boundingBoxSize)
- }
- if (this.realTimeFiltering) {
- var tt = $.getSize().width;
- _e.updateFloat2("vReflectionFilteringInfo", tt, Scalar.Log2(tt))
- }
- if (!_.USEIRRADIANCEMAP) {
- var rt = $.sphericalPolynomial;
- if (_.USESPHERICALFROMREFLECTIONMAP && rt)
- if (_.SPHERICAL_HARMONICS) {
- var it = rt.preScaledHarmonics;
- _e.updateVector3("vSphericalL00", it.l00),
- _e.updateVector3("vSphericalL1_1", it.l1_1),
- _e.updateVector3("vSphericalL10", it.l10),
- _e.updateVector3("vSphericalL11", it.l11),
- _e.updateVector3("vSphericalL2_2", it.l2_2),
- _e.updateVector3("vSphericalL2_1", it.l2_1),
- _e.updateVector3("vSphericalL20", it.l20),
- _e.updateVector3("vSphericalL21", it.l21),
- _e.updateVector3("vSphericalL22", it.l22)
- } else
- _e.updateFloat3("vSphericalX", rt.x.x, rt.x.y, rt.x.z),
- _e.updateFloat3("vSphericalY", rt.y.x, rt.y.y, rt.y.z),
- _e.updateFloat3("vSphericalZ", rt.z.x, rt.z.y, rt.z.z),
- _e.updateFloat3("vSphericalXX_ZZ", rt.xx.x - rt.zz.x, rt.xx.y - rt.zz.y, rt.xx.z - rt.zz.z),
- _e.updateFloat3("vSphericalYY_ZZ", rt.yy.x - rt.zz.x, rt.yy.y - rt.zz.y, rt.yy.z - rt.zz.z),
- _e.updateFloat3("vSphericalZZ", rt.zz.x, rt.zz.y, rt.zz.z),
- _e.updateFloat3("vSphericalXY", rt.xy.x, rt.xy.y, rt.xy.z),
- _e.updateFloat3("vSphericalYZ", rt.yz.x, rt.yz.y, rt.yz.z),
- _e.updateFloat3("vSphericalZX", rt.zx.x, rt.zx.y, rt.zx.z)
- }
- _e.updateFloat3("vReflectionMicrosurfaceInfos", $.getSize().width, $.lodGenerationScale, $.lodGenerationOffset)
- }
- this._emissiveTexture && MaterialFlags.EmissiveTextureEnabled && (_e.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level),
- MaterialHelper.BindTextureMatrix(this._emissiveTexture, _e, "emissive")),
- this._lightmapTexture && MaterialFlags.LightmapTextureEnabled && (_e.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level),
- MaterialHelper.BindTextureMatrix(this._lightmapTexture, _e, "lightmap")),
- MaterialFlags.SpecularTextureEnabled && (this._metallicTexture ? (_e.updateFloat3("vReflectivityInfos", this._metallicTexture.coordinatesIndex, this._metallicTexture.level, this._ambientTextureStrength),
- MaterialHelper.BindTextureMatrix(this._metallicTexture, _e, "reflectivity")) : this._reflectivityTexture && (_e.updateFloat3("vReflectivityInfos", this._reflectivityTexture.coordinatesIndex, this._reflectivityTexture.level, 1),
- MaterialHelper.BindTextureMatrix(this._reflectivityTexture, _e, "reflectivity")),
- this._metallicReflectanceTexture && (_e.updateFloat2("vMetallicReflectanceInfos", this._metallicReflectanceTexture.coordinatesIndex, this._metallicReflectanceTexture.level),
- MaterialHelper.BindTextureMatrix(this._metallicReflectanceTexture, _e, "metallicReflectance")),
- this._reflectanceTexture && _.REFLECTANCE && (_e.updateFloat2("vReflectanceInfos", this._reflectanceTexture.coordinatesIndex, this._reflectanceTexture.level),
- MaterialHelper.BindTextureMatrix(this._reflectanceTexture, _e, "reflectance")),
- this._microSurfaceTexture && (_e.updateFloat2("vMicroSurfaceSamplerInfos", this._microSurfaceTexture.coordinatesIndex, this._microSurfaceTexture.level),
- MaterialHelper.BindTextureMatrix(this._microSurfaceTexture, _e, "microSurfaceSampler"))),
- this._bumpTexture && k.getCaps().standardDerivatives && MaterialFlags.BumpTextureEnabled && !this._disableBumpMap && (_e.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level, this._parallaxScaleBias),
- MaterialHelper.BindTextureMatrix(this._bumpTexture, _e, "bump"),
- d._mirroredCameraPosition ? _e.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1 : -1, this._invertNormalMapY ? 1 : -1) : _e.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1 : 1, this._invertNormalMapY ? -1 : 1))
- }
- if (this.pointsCloud && _e.updateFloat("pointSize", this.pointSize),
- _.METALLICWORKFLOW) {
- TmpColors.Color3[0].r = this._metallic === void 0 || this._metallic === null ? 1 : this._metallic,
- TmpColors.Color3[0].g = this._roughness === void 0 || this._roughness === null ? 1 : this._roughness,
- _e.updateColor4("vReflectivityColor", TmpColors.Color3[0], 1);
- var nt = this.subSurface.indexOfRefraction
- , ot = 1
- , at = Math.pow((nt - ot) / (nt + ot), 2);
- this._metallicReflectanceColor.scaleToRef(at * this._metallicF0Factor, TmpColors.Color3[0]);
- var st = this._metallicF0Factor;
- _e.updateColor4("vMetallicReflectanceFactors", TmpColors.Color3[0], st)
- } else
- _e.updateColor4("vReflectivityColor", this._reflectivityColor, this._microSurface);
- _e.updateColor3("vEmissiveColor", MaterialFlags.EmissiveTextureEnabled ? this._emissiveColor : Color3.BlackReadOnly),
- _e.updateColor3("vReflectionColor", this._reflectionColor),
- !_.SS_REFRACTION && this.subSurface.linkRefractionWithTransparency ? _e.updateColor4("vAlbedoColor", this._albedoColor, 1) : _e.updateColor4("vAlbedoColor", this._albedoColor, this.alpha),
- this._lightingInfos.x = this._directIntensity,
- this._lightingInfos.y = this._emissiveIntensity,
- this._lightingInfos.z = this._environmentIntensity * d.environmentIntensity,
- this._lightingInfos.w = this._specularIntensity,
- _e.updateVector4("vLightingIntensity", this._lightingInfos),
- d.ambientColor.multiplyToRef(this._ambientColor, this._globalAmbientColor),
- _e.updateColor3("vAmbientColor", this._globalAmbientColor),
- _e.updateFloat2("vDebugMode", this.debugLimit, this.debugFactor)
- }
- d.texturesEnabled && (this._albedoTexture && MaterialFlags.DiffuseTextureEnabled && _e.setTexture("albedoSampler", this._albedoTexture),
- this._ambientTexture && MaterialFlags.AmbientTextureEnabled && _e.setTexture("ambientSampler", this._ambientTexture),
- this._opacityTexture && MaterialFlags.OpacityTextureEnabled && _e.setTexture("opacitySampler", this._opacityTexture),
- $ && MaterialFlags.ReflectionTextureEnabled && (_.LODBASEDMICROSFURACE ? _e.setTexture("reflectionSampler", $) : (_e.setTexture("reflectionSampler", $._lodTextureMid || $),
- _e.setTexture("reflectionSamplerLow", $._lodTextureLow || $),
- _e.setTexture("reflectionSamplerHigh", $._lodTextureHigh || $)),
- _.USEIRRADIANCEMAP && _e.setTexture("irradianceSampler", $.irradianceTexture)),
- _.ENVIRONMENTBRDF && _e.setTexture("environmentBrdfSampler", this._environmentBRDFTexture),
- this._emissiveTexture && MaterialFlags.EmissiveTextureEnabled && _e.setTexture("emissiveSampler", this._emissiveTexture),
- this._lightmapTexture && MaterialFlags.LightmapTextureEnabled && _e.setTexture("lightmapSampler", this._lightmapTexture),
- MaterialFlags.SpecularTextureEnabled && (this._metallicTexture ? _e.setTexture("reflectivitySampler", this._metallicTexture) : this._reflectivityTexture && _e.setTexture("reflectivitySampler", this._reflectivityTexture),
- this._metallicReflectanceTexture && _e.setTexture("metallicReflectanceSampler", this._metallicReflectanceTexture),
- this._reflectanceTexture && _.REFLECTANCE && _e.setTexture("reflectanceSampler", this._reflectanceTexture),
- this._microSurfaceTexture && _e.setTexture("microSurfaceSampler", this._microSurfaceTexture)),
- this._bumpTexture && k.getCaps().standardDerivatives && MaterialFlags.BumpTextureEnabled && !this._disableBumpMap && _e.setTexture("bumpSampler", this._bumpTexture)),
- this.getScene().useOrderIndependentTransparency && this.needAlphaBlendingForMesh(o) && this.getScene().depthPeelingRenderer.bind(b),
- this.detailMap.bindForSubMesh(_e, d, this.isFrozen),
- this.subSurface.bindForSubMesh(_e, d, k, this.isFrozen, _.LODBASEDMICROSFURACE, this.realTimeFiltering, s),
- this.clearCoat.bindForSubMesh(_e, d, k, this._disableBumpMap, this.isFrozen, this._invertNormalMapX, this._invertNormalMapY, s),
- this.anisotropy.bindForSubMesh(_e, d, this.isFrozen),
- this.sheen.bindForSubMesh(_e, d, this.isFrozen, s),
- MaterialHelper.BindClipPlane(this._activeEffect, d),
- this.bindEyePosition(b)
- } else
- d.getEngine()._features.needToAlwaysBindUniformBuffers && (this._needToBindSceneUbo = !0);
- (j || !this.isFrozen) && (d.lightsEnabled && !this._disableLighting && MaterialHelper.BindLights(d, o, this._activeEffect, _, this._maxSimultaneousLights),
- (d.fogEnabled && o.applyFog && d.fogMode !== Scene.FOGMODE_NONE || $ || o.receiveShadows) && this.bindView(b),
- MaterialHelper.BindFogParameters(d, o, this._activeEffect, !0),
- _.NUM_MORPH_INFLUENCERS && MaterialHelper.BindMorphTargetParameters(o, this._activeEffect),
- _.BAKED_VERTEX_ANIMATION_TEXTURE && ((c = o.bakedVertexAnimationManager) === null || c === void 0 || c.bind(b, _.INSTANCES)),
- this._imageProcessingConfiguration.bind(this._activeEffect),
- MaterialHelper.BindLogDepth(_, this._activeEffect, d)),
- this._afterBind(o, this._activeEffect),
- _e.update()
- }
- }
- }
- ,
- e.prototype.getAnimatables = function() {
- var i = [];
- return this._albedoTexture && this._albedoTexture.animations && this._albedoTexture.animations.length > 0 && i.push(this._albedoTexture),
- this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0 && i.push(this._ambientTexture),
- this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0 && i.push(this._opacityTexture),
- this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0 && i.push(this._reflectionTexture),
- this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0 && i.push(this._emissiveTexture),
- 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),
- this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0 && i.push(this._bumpTexture),
- this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0 && i.push(this._lightmapTexture),
- this.detailMap.getAnimatables(i),
- this.subSurface.getAnimatables(i),
- this.clearCoat.getAnimatables(i),
- this.sheen.getAnimatables(i),
- this.anisotropy.getAnimatables(i),
- i
- }
- ,
- e.prototype._getReflectionTexture = function() {
- return this._reflectionTexture ? this._reflectionTexture : this.getScene().environmentTexture
- }
- ,
- e.prototype.getActiveTextures = function() {
- var i = a.prototype.getActiveTextures.call(this);
- return this._albedoTexture && i.push(this._albedoTexture),
- this._ambientTexture && i.push(this._ambientTexture),
- this._opacityTexture && i.push(this._opacityTexture),
- this._reflectionTexture && i.push(this._reflectionTexture),
- this._emissiveTexture && i.push(this._emissiveTexture),
- this._reflectivityTexture && i.push(this._reflectivityTexture),
- this._metallicTexture && i.push(this._metallicTexture),
- this._metallicReflectanceTexture && i.push(this._metallicReflectanceTexture),
- this._reflectanceTexture && i.push(this._reflectanceTexture),
- this._microSurfaceTexture && i.push(this._microSurfaceTexture),
- this._bumpTexture && i.push(this._bumpTexture),
- this._lightmapTexture && i.push(this._lightmapTexture),
- this.detailMap.getActiveTextures(i),
- this.subSurface.getActiveTextures(i),
- this.clearCoat.getActiveTextures(i),
- this.sheen.getActiveTextures(i),
- this.anisotropy.getActiveTextures(i),
- i
- }
- ,
- e.prototype.hasTexture = function(i) {
- 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)
- }
- ,
- e.prototype.setPrePassRenderer = function(i) {
- if (this.subSurface.isScatteringEnabled) {
- var o = this.getScene().enableSubSurfaceForPrePass();
- return o && (o.enabled = !0),
- !0
- }
- return !1
- }
- ,
- e.prototype.dispose = function(i, o) {
- var s, c, d, _, b, k, j, $, _e, et, tt, rt;
- o && (this._environmentBRDFTexture && this.getScene().environmentBRDFTexture !== this._environmentBRDFTexture && this._environmentBRDFTexture.dispose(),
- (s = this._albedoTexture) === null || s === void 0 || s.dispose(),
- (c = this._ambientTexture) === null || c === void 0 || c.dispose(),
- (d = this._opacityTexture) === null || d === void 0 || d.dispose(),
- (_ = this._reflectionTexture) === null || _ === void 0 || _.dispose(),
- (b = this._emissiveTexture) === null || b === void 0 || b.dispose(),
- (k = this._metallicTexture) === null || k === void 0 || k.dispose(),
- (j = this._reflectivityTexture) === null || j === void 0 || j.dispose(),
- ($ = this._bumpTexture) === null || $ === void 0 || $.dispose(),
- (_e = this._lightmapTexture) === null || _e === void 0 || _e.dispose(),
- (et = this._metallicReflectanceTexture) === null || et === void 0 || et.dispose(),
- (tt = this._reflectanceTexture) === null || tt === void 0 || tt.dispose(),
- (rt = this._microSurfaceTexture) === null || rt === void 0 || rt.dispose()),
- this.detailMap.dispose(o),
- this.subSurface.dispose(o),
- this.clearCoat.dispose(o),
- this.sheen.dispose(o),
- this.anisotropy.dispose(o),
- this._renderTargets.dispose(),
- this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
- a.prototype.dispose.call(this, i, o)
- }
- ,
- e.PBRMATERIAL_OPAQUE = Material.MATERIAL_OPAQUE,
- e.PBRMATERIAL_ALPHATEST = Material.MATERIAL_ALPHATEST,
- e.PBRMATERIAL_ALPHABLEND = Material.MATERIAL_ALPHABLEND,
- e.PBRMATERIAL_ALPHATESTANDBLEND = Material.MATERIAL_ALPHATESTANDBLEND,
- e.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = 0,
- e.LIGHTFALLOFF_PHYSICAL = 0,
- e.LIGHTFALLOFF_GLTF = 1,
- e.LIGHTFALLOFF_STANDARD = 2,
- __decorate([serializeAsImageProcessingConfiguration()], e.prototype, "_imageProcessingConfiguration", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsMiscDirty")], e.prototype, "debugMode", void 0),
- __decorate([serialize()], e.prototype, "useLogarithmicDepth", null),
- e
- }(PushMaterial)
- , SheenBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Fragment) || this;
- return o.albedoScaling = !1,
- o.linkSheenWithAlbedo = !1,
- o._isUnique = !0,
- o.registerInput("intensity", NodeMaterialBlockConnectionPointTypes.Float, !0, NodeMaterialBlockTargets.Fragment),
- o.registerInput("color", NodeMaterialBlockConnectionPointTypes.Color3, !0, NodeMaterialBlockTargets.Fragment),
- o.registerInput("roughness", NodeMaterialBlockConnectionPointTypes.Float, !0, NodeMaterialBlockTargets.Fragment),
- o.registerOutput("sheen", NodeMaterialBlockConnectionPointTypes.Object, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("sheen",o,NodeMaterialConnectionPointDirection.Output,e,"SheenBlock")),
- o
- }
- return e.prototype.initialize = function(i) {
- i._excludeVariableName("sheenOut"),
- i._excludeVariableName("sheenMapData"),
- i._excludeVariableName("vSheenColor"),
- i._excludeVariableName("vSheenRoughness")
- }
- ,
- e.prototype.getClassName = function() {
- return "SheenBlock"
- }
- ,
- Object.defineProperty(e.prototype, "intensity", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "color", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "roughness", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "sheen", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.prepareDefines = function(i, o, s) {
- a.prototype.prepareDefines.call(this, i, o, s),
- s.setValue("SHEEN", !0),
- s.setValue("SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE", !0, !0),
- s.setValue("SHEEN_LINKWITHALBEDO", this.linkSheenWithAlbedo, !0),
- s.setValue("SHEEN_ROUGHNESS", this.roughness.isConnected, !0),
- s.setValue("SHEEN_ALBEDOSCALING", this.albedoScaling, !0)
- }
- ,
- e.prototype.getCode = function(i) {
- var o = ""
- , s = this.color.isConnected ? this.color.associatedVariableName : "vec3(1.)"
- , c = this.intensity.isConnected ? this.intensity.associatedVariableName : "1."
- , d = this.roughness.isConnected ? this.roughness.associatedVariableName : "0."
- , _ = "vec4(0.)";
- return o = `#ifdef SHEEN
- sheenOutParams sheenOut;
- vec4 vSheenColor = vec4(` + s + ", " + c + `);
- sheenBlock(
- vSheenColor,
- #ifdef SHEEN_ROUGHNESS
- ` + d + `,
- #endif
- roughness,
- #ifdef SHEEN_TEXTURE
- ` + _ + `,
- 1.0,
- #endif
- reflectance,
- #ifdef SHEEN_LINKWITHALBEDO
- baseColor,
- surfaceAlbedo,
- #endif
- #ifdef ENVIRONMENTBRDF
- NdotV,
- environmentBrdf,
- #endif
- #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
- AARoughnessFactors,
- ` + (i == null ? void 0 : i._vReflectionMicrosurfaceInfosName) + `,
- ` + (i == null ? void 0 : i._vReflectionInfosName) + `,
- ` + (i == null ? void 0 : i.reflectionColor) + `,
- vLightingIntensity,
- #ifdef ` + (i == null ? void 0 : i._define3DName) + `
- ` + (i == null ? void 0 : i._cubeSamplerName) + `,
- #else
- ` + (i == null ? void 0 : i._2DSamplerName) + `,
- #endif
- reflectionOut.reflectionCoords,
- NdotVUnclamped,
- #ifndef LODBASEDMICROSFURACE
- #ifdef ` + (i == null ? void 0 : i._define3DName) + `
- ` + (i == null ? void 0 : i._cubeSamplerName) + `,
- ` + (i == null ? void 0 : i._cubeSamplerName) + `,
- #else
- ` + (i == null ? void 0 : i._2DSamplerName) + `,
- ` + (i == null ? void 0 : i._2DSamplerName) + `,
- #endif
- #endif
- #if !defined(` + (i == null ? void 0 : i._defineSkyboxName) + `) && defined(RADIANCEOCCLUSION)
- seo,
- #endif
- #if !defined(` + (i == null ? void 0 : i._defineSkyboxName) + ") && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(" + (i == null ? void 0 : i._define3DName) + `)
- eho,
- #endif
- #endif
- sheenOut
- );
- #ifdef SHEEN_LINKWITHALBEDO
- surfaceAlbedo = sheenOut.surfaceAlbedo;
- #endif
- #endif\r
- `,
- o
- }
- ,
- e.prototype._buildBlock = function(i) {
- return i.target === NodeMaterialBlockTargets.Fragment && i.sharedData.blocksWithDefines.push(this),
- this
- }
- ,
- e.prototype._dumpPropertiesCode = function() {
- var i = a.prototype._dumpPropertiesCode.call(this);
- return i += this._codeVariableName + ".albedoScaling = " + this.albedoScaling + `;\r
- `,
- i += this._codeVariableName + ".linkSheenWithAlbedo = " + this.linkSheenWithAlbedo + `;\r
- `,
- i
- }
- ,
- e.prototype.serialize = function() {
- var i = a.prototype.serialize.call(this);
- return i.albedoScaling = this.albedoScaling,
- i.linkSheenWithAlbedo = this.linkSheenWithAlbedo,
- i
- }
- ,
- e.prototype._deserialize = function(i, o, s) {
- a.prototype._deserialize.call(this, i, o, s),
- this.albedoScaling = i.albedoScaling,
- this.linkSheenWithAlbedo = i.linkSheenWithAlbedo
- }
- ,
- __decorate([editableInPropertyPage("Albedo scaling", PropertyTypeForEdition.Boolean, "PROPERTIES", {
- notifiers: {
- update: !0
- }
- })], e.prototype, "albedoScaling", void 0),
- __decorate([editableInPropertyPage("Link sheen with albedo", PropertyTypeForEdition.Boolean, "PROPERTIES", {
- notifiers: {
- update: !0
- }
- })], e.prototype, "linkSheenWithAlbedo", void 0),
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.SheenBlock", SheenBlock);
- var AnisotropyBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Fragment) || this;
- return o._isUnique = !0,
- o.registerInput("intensity", NodeMaterialBlockConnectionPointTypes.Float, !0, NodeMaterialBlockTargets.Fragment),
- o.registerInput("direction", NodeMaterialBlockConnectionPointTypes.Vector2, !0, NodeMaterialBlockTargets.Fragment),
- o.registerInput("uv", NodeMaterialBlockConnectionPointTypes.Vector2, !0),
- o.registerInput("worldTangent", NodeMaterialBlockConnectionPointTypes.Vector4, !0),
- o.registerOutput("anisotropy", NodeMaterialBlockConnectionPointTypes.Object, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("anisotropy",o,NodeMaterialConnectionPointDirection.Output,e,"AnisotropyBlock")),
- o
- }
- return e.prototype.initialize = function(i) {
- i._excludeVariableName("anisotropicOut"),
- i._excludeVariableName("TBN")
- }
- ,
- e.prototype.getClassName = function() {
- return "AnisotropyBlock"
- }
- ,
- Object.defineProperty(e.prototype, "intensity", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "direction", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "uv", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "worldTangent", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "anisotropy", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._generateTBNSpace = function(i) {
- var o = ""
- , s = "//" + this.name
- , c = this.uv
- , d = this.worldPositionConnectionPoint
- , _ = this.worldNormalConnectionPoint
- , b = this.worldTangent;
- c.isConnected || console.error("You must connect the 'uv' input of the Anisotropy block!"),
- i._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable");
- var k = {
- search: /defined\(TANGENT\)/g,
- replace: b.isConnected ? "defined(TANGENT)" : "defined(IGNORE)"
- };
- return b.isConnected && (o += "vec3 tbnNormal = normalize(" + _.associatedVariableName + `.xyz);\r
- `,
- o += "vec3 tbnTangent = normalize(" + b.associatedVariableName + `.xyz);\r
- `,
- o += `vec3 tbnBitangent = cross(tbnNormal, tbnTangent);\r
- `,
- o += `mat3 vTBN = mat3(tbnTangent, tbnBitangent, tbnNormal);\r
- `),
- o += `
- #if defined(` + (b.isConnected ? "TANGENT" : "IGNORE") + `) && defined(NORMAL)
- mat3 TBN = vTBN;
- #else
- mat3 TBN = cotangent_frame(` + (_.associatedVariableName + ".xyz") + ", " + ("v_" + d.associatedVariableName + ".xyz") + ", " + (c.isConnected ? c.associatedVariableName : "vec2(0.)") + `, vec2(1., 1.));
- #endif\r
- `,
- i._emitFunctionFromInclude("bumpFragmentMainFunctions", s, {
- replaceStrings: [k]
- }),
- o
- }
- ,
- e.prototype.getCode = function(i, o) {
- o === void 0 && (o = !1);
- var s = "";
- o && (s += this._generateTBNSpace(i));
- var c = this.intensity.isConnected ? this.intensity.associatedVariableName : "1.0"
- , d = this.direction.isConnected ? this.direction.associatedVariableName : "vec2(1., 0.)";
- return s += `anisotropicOutParams anisotropicOut;
- anisotropicBlock(
- vec3(` + d + ", " + c + `),
- #ifdef ANISOTROPIC_TEXTURE
- vec3(0.),
- #endif
- TBN,
- normalW,
- viewDirectionW,
- anisotropicOut
- );\r
- `,
- s
- }
- ,
- e.prototype.prepareDefines = function(i, o, s) {
- a.prototype.prepareDefines.call(this, i, o, s),
- s.setValue("ANISOTROPIC", !0),
- s.setValue("ANISOTROPIC_TEXTURE", !1, !0)
- }
- ,
- e.prototype._buildBlock = function(i) {
- return i.target === NodeMaterialBlockTargets.Fragment && i.sharedData.blocksWithDefines.push(this),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.AnisotropyBlock", AnisotropyBlock);
- var ReflectionBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i) || this;
- return o.useSphericalHarmonics = !0,
- o.forceIrradianceInFragment = !1,
- o._isUnique = !0,
- o.registerInput("position", NodeMaterialBlockConnectionPointTypes.Vector3, !1, NodeMaterialBlockTargets.Vertex),
- o.registerInput("world", NodeMaterialBlockConnectionPointTypes.Matrix, !1, NodeMaterialBlockTargets.Vertex),
- o.registerInput("color", NodeMaterialBlockConnectionPointTypes.Color3, !0, NodeMaterialBlockTargets.Fragment),
- o.registerOutput("reflection", NodeMaterialBlockConnectionPointTypes.Object, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("reflection",o,NodeMaterialConnectionPointDirection.Output,e,"ReflectionBlock")),
- o
- }
- return e.prototype.getClassName = function() {
- return "ReflectionBlock"
- }
- ,
- Object.defineProperty(e.prototype, "position", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "worldPosition", {
- get: function() {
- return this.worldPositionConnectionPoint
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "worldNormal", {
- get: function() {
- return this.worldNormalConnectionPoint
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "world", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cameraPosition", {
- get: function() {
- return this.cameraPositionConnectionPoint
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "view", {
- get: function() {
- return this.viewConnectionPoint
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "color", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "reflection", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "hasTexture", {
- get: function() {
- return !!this._getTexture()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "reflectionColor", {
- get: function() {
- return this.color.isConnected ? this.color.associatedVariableName : "vec3(1., 1., 1.)"
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._getTexture = function() {
- return this.texture ? this.texture : this._scene.environmentTexture
- }
- ,
- e.prototype.prepareDefines = function(i, o, s) {
- a.prototype.prepareDefines.call(this, i, o, s);
- var c = this._getTexture()
- , d = c && c.getTextureMatrix;
- s.setValue("REFLECTION", d, !0),
- d && (s.setValue(this._defineLODReflectionAlpha, c.lodLevelInAlpha, !0),
- s.setValue(this._defineLinearSpecularReflection, c.linearSpecularLOD, !0),
- s.setValue(this._defineOppositeZ, this._scene.useRightHandedSystem ? !c.invertZ : c.invertZ, !0),
- s.setValue("SPHERICAL_HARMONICS", this.useSphericalHarmonics, !0),
- s.setValue("GAMMAREFLECTION", c.gammaSpace, !0),
- s.setValue("RGBDREFLECTION", c.isRGBD, !0),
- c && c.coordinatesMode !== Texture.SKYBOX_MODE && c.isCube && (s.setValue("USESPHERICALFROMREFLECTIONMAP", !0),
- s.setValue("USEIRRADIANCEMAP", !1),
- this.forceIrradianceInFragment || this._scene.getEngine().getCaps().maxVaryingVectors <= 8 ? s.setValue("USESPHERICALINVERTEX", !1) : s.setValue("USESPHERICALINVERTEX", !0)))
- }
- ,
- e.prototype.bind = function(i, o, s, c) {
- a.prototype.bind.call(this, i, o, s);
- var d = this._getTexture();
- if (!(!d || !c)) {
- d.isCube ? i.setTexture(this._cubeSamplerName, d) : i.setTexture(this._2DSamplerName, d);
- var _ = d.getSize().width;
- i.setFloat3(this._vReflectionMicrosurfaceInfosName, _, d.lodGenerationScale, d.lodGenerationOffset),
- i.setFloat2(this._vReflectionFilteringInfoName, _, Scalar.Log2(_));
- var b = c.materialDefines
- , k = d.sphericalPolynomial;
- if (b.USESPHERICALFROMREFLECTIONMAP && k)
- if (b.SPHERICAL_HARMONICS) {
- var j = k.preScaledHarmonics;
- i.setVector3("vSphericalL00", j.l00),
- i.setVector3("vSphericalL1_1", j.l1_1),
- i.setVector3("vSphericalL10", j.l10),
- i.setVector3("vSphericalL11", j.l11),
- i.setVector3("vSphericalL2_2", j.l2_2),
- i.setVector3("vSphericalL2_1", j.l2_1),
- i.setVector3("vSphericalL20", j.l20),
- i.setVector3("vSphericalL21", j.l21),
- i.setVector3("vSphericalL22", j.l22)
- } else
- i.setFloat3("vSphericalX", k.x.x, k.x.y, k.x.z),
- i.setFloat3("vSphericalY", k.y.x, k.y.y, k.y.z),
- i.setFloat3("vSphericalZ", k.z.x, k.z.y, k.z.z),
- i.setFloat3("vSphericalXX_ZZ", k.xx.x - k.zz.x, k.xx.y - k.zz.y, k.xx.z - k.zz.z),
- i.setFloat3("vSphericalYY_ZZ", k.yy.x - k.zz.x, k.yy.y - k.zz.y, k.yy.z - k.zz.z),
- i.setFloat3("vSphericalZZ", k.zz.x, k.zz.y, k.zz.z),
- i.setFloat3("vSphericalXY", k.xy.x, k.xy.y, k.xy.z),
- i.setFloat3("vSphericalYZ", k.yz.x, k.yz.y, k.yz.z),
- i.setFloat3("vSphericalZX", k.zx.x, k.zx.y, k.zx.z)
- }
- }
- ,
- e.prototype.handleVertexSide = function(i) {
- var o = a.prototype.handleVertexSide.call(this, i);
- i._emitFunctionFromInclude("harmonicsFunctions", "//" + this.name, {
- replaceStrings: [{
- search: /uniform vec3 vSphericalL00;[\s\S]*?uniform vec3 vSphericalL22;/g,
- replace: ""
- }, {
- search: /uniform vec3 vSphericalX;[\s\S]*?uniform vec3 vSphericalZX;/g,
- replace: ""
- }]
- });
- var s = i._getFreeVariableName("reflectionVector");
- return this._vEnvironmentIrradianceName = i._getFreeVariableName("vEnvironmentIrradiance"),
- i._emitVaryingFromString(this._vEnvironmentIrradianceName, "vec3", "defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)"),
- i._emitUniformFromString("vSphericalL00", "vec3", "SPHERICAL_HARMONICS"),
- i._emitUniformFromString("vSphericalL1_1", "vec3", "SPHERICAL_HARMONICS"),
- i._emitUniformFromString("vSphericalL10", "vec3", "SPHERICAL_HARMONICS"),
- i._emitUniformFromString("vSphericalL11", "vec3", "SPHERICAL_HARMONICS"),
- i._emitUniformFromString("vSphericalL2_2", "vec3", "SPHERICAL_HARMONICS"),
- i._emitUniformFromString("vSphericalL2_1", "vec3", "SPHERICAL_HARMONICS"),
- i._emitUniformFromString("vSphericalL20", "vec3", "SPHERICAL_HARMONICS"),
- i._emitUniformFromString("vSphericalL21", "vec3", "SPHERICAL_HARMONICS"),
- i._emitUniformFromString("vSphericalL22", "vec3", "SPHERICAL_HARMONICS"),
- i._emitUniformFromString("vSphericalX", "vec3", "SPHERICAL_HARMONICS", !0),
- i._emitUniformFromString("vSphericalY", "vec3", "SPHERICAL_HARMONICS", !0),
- i._emitUniformFromString("vSphericalZ", "vec3", "SPHERICAL_HARMONICS", !0),
- i._emitUniformFromString("vSphericalXX_ZZ", "vec3", "SPHERICAL_HARMONICS", !0),
- i._emitUniformFromString("vSphericalYY_ZZ", "vec3", "SPHERICAL_HARMONICS", !0),
- i._emitUniformFromString("vSphericalZZ", "vec3", "SPHERICAL_HARMONICS", !0),
- i._emitUniformFromString("vSphericalXY", "vec3", "SPHERICAL_HARMONICS", !0),
- i._emitUniformFromString("vSphericalYZ", "vec3", "SPHERICAL_HARMONICS", !0),
- i._emitUniformFromString("vSphericalZX", "vec3", "SPHERICAL_HARMONICS", !0),
- o += `#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
- vec3 ` + s + " = vec3(" + this._reflectionMatrixName + " * vec4(normalize(" + this.worldNormal.associatedVariableName + `).xyz, 0)).xyz;
- #ifdef ` + this._defineOppositeZ + `
- ` + s + `.z *= -1.0;
- #endif
- ` + this._vEnvironmentIrradianceName + " = computeEnvironmentIrradiance(" + s + `);
- #endif\r
- `,
- o
- }
- ,
- e.prototype.getCode = function(i, o) {
- var s = "";
- this.handleFragmentSideInits(i),
- i._emitFunctionFromInclude("harmonicsFunctions", "//" + this.name, {
- replaceStrings: [{
- search: /uniform vec3 vSphericalL00;[\s\S]*?uniform vec3 vSphericalL22;/g,
- replace: ""
- }, {
- search: /uniform vec3 vSphericalX;[\s\S]*?uniform vec3 vSphericalZX;/g,
- replace: ""
- }]
- }),
- i._emitFunction("sampleReflection", `
- #ifdef ` + this._define3DName + `
- #define sampleReflection(s, c) textureCube(s, c)
- #else
- #define sampleReflection(s, c) texture2D(s, c)
- #endif\r
- `, "//" + this.name),
- i._emitFunction("sampleReflectionLod", `
- #ifdef ` + this._define3DName + `
- #define sampleReflectionLod(s, c, l) textureCubeLodEXT(s, c, l)
- #else
- #define sampleReflectionLod(s, c, l) texture2DLodEXT(s, c, l)
- #endif\r
- `, "//" + this.name);
- var c = `
- vec3 computeReflectionCoordsPBR(vec4 worldPos, vec3 worldNormal) {
- ` + this.handleFragmentSideCodeReflectionCoords("worldNormal", "worldPos", !0) + `
- return ` + this._reflectionVectorName + `;
- }\r
- `;
- return i._emitFunction("computeReflectionCoordsPBR", c, "//" + this.name),
- this._vReflectionMicrosurfaceInfosName = i._getFreeVariableName("vReflectionMicrosurfaceInfos"),
- i._emitUniformFromString(this._vReflectionMicrosurfaceInfosName, "vec3"),
- this._vReflectionInfosName = i._getFreeVariableName("vReflectionInfos"),
- this._vReflectionFilteringInfoName = i._getFreeVariableName("vReflectionFilteringInfo"),
- i._emitUniformFromString(this._vReflectionFilteringInfoName, "vec2"),
- s += `#ifdef REFLECTION
- vec2 ` + this._vReflectionInfosName + ` = vec2(1., 0.);
- reflectionOutParams reflectionOut;
- reflectionBlock(
- ` + ("v_" + this.worldPosition.associatedVariableName + ".xyz") + `,
- ` + o + `,
- alphaG,
- ` + this._vReflectionMicrosurfaceInfosName + `,
- ` + this._vReflectionInfosName + `,
- ` + this.reflectionColor + `,
- #ifdef ANISOTROPIC
- anisotropicOut,
- #endif
- #if defined(` + this._defineLODReflectionAlpha + ") && !defined(" + this._defineSkyboxName + `)
- NdotVUnclamped,
- #endif
- #ifdef ` + this._defineLinearSpecularReflection + `
- roughness,
- #endif
- #ifdef ` + this._define3DName + `
- ` + this._cubeSamplerName + `,
- #else
- ` + this._2DSamplerName + `,
- #endif
- #if defined(NORMAL) && defined(USESPHERICALINVERTEX)
- ` + this._vEnvironmentIrradianceName + `,
- #endif
- #ifdef USESPHERICALFROMREFLECTIONMAP
- #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
- ` + this._reflectionMatrixName + `,
- #endif
- #endif
- #ifdef USEIRRADIANCEMAP
- irradianceSampler, // ** not handled **
- #endif
- #ifndef LODBASEDMICROSFURACE
- #ifdef ` + this._define3DName + `
- ` + this._cubeSamplerName + `,
- ` + this._cubeSamplerName + `,
- #else
- ` + this._2DSamplerName + `,
- ` + this._2DSamplerName + `,
- #endif
- #endif
- #ifdef REALTIME_FILTERING
- ` + this._vReflectionFilteringInfoName + `,
- #endif
- reflectionOut
- );
- #endif\r
- `,
- s
- }
- ,
- e.prototype._buildBlock = function(i) {
- return this._scene = i.sharedData.scene,
- i.target !== NodeMaterialBlockTargets.Fragment && (this._defineLODReflectionAlpha = i._getFreeDefineName("LODINREFLECTIONALPHA"),
- this._defineLinearSpecularReflection = i._getFreeDefineName("LINEARSPECULARREFLECTION")),
- this
- }
- ,
- e.prototype._dumpPropertiesCode = function() {
- var i = a.prototype._dumpPropertiesCode.call(this);
- return this.texture && (i += this._codeVariableName + ".texture.gammaSpace = " + this.texture.gammaSpace + `;\r
- `),
- i += this._codeVariableName + ".useSphericalHarmonics = " + this.useSphericalHarmonics + `;\r
- `,
- i += this._codeVariableName + ".forceIrradianceInFragment = " + this.forceIrradianceInFragment + `;\r
- `,
- i
- }
- ,
- e.prototype.serialize = function() {
- var i, o, s = a.prototype.serialize.call(this);
- return s.useSphericalHarmonics = this.useSphericalHarmonics,
- s.forceIrradianceInFragment = this.forceIrradianceInFragment,
- s.gammaSpace = (o = (i = this.texture) === null || i === void 0 ? void 0 : i.gammaSpace) !== null && o !== void 0 ? o : !0,
- s
- }
- ,
- e.prototype._deserialize = function(i, o, s) {
- a.prototype._deserialize.call(this, i, o, s),
- this.useSphericalHarmonics = i.useSphericalHarmonics,
- this.forceIrradianceInFragment = i.forceIrradianceInFragment,
- this.texture && (this.texture.gammaSpace = i.gammaSpace)
- }
- ,
- __decorate([editableInPropertyPage("Spherical Harmonics", PropertyTypeForEdition.Boolean, "ADVANCED", {
- notifiers: {
- update: !0
- }
- })], e.prototype, "useSphericalHarmonics", void 0),
- __decorate([editableInPropertyPage("Force irradiance in fragment", PropertyTypeForEdition.Boolean, "ADVANCED", {
- notifiers: {
- update: !0
- }
- })], e.prototype, "forceIrradianceInFragment", void 0),
- e
- }(ReflectionTextureBaseBlock);
- RegisterClass("BABYLON.ReflectionBlock", ReflectionBlock);
- var ClearCoatBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Fragment) || this;
- return o.remapF0OnInterfaceChange = !0,
- o._isUnique = !0,
- o.registerInput("intensity", NodeMaterialBlockConnectionPointTypes.Float, !1, NodeMaterialBlockTargets.Fragment),
- o.registerInput("roughness", NodeMaterialBlockConnectionPointTypes.Float, !0, NodeMaterialBlockTargets.Fragment),
- o.registerInput("indexOfRefraction", NodeMaterialBlockConnectionPointTypes.Float, !0, NodeMaterialBlockTargets.Fragment),
- o.registerInput("normalMapColor", NodeMaterialBlockConnectionPointTypes.Color3, !0, NodeMaterialBlockTargets.Fragment),
- o.registerInput("uv", NodeMaterialBlockConnectionPointTypes.Vector2, !0, NodeMaterialBlockTargets.Fragment),
- o.registerInput("tintColor", NodeMaterialBlockConnectionPointTypes.Color3, !0, NodeMaterialBlockTargets.Fragment),
- o.registerInput("tintAtDistance", NodeMaterialBlockConnectionPointTypes.Float, !0, NodeMaterialBlockTargets.Fragment),
- o.registerInput("tintThickness", NodeMaterialBlockConnectionPointTypes.Float, !0, NodeMaterialBlockTargets.Fragment),
- o.registerInput("worldTangent", NodeMaterialBlockConnectionPointTypes.Vector4, !0),
- o.registerOutput("clearcoat", NodeMaterialBlockConnectionPointTypes.Object, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("clearcoat",o,NodeMaterialConnectionPointDirection.Output,e,"ClearCoatBlock")),
- o
- }
- return e.prototype.initialize = function(i) {
- i._excludeVariableName("clearcoatOut"),
- i._excludeVariableName("vClearCoatParams"),
- i._excludeVariableName("vClearCoatTintParams"),
- i._excludeVariableName("vClearCoatRefractionParams"),
- i._excludeVariableName("vClearCoatTangentSpaceParams")
- }
- ,
- e.prototype.getClassName = function() {
- return "ClearCoatBlock"
- }
- ,
- Object.defineProperty(e.prototype, "intensity", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "roughness", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "indexOfRefraction", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "normalMapColor", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "uv", {
- get: function() {
- return this._inputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "tintColor", {
- get: function() {
- return this._inputs[5]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "tintAtDistance", {
- get: function() {
- return this._inputs[6]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "tintThickness", {
- get: function() {
- return this._inputs[7]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "worldTangent", {
- get: function() {
- return this._inputs[8]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "clearcoat", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.autoConfigure = function(i) {
- if (!this.intensity.isConnected) {
- var o = new InputBlock("ClearCoat intensity",NodeMaterialBlockTargets.Fragment,NodeMaterialBlockConnectionPointTypes.Float);
- o.value = 1,
- o.output.connectTo(this.intensity)
- }
- }
- ,
- e.prototype.prepareDefines = function(i, o, s) {
- a.prototype.prepareDefines.call(this, i, o, s),
- s.setValue("CLEARCOAT", !0),
- s.setValue("CLEARCOAT_TEXTURE", !1, !0),
- s.setValue("CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE", !0, !0),
- s.setValue("CLEARCOAT_TINT", this.tintColor.isConnected || this.tintThickness.isConnected || this.tintAtDistance.isConnected, !0),
- s.setValue("CLEARCOAT_BUMP", this.normalMapColor.isConnected, !0),
- s.setValue("CLEARCOAT_DEFAULTIOR", this.indexOfRefraction.isConnected ? this.indexOfRefraction.connectInputBlock.value === PBRClearCoatConfiguration._DefaultIndexOfRefraction : !0, !0),
- s.setValue("CLEARCOAT_REMAP_F0", this.remapF0OnInterfaceChange, !0)
- }
- ,
- e.prototype.bind = function(i, o, s, c) {
- var d, _;
- a.prototype.bind.call(this, i, o, s);
- var b = (_ = (d = this.indexOfRefraction.connectInputBlock) === null || d === void 0 ? void 0 : d.value) !== null && _ !== void 0 ? _ : PBRClearCoatConfiguration._DefaultIndexOfRefraction
- , k = 1 - b
- , j = 1 + b
- , $ = Math.pow(-k / j, 2)
- , _e = 1 / b;
- i.setFloat4("vClearCoatRefractionParams", $, _e, k, j);
- var et = this.clearcoat.hasEndpoints ? this.clearcoat.endpoints[0].ownerBlock : null
- , tt = et != null && et.perturbedNormal.isConnected ? et.perturbedNormal.connectedPoint.ownerBlock : null;
- 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)
- }
- ,
- e.prototype._generateTBNSpace = function(i, o, s) {
- var c = ""
- , d = "//" + this.name
- , _ = this.worldTangent;
- i._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable");
- var b = {
- search: /defined\(TANGENT\)/g,
- replace: _.isConnected ? "defined(TANGENT)" : "defined(IGNORE)"
- };
- return _.isConnected && (c += "vec3 tbnNormal = normalize(" + s + `.xyz);\r
- `,
- c += "vec3 tbnTangent = normalize(" + _.associatedVariableName + `.xyz);\r
- `,
- c += `vec3 tbnBitangent = cross(tbnNormal, tbnTangent);\r
- `,
- c += `mat3 vTBN = mat3(tbnTangent, tbnBitangent, tbnNormal);\r
- `),
- i._emitFunctionFromInclude("bumpFragmentMainFunctions", d, {
- replaceStrings: [b]
- }),
- c
- }
- ,
- e.GetCode = function(i, o, s, c, d, _, b) {
- var k = ""
- , j = o != null && o.intensity.isConnected ? o.intensity.associatedVariableName : "1."
- , $ = o != null && o.roughness.isConnected ? o.roughness.associatedVariableName : "0."
- , _e = o != null && o.normalMapColor.isConnected ? o.normalMapColor.associatedVariableName : "vec3(0.)"
- , et = o != null && o.uv.isConnected ? o.uv.associatedVariableName : "vec2(0.)"
- , tt = o != null && o.tintColor.isConnected ? o.tintColor.associatedVariableName : "vec3(1.)"
- , rt = o != null && o.tintThickness.isConnected ? o.tintThickness.associatedVariableName : "1."
- , it = o != null && o.tintAtDistance.isConnected ? o.tintAtDistance.associatedVariableName : "1."
- , nt = "vec4(0.)";
- return o && (i._emitUniformFromString("vClearCoatRefractionParams", "vec4"),
- i._emitUniformFromString("vClearCoatTangentSpaceParams", "vec2")),
- d && o && (k += o._generateTBNSpace(i, c, b),
- _ = o.worldTangent.isConnected),
- k += `clearcoatOutParams clearcoatOut;
- #ifdef CLEARCOAT
- vec2 vClearCoatParams = vec2(` + j + ", " + $ + `);
- vec4 vClearCoatTintParams = vec4(` + tt + ", " + rt + `);
- clearcoatBlock(
- ` + c + `.xyz,
- geometricNormalW,
- viewDirectionW,
- vClearCoatParams,
- specularEnvironmentR0,
- #ifdef CLEARCOAT_TEXTURE
- vec2(0.),
- #endif
- #ifdef CLEARCOAT_TINT
- vClearCoatTintParams,
- ` + it + `,
- vClearCoatRefractionParams,
- #ifdef CLEARCOAT_TINT_TEXTURE
- ` + nt + `,
- #endif
- #endif
- #ifdef CLEARCOAT_BUMP
- vec2(0., 1.),
- vec4(` + _e + `, 0.),
- ` + et + `,
- #if defined(` + (_ ? "TANGENT" : "IGNORE") + `) && defined(NORMAL)
- vTBN,
- #else
- vClearCoatTangentSpaceParams,
- #endif
- #ifdef OBJECTSPACE_NORMALMAP
- normalMatrix,
- #endif
- #endif
- #if defined(FORCENORMALFORWARD) && defined(NORMAL)
- faceNormal,
- #endif
- #ifdef REFLECTION
- ` + (s == null ? void 0 : s._vReflectionMicrosurfaceInfosName) + `,
- ` + (s == null ? void 0 : s._vReflectionInfosName) + `,
- ` + (s == null ? void 0 : s.reflectionColor) + `,
- vLightingIntensity,
- #ifdef ` + (s == null ? void 0 : s._define3DName) + `
- ` + (s == null ? void 0 : s._cubeSamplerName) + `,
- #else
- ` + (s == null ? void 0 : s._2DSamplerName) + `,
- #endif
- #ifndef LODBASEDMICROSFURACE
- #ifdef ` + (s == null ? void 0 : s._define3DName) + `
- ` + (s == null ? void 0 : s._cubeSamplerName) + `,
- ` + (s == null ? void 0 : s._cubeSamplerName) + `,
- #else
- ` + (s == null ? void 0 : s._2DSamplerName) + `,
- ` + (s == null ? void 0 : s._2DSamplerName) + `,
- #endif
- #endif
- #endif
- #if defined(ENVIRONMENTBRDF) && !defined(` + (s == null ? void 0 : s._defineSkyboxName) + `)
- #ifdef RADIANCEOCCLUSION
- ambientMonochrome,
- #endif
- #endif
- #if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)
- (gl_FrontFacing ? 1. : -1.),
- #endif
- clearcoatOut
- );
- #else
- clearcoatOut.specularEnvironmentR0 = specularEnvironmentR0;
- #endif\r
- `,
- k
- }
- ,
- e.prototype._buildBlock = function(i) {
- return this._scene = i.sharedData.scene,
- i.target === NodeMaterialBlockTargets.Fragment && (i.sharedData.bindableBlocks.push(this),
- i.sharedData.blocksWithDefines.push(this)),
- this
- }
- ,
- e.prototype._dumpPropertiesCode = function() {
- var i = a.prototype._dumpPropertiesCode.call(this);
- return i += this._codeVariableName + ".remapF0OnInterfaceChange = " + this.remapF0OnInterfaceChange + `;\r
- `,
- i
- }
- ,
- e.prototype.serialize = function() {
- var i = a.prototype.serialize.call(this);
- return i.remapF0OnInterfaceChange = this.remapF0OnInterfaceChange,
- i
- }
- ,
- e.prototype._deserialize = function(i, o, s) {
- var c;
- a.prototype._deserialize.call(this, i, o, s),
- this.remapF0OnInterfaceChange = (c = i.remapF0OnInterfaceChange) !== null && c !== void 0 ? c : !0
- }
- ,
- __decorate([editableInPropertyPage("Remap F0 on interface change", PropertyTypeForEdition.Boolean, "ADVANCED")], e.prototype, "remapF0OnInterfaceChange", void 0),
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.ClearCoatBlock", ClearCoatBlock);
- var RefractionBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Fragment) || this;
- return o.linkRefractionWithTransparency = !1,
- o.invertRefractionY = !1,
- o.useThicknessAsDepth = !1,
- o._isUnique = !0,
- o.registerInput("intensity", NodeMaterialBlockConnectionPointTypes.Float, !1, NodeMaterialBlockTargets.Fragment),
- o.registerInput("tintAtDistance", NodeMaterialBlockConnectionPointTypes.Float, !0, NodeMaterialBlockTargets.Fragment),
- o.registerInput("volumeIndexOfRefraction", NodeMaterialBlockConnectionPointTypes.Float, !0, NodeMaterialBlockTargets.Fragment),
- o.registerOutput("refraction", NodeMaterialBlockConnectionPointTypes.Object, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("refraction",o,NodeMaterialConnectionPointDirection.Output,e,"RefractionBlock")),
- o
- }
- return e.prototype.initialize = function(i) {
- i._excludeVariableName("vRefractionPosition"),
- i._excludeVariableName("vRefractionSize")
- }
- ,
- e.prototype.getClassName = function() {
- return "RefractionBlock"
- }
- ,
- Object.defineProperty(e.prototype, "intensity", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "tintAtDistance", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "volumeIndexOfRefraction", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "view", {
- get: function() {
- return this.viewConnectionPoint
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "refraction", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "hasTexture", {
- get: function() {
- return !!this._getTexture()
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._getTexture = function() {
- return this.texture ? this.texture : this._scene.environmentTexture
- }
- ,
- e.prototype.autoConfigure = function(i) {
- if (!this.intensity.isConnected) {
- var o = new InputBlock("Refraction intensity",NodeMaterialBlockTargets.Fragment,NodeMaterialBlockConnectionPointTypes.Float);
- o.value = 1,
- o.output.connectTo(this.intensity)
- }
- if (this.view && !this.view.isConnected) {
- var s = i.getInputBlockByPredicate(function(c) {
- return c.systemValue === NodeMaterialSystemValues.View
- });
- s || (s = new InputBlock("view"),
- s.setAsSystemValue(NodeMaterialSystemValues.View)),
- s.output.connectTo(this.view)
- }
- }
- ,
- e.prototype.prepareDefines = function(i, o, s) {
- a.prototype.prepareDefines.call(this, i, o, s);
- var c = this._getTexture()
- , d = c && c.getTextureMatrix;
- s.setValue("SS_REFRACTION", d, !0),
- d && (s.setValue(this._define3DName, c.isCube, !0),
- s.setValue(this._defineLODRefractionAlpha, c.lodLevelInAlpha, !0),
- s.setValue(this._defineLinearSpecularRefraction, c.linearSpecularLOD, !0),
- s.setValue(this._defineOppositeZ, this._scene.useRightHandedSystem ? !c.invertZ : c.invertZ, !0),
- s.setValue("SS_LINKREFRACTIONTOTRANSPARENCY", this.linkRefractionWithTransparency, !0),
- s.setValue("SS_GAMMAREFRACTION", c.gammaSpace, !0),
- s.setValue("SS_RGBDREFRACTION", c.isRGBD, !0),
- s.setValue("SS_USE_LOCAL_REFRACTIONMAP_CUBIC", !!c.boundingBoxSize, !0),
- s.setValue("SS_USE_THICKNESS_AS_DEPTH", this.useThicknessAsDepth, !0))
- }
- ,
- e.prototype.isReady = function() {
- var i = this._getTexture();
- return !(i && !i.isReadyOrNotBlocking())
- }
- ,
- e.prototype.bind = function(i, o, s, c) {
- var d, _, b, k;
- a.prototype.bind.call(this, i, o, s);
- var j = this._getTexture();
- if (!!j) {
- j.isCube ? i.setTexture(this._cubeSamplerName, j) : i.setTexture(this._2DSamplerName, j),
- i.setMatrix(this._refractionMatrixName, j.getReflectionTextureMatrix());
- var $ = 1;
- j.isCube || j.depth && ($ = j.depth);
- 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;
- i.setFloat4(this._vRefractionInfosName, j.level, 1 / _e, $, this.invertRefractionY ? -1 : 1),
- i.setFloat4(this._vRefractionMicrosurfaceInfosName, j.getSize().width, j.lodGenerationScale, j.lodGenerationOffset, 1 / _e);
- var et = j.getSize().width;
- if (i.setFloat2(this._vRefractionFilteringInfoName, et, Scalar.Log2(et)),
- j.boundingBoxSize) {
- var tt = j;
- i.setVector3("vRefractionPosition", tt.boundingBoxPosition),
- i.setVector3("vRefractionSize", tt.boundingBoxSize)
- }
- }
- }
- ,
- e.prototype.getCode = function(i) {
- var o = "";
- return i.sharedData.blockingBlocks.push(this),
- i.sharedData.textureBlocks.push(this),
- this._cubeSamplerName = i._getFreeVariableName(this.name + "CubeSampler"),
- i.samplers.push(this._cubeSamplerName),
- this._2DSamplerName = i._getFreeVariableName(this.name + "2DSampler"),
- i.samplers.push(this._2DSamplerName),
- this._define3DName = i._getFreeDefineName("SS_REFRACTIONMAP_3D"),
- i._samplerDeclaration += "#ifdef " + this._define3DName + `\r
- `,
- i._samplerDeclaration += "uniform samplerCube " + this._cubeSamplerName + `;\r
- `,
- i._samplerDeclaration += `#else\r
- `,
- i._samplerDeclaration += "uniform sampler2D " + this._2DSamplerName + `;\r
- `,
- i._samplerDeclaration += `#endif\r
- `,
- i.sharedData.blocksWithDefines.push(this),
- i.sharedData.bindableBlocks.push(this),
- this._defineLODRefractionAlpha = i._getFreeDefineName("SS_LODINREFRACTIONALPHA"),
- this._defineLinearSpecularRefraction = i._getFreeDefineName("SS_LINEARSPECULARREFRACTION"),
- this._defineOppositeZ = i._getFreeDefineName("SS_REFRACTIONMAP_OPPOSITEZ"),
- this._refractionMatrixName = i._getFreeVariableName("refractionMatrix"),
- i._emitUniformFromString(this._refractionMatrixName, "mat4"),
- i._emitFunction("sampleRefraction", `
- #ifdef ` + this._define3DName + `
- #define sampleRefraction(s, c) textureCube(s, c)
- #else
- #define sampleRefraction(s, c) texture2D(s, c)
- #endif\r
- `, "//" + this.name),
- i._emitFunction("sampleRefractionLod", `
- #ifdef ` + this._define3DName + `
- #define sampleRefractionLod(s, c, l) textureCubeLodEXT(s, c, l)
- #else
- #define sampleRefractionLod(s, c, l) texture2DLodEXT(s, c, l)
- #endif\r
- `, "//" + this.name),
- this._vRefractionMicrosurfaceInfosName = i._getFreeVariableName("vRefractionMicrosurfaceInfos"),
- i._emitUniformFromString(this._vRefractionMicrosurfaceInfosName, "vec4"),
- this._vRefractionInfosName = i._getFreeVariableName("vRefractionInfos"),
- i._emitUniformFromString(this._vRefractionInfosName, "vec4"),
- this._vRefractionFilteringInfoName = i._getFreeVariableName("vRefractionFilteringInfo"),
- i._emitUniformFromString(this._vRefractionFilteringInfoName, "vec2"),
- i._emitUniformFromString("vRefractionPosition", "vec3"),
- i._emitUniformFromString("vRefractionSize", "vec3"),
- o
- }
- ,
- e.prototype._buildBlock = function(i) {
- return this._scene = i.sharedData.scene,
- this
- }
- ,
- e.prototype._dumpPropertiesCode = function() {
- var i = a.prototype._dumpPropertiesCode.call(this);
- return this.texture && (this.texture.isCube ? i = this._codeVariableName + '.texture = new BABYLON.CubeTexture("' + this.texture.name + `");\r
- ` : i = this._codeVariableName + '.texture = new BABYLON.Texture("' + this.texture.name + `");\r
- `,
- i += this._codeVariableName + ".texture.coordinatesMode = " + this.texture.coordinatesMode + `;\r
- `),
- i += this._codeVariableName + ".linkRefractionWithTransparency = " + this.linkRefractionWithTransparency + `;\r
- `,
- i += this._codeVariableName + ".invertRefractionY = " + this.invertRefractionY + `;\r
- `,
- i += this._codeVariableName + ".useThicknessAsDepth = " + this.useThicknessAsDepth + `;\r
- `,
- i
- }
- ,
- e.prototype.serialize = function() {
- var i = a.prototype.serialize.call(this);
- return this.texture && !this.texture.isRenderTarget && (i.texture = this.texture.serialize()),
- i.linkRefractionWithTransparency = this.linkRefractionWithTransparency,
- i.invertRefractionY = this.invertRefractionY,
- i.useThicknessAsDepth = this.useThicknessAsDepth,
- i
- }
- ,
- e.prototype._deserialize = function(i, o, s) {
- a.prototype._deserialize.call(this, i, o, s),
- i.texture && (s = i.texture.url.indexOf("data:") === 0 ? "" : s,
- i.texture.isCube ? this.texture = CubeTexture.Parse(i.texture, o, s) : this.texture = Texture.Parse(i.texture, o, s)),
- this.linkRefractionWithTransparency = i.linkRefractionWithTransparency,
- this.invertRefractionY = i.invertRefractionY,
- this.useThicknessAsDepth = !!i.useThicknessAsDepth
- }
- ,
- __decorate([editableInPropertyPage("Link refraction to transparency", PropertyTypeForEdition.Boolean, "ADVANCED", {
- notifiers: {
- update: !0
- }
- })], e.prototype, "linkRefractionWithTransparency", void 0),
- __decorate([editableInPropertyPage("Invert refraction Y", PropertyTypeForEdition.Boolean, "ADVANCED", {
- notifiers: {
- update: !0
- }
- })], e.prototype, "invertRefractionY", void 0),
- __decorate([editableInPropertyPage("Use thickness as depth", PropertyTypeForEdition.Boolean, "ADVANCED", {
- notifiers: {
- update: !0
- }
- })], e.prototype, "useThicknessAsDepth", void 0),
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.RefractionBlock", RefractionBlock);
- var SubSurfaceBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Fragment) || this;
- return o._isUnique = !0,
- o.registerInput("thickness", NodeMaterialBlockConnectionPointTypes.Float, !1, NodeMaterialBlockTargets.Fragment),
- o.registerInput("tintColor", NodeMaterialBlockConnectionPointTypes.Color3, !0, NodeMaterialBlockTargets.Fragment),
- o.registerInput("translucencyIntensity", NodeMaterialBlockConnectionPointTypes.Float, !0, NodeMaterialBlockTargets.Fragment),
- o.registerInput("translucencyDiffusionDist", NodeMaterialBlockConnectionPointTypes.Color3, !0, NodeMaterialBlockTargets.Fragment),
- o.registerInput("refraction", NodeMaterialBlockConnectionPointTypes.Object, !0, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("refraction",o,NodeMaterialConnectionPointDirection.Input,RefractionBlock,"RefractionBlock")),
- o.registerOutput("subsurface", NodeMaterialBlockConnectionPointTypes.Object, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("subsurface",o,NodeMaterialConnectionPointDirection.Output,e,"SubSurfaceBlock")),
- o
- }
- return e.prototype.initialize = function(i) {
- i._excludeVariableName("subSurfaceOut"),
- i._excludeVariableName("vThicknessParam"),
- i._excludeVariableName("vTintColor"),
- i._excludeVariableName("vSubSurfaceIntensity")
- }
- ,
- e.prototype.getClassName = function() {
- return "SubSurfaceBlock"
- }
- ,
- Object.defineProperty(e.prototype, "thickness", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "tintColor", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "translucencyIntensity", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "translucencyDiffusionDist", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "refraction", {
- get: function() {
- return this._inputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "subsurface", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.autoConfigure = function(i) {
- if (!this.thickness.isConnected) {
- var o = new InputBlock("SubSurface thickness",NodeMaterialBlockTargets.Fragment,NodeMaterialBlockConnectionPointTypes.Float);
- o.value = 0,
- o.output.connectTo(this.thickness)
- }
- }
- ,
- e.prototype.prepareDefines = function(i, o, s) {
- a.prototype.prepareDefines.call(this, i, o, s);
- var c = this.translucencyDiffusionDist.isConnected || this.translucencyIntensity.isConnected;
- s.setValue("SUBSURFACE", c || this.refraction.isConnected, !0),
- s.setValue("SS_TRANSLUCENCY", c, !0),
- s.setValue("SS_THICKNESSANDMASK_TEXTURE", !1, !0),
- s.setValue("SS_REFRACTIONINTENSITY_TEXTURE", !1, !0),
- s.setValue("SS_TRANSLUCENCYINTENSITY_TEXTURE", !1, !0),
- s.setValue("SS_MASK_FROM_THICKNESS_TEXTURE", !1, !0),
- s.setValue("SS_USE_GLTF_TEXTURES", !1, !0)
- }
- ,
- e.GetCode = function(i, o, s, c) {
- 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 : "";
- return ct += (_ = dt == null ? void 0 : dt.getCode(i)) !== null && _ !== void 0 ? _ : "",
- ct += `subSurfaceOutParams subSurfaceOut;
- #ifdef SUBSURFACE
- vec2 vThicknessParam = vec2(0., ` + lt + `);
- vec4 vTintColor = vec4(` + ft + ", " + _t + `);
- vec3 vSubSurfaceIntensity = vec3(` + mt + ", " + ht + `, 0.);
- subSurfaceBlock(
- vSubSurfaceIntensity,
- vThicknessParam,
- vTintColor,
- normalW,
- specularEnvironmentReflectance,
- #ifdef SS_THICKNESSANDMASK_TEXTURE
- vec4(0.),
- #endif
- #ifdef REFLECTION
- #ifdef SS_TRANSLUCENCY
- ` + (s == null ? void 0 : s._reflectionMatrixName) + `,
- #ifdef USESPHERICALFROMREFLECTIONMAP
- #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
- reflectionOut.irradianceVector,
- #endif
- #if defined(REALTIME_FILTERING)
- ` + (s == null ? void 0 : s._cubeSamplerName) + `,
- ` + (s == null ? void 0 : s._vReflectionFilteringInfoName) + `,
- #endif
- #endif
- #ifdef USEIRRADIANCEMAP
- irradianceSampler,
- #endif
- #endif
- #endif
- #if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)
- surfaceAlbedo,
- #endif
- #ifdef SS_REFRACTION
- ` + c + `.xyz,
- viewDirectionW,
- ` + vt + `,
- ` + ((b = dt == null ? void 0 : dt._vRefractionInfosName) !== null && b !== void 0 ? b : "") + `,
- ` + ((k = dt == null ? void 0 : dt._refractionMatrixName) !== null && k !== void 0 ? k : "") + `,
- ` + ((j = dt == null ? void 0 : dt._vRefractionMicrosurfaceInfosName) !== null && j !== void 0 ? j : "") + `,
- vLightingIntensity,
- #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
- alpha,
- #endif
- #ifdef ` + (($ = dt == null ? void 0 : dt._defineLODRefractionAlpha) !== null && $ !== void 0 ? $ : "IGNORE") + `
- NdotVUnclamped,
- #endif
- #ifdef ` + ((_e = dt == null ? void 0 : dt._defineLinearSpecularRefraction) !== null && _e !== void 0 ? _e : "IGNORE") + `
- roughness,
- #endif
- alphaG,
- #ifdef ` + ((et = dt == null ? void 0 : dt._define3DName) !== null && et !== void 0 ? et : "IGNORE") + `
- ` + ((tt = dt == null ? void 0 : dt._cubeSamplerName) !== null && tt !== void 0 ? tt : "") + `,
- #else
- ` + ((rt = dt == null ? void 0 : dt._2DSamplerName) !== null && rt !== void 0 ? rt : "") + `,
- #endif
- #ifndef LODBASEDMICROSFURACE
- #ifdef ` + ((it = dt == null ? void 0 : dt._define3DName) !== null && it !== void 0 ? it : "IGNORE") + `
- ` + ((nt = dt == null ? void 0 : dt._cubeSamplerName) !== null && nt !== void 0 ? nt : "") + `,
- ` + ((ot = dt == null ? void 0 : dt._cubeSamplerName) !== null && ot !== void 0 ? ot : "") + `,
- #else
- ` + ((at = dt == null ? void 0 : dt._2DSamplerName) !== null && at !== void 0 ? at : "") + `,
- ` + ((st = dt == null ? void 0 : dt._2DSamplerName) !== null && st !== void 0 ? st : "") + `,
- #endif
- #endif
- #ifdef ANISOTROPIC
- anisotropicOut,
- #endif
- #ifdef REALTIME_FILTERING
- ` + ((ut = dt == null ? void 0 : dt._vRefractionFilteringInfoName) !== null && ut !== void 0 ? ut : "") + `,
- #endif
- #ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
- vRefractionPosition,
- vRefractionSize,
- #endif
- #endif
- #ifdef SS_TRANSLUCENCY
- ` + pt + `,
- #endif
- subSurfaceOut
- );
- #ifdef SS_REFRACTION
- surfaceAlbedo = subSurfaceOut.surfaceAlbedo;
- #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
- alpha = subSurfaceOut.alpha;
- #endif
- #endif
- #else
- subSurfaceOut.specularEnvironmentReflectance = specularEnvironmentReflectance;
- #endif\r
- `,
- ct
- }
- ,
- e.prototype._buildBlock = function(i) {
- return i.target === NodeMaterialBlockTargets.Fragment && i.sharedData.blocksWithDefines.push(this),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.SubSurfaceBlock", SubSurfaceBlock);
- var mapOutputToVariable = {
- ambientClr: ["finalAmbient", ""],
- diffuseDir: ["finalDiffuse", ""],
- specularDir: ["finalSpecularScaled", "!defined(UNLIT) && defined(SPECULARTERM)"],
- clearcoatDir: ["finalClearCoatScaled", "!defined(UNLIT) && defined(CLEARCOAT)"],
- sheenDir: ["finalSheenScaled", "!defined(UNLIT) && defined(SHEEN)"],
- diffuseInd: ["finalIrradiance", "!defined(UNLIT) && defined(REFLECTION)"],
- specularInd: ["finalRadianceScaled", "!defined(UNLIT) && defined(REFLECTION)"],
- clearcoatInd: ["clearcoatOut.finalClearCoatRadianceScaled", "!defined(UNLIT) && defined(REFLECTION) && defined(CLEARCOAT)"],
- sheenInd: ["sheenOut.finalSheenRadianceScaled", "!defined(UNLIT) && defined(REFLECTION) && defined(SHEEN) && defined(ENVIRONMENTBRDF)"],
- refraction: ["subSurfaceOut.finalRefraction", "!defined(UNLIT) && defined(SS_REFRACTION)"],
- lighting: ["finalColor.rgb", ""],
- shadow: ["shadow", ""],
- alpha: ["alpha", ""]
- }
- , PBRMetallicRoughnessBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.VertexAndFragment) || this;
- return o._environmentBRDFTexture = null,
- o._metallicReflectanceColor = Color3.White(),
- o._metallicF0Factor = 1,
- o.directIntensity = 1,
- o.environmentIntensity = 1,
- o.specularIntensity = 1,
- o.lightFalloff = 0,
- o.useAlphaTest = !1,
- o.alphaTestCutoff = .5,
- o.useAlphaBlending = !1,
- o.useRadianceOverAlpha = !0,
- o.useSpecularOverAlpha = !0,
- o.enableSpecularAntiAliasing = !1,
- o.realTimeFiltering = !1,
- o.realTimeFilteringQuality = 8,
- o.useEnergyConservation = !0,
- o.useRadianceOcclusion = !0,
- o.useHorizonOcclusion = !0,
- o.unlit = !1,
- o.forceNormalForward = !1,
- o.debugMode = 0,
- o.debugLimit = 0,
- o.debugFactor = 1,
- o._isUnique = !0,
- o.registerInput("worldPosition", NodeMaterialBlockConnectionPointTypes.Vector4, !1, NodeMaterialBlockTargets.Vertex),
- o.registerInput("worldNormal", NodeMaterialBlockConnectionPointTypes.Vector4, !1, NodeMaterialBlockTargets.Fragment),
- o.registerInput("view", NodeMaterialBlockConnectionPointTypes.Matrix, !1),
- o.registerInput("cameraPosition", NodeMaterialBlockConnectionPointTypes.Vector3, !1, NodeMaterialBlockTargets.Fragment),
- o.registerInput("perturbedNormal", NodeMaterialBlockConnectionPointTypes.Vector4, !0, NodeMaterialBlockTargets.Fragment),
- o.registerInput("baseColor", NodeMaterialBlockConnectionPointTypes.Color3, !0, NodeMaterialBlockTargets.Fragment),
- o.registerInput("metallic", NodeMaterialBlockConnectionPointTypes.Float, !1, NodeMaterialBlockTargets.Fragment),
- o.registerInput("roughness", NodeMaterialBlockConnectionPointTypes.Float, !1, NodeMaterialBlockTargets.Fragment),
- o.registerInput("ambientOcc", NodeMaterialBlockConnectionPointTypes.Float, !0, NodeMaterialBlockTargets.Fragment),
- o.registerInput("opacity", NodeMaterialBlockConnectionPointTypes.Float, !0, NodeMaterialBlockTargets.Fragment),
- o.registerInput("indexOfRefraction", NodeMaterialBlockConnectionPointTypes.Float, !0, NodeMaterialBlockTargets.Fragment),
- o.registerInput("ambientColor", NodeMaterialBlockConnectionPointTypes.Color3, !0, NodeMaterialBlockTargets.Fragment),
- o.registerInput("reflection", NodeMaterialBlockConnectionPointTypes.Object, !0, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("reflection",o,NodeMaterialConnectionPointDirection.Input,ReflectionBlock,"ReflectionBlock")),
- o.registerInput("clearcoat", NodeMaterialBlockConnectionPointTypes.Object, !0, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("clearcoat",o,NodeMaterialConnectionPointDirection.Input,ClearCoatBlock,"ClearCoatBlock")),
- o.registerInput("sheen", NodeMaterialBlockConnectionPointTypes.Object, !0, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("sheen",o,NodeMaterialConnectionPointDirection.Input,SheenBlock,"SheenBlock")),
- o.registerInput("subsurface", NodeMaterialBlockConnectionPointTypes.Object, !0, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("subsurface",o,NodeMaterialConnectionPointDirection.Input,SubSurfaceBlock,"SubSurfaceBlock")),
- o.registerInput("anisotropy", NodeMaterialBlockConnectionPointTypes.Object, !0, NodeMaterialBlockTargets.Fragment, new NodeMaterialConnectionPointCustomObject("anisotropy",o,NodeMaterialConnectionPointDirection.Input,AnisotropyBlock,"AnisotropyBlock")),
- o.registerOutput("ambientClr", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment),
- o.registerOutput("diffuseDir", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment),
- o.registerOutput("specularDir", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment),
- o.registerOutput("clearcoatDir", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment),
- o.registerOutput("sheenDir", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment),
- o.registerOutput("diffuseInd", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment),
- o.registerOutput("specularInd", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment),
- o.registerOutput("clearcoatInd", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment),
- o.registerOutput("sheenInd", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment),
- o.registerOutput("refraction", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment),
- o.registerOutput("lighting", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment),
- o.registerOutput("shadow", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
- o.registerOutput("alpha", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment),
- o
- }
- return e.prototype.initialize = function(i) {
- i._excludeVariableName("vLightingIntensity"),
- i._excludeVariableName("geometricNormalW"),
- i._excludeVariableName("normalW"),
- i._excludeVariableName("faceNormal"),
- i._excludeVariableName("albedoOpacityOut"),
- i._excludeVariableName("surfaceAlbedo"),
- i._excludeVariableName("alpha"),
- i._excludeVariableName("aoOut"),
- i._excludeVariableName("baseColor"),
- i._excludeVariableName("reflectivityOut"),
- i._excludeVariableName("microSurface"),
- i._excludeVariableName("roughness"),
- i._excludeVariableName("NdotVUnclamped"),
- i._excludeVariableName("NdotV"),
- i._excludeVariableName("alphaG"),
- i._excludeVariableName("AARoughnessFactors"),
- i._excludeVariableName("environmentBrdf"),
- i._excludeVariableName("ambientMonochrome"),
- i._excludeVariableName("seo"),
- i._excludeVariableName("eho"),
- i._excludeVariableName("environmentRadiance"),
- i._excludeVariableName("irradianceVector"),
- i._excludeVariableName("environmentIrradiance"),
- i._excludeVariableName("diffuseBase"),
- i._excludeVariableName("specularBase"),
- i._excludeVariableName("preInfo"),
- i._excludeVariableName("info"),
- i._excludeVariableName("shadow"),
- i._excludeVariableName("finalDiffuse"),
- i._excludeVariableName("finalAmbient"),
- i._excludeVariableName("ambientOcclusionForDirectDiffuse"),
- i._excludeVariableName("finalColor"),
- i._excludeVariableName("vClipSpacePosition"),
- i._excludeVariableName("vDebugMode")
- }
- ,
- e.prototype.getClassName = function() {
- return "PBRMetallicRoughnessBlock"
- }
- ,
- Object.defineProperty(e.prototype, "worldPosition", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "worldNormal", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "view", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cameraPosition", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "perturbedNormal", {
- get: function() {
- return this._inputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "baseColor", {
- get: function() {
- return this._inputs[5]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "metallic", {
- get: function() {
- return this._inputs[6]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "roughness", {
- get: function() {
- return this._inputs[7]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "ambientOcc", {
- get: function() {
- return this._inputs[8]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "opacity", {
- get: function() {
- return this._inputs[9]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "indexOfRefraction", {
- get: function() {
- return this._inputs[10]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "ambientColor", {
- get: function() {
- return this._inputs[11]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "reflection", {
- get: function() {
- return this._inputs[12]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "clearcoat", {
- get: function() {
- return this._inputs[13]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "sheen", {
- get: function() {
- return this._inputs[14]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "subsurface", {
- get: function() {
- return this._inputs[15]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "anisotropy", {
- get: function() {
- return this._inputs[16]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "ambientClr", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "diffuseDir", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "specularDir", {
- get: function() {
- return this._outputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "clearcoatDir", {
- get: function() {
- return this._outputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "sheenDir", {
- get: function() {
- return this._outputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "diffuseInd", {
- get: function() {
- return this._outputs[5]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "specularInd", {
- get: function() {
- return this._outputs[6]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "clearcoatInd", {
- get: function() {
- return this._outputs[7]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "sheenInd", {
- get: function() {
- return this._outputs[8]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "refraction", {
- get: function() {
- return this._outputs[9]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "lighting", {
- get: function() {
- return this._outputs[10]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "shadow", {
- get: function() {
- return this._outputs[11]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "alpha", {
- get: function() {
- return this._outputs[12]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.autoConfigure = function(i) {
- if (!this.cameraPosition.isConnected) {
- var o = i.getInputBlockByPredicate(function(c) {
- return c.systemValue === NodeMaterialSystemValues.CameraPosition
- });
- o || (o = new InputBlock("cameraPosition"),
- o.setAsSystemValue(NodeMaterialSystemValues.CameraPosition)),
- o.output.connectTo(this.cameraPosition)
- }
- if (!this.view.isConnected) {
- var s = i.getInputBlockByPredicate(function(c) {
- return c.systemValue === NodeMaterialSystemValues.View
- });
- s || (s = new InputBlock("view"),
- s.setAsSystemValue(NodeMaterialSystemValues.View)),
- s.output.connectTo(this.view)
- }
- }
- ,
- e.prototype.prepareDefines = function(i, o, s) {
- s.setValue("PBR", !0),
- s.setValue("METALLICWORKFLOW", !0),
- s.setValue("DEBUGMODE", this.debugMode, !0),
- s.setValue("NORMALXYSCALE", !0),
- s.setValue("BUMP", this.perturbedNormal.isConnected, !0),
- s.setValue("LODBASEDMICROSFURACE", this._scene.getEngine().getCaps().textureLOD),
- s.setValue("ALBEDO", !1, !0),
- s.setValue("OPACITY", this.opacity.isConnected, !0),
- s.setValue("AMBIENT", !0, !0),
- s.setValue("AMBIENTINGRAYSCALE", !1, !0),
- s.setValue("REFLECTIVITY", !1, !0),
- s.setValue("AOSTOREINMETALMAPRED", !1, !0),
- s.setValue("METALLNESSSTOREINMETALMAPBLUE", !1, !0),
- s.setValue("ROUGHNESSSTOREINMETALMAPALPHA", !1, !0),
- s.setValue("ROUGHNESSSTOREINMETALMAPGREEN", !1, !0),
- this.lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_STANDARD ? (s.setValue("USEPHYSICALLIGHTFALLOFF", !1),
- s.setValue("USEGLTFLIGHTFALLOFF", !1)) : this.lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_GLTF ? (s.setValue("USEPHYSICALLIGHTFALLOFF", !1),
- s.setValue("USEGLTFLIGHTFALLOFF", !0)) : (s.setValue("USEPHYSICALLIGHTFALLOFF", !0),
- s.setValue("USEGLTFLIGHTFALLOFF", !1));
- var c = this.alphaTestCutoff.toString();
- s.setValue("ALPHABLEND", this.useAlphaBlending, !0),
- s.setValue("ALPHAFROMALBEDO", !1, !0),
- s.setValue("ALPHATEST", this.useAlphaTest, !0),
- s.setValue("ALPHATESTVALUE", c.indexOf(".") < 0 ? c + "." : c, !0),
- s.setValue("OPACITYRGB", !1, !0),
- s.setValue("RADIANCEOVERALPHA", this.useRadianceOverAlpha, !0),
- s.setValue("SPECULAROVERALPHA", this.useSpecularOverAlpha, !0),
- s.setValue("SPECULARAA", this._scene.getEngine().getCaps().standardDerivatives && this.enableSpecularAntiAliasing, !0),
- s.setValue("REALTIME_FILTERING", this.realTimeFiltering, !0);
- var d = i.getScene();
- if (d.getEngine()._features.needTypeSuffixInShaderConstants ? s.setValue("NUM_SAMPLES", this.realTimeFilteringQuality + "u", !0) : s.setValue("NUM_SAMPLES", "" + this.realTimeFilteringQuality, !0),
- s.setValue("BRDF_V_HEIGHT_CORRELATED", !0),
- s.setValue("MS_BRDF_ENERGY_CONSERVATION", this.useEnergyConservation, !0),
- s.setValue("RADIANCEOCCLUSION", this.useRadianceOcclusion, !0),
- s.setValue("HORIZONOCCLUSION", this.useHorizonOcclusion, !0),
- s.setValue("UNLIT", this.unlit, !0),
- s.setValue("FORCENORMALFORWARD", this.forceNormalForward, !0),
- this._environmentBRDFTexture && MaterialFlags.ReflectionTextureEnabled ? (s.setValue("ENVIRONMENTBRDF", !0),
- s.setValue("ENVIRONMENTBRDF_RGBD", this._environmentBRDFTexture.isRGBD, !0)) : (s.setValue("ENVIRONMENTBRDF", !1),
- s.setValue("ENVIRONMENTBRDF_RGBD", !1)),
- s._areImageProcessingDirty && o.imageProcessingConfiguration && o.imageProcessingConfiguration.prepareDefines(s),
- !!s._areLightsDirty)
- if (!this.light)
- MaterialHelper.PrepareDefinesForLights(d, i, s, !0, o.maxSimultaneousLights),
- s._needNormals = !0,
- MaterialHelper.PrepareDefinesForMultiview(d, s);
- else {
- var _ = {
- needNormals: !1,
- needRebuild: !1,
- lightmapMode: !1,
- shadowEnabled: !1,
- specularEnabled: !1
- };
- MaterialHelper.PrepareDefinesForLight(d, i, this.light, this._lightId, s, !0, _),
- _.needRebuild && s.rebuild()
- }
- }
- ,
- e.prototype.updateUniformsAndSamples = function(i, o, s, c) {
- for (var d = 0; d < o.maxSimultaneousLights && s["LIGHT" + d]; d++) {
- var _ = i.uniforms.indexOf("vLightData" + d) >= 0;
- MaterialHelper.PrepareUniformsAndSamplersForLight(d, i.uniforms, i.samplers, s["PROJECTEDLIGHTTEXTURE" + d], c, _)
- }
- }
- ,
- e.prototype.isReady = function(i, o, s) {
- return !(this._environmentBRDFTexture && !this._environmentBRDFTexture.isReady() || s._areImageProcessingDirty && o.imageProcessingConfiguration && !o.imageProcessingConfiguration.isReady())
- }
- ,
- e.prototype.bind = function(i, o, s) {
- var c, d;
- if (!!s) {
- var _ = s.getScene();
- this.light ? MaterialHelper.BindLight(this.light, this._lightId, _, i, !0) : MaterialHelper.BindLights(_, s, i, !0, o.maxSimultaneousLights),
- i.setTexture(this._environmentBrdfSamplerName, this._environmentBRDFTexture),
- i.setFloat2("vDebugMode", this.debugLimit, this.debugFactor);
- var b = this._scene.ambientColor;
- b && i.setColor3("ambientFromScene", b);
- var k = _.useRightHandedSystem === (_._mirroredCameraPosition != null);
- i.setFloat(this._invertNormalName, k ? -1 : 1),
- i.setFloat4("vLightingIntensity", this.directIntensity, 1, this.environmentIntensity * this._scene.environmentIntensity, this.specularIntensity);
- var j = 1
- , $ = (d = (c = this.indexOfRefraction.connectInputBlock) === null || c === void 0 ? void 0 : c.value) !== null && d !== void 0 ? d : 1.5
- , _e = Math.pow(($ - j) / ($ + j), 2);
- this._metallicReflectanceColor.scaleToRef(_e * this._metallicF0Factor, TmpColors.Color3[0]);
- var et = this._metallicF0Factor;
- i.setColor4(this._vMetallicReflectanceFactorsName, TmpColors.Color3[0], et),
- o.imageProcessingConfiguration && o.imageProcessingConfiguration.bind(i)
- }
- }
- ,
- e.prototype._injectVertexCode = function(i) {
- var o, s, c = this.worldPosition, d = "//" + this.name;
- this.light ? (this._lightId = (i.counters.lightCounter !== void 0 ? i.counters.lightCounter : -1) + 1,
- i.counters.lightCounter = this._lightId,
- i._emitFunctionFromInclude(i.supportUniformBuffers ? "lightVxUboDeclaration" : "lightVxFragmentDeclaration", d, {
- replaceStrings: [{
- search: /{X}/g,
- replace: this._lightId.toString()
- }]
- }, this._lightId.toString())) : (i._emitFunctionFromInclude(i.supportUniformBuffers ? "lightVxUboDeclaration" : "lightVxFragmentDeclaration", d, {
- repeatKey: "maxSimultaneousLights"
- }),
- this._lightId = 0,
- i.sharedData.dynamicUniformBlocks.push(this));
- var _ = "v_" + c.associatedVariableName;
- i._emitVaryingFromString(_, "vec4") && (i.compilationString += _ + " = " + c.associatedVariableName + `;\r
- `);
- var b = this.reflection.isConnected ? (o = this.reflection.connectedPoint) === null || o === void 0 ? void 0 : o.ownerBlock : null;
- b && (b.viewConnectionPoint = this.view),
- i.compilationString += (s = b == null ? void 0 : b.handleVertexSide(i)) !== null && s !== void 0 ? s : "",
- i._emitUniformFromString("vDebugMode", "vec2", "defined(IGNORE) || DEBUGMODE > 0"),
- i._emitUniformFromString("ambientFromScene", "vec3"),
- i._emitVaryingFromString("vClipSpacePosition", "vec4", "defined(IGNORE) || DEBUGMODE > 0") && (i._injectAtEnd += `#if DEBUGMODE > 0\r
- `,
- i._injectAtEnd += `vClipSpacePosition = gl_Position;\r
- `,
- i._injectAtEnd += `#endif\r
- `),
- this.light ? i.compilationString += i._emitCodeFromInclude("shadowsVertex", d, {
- replaceStrings: [{
- search: /{X}/g,
- replace: this._lightId.toString()
- }, {
- search: /worldPos/g,
- replace: c.associatedVariableName
- }]
- }) : (i.compilationString += "vec4 worldPos = " + c.associatedVariableName + `;\r
- `,
- this.view.isConnected && (i.compilationString += "mat4 view = " + this.view.associatedVariableName + `;\r
- `),
- i.compilationString += i._emitCodeFromInclude("shadowsVertex", d, {
- repeatKey: "maxSimultaneousLights"
- }))
- }
- ,
- e.prototype._getAlbedoOpacityCode = function() {
- var i = `albedoOpacityOutParams albedoOpacityOut;\r
- `
- , o = this.baseColor.isConnected ? this.baseColor.associatedVariableName : "vec3(1.)"
- , s = this.opacity.isConnected ? this.opacity.associatedVariableName : "1.";
- return i += `albedoOpacityBlock(
- vec4(` + o + `, 1.),
- #ifdef ALBEDO
- vec4(1.),
- vec2(1., 1.),
- #endif
- #ifdef OPACITY
- vec4(` + s + `),
- vec2(1., 1.),
- #endif
- albedoOpacityOut
- );
- vec3 surfaceAlbedo = albedoOpacityOut.surfaceAlbedo;
- float alpha = albedoOpacityOut.alpha;\r
- `,
- i
- }
- ,
- e.prototype._getAmbientOcclusionCode = function() {
- var i = `ambientOcclusionOutParams aoOut;\r
- `
- , o = this.ambientOcc.isConnected ? this.ambientOcc.associatedVariableName : "1.";
- return i += `ambientOcclusionBlock(
- #ifdef AMBIENT
- vec3(` + o + `),
- vec4(0., 1.0, 1.0, 0.),
- #endif
- aoOut
- );\r
- `,
- i
- }
- ,
- e.prototype._getReflectivityCode = function(i) {
- var o = `reflectivityOutParams reflectivityOut;\r
- `
- , s = "1.";
- return this._vMetallicReflectanceFactorsName = i._getFreeVariableName("vMetallicReflectanceFactors"),
- i._emitUniformFromString(this._vMetallicReflectanceFactorsName, "vec4"),
- o += `vec3 baseColor = surfaceAlbedo;
- reflectivityBlock(
- vec4(` + this.metallic.associatedVariableName + ", " + this.roughness.associatedVariableName + `, 0., 0.),
- #ifdef METALLICWORKFLOW
- surfaceAlbedo,
- ` + this._vMetallicReflectanceFactorsName + `,
- #endif
- #ifdef REFLECTIVITY
- vec3(0., 0., ` + s + `),
- vec4(1.),
- #endif
- #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
- aoOut.ambientOcclusionColor,
- #endif
- #ifdef MICROSURFACEMAP
- microSurfaceTexel, <== not handled!
- #endif
- reflectivityOut
- );
- float microSurface = reflectivityOut.microSurface;
- float roughness = reflectivityOut.roughness;
- #ifdef METALLICWORKFLOW
- surfaceAlbedo = reflectivityOut.surfaceAlbedo;
- #endif
- #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
- aoOut.ambientOcclusionColor = reflectivityOut.ambientOcclusionColor;
- #endif\r
- `,
- o
- }
- ,
- e.prototype._buildBlock = function(i) {
- 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;
- a.prototype._buildBlock.call(this, i),
- this._scene = i.sharedData.scene,
- this._environmentBRDFTexture || (this._environmentBRDFTexture = GetEnvironmentBRDFTexture(this._scene));
- var Ct = this.reflection.isConnected ? (o = this.reflection.connectedPoint) === null || o === void 0 ? void 0 : o.ownerBlock : null;
- if (Ct && (Ct.worldPositionConnectionPoint = this.worldPosition,
- Ct.cameraPositionConnectionPoint = this.cameraPosition,
- Ct.worldNormalConnectionPoint = this.worldNormal),
- i.target !== NodeMaterialBlockTargets.Fragment)
- return this._injectVertexCode(i),
- this;
- i.sharedData.forcedBindableBlocks.push(this),
- i.sharedData.blocksWithDefines.push(this),
- i.sharedData.blockingBlocks.push(this);
- var Ot = "//" + this.name
- , wt = "v_" + this.worldPosition.associatedVariableName
- , Nt = this.perturbedNormal;
- this._environmentBrdfSamplerName = i._getFreeVariableName("environmentBrdfSampler"),
- i._emit2DSampler(this._environmentBrdfSamplerName),
- i.sharedData.hints.needAlphaBlending = i.sharedData.hints.needAlphaBlending || this.useAlphaBlending,
- i.sharedData.hints.needAlphaTesting = i.sharedData.hints.needAlphaTesting || this.useAlphaTest,
- i._emitExtension("lod", "#extension GL_EXT_shader_texture_lod : enable", "defined(LODBASEDMICROSFURACE)"),
- i._emitExtension("derivatives", "#extension GL_OES_standard_derivatives : enable"),
- i.uniforms.push("exposureLinear"),
- i.uniforms.push("contrast"),
- i.uniforms.push("vInverseScreenSize"),
- i.uniforms.push("vignetteSettings1"),
- i.uniforms.push("vignetteSettings2"),
- i.uniforms.push("vCameraColorCurveNegative"),
- i.uniforms.push("vCameraColorCurveNeutral"),
- i.uniforms.push("vCameraColorCurvePositive"),
- i.uniforms.push("txColorTransform"),
- i.uniforms.push("colorTransformSettings"),
- this.light ? i._emitFunctionFromInclude(i.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", Ot, {
- replaceStrings: [{
- search: /{X}/g,
- replace: this._lightId.toString()
- }]
- }, this._lightId.toString()) : i._emitFunctionFromInclude(i.supportUniformBuffers ? "lightUboDeclaration" : "lightFragmentDeclaration", Ot, {
- repeatKey: "maxSimultaneousLights"
- }),
- i._emitFunctionFromInclude("helperFunctions", Ot),
- i._emitFunctionFromInclude("importanceSampling", Ot),
- i._emitFunctionFromInclude("pbrHelperFunctions", Ot),
- i._emitFunctionFromInclude("imageProcessingDeclaration", Ot),
- i._emitFunctionFromInclude("imageProcessingFunctions", Ot),
- i._emitFunctionFromInclude("shadowsFragmentFunctions", Ot, {
- replaceStrings: [{
- search: /vPositionW/g,
- replace: wt + ".xyz"
- }]
- }),
- i._emitFunctionFromInclude("pbrDirectLightingSetupFunctions", Ot, {
- replaceStrings: [{
- search: /vPositionW/g,
- replace: wt + ".xyz"
- }]
- }),
- i._emitFunctionFromInclude("pbrDirectLightingFalloffFunctions", Ot),
- i._emitFunctionFromInclude("pbrBRDFFunctions", Ot, {
- replaceStrings: [{
- search: /REFLECTIONMAP_SKYBOX/g,
- replace: (s = Ct == null ? void 0 : Ct._defineSkyboxName) !== null && s !== void 0 ? s : "REFLECTIONMAP_SKYBOX"
- }]
- }),
- i._emitFunctionFromInclude("hdrFilteringFunctions", Ot),
- i._emitFunctionFromInclude("pbrDirectLightingFunctions", Ot, {
- replaceStrings: [{
- search: /vPositionW/g,
- replace: wt + ".xyz"
- }]
- }),
- i._emitFunctionFromInclude("pbrIBLFunctions", Ot),
- i._emitFunctionFromInclude("pbrBlockAlbedoOpacity", Ot),
- i._emitFunctionFromInclude("pbrBlockReflectivity", Ot),
- i._emitFunctionFromInclude("pbrBlockAmbientOcclusion", Ot),
- i._emitFunctionFromInclude("pbrBlockAlphaFresnel", Ot),
- i._emitFunctionFromInclude("pbrBlockAnisotropic", Ot),
- i._emitUniformFromString("vLightingIntensity", "vec4"),
- this._vNormalWName = i._getFreeVariableName("vNormalW"),
- i.compilationString += "vec4 " + this._vNormalWName + " = normalize(" + this.worldNormal.associatedVariableName + `);\r
- `,
- i._registerTempVariable("viewDirectionW") && (i.compilationString += "vec3 viewDirectionW = normalize(" + this.cameraPosition.associatedVariableName + " - " + wt + `.xyz);\r
- `),
- i.compilationString += "vec3 geometricNormalW = " + this._vNormalWName + `.xyz;\r
- `,
- i.compilationString += "vec3 normalW = " + (Nt.isConnected ? "normalize(" + Nt.associatedVariableName + ".xyz)" : "geometricNormalW") + `;\r
- `,
- this._invertNormalName = i._getFreeVariableName("invertNormal"),
- i._emitUniformFromString(this._invertNormalName, "float"),
- i.compilationString += i._emitCodeFromInclude("pbrBlockNormalFinal", Ot, {
- replaceStrings: [{
- search: /vPositionW/g,
- replace: wt + ".xyz"
- }, {
- search: /vEyePosition.w/g,
- replace: this._invertNormalName
- }]
- }),
- i.compilationString += this._getAlbedoOpacityCode(),
- i.compilationString += i._emitCodeFromInclude("depthPrePass", Ot),
- i.compilationString += this._getAmbientOcclusionCode(),
- i.compilationString += i._emitCodeFromInclude("pbrBlockLightmapInit", Ot),
- i.compilationString += `#ifdef UNLIT
- vec3 diffuseBase = vec3(1., 1., 1.);
- #else\r
- `,
- i.compilationString += this._getReflectivityCode(i),
- i.compilationString += i._emitCodeFromInclude("pbrBlockGeometryInfo", Ot, {
- replaceStrings: [{
- search: /REFLECTIONMAP_SKYBOX/g,
- replace: (c = Ct == null ? void 0 : Ct._defineSkyboxName) !== null && c !== void 0 ? c : "REFLECTIONMAP_SKYBOX"
- }, {
- search: /REFLECTIONMAP_3D/g,
- replace: (d = Ct == null ? void 0 : Ct._define3DName) !== null && d !== void 0 ? d : "REFLECTIONMAP_3D"
- }]
- });
- var Ft = this.anisotropy.isConnected ? (_ = this.anisotropy.connectedPoint) === null || _ === void 0 ? void 0 : _.ownerBlock : null;
- Ft && (Ft.worldPositionConnectionPoint = this.worldPosition,
- Ft.worldNormalConnectionPoint = this.worldNormal,
- i.compilationString += Ft.getCode(i, !this.perturbedNormal.isConnected)),
- Ct && Ct.hasTexture && (i.compilationString += Ct.getCode(i, Ft ? "anisotropicOut.anisotropicNormal" : "normalW")),
- i._emitFunctionFromInclude("pbrBlockReflection", Ot, {
- replaceStrings: [{
- search: /computeReflectionCoords/g,
- replace: "computeReflectionCoordsPBR"
- }, {
- search: /REFLECTIONMAP_3D/g,
- replace: (b = Ct == null ? void 0 : Ct._define3DName) !== null && b !== void 0 ? b : "REFLECTIONMAP_3D"
- }, {
- search: /REFLECTIONMAP_OPPOSITEZ/g,
- replace: (k = Ct == null ? void 0 : Ct._defineOppositeZ) !== null && k !== void 0 ? k : "REFLECTIONMAP_OPPOSITEZ"
- }, {
- search: /REFLECTIONMAP_PROJECTION/g,
- replace: (j = Ct == null ? void 0 : Ct._defineProjectionName) !== null && j !== void 0 ? j : "REFLECTIONMAP_PROJECTION"
- }, {
- search: /REFLECTIONMAP_SKYBOX/g,
- replace: ($ = Ct == null ? void 0 : Ct._defineSkyboxName) !== null && $ !== void 0 ? $ : "REFLECTIONMAP_SKYBOX"
- }, {
- search: /LODINREFLECTIONALPHA/g,
- replace: (_e = Ct == null ? void 0 : Ct._defineLODReflectionAlpha) !== null && _e !== void 0 ? _e : "LODINREFLECTIONALPHA"
- }, {
- search: /LINEARSPECULARREFLECTION/g,
- replace: (et = Ct == null ? void 0 : Ct._defineLinearSpecularReflection) !== null && et !== void 0 ? et : "LINEARSPECULARREFLECTION"
- }, {
- search: /vReflectionFilteringInfo/g,
- replace: (tt = Ct == null ? void 0 : Ct._vReflectionFilteringInfoName) !== null && tt !== void 0 ? tt : "vReflectionFilteringInfo"
- }]
- }),
- i.compilationString += i._emitCodeFromInclude("pbrBlockReflectance0", Ot, {
- replaceStrings: [{
- search: /metallicReflectanceFactors/g,
- replace: this._vMetallicReflectanceFactorsName
- }]
- });
- var Vt = this.sheen.isConnected ? (rt = this.sheen.connectedPoint) === null || rt === void 0 ? void 0 : rt.ownerBlock : null;
- Vt && (i.compilationString += Vt.getCode(Ct)),
- i._emitFunctionFromInclude("pbrBlockSheen", Ot, {
- replaceStrings: [{
- search: /REFLECTIONMAP_3D/g,
- replace: (it = Ct == null ? void 0 : Ct._define3DName) !== null && it !== void 0 ? it : "REFLECTIONMAP_3D"
- }, {
- search: /REFLECTIONMAP_SKYBOX/g,
- replace: (nt = Ct == null ? void 0 : Ct._defineSkyboxName) !== null && nt !== void 0 ? nt : "REFLECTIONMAP_SKYBOX"
- }, {
- search: /LODINREFLECTIONALPHA/g,
- replace: (ot = Ct == null ? void 0 : Ct._defineLODReflectionAlpha) !== null && ot !== void 0 ? ot : "LODINREFLECTIONALPHA"
- }, {
- search: /LINEARSPECULARREFLECTION/g,
- replace: (at = Ct == null ? void 0 : Ct._defineLinearSpecularReflection) !== null && at !== void 0 ? at : "LINEARSPECULARREFLECTION"
- }]
- });
- var Lt = this.clearcoat.isConnected ? (st = this.clearcoat.connectedPoint) === null || st === void 0 ? void 0 : st.ownerBlock : null
- , kt = !this.perturbedNormal.isConnected && !this.anisotropy.isConnected
- , 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)
- , Ut = this.anisotropy.isConnected && ((lt = this.anisotropy.connectedPoint) === null || lt === void 0 ? void 0 : lt.ownerBlock).worldTangent.isConnected
- , Gt = Bt || !this.perturbedNormal.isConnected && Ut;
- i.compilationString += ClearCoatBlock.GetCode(i, Lt, Ct, wt, kt, Gt, this.worldNormal.associatedVariableName),
- kt && (Gt = (ft = Lt == null ? void 0 : Lt.worldTangent.isConnected) !== null && ft !== void 0 ? ft : !1),
- i._emitFunctionFromInclude("pbrBlockClearcoat", Ot, {
- replaceStrings: [{
- search: /computeReflectionCoords/g,
- replace: "computeReflectionCoordsPBR"
- }, {
- search: /REFLECTIONMAP_3D/g,
- replace: (ht = Ct == null ? void 0 : Ct._define3DName) !== null && ht !== void 0 ? ht : "REFLECTIONMAP_3D"
- }, {
- search: /REFLECTIONMAP_OPPOSITEZ/g,
- replace: (pt = Ct == null ? void 0 : Ct._defineOppositeZ) !== null && pt !== void 0 ? pt : "REFLECTIONMAP_OPPOSITEZ"
- }, {
- search: /REFLECTIONMAP_PROJECTION/g,
- replace: (dt = Ct == null ? void 0 : Ct._defineProjectionName) !== null && dt !== void 0 ? dt : "REFLECTIONMAP_PROJECTION"
- }, {
- search: /REFLECTIONMAP_SKYBOX/g,
- replace: (_t = Ct == null ? void 0 : Ct._defineSkyboxName) !== null && _t !== void 0 ? _t : "REFLECTIONMAP_SKYBOX"
- }, {
- search: /LODINREFLECTIONALPHA/g,
- replace: (mt = Ct == null ? void 0 : Ct._defineLODReflectionAlpha) !== null && mt !== void 0 ? mt : "LODINREFLECTIONALPHA"
- }, {
- search: /LINEARSPECULARREFLECTION/g,
- replace: (vt = Ct == null ? void 0 : Ct._defineLinearSpecularReflection) !== null && vt !== void 0 ? vt : "LINEARSPECULARREFLECTION"
- }, {
- search: /defined\(TANGENT\)/g,
- replace: Gt ? "defined(TANGENT)" : "defined(IGNORE)"
- }]
- }),
- i.compilationString += i._emitCodeFromInclude("pbrBlockReflectance", Ot, {
- replaceStrings: [{
- search: /REFLECTIONMAP_SKYBOX/g,
- replace: (yt = Ct == null ? void 0 : Ct._defineSkyboxName) !== null && yt !== void 0 ? yt : "REFLECTIONMAP_SKYBOX"
- }, {
- search: /REFLECTIONMAP_3D/g,
- replace: (Et = Ct == null ? void 0 : Ct._define3DName) !== null && Et !== void 0 ? Et : "REFLECTIONMAP_3D"
- }]
- });
- var Ht = this.subsurface.isConnected ? (At = this.subsurface.connectedPoint) === null || At === void 0 ? void 0 : At.ownerBlock : null
- , 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;
- zt && (zt.viewConnectionPoint = this.view,
- zt.indexOfRefractionConnectionPoint = this.indexOfRefraction),
- i.compilationString += SubSurfaceBlock.GetCode(i, Ht, Ct, wt),
- i._emitFunctionFromInclude("pbrBlockSubSurface", Ot, {
- replaceStrings: [{
- search: /REFLECTIONMAP_3D/g,
- replace: (xt = Ct == null ? void 0 : Ct._define3DName) !== null && xt !== void 0 ? xt : "REFLECTIONMAP_3D"
- }, {
- search: /REFLECTIONMAP_OPPOSITEZ/g,
- replace: (bt = Ct == null ? void 0 : Ct._defineOppositeZ) !== null && bt !== void 0 ? bt : "REFLECTIONMAP_OPPOSITEZ"
- }, {
- search: /REFLECTIONMAP_PROJECTION/g,
- replace: (Rt = Ct == null ? void 0 : Ct._defineProjectionName) !== null && Rt !== void 0 ? Rt : "REFLECTIONMAP_PROJECTION"
- }, {
- search: /SS_REFRACTIONMAP_3D/g,
- replace: (Mt = zt == null ? void 0 : zt._define3DName) !== null && Mt !== void 0 ? Mt : "SS_REFRACTIONMAP_3D"
- }, {
- search: /SS_LODINREFRACTIONALPHA/g,
- replace: (Pt = zt == null ? void 0 : zt._defineLODRefractionAlpha) !== null && Pt !== void 0 ? Pt : "SS_LODINREFRACTIONALPHA"
- }, {
- search: /SS_LINEARSPECULARREFRACTION/g,
- replace: (It = zt == null ? void 0 : zt._defineLinearSpecularRefraction) !== null && It !== void 0 ? It : "SS_LINEARSPECULARREFRACTION"
- }, {
- search: /SS_REFRACTIONMAP_OPPOSITEZ/g,
- replace: (Dt = zt == null ? void 0 : zt._defineOppositeZ) !== null && Dt !== void 0 ? Dt : "SS_REFRACTIONMAP_OPPOSITEZ"
- }]
- }),
- i.compilationString += i._emitCodeFromInclude("pbrBlockDirectLighting", Ot),
- this.light ? i.compilationString += i._emitCodeFromInclude("lightFragment", Ot, {
- replaceStrings: [{
- search: /{X}/g,
- replace: this._lightId.toString()
- }]
- }) : i.compilationString += i._emitCodeFromInclude("lightFragment", Ot, {
- repeatKey: "maxSimultaneousLights"
- }),
- i.compilationString += i._emitCodeFromInclude("pbrBlockFinalLitComponents", Ot),
- i.compilationString += `#endif\r
- `;
- var Wt = this.ambientColor.isConnected ? this.ambientColor.associatedVariableName : "vec3(0., 0., 0.)"
- , Kt = PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS.toString();
- Kt.indexOf(".") === -1 && (Kt += "."),
- i.compilationString += i._emitCodeFromInclude("pbrBlockFinalUnlitComponents", Ot, {
- replaceStrings: [{
- search: /vec3 finalEmissive[\s\S]*?finalEmissive\*=vLightingIntensity\.y;/g,
- replace: ""
- }, {
- search: /vAmbientColor/g,
- replace: Wt + " * ambientFromScene"
- }, {
- search: /vAmbientInfos\.w/g,
- replace: Kt
- }]
- }),
- i.compilationString += i._emitCodeFromInclude("pbrBlockFinalColorComposition", Ot, {
- replaceStrings: [{
- search: /finalEmissive/g,
- replace: "vec3(0.)"
- }]
- }),
- i.compilationString += i._emitCodeFromInclude("pbrBlockImageProcessing", Ot, {
- replaceStrings: [{
- search: /visibility/g,
- replace: "1."
- }]
- }),
- i.compilationString += i._emitCodeFromInclude("pbrDebug", Ot, {
- replaceStrings: [{
- search: /vNormalW/g,
- replace: this._vNormalWName
- }, {
- search: /vPositionW/g,
- replace: wt
- }, {
- search: /albedoTexture\.rgb;/g,
- replace: `vec3(1.);\r
- gl_FragColor.rgb = toGammaSpace(gl_FragColor.rgb);\r
- `
- }]
- });
- for (var Qt = 0, qt = this._outputs; Qt < qt.length; Qt++) {
- var Yt = qt[Qt];
- if (Yt.hasEndpoints) {
- var Jt = mapOutputToVariable[Yt.name];
- if (Jt) {
- var jt = Jt[0]
- , Xt = Jt[1];
- Xt && (i.compilationString += "#if " + Xt + `\r
- `),
- i.compilationString += this._declareOutput(Yt, i) + " = " + jt + `;\r
- `,
- Xt && (i.compilationString += `#else\r
- `,
- i.compilationString += this._declareOutput(Yt, i) + ` = vec3(0.);\r
- `,
- i.compilationString += `#endif\r
- `)
- } else
- console.error("There's no remapping for the " + Yt.name + " end point! No code generated")
- }
- }
- return this
- }
- ,
- e.prototype._dumpPropertiesCode = function() {
- var i = a.prototype._dumpPropertiesCode.call(this);
- return i += this._codeVariableName + ".lightFalloff = " + this.lightFalloff + `;\r
- `,
- i += this._codeVariableName + ".useAlphaTest = " + this.useAlphaTest + `;\r
- `,
- i += this._codeVariableName + ".alphaTestCutoff = " + this.alphaTestCutoff + `;\r
- `,
- i += this._codeVariableName + ".useAlphaBlending = " + this.useAlphaBlending + `;\r
- `,
- i += this._codeVariableName + ".useRadianceOverAlpha = " + this.useRadianceOverAlpha + `;\r
- `,
- i += this._codeVariableName + ".useSpecularOverAlpha = " + this.useSpecularOverAlpha + `;\r
- `,
- i += this._codeVariableName + ".enableSpecularAntiAliasing = " + this.enableSpecularAntiAliasing + `;\r
- `,
- i += this._codeVariableName + ".realTimeFiltering = " + this.realTimeFiltering + `;\r
- `,
- i += this._codeVariableName + ".realTimeFilteringQuality = " + this.realTimeFilteringQuality + `;\r
- `,
- i += this._codeVariableName + ".useEnergyConservation = " + this.useEnergyConservation + `;\r
- `,
- i += this._codeVariableName + ".useRadianceOcclusion = " + this.useRadianceOcclusion + `;\r
- `,
- i += this._codeVariableName + ".useHorizonOcclusion = " + this.useHorizonOcclusion + `;\r
- `,
- i += this._codeVariableName + ".unlit = " + this.unlit + `;\r
- `,
- i += this._codeVariableName + ".forceNormalForward = " + this.forceNormalForward + `;\r
- `,
- i += this._codeVariableName + ".debugMode = " + this.debugMode + `;\r
- `,
- i += this._codeVariableName + ".debugLimit = " + this.debugLimit + `;\r
- `,
- i += this._codeVariableName + ".debugFactor = " + this.debugFactor + `;\r
- `,
- i
- }
- ,
- e.prototype.serialize = function() {
- var i = a.prototype.serialize.call(this);
- return this.light && (i.lightId = this.light.id),
- i.lightFalloff = this.lightFalloff,
- i.useAlphaTest = this.useAlphaTest,
- i.alphaTestCutoff = this.alphaTestCutoff,
- i.useAlphaBlending = this.useAlphaBlending,
- i.useRadianceOverAlpha = this.useRadianceOverAlpha,
- i.useSpecularOverAlpha = this.useSpecularOverAlpha,
- i.enableSpecularAntiAliasing = this.enableSpecularAntiAliasing,
- i.realTimeFiltering = this.realTimeFiltering,
- i.realTimeFilteringQuality = this.realTimeFilteringQuality,
- i.useEnergyConservation = this.useEnergyConservation,
- i.useRadianceOcclusion = this.useRadianceOcclusion,
- i.useHorizonOcclusion = this.useHorizonOcclusion,
- i.unlit = this.unlit,
- i.forceNormalForward = this.forceNormalForward,
- i.debugMode = this.debugMode,
- i.debugLimit = this.debugLimit,
- i.debugFactor = this.debugFactor,
- i
- }
- ,
- e.prototype._deserialize = function(i, o, s) {
- var c, d;
- a.prototype._deserialize.call(this, i, o, s),
- i.lightId && (this.light = o.getLightById(i.lightId)),
- this.lightFalloff = (c = i.lightFalloff) !== null && c !== void 0 ? c : 0,
- this.useAlphaTest = i.useAlphaTest,
- this.alphaTestCutoff = i.alphaTestCutoff,
- this.useAlphaBlending = i.useAlphaBlending,
- this.useRadianceOverAlpha = i.useRadianceOverAlpha,
- this.useSpecularOverAlpha = i.useSpecularOverAlpha,
- this.enableSpecularAntiAliasing = i.enableSpecularAntiAliasing,
- this.realTimeFiltering = !!i.realTimeFiltering,
- this.realTimeFilteringQuality = (d = i.realTimeFilteringQuality) !== null && d !== void 0 ? d : 8,
- this.useEnergyConservation = i.useEnergyConservation,
- this.useRadianceOcclusion = i.useRadianceOcclusion,
- this.useHorizonOcclusion = i.useHorizonOcclusion,
- this.unlit = i.unlit,
- this.forceNormalForward = !!i.forceNormalForward,
- this.debugMode = i.debugMode,
- this.debugLimit = i.debugLimit,
- this.debugFactor = i.debugFactor
- }
- ,
- __decorate([editableInPropertyPage("Direct lights", PropertyTypeForEdition.Float, "INTENSITY", {
- min: 0,
- max: 1,
- notifiers: {
- update: !0
- }
- })], e.prototype, "directIntensity", void 0),
- __decorate([editableInPropertyPage("Environment lights", PropertyTypeForEdition.Float, "INTENSITY", {
- min: 0,
- max: 1,
- notifiers: {
- update: !0
- }
- })], e.prototype, "environmentIntensity", void 0),
- __decorate([editableInPropertyPage("Specular highlights", PropertyTypeForEdition.Float, "INTENSITY", {
- min: 0,
- max: 1,
- notifiers: {
- update: !0
- }
- })], e.prototype, "specularIntensity", void 0),
- __decorate([editableInPropertyPage("Light falloff", PropertyTypeForEdition.List, "LIGHTING & COLORS", {
- notifiers: {
- update: !0
- },
- options: [{
- label: "Physical",
- value: PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL
- }, {
- label: "GLTF",
- value: PBRBaseMaterial.LIGHTFALLOFF_GLTF
- }, {
- label: "Standard",
- value: PBRBaseMaterial.LIGHTFALLOFF_STANDARD
- }]
- })], e.prototype, "lightFalloff", void 0),
- __decorate([editableInPropertyPage("Alpha Testing", PropertyTypeForEdition.Boolean, "OPACITY")], e.prototype, "useAlphaTest", void 0),
- __decorate([editableInPropertyPage("Alpha CutOff", PropertyTypeForEdition.Float, "OPACITY", {
- min: 0,
- max: 1,
- notifiers: {
- update: !0
- }
- })], e.prototype, "alphaTestCutoff", void 0),
- __decorate([editableInPropertyPage("Alpha blending", PropertyTypeForEdition.Boolean, "OPACITY")], e.prototype, "useAlphaBlending", void 0),
- __decorate([editableInPropertyPage("Radiance over alpha", PropertyTypeForEdition.Boolean, "RENDERING", {
- notifiers: {
- update: !0
- }
- })], e.prototype, "useRadianceOverAlpha", void 0),
- __decorate([editableInPropertyPage("Specular over alpha", PropertyTypeForEdition.Boolean, "RENDERING", {
- notifiers: {
- update: !0
- }
- })], e.prototype, "useSpecularOverAlpha", void 0),
- __decorate([editableInPropertyPage("Specular anti-aliasing", PropertyTypeForEdition.Boolean, "RENDERING", {
- notifiers: {
- update: !0
- }
- })], e.prototype, "enableSpecularAntiAliasing", void 0),
- __decorate([editableInPropertyPage("Realtime filtering", PropertyTypeForEdition.Boolean, "RENDERING", {
- notifiers: {
- update: !0
- }
- })], e.prototype, "realTimeFiltering", void 0),
- __decorate([editableInPropertyPage("Realtime filtering quality", PropertyTypeForEdition.List, "RENDERING", {
- notifiers: {
- update: !0
- },
- options: [{
- label: "Low",
- value: 8
- }, {
- label: "Medium",
- value: 16
- }, {
- label: "High",
- value: 64
- }]
- })], e.prototype, "realTimeFilteringQuality", void 0),
- __decorate([editableInPropertyPage("Energy Conservation", PropertyTypeForEdition.Boolean, "ADVANCED", {
- notifiers: {
- update: !0
- }
- })], e.prototype, "useEnergyConservation", void 0),
- __decorate([editableInPropertyPage("Radiance occlusion", PropertyTypeForEdition.Boolean, "ADVANCED", {
- notifiers: {
- update: !0
- }
- })], e.prototype, "useRadianceOcclusion", void 0),
- __decorate([editableInPropertyPage("Horizon occlusion", PropertyTypeForEdition.Boolean, "ADVANCED", {
- notifiers: {
- update: !0
- }
- })], e.prototype, "useHorizonOcclusion", void 0),
- __decorate([editableInPropertyPage("Unlit", PropertyTypeForEdition.Boolean, "ADVANCED", {
- notifiers: {
- update: !0
- }
- })], e.prototype, "unlit", void 0),
- __decorate([editableInPropertyPage("Force normal forward", PropertyTypeForEdition.Boolean, "ADVANCED", {
- notifiers: {
- update: !0
- }
- })], e.prototype, "forceNormalForward", void 0),
- __decorate([editableInPropertyPage("Debug mode", PropertyTypeForEdition.List, "DEBUG", {
- notifiers: {
- update: !0
- },
- options: [{
- label: "None",
- value: 0
- }, {
- label: "Normalized position",
- value: 1
- }, {
- label: "Normals",
- value: 2
- }, {
- label: "Tangents",
- value: 3
- }, {
- label: "Bitangents",
- value: 4
- }, {
- label: "Bump Normals",
- value: 5
- }, {
- label: "ClearCoat Normals",
- value: 8
- }, {
- label: "ClearCoat Tangents",
- value: 9
- }, {
- label: "ClearCoat Bitangents",
- value: 10
- }, {
- label: "Anisotropic Normals",
- value: 11
- }, {
- label: "Anisotropic Tangents",
- value: 12
- }, {
- label: "Anisotropic Bitangents",
- value: 13
- }, {
- label: "Env Refraction",
- value: 40
- }, {
- label: "Env Reflection",
- value: 41
- }, {
- label: "Env Clear Coat",
- value: 42
- }, {
- label: "Direct Diffuse",
- value: 50
- }, {
- label: "Direct Specular",
- value: 51
- }, {
- label: "Direct Clear Coat",
- value: 52
- }, {
- label: "Direct Sheen",
- value: 53
- }, {
- label: "Env Irradiance",
- value: 54
- }, {
- label: "Surface Albedo",
- value: 60
- }, {
- label: "Reflectance 0",
- value: 61
- }, {
- label: "Metallic",
- value: 62
- }, {
- label: "Metallic F0",
- value: 71
- }, {
- label: "Roughness",
- value: 63
- }, {
- label: "AlphaG",
- value: 64
- }, {
- label: "NdotV",
- value: 65
- }, {
- label: "ClearCoat Color",
- value: 66
- }, {
- label: "ClearCoat Roughness",
- value: 67
- }, {
- label: "ClearCoat NdotV",
- value: 68
- }, {
- label: "Transmittance",
- value: 69
- }, {
- label: "Refraction Transmittance",
- value: 70
- }, {
- label: "SEO",
- value: 80
- }, {
- label: "EHO",
- value: 81
- }, {
- label: "Energy Factor",
- value: 82
- }, {
- label: "Specular Reflectance",
- value: 83
- }, {
- label: "Clear Coat Reflectance",
- value: 84
- }, {
- label: "Sheen Reflectance",
- value: 85
- }, {
- label: "Luminance Over Alpha",
- value: 86
- }, {
- label: "Alpha",
- value: 87
- }]
- })], e.prototype, "debugMode", void 0),
- __decorate([editableInPropertyPage("Split position", PropertyTypeForEdition.Float, "DEBUG", {
- min: -1,
- max: 1,
- notifiers: {
- update: !0
- }
- })], e.prototype, "debugLimit", void 0),
- __decorate([editableInPropertyPage("Output factor", PropertyTypeForEdition.Float, "DEBUG", {
- min: 0,
- max: 5,
- notifiers: {
- update: !0
- }
- })], e.prototype, "debugFactor", void 0),
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.PBRMetallicRoughnessBlock", PBRMetallicRoughnessBlock);
- var ModBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("left", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerInput("right", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
- o._outputs[0]._typeConnectionSource = o._inputs[0],
- o._linkConnectionTypes(0, 1),
- o
- }
- return e.prototype.getClassName = function() {
- return "ModBlock"
- }
- ,
- Object.defineProperty(e.prototype, "left", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "right", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0];
- return i.compilationString += this._declareOutput(o, i) + (" = mod(" + this.left.associatedVariableName + ", " + this.right.associatedVariableName + `);\r
- `),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.ModBlock", ModBlock);
- var MatrixBuilderBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("row0", NodeMaterialBlockConnectionPointTypes.Vector4),
- o.registerInput("row1", NodeMaterialBlockConnectionPointTypes.Vector4),
- o.registerInput("row2", NodeMaterialBlockConnectionPointTypes.Vector4),
- o.registerInput("row3", NodeMaterialBlockConnectionPointTypes.Vector4),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Matrix),
- o
- }
- return e.prototype.getClassName = function() {
- return "MatrixBuilder"
- }
- ,
- Object.defineProperty(e.prototype, "row0", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "row1", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "row2", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "row3", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.autoConfigure = function(i) {
- if (!this.row0.isConnected) {
- var o = new InputBlock("row0");
- o.value = new Vector4(1,0,0,0),
- o.output.connectTo(this.row0)
- }
- if (!this.row1.isConnected) {
- var s = new InputBlock("row1");
- s.value = new Vector4(0,1,0,0),
- s.output.connectTo(this.row1)
- }
- if (!this.row2.isConnected) {
- var c = new InputBlock("row2");
- c.value = new Vector4(0,0,1,0),
- c.output.connectTo(this.row2)
- }
- if (!this.row3.isConnected) {
- var d = new InputBlock("row3");
- d.value = new Vector4(0,0,0,1),
- d.output.connectTo(this.row3)
- }
- }
- ,
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0]
- , s = this.row0
- , c = this.row1
- , d = this.row2
- , _ = this.row3;
- return i.compilationString += this._declareOutput(o, i) + (" = mat4(" + s.associatedVariableName + ", " + c.associatedVariableName + ", " + d.associatedVariableName + ", " + _.associatedVariableName + `);\r
- `),
- this
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.MatrixBuilder", MatrixBuilderBlock);
- var ConditionalBlockConditions;
- (function(a) {
- a[a.Equal = 0] = "Equal",
- a[a.NotEqual = 1] = "NotEqual",
- a[a.LessThan = 2] = "LessThan",
- a[a.GreaterThan = 3] = "GreaterThan",
- a[a.LessOrEqual = 4] = "LessOrEqual",
- a[a.GreaterOrEqual = 5] = "GreaterOrEqual",
- a[a.Xor = 6] = "Xor",
- a[a.Or = 7] = "Or",
- a[a.And = 8] = "And"
- }
- )(ConditionalBlockConditions || (ConditionalBlockConditions = {}));
- var ConditionalBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.condition = ConditionalBlockConditions.LessThan,
- o.registerInput("a", NodeMaterialBlockConnectionPointTypes.Float),
- o.registerInput("b", NodeMaterialBlockConnectionPointTypes.Float),
- o.registerInput("true", NodeMaterialBlockConnectionPointTypes.AutoDetect, !0),
- o.registerInput("false", NodeMaterialBlockConnectionPointTypes.AutoDetect, !0),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput),
- o._linkConnectionTypes(2, 3),
- o._outputs[0]._typeConnectionSource = o._inputs[2],
- o._outputs[0]._defaultConnectionPointType = NodeMaterialBlockConnectionPointTypes.Float,
- o
- }
- return e.prototype.getClassName = function() {
- return "ConditionalBlock"
- }
- ,
- Object.defineProperty(e.prototype, "a", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "b", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "true", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "false", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- a.prototype._buildBlock.call(this, i);
- var o = this._outputs[0]
- , s = this.true.isConnected ? this.true.associatedVariableName : "1.0"
- , c = this.false.isConnected ? this.false.associatedVariableName : "0.0";
- switch (this.condition) {
- case ConditionalBlockConditions.Equal:
- {
- i.compilationString += this._declareOutput(o, i) + (" = " + this.a.associatedVariableName + " == " + this.b.associatedVariableName + " ? " + s + " : " + c + `;\r
- `);
- break
- }
- case ConditionalBlockConditions.NotEqual:
- {
- i.compilationString += this._declareOutput(o, i) + (" = " + this.a.associatedVariableName + " != " + this.b.associatedVariableName + " ? " + s + " : " + c + `;\r
- `);
- break
- }
- case ConditionalBlockConditions.LessThan:
- {
- i.compilationString += this._declareOutput(o, i) + (" = " + this.a.associatedVariableName + " < " + this.b.associatedVariableName + " ? " + s + " : " + c + `;\r
- `);
- break
- }
- case ConditionalBlockConditions.LessOrEqual:
- {
- i.compilationString += this._declareOutput(o, i) + (" = " + this.a.associatedVariableName + " <= " + this.b.associatedVariableName + " ? " + s + " : " + c + `;\r
- `);
- break
- }
- case ConditionalBlockConditions.GreaterThan:
- {
- i.compilationString += this._declareOutput(o, i) + (" = " + this.a.associatedVariableName + " > " + this.b.associatedVariableName + " ? " + s + " : " + c + `;\r
- `);
- break
- }
- case ConditionalBlockConditions.GreaterOrEqual:
- {
- i.compilationString += this._declareOutput(o, i) + (" = " + this.a.associatedVariableName + " >= " + this.b.associatedVariableName + " ? " + s + " : " + c + `;\r
- `);
- break
- }
- case ConditionalBlockConditions.Xor:
- {
- i.compilationString += this._declareOutput(o, i) + (" = (mod(" + this.a.associatedVariableName + " + " + this.b.associatedVariableName + ", 2.0) > 0.0) ? " + s + " : " + c + `;\r
- `);
- break
- }
- case ConditionalBlockConditions.Or:
- {
- i.compilationString += this._declareOutput(o, i) + (" = (min(" + this.a.associatedVariableName + " + " + this.b.associatedVariableName + ", 1.0) > 0.0) ? " + s + " : " + c + `;\r
- `);
- break
- }
- case ConditionalBlockConditions.And:
- {
- i.compilationString += this._declareOutput(o, i) + (" = (" + this.a.associatedVariableName + " * " + this.b.associatedVariableName + " > 0.0) ? " + s + " : " + c + `;\r
- `);
- break
- }
- }
- return this
- }
- ,
- e.prototype.serialize = function() {
- var i = a.prototype.serialize.call(this);
- return i.condition = this.condition,
- i
- }
- ,
- e.prototype._deserialize = function(i, o, s) {
- a.prototype._deserialize.call(this, i, o, s),
- this.condition = i.condition
- }
- ,
- e.prototype._dumpPropertiesCode = function() {
- var i = a.prototype._dumpPropertiesCode.call(this) + (this._codeVariableName + ".condition = BABYLON.ConditionalBlockConditions." + ConditionalBlockConditions[this.condition] + `;\r
- `);
- return i
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.ConditionalBlock", ConditionalBlock);
- var CloudBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.octaves = 6,
- o.registerInput("seed", NodeMaterialBlockConnectionPointTypes.AutoDetect),
- o.registerInput("chaos", NodeMaterialBlockConnectionPointTypes.AutoDetect, !0),
- o.registerInput("offsetX", NodeMaterialBlockConnectionPointTypes.Float, !0),
- o.registerInput("offsetY", NodeMaterialBlockConnectionPointTypes.Float, !0),
- o.registerInput("offsetZ", NodeMaterialBlockConnectionPointTypes.Float, !0),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Float),
- o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector2),
- o._inputs[0].acceptedConnectionPointTypes.push(NodeMaterialBlockConnectionPointTypes.Vector3),
- o._linkConnectionTypes(0, 1),
- o
- }
- return e.prototype.getClassName = function() {
- return "CloudBlock"
- }
- ,
- Object.defineProperty(e.prototype, "seed", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "chaos", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "offsetX", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "offsetY", {
- get: function() {
- return this._inputs[3]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "offsetZ", {
- get: function() {
- return this._inputs[4]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- var o, s;
- if (a.prototype._buildBlock.call(this, i),
- !!this.seed.isConnected && !!this._outputs[0].hasEndpoints) {
- var c = `
- float cloudRandom(in float p) { p = fract(p * 0.011); p *= p + 7.5; p *= p + p; return fract(p); }
- // Based on Morgan McGuire @morgan3d
- // https://www.shadertoy.com/view/4dS3Wd
- float cloudNoise(in vec2 x, in vec2 chaos) {
- vec2 step = chaos * vec2(75., 120.) + vec2(75., 120.);
- vec2 i = floor(x);
- vec2 f = fract(x);
- float n = dot(i, step);
- vec2 u = f * f * (3.0 - 2.0 * f);
- return mix(
- mix(cloudRandom(n + dot(step, vec2(0, 0))), cloudRandom(n + dot(step, vec2(1, 0))), u.x),
- mix(cloudRandom(n + dot(step, vec2(0, 1))), cloudRandom(n + dot(step, vec2(1, 1))), u.x),
- u.y
- );
- }
- float cloudNoise(in vec3 x, in vec3 chaos) {
- vec3 step = chaos * vec3(60., 120., 75.) + vec3(60., 120., 75.);
- vec3 i = floor(x);
- vec3 f = fract(x);
- float n = dot(i, step);
- vec3 u = f * f * (3.0 - 2.0 * f);
- return mix(mix(mix( cloudRandom(n + dot(step, vec3(0, 0, 0))), cloudRandom(n + dot(step, vec3(1, 0, 0))), u.x),
- mix( cloudRandom(n + dot(step, vec3(0, 1, 0))), cloudRandom(n + dot(step, vec3(1, 1, 0))), u.x), u.y),
- mix(mix( cloudRandom(n + dot(step, vec3(0, 0, 1))), cloudRandom(n + dot(step, vec3(1, 0, 1))), u.x),
- mix( cloudRandom(n + dot(step, vec3(0, 1, 1))), cloudRandom(n + dot(step, vec3(1, 1, 1))), u.x), u.y), u.z);
- }`
- , d = `
- float fbm(in vec2 st, in vec2 chaos) {
- // Initial values
- float value = 0.0;
- float amplitude = .5;
- float frequency = 0.;
- // Loop of octaves
- for (int i = 0; i < OCTAVES; i++) {
- value += amplitude * cloudNoise(st, chaos);
- st *= 2.0;
- amplitude *= 0.5;
- }
- return value;
- }
- float fbm(in vec3 x, in vec3 chaos) {
- // Initial values
- float value = 0.0;
- float amplitude = 0.5;
- for (int i = 0; i < OCTAVES; ++i) {
- value += amplitude * cloudNoise(x, chaos);
- x = x * 2.0;
- amplitude *= 0.5;
- }
- return value;
- }`
- , _ = "fbm" + this.octaves;
- i._emitFunction("CloudBlockCode", c, "// CloudBlockCode"),
- i._emitFunction("CloudBlockCodeFBM" + this.octaves, d.replace(/fbm/gi, _).replace(/OCTAVES/gi, (this.octaves | 0).toString()), "// CloudBlockCode FBM");
- var b = i._getFreeVariableName("st")
- , k = ((o = this.seed.connectedPoint) === null || o === void 0 ? void 0 : o.type) === NodeMaterialBlockConnectionPointTypes.Vector2 ? "vec2" : "vec3";
- i.compilationString += k + " " + b + " = " + this.seed.associatedVariableName + `;\r
- `,
- this.offsetX.isConnected && (i.compilationString += b + ".x += 0.1 * " + this.offsetX.associatedVariableName + `;\r
- `),
- this.offsetY.isConnected && (i.compilationString += b + ".y += 0.1 * " + this.offsetY.associatedVariableName + `;\r
- `),
- this.offsetZ.isConnected && k === "vec3" && (i.compilationString += b + ".z += 0.1 * " + this.offsetZ.associatedVariableName + `;\r
- `);
- var j = "";
- 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.)",
- i.compilationString += this._declareOutput(this._outputs[0], i) + (" = " + _ + "(" + b + ", " + j + `);\r
- `),
- this
- }
- }
- ,
- e.prototype._dumpPropertiesCode = function() {
- var i = a.prototype._dumpPropertiesCode.call(this) + (this._codeVariableName + ".octaves = " + this.octaves + `;\r
- `);
- return i
- }
- ,
- e.prototype.serialize = function() {
- var i = a.prototype.serialize.call(this);
- return i.octaves = this.octaves,
- i
- }
- ,
- e.prototype._deserialize = function(i, o, s) {
- a.prototype._deserialize.call(this, i, o, s),
- this.octaves = i.octaves
- }
- ,
- __decorate([editableInPropertyPage("Octaves", PropertyTypeForEdition.Int)], e.prototype, "octaves", void 0),
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.CloudBlock", CloudBlock);
- var VoronoiNoiseBlock = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i, NodeMaterialBlockTargets.Neutral) || this;
- return o.registerInput("seed", NodeMaterialBlockConnectionPointTypes.Vector2),
- o.registerInput("offset", NodeMaterialBlockConnectionPointTypes.Float),
- o.registerInput("density", NodeMaterialBlockConnectionPointTypes.Float),
- o.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Float),
- o.registerOutput("cells", NodeMaterialBlockConnectionPointTypes.Float),
- o
- }
- return e.prototype.getClassName = function() {
- return "VoronoiNoiseBlock"
- }
- ,
- Object.defineProperty(e.prototype, "seed", {
- get: function() {
- return this._inputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "offset", {
- get: function() {
- return this._inputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "density", {
- get: function() {
- return this._inputs[2]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "output", {
- get: function() {
- return this._outputs[0]
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cells", {
- get: function() {
- return this._outputs[1]
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._buildBlock = function(i) {
- if (a.prototype._buildBlock.call(this, i),
- !!this.seed.isConnected) {
- var o = `vec2 voronoiRandom(vec2 seed, float offset){
- mat2 m = mat2(15.27, 47.63, 99.41, 89.98);
- vec2 uv = fract(sin(m * seed) * 46839.32);
- return vec2(sin(uv.y * offset) * 0.5 + 0.5, cos(uv.x * offset) * 0.5 + 0.5);
- }
- `;
- i._emitFunction("voronoiRandom", o, "// Voronoi random generator"),
- o = `void voronoi(vec2 seed, float offset, float density, out float outValue, out float cells){
- vec2 g = floor(seed * density);
- vec2 f = fract(seed * density);
- float t = 8.0;
- vec3 res = vec3(8.0, 0.0, 0.0);
- for(int y=-1; y<=1; y++)
- {
- for(int x=-1; x<=1; x++)
- {
- vec2 lattice = vec2(x,y);
- vec2 randomOffset = voronoiRandom(lattice + g, offset);
- float d = distance(lattice + randomOffset, f);
- if(d < res.x)
- {
- res = vec3(d, randomOffset.x, randomOffset.y);
- outValue = res.x;
- cells = res.y;
- }
- }
- }
- }
- `,
- i._emitFunction("voronoi", o, "// Voronoi");
- var s = i._getFreeVariableName("tempOutput")
- , c = i._getFreeVariableName("tempCells");
- return i.compilationString += "float " + s + ` = 0.0;\r
- `,
- i.compilationString += "float " + c + ` = 0.0;\r
- `,
- i.compilationString += "voronoi(" + this.seed.associatedVariableName + ", " + this.offset.associatedVariableName + ", " + this.density.associatedVariableName + ", " + s + ", " + c + `);\r
- `,
- this.output.hasEndpoints && (i.compilationString += this._declareOutput(this.output, i) + (" = " + s + `;\r
- `)),
- this.cells.hasEndpoints && (i.compilationString += this._declareOutput(this.cells, i) + (" = " + c + `;\r
- `)),
- this
- }
- }
- ,
- e
- }(NodeMaterialBlock);
- RegisterClass("BABYLON.VoronoiNoiseBlock", VoronoiNoiseBlock);
- Node$2.AddNodeConstructor("Light_Type_2", function(a, e) {
- return function() {
- return new SpotLight(a,Vector3.Zero(),Vector3.Zero(),0,0,e)
- }
- });
- var SpotLight = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _) {
- var b = a.call(this, i, _) || this;
- return b._innerAngle = 0,
- b._projectionTextureMatrix = Matrix.Zero(),
- b._projectionTextureLightNear = 1e-6,
- b._projectionTextureLightFar = 1e3,
- b._projectionTextureUpDirection = Vector3.Up(),
- b._projectionTextureViewLightDirty = !0,
- b._projectionTextureProjectionLightDirty = !0,
- b._projectionTextureDirty = !0,
- b._projectionTextureViewTargetVector = Vector3.Zero(),
- b._projectionTextureViewLightMatrix = Matrix.Zero(),
- b._projectionTextureProjectionLightMatrix = Matrix.Zero(),
- b._projectionTextureScalingMatrix = Matrix.FromValues(.5, 0, 0, 0, 0, .5, 0, 0, 0, 0, .5, 0, .5, .5, .5, 1),
- b.position = o,
- b.direction = s,
- b.angle = c,
- b.exponent = d,
- b
- }
- return Object.defineProperty(e.prototype, "angle", {
- get: function() {
- return this._angle
- },
- set: function(i) {
- this._angle = i,
- this._cosHalfAngle = Math.cos(i * .5),
- this._projectionTextureProjectionLightDirty = !0,
- this.forceProjectionMatrixCompute(),
- this._computeAngleValues()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "innerAngle", {
- get: function() {
- return this._innerAngle
- },
- set: function(i) {
- this._innerAngle = i,
- this._computeAngleValues()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "shadowAngleScale", {
- get: function() {
- return this._shadowAngleScale
- },
- set: function(i) {
- this._shadowAngleScale = i,
- this.forceProjectionMatrixCompute()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "projectionTextureMatrix", {
- get: function() {
- return this._projectionTextureMatrix
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "projectionTextureLightNear", {
- get: function() {
- return this._projectionTextureLightNear
- },
- set: function(i) {
- this._projectionTextureLightNear = i,
- this._projectionTextureProjectionLightDirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "projectionTextureLightFar", {
- get: function() {
- return this._projectionTextureLightFar
- },
- set: function(i) {
- this._projectionTextureLightFar = i,
- this._projectionTextureProjectionLightDirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "projectionTextureUpDirection", {
- get: function() {
- return this._projectionTextureUpDirection
- },
- set: function(i) {
- this._projectionTextureUpDirection = i,
- this._projectionTextureProjectionLightDirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "projectionTexture", {
- get: function() {
- return this._projectionTexture
- },
- set: function(i) {
- var o = this;
- this._projectionTexture !== i && (this._projectionTexture = i,
- this._projectionTextureDirty = !0,
- this._projectionTexture && !this._projectionTexture.isReady() && (e._IsProceduralTexture(this._projectionTexture) ? this._projectionTexture.getEffect().executeWhenCompiled(function() {
- o._markMeshesAsLightDirty()
- }) : e._IsTexture(this._projectionTexture) && this._projectionTexture.onLoadObservable.addOnce(function() {
- o._markMeshesAsLightDirty()
- })))
- },
- enumerable: !1,
- configurable: !0
- }),
- e._IsProceduralTexture = function(i) {
- return i.onGeneratedObservable !== void 0
- }
- ,
- e._IsTexture = function(i) {
- return i.onLoadObservable !== void 0
- }
- ,
- Object.defineProperty(e.prototype, "projectionTextureProjectionLightMatrix", {
- get: function() {
- return this._projectionTextureProjectionLightMatrix
- },
- set: function(i) {
- this._projectionTextureProjectionLightMatrix = i,
- this._projectionTextureProjectionLightDirty = !1,
- this._projectionTextureDirty = !0
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getClassName = function() {
- return "SpotLight"
- }
- ,
- e.prototype.getTypeID = function() {
- return Light.LIGHTTYPEID_SPOTLIGHT
- }
- ,
- e.prototype._setDirection = function(i) {
- a.prototype._setDirection.call(this, i),
- this._projectionTextureViewLightDirty = !0
- }
- ,
- e.prototype._setPosition = function(i) {
- a.prototype._setPosition.call(this, i),
- this._projectionTextureViewLightDirty = !0
- }
- ,
- e.prototype._setDefaultShadowProjectionMatrix = function(i, o, s) {
- var c = this.getScene().activeCamera;
- if (!!c) {
- this._shadowAngleScale = this._shadowAngleScale || 1;
- var d = this._shadowAngleScale * this._angle
- , _ = this.shadowMinZ !== void 0 ? this.shadowMinZ : c.minZ
- , b = this.shadowMaxZ !== void 0 ? this.shadowMaxZ : c.maxZ
- , k = this.getScene().getEngine().useReverseDepthBuffer;
- Matrix.PerspectiveFovLHToRef(d, 1, k ? b : _, k ? _ : b, i, !0, this._scene.getEngine().isNDCHalfZRange, void 0, k)
- }
- }
- ,
- e.prototype._computeProjectionTextureViewLightMatrix = function() {
- this._projectionTextureViewLightDirty = !1,
- this._projectionTextureDirty = !0,
- this.position.addToRef(this.direction, this._projectionTextureViewTargetVector),
- Matrix.LookAtLHToRef(this.position, this._projectionTextureViewTargetVector, this._projectionTextureUpDirection, this._projectionTextureViewLightMatrix)
- }
- ,
- e.prototype._computeProjectionTextureProjectionLightMatrix = function() {
- this._projectionTextureProjectionLightDirty = !1,
- this._projectionTextureDirty = !0;
- var i = this.projectionTextureLightFar
- , o = this.projectionTextureLightNear
- , s = i / (i - o)
- , c = -s * o
- , d = 1 / Math.tan(this._angle / 2)
- , _ = 1;
- Matrix.FromValuesToRef(d / _, 0, 0, 0, 0, d, 0, 0, 0, 0, s, 1, 0, 0, c, 0, this._projectionTextureProjectionLightMatrix)
- }
- ,
- e.prototype._computeProjectionTextureMatrix = function() {
- if (this._projectionTextureDirty = !1,
- this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix, this._projectionTextureMatrix),
- this._projectionTexture instanceof Texture) {
- var i = this._projectionTexture.uScale / 2
- , o = this._projectionTexture.vScale / 2;
- Matrix.FromValuesToRef(i, 0, 0, 0, 0, o, 0, 0, 0, 0, .5, 0, .5, .5, .5, 1, this._projectionTextureScalingMatrix)
- }
- this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix, this._projectionTextureMatrix)
- }
- ,
- e.prototype._buildUniformLayout = function() {
- this._uniformBuffer.addUniform("vLightData", 4),
- this._uniformBuffer.addUniform("vLightDiffuse", 4),
- this._uniformBuffer.addUniform("vLightSpecular", 4),
- this._uniformBuffer.addUniform("vLightDirection", 3),
- this._uniformBuffer.addUniform("vLightFalloff", 4),
- this._uniformBuffer.addUniform("shadowsInfo", 3),
- this._uniformBuffer.addUniform("depthValues", 2),
- this._uniformBuffer.create()
- }
- ,
- e.prototype._computeAngleValues = function() {
- this._lightAngleScale = 1 / Math.max(.001, Math.cos(this._innerAngle * .5) - this._cosHalfAngle),
- this._lightAngleOffset = -this._cosHalfAngle * this._lightAngleScale
- }
- ,
- e.prototype.transferTexturesToEffect = function(i, o) {
- return this.projectionTexture && this.projectionTexture.isReady() && (this._projectionTextureViewLightDirty && this._computeProjectionTextureViewLightMatrix(),
- this._projectionTextureProjectionLightDirty && this._computeProjectionTextureProjectionLightMatrix(),
- this._projectionTextureDirty && this._computeProjectionTextureMatrix(),
- i.setMatrix("textureProjectionMatrix" + o, this._projectionTextureMatrix),
- i.setTexture("projectionLightSampler" + o, this.projectionTexture)),
- this
- }
- ,
- e.prototype.transferToEffect = function(i, o) {
- var s;
- return this.computeTransformedInformation() ? (this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, this.exponent, o),
- s = Vector3.Normalize(this.transformedDirection)) : (this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, this.exponent, o),
- s = Vector3.Normalize(this.direction)),
- this._uniformBuffer.updateFloat4("vLightDirection", s.x, s.y, s.z, this._cosHalfAngle, o),
- this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, this._lightAngleScale, this._lightAngleOffset, o),
- this
- }
- ,
- e.prototype.transferToNodeMaterialEffect = function(i, o) {
- var s;
- return this.computeTransformedInformation() ? s = Vector3.Normalize(this.transformedDirection) : s = Vector3.Normalize(this.direction),
- this.getScene().useRightHandedSystem ? i.setFloat3(o, -s.x, -s.y, -s.z) : i.setFloat3(o, s.x, s.y, s.z),
- this
- }
- ,
- e.prototype.dispose = function() {
- a.prototype.dispose.call(this),
- this._projectionTexture && this._projectionTexture.dispose()
- }
- ,
- e.prototype.getDepthMinZ = function(i) {
- var o = this._scene.getEngine()
- , s = this.shadowMinZ !== void 0 ? this.shadowMinZ : i.minZ;
- return o.useReverseDepthBuffer && o.isNDCHalfZRange ? s : this._scene.getEngine().isNDCHalfZRange ? 0 : s
- }
- ,
- e.prototype.getDepthMaxZ = function(i) {
- var o = this._scene.getEngine()
- , s = this.shadowMaxZ !== void 0 ? this.shadowMaxZ : i.maxZ;
- return o.useReverseDepthBuffer && o.isNDCHalfZRange ? 0 : s
- }
- ,
- e.prototype.prepareLightSpecificDefines = function(i, o) {
- i["SPOTLIGHT" + o] = !0,
- i["PROJECTEDLIGHTTEXTURE" + o] = !!(this.projectionTexture && this.projectionTexture.isReady())
- }
- ,
- __decorate([serialize()], e.prototype, "angle", null),
- __decorate([serialize()], e.prototype, "innerAngle", null),
- __decorate([serialize()], e.prototype, "shadowAngleScale", null),
- __decorate([serialize()], e.prototype, "exponent", void 0),
- __decorate([serialize()], e.prototype, "projectionTextureLightNear", null),
- __decorate([serialize()], e.prototype, "projectionTextureLightFar", null),
- __decorate([serialize()], e.prototype, "projectionTextureUpDirection", null),
- __decorate([serializeAsTexture("projectedLightTexture")], e.prototype, "_projectionTexture", void 0),
- e
- }(ShadowLight)
- , name$D = "glowMapGenerationPixelShader"
- , shader$D = `#if defined(DIFFUSE_ISLINEAR) || defined(EMISSIVE_ISLINEAR)
- #include<helperFunctions>
- #endif
- #ifdef DIFFUSE
- varying vec2 vUVDiffuse;
- uniform sampler2D diffuseSampler;
- #endif
- #ifdef OPACITY
- varying vec2 vUVOpacity;
- uniform sampler2D opacitySampler;
- uniform float opacityIntensity;
- #endif
- #ifdef EMISSIVE
- varying vec2 vUVEmissive;
- uniform sampler2D emissiveSampler;
- #endif
- #ifdef VERTEXALPHA
- varying vec4 vColor;
- #endif
- uniform vec4 glowColor;
- void main(void)
- {
- vec4 finalColor=glowColor;
- #ifdef DIFFUSE
- vec4 albedoTexture=texture2D(diffuseSampler,vUVDiffuse);
- #ifdef DIFFUSE_ISLINEAR
- albedoTexture=toGammaSpace(albedoTexture);
- #endif
- #ifdef GLOW
- finalColor.a*=albedoTexture.a;
- #endif
- #ifdef HIGHLIGHT
- finalColor.a=albedoTexture.a;
- #endif
- #endif
- #ifdef OPACITY
- vec4 opacityMap=texture2D(opacitySampler,vUVOpacity);
- #ifdef OPACITYRGB
- finalColor.a*=getLuminance(opacityMap.rgb);
- #else
- finalColor.a*=opacityMap.a;
- #endif
- finalColor.a*=opacityIntensity;
- #endif
- #ifdef VERTEXALPHA
- finalColor.a*=vColor.a;
- #endif
- #ifdef ALPHATEST
- if (finalColor.a<ALPHATESTVALUE)
- discard;
- #endif
- #ifdef EMISSIVE
- vec4 emissive=texture2D(emissiveSampler,vUVEmissive);
- #ifdef EMISSIVE_ISLINEAR
- emissive=toGammaSpace(emissive);
- #endif
- gl_FragColor=emissive*finalColor;
- #else
- gl_FragColor=finalColor;
- #endif
- #ifdef HIGHLIGHT
- gl_FragColor.a=glowColor.a;
- #endif
- }`;
- ShaderStore.ShadersStore[name$D] = shader$D;
- var name$C = "glowMapGenerationVertexShader"
- , shader$C = `
- attribute vec3 position;
- #include<bonesDeclaration>
- #include<bakedVertexAnimationDeclaration>
- #include<morphTargetsVertexGlobalDeclaration>
- #include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
- #include<instancesDeclaration>
- uniform mat4 viewProjection;
- varying vec4 vPosition;
- #ifdef UV1
- attribute vec2 uv;
- #endif
- #ifdef UV2
- attribute vec2 uv2;
- #endif
- #ifdef DIFFUSE
- varying vec2 vUVDiffuse;
- uniform mat4 diffuseMatrix;
- #endif
- #ifdef OPACITY
- varying vec2 vUVOpacity;
- uniform mat4 opacityMatrix;
- #endif
- #ifdef EMISSIVE
- varying vec2 vUVEmissive;
- uniform mat4 emissiveMatrix;
- #endif
- #ifdef VERTEXALPHA
- attribute vec4 color;
- varying vec4 vColor;
- #endif
- void main(void)
- {
- vec3 positionUpdated=position;
- #ifdef UV1
- vec2 uvUpdated=uv;
- #endif
- #include<morphTargetsVertexGlobal>
- #include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
- #include<instancesVertex>
- #include<bonesVertex>
- #include<bakedVertexAnimation>
- #ifdef CUBEMAP
- vPosition=finalWorld*vec4(positionUpdated,1.0);
- gl_Position=viewProjection*finalWorld*vec4(position,1.0);
- #else
- vPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);
- gl_Position=vPosition;
- #endif
- #ifdef DIFFUSE
- #ifdef DIFFUSEUV1
- vUVDiffuse=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));
- #endif
- #ifdef DIFFUSEUV2
- vUVDiffuse=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
- #endif
- #endif
- #ifdef OPACITY
- #ifdef OPACITYUV1
- vUVOpacity=vec2(opacityMatrix*vec4(uvUpdated,1.0,0.0));
- #endif
- #ifdef OPACITYUV2
- vUVOpacity=vec2(opacityMatrix*vec4(uv2,1.0,0.0));
- #endif
- #endif
- #ifdef EMISSIVE
- #ifdef EMISSIVEUV1
- vUVEmissive=vec2(emissiveMatrix*vec4(uvUpdated,1.0,0.0));
- #endif
- #ifdef EMISSIVEUV2
- vUVEmissive=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));
- #endif
- #endif
- #ifdef VERTEXALPHA
- vColor=color;
- #endif
- }`;
- ShaderStore.ShadersStore[name$C] = shader$C;
- var EffectLayer = function() {
- function a(e, i) {
- this._vertexBuffers = {},
- this._maxSize = 0,
- this._mainTextureDesiredSize = {
- width: 0,
- height: 0
- },
- this._shouldRender = !0,
- this._postProcesses = [],
- this._textures = [],
- this._emissiveTextureAndColor = {
- texture: null,
- color: new Color4
- },
- this.neutralColor = new Color4,
- this.isEnabled = !0,
- this.disableBoundingBoxesFromEffectLayer = !1,
- this.onDisposeObservable = new Observable,
- this.onBeforeRenderMainTextureObservable = new Observable,
- this.onBeforeComposeObservable = new Observable,
- this.onBeforeRenderMeshToEffect = new Observable,
- this.onAfterRenderMeshToEffect = new Observable,
- this.onAfterComposeObservable = new Observable,
- this.onSizeChangedObservable = new Observable,
- this.name = e,
- this._scene = i || EngineStore.LastCreatedScene,
- a._SceneComponentInitialization(this._scene),
- this._engine = this._scene.getEngine(),
- this._maxSize = this._engine.getCaps().maxTextureSize,
- this._scene.effectLayers.push(this),
- this._mergeDrawWrapper = [],
- this._generateIndexBuffer(),
- this._generateVertexBuffer()
- }
- return Object.defineProperty(a.prototype, "camera", {
- get: function() {
- return this._effectLayerOptions.camera
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "renderingGroupId", {
- get: function() {
- return this._effectLayerOptions.renderingGroupId
- },
- set: function(e) {
- this._effectLayerOptions.renderingGroupId = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.setMaterialForRendering = function(e, i) {
- this._mainTexture.setMaterialForRendering(e, i)
- }
- ,
- a.prototype._numInternalDraws = function() {
- return 1
- }
- ,
- a.prototype._init = function(e) {
- this._effectLayerOptions = __assign({
- mainTextureRatio: .5,
- alphaBlendingMode: 2,
- camera: null,
- renderingGroupId: -1
- }, e),
- this._setMainTextureSize(),
- this._createMainTexture(),
- this._createTextureAndPostProcesses()
- }
- ,
- a.prototype._generateIndexBuffer = function() {
- var e = [];
- e.push(0),
- e.push(1),
- e.push(2),
- e.push(0),
- e.push(2),
- e.push(3),
- this._indexBuffer = this._engine.createIndexBuffer(e)
- }
- ,
- a.prototype._generateVertexBuffer = function() {
- var e = [];
- e.push(1, 1),
- e.push(-1, 1),
- e.push(-1, -1),
- e.push(1, -1);
- var i = new VertexBuffer(this._engine,e,VertexBuffer.PositionKind,!1,!1,2);
- this._vertexBuffers[VertexBuffer.PositionKind] = i
- }
- ,
- a.prototype._setMainTextureSize = function() {
- this._effectLayerOptions.mainTextureFixedSize ? (this._mainTextureDesiredSize.width = this._effectLayerOptions.mainTextureFixedSize,
- this._mainTextureDesiredSize.height = this._effectLayerOptions.mainTextureFixedSize) : (this._mainTextureDesiredSize.width = this._engine.getRenderWidth() * this._effectLayerOptions.mainTextureRatio,
- this._mainTextureDesiredSize.height = this._engine.getRenderHeight() * this._effectLayerOptions.mainTextureRatio,
- this._mainTextureDesiredSize.width = this._engine.needPOTTextures ? Engine.GetExponentOfTwo(this._mainTextureDesiredSize.width, this._maxSize) : this._mainTextureDesiredSize.width,
- this._mainTextureDesiredSize.height = this._engine.needPOTTextures ? Engine.GetExponentOfTwo(this._mainTextureDesiredSize.height, this._maxSize) : this._mainTextureDesiredSize.height),
- this._mainTextureDesiredSize.width = Math.floor(this._mainTextureDesiredSize.width),
- this._mainTextureDesiredSize.height = Math.floor(this._mainTextureDesiredSize.height)
- }
- ,
- a.prototype._createMainTexture = function() {
- var e = this;
- if (this._mainTexture = new RenderTargetTexture("EffectLayerMainRTT",{
- width: this._mainTextureDesiredSize.width,
- height: this._mainTextureDesiredSize.height
- },this._scene,!1,!0,0),
- this._mainTexture.activeCamera = this._effectLayerOptions.camera,
- this._mainTexture.wrapU = Texture.CLAMP_ADDRESSMODE,
- this._mainTexture.wrapV = Texture.CLAMP_ADDRESSMODE,
- this._mainTexture.anisotropicFilteringLevel = 1,
- this._mainTexture.updateSamplingMode(Texture.BILINEAR_SAMPLINGMODE),
- this._mainTexture.renderParticles = !1,
- this._mainTexture.renderList = null,
- this._mainTexture.ignoreCameraViewport = !0,
- this._mainTexture.customRenderFunction = function(o, s, c, d) {
- e.onBeforeRenderMainTextureObservable.notifyObservers(e);
- var _, b = e._scene.getEngine();
- if (d.length) {
- for (b.setColorWrite(!1),
- _ = 0; _ < d.length; _++)
- e._renderSubMesh(d.data[_]);
- b.setColorWrite(!0)
- }
- for (_ = 0; _ < o.length; _++)
- e._renderSubMesh(o.data[_]);
- for (_ = 0; _ < s.length; _++)
- e._renderSubMesh(s.data[_]);
- var k = b.getAlphaMode();
- for (_ = 0; _ < c.length; _++)
- e._renderSubMesh(c.data[_], !0);
- b.setAlphaMode(k)
- }
- ,
- this._mainTexture.onClearObservable.add(function(o) {
- o.clear(e.neutralColor, !0, !0, !0)
- }),
- this._scene.getBoundingBoxRenderer) {
- var i = this._scene.getBoundingBoxRenderer().enabled;
- this._mainTexture.onBeforeBindObservable.add(function() {
- e._scene.getBoundingBoxRenderer().enabled = !e.disableBoundingBoxesFromEffectLayer && i
- }),
- this._mainTexture.onAfterUnbindObservable.add(function() {
- e._scene.getBoundingBoxRenderer().enabled = i
- })
- }
- }
- ,
- a.prototype._addCustomEffectDefines = function(e) {}
- ,
- a.prototype._isReady = function(e, i, o) {
- var s, c = this._scene.getEngine(), d = e.getMesh(), _ = (s = d._internalAbstractMeshDataInfo._materialForRenderPass) === null || s === void 0 ? void 0 : s[c.currentRenderPassId];
- if (_)
- return _.isReadyForSubMesh(d, e, i);
- var b = e.getMaterial();
- if (!b)
- return !1;
- if (this._useMeshMaterial(e.getRenderingMesh()))
- return b.isReadyForSubMesh(e.getMesh(), e, i);
- var k = []
- , j = [VertexBuffer.PositionKind]
- , $ = !1
- , _e = !1;
- if (b) {
- var et = b.needAlphaTesting()
- , tt = b.getAlphaTestTexture()
- , rt = tt && tt.hasAlpha && (b.useAlphaFromDiffuseTexture || b._useAlphaFromAlbedoTexture);
- tt && (et || rt) && (k.push("#define DIFFUSE"),
- d.isVerticesDataPresent(VertexBuffer.UV2Kind) && tt.coordinatesIndex === 1 ? (k.push("#define DIFFUSEUV2"),
- _e = !0) : d.isVerticesDataPresent(VertexBuffer.UVKind) && (k.push("#define DIFFUSEUV1"),
- $ = !0),
- et && (k.push("#define ALPHATEST"),
- k.push("#define ALPHATESTVALUE 0.4")),
- tt.gammaSpace || k.push("#define DIFFUSE_ISLINEAR"));
- var it = b.opacityTexture;
- it && (k.push("#define OPACITY"),
- d.isVerticesDataPresent(VertexBuffer.UV2Kind) && it.coordinatesIndex === 1 ? (k.push("#define OPACITYUV2"),
- _e = !0) : d.isVerticesDataPresent(VertexBuffer.UVKind) && (k.push("#define OPACITYUV1"),
- $ = !0))
- }
- o && (k.push("#define EMISSIVE"),
- d.isVerticesDataPresent(VertexBuffer.UV2Kind) && o.coordinatesIndex === 1 ? (k.push("#define EMISSIVEUV2"),
- _e = !0) : d.isVerticesDataPresent(VertexBuffer.UVKind) && (k.push("#define EMISSIVEUV1"),
- $ = !0),
- o.gammaSpace || k.push("#define EMISSIVE_ISLINEAR")),
- d.isVerticesDataPresent(VertexBuffer.ColorKind) && d.hasVertexAlpha && (j.push(VertexBuffer.ColorKind),
- k.push("#define VERTEXALPHA")),
- $ && (j.push(VertexBuffer.UVKind),
- k.push("#define UV1")),
- _e && (j.push(VertexBuffer.UV2Kind),
- k.push("#define UV2"));
- var nt = new EffectFallbacks;
- if (d.useBones && d.computeBonesUsingShaders) {
- j.push(VertexBuffer.MatricesIndicesKind),
- j.push(VertexBuffer.MatricesWeightsKind),
- d.numBoneInfluencers > 4 && (j.push(VertexBuffer.MatricesIndicesExtraKind),
- j.push(VertexBuffer.MatricesWeightsExtraKind)),
- k.push("#define NUM_BONE_INFLUENCERS " + d.numBoneInfluencers);
- var ot = d.skeleton;
- ot && ot.isUsingTextureForMatrices ? k.push("#define BONETEXTURE") : k.push("#define BonesPerMesh " + (ot ? ot.bones.length + 1 : 0)),
- d.numBoneInfluencers > 0 && nt.addCPUSkinningFallback(0, d)
- } else
- k.push("#define NUM_BONE_INFLUENCERS 0");
- var at = d.morphTargetManager
- , st = 0;
- at && at.numInfluencers > 0 && (k.push("#define MORPHTARGETS"),
- st = at.numInfluencers,
- k.push("#define NUM_MORPH_INFLUENCERS " + st),
- at.isUsingTextureForTargets && k.push("#define MORPHTARGETS_TEXTURE"),
- MaterialHelper.PrepareAttributesForMorphTargetsInfluencers(j, d, st)),
- i && (k.push("#define INSTANCES"),
- MaterialHelper.PushAttributesForInstances(j),
- e.getRenderingMesh().hasThinInstances && k.push("#define THIN_INSTANCES")),
- this._addCustomEffectDefines(k);
- var ut = e._getDrawWrapper(void 0, !0)
- , ct = ut.defines
- , lt = k.join(`
- `);
- 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, {
- maxSimultaneousMorphTargets: st
- }), lt),
- ut.effect.isReady()
- }
- ,
- a.prototype.render = function() {
- for (var e = 0; e < this._postProcesses.length; e++)
- if (!this._postProcesses[e].isReady())
- return;
- for (var i = this._scene.getEngine(), o = this._numInternalDraws(), s = !0, c = 0; c < o; ++c) {
- var d = this._mergeDrawWrapper[c];
- d || (d = this._mergeDrawWrapper[c] = new DrawWrapper(this._engine),
- d.setEffect(this._createMergeEffect())),
- s = s && d.effect.isReady()
- }
- if (!!s) {
- this.onBeforeComposeObservable.notifyObservers(this);
- for (var _ = i.getAlphaMode(), b = 0; b < o; ++b) {
- var d = this._mergeDrawWrapper[b];
- i.enableEffect(d),
- i.setState(!1),
- i.bindBuffers(this._vertexBuffers, this._indexBuffer, d.effect),
- i.setAlphaMode(this._effectLayerOptions.alphaBlendingMode),
- this._internalRender(d.effect, b)
- }
- i.setAlphaMode(_),
- this.onAfterComposeObservable.notifyObservers(this);
- var k = this._mainTexture.getSize();
- this._setMainTextureSize(),
- (k.width !== this._mainTextureDesiredSize.width || k.height !== this._mainTextureDesiredSize.height) && this._mainTextureDesiredSize.width !== 0 && this._mainTextureDesiredSize.height !== 0 && (this.onSizeChangedObservable.notifyObservers(this),
- this._disposeTextureAndPostProcesses(),
- this._createMainTexture(),
- this._createTextureAndPostProcesses())
- }
- }
- ,
- a.prototype.hasMesh = function(e) {
- return this.renderingGroupId === -1 || e.renderingGroupId === this.renderingGroupId
- }
- ,
- a.prototype.shouldRender = function() {
- return this.isEnabled && this._shouldRender
- }
- ,
- a.prototype._shouldRenderMesh = function(e) {
- return !0
- }
- ,
- a.prototype._canRenderMesh = function(e, i) {
- return !i.needAlphaBlendingForMesh(e)
- }
- ,
- a.prototype._shouldRenderEmissiveTextureForMesh = function() {
- return !0
- }
- ,
- a.prototype._renderSubMesh = function(e, i) {
- var o, s;
- if (i === void 0 && (i = !1),
- !!this.shouldRender()) {
- var c = e.getMaterial()
- , d = e.getMesh()
- , _ = e.getReplacementMesh()
- , b = e.getRenderingMesh()
- , k = e.getEffectiveMesh()
- , j = this._scene
- , $ = j.getEngine();
- if (k._internalAbstractMeshDataInfo._isActiveIntermediate = !1,
- !!c && !!this._canRenderMesh(b, c)) {
- var _e = (o = b.overrideMaterialSideOrientation) !== null && o !== void 0 ? o : c.sideOrientation
- , et = b._getWorldMatrixDeterminant();
- et < 0 && (_e = _e === Material.ClockWiseSideOrientation ? Material.CounterClockWiseSideOrientation : Material.ClockWiseSideOrientation);
- var tt = _e === Material.ClockWiseSideOrientation;
- $.setState(c.backFaceCulling, c.zOffset, void 0, tt, c.cullBackFaces, void 0, c.zOffsetUnits);
- var rt = b._getInstancesRenderList(e._id, !!_);
- if (!rt.mustReturn && !!this._shouldRenderMesh(b)) {
- var it = rt.hardwareInstancedRendering[e._id] || b.hasThinInstances;
- if (this._setEmissiveTextureAndColor(b, e, c),
- this.onBeforeRenderMeshToEffect.notifyObservers(d),
- this._useMeshMaterial(b))
- b.render(e, it, _ || void 0);
- else if (this._isReady(e, it, this._emissiveTextureAndColor.texture)) {
- var nt = (s = k._internalAbstractMeshDataInfo._materialForRenderPass) === null || s === void 0 ? void 0 : s[$.currentRenderPassId]
- , ot = e._getDrawWrapper();
- if (!ot && nt && (ot = nt._getDrawWrapper()),
- !ot)
- return;
- var at = ot.effect;
- if ($.enableEffect(ot),
- !it) {
- var st = j.forcePointsCloud ? Material.PointFillMode : j.forceWireframe ? Material.WireFrameFillMode : c.fillMode;
- b._bind(e, at, st)
- }
- if (nt ? nt.bindForSubMesh(k.getWorldMatrix(), k, e) : (at.setMatrix("viewProjection", j.getTransformMatrix()),
- at.setMatrix("world", k.getWorldMatrix()),
- at.setFloat4("glowColor", this._emissiveTextureAndColor.color.r, this._emissiveTextureAndColor.color.g, this._emissiveTextureAndColor.color.b, this._emissiveTextureAndColor.color.a)),
- !nt) {
- var ut = c.needAlphaTesting()
- , ct = c.getAlphaTestTexture()
- , lt = ct && ct.hasAlpha && (c.useAlphaFromDiffuseTexture || c._useAlphaFromAlbedoTexture);
- if (ct && (ut || lt)) {
- at.setTexture("diffuseSampler", ct);
- var ft = ct.getTextureMatrix();
- ft && at.setMatrix("diffuseMatrix", ft)
- }
- var ht = c.opacityTexture;
- if (ht) {
- at.setTexture("opacitySampler", ht),
- at.setFloat("opacityIntensity", ht.level);
- var ft = ht.getTextureMatrix();
- ft && at.setMatrix("opacityMatrix", ft)
- }
- if (this._emissiveTextureAndColor.texture && (at.setTexture("emissiveSampler", this._emissiveTextureAndColor.texture),
- at.setMatrix("emissiveMatrix", this._emissiveTextureAndColor.texture.getTextureMatrix())),
- b.useBones && b.computeBonesUsingShaders && b.skeleton) {
- var pt = b.skeleton;
- if (pt.isUsingTextureForMatrices) {
- var dt = pt.getTransformMatrixTexture(b);
- if (!dt)
- return;
- at.setTexture("boneSampler", dt),
- at.setFloat("boneTextureWidth", 4 * (pt.bones.length + 1))
- } else
- at.setMatrices("mBones", pt.getTransformMatrices(b))
- }
- MaterialHelper.BindMorphTargetParameters(b, at),
- b.morphTargetManager && b.morphTargetManager.isUsingTextureForTargets && b.morphTargetManager._bind(at),
- i && $.setAlphaMode(c.alphaMode)
- }
- b._processRendering(k, e, at, c.fillMode, rt, it, function(_t, mt) {
- return at.setMatrix("world", mt)
- })
- } else
- this._mainTexture.resetRefreshCounter();
- this.onAfterRenderMeshToEffect.notifyObservers(d)
- }
- }
- }
- }
- ,
- a.prototype._useMeshMaterial = function(e) {
- return !1
- }
- ,
- a.prototype._rebuild = function() {
- var e = this._vertexBuffers[VertexBuffer.PositionKind];
- e && e._rebuild(),
- this._generateIndexBuffer()
- }
- ,
- a.prototype._disposeTextureAndPostProcesses = function() {
- this._mainTexture.dispose();
- for (var e = 0; e < this._postProcesses.length; e++)
- this._postProcesses[e] && this._postProcesses[e].dispose();
- this._postProcesses = [];
- for (var e = 0; e < this._textures.length; e++)
- this._textures[e] && this._textures[e].dispose();
- this._textures = []
- }
- ,
- a.prototype.dispose = function() {
- var e = this._vertexBuffers[VertexBuffer.PositionKind];
- e && (e.dispose(),
- this._vertexBuffers[VertexBuffer.PositionKind] = null),
- this._indexBuffer && (this._scene.getEngine()._releaseBuffer(this._indexBuffer),
- this._indexBuffer = null);
- for (var i = 0, o = this._mergeDrawWrapper; i < o.length; i++) {
- var s = o[i];
- s.dispose()
- }
- this._mergeDrawWrapper = [],
- this._disposeTextureAndPostProcesses();
- var c = this._scene.effectLayers.indexOf(this, 0);
- c > -1 && this._scene.effectLayers.splice(c, 1),
- this.onDisposeObservable.notifyObservers(this),
- this.onDisposeObservable.clear(),
- this.onBeforeRenderMainTextureObservable.clear(),
- this.onBeforeComposeObservable.clear(),
- this.onBeforeRenderMeshToEffect.clear(),
- this.onAfterRenderMeshToEffect.clear(),
- this.onAfterComposeObservable.clear(),
- this.onSizeChangedObservable.clear()
- }
- ,
- a.prototype.getClassName = function() {
- return "EffectLayer"
- }
- ,
- a.Parse = function(e, i, o) {
- var s = Tools.Instantiate(e.customType);
- return s.Parse(e, i, o)
- }
- ,
- a._SceneComponentInitialization = function(e) {
- throw _WarnImport("EffectLayerSceneComponent")
- }
- ,
- __decorate([serialize()], a.prototype, "name", void 0),
- __decorate([serializeAsColor4()], a.prototype, "neutralColor", void 0),
- __decorate([serialize()], a.prototype, "isEnabled", void 0),
- __decorate([serializeAsCameraReference()], a.prototype, "camera", null),
- __decorate([serialize()], a.prototype, "renderingGroupId", null),
- __decorate([serialize()], a.prototype, "disableBoundingBoxesFromEffectLayer", void 0),
- a
- }()
- , name$B = "glowMapMergePixelShader"
- , shader$B = `
- varying vec2 vUV;
- uniform sampler2D textureSampler;
- #ifdef EMISSIVE
- uniform sampler2D textureSampler2;
- #endif
- uniform float offset;
- void main(void) {
- vec4 baseColor=texture2D(textureSampler,vUV);
- #ifdef EMISSIVE
- baseColor+=texture2D(textureSampler2,vUV);
- baseColor*=offset;
- #else
- baseColor.a=abs(offset-baseColor.a);
- #ifdef STROKE
- float alpha=smoothstep(.0,.1,baseColor.a);
- baseColor.a=alpha;
- baseColor.rgb=baseColor.rgb*alpha;
- #endif
- #endif
- #if LDR
- baseColor=clamp(baseColor,0.,1.0);
- #endif
- gl_FragColor=baseColor;
- }`;
- ShaderStore.ShadersStore[name$B] = shader$B;
- var name$A = "glowMapMergeVertexShader"
- , shader$A = `
- attribute vec2 position;
- varying vec2 vUV;
- const vec2 madd=vec2(0.5,0.5);
- void main(void) {
- vUV=position*madd+madd;
- gl_Position=vec4(position,0.0,1.0);
- }`;
- ShaderStore.ShadersStore[name$A] = shader$A;
- AbstractScene.AddParser(SceneComponentConstants.NAME_EFFECTLAYER, function(a, e, i, o) {
- if (a.effectLayers) {
- i.effectLayers || (i.effectLayers = new Array);
- for (var s = 0; s < a.effectLayers.length; s++) {
- var c = EffectLayer.Parse(a.effectLayers[s], e, o);
- i.effectLayers.push(c)
- }
- }
- });
- AbstractScene.prototype.removeEffectLayer = function(a) {
- var e = this.effectLayers.indexOf(a);
- return e !== -1 && this.effectLayers.splice(e, 1),
- e
- }
- ;
- AbstractScene.prototype.addEffectLayer = function(a) {
- this.effectLayers.push(a)
- }
- ;
- var EffectLayerSceneComponent = function() {
- function a(e) {
- this.name = SceneComponentConstants.NAME_EFFECTLAYER,
- this._renderEffects = !1,
- this._needStencil = !1,
- this._previousStencilState = !1,
- this.scene = e,
- this._engine = e.getEngine(),
- e.effectLayers = new Array
- }
- return a.prototype.register = function() {
- this.scene._isReadyForMeshStage.registerStep(SceneComponentConstants.STEP_ISREADYFORMESH_EFFECTLAYER, this, this._isReadyForMesh),
- this.scene._cameraDrawRenderTargetStage.registerStep(SceneComponentConstants.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER, this, this._renderMainTexture),
- this.scene._beforeCameraDrawStage.registerStep(SceneComponentConstants.STEP_BEFORECAMERADRAW_EFFECTLAYER, this, this._setStencil),
- this.scene._afterRenderingGroupDrawStage.registerStep(SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW, this, this._drawRenderingGroup),
- this.scene._afterCameraDrawStage.registerStep(SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER, this, this._setStencilBack),
- this.scene._afterCameraDrawStage.registerStep(SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW, this, this._drawCamera)
- }
- ,
- a.prototype.rebuild = function() {
- for (var e = this.scene.effectLayers, i = 0, o = e; i < o.length; i++) {
- var s = o[i];
- s._rebuild()
- }
- }
- ,
- a.prototype.serialize = function(e) {
- e.effectLayers = [];
- for (var i = this.scene.effectLayers, o = 0, s = i; o < s.length; o++) {
- var c = s[o];
- c.serialize && e.effectLayers.push(c.serialize())
- }
- }
- ,
- a.prototype.addFromContainer = function(e) {
- var i = this;
- !e.effectLayers || e.effectLayers.forEach(function(o) {
- i.scene.addEffectLayer(o)
- })
- }
- ,
- a.prototype.removeFromContainer = function(e, i) {
- var o = this;
- !e.effectLayers || e.effectLayers.forEach(function(s) {
- o.scene.removeEffectLayer(s),
- i && s.dispose()
- })
- }
- ,
- a.prototype.dispose = function() {
- for (var e = this.scene.effectLayers; e.length; )
- e[0].dispose()
- }
- ,
- a.prototype._isReadyForMesh = function(e, i) {
- for (var o = this._engine.currentRenderPassId, s = this.scene.effectLayers, c = 0, d = s; c < d.length; c++) {
- var _ = d[c];
- if (!!_.hasMesh(e)) {
- var b = _._mainTexture;
- this._engine.currentRenderPassId = b.renderPassId;
- for (var k = 0, j = e.subMeshes; k < j.length; k++) {
- var $ = j[k];
- if (!_.isReady($, i))
- return this._engine.currentRenderPassId = o,
- !1
- }
- }
- }
- return this._engine.currentRenderPassId = o,
- !0
- }
- ,
- a.prototype._renderMainTexture = function(e) {
- this._renderEffects = !1,
- this._needStencil = !1;
- var i = !1
- , o = this.scene.effectLayers;
- if (o && o.length > 0) {
- this._previousStencilState = this._engine.getStencilBuffer();
- for (var s = 0, c = o; s < c.length; s++) {
- var d = c[s];
- 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)) {
- this._renderEffects = !0,
- this._needStencil = this._needStencil || d.needStencil();
- var _ = d._mainTexture;
- _._shouldRender() && (this.scene.incrementRenderId(),
- _.render(!1, !1),
- i = !0)
- }
- }
- this.scene.incrementRenderId()
- }
- return i
- }
- ,
- a.prototype._setStencil = function() {
- this._needStencil && this._engine.setStencilBuffer(!0)
- }
- ,
- a.prototype._setStencilBack = function() {
- this._needStencil && this._engine.setStencilBuffer(this._previousStencilState)
- }
- ,
- a.prototype._draw = function(e) {
- if (this._renderEffects) {
- this._engine.setDepthBuffer(!1);
- for (var i = this.scene.effectLayers, o = 0; o < i.length; o++) {
- var s = i[o];
- s.renderingGroupId === e && s.shouldRender() && s.render()
- }
- this._engine.setDepthBuffer(!0)
- }
- }
- ,
- a.prototype._drawCamera = function() {
- this._renderEffects && this._draw(-1)
- }
- ,
- a.prototype._drawRenderingGroup = function(e) {
- !this.scene._isInIntermediateRendering() && this._renderEffects && this._draw(e)
- }
- ,
- a
- }();
- EffectLayer._SceneComponentInitialization = function(a) {
- var e = a._getComponent(SceneComponentConstants.NAME_EFFECTLAYER);
- e || (e = new EffectLayerSceneComponent(a),
- a._addComponent(e))
- }
- ;
- AbstractScene.prototype.getGlowLayerByName = function(a) {
- for (var e = 0; e < this.effectLayers.length; e++)
- if (this.effectLayers[e].name === a && this.effectLayers[e].getEffectName() === GlowLayer.EffectName)
- return this.effectLayers[e];
- return null
- }
- ;
- var GlowLayer = function(a) {
- __extends(e, a);
- function e(i, o, s) {
- var c = a.call(this, i, o) || this;
- return c._intensity = 1,
- c._includedOnlyMeshes = [],
- c._excludedMeshes = [],
- c._meshesUsingTheirOwnMaterials = [],
- c.neutralColor = new Color4(0,0,0,1),
- c._options = __assign({
- mainTextureRatio: e.DefaultTextureRatio,
- blurKernelSize: 32,
- mainTextureFixedSize: void 0,
- camera: null,
- mainTextureSamples: 1,
- renderingGroupId: -1,
- ldrMerge: !1,
- alphaBlendingMode: 1
- }, s),
- c._init({
- alphaBlendingMode: c._options.alphaBlendingMode,
- camera: c._options.camera,
- mainTextureFixedSize: c._options.mainTextureFixedSize,
- mainTextureRatio: c._options.mainTextureRatio,
- renderingGroupId: c._options.renderingGroupId
- }),
- c
- }
- return Object.defineProperty(e.prototype, "blurKernelSize", {
- get: function() {
- return this._horizontalBlurPostprocess1.kernel
- },
- set: function(i) {
- this._horizontalBlurPostprocess1.kernel = i,
- this._verticalBlurPostprocess1.kernel = i,
- this._horizontalBlurPostprocess2.kernel = i,
- this._verticalBlurPostprocess2.kernel = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "intensity", {
- get: function() {
- return this._intensity
- },
- set: function(i) {
- this._intensity = i
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getEffectName = function() {
- return e.EffectName
- }
- ,
- e.prototype._createMergeEffect = function() {
- var i = `#define EMISSIVE
- `;
- return this._options.ldrMerge && (i += `#define LDR
- `),
- this._engine.createEffect("glowMapMerge", [VertexBuffer.PositionKind], ["offset"], ["textureSampler", "textureSampler2"], i)
- }
- ,
- e.prototype._createTextureAndPostProcesses = function() {
- var i = this
- , o = this._mainTextureDesiredSize.width
- , s = this._mainTextureDesiredSize.height;
- o = this._engine.needPOTTextures ? Engine.GetExponentOfTwo(o, this._maxSize) : o,
- s = this._engine.needPOTTextures ? Engine.GetExponentOfTwo(s, this._maxSize) : s;
- var c = 0;
- this._engine.getCaps().textureHalfFloatRender ? c = 2 : c = 0,
- this._blurTexture1 = new RenderTargetTexture("GlowLayerBlurRTT",{
- width: o,
- height: s
- },this._scene,!1,!0,c),
- this._blurTexture1.wrapU = Texture.CLAMP_ADDRESSMODE,
- this._blurTexture1.wrapV = Texture.CLAMP_ADDRESSMODE,
- this._blurTexture1.updateSamplingMode(Texture.BILINEAR_SAMPLINGMODE),
- this._blurTexture1.renderParticles = !1,
- this._blurTexture1.ignoreCameraViewport = !0;
- var d = Math.floor(o / 2)
- , _ = Math.floor(s / 2);
- this._blurTexture2 = new RenderTargetTexture("GlowLayerBlurRTT2",{
- width: d,
- height: _
- },this._scene,!1,!0,c),
- this._blurTexture2.wrapU = Texture.CLAMP_ADDRESSMODE,
- this._blurTexture2.wrapV = Texture.CLAMP_ADDRESSMODE,
- this._blurTexture2.updateSamplingMode(Texture.BILINEAR_SAMPLINGMODE),
- this._blurTexture2.renderParticles = !1,
- this._blurTexture2.ignoreCameraViewport = !0,
- this._textures = [this._blurTexture1, this._blurTexture2],
- this._horizontalBlurPostprocess1 = new BlurPostProcess("GlowLayerHBP1",new Vector2(1,0),this._options.blurKernelSize / 2,{
- width: o,
- height: s
- },null,Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,c),
- this._horizontalBlurPostprocess1.width = o,
- this._horizontalBlurPostprocess1.height = s,
- this._horizontalBlurPostprocess1.externalTextureSamplerBinding = !0,
- this._horizontalBlurPostprocess1.onApplyObservable.add(function(b) {
- b.setTexture("textureSampler", i._mainTexture)
- }),
- this._verticalBlurPostprocess1 = new BlurPostProcess("GlowLayerVBP1",new Vector2(0,1),this._options.blurKernelSize / 2,{
- width: o,
- height: s
- },null,Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,c),
- this._horizontalBlurPostprocess2 = new BlurPostProcess("GlowLayerHBP2",new Vector2(1,0),this._options.blurKernelSize / 2,{
- width: d,
- height: _
- },null,Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,c),
- this._horizontalBlurPostprocess2.width = d,
- this._horizontalBlurPostprocess2.height = _,
- this._horizontalBlurPostprocess2.externalTextureSamplerBinding = !0,
- this._horizontalBlurPostprocess2.onApplyObservable.add(function(b) {
- b.setTexture("textureSampler", i._blurTexture1)
- }),
- this._verticalBlurPostprocess2 = new BlurPostProcess("GlowLayerVBP2",new Vector2(0,1),this._options.blurKernelSize / 2,{
- width: d,
- height: _
- },null,Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,c),
- this._postProcesses = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1, this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2],
- this._postProcesses1 = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1],
- this._postProcesses2 = [this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2],
- this._mainTexture.samples = this._options.mainTextureSamples,
- this._mainTexture.onAfterUnbindObservable.add(function() {
- var b = i._blurTexture1.renderTarget;
- if (b) {
- i._scene.postProcessManager.directRender(i._postProcesses1, b, !0);
- var k = i._blurTexture2.renderTarget;
- k && i._scene.postProcessManager.directRender(i._postProcesses2, k, !0),
- i._engine.unBindFramebuffer(k != null ? k : b, !0)
- }
- }),
- this._postProcesses.map(function(b) {
- b.autoClear = !1
- })
- }
- ,
- e.prototype.isReady = function(i, o) {
- var s = i.getMaterial()
- , c = i.getRenderingMesh();
- if (!s || !c)
- return !1;
- var d = s.emissiveTexture;
- return a.prototype._isReady.call(this, i, o, d)
- }
- ,
- e.prototype.needStencil = function() {
- return !1
- }
- ,
- e.prototype._canRenderMesh = function(i, o) {
- return !0
- }
- ,
- e.prototype._internalRender = function(i) {
- i.setTexture("textureSampler", this._blurTexture1),
- i.setTexture("textureSampler2", this._blurTexture2),
- i.setFloat("offset", this._intensity);
- var o = this._engine
- , s = o.getStencilBuffer();
- o.setStencilBuffer(!1),
- o.drawElementsType(Material.TriangleFillMode, 0, 6),
- o.setStencilBuffer(s)
- }
- ,
- e.prototype._setEmissiveTextureAndColor = function(i, o, s) {
- var c, d = 1;
- if (this.customEmissiveTextureSelector ? this._emissiveTextureAndColor.texture = this.customEmissiveTextureSelector(i, o, s) : s ? (this._emissiveTextureAndColor.texture = s.emissiveTexture,
- this._emissiveTextureAndColor.texture && (d = this._emissiveTextureAndColor.texture.level)) : this._emissiveTextureAndColor.texture = null,
- this.customEmissiveColorSelector)
- this.customEmissiveColorSelector(i, o, s, this._emissiveTextureAndColor.color);
- else if (s.emissiveColor) {
- var _ = (c = s.emissiveIntensity) !== null && c !== void 0 ? c : 1;
- d *= _,
- this._emissiveTextureAndColor.color.set(s.emissiveColor.r * d, s.emissiveColor.g * d, s.emissiveColor.b * d, s.alpha)
- } else
- this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a)
- }
- ,
- e.prototype._shouldRenderMesh = function(i) {
- return this.hasMesh(i)
- }
- ,
- e.prototype._addCustomEffectDefines = function(i) {
- i.push("#define GLOW")
- }
- ,
- e.prototype.addExcludedMesh = function(i) {
- this._excludedMeshes.indexOf(i.uniqueId) === -1 && this._excludedMeshes.push(i.uniqueId)
- }
- ,
- e.prototype.removeExcludedMesh = function(i) {
- var o = this._excludedMeshes.indexOf(i.uniqueId);
- o !== -1 && this._excludedMeshes.splice(o, 1)
- }
- ,
- e.prototype.addIncludedOnlyMesh = function(i) {
- this._includedOnlyMeshes.indexOf(i.uniqueId) === -1 && this._includedOnlyMeshes.push(i.uniqueId)
- }
- ,
- e.prototype.removeIncludedOnlyMesh = function(i) {
- var o = this._includedOnlyMeshes.indexOf(i.uniqueId);
- o !== -1 && this._includedOnlyMeshes.splice(o, 1)
- }
- ,
- e.prototype.hasMesh = function(i) {
- 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
- }
- ,
- e.prototype._useMeshMaterial = function(i) {
- return this._meshesUsingTheirOwnMaterials.length == 0 ? !1 : this._meshesUsingTheirOwnMaterials.indexOf(i.uniqueId) > -1
- }
- ,
- e.prototype.referenceMeshToUseItsOwnMaterial = function(i) {
- var o = this;
- this._meshesUsingTheirOwnMaterials.push(i.uniqueId),
- i.onDisposeObservable.add(function() {
- o._disposeMesh(i)
- })
- }
- ,
- e.prototype.unReferenceMeshFromUsingItsOwnMaterial = function(i) {
- for (var o = this._meshesUsingTheirOwnMaterials.indexOf(i.uniqueId); o >= 0; )
- this._meshesUsingTheirOwnMaterials.splice(o, 1),
- o = this._meshesUsingTheirOwnMaterials.indexOf(i.uniqueId)
- }
- ,
- e.prototype._disposeMesh = function(i) {
- this.removeIncludedOnlyMesh(i),
- this.removeExcludedMesh(i)
- }
- ,
- e.prototype.getClassName = function() {
- return "GlowLayer"
- }
- ,
- e.prototype.serialize = function() {
- var i = SerializationHelper.Serialize(this);
- i.customType = "BABYLON.GlowLayer";
- var o;
- if (i.includedMeshes = [],
- this._includedOnlyMeshes.length)
- for (o = 0; o < this._includedOnlyMeshes.length; o++) {
- var s = this._scene.getMeshByUniqueId(this._includedOnlyMeshes[o]);
- s && i.includedMeshes.push(s.id)
- }
- if (i.excludedMeshes = [],
- this._excludedMeshes.length)
- for (o = 0; o < this._excludedMeshes.length; o++) {
- var s = this._scene.getMeshByUniqueId(this._excludedMeshes[o]);
- s && i.excludedMeshes.push(s.id)
- }
- return i
- }
- ,
- e.Parse = function(i, o, s) {
- var c = SerializationHelper.Parse(function() {
- return new e(i.name,o,i.options)
- }, i, o, s), d;
- for (d = 0; d < i.excludedMeshes.length; d++) {
- var _ = o.getMeshById(i.excludedMeshes[d]);
- _ && c.addExcludedMesh(_)
- }
- for (d = 0; d < i.includedMeshes.length; d++) {
- var _ = o.getMeshById(i.includedMeshes[d]);
- _ && c.addIncludedOnlyMesh(_)
- }
- return c
- }
- ,
- e.EffectName = "GlowLayer",
- e.DefaultBlurKernelSize = 32,
- e.DefaultTextureRatio = .5,
- __decorate([serialize()], e.prototype, "blurKernelSize", null),
- __decorate([serialize()], e.prototype, "intensity", null),
- __decorate([serialize("options")], e.prototype, "_options", void 0),
- e
- }(EffectLayer);
- RegisterClass("BABYLON.GlowLayer", GlowLayer);
- var name$z = "glowBlurPostProcessPixelShader"
- , shader$z = `
- varying vec2 vUV;
- uniform sampler2D textureSampler;
- uniform vec2 screenSize;
- uniform vec2 direction;
- uniform float blurWidth;
- float getLuminance(vec3 color)
- {
- return dot(color,vec3(0.2126,0.7152,0.0722));
- }
- void main(void)
- {
- float weights[7];
- weights[0]=0.05;
- weights[1]=0.1;
- weights[2]=0.2;
- weights[3]=0.3;
- weights[4]=0.2;
- weights[5]=0.1;
- weights[6]=0.05;
- vec2 texelSize=vec2(1.0/screenSize.x,1.0/screenSize.y);
- vec2 texelStep=texelSize*direction*blurWidth;
- vec2 start=vUV-3.0*texelStep;
- vec4 baseColor=vec4(0.,0.,0.,0.);
- vec2 texelOffset=vec2(0.,0.);
- for (int i=0; i<7; i++)
- {
- vec4 texel=texture2D(textureSampler,start+texelOffset);
- baseColor.a+=texel.a*weights[i];
- float luminance=getLuminance(baseColor.rgb);
- float luminanceTexel=getLuminance(texel.rgb);
- float choice=step(luminanceTexel,luminance);
- baseColor.rgb=choice*baseColor.rgb+(1.0-choice)*texel.rgb;
- texelOffset+=texelStep;
- }
- gl_FragColor=baseColor;
- }`;
- ShaderStore.ShadersStore[name$z] = shader$z;
- AbstractScene.prototype.getHighlightLayerByName = function(a) {
- for (var e = 0; e < this.effectLayers.length; e++)
- if (this.effectLayers[e].name === a && this.effectLayers[e].getEffectName() === HighlightLayer.EffectName)
- return this.effectLayers[e];
- return null
- }
- ;
- var GlowBlurPostProcess = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _, b, k) {
- _ === void 0 && (_ = Texture.BILINEAR_SAMPLINGMODE);
- var j = a.call(this, i, "glowBlurPostProcess", ["screenSize", "direction", "blurWidth"], null, c, d, _, b, k) || this;
- return j.direction = o,
- j.kernel = s,
- j.onApplyObservable.add(function($) {
- $.setFloat2("screenSize", j.width, j.height),
- $.setVector2("direction", j.direction),
- $.setFloat("blurWidth", j.kernel)
- }),
- j
- }
- return e
- }(PostProcess)
- , HighlightLayer = function(a) {
- __extends(e, a);
- function e(i, o, s) {
- var c = a.call(this, i, o) || this;
- return c.name = i,
- c.innerGlow = !0,
- c.outerGlow = !0,
- c.onBeforeBlurObservable = new Observable,
- c.onAfterBlurObservable = new Observable,
- c._instanceGlowingMeshStencilReference = e.GlowingMeshStencilReference++,
- c._meshes = {},
- c._excludedMeshes = {},
- c.neutralColor = e.NeutralColor,
- 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 }"),
- c._options = __assign({
- mainTextureRatio: .5,
- blurTextureSizeRatio: .5,
- blurHorizontalSize: 1,
- blurVerticalSize: 1,
- alphaBlendingMode: 2,
- camera: null,
- renderingGroupId: -1
- }, s),
- c._init({
- alphaBlendingMode: c._options.alphaBlendingMode,
- camera: c._options.camera,
- mainTextureFixedSize: c._options.mainTextureFixedSize,
- mainTextureRatio: c._options.mainTextureRatio,
- renderingGroupId: c._options.renderingGroupId
- }),
- c._shouldRender = !1,
- c
- }
- return Object.defineProperty(e.prototype, "blurHorizontalSize", {
- get: function() {
- return this._horizontalBlurPostprocess.kernel
- },
- set: function(i) {
- this._horizontalBlurPostprocess.kernel = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "blurVerticalSize", {
- get: function() {
- return this._verticalBlurPostprocess.kernel
- },
- set: function(i) {
- this._verticalBlurPostprocess.kernel = i
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getEffectName = function() {
- return e.EffectName
- }
- ,
- e.prototype._numInternalDraws = function() {
- return 2
- }
- ,
- e.prototype._createMergeEffect = function() {
- return this._engine.createEffect("glowMapMerge", [VertexBuffer.PositionKind], ["offset"], ["textureSampler"], this._options.isStroke ? `#define STROKE
- ` : void 0)
- }
- ,
- e.prototype._createTextureAndPostProcesses = function() {
- var i = this
- , o = this._mainTextureDesiredSize.width * this._options.blurTextureSizeRatio
- , s = this._mainTextureDesiredSize.height * this._options.blurTextureSizeRatio;
- o = this._engine.needPOTTextures ? Engine.GetExponentOfTwo(o, this._maxSize) : o,
- s = this._engine.needPOTTextures ? Engine.GetExponentOfTwo(s, this._maxSize) : s;
- var c = 0;
- this._engine.getCaps().textureHalfFloatRender ? c = 2 : c = 0,
- this._blurTexture = new RenderTargetTexture("HighlightLayerBlurRTT",{
- width: o,
- height: s
- },this._scene,!1,!0,c),
- this._blurTexture.wrapU = Texture.CLAMP_ADDRESSMODE,
- this._blurTexture.wrapV = Texture.CLAMP_ADDRESSMODE,
- this._blurTexture.anisotropicFilteringLevel = 16,
- this._blurTexture.updateSamplingMode(Texture.TRILINEAR_SAMPLINGMODE),
- this._blurTexture.renderParticles = !1,
- this._blurTexture.ignoreCameraViewport = !0,
- this._textures = [this._blurTexture],
- this._options.alphaBlendingMode === 2 ? (this._downSamplePostprocess = new PassPostProcess("HighlightLayerPPP",this._options.blurTextureSizeRatio,null,Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine()),
- this._downSamplePostprocess.externalTextureSamplerBinding = !0,
- this._downSamplePostprocess.onApplyObservable.add(function(d) {
- d.setTexture("textureSampler", i._mainTexture)
- }),
- this._horizontalBlurPostprocess = new GlowBlurPostProcess("HighlightLayerHBP",new Vector2(1,0),this._options.blurHorizontalSize,1,null,Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine()),
- this._horizontalBlurPostprocess.onApplyObservable.add(function(d) {
- d.setFloat2("screenSize", o, s)
- }),
- this._verticalBlurPostprocess = new GlowBlurPostProcess("HighlightLayerVBP",new Vector2(0,1),this._options.blurVerticalSize,1,null,Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine()),
- this._verticalBlurPostprocess.onApplyObservable.add(function(d) {
- d.setFloat2("screenSize", o, s)
- }),
- this._postProcesses = [this._downSamplePostprocess, this._horizontalBlurPostprocess, this._verticalBlurPostprocess]) : (this._horizontalBlurPostprocess = new BlurPostProcess("HighlightLayerHBP",new Vector2(1,0),this._options.blurHorizontalSize / 2,{
- width: o,
- height: s
- },null,Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,c),
- this._horizontalBlurPostprocess.width = o,
- this._horizontalBlurPostprocess.height = s,
- this._horizontalBlurPostprocess.externalTextureSamplerBinding = !0,
- this._horizontalBlurPostprocess.onApplyObservable.add(function(d) {
- d.setTexture("textureSampler", i._mainTexture)
- }),
- this._verticalBlurPostprocess = new BlurPostProcess("HighlightLayerVBP",new Vector2(0,1),this._options.blurVerticalSize / 2,{
- width: o,
- height: s
- },null,Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,c),
- this._postProcesses = [this._horizontalBlurPostprocess, this._verticalBlurPostprocess]),
- this._mainTexture.onAfterUnbindObservable.add(function() {
- i.onBeforeBlurObservable.notifyObservers(i);
- var d = i._blurTexture.renderTarget;
- d && (i._scene.postProcessManager.directRender(i._postProcesses, d, !0),
- i._engine.unBindFramebuffer(d, !0)),
- i.onAfterBlurObservable.notifyObservers(i)
- }),
- this._postProcesses.map(function(d) {
- d.autoClear = !1
- })
- }
- ,
- e.prototype.needStencil = function() {
- return !0
- }
- ,
- e.prototype.isReady = function(i, o) {
- var s = i.getMaterial()
- , c = i.getRenderingMesh();
- if (!s || !c || !this._meshes)
- return !1;
- var d = null
- , _ = this._meshes[c.uniqueId];
- return _ && _.glowEmissiveOnly && s && (d = s.emissiveTexture),
- a.prototype._isReady.call(this, i, o, d)
- }
- ,
- e.prototype._internalRender = function(i, o) {
- i.setTexture("textureSampler", this._blurTexture);
- var s = this._engine;
- s.cacheStencilState(),
- s.setStencilOperationPass(7681),
- s.setStencilOperationFail(7680),
- s.setStencilOperationDepthFail(7680),
- s.setStencilMask(0),
- s.setStencilBuffer(!0),
- s.setStencilFunctionReference(this._instanceGlowingMeshStencilReference),
- this.outerGlow && o === 0 && (i.setFloat("offset", 0),
- s.setStencilFunction(517),
- s.drawElementsType(Material.TriangleFillMode, 0, 6)),
- this.innerGlow && o === 1 && (i.setFloat("offset", 1),
- s.setStencilFunction(514),
- s.drawElementsType(Material.TriangleFillMode, 0, 6)),
- s.restoreStencilState()
- }
- ,
- e.prototype.shouldRender = function() {
- return a.prototype.shouldRender.call(this) ? !!this._meshes : !1
- }
- ,
- e.prototype._shouldRenderMesh = function(i) {
- return !(this._excludedMeshes && this._excludedMeshes[i.uniqueId] || !a.prototype.hasMesh.call(this, i))
- }
- ,
- e.prototype._canRenderMesh = function(i, o) {
- return !0
- }
- ,
- e.prototype._addCustomEffectDefines = function(i) {
- i.push("#define HIGHLIGHT")
- }
- ,
- e.prototype._setEmissiveTextureAndColor = function(i, o, s) {
- var c = this._meshes[i.uniqueId];
- 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),
- c && c.glowEmissiveOnly && s ? (this._emissiveTextureAndColor.texture = s.emissiveTexture,
- this._emissiveTextureAndColor.color.set(1, 1, 1, 1)) : this._emissiveTextureAndColor.texture = null
- }
- ,
- e.prototype.addExcludedMesh = function(i) {
- if (!!this._excludedMeshes) {
- var o = this._excludedMeshes[i.uniqueId];
- o || (this._excludedMeshes[i.uniqueId] = {
- mesh: i,
- beforeBind: i.onBeforeBindObservable.add(function(s) {
- s.getEngine().setStencilBuffer(!1)
- }),
- afterRender: i.onAfterRenderObservable.add(function(s) {
- s.getEngine().setStencilBuffer(!0)
- })
- })
- }
- }
- ,
- e.prototype.removeExcludedMesh = function(i) {
- if (!!this._excludedMeshes) {
- var o = this._excludedMeshes[i.uniqueId];
- o && (o.beforeBind && i.onBeforeBindObservable.remove(o.beforeBind),
- o.afterRender && i.onAfterRenderObservable.remove(o.afterRender)),
- this._excludedMeshes[i.uniqueId] = null
- }
- }
- ,
- e.prototype.hasMesh = function(i) {
- return !this._meshes || !a.prototype.hasMesh.call(this, i) ? !1 : this._meshes[i.uniqueId] !== void 0 && this._meshes[i.uniqueId] !== null
- }
- ,
- e.prototype.addMesh = function(i, o, s) {
- var c = this;
- if (s === void 0 && (s = !1),
- !!this._meshes) {
- var d = this._meshes[i.uniqueId];
- d ? d.color = o : (this._meshes[i.uniqueId] = {
- mesh: i,
- color: o,
- observerHighlight: i.onBeforeBindObservable.add(function(_) {
- c.isEnabled && (c._excludedMeshes && c._excludedMeshes[_.uniqueId] ? c._defaultStencilReference(_) : _.getScene().getEngine().setStencilFunctionReference(c._instanceGlowingMeshStencilReference))
- }),
- observerDefault: i.onAfterRenderObservable.add(function(_) {
- c.isEnabled && c._defaultStencilReference(_)
- }),
- glowEmissiveOnly: s
- },
- i.onDisposeObservable.add(function() {
- c._disposeMesh(i)
- })),
- this._shouldRender = !0
- }
- }
- ,
- e.prototype.removeMesh = function(i) {
- if (!!this._meshes) {
- var o = this._meshes[i.uniqueId];
- o && (o.observerHighlight && i.onBeforeBindObservable.remove(o.observerHighlight),
- o.observerDefault && i.onAfterRenderObservable.remove(o.observerDefault),
- delete this._meshes[i.uniqueId]),
- this._shouldRender = !1;
- for (var s in this._meshes)
- if (this._meshes[s]) {
- this._shouldRender = !0;
- break
- }
- }
- }
- ,
- e.prototype.removeAllMeshes = function() {
- if (!!this._meshes) {
- for (var i in this._meshes)
- if (this._meshes.hasOwnProperty(i)) {
- var o = this._meshes[i];
- o && this.removeMesh(o.mesh)
- }
- }
- }
- ,
- e.prototype._defaultStencilReference = function(i) {
- i.getScene().getEngine().setStencilFunctionReference(e.NormalMeshStencilReference)
- }
- ,
- e.prototype._disposeMesh = function(i) {
- this.removeMesh(i),
- this.removeExcludedMesh(i)
- }
- ,
- e.prototype.dispose = function() {
- if (this._meshes) {
- for (var i in this._meshes) {
- var o = this._meshes[i];
- o && o.mesh && (o.observerHighlight && o.mesh.onBeforeBindObservable.remove(o.observerHighlight),
- o.observerDefault && o.mesh.onAfterRenderObservable.remove(o.observerDefault))
- }
- this._meshes = null
- }
- if (this._excludedMeshes) {
- for (var i in this._excludedMeshes) {
- var o = this._excludedMeshes[i];
- o && (o.beforeBind && o.mesh.onBeforeBindObservable.remove(o.beforeBind),
- o.afterRender && o.mesh.onAfterRenderObservable.remove(o.afterRender))
- }
- this._excludedMeshes = null
- }
- a.prototype.dispose.call(this)
- }
- ,
- e.prototype.getClassName = function() {
- return "HighlightLayer"
- }
- ,
- e.prototype.serialize = function() {
- var i = SerializationHelper.Serialize(this);
- if (i.customType = "BABYLON.HighlightLayer",
- i.meshes = [],
- this._meshes)
- for (var o in this._meshes) {
- var s = this._meshes[o];
- s && i.meshes.push({
- glowEmissiveOnly: s.glowEmissiveOnly,
- color: s.color.asArray(),
- meshId: s.mesh.id
- })
- }
- if (i.excludedMeshes = [],
- this._excludedMeshes)
- for (var c in this._excludedMeshes) {
- var d = this._excludedMeshes[c];
- d && i.excludedMeshes.push(d.mesh.id)
- }
- return i
- }
- ,
- e.Parse = function(i, o, s) {
- var c = SerializationHelper.Parse(function() {
- return new e(i.name,o,i.options)
- }, i, o, s), d;
- for (d = 0; d < i.excludedMeshes.length; d++) {
- var _ = o.getMeshById(i.excludedMeshes[d]);
- _ && c.addExcludedMesh(_)
- }
- for (d = 0; d < i.meshes.length; d++) {
- var b = i.meshes[d]
- , _ = o.getMeshById(b.meshId);
- _ && c.addMesh(_, Color3.FromArray(b.color), b.glowEmissiveOnly)
- }
- return c
- }
- ,
- e.EffectName = "HighlightLayer",
- e.NeutralColor = new Color4(0,0,0,0),
- e.GlowingMeshStencilReference = 2,
- e.NormalMeshStencilReference = 1,
- __decorate([serialize()], e.prototype, "innerGlow", void 0),
- __decorate([serialize()], e.prototype, "outerGlow", void 0),
- __decorate([serialize()], e.prototype, "blurHorizontalSize", null),
- __decorate([serialize()], e.prototype, "blurVerticalSize", null),
- __decorate([serialize("options")], e.prototype, "_options", void 0),
- e
- }(EffectLayer);
- RegisterClass("BABYLON.HighlightLayer", HighlightLayer);
- var name$y = "sharpenPixelShader"
- , shader$y = `
- varying vec2 vUV;
- uniform sampler2D textureSampler;
- uniform vec2 screenSize;
- uniform vec2 sharpnessAmounts;
- void main(void)
- {
- vec2 onePixel=vec2(1.0,1.0)/screenSize;
- vec4 color=texture2D(textureSampler,vUV);
- vec4 edgeDetection=texture2D(textureSampler,vUV+onePixel*vec2(0,-1)) +
- texture2D(textureSampler,vUV+onePixel*vec2(-1,0)) +
- texture2D(textureSampler,vUV+onePixel*vec2(1,0)) +
- texture2D(textureSampler,vUV+onePixel*vec2(0,1)) -
- color*4.0;
- gl_FragColor=max(vec4(color.rgb*sharpnessAmounts.y,color.a)-(sharpnessAmounts.x*vec4(edgeDetection.rgb,0)),0.);
- }`;
- ShaderStore.ShadersStore[name$y] = shader$y;
- var SharpenPostProcess = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _, b, k) {
- b === void 0 && (b = 0),
- k === void 0 && (k = !1);
- var j = a.call(this, i, "sharpen", ["sharpnessAmounts", "screenSize"], null, o, s, c, d, _, null, b, void 0, null, k) || this;
- return j.colorAmount = 1,
- j.edgeAmount = .3,
- j.onApply = function($) {
- $.setFloat2("screenSize", j.width, j.height),
- $.setFloat2("sharpnessAmounts", j.edgeAmount, j.colorAmount)
- }
- ,
- j
- }
- return e.prototype.getClassName = function() {
- return "SharpenPostProcess"
- }
- ,
- e._Parse = function(i, o, s, c) {
- return SerializationHelper.Parse(function() {
- return new e(i.name,i.options,o,i.renderTargetSamplingMode,s.getEngine(),i.textureType,i.reusable)
- }, i, s, c)
- }
- ,
- __decorate([serialize()], e.prototype, "colorAmount", void 0),
- __decorate([serialize()], e.prototype, "edgeAmount", void 0),
- e
- }(PostProcess);
- RegisterClass("BABYLON.SharpenPostProcess", SharpenPostProcess);
- var name$x = "imageProcessingPixelShader"
- , shader$x = `
- varying vec2 vUV;
- uniform sampler2D textureSampler;
- #include<imageProcessingDeclaration>
- #include<helperFunctions>
- #include<imageProcessingFunctions>
- void main(void)
- {
- vec4 result=texture2D(textureSampler,vUV);
- #ifdef IMAGEPROCESSING
- #ifndef FROMLINEARSPACE
- result.rgb=toLinearSpace(result.rgb);
- #endif
- result=applyImageProcessing(result);
- #else
- #ifdef FROMLINEARSPACE
- result=applyImageProcessing(result);
- #endif
- #endif
- gl_FragColor=result;
- }`;
- ShaderStore.ShadersStore[name$x] = shader$x;
- var ImageProcessingPostProcess = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _, b, k) {
- s === void 0 && (s = null),
- b === void 0 && (b = 0);
- var j = a.call(this, i, "imageProcessing", [], [], o, s, c, d, _, null, b, "postprocess", null, !0) || this;
- return j._fromLinearSpace = !0,
- j._defines = {
- IMAGEPROCESSING: !1,
- VIGNETTE: !1,
- VIGNETTEBLENDMODEMULTIPLY: !1,
- VIGNETTEBLENDMODEOPAQUE: !1,
- TONEMAPPING: !1,
- TONEMAPPING_ACES: !1,
- CONTRAST: !1,
- COLORCURVES: !1,
- COLORGRADING: !1,
- COLORGRADING3D: !1,
- FROMLINEARSPACE: !1,
- SAMPLER3DGREENDEPTH: !1,
- SAMPLER3DBGRMAP: !1,
- IMAGEPROCESSINGPOSTPROCESS: !1,
- EXPOSURE: !1,
- SKIPFINALCOLORCLAMP: !1
- },
- k ? (k.applyByPostProcess = !0,
- j._attachImageProcessingConfiguration(k, !0),
- j.fromLinearSpace = !1) : (j._attachImageProcessingConfiguration(null, !0),
- j.imageProcessingConfiguration.applyByPostProcess = !0),
- j.onApply = function($) {
- j.imageProcessingConfiguration.bind($, j.aspectRatio)
- }
- ,
- j
- }
- return Object.defineProperty(e.prototype, "imageProcessingConfiguration", {
- get: function() {
- return this._imageProcessingConfiguration
- },
- set: function(i) {
- i.applyByPostProcess = !0,
- this._attachImageProcessingConfiguration(i)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._attachImageProcessingConfiguration = function(i, o) {
- var s = this;
- if (o === void 0 && (o = !1),
- i !== this._imageProcessingConfiguration) {
- if (this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
- i)
- this._imageProcessingConfiguration = i;
- else {
- var c = null
- , d = this.getEngine()
- , _ = this.getCamera();
- if (_)
- c = _.getScene();
- else if (d && d.scenes) {
- var b = d.scenes;
- c = b[b.length - 1]
- } else
- c = EngineStore.LastCreatedScene;
- c ? this._imageProcessingConfiguration = c.imageProcessingConfiguration : this._imageProcessingConfiguration = new ImageProcessingConfiguration
- }
- this._imageProcessingConfiguration && (this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function() {
- s._updateParameters()
- })),
- o || this._updateParameters()
- }
- }
- ,
- Object.defineProperty(e.prototype, "isSupported", {
- get: function() {
- var i = this.getEffect();
- return !i || i.isSupported
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "colorCurves", {
- get: function() {
- return this.imageProcessingConfiguration.colorCurves
- },
- set: function(i) {
- this.imageProcessingConfiguration.colorCurves = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "colorCurvesEnabled", {
- get: function() {
- return this.imageProcessingConfiguration.colorCurvesEnabled
- },
- set: function(i) {
- this.imageProcessingConfiguration.colorCurvesEnabled = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "colorGradingTexture", {
- get: function() {
- return this.imageProcessingConfiguration.colorGradingTexture
- },
- set: function(i) {
- this.imageProcessingConfiguration.colorGradingTexture = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "colorGradingEnabled", {
- get: function() {
- return this.imageProcessingConfiguration.colorGradingEnabled
- },
- set: function(i) {
- this.imageProcessingConfiguration.colorGradingEnabled = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "exposure", {
- get: function() {
- return this.imageProcessingConfiguration.exposure
- },
- set: function(i) {
- this.imageProcessingConfiguration.exposure = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "toneMappingEnabled", {
- get: function() {
- return this._imageProcessingConfiguration.toneMappingEnabled
- },
- set: function(i) {
- this._imageProcessingConfiguration.toneMappingEnabled = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "toneMappingType", {
- get: function() {
- return this._imageProcessingConfiguration.toneMappingType
- },
- set: function(i) {
- this._imageProcessingConfiguration.toneMappingType = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "contrast", {
- get: function() {
- return this.imageProcessingConfiguration.contrast
- },
- set: function(i) {
- this.imageProcessingConfiguration.contrast = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "vignetteStretch", {
- get: function() {
- return this.imageProcessingConfiguration.vignetteStretch
- },
- set: function(i) {
- this.imageProcessingConfiguration.vignetteStretch = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "vignetteCentreX", {
- get: function() {
- return this.imageProcessingConfiguration.vignetteCentreX
- },
- set: function(i) {
- this.imageProcessingConfiguration.vignetteCentreX = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "vignetteCentreY", {
- get: function() {
- return this.imageProcessingConfiguration.vignetteCentreY
- },
- set: function(i) {
- this.imageProcessingConfiguration.vignetteCentreY = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "vignetteWeight", {
- get: function() {
- return this.imageProcessingConfiguration.vignetteWeight
- },
- set: function(i) {
- this.imageProcessingConfiguration.vignetteWeight = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "vignetteColor", {
- get: function() {
- return this.imageProcessingConfiguration.vignetteColor
- },
- set: function(i) {
- this.imageProcessingConfiguration.vignetteColor = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "vignetteCameraFov", {
- get: function() {
- return this.imageProcessingConfiguration.vignetteCameraFov
- },
- set: function(i) {
- this.imageProcessingConfiguration.vignetteCameraFov = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "vignetteBlendMode", {
- get: function() {
- return this.imageProcessingConfiguration.vignetteBlendMode
- },
- set: function(i) {
- this.imageProcessingConfiguration.vignetteBlendMode = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "vignetteEnabled", {
- get: function() {
- return this.imageProcessingConfiguration.vignetteEnabled
- },
- set: function(i) {
- this.imageProcessingConfiguration.vignetteEnabled = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "fromLinearSpace", {
- get: function() {
- return this._fromLinearSpace
- },
- set: function(i) {
- this._fromLinearSpace !== i && (this._fromLinearSpace = i,
- this._updateParameters())
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getClassName = function() {
- return "ImageProcessingPostProcess"
- }
- ,
- e.prototype._updateParameters = function() {
- this._defines.FROMLINEARSPACE = this._fromLinearSpace,
- this.imageProcessingConfiguration.prepareDefines(this._defines, !0);
- var i = "";
- for (var o in this._defines)
- this._defines[o] && (i += "#define " + o + `;\r
- `);
- var s = ["textureSampler"]
- , c = ["scale"];
- ImageProcessingConfiguration && (ImageProcessingConfiguration.PrepareSamplers(s, this._defines),
- ImageProcessingConfiguration.PrepareUniforms(c, this._defines)),
- this.updateEffect(i, c, s)
- }
- ,
- e.prototype.dispose = function(i) {
- a.prototype.dispose.call(this, i),
- this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
- this._imageProcessingConfiguration && (this.imageProcessingConfiguration.applyByPostProcess = !1)
- }
- ,
- __decorate([serialize()], e.prototype, "_fromLinearSpace", void 0),
- e
- }(PostProcess)
- , name$w = "chromaticAberrationPixelShader"
- , shader$w = `
- uniform sampler2D textureSampler;
- uniform float chromatic_aberration;
- uniform float radialIntensity;
- uniform vec2 direction;
- uniform vec2 centerPosition;
- uniform float screen_width;
- uniform float screen_height;
- varying vec2 vUV;
- void main(void)
- {
- vec2 centered_screen_pos=vec2(vUV.x-centerPosition.x,vUV.y-centerPosition.y);
- vec2 directionOfEffect=direction;
- if(directionOfEffect.x == 0. && directionOfEffect.y == 0.){
- directionOfEffect=normalize(centered_screen_pos);
- }
- float radius2=centered_screen_pos.x*centered_screen_pos.x
- +centered_screen_pos.y*centered_screen_pos.y;
- float radius=sqrt(radius2);
- vec4 original=texture2D(textureSampler,vUV);
- vec3 ref_indices=vec3(-0.3,0.0,0.3);
- float ref_shiftX=chromatic_aberration*pow(radius,radialIntensity)*directionOfEffect.x/screen_width;
- float ref_shiftY=chromatic_aberration*pow(radius,radialIntensity)*directionOfEffect.y/screen_height;
- vec2 ref_coords_r=vec2(vUV.x+ref_indices.r*ref_shiftX,vUV.y+ref_indices.r*ref_shiftY*0.5);
- vec2 ref_coords_g=vec2(vUV.x+ref_indices.g*ref_shiftX,vUV.y+ref_indices.g*ref_shiftY*0.5);
- vec2 ref_coords_b=vec2(vUV.x+ref_indices.b*ref_shiftX,vUV.y+ref_indices.b*ref_shiftY*0.5);
- original.r=texture2D(textureSampler,ref_coords_r).r;
- original.g=texture2D(textureSampler,ref_coords_g).g;
- original.b=texture2D(textureSampler,ref_coords_b).b;
- original.a=clamp(texture2D(textureSampler,ref_coords_r).a+texture2D(textureSampler,ref_coords_g).a+texture2D(textureSampler,ref_coords_b).a,0.,1.);
- gl_FragColor=original;
- }`;
- ShaderStore.ShadersStore[name$w] = shader$w;
- var ChromaticAberrationPostProcess = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _, b, k, j, $) {
- j === void 0 && (j = 0),
- $ === void 0 && ($ = !1);
- 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;
- return _e.aberrationAmount = 30,
- _e.radialIntensity = 0,
- _e.direction = new Vector2(.707,.707),
- _e.centerPosition = new Vector2(.5,.5),
- _e.screenWidth = o,
- _e.screenHeight = s,
- _e.onApplyObservable.add(function(et) {
- et.setFloat("chromatic_aberration", _e.aberrationAmount),
- et.setFloat("screen_width", o),
- et.setFloat("screen_height", s),
- et.setFloat("radialIntensity", _e.radialIntensity),
- et.setFloat2("direction", _e.direction.x, _e.direction.y),
- et.setFloat2("centerPosition", _e.centerPosition.x, _e.centerPosition.y)
- }),
- _e
- }
- return e.prototype.getClassName = function() {
- return "ChromaticAberrationPostProcess"
- }
- ,
- e._Parse = function(i, o, s, c) {
- return SerializationHelper.Parse(function() {
- return new e(i.name,i.screenWidth,i.screenHeight,i.options,o,i.renderTargetSamplingMode,s.getEngine(),i.reusable,i.textureType,!1)
- }, i, s, c)
- }
- ,
- __decorate([serialize()], e.prototype, "aberrationAmount", void 0),
- __decorate([serialize()], e.prototype, "radialIntensity", void 0),
- __decorate([serialize()], e.prototype, "direction", void 0),
- __decorate([serialize()], e.prototype, "centerPosition", void 0),
- __decorate([serialize()], e.prototype, "screenWidth", void 0),
- __decorate([serialize()], e.prototype, "screenHeight", void 0),
- e
- }(PostProcess);
- RegisterClass("BABYLON.ChromaticAberrationPostProcess", ChromaticAberrationPostProcess);
- var name$v = "grainPixelShader"
- , shader$v = `#include<helperFunctions>
- uniform sampler2D textureSampler;
- uniform float intensity;
- uniform float animatedSeed;
- varying vec2 vUV;
- void main(void)
- {
- gl_FragColor=texture2D(textureSampler,vUV);
- vec2 seed=vUV*(animatedSeed);
- float grain=dither(seed,intensity);
- float lum=getLuminance(gl_FragColor.rgb);
- float grainAmount=(cos(-PI+(lum*PI*2.))+1.)/2.;
- gl_FragColor.rgb+=grain*grainAmount;
- gl_FragColor.rgb=max(gl_FragColor.rgb,0.0);
- }`;
- ShaderStore.ShadersStore[name$v] = shader$v;
- var GrainPostProcess = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _, b, k) {
- b === void 0 && (b = 0),
- k === void 0 && (k = !1);
- var j = a.call(this, i, "grain", ["intensity", "animatedSeed"], [], o, s, c, d, _, null, b, void 0, null, k) || this;
- return j.intensity = 30,
- j.animated = !1,
- j.onApplyObservable.add(function($) {
- $.setFloat("intensity", j.intensity),
- $.setFloat("animatedSeed", j.animated ? Math.random() + 1 : 1)
- }),
- j
- }
- return e.prototype.getClassName = function() {
- return "GrainPostProcess"
- }
- ,
- e._Parse = function(i, o, s, c) {
- return SerializationHelper.Parse(function() {
- return new e(i.name,i.options,o,i.renderTargetSamplingMode,s.getEngine(),i.reusable)
- }, i, s, c)
- }
- ,
- __decorate([serialize()], e.prototype, "intensity", void 0),
- __decorate([serialize()], e.prototype, "animated", void 0),
- e
- }(PostProcess);
- RegisterClass("BABYLON.GrainPostProcess", GrainPostProcess);
- var name$u = "fxaaPixelShader"
- , shader$u = `uniform sampler2D textureSampler;
- uniform vec2 texelSize;
- varying vec2 vUV;
- varying vec2 sampleCoordS;
- varying vec2 sampleCoordE;
- varying vec2 sampleCoordN;
- varying vec2 sampleCoordW;
- varying vec2 sampleCoordNW;
- varying vec2 sampleCoordSE;
- varying vec2 sampleCoordNE;
- varying vec2 sampleCoordSW;
- const float fxaaQualitySubpix=1.0;
- const float fxaaQualityEdgeThreshold=0.166;
- const float fxaaQualityEdgeThresholdMin=0.0833;
- const vec3 kLumaCoefficients=vec3(0.2126,0.7152,0.0722);
- #define FxaaLuma(rgba) dot(rgba.rgb,kLumaCoefficients)
- void main(){
- vec2 posM;
- posM.x=vUV.x;
- posM.y=vUV.y;
- vec4 rgbyM=texture2D(textureSampler,vUV,0.0);
- float lumaM=FxaaLuma(rgbyM);
- float lumaS=FxaaLuma(texture2D(textureSampler,sampleCoordS,0.0));
- float lumaE=FxaaLuma(texture2D(textureSampler,sampleCoordE,0.0));
- float lumaN=FxaaLuma(texture2D(textureSampler,sampleCoordN,0.0));
- float lumaW=FxaaLuma(texture2D(textureSampler,sampleCoordW,0.0));
- float maxSM=max(lumaS,lumaM);
- float minSM=min(lumaS,lumaM);
- float maxESM=max(lumaE,maxSM);
- float minESM=min(lumaE,minSM);
- float maxWN=max(lumaN,lumaW);
- float minWN=min(lumaN,lumaW);
- float rangeMax=max(maxWN,maxESM);
- float rangeMin=min(minWN,minESM);
- float rangeMaxScaled=rangeMax*fxaaQualityEdgeThreshold;
- float range=rangeMax-rangeMin;
- float rangeMaxClamped=max(fxaaQualityEdgeThresholdMin,rangeMaxScaled);
- #ifndef MALI
- if(range<rangeMaxClamped)
- {
- gl_FragColor=rgbyM;
- return;
- }
- #endif
- float lumaNW=FxaaLuma(texture2D(textureSampler,sampleCoordNW,0.0));
- float lumaSE=FxaaLuma(texture2D(textureSampler,sampleCoordSE,0.0));
- float lumaNE=FxaaLuma(texture2D(textureSampler,sampleCoordNE,0.0));
- float lumaSW=FxaaLuma(texture2D(textureSampler,sampleCoordSW,0.0));
- float lumaNS=lumaN+lumaS;
- float lumaWE=lumaW+lumaE;
- float subpixRcpRange=1.0/range;
- float subpixNSWE=lumaNS+lumaWE;
- float edgeHorz1=(-2.0*lumaM)+lumaNS;
- float edgeVert1=(-2.0*lumaM)+lumaWE;
- float lumaNESE=lumaNE+lumaSE;
- float lumaNWNE=lumaNW+lumaNE;
- float edgeHorz2=(-2.0*lumaE)+lumaNESE;
- float edgeVert2=(-2.0*lumaN)+lumaNWNE;
- float lumaNWSW=lumaNW+lumaSW;
- float lumaSWSE=lumaSW+lumaSE;
- float edgeHorz4=(abs(edgeHorz1)*2.0)+abs(edgeHorz2);
- float edgeVert4=(abs(edgeVert1)*2.0)+abs(edgeVert2);
- float edgeHorz3=(-2.0*lumaW)+lumaNWSW;
- float edgeVert3=(-2.0*lumaS)+lumaSWSE;
- float edgeHorz=abs(edgeHorz3)+edgeHorz4;
- float edgeVert=abs(edgeVert3)+edgeVert4;
- float subpixNWSWNESE=lumaNWSW+lumaNESE;
- float lengthSign=texelSize.x;
- bool horzSpan=edgeHorz>=edgeVert;
- float subpixA=subpixNSWE*2.0+subpixNWSWNESE;
- if (!horzSpan)
- {
- lumaN=lumaW;
- }
- if (!horzSpan)
- {
- lumaS=lumaE;
- }
- if (horzSpan)
- {
- lengthSign=texelSize.y;
- }
- float subpixB=(subpixA*(1.0/12.0))-lumaM;
- float gradientN=lumaN-lumaM;
- float gradientS=lumaS-lumaM;
- float lumaNN=lumaN+lumaM;
- float lumaSS=lumaS+lumaM;
- bool pairN=abs(gradientN)>=abs(gradientS);
- float gradient=max(abs(gradientN),abs(gradientS));
- if (pairN)
- {
- lengthSign=-lengthSign;
- }
- float subpixC=clamp(abs(subpixB)*subpixRcpRange,0.0,1.0);
- vec2 posB;
- posB.x=posM.x;
- posB.y=posM.y;
- vec2 offNP;
- offNP.x=(!horzSpan) ? 0.0 : texelSize.x;
- offNP.y=(horzSpan) ? 0.0 : texelSize.y;
- if (!horzSpan)
- {
- posB.x+=lengthSign*0.5;
- }
- if (horzSpan)
- {
- posB.y+=lengthSign*0.5;
- }
- vec2 posN;
- posN.x=posB.x-offNP.x*1.5;
- posN.y=posB.y-offNP.y*1.5;
- vec2 posP;
- posP.x=posB.x+offNP.x*1.5;
- posP.y=posB.y+offNP.y*1.5;
- float subpixD=((-2.0)*subpixC)+3.0;
- float lumaEndN=FxaaLuma(texture2D(textureSampler,posN,0.0));
- float subpixE=subpixC*subpixC;
- float lumaEndP=FxaaLuma(texture2D(textureSampler,posP,0.0));
- if (!pairN)
- {
- lumaNN=lumaSS;
- }
- float gradientScaled=gradient*1.0/4.0;
- float lumaMM=lumaM-lumaNN*0.5;
- float subpixF=subpixD*subpixE;
- bool lumaMLTZero=lumaMM<0.0;
- lumaEndN-=lumaNN*0.5;
- lumaEndP-=lumaNN*0.5;
- bool doneN=abs(lumaEndN)>=gradientScaled;
- bool doneP=abs(lumaEndP)>=gradientScaled;
- if (!doneN)
- {
- posN.x-=offNP.x*3.0;
- }
- if (!doneN)
- {
- posN.y-=offNP.y*3.0;
- }
- bool doneNP=(!doneN) || (!doneP);
- if (!doneP)
- {
- posP.x+=offNP.x*3.0;
- }
- if (!doneP)
- {
- posP.y+=offNP.y*3.0;
- }
- if (doneNP)
- {
- if (!doneN) lumaEndN=FxaaLuma(texture2D(textureSampler,posN.xy,0.0));
- if (!doneP) lumaEndP=FxaaLuma(texture2D(textureSampler,posP.xy,0.0));
- if (!doneN) lumaEndN=lumaEndN-lumaNN*0.5;
- if (!doneP) lumaEndP=lumaEndP-lumaNN*0.5;
- doneN=abs(lumaEndN)>=gradientScaled;
- doneP=abs(lumaEndP)>=gradientScaled;
- if (!doneN) posN.x-=offNP.x*12.0;
- if (!doneN) posN.y-=offNP.y*12.0;
- doneNP=(!doneN) || (!doneP);
- if (!doneP) posP.x+=offNP.x*12.0;
- if (!doneP) posP.y+=offNP.y*12.0;
- }
- float dstN=posM.x-posN.x;
- float dstP=posP.x-posM.x;
- if (!horzSpan)
- {
- dstN=posM.y-posN.y;
- }
- if (!horzSpan)
- {
- dstP=posP.y-posM.y;
- }
- bool goodSpanN=(lumaEndN<0.0) != lumaMLTZero;
- float spanLength=(dstP+dstN);
- bool goodSpanP=(lumaEndP<0.0) != lumaMLTZero;
- float spanLengthRcp=1.0/spanLength;
- bool directionN=dstN<dstP;
- float dst=min(dstN,dstP);
- bool goodSpan=directionN ? goodSpanN : goodSpanP;
- float subpixG=subpixF*subpixF;
- float pixelOffset=(dst*(-spanLengthRcp))+0.5;
- float subpixH=subpixG*fxaaQualitySubpix;
- float pixelOffsetGood=goodSpan ? pixelOffset : 0.0;
- float pixelOffsetSubpix=max(pixelOffsetGood,subpixH);
- if (!horzSpan)
- {
- posM.x+=pixelOffsetSubpix*lengthSign;
- }
- if (horzSpan)
- {
- posM.y+=pixelOffsetSubpix*lengthSign;
- }
- #ifdef MALI
- if(range<rangeMaxClamped)
- {
- gl_FragColor=rgbyM;
- }
- else
- {
- gl_FragColor=texture2D(textureSampler,posM,0.0);
- }
- #else
- gl_FragColor=texture2D(textureSampler,posM,0.0);
- #endif
- }`;
- ShaderStore.ShadersStore[name$u] = shader$u;
- var name$t = "fxaaVertexShader"
- , shader$t = `
- attribute vec2 position;
- uniform vec2 texelSize;
- varying vec2 vUV;
- varying vec2 sampleCoordS;
- varying vec2 sampleCoordE;
- varying vec2 sampleCoordN;
- varying vec2 sampleCoordW;
- varying vec2 sampleCoordNW;
- varying vec2 sampleCoordSE;
- varying vec2 sampleCoordNE;
- varying vec2 sampleCoordSW;
- const vec2 madd=vec2(0.5,0.5);
- void main(void) {
- vUV=(position*madd+madd);
- sampleCoordS=vUV+vec2( 0.0,1.0)*texelSize;
- sampleCoordE=vUV+vec2( 1.0,0.0)*texelSize;
- sampleCoordN=vUV+vec2( 0.0,-1.0)*texelSize;
- sampleCoordW=vUV+vec2(-1.0,0.0)*texelSize;
- sampleCoordNW=vUV+vec2(-1.0,-1.0)*texelSize;
- sampleCoordSE=vUV+vec2( 1.0,1.0)*texelSize;
- sampleCoordNE=vUV+vec2( 1.0,-1.0)*texelSize;
- sampleCoordSW=vUV+vec2(-1.0,1.0)*texelSize;
- gl_Position=vec4(position,0.0,1.0);
- }`;
- ShaderStore.ShadersStore[name$t] = shader$t;
- var FxaaPostProcess = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _, b) {
- s === void 0 && (s = null),
- b === void 0 && (b = 0);
- var k = a.call(this, i, "fxaa", ["texelSize"], null, o, s, c || Texture.BILINEAR_SAMPLINGMODE, d, _, null, b, "fxaa", void 0, !0) || this
- , j = k._getDefines();
- return k.updateEffect(j),
- k.onApplyObservable.add(function($) {
- var _e = k.texelSize;
- $.setFloat2("texelSize", _e.x, _e.y)
- }),
- k
- }
- return e.prototype.getClassName = function() {
- return "FxaaPostProcess"
- }
- ,
- e.prototype._getDefines = function() {
- var i = this.getEngine();
- if (!i)
- return null;
- var o = i.getGlInfo();
- return o && o.renderer && o.renderer.toLowerCase().indexOf("mali") > -1 ? `#define MALI 1
- ` : null
- }
- ,
- e._Parse = function(i, o, s, c) {
- return SerializationHelper.Parse(function() {
- return new e(i.name,i.options,o,i.renderTargetSamplingMode,s.getEngine(),i.reusable)
- }, i, s, c)
- }
- ,
- e
- }(PostProcess);
- RegisterClass("BABYLON.FxaaPostProcess", FxaaPostProcess);
- var PostProcessRenderPipeline = function() {
- function a(e, i) {
- this.engine = e,
- this._name = i,
- this._renderEffects = {},
- this._renderEffectsForIsolatedPass = new Array,
- this._cameras = []
- }
- return Object.defineProperty(a.prototype, "name", {
- get: function() {
- return this._name
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "cameras", {
- get: function() {
- return this._cameras
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.getClassName = function() {
- return "PostProcessRenderPipeline"
- }
- ,
- Object.defineProperty(a.prototype, "isSupported", {
- get: function() {
- for (var e in this._renderEffects)
- if (this._renderEffects.hasOwnProperty(e) && !this._renderEffects[e].isSupported)
- return !1;
- return !0
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.addEffect = function(e) {
- this._renderEffects[e._name] = e
- }
- ,
- a.prototype._rebuild = function() {}
- ,
- a.prototype._enableEffect = function(e, i) {
- var o = this._renderEffects[e];
- !o || o._enable(Tools.MakeArray(i || this._cameras))
- }
- ,
- a.prototype._disableEffect = function(e, i) {
- var o = this._renderEffects[e];
- !o || o._disable(Tools.MakeArray(i || this._cameras))
- }
- ,
- a.prototype._attachCameras = function(e, i) {
- var o = Tools.MakeArray(e || this._cameras);
- if (!!o) {
- var s = [], c;
- for (c = 0; c < o.length; c++) {
- var d = o[c];
- if (!!d) {
- var _ = d.name;
- this._cameras.indexOf(d) === -1 ? this._cameras[_] = d : i && s.push(c)
- }
- }
- for (c = 0; c < s.length; c++)
- o.splice(s[c], 1);
- for (var b in this._renderEffects)
- this._renderEffects.hasOwnProperty(b) && this._renderEffects[b]._attachCameras(o)
- }
- }
- ,
- a.prototype._detachCameras = function(e) {
- var i = Tools.MakeArray(e || this._cameras);
- if (!!i) {
- for (var o in this._renderEffects)
- this._renderEffects.hasOwnProperty(o) && this._renderEffects[o]._detachCameras(i);
- for (var s = 0; s < i.length; s++)
- this._cameras.splice(this._cameras.indexOf(i[s]), 1)
- }
- }
- ,
- a.prototype._update = function() {
- for (var e in this._renderEffects)
- this._renderEffects.hasOwnProperty(e) && this._renderEffects[e]._update();
- for (var i = 0; i < this._cameras.length; i++)
- if (!!this._cameras[i]) {
- var o = this._cameras[i].name;
- this._renderEffectsForIsolatedPass[o] && this._renderEffectsForIsolatedPass[o]._update()
- }
- }
- ,
- a.prototype._reset = function() {
- this._renderEffects = {},
- this._renderEffectsForIsolatedPass = new Array
- }
- ,
- a.prototype._enableMSAAOnFirstPostProcess = function(e) {
- if (!this.engine._features.supportMSAA)
- return !1;
- var i = Object.keys(this._renderEffects);
- if (i.length > 0) {
- var o = this._renderEffects[i[0]].getPostProcesses();
- o && (o[0].samples = e)
- }
- return !0
- }
- ,
- a.prototype.setPrePassRenderer = function(e) {
- return !1
- }
- ,
- a.prototype.dispose = function() {}
- ,
- __decorate([serialize()], a.prototype, "_name", void 0),
- a
- }()
- , PostProcessRenderEffect = function() {
- function a(e, i, o, s) {
- this._name = i,
- this._singleInstance = s || !0,
- this._getPostProcesses = o,
- this._cameras = {},
- this._indicesForCamera = {},
- this._postProcesses = {}
- }
- return Object.defineProperty(a.prototype, "isSupported", {
- get: function() {
- for (var e in this._postProcesses)
- if (this._postProcesses.hasOwnProperty(e)) {
- for (var i = this._postProcesses[e], o = 0; o < i.length; o++)
- if (!i[o].isSupported)
- return !1
- }
- return !0
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._update = function() {}
- ,
- a.prototype._attachCameras = function(e) {
- var i = this, o, s = Tools.MakeArray(e || this._cameras);
- if (!!s)
- for (var c = 0; c < s.length; c++) {
- var d = s[c];
- if (!!d) {
- var _ = d.name;
- if (this._singleInstance ? o = 0 : o = _,
- !this._postProcesses[o]) {
- var b = this._getPostProcesses();
- b && (this._postProcesses[o] = Array.isArray(b) ? b : [b])
- }
- this._indicesForCamera[_] || (this._indicesForCamera[_] = []),
- this._postProcesses[o].forEach(function(k) {
- var j = d.attachPostProcess(k);
- i._indicesForCamera[_].push(j)
- }),
- this._cameras[_] || (this._cameras[_] = d)
- }
- }
- }
- ,
- a.prototype._detachCameras = function(e) {
- var i = Tools.MakeArray(e || this._cameras);
- if (!!i)
- for (var o = 0; o < i.length; o++) {
- var s = i[o]
- , c = s.name
- , d = this._postProcesses[this._singleInstance ? 0 : c];
- d && d.forEach(function(_) {
- s.detachPostProcess(_)
- }),
- this._cameras[c] && (this._cameras[c] = null)
- }
- }
- ,
- a.prototype._enable = function(e) {
- var i = this
- , o = Tools.MakeArray(e || this._cameras);
- if (!!o)
- for (var s = 0; s < o.length; s++)
- for (var c = o[s], d = c.name, _ = 0; _ < this._indicesForCamera[d].length; _++)
- (c._postProcesses[this._indicesForCamera[d][_]] === void 0 || c._postProcesses[this._indicesForCamera[d][_]] === null) && this._postProcesses[this._singleInstance ? 0 : d].forEach(function(b) {
- o[s].attachPostProcess(b, i._indicesForCamera[d][_])
- })
- }
- ,
- a.prototype._disable = function(e) {
- var i = Tools.MakeArray(e || this._cameras);
- if (!!i)
- for (var o = 0; o < i.length; o++) {
- var s = i[o]
- , c = s.name;
- this._postProcesses[this._singleInstance ? 0 : c].forEach(function(d) {
- s.detachPostProcess(d)
- })
- }
- }
- ,
- a.prototype.getPostProcesses = function(e) {
- return this._singleInstance ? this._postProcesses[0] : e ? this._postProcesses[e.name] : null
- }
- ,
- a
- }()
- , name$s = "circleOfConfusionPixelShader"
- , shader$s = `
- uniform sampler2D depthSampler;
- varying vec2 vUV;
- uniform vec2 cameraMinMaxZ;
- uniform float focusDistance;
- uniform float cocPrecalculation;
- void main(void)
- {
- float depth=texture2D(depthSampler,vUV).r;
- float pixelDistance=(cameraMinMaxZ.x+(cameraMinMaxZ.y-cameraMinMaxZ.x)*depth)*1000.0;
- float coc=abs(cocPrecalculation* ((focusDistance-pixelDistance)/pixelDistance));
- coc=clamp(coc,0.0,1.0);
- gl_FragColor=vec4(coc,depth,coc,1.0);
- }
- `;
- ShaderStore.ShadersStore[name$s] = shader$s;
- var CircleOfConfusionPostProcess = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _, b, k, j) {
- k === void 0 && (k = 0),
- j === void 0 && (j = !1);
- var $ = a.call(this, i, "circleOfConfusion", ["cameraMinMaxZ", "focusDistance", "cocPrecalculation"], ["depthSampler"], s, c, d, _, b, null, k, void 0, null, j) || this;
- return $.lensSize = 50,
- $.fStop = 1.4,
- $.focusDistance = 2e3,
- $.focalLength = 50,
- $._depthTexture = null,
- $._depthTexture = o,
- $.onApplyObservable.add(function(_e) {
- if (!$._depthTexture) {
- Logger$2.Warn("No depth texture set on CircleOfConfusionPostProcess");
- return
- }
- _e.setTexture("depthSampler", $._depthTexture);
- var et = $.lensSize / $.fStop
- , tt = et * $.focalLength / ($.focusDistance - $.focalLength);
- _e.setFloat("focusDistance", $.focusDistance),
- _e.setFloat("cocPrecalculation", tt),
- _e.setFloat2("cameraMinMaxZ", $._depthTexture.activeCamera.minZ, $._depthTexture.activeCamera.maxZ)
- }),
- $
- }
- return e.prototype.getClassName = function() {
- return "CircleOfConfusionPostProcess"
- }
- ,
- Object.defineProperty(e.prototype, "depthTexture", {
- set: function(i) {
- this._depthTexture = i
- },
- enumerable: !1,
- configurable: !0
- }),
- __decorate([serialize()], e.prototype, "lensSize", void 0),
- __decorate([serialize()], e.prototype, "fStop", void 0),
- __decorate([serialize()], e.prototype, "focusDistance", void 0),
- __decorate([serialize()], e.prototype, "focalLength", void 0),
- e
- }(PostProcess);
- RegisterClass("BABYLON.CircleOfConfusionPostProcess", CircleOfConfusionPostProcess);
- var DepthOfFieldBlurPostProcess = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _, b, k, j, $, _e, et, tt) {
- k === void 0 && (k = null),
- tt === void 0 && (tt = !1);
- var rt = a.call(this, i, s, c, d, _, 2, $, _e, 0, `#define DOF 1\r
- `, tt) || this;
- return rt.direction = s,
- rt.externalTextureSamplerBinding = !!k,
- rt.onApplyObservable.add(function(it) {
- k != null && it.setTextureFromPostProcess("textureSampler", k),
- it.setTextureFromPostProcessOutput("circleOfConfusionSampler", b),
- o.activeCamera && it.setFloat2("cameraMinMaxZ", o.activeCamera.minZ, o.activeCamera.maxZ)
- }),
- rt
- }
- return e.prototype.getClassName = function() {
- return "DepthOfFieldBlurPostProcess"
- }
- ,
- __decorate([serialize()], e.prototype, "direction", void 0),
- e
- }(BlurPostProcess);
- RegisterClass("BABYLON.DepthOfFieldBlurPostProcess", DepthOfFieldBlurPostProcess);
- var name$r = "depthOfFieldMergePixelShader"
- , shader$r = `uniform sampler2D textureSampler;
- varying vec2 vUV;
- uniform sampler2D circleOfConfusionSampler;
- uniform sampler2D blurStep0;
- #if BLUR_LEVEL>0
- uniform sampler2D blurStep1;
- #endif
- #if BLUR_LEVEL>1
- uniform sampler2D blurStep2;
- #endif
- void main(void)
- {
- float coc=texture2D(circleOfConfusionSampler,vUV).r;
- #if BLUR_LEVEL == 0
- vec4 original=texture2D(textureSampler,vUV);
- vec4 blurred0=texture2D(blurStep0,vUV);
- gl_FragColor=mix(original,blurred0,coc);
- #endif
- #if BLUR_LEVEL == 1
- if(coc<0.5){
- vec4 original=texture2D(textureSampler,vUV);
- vec4 blurred1=texture2D(blurStep1,vUV);
- gl_FragColor=mix(original,blurred1,coc/0.5);
- }else{
- vec4 blurred0=texture2D(blurStep0,vUV);
- vec4 blurred1=texture2D(blurStep1,vUV);
- gl_FragColor=mix(blurred1,blurred0,(coc-0.5)/0.5);
- }
- #endif
- #if BLUR_LEVEL == 2
- if(coc<0.33){
- vec4 original=texture2D(textureSampler,vUV);
- vec4 blurred2=texture2D(blurStep2,vUV);
- gl_FragColor=mix(original,blurred2,coc/0.33);
- }else if(coc<0.66){
- vec4 blurred1=texture2D(blurStep1,vUV);
- vec4 blurred2=texture2D(blurStep2,vUV);
- gl_FragColor=mix(blurred2,blurred1,(coc-0.33)/0.33);
- }else{
- vec4 blurred0=texture2D(blurStep0,vUV);
- vec4 blurred1=texture2D(blurStep1,vUV);
- gl_FragColor=mix(blurred1,blurred0,(coc-0.66)/0.34);
- }
- #endif
- }
- `;
- ShaderStore.ShadersStore[name$r] = shader$r;
- var DepthOfFieldMergePostProcess = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _, b, k, j, $, _e) {
- $ === void 0 && ($ = 0),
- _e === void 0 && (_e = !1);
- var et = a.call(this, i, "depthOfFieldMerge", [], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2"], d, _, b, k, j, null, $, void 0, null, !0) || this;
- return et.blurSteps = c,
- et.externalTextureSamplerBinding = !0,
- et.onApplyObservable.add(function(tt) {
- tt.setTextureFromPostProcess("textureSampler", o),
- tt.setTextureFromPostProcessOutput("circleOfConfusionSampler", s),
- c.forEach(function(rt, it) {
- tt.setTextureFromPostProcessOutput("blurStep" + (c.length - it - 1), rt)
- })
- }),
- _e || et.updateEffect(),
- et
- }
- return e.prototype.getClassName = function() {
- return "DepthOfFieldMergePostProcess"
- }
- ,
- e.prototype.updateEffect = function(i, o, s, c, d, _) {
- i === void 0 && (i = null),
- o === void 0 && (o = null),
- s === void 0 && (s = null),
- i || (i = "",
- i += "#define BLUR_LEVEL " + (this.blurSteps.length - 1) + `
- `),
- a.prototype.updateEffect.call(this, i, o, s, c, d, _)
- }
- ,
- e
- }(PostProcess), DepthOfFieldEffectBlurLevel;
- (function(a) {
- a[a.Low = 0] = "Low",
- a[a.Medium = 1] = "Medium",
- a[a.High = 2] = "High"
- }
- )(DepthOfFieldEffectBlurLevel || (DepthOfFieldEffectBlurLevel = {}));
- var DepthOfFieldEffect = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d) {
- s === void 0 && (s = DepthOfFieldEffectBlurLevel.Low),
- c === void 0 && (c = 0),
- d === void 0 && (d = !1);
- var _ = a.call(this, i.getEngine(), "depth of field", function() {
- return _._effects
- }, !0) || this;
- _._effects = [],
- _._circleOfConfusion = new CircleOfConfusionPostProcess("circleOfConfusion",o,1,null,Texture.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,c,d),
- _._depthOfFieldBlurY = [],
- _._depthOfFieldBlurX = [];
- var b = 1
- , k = 15;
- switch (s) {
- case DepthOfFieldEffectBlurLevel.High:
- {
- b = 3,
- k = 51;
- break
- }
- case DepthOfFieldEffectBlurLevel.Medium:
- {
- b = 2,
- k = 31;
- break
- }
- default:
- {
- k = 15,
- b = 1;
- break
- }
- }
- for (var j = k / Math.pow(2, b - 1), $ = 1, _e = 0; _e < b; _e++) {
- 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);
- et.autoClear = !1,
- $ = .75 / Math.pow(2, _e);
- var tt = new DepthOfFieldBlurPostProcess("horizontal blur",i,new Vector2(1,0),j,$,null,_._circleOfConfusion,null,Texture.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,c,d);
- tt.autoClear = !1,
- _._depthOfFieldBlurY.push(et),
- _._depthOfFieldBlurX.push(tt)
- }
- _._effects = [_._circleOfConfusion];
- for (var _e = 0; _e < _._depthOfFieldBlurX.length; _e++)
- _._effects.push(_._depthOfFieldBlurY[_e]),
- _._effects.push(_._depthOfFieldBlurX[_e]);
- return _._dofMerge = new DepthOfFieldMergePostProcess("dofMerge",_._circleOfConfusion,_._circleOfConfusion,_._depthOfFieldBlurX,$,null,Texture.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,c,d),
- _._dofMerge.autoClear = !1,
- _._effects.push(_._dofMerge),
- _
- }
- return Object.defineProperty(e.prototype, "focalLength", {
- get: function() {
- return this._circleOfConfusion.focalLength
- },
- set: function(i) {
- this._circleOfConfusion.focalLength = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "fStop", {
- get: function() {
- return this._circleOfConfusion.fStop
- },
- set: function(i) {
- this._circleOfConfusion.fStop = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "focusDistance", {
- get: function() {
- return this._circleOfConfusion.focusDistance
- },
- set: function(i) {
- this._circleOfConfusion.focusDistance = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "lensSize", {
- get: function() {
- return this._circleOfConfusion.lensSize
- },
- set: function(i) {
- this._circleOfConfusion.lensSize = i
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getClassName = function() {
- return "DepthOfFieldEffect"
- }
- ,
- Object.defineProperty(e.prototype, "depthTexture", {
- set: function(i) {
- this._circleOfConfusion.depthTexture = i
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.disposeEffects = function(i) {
- for (var o = 0; o < this._effects.length; o++)
- this._effects[o].dispose(i)
- }
- ,
- e.prototype._updateEffects = function() {
- for (var i = 0; i < this._effects.length; i++)
- this._effects[i].updateEffect()
- }
- ,
- e.prototype._isReady = function() {
- for (var i = 0; i < this._effects.length; i++)
- if (!this._effects[i].isReady())
- return !1;
- return !0
- }
- ,
- e
- }(PostProcessRenderEffect)
- , name$q = "extractHighlightsPixelShader"
- , shader$q = `#include<helperFunctions>
- varying vec2 vUV;
- uniform sampler2D textureSampler;
- uniform float threshold;
- uniform float exposure;
- void main(void)
- {
- gl_FragColor=texture2D(textureSampler,vUV);
- float luma=getLuminance(gl_FragColor.rgb*exposure);
- gl_FragColor.rgb=step(threshold,luma)*gl_FragColor.rgb;
- }`;
- ShaderStore.ShadersStore[name$q] = shader$q;
- var ExtractHighlightsPostProcess = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _, b, k) {
- b === void 0 && (b = 0),
- k === void 0 && (k = !1);
- var j = a.call(this, i, "extractHighlights", ["threshold", "exposure"], null, o, s, c, d, _, null, b, void 0, null, k) || this;
- return j.threshold = .9,
- j._exposure = 1,
- j._inputPostProcess = null,
- j.onApplyObservable.add(function($) {
- j.externalTextureSamplerBinding = !!j._inputPostProcess,
- j._inputPostProcess && $.setTextureFromPostProcess("textureSampler", j._inputPostProcess),
- $.setFloat("threshold", Math.pow(j.threshold, ToGammaSpace)),
- $.setFloat("exposure", j._exposure)
- }),
- j
- }
- return e.prototype.getClassName = function() {
- return "ExtractHighlightsPostProcess"
- }
- ,
- __decorate([serialize()], e.prototype, "threshold", void 0),
- e
- }(PostProcess);
- RegisterClass("BABYLON.ExtractHighlightsPostProcess", ExtractHighlightsPostProcess);
- var name$p = "bloomMergePixelShader"
- , shader$p = `uniform sampler2D textureSampler;
- uniform sampler2D bloomBlur;
- varying vec2 vUV;
- uniform float bloomWeight;
- void main(void)
- {
- gl_FragColor=texture2D(textureSampler,vUV);
- vec3 blurred=texture2D(bloomBlur,vUV).rgb;
- gl_FragColor.rgb=gl_FragColor.rgb+(blurred.rgb*bloomWeight);
- }
- `;
- ShaderStore.ShadersStore[name$p] = shader$p;
- var BloomMergePostProcess = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _, b, k, j, $, _e) {
- $ === void 0 && ($ = 0),
- _e === void 0 && (_e = !1);
- var et = a.call(this, i, "bloomMerge", ["bloomWeight"], ["bloomBlur"], d, _, b, k, j, null, $, void 0, null, !0) || this;
- return et.weight = 1,
- et.weight = c,
- et.externalTextureSamplerBinding = !0,
- et.onApplyObservable.add(function(tt) {
- tt.setTextureFromPostProcess("textureSampler", o),
- tt.setTextureFromPostProcessOutput("bloomBlur", s),
- tt.setFloat("bloomWeight", et.weight)
- }),
- _e || et.updateEffect(),
- et
- }
- return e.prototype.getClassName = function() {
- return "BloomMergePostProcess"
- }
- ,
- __decorate([serialize()], e.prototype, "weight", void 0),
- e
- }(PostProcess);
- RegisterClass("BABYLON.BloomMergePostProcess", BloomMergePostProcess);
- var BloomEffect = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _) {
- d === void 0 && (d = 0),
- _ === void 0 && (_ = !1);
- var b = a.call(this, i.getEngine(), "bloom", function() {
- return b._effects
- }, !0) || this;
- return b.bloomScale = o,
- b._effects = [],
- b._downscale = new ExtractHighlightsPostProcess("highlights",1,null,Texture.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,d,_),
- b._blurX = new BlurPostProcess("horizontal blur",new Vector2(1,0),10,o,null,Texture.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,d,void 0,_),
- b._blurX.alwaysForcePOT = !0,
- b._blurX.autoClear = !1,
- b._blurY = new BlurPostProcess("vertical blur",new Vector2(0,1),10,o,null,Texture.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,d,void 0,_),
- b._blurY.alwaysForcePOT = !0,
- b._blurY.autoClear = !1,
- b.kernel = c,
- b._effects = [b._downscale, b._blurX, b._blurY],
- b._merge = new BloomMergePostProcess("bloomMerge",b._downscale,b._blurY,s,o,null,Texture.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,d,_),
- b._merge.autoClear = !1,
- b._effects.push(b._merge),
- b
- }
- return Object.defineProperty(e.prototype, "threshold", {
- get: function() {
- return this._downscale.threshold
- },
- set: function(i) {
- this._downscale.threshold = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "weight", {
- get: function() {
- return this._merge.weight
- },
- set: function(i) {
- this._merge.weight = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "kernel", {
- get: function() {
- return this._blurX.kernel / this.bloomScale
- },
- set: function(i) {
- this._blurX.kernel = i * this.bloomScale,
- this._blurY.kernel = i * this.bloomScale
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.disposeEffects = function(i) {
- for (var o = 0; o < this._effects.length; o++)
- this._effects[o].dispose(i)
- }
- ,
- e.prototype._updateEffects = function() {
- for (var i = 0; i < this._effects.length; i++)
- this._effects[i].updateEffect()
- }
- ,
- e.prototype._isReady = function() {
- for (var i = 0; i < this._effects.length; i++)
- if (!this._effects[i].isReady())
- return !1;
- return !0
- }
- ,
- e
- }(PostProcessRenderEffect)
- , PostProcessRenderPipelineManager = function() {
- function a() {
- this._renderPipelines = {}
- }
- return Object.defineProperty(a.prototype, "supportedPipelines", {
- get: function() {
- var e = [];
- for (var i in this._renderPipelines)
- if (this._renderPipelines.hasOwnProperty(i)) {
- var o = this._renderPipelines[i];
- o.isSupported && e.push(o)
- }
- return e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.addPipeline = function(e) {
- this._renderPipelines[e._name] = e
- }
- ,
- a.prototype.attachCamerasToRenderPipeline = function(e, i, o) {
- o === void 0 && (o = !1);
- var s = this._renderPipelines[e];
- !s || s._attachCameras(i, o)
- }
- ,
- a.prototype.detachCamerasFromRenderPipeline = function(e, i) {
- var o = this._renderPipelines[e];
- !o || o._detachCameras(i)
- }
- ,
- a.prototype.enableEffectInPipeline = function(e, i, o) {
- var s = this._renderPipelines[e];
- !s || s._enableEffect(i, o)
- }
- ,
- a.prototype.disableEffectInPipeline = function(e, i, o) {
- var s = this._renderPipelines[e];
- !s || s._disableEffect(i, o)
- }
- ,
- a.prototype.update = function() {
- for (var e in this._renderPipelines)
- if (this._renderPipelines.hasOwnProperty(e)) {
- var i = this._renderPipelines[e];
- i.isSupported ? i._update() : (i.dispose(),
- delete this._renderPipelines[e])
- }
- }
- ,
- a.prototype._rebuild = function() {
- for (var e in this._renderPipelines)
- if (this._renderPipelines.hasOwnProperty(e)) {
- var i = this._renderPipelines[e];
- i._rebuild()
- }
- }
- ,
- a.prototype.dispose = function() {
- for (var e in this._renderPipelines)
- if (this._renderPipelines.hasOwnProperty(e)) {
- var i = this._renderPipelines[e];
- i.dispose()
- }
- }
- ,
- a
- }();
- Object.defineProperty(Scene.prototype, "postProcessRenderPipelineManager", {
- get: function() {
- if (!this._postProcessRenderPipelineManager) {
- var a = this._getComponent(SceneComponentConstants.NAME_POSTPROCESSRENDERPIPELINEMANAGER);
- a || (a = new PostProcessRenderPipelineManagerSceneComponent(this),
- this._addComponent(a)),
- this._postProcessRenderPipelineManager = new PostProcessRenderPipelineManager
- }
- return this._postProcessRenderPipelineManager
- },
- enumerable: !0,
- configurable: !0
- });
- var PostProcessRenderPipelineManagerSceneComponent = function() {
- function a(e) {
- this.name = SceneComponentConstants.NAME_POSTPROCESSRENDERPIPELINEMANAGER,
- this.scene = e
- }
- return a.prototype.register = function() {
- this.scene._gatherRenderTargetsStage.registerStep(SceneComponentConstants.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER, this, this._gatherRenderTargets)
- }
- ,
- a.prototype.rebuild = function() {
- this.scene._postProcessRenderPipelineManager && this.scene._postProcessRenderPipelineManager._rebuild()
- }
- ,
- a.prototype.dispose = function() {
- this.scene._postProcessRenderPipelineManager && this.scene._postProcessRenderPipelineManager.dispose()
- }
- ,
- a.prototype._gatherRenderTargets = function() {
- this.scene._postProcessRenderPipelineManager && this.scene._postProcessRenderPipelineManager.update()
- }
- ,
- a
- }()
- , DefaultRenderingPipeline = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d) {
- i === void 0 && (i = ""),
- o === void 0 && (o = !0),
- s === void 0 && (s = EngineStore.LastCreatedScene),
- d === void 0 && (d = !0);
- var _ = a.call(this, s.getEngine(), i) || this;
- _._camerasToBeAttached = [],
- _.SharpenPostProcessId = "SharpenPostProcessEffect",
- _.ImageProcessingPostProcessId = "ImageProcessingPostProcessEffect",
- _.FxaaPostProcessId = "FxaaPostProcessEffect",
- _.ChromaticAberrationPostProcessId = "ChromaticAberrationPostProcessEffect",
- _.GrainPostProcessId = "GrainPostProcessEffect",
- _._glowLayer = null,
- _.animations = [],
- _._imageProcessingConfigurationObserver = null,
- _._sharpenEnabled = !1,
- _._bloomEnabled = !1,
- _._depthOfFieldEnabled = !1,
- _._depthOfFieldBlurLevel = DepthOfFieldEffectBlurLevel.Low,
- _._fxaaEnabled = !1,
- _._imageProcessingEnabled = !0,
- _._bloomScale = .5,
- _._chromaticAberrationEnabled = !1,
- _._grainEnabled = !1,
- _._buildAllowed = !0,
- _.onBuildObservable = new Observable,
- _._resizeObserver = null,
- _._hardwareScaleLevel = 1,
- _._bloomKernel = 64,
- _._bloomWeight = .15,
- _._bloomThreshold = .9,
- _._samples = 1,
- _._hasCleared = !1,
- _._prevPostProcess = null,
- _._prevPrevPostProcess = null,
- _._depthOfFieldSceneObserver = null,
- _._cameras = c || s.cameras,
- _._cameras = _._cameras.slice(),
- _._camerasToBeAttached = _._cameras.slice(),
- _._buildAllowed = d,
- _._scene = s;
- var b = _._scene.getEngine().getCaps();
- _._hdr = o && (b.textureHalfFloatRender || b.textureFloatRender),
- _._hdr ? b.textureHalfFloatRender ? _._defaultPipelineTextureType = 2 : b.textureFloatRender && (_._defaultPipelineTextureType = 1) : _._defaultPipelineTextureType = 0,
- s.postProcessRenderPipelineManager.addPipeline(_);
- var k = _._scene.getEngine();
- return _.sharpen = new SharpenPostProcess("sharpen",1,null,Texture.BILINEAR_SAMPLINGMODE,k,!1,_._defaultPipelineTextureType,!0),
- _._sharpenEffect = new PostProcessRenderEffect(k,_.SharpenPostProcessId,function() {
- return _.sharpen
- }
- ,!0),
- _.depthOfField = new DepthOfFieldEffect(_._scene,null,_._depthOfFieldBlurLevel,_._defaultPipelineTextureType,!0),
- _.bloom = new BloomEffect(_._scene,_._bloomScale,_._bloomWeight,_.bloomKernel,_._defaultPipelineTextureType,!0),
- _.chromaticAberration = new ChromaticAberrationPostProcess("ChromaticAberration",k.getRenderWidth(),k.getRenderHeight(),1,null,Texture.BILINEAR_SAMPLINGMODE,k,!1,_._defaultPipelineTextureType,!0),
- _._chromaticAberrationEffect = new PostProcessRenderEffect(k,_.ChromaticAberrationPostProcessId,function() {
- return _.chromaticAberration
- }
- ,!0),
- _.grain = new GrainPostProcess("Grain",1,null,Texture.BILINEAR_SAMPLINGMODE,k,!1,_._defaultPipelineTextureType,!0),
- _._grainEffect = new PostProcessRenderEffect(k,_.GrainPostProcessId,function() {
- return _.grain
- }
- ,!0),
- _._resizeObserver = k.onResizeObservable.add(function() {
- _._hardwareScaleLevel = k.getHardwareScalingLevel(),
- _.bloomKernel = _.bloomKernel
- }),
- _._imageProcessingConfigurationObserver = _._scene.imageProcessingConfiguration.onUpdateParameters.add(function() {
- _.bloom._downscale._exposure = _._scene.imageProcessingConfiguration.exposure,
- _.imageProcessingEnabled !== _._scene.imageProcessingConfiguration.isEnabled && (_._imageProcessingEnabled = _._scene.imageProcessingConfiguration.isEnabled,
- _._buildPipeline())
- }),
- _._buildPipeline(),
- _
- }
- return Object.defineProperty(e.prototype, "scene", {
- get: function() {
- return this._scene
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "sharpenEnabled", {
- get: function() {
- return this._sharpenEnabled
- },
- set: function(i) {
- this._sharpenEnabled !== i && (this._sharpenEnabled = i,
- this._buildPipeline())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "bloomKernel", {
- get: function() {
- return this._bloomKernel
- },
- set: function(i) {
- this._bloomKernel = i,
- this.bloom.kernel = i / this._hardwareScaleLevel
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "bloomWeight", {
- get: function() {
- return this._bloomWeight
- },
- set: function(i) {
- this._bloomWeight !== i && (this.bloom.weight = i,
- this._bloomWeight = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "bloomThreshold", {
- get: function() {
- return this._bloomThreshold
- },
- set: function(i) {
- this._bloomThreshold !== i && (this.bloom.threshold = i,
- this._bloomThreshold = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "bloomScale", {
- get: function() {
- return this._bloomScale
- },
- set: function(i) {
- this._bloomScale !== i && (this._bloomScale = i,
- this._rebuildBloom(),
- this._buildPipeline())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "bloomEnabled", {
- get: function() {
- return this._bloomEnabled
- },
- set: function(i) {
- this._bloomEnabled !== i && (this._bloomEnabled = i,
- this._buildPipeline())
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._rebuildBloom = function() {
- var i = this.bloom;
- this.bloom = new BloomEffect(this._scene,this.bloomScale,this._bloomWeight,this.bloomKernel,this._defaultPipelineTextureType,!1),
- this.bloom.threshold = i.threshold;
- for (var o = 0; o < this._cameras.length; o++)
- i.disposeEffects(this._cameras[o])
- }
- ,
- Object.defineProperty(e.prototype, "depthOfFieldEnabled", {
- get: function() {
- return this._depthOfFieldEnabled
- },
- set: function(i) {
- this._depthOfFieldEnabled !== i && (this._depthOfFieldEnabled = i,
- this._buildPipeline())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "depthOfFieldBlurLevel", {
- get: function() {
- return this._depthOfFieldBlurLevel
- },
- set: function(i) {
- if (this._depthOfFieldBlurLevel !== i) {
- this._depthOfFieldBlurLevel = i;
- var o = this.depthOfField;
- this.depthOfField = new DepthOfFieldEffect(this._scene,null,this._depthOfFieldBlurLevel,this._defaultPipelineTextureType,!1),
- this.depthOfField.focalLength = o.focalLength,
- this.depthOfField.focusDistance = o.focusDistance,
- this.depthOfField.fStop = o.fStop,
- this.depthOfField.lensSize = o.lensSize;
- for (var s = 0; s < this._cameras.length; s++)
- o.disposeEffects(this._cameras[s]);
- this._buildPipeline()
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "fxaaEnabled", {
- get: function() {
- return this._fxaaEnabled
- },
- set: function(i) {
- this._fxaaEnabled !== i && (this._fxaaEnabled = i,
- this._buildPipeline())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "samples", {
- get: function() {
- return this._samples
- },
- set: function(i) {
- this._samples !== i && (this._samples = i,
- this._buildPipeline())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "imageProcessingEnabled", {
- get: function() {
- return this._imageProcessingEnabled
- },
- set: function(i) {
- this._imageProcessingEnabled !== i && (this._scene.imageProcessingConfiguration.isEnabled = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "glowLayerEnabled", {
- get: function() {
- return this._glowLayer != null
- },
- set: function(i) {
- i && !this._glowLayer ? this._glowLayer = new GlowLayer("",this._scene) : !i && this._glowLayer && (this._glowLayer.dispose(),
- this._glowLayer = null)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "glowLayer", {
- get: function() {
- return this._glowLayer
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "chromaticAberrationEnabled", {
- get: function() {
- return this._chromaticAberrationEnabled
- },
- set: function(i) {
- this._chromaticAberrationEnabled !== i && (this._chromaticAberrationEnabled = i,
- this._buildPipeline())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "grainEnabled", {
- get: function() {
- return this._grainEnabled
- },
- set: function(i) {
- this._grainEnabled !== i && (this._grainEnabled = i,
- this._buildPipeline())
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getClassName = function() {
- return "DefaultRenderingPipeline"
- }
- ,
- e.prototype.prepare = function() {
- var i = this._buildAllowed;
- this._buildAllowed = !0,
- this._buildPipeline(),
- this._buildAllowed = i
- }
- ,
- e.prototype._setAutoClearAndTextureSharing = function(i, o) {
- o === void 0 && (o = !1),
- this._hasCleared ? i.autoClear = !1 : (i.autoClear = !0,
- this._scene.autoClear = !1,
- this._hasCleared = !0),
- o || (this._prevPrevPostProcess ? i.shareOutputWith(this._prevPrevPostProcess) : i.useOwnOutput(),
- this._prevPostProcess && (this._prevPrevPostProcess = this._prevPostProcess),
- this._prevPostProcess = i)
- }
- ,
- e.prototype._buildPipeline = function() {
- var i = this;
- if (!!this._buildAllowed) {
- this._scene.autoClear = !0;
- var o = this._scene.getEngine();
- if (this._disposePostProcesses(),
- this._cameras !== null && (this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras),
- this._cameras = this._camerasToBeAttached.slice()),
- this._reset(),
- this._prevPostProcess = null,
- this._prevPrevPostProcess = null,
- this._hasCleared = !1,
- this.depthOfFieldEnabled) {
- if (this._cameras.length > 1) {
- for (var s = 0, c = this._cameras; s < c.length; s++) {
- var d = c[s]
- , _ = this._scene.enableDepthRenderer(d);
- _.useOnlyInActiveCamera = !0
- }
- this._depthOfFieldSceneObserver = this._scene.onAfterRenderTargetsRenderObservable.add(function(b) {
- i._cameras.indexOf(b.activeCamera) > -1 && (i.depthOfField.depthTexture = b.enableDepthRenderer(b.activeCamera).getDepthMap())
- })
- } else {
- this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
- var _ = this._scene.enableDepthRenderer(this._cameras[0]);
- this.depthOfField.depthTexture = _.getDepthMap()
- }
- this.depthOfField._isReady() || this.depthOfField._updateEffects(),
- this.addEffect(this.depthOfField),
- this._setAutoClearAndTextureSharing(this.depthOfField._effects[0], !0)
- } else
- this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
- this.bloomEnabled && (this.bloom._isReady() || this.bloom._updateEffects(),
- this.addEffect(this.bloom),
- this._setAutoClearAndTextureSharing(this.bloom._effects[0], !0)),
- this._imageProcessingEnabled && (this.imageProcessing = new ImageProcessingPostProcess("imageProcessing",1,null,Texture.BILINEAR_SAMPLINGMODE,o,!1,this._defaultPipelineTextureType),
- this._hdr ? (this.addEffect(new PostProcessRenderEffect(o,this.ImageProcessingPostProcessId,function() {
- return i.imageProcessing
- }
- ,!0)),
- this._setAutoClearAndTextureSharing(this.imageProcessing)) : this._scene.imageProcessingConfiguration.applyByPostProcess = !1,
- (!this.cameras || this.cameras.length === 0) && (this._scene.imageProcessingConfiguration.applyByPostProcess = !1),
- this.imageProcessing.getEffect() || this.imageProcessing._updateParameters()),
- this.sharpenEnabled && (this.sharpen.isReady() || this.sharpen.updateEffect(),
- this.addEffect(this._sharpenEffect),
- this._setAutoClearAndTextureSharing(this.sharpen)),
- this.grainEnabled && (this.grain.isReady() || this.grain.updateEffect(),
- this.addEffect(this._grainEffect),
- this._setAutoClearAndTextureSharing(this.grain)),
- this.chromaticAberrationEnabled && (this.chromaticAberration.isReady() || this.chromaticAberration.updateEffect(),
- this.addEffect(this._chromaticAberrationEffect),
- this._setAutoClearAndTextureSharing(this.chromaticAberration)),
- this.fxaaEnabled && (this.fxaa = new FxaaPostProcess("fxaa",1,null,Texture.BILINEAR_SAMPLINGMODE,o,!1,this._defaultPipelineTextureType),
- this.addEffect(new PostProcessRenderEffect(o,this.FxaaPostProcessId,function() {
- return i.fxaa
- }
- ,!0)),
- this._setAutoClearAndTextureSharing(this.fxaa, !0)),
- this._cameras !== null && this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras),
- this._scene.activeCameras && this._scene.activeCameras.length > 1 && (this._scene.autoClear = !0),
- !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"),
- this.onBuildObservable.notifyObservers(this)
- }
- }
- ,
- e.prototype._disposePostProcesses = function(i) {
- i === void 0 && (i = !1);
- for (var o = 0; o < this._cameras.length; o++) {
- var s = this._cameras[o];
- this.imageProcessing && this.imageProcessing.dispose(s),
- this.fxaa && this.fxaa.dispose(s),
- i && (this.sharpen && this.sharpen.dispose(s),
- this.depthOfField && (this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver),
- this.depthOfField.disposeEffects(s)),
- this.bloom && this.bloom.disposeEffects(s),
- this.chromaticAberration && this.chromaticAberration.dispose(s),
- this.grain && this.grain.dispose(s),
- this._glowLayer && this._glowLayer.dispose())
- }
- this.imageProcessing = null,
- this.fxaa = null,
- i && (this.sharpen = null,
- this._sharpenEffect = null,
- this.depthOfField = null,
- this.bloom = null,
- this.chromaticAberration = null,
- this._chromaticAberrationEffect = null,
- this.grain = null,
- this._grainEffect = null,
- this._glowLayer = null)
- }
- ,
- e.prototype.addCamera = function(i) {
- this._camerasToBeAttached.push(i),
- this._buildPipeline()
- }
- ,
- e.prototype.removeCamera = function(i) {
- var o = this._camerasToBeAttached.indexOf(i);
- this._camerasToBeAttached.splice(o, 1),
- this._buildPipeline()
- }
- ,
- e.prototype.dispose = function() {
- this.onBuildObservable.clear(),
- this._disposePostProcesses(!0),
- this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras),
- this._scene.autoClear = !0,
- this._resizeObserver && (this._scene.getEngine().onResizeObservable.remove(this._resizeObserver),
- this._resizeObserver = null),
- this._scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigurationObserver),
- a.prototype.dispose.call(this)
- }
- ,
- e.prototype.serialize = function() {
- var i = SerializationHelper.Serialize(this);
- return i.customType = "DefaultRenderingPipeline",
- i
- }
- ,
- e.Parse = function(i, o, s) {
- return SerializationHelper.Parse(function() {
- return new e(i._name,i._name._hdr,o)
- }, i, o, s)
- }
- ,
- __decorate([serialize()], e.prototype, "sharpenEnabled", null),
- __decorate([serialize()], e.prototype, "bloomKernel", null),
- __decorate([serialize()], e.prototype, "_bloomWeight", void 0),
- __decorate([serialize()], e.prototype, "_bloomThreshold", void 0),
- __decorate([serialize()], e.prototype, "_hdr", void 0),
- __decorate([serialize()], e.prototype, "bloomWeight", null),
- __decorate([serialize()], e.prototype, "bloomThreshold", null),
- __decorate([serialize()], e.prototype, "bloomScale", null),
- __decorate([serialize()], e.prototype, "bloomEnabled", null),
- __decorate([serialize()], e.prototype, "depthOfFieldEnabled", null),
- __decorate([serialize()], e.prototype, "depthOfFieldBlurLevel", null),
- __decorate([serialize()], e.prototype, "fxaaEnabled", null),
- __decorate([serialize()], e.prototype, "samples", null),
- __decorate([serialize()], e.prototype, "imageProcessingEnabled", null),
- __decorate([serialize()], e.prototype, "glowLayerEnabled", null),
- __decorate([serialize()], e.prototype, "chromaticAberrationEnabled", null),
- __decorate([serialize()], e.prototype, "grainEnabled", null),
- e
- }(PostProcessRenderPipeline);
- RegisterClass("BABYLON.DefaultRenderingPipeline", DefaultRenderingPipeline);
- var name$o = "imageProcessingCompatibility"
- , shader$o = `#ifdef IMAGEPROCESSINGPOSTPROCESS
- gl_FragColor.rgb=pow(gl_FragColor.rgb,vec3(2.2));
- #endif`;
- ShaderStore.IncludesShadersStore[name$o] = shader$o;
- var name$n = "gridPixelShader"
- , shader$n = `#extension GL_OES_standard_derivatives : enable
- #define SQRT2 1.41421356
- #define PI 3.14159
- precision highp float;
- uniform float visibility;
- uniform vec3 mainColor;
- uniform vec3 lineColor;
- uniform vec4 gridControl;
- uniform vec3 gridOffset;
- varying vec3 vPosition;
- varying vec3 vNormal;
- #include<fogFragmentDeclaration>
- #ifdef OPACITY
- varying vec2 vOpacityUV;
- uniform sampler2D opacitySampler;
- uniform vec2 vOpacityInfos;
- #endif
- float getDynamicVisibility(float position) {
- float majorGridFrequency=gridControl.y;
- if (floor(position+0.5) == floor(position/majorGridFrequency+0.5)*majorGridFrequency)
- {
- return 1.0;
- }
- return gridControl.z;
- }
- float getAnisotropicAttenuation(float differentialLength) {
- const float maxNumberOfLines=10.0;
- return clamp(1.0/(differentialLength+1.0)-1.0/maxNumberOfLines,0.0,1.0);
- }
- float isPointOnLine(float position,float differentialLength) {
- float fractionPartOfPosition=position-floor(position+0.5);
- fractionPartOfPosition/=differentialLength;
- fractionPartOfPosition=clamp(fractionPartOfPosition,-1.,1.);
- float result=0.5+0.5*cos(fractionPartOfPosition*PI);
- return result;
- }
- float contributionOnAxis(float position) {
- float differentialLength=length(vec2(dFdx(position),dFdy(position)));
- differentialLength*=SQRT2;
- float result=isPointOnLine(position,differentialLength);
- float dynamicVisibility=getDynamicVisibility(position);
- result*=dynamicVisibility;
- float anisotropicAttenuation=getAnisotropicAttenuation(differentialLength);
- result*=anisotropicAttenuation;
- return result;
- }
- float normalImpactOnAxis(float x) {
- float normalImpact=clamp(1.0-3.0*abs(x*x*x),0.0,1.0);
- return normalImpact;
- }
- void main(void) {
- float gridRatio=gridControl.x;
- vec3 gridPos=(vPosition+gridOffset.xyz)/gridRatio;
- float x=contributionOnAxis(gridPos.x);
- float y=contributionOnAxis(gridPos.y);
- float z=contributionOnAxis(gridPos.z);
- vec3 normal=normalize(vNormal);
- x*=normalImpactOnAxis(normal.x);
- y*=normalImpactOnAxis(normal.y);
- z*=normalImpactOnAxis(normal.z);
- #ifdef MAX_LINE
- float grid=clamp(max(max(x,y),z),0.,1.);
- #else
- float grid=clamp(x+y+z,0.,1.);
- #endif
- vec3 color=mix(mainColor,lineColor,grid);
- #ifdef FOG
- #include<fogFragment>
- #endif
- float opacity=1.0;
- #ifdef TRANSPARENT
- opacity=clamp(grid,0.08,gridControl.w*grid);
- #endif
- #ifdef OPACITY
- opacity*=texture2D(opacitySampler,vOpacityUV).a;
- #endif
- gl_FragColor=vec4(color.rgb,opacity*visibility);
- #ifdef TRANSPARENT
- #ifdef PREMULTIPLYALPHA
- gl_FragColor.rgb*=opacity;
- #endif
- #else
- #endif
- #include<imageProcessingCompatibility>
- }
- `;
- ShaderStore.ShadersStore[name$n] = shader$n;
- var name$m = "gridVertexShader"
- , shader$m = `precision highp float;
- attribute vec3 position;
- attribute vec3 normal;
- #ifdef UV1
- attribute vec2 uv;
- #endif
- #ifdef UV2
- attribute vec2 uv2;
- #endif
- #include<instancesDeclaration>
- uniform mat4 projection;
- uniform mat4 view;
- varying vec3 vPosition;
- varying vec3 vNormal;
- #include<fogVertexDeclaration>
- #ifdef OPACITY
- varying vec2 vOpacityUV;
- uniform mat4 opacityMatrix;
- uniform vec2 vOpacityInfos;
- #endif
- void main(void) {
- #include<instancesVertex>
- vec4 worldPos=finalWorld*vec4(position,1.0);
- #include<fogVertex>
- vec4 cameraSpacePosition=view*worldPos;
- gl_Position=projection*cameraSpacePosition;
- #ifdef OPACITY
- #ifndef UV1
- vec2 uv=vec2(0.,0.);
- #endif
- #ifndef UV2
- vec2 uv2=vec2(0.,0.);
- #endif
- if (vOpacityInfos.x == 0.)
- {
- vOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));
- }
- else
- {
- vOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));
- }
- #endif
- vPosition=position;
- vNormal=normal;
- }`;
- ShaderStore.ShadersStore[name$m] = shader$m;
- var GridMaterialDefines = function(a) {
- __extends(e, a);
- function e() {
- var i = a.call(this) || this;
- return i.OPACITY = !1,
- i.TRANSPARENT = !1,
- i.FOG = !1,
- i.PREMULTIPLYALPHA = !1,
- i.MAX_LINE = !1,
- i.UV1 = !1,
- i.UV2 = !1,
- i.INSTANCES = !1,
- i.THIN_INSTANCES = !1,
- i.IMAGEPROCESSINGPOSTPROCESS = !1,
- i.SKIPFINALCOLORCLAMP = !1,
- i.rebuild(),
- i
- }
- return e
- }(MaterialDefines)
- , GridMaterial = function(a) {
- __extends(e, a);
- function e(i, o) {
- var s = a.call(this, i, o) || this;
- return s.mainColor = Color3.Black(),
- s.lineColor = Color3.Teal(),
- s.gridRatio = 1,
- s.gridOffset = Vector3.Zero(),
- s.majorUnitFrequency = 10,
- s.minorUnitVisibility = .33,
- s.opacity = 1,
- s.preMultiplyAlpha = !1,
- s.useMaxLine = !1,
- s._gridControl = new Vector4(s.gridRatio,s.majorUnitFrequency,s.minorUnitVisibility,s.opacity),
- s
- }
- return e.prototype.needAlphaBlending = function() {
- return this.opacity < 1 || this._opacityTexture && this._opacityTexture.isReady()
- }
- ,
- e.prototype.needAlphaBlendingForMesh = function(i) {
- return i.visibility < 1 || this.needAlphaBlending()
- }
- ,
- e.prototype.isReadyForSubMesh = function(i, o, s) {
- if (this.isFrozen && o.effect && o.effect._wasPreviouslyReady)
- return !0;
- o.materialDefines || (o.materialDefines = new GridMaterialDefines);
- var c = o.materialDefines
- , d = this.getScene();
- if (this._isReadyForSubMesh(o))
- return !0;
- if (c.TRANSPARENT !== this.opacity < 1 && (c.TRANSPARENT = !c.TRANSPARENT,
- c.markAsUnprocessed()),
- c.PREMULTIPLYALPHA != this.preMultiplyAlpha && (c.PREMULTIPLYALPHA = !c.PREMULTIPLYALPHA,
- c.markAsUnprocessed()),
- c.MAX_LINE !== this.useMaxLine && (c.MAX_LINE = !c.MAX_LINE,
- c.markAsUnprocessed()),
- c._areTexturesDirty && (c._needUVs = !1,
- d.texturesEnabled && this._opacityTexture && MaterialFlags.OpacityTextureEnabled))
- if (this._opacityTexture.isReady())
- c._needUVs = !0,
- c.OPACITY = !0;
- else
- return !1;
- if (MaterialHelper.PrepareDefinesForMisc(i, d, !1, !1, this.fogEnabled, !1, c),
- MaterialHelper.PrepareDefinesForFrameBoundValues(d, d.getEngine(), c, !!s),
- c.isDirty) {
- c.markAsProcessed(),
- d.resetCachedMaterial(),
- MaterialHelper.PrepareDefinesForAttributes(i, c, !1, !1);
- var _ = [VertexBuffer.PositionKind, VertexBuffer.NormalKind];
- c.UV1 && _.push(VertexBuffer.UVKind),
- c.UV2 && _.push(VertexBuffer.UV2Kind),
- c.IMAGEPROCESSINGPOSTPROCESS = d.imageProcessingConfiguration.applyByPostProcess,
- MaterialHelper.PrepareAttributesForInstances(_, c);
- var b = c.toString();
- 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)
- }
- return !o.effect || !o.effect.isReady() ? !1 : (c._renderId = d.getRenderId(),
- o.effect._wasPreviouslyReady = !0,
- !0)
- }
- ,
- e.prototype.bindForSubMesh = function(i, o, s) {
- var c = this.getScene()
- , d = s.materialDefines;
- if (!!d) {
- var _ = s.effect;
- !_ || (this._activeEffect = _,
- this._activeEffect.setFloat("visibility", o.visibility),
- (!d.INSTANCES || d.THIN_INSTANCE) && this.bindOnlyWorldMatrix(i),
- this._activeEffect.setMatrix("view", c.getViewMatrix()),
- this._activeEffect.setMatrix("projection", c.getProjectionMatrix()),
- this._mustRebind(c, _) && (this._activeEffect.setColor3("mainColor", this.mainColor),
- this._activeEffect.setColor3("lineColor", this.lineColor),
- this._activeEffect.setVector3("gridOffset", this.gridOffset),
- this._gridControl.x = this.gridRatio,
- this._gridControl.y = Math.round(this.majorUnitFrequency),
- this._gridControl.z = this.minorUnitVisibility,
- this._gridControl.w = this.opacity,
- this._activeEffect.setVector4("gridControl", this._gridControl),
- this._opacityTexture && MaterialFlags.OpacityTextureEnabled && (this._activeEffect.setTexture("opacitySampler", this._opacityTexture),
- this._activeEffect.setFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level),
- this._activeEffect.setMatrix("opacityMatrix", this._opacityTexture.getTextureMatrix()))),
- MaterialHelper.BindFogParameters(c, o, this._activeEffect),
- this._afterBind(o, this._activeEffect))
- }
- }
- ,
- e.prototype.dispose = function(i) {
- a.prototype.dispose.call(this, i)
- }
- ,
- e.prototype.clone = function(i) {
- var o = this;
- return SerializationHelper.Clone(function() {
- return new e(i,o.getScene())
- }, this)
- }
- ,
- e.prototype.serialize = function() {
- var i = SerializationHelper.Serialize(this);
- return i.customType = "BABYLON.GridMaterial",
- i
- }
- ,
- e.prototype.getClassName = function() {
- return "GridMaterial"
- }
- ,
- e.Parse = function(i, o, s) {
- return SerializationHelper.Parse(function() {
- return new e(i.name,o)
- }, i, o, s)
- }
- ,
- __decorate([serializeAsColor3()], e.prototype, "mainColor", void 0),
- __decorate([serializeAsColor3()], e.prototype, "lineColor", void 0),
- __decorate([serialize()], e.prototype, "gridRatio", void 0),
- __decorate([serializeAsVector3()], e.prototype, "gridOffset", void 0),
- __decorate([serialize()], e.prototype, "majorUnitFrequency", void 0),
- __decorate([serialize()], e.prototype, "minorUnitVisibility", void 0),
- __decorate([serialize()], e.prototype, "opacity", void 0),
- __decorate([serialize()], e.prototype, "preMultiplyAlpha", void 0),
- __decorate([serialize()], e.prototype, "useMaxLine", void 0),
- __decorate([serializeAsTexture("opacityTexture")], e.prototype, "_opacityTexture", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "opacityTexture", void 0),
- e
- }(PushMaterial);
- RegisterClass("BABYLON.GridMaterial", GridMaterial);
- var SceneInstrumentation = function() {
- function a(e) {
- var i = this;
- this.scene = e,
- this._captureActiveMeshesEvaluationTime = !1,
- this._activeMeshesEvaluationTime = new PerfCounter,
- this._captureRenderTargetsRenderTime = !1,
- this._renderTargetsRenderTime = new PerfCounter,
- this._registerBeforeRenderTime = new PerfCounter,
- this._onBeforeRegisterBeforeRenderObserver = null,
- this._onAfterRegisterBeforeRenderObserver = null,
- this._RTT1Time = new PerfCounter,
- this._onBeforeRTT1Observer = null,
- this._onAfterRTT1Observer = null,
- this._registerAfterRenderTime = new PerfCounter,
- this._onBeforeRegisterAfterRenderObserver = null,
- this._onAfterRegisterAfterRenderObserver = null,
- this._captureFrameTime = !1,
- this._frameTime = new PerfCounter,
- this._captureRenderTime = !1,
- this._renderTime = new PerfCounter,
- this._captureInterFrameTime = !1,
- this._interFrameTime = new PerfCounter,
- this._captureParticlesRenderTime = !1,
- this._particlesRenderTime = new PerfCounter,
- this._captureSpritesRenderTime = !1,
- this._spritesRenderTime = new PerfCounter,
- this._capturePhysicsTime = !1,
- this._physicsTime = new PerfCounter,
- this._captureAnimationsTime = !1,
- this._animationsTime = new PerfCounter,
- this._captureCameraRenderTime = !1,
- this._cameraRenderTime = new PerfCounter,
- this._onBeforeActiveMeshesEvaluationObserver = null,
- this._onAfterActiveMeshesEvaluationObserver = null,
- this._onBeforeRenderTargetsRenderObserver = null,
- this._onAfterRenderTargetsRenderObserver = null,
- this._onAfterRenderObserver = null,
- this._onBeforeDrawPhaseObserver = null,
- this._onAfterDrawPhaseObserver = null,
- this._onBeforeAnimationsObserver = null,
- this._onBeforeParticlesRenderingObserver = null,
- this._onAfterParticlesRenderingObserver = null,
- this._onBeforeSpritesRenderingObserver = null,
- this._onAfterSpritesRenderingObserver = null,
- this._onBeforePhysicsObserver = null,
- this._onAfterPhysicsObserver = null,
- this._onAfterAnimationsObserver = null,
- this._onBeforeCameraRenderObserver = null,
- this._onAfterCameraRenderObserver = null,
- this._onBeforeAnimationsObserver = e.onBeforeAnimationsObservable.add(function() {
- i._captureActiveMeshesEvaluationTime && i._activeMeshesEvaluationTime.fetchNewFrame(),
- i._captureRenderTargetsRenderTime && i._renderTargetsRenderTime.fetchNewFrame(),
- i._captureFrameTime && (Tools.StartPerformanceCounter("Scene rendering"),
- i._frameTime.beginMonitoring()),
- i._captureInterFrameTime && i._interFrameTime.endMonitoring(),
- i._captureParticlesRenderTime && i._particlesRenderTime.fetchNewFrame(),
- i._captureSpritesRenderTime && i._spritesRenderTime.fetchNewFrame(),
- i._captureAnimationsTime && i._animationsTime.beginMonitoring(),
- i.scene.getEngine()._drawCalls.fetchNewFrame()
- }),
- this._onAfterRenderObserver = e.onAfterRenderObservable.add(function() {
- i._captureFrameTime && (Tools.EndPerformanceCounter("Scene rendering"),
- i._frameTime.endMonitoring()),
- i._captureRenderTime && i._renderTime.endMonitoring(!1),
- i._captureInterFrameTime && i._interFrameTime.beginMonitoring()
- }),
- this._onBeforeRegisterBeforeRenderObserver = e.onBeforeRunRegisterBeforeRenderObservable.add(function() {
- i._registerBeforeRenderTime.beginMonitoring()
- }),
- this._onAfterRegisterBeforeRenderObserver = e.onAfterRunRegisterBeforeRenderObservable.add(function() {
- i._registerBeforeRenderTime.endMonitoring()
- }),
- this._onBeforeRegisterAfterRenderObserver = e.onBeforeRunRegisterAfterRenderObservable.add(function() {
- i._registerAfterRenderTime.beginMonitoring()
- }),
- this._onAfterRegisterAfterRenderObserver = e.onAfterRunRegisterAfterRenderObservable.add(function() {
- i._registerAfterRenderTime.endMonitoring()
- }),
- this._onBeforeRTT1Observer = e.onBeforeRTT1Observable.add(function() {
- i._RTT1Time.beginMonitoring()
- }),
- this._onAfterRTT1Observer = e.onAfterRTT1Observable.add(function() {
- i._RTT1Time.endMonitoring()
- })
- }
- return Object.defineProperty(a.prototype, "activeMeshesEvaluationTimeCounter", {
- get: function() {
- return this._activeMeshesEvaluationTime
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "captureActiveMeshesEvaluationTime", {
- get: function() {
- return this._captureActiveMeshesEvaluationTime
- },
- set: function(e) {
- var i = this;
- e !== this._captureActiveMeshesEvaluationTime && (this._captureActiveMeshesEvaluationTime = e,
- e ? (this._onBeforeActiveMeshesEvaluationObserver = this.scene.onBeforeActiveMeshesEvaluationObservable.add(function() {
- Tools.StartPerformanceCounter("Active meshes evaluation"),
- i._activeMeshesEvaluationTime.beginMonitoring()
- }),
- this._onAfterActiveMeshesEvaluationObserver = this.scene.onAfterActiveMeshesEvaluationObservable.add(function() {
- Tools.EndPerformanceCounter("Active meshes evaluation"),
- i._activeMeshesEvaluationTime.endMonitoring()
- })) : (this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver),
- this._onBeforeActiveMeshesEvaluationObserver = null,
- this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver),
- this._onAfterActiveMeshesEvaluationObserver = null))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "renderTargetsRenderTimeCounter", {
- get: function() {
- return this._renderTargetsRenderTime
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "registerBeforeTimeCounter", {
- get: function() {
- return this._registerBeforeRenderTime
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "getRTT1TimeCounter", {
- get: function() {
- return this._RTT1Time
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "registerAfterTimeCounter", {
- get: function() {
- return this._registerAfterRenderTime
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "captureRenderTargetsRenderTime", {
- get: function() {
- return this._captureRenderTargetsRenderTime
- },
- set: function(e) {
- var i = this;
- e !== this._captureRenderTargetsRenderTime && (this._captureRenderTargetsRenderTime = e,
- e ? (this._onBeforeRenderTargetsRenderObserver = this.scene.onBeforeRenderTargetsRenderObservable.add(function() {
- Tools.StartPerformanceCounter("Render targets rendering"),
- i._renderTargetsRenderTime.beginMonitoring()
- }),
- this._onAfterRenderTargetsRenderObserver = this.scene.onAfterRenderTargetsRenderObservable.add(function() {
- Tools.EndPerformanceCounter("Render targets rendering"),
- i._renderTargetsRenderTime.endMonitoring(!1)
- })) : (this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver),
- this._onBeforeRenderTargetsRenderObserver = null,
- this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver),
- this._onAfterRenderTargetsRenderObserver = null))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "particlesRenderTimeCounter", {
- get: function() {
- return this._particlesRenderTime
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "captureParticlesRenderTime", {
- get: function() {
- return this._captureParticlesRenderTime
- },
- set: function(e) {
- var i = this;
- e !== this._captureParticlesRenderTime && (this._captureParticlesRenderTime = e,
- e ? (this._onBeforeParticlesRenderingObserver = this.scene.onBeforeParticlesRenderingObservable.add(function() {
- Tools.StartPerformanceCounter("Particles"),
- i._particlesRenderTime.beginMonitoring()
- }),
- this._onAfterParticlesRenderingObserver = this.scene.onAfterParticlesRenderingObservable.add(function() {
- Tools.EndPerformanceCounter("Particles"),
- i._particlesRenderTime.endMonitoring(!1)
- })) : (this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver),
- this._onBeforeParticlesRenderingObserver = null,
- this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver),
- this._onAfterParticlesRenderingObserver = null))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "spritesRenderTimeCounter", {
- get: function() {
- return this._spritesRenderTime
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "captureSpritesRenderTime", {
- get: function() {
- return this._captureSpritesRenderTime
- },
- set: function(e) {
- var i = this;
- e !== this._captureSpritesRenderTime && (this._captureSpritesRenderTime = e,
- this.scene.spriteManagers && (e ? (this._onBeforeSpritesRenderingObserver = this.scene.onBeforeSpritesRenderingObservable.add(function() {
- Tools.StartPerformanceCounter("Sprites"),
- i._spritesRenderTime.beginMonitoring()
- }),
- this._onAfterSpritesRenderingObserver = this.scene.onAfterSpritesRenderingObservable.add(function() {
- Tools.EndPerformanceCounter("Sprites"),
- i._spritesRenderTime.endMonitoring(!1)
- })) : (this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver),
- this._onBeforeSpritesRenderingObserver = null,
- this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver),
- this._onAfterSpritesRenderingObserver = null)))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "physicsTimeCounter", {
- get: function() {
- return this._physicsTime
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "capturePhysicsTime", {
- get: function() {
- return this._capturePhysicsTime
- },
- set: function(e) {
- var i = this;
- e !== this._capturePhysicsTime && (!this.scene.onBeforePhysicsObservable || (this._capturePhysicsTime = e,
- e ? (this._onBeforePhysicsObserver = this.scene.onBeforePhysicsObservable.add(function() {
- Tools.StartPerformanceCounter("Physics"),
- i._physicsTime.beginMonitoring()
- }),
- this._onAfterPhysicsObserver = this.scene.onAfterPhysicsObservable.add(function() {
- Tools.EndPerformanceCounter("Physics"),
- i._physicsTime.endMonitoring()
- })) : (this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver),
- this._onBeforePhysicsObserver = null,
- this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver),
- this._onAfterPhysicsObserver = null)))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "animationsTimeCounter", {
- get: function() {
- return this._animationsTime
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "captureAnimationsTime", {
- get: function() {
- return this._captureAnimationsTime
- },
- set: function(e) {
- var i = this;
- e !== this._captureAnimationsTime && (this._captureAnimationsTime = e,
- e ? this._onAfterAnimationsObserver = this.scene.onAfterAnimationsObservable.add(function() {
- i._animationsTime.endMonitoring()
- }) : (this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver),
- this._onAfterAnimationsObserver = null))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "frameTimeCounter", {
- get: function() {
- return this._frameTime
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "captureFrameTime", {
- get: function() {
- return this._captureFrameTime
- },
- set: function(e) {
- this._captureFrameTime = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "interFrameTimeCounter", {
- get: function() {
- return this._interFrameTime
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "captureInterFrameTime", {
- get: function() {
- return this._captureInterFrameTime
- },
- set: function(e) {
- this._captureInterFrameTime = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "renderTimeCounter", {
- get: function() {
- return this._renderTime
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "captureRenderTime", {
- get: function() {
- return this._captureRenderTime
- },
- set: function(e) {
- var i = this;
- e !== this._captureRenderTime && (this._captureRenderTime = e,
- e ? (this._onBeforeDrawPhaseObserver = this.scene.onBeforeDrawPhaseObservable.add(function() {
- i._renderTime.beginMonitoring(),
- Tools.StartPerformanceCounter("Main render")
- }),
- this._onAfterDrawPhaseObserver = this.scene.onAfterDrawPhaseObservable.add(function() {
- i._renderTime.endMonitoring(!1),
- Tools.EndPerformanceCounter("Main render")
- })) : (this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver),
- this._onBeforeDrawPhaseObserver = null,
- this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver),
- this._onAfterDrawPhaseObserver = null))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "cameraRenderTimeCounter", {
- get: function() {
- return this._cameraRenderTime
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "captureCameraRenderTime", {
- get: function() {
- return this._captureCameraRenderTime
- },
- set: function(e) {
- var i = this;
- e !== this._captureCameraRenderTime && (this._captureCameraRenderTime = e,
- e ? (this._onBeforeCameraRenderObserver = this.scene.onBeforeCameraRenderObservable.add(function(o) {
- i._cameraRenderTime.beginMonitoring(),
- Tools.StartPerformanceCounter("Rendering camera " + o.name)
- }),
- this._onAfterCameraRenderObserver = this.scene.onAfterCameraRenderObservable.add(function(o) {
- i._cameraRenderTime.endMonitoring(!1),
- Tools.EndPerformanceCounter("Rendering camera " + o.name)
- })) : (this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),
- this._onBeforeCameraRenderObserver = null,
- this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),
- this._onAfterCameraRenderObserver = null))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "drawCallsCounter", {
- get: function() {
- return this.scene.getEngine()._drawCalls
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.dispose = function() {
- this.scene.onBeforeRunRegisterBeforeRenderObservable.remove(this._onBeforeRegisterBeforeRenderObserver),
- this._onBeforeRegisterBeforeRenderObserver = null,
- this.scene.onAfterRunRegisterBeforeRenderObservable.remove(this._onAfterRegisterBeforeRenderObserver),
- this._onAfterRegisterBeforeRenderObserver = null,
- this.scene.onBeforeRunRegisterAfterRenderObservable.remove(this._onBeforeRegisterAfterRenderObserver),
- this._onBeforeRegisterAfterRenderObserver = null,
- this.scene.onAfterRunRegisterAfterRenderObservable.remove(this._onAfterRegisterAfterRenderObserver),
- this._onAfterRegisterAfterRenderObserver = null,
- this.scene.onBeforeRTT1Observable.remove(this._onBeforeRTT1Observer),
- this._onBeforeRTT1Observer = null,
- this.scene.onAfterRTT1Observable.remove(this._onAfterRTT1Observer),
- this._onAfterRTT1Observer = null,
- this.scene.onAfterRenderObservable.remove(this._onAfterRenderObserver),
- this._onAfterRenderObserver = null,
- this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver),
- this._onBeforeActiveMeshesEvaluationObserver = null,
- this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver),
- this._onAfterActiveMeshesEvaluationObserver = null,
- this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver),
- this._onBeforeRenderTargetsRenderObserver = null,
- this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver),
- this._onAfterRenderTargetsRenderObserver = null,
- this.scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver),
- this._onBeforeAnimationsObserver = null,
- this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver),
- this._onBeforeParticlesRenderingObserver = null,
- this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver),
- this._onAfterParticlesRenderingObserver = null,
- this._onBeforeSpritesRenderingObserver && (this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver),
- this._onBeforeSpritesRenderingObserver = null),
- this._onAfterSpritesRenderingObserver && (this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver),
- this._onAfterSpritesRenderingObserver = null),
- this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver),
- this._onBeforeDrawPhaseObserver = null,
- this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver),
- this._onAfterDrawPhaseObserver = null,
- this._onBeforePhysicsObserver && (this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver),
- this._onBeforePhysicsObserver = null),
- this._onAfterPhysicsObserver && (this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver),
- this._onAfterPhysicsObserver = null),
- this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver),
- this._onAfterAnimationsObserver = null,
- this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),
- this._onBeforeCameraRenderObserver = null,
- this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),
- this._onAfterCameraRenderObserver = null,
- this.scene = null
- }
- ,
- a
- }()
- , EngineInstrumentation = function() {
- function a(e) {
- this.engine = e,
- this._captureGPUFrameTime = !1,
- this._captureShaderCompilationTime = !1,
- this._shaderCompilationTime = new PerfCounter,
- this._onBeginFrameObserver = null,
- this._onEndFrameObserver = null,
- this._onBeforeShaderCompilationObserver = null,
- this._onAfterShaderCompilationObserver = null
- }
- return Object.defineProperty(a.prototype, "gpuFrameTimeCounter", {
- get: function() {
- return this.engine.getGPUFrameTimeCounter()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "captureGPUFrameTime", {
- get: function() {
- return this._captureGPUFrameTime
- },
- set: function(e) {
- e !== this._captureGPUFrameTime && (this._captureGPUFrameTime = e,
- this.engine.captureGPUFrameTime(e))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "shaderCompilationTimeCounter", {
- get: function() {
- return this._shaderCompilationTime
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "captureShaderCompilationTime", {
- get: function() {
- return this._captureShaderCompilationTime
- },
- set: function(e) {
- var i = this;
- e !== this._captureShaderCompilationTime && (this._captureShaderCompilationTime = e,
- e ? (this._onBeforeShaderCompilationObserver = this.engine.onBeforeShaderCompilationObservable.add(function() {
- i._shaderCompilationTime.fetchNewFrame(),
- i._shaderCompilationTime.beginMonitoring()
- }),
- this._onAfterShaderCompilationObserver = this.engine.onAfterShaderCompilationObservable.add(function() {
- i._shaderCompilationTime.endMonitoring()
- })) : (this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver),
- this._onBeforeShaderCompilationObserver = null,
- this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver),
- this._onAfterShaderCompilationObserver = null))
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.dispose = function() {
- this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver),
- this._onBeginFrameObserver = null,
- this.engine.onEndFrameObservable.remove(this._onEndFrameObserver),
- this._onEndFrameObserver = null,
- this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver),
- this._onBeforeShaderCompilationObserver = null,
- this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver),
- this._onAfterShaderCompilationObserver = null,
- this.engine = null
- }
- ,
- a
- }()
- , KeepAssets = function(a) {
- __extends(e, a);
- function e() {
- return a !== null && a.apply(this, arguments) || this
- }
- return e
- }(AbstractScene)
- , InstantiatedEntries = function() {
- function a() {
- this.rootNodes = [],
- this.skeletons = [],
- this.animationGroups = []
- }
- return a
- }()
- , AssetContainer = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this) || this;
- return o._wasAddedToScene = !1,
- o.scene = i,
- o.sounds = [],
- o.effectLayers = [],
- o.layers = [],
- o.lensFlareSystems = [],
- o.proceduralTextures = [],
- o.reflectionProbes = [],
- i.onDisposeObservable.add(function() {
- o._wasAddedToScene || o.dispose()
- }),
- o._onContextRestoredObserver = i.getEngine().onContextRestoredObservable.add(function() {
- for (var s = 0, c = o.geometries; s < c.length; s++) {
- var d = c[s];
- d._rebuild()
- }
- for (var _ = 0, b = o.meshes; _ < b.length; _++) {
- var k = b[_];
- k._rebuild()
- }
- for (var j = 0, $ = o.particleSystems; j < $.length; j++) {
- var _e = $[j];
- _e.rebuild()
- }
- for (var et = 0, tt = o.textures; et < tt.length; et++) {
- var rt = tt[et];
- rt._rebuild()
- }
- }),
- o
- }
- return e.prototype.instantiateModelsToScene = function(i, o, s) {
- var c = this;
- o === void 0 && (o = !1);
- var d = {}
- , _ = {}
- , b = new InstantiatedEntries
- , k = []
- , j = [];
- s || (s = {
- doNotInstantiate: !0
- });
- var $ = function(_e, et) {
- if (d[_e.uniqueId] = et.uniqueId,
- _[et.uniqueId] = et,
- i && (et.name = i(_e.name)),
- et instanceof Mesh) {
- var tt = et;
- if (tt.morphTargetManager) {
- var rt = _e.morphTargetManager;
- tt.morphTargetManager = rt.clone();
- for (var it = 0; it < rt.numTargets; it++) {
- var nt = rt.getTarget(it)
- , ot = tt.morphTargetManager.getTarget(it);
- d[nt.uniqueId] = ot.uniqueId,
- _[ot.uniqueId] = ot
- }
- }
- }
- };
- return this.transformNodes.forEach(function(_e) {
- if (!_e.parent) {
- var et = _e.instantiateHierarchy(null, s, function(tt, rt) {
- $(tt, rt)
- });
- et && b.rootNodes.push(et)
- }
- }),
- this.meshes.forEach(function(_e) {
- if (!_e.parent) {
- var et = _e.instantiateHierarchy(null, s, function(tt, rt) {
- if ($(tt, rt),
- rt.material) {
- var it = rt;
- if (it.material)
- if (o) {
- var nt = tt.material;
- if (j.indexOf(nt) === -1) {
- var ot = nt.clone(i ? i(nt.name) : "Clone of " + nt.name);
- if (j.push(nt),
- d[nt.uniqueId] = ot.uniqueId,
- _[ot.uniqueId] = ot,
- nt.getClassName() === "MultiMaterial") {
- for (var at = nt, st = 0, ut = at.subMaterials; st < ut.length; st++) {
- var ct = ut[st];
- !ct || (ot = ct.clone(i ? i(ct.name) : "Clone of " + ct.name),
- j.push(ct),
- d[ct.uniqueId] = ot.uniqueId,
- _[ot.uniqueId] = ot)
- }
- at.subMaterials = at.subMaterials.map(function(lt) {
- return lt && _[d[lt.uniqueId]]
- })
- }
- }
- it.getClassName() !== "InstancedMesh" && (it.material = _[d[nt.uniqueId]])
- } else
- 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)
- }
- });
- et && b.rootNodes.push(et)
- }
- }),
- this.skeletons.forEach(function(_e) {
- var et = _e.clone(i ? i(_e.name) : "Clone of " + _e.name);
- _e.overrideMesh && (et.overrideMesh = _[d[_e.overrideMesh.uniqueId]]);
- for (var tt = 0, rt = c.meshes; tt < rt.length; tt++) {
- var it = rt[tt];
- if (it.skeleton === _e && !it.isAnInstance) {
- var nt = _[d[it.uniqueId]];
- if (nt.isAnInstance || (nt.skeleton = et,
- k.indexOf(et) !== -1))
- continue;
- k.push(et);
- for (var ot = 0, at = et.bones; ot < at.length; ot++) {
- var st = at[ot];
- st._linkedTransformNode && (st._linkedTransformNode = _[d[st._linkedTransformNode.uniqueId]])
- }
- }
- }
- b.skeletons.push(et)
- }),
- this.animationGroups.forEach(function(_e) {
- var et = _e.clone(_e.name, function(tt) {
- var rt = _[d[tt.uniqueId]];
- return rt || tt
- });
- b.animationGroups.push(et)
- }),
- b
- }
- ,
- e.prototype.addAllToScene = function() {
- var i = this;
- this._wasAddedToScene = !0,
- this.cameras.forEach(function(d) {
- i.scene.addCamera(d)
- }),
- this.lights.forEach(function(d) {
- i.scene.addLight(d)
- }),
- this.meshes.forEach(function(d) {
- i.scene.addMesh(d)
- }),
- this.skeletons.forEach(function(d) {
- i.scene.addSkeleton(d)
- }),
- this.animations.forEach(function(d) {
- i.scene.addAnimation(d)
- }),
- this.animationGroups.forEach(function(d) {
- i.scene.addAnimationGroup(d)
- }),
- this.multiMaterials.forEach(function(d) {
- i.scene.addMultiMaterial(d)
- }),
- this.materials.forEach(function(d) {
- i.scene.addMaterial(d)
- }),
- this.morphTargetManagers.forEach(function(d) {
- i.scene.addMorphTargetManager(d)
- }),
- this.geometries.forEach(function(d) {
- i.scene.addGeometry(d)
- }),
- this.transformNodes.forEach(function(d) {
- i.scene.addTransformNode(d)
- }),
- this.actionManagers.forEach(function(d) {
- i.scene.addActionManager(d)
- }),
- this.textures.forEach(function(d) {
- i.scene.addTexture(d)
- }),
- this.reflectionProbes.forEach(function(d) {
- i.scene.addReflectionProbe(d)
- }),
- this.environmentTexture && (this.scene.environmentTexture = this.environmentTexture);
- for (var o = 0, s = this.scene._serializableComponents; o < s.length; o++) {
- var c = s[o];
- c.addFromContainer(this)
- }
- this.scene.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),
- this._onContextRestoredObserver = null
- }
- ,
- e.prototype.removeAllFromScene = function() {
- var i = this;
- this._wasAddedToScene = !1,
- this.cameras.forEach(function(d) {
- i.scene.removeCamera(d)
- }),
- this.lights.forEach(function(d) {
- i.scene.removeLight(d)
- }),
- this.meshes.forEach(function(d) {
- i.scene.removeMesh(d)
- }),
- this.skeletons.forEach(function(d) {
- i.scene.removeSkeleton(d)
- }),
- this.animations.forEach(function(d) {
- i.scene.removeAnimation(d)
- }),
- this.animationGroups.forEach(function(d) {
- i.scene.removeAnimationGroup(d)
- }),
- this.multiMaterials.forEach(function(d) {
- i.scene.removeMultiMaterial(d)
- }),
- this.materials.forEach(function(d) {
- i.scene.removeMaterial(d)
- }),
- this.morphTargetManagers.forEach(function(d) {
- i.scene.removeMorphTargetManager(d)
- }),
- this.geometries.forEach(function(d) {
- i.scene.removeGeometry(d)
- }),
- this.transformNodes.forEach(function(d) {
- i.scene.removeTransformNode(d)
- }),
- this.actionManagers.forEach(function(d) {
- i.scene.removeActionManager(d)
- }),
- this.textures.forEach(function(d) {
- i.scene.removeTexture(d)
- }),
- this.reflectionProbes.forEach(function(d) {
- i.scene.removeReflectionProbe(d)
- }),
- this.environmentTexture === this.scene.environmentTexture && (this.scene.environmentTexture = null);
- for (var o = 0, s = this.scene._serializableComponents; o < s.length; o++) {
- var c = s[o];
- c.removeFromContainer(this)
- }
- }
- ,
- e.prototype.dispose = function() {
- this.cameras.slice(0).forEach(function(c) {
- c.dispose()
- }),
- this.cameras = [],
- this.lights.slice(0).forEach(function(c) {
- c.dispose()
- }),
- this.lights = [],
- this.meshes.slice(0).forEach(function(c) {
- c.dispose()
- }),
- this.meshes = [],
- this.skeletons.slice(0).forEach(function(c) {
- c.dispose()
- }),
- this.skeletons = [],
- this.animationGroups.slice(0).forEach(function(c) {
- c.dispose()
- }),
- this.animationGroups = [],
- this.multiMaterials.slice(0).forEach(function(c) {
- c.dispose()
- }),
- this.multiMaterials = [],
- this.materials.slice(0).forEach(function(c) {
- c.dispose()
- }),
- this.materials = [],
- this.geometries.slice(0).forEach(function(c) {
- c.dispose()
- }),
- this.geometries = [],
- this.transformNodes.slice(0).forEach(function(c) {
- c.dispose()
- }),
- this.transformNodes = [],
- this.actionManagers.slice(0).forEach(function(c) {
- c.dispose()
- }),
- this.actionManagers = [],
- this.textures.slice(0).forEach(function(c) {
- c.dispose()
- }),
- this.textures = [],
- this.reflectionProbes.slice(0).forEach(function(c) {
- c.dispose()
- }),
- this.reflectionProbes = [],
- this.environmentTexture && (this.environmentTexture.dispose(),
- this.environmentTexture = null);
- for (var i = 0, o = this.scene._serializableComponents; i < o.length; i++) {
- var s = o[i];
- s.removeFromContainer(this, !0)
- }
- this._onContextRestoredObserver && (this.scene.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),
- this._onContextRestoredObserver = null)
- }
- ,
- e.prototype._moveAssets = function(i, o, s) {
- if (!!i)
- for (var c = 0, d = i; c < d.length; c++) {
- var _ = d[c]
- , b = !0;
- if (s)
- for (var k = 0, j = s; k < j.length; k++) {
- var $ = j[k];
- if (_ === $) {
- b = !1;
- break
- }
- }
- b && (o.push(_),
- _._parentContainer = this)
- }
- }
- ,
- e.prototype.moveAllFromScene = function(i) {
- this._wasAddedToScene = !1,
- i === void 0 && (i = new KeepAssets);
- for (var o in this)
- this.hasOwnProperty(o) && (this[o] = this[o] || (o === "environmentTexture" ? null : []),
- this._moveAssets(this.scene[o], this[o], i[o]));
- this.environmentTexture = this.scene.environmentTexture,
- this.removeAllFromScene()
- }
- ,
- e.prototype.createRootMesh = function() {
- var i = new Mesh("assetContainerRootMesh",this.scene);
- return this.meshes.forEach(function(o) {
- o.parent || i.addChild(o)
- }),
- this.meshes.unshift(i),
- i
- }
- ,
- e.prototype.mergeAnimationsTo = function(i, o, s) {
- if (i === void 0 && (i = EngineStore.LastCreatedScene),
- s === void 0 && (s = null),
- !i)
- return Logger$2.Error("No scene available to merge animations to"),
- [];
- var c = s || function(b) {
- var k = null
- , j = b.animations.length ? b.animations[0].targetProperty : ""
- , $ = b.name.split(".").join("").split("_primitive")[0];
- switch (j) {
- case "position":
- case "rotationQuaternion":
- k = i.getTransformNodeByName(b.name) || i.getTransformNodeByName($);
- break;
- case "influence":
- k = i.getMorphTargetByName(b.name) || i.getMorphTargetByName($);
- break;
- default:
- k = i.getNodeByName(b.name) || i.getNodeByName($)
- }
- return k
- }
- , d = this.getNodes();
- d.forEach(function(b) {
- var k = c(b);
- if (k !== null) {
- for (var j = function(tt) {
- for (var rt = k.animations.filter(function(st) {
- return st.targetProperty === tt.targetProperty
- }), it = 0, nt = rt; it < nt.length; it++) {
- var ot = nt[it]
- , at = k.animations.indexOf(ot, 0);
- at > -1 && k.animations.splice(at, 1)
- }
- }, $ = 0, _e = b.animations; $ < _e.length; $++) {
- var et = _e[$];
- j(et)
- }
- k.animations = k.animations.concat(b.animations)
- }
- });
- var _ = new Array;
- return this.animationGroups.slice().forEach(function(b) {
- _.push(b.clone(b.name, c)),
- b.animatables.forEach(function(k) {
- k.stop()
- })
- }),
- o.forEach(function(b) {
- var k = c(b.target);
- 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),
- i.stopAnimation(b.target))
- }),
- _
- }
- ,
- e
- }(AbstractScene)
- , Sound = function() {
- function a(e, i, o, s, c) {
- var d = this;
- s === void 0 && (s = null);
- var _, b, k, j, $;
- if (this.autoplay = !1,
- this._loop = !1,
- this.useCustomAttenuation = !1,
- this.isPlaying = !1,
- this.isPaused = !1,
- this.spatialSound = !1,
- this.refDistance = 1,
- this.rolloffFactor = 1,
- this.maxDistance = 100,
- this.distanceModel = "linear",
- this.metadata = null,
- this.onEndedObservable = new Observable,
- this._panningModel = "equalpower",
- this._playbackRate = 1,
- this._streaming = !1,
- this._startTime = 0,
- this._startOffset = 0,
- this._position = Vector3.Zero(),
- this._localDirection = new Vector3(1,0,0),
- this._volume = 1,
- this._isReadyToPlay = !1,
- this._isDirectional = !1,
- this._coneInnerAngle = 360,
- this._coneOuterAngle = 360,
- this._coneOuterGain = 0,
- this._isOutputConnected = !1,
- this._urlType = "Unknown",
- this.name = e,
- this._scene = o,
- a._SceneComponentInitialization(o),
- this._readyToPlayCallback = s,
- this._customAttenuationFunction = function(nt, ot, at, st, ut) {
- return ot < at ? nt * (1 - ot / at) : 0
- }
- ,
- c && (this.autoplay = c.autoplay || !1,
- this._loop = c.loop || !1,
- c.volume !== void 0 && (this._volume = c.volume),
- this.spatialSound = (_ = c.spatialSound) !== null && _ !== void 0 ? _ : !1,
- this.maxDistance = (b = c.maxDistance) !== null && b !== void 0 ? b : 100,
- this.useCustomAttenuation = (k = c.useCustomAttenuation) !== null && k !== void 0 ? k : !1,
- this.rolloffFactor = c.rolloffFactor || 1,
- this.refDistance = c.refDistance || 1,
- this.distanceModel = c.distanceModel || "linear",
- this._playbackRate = c.playbackRate || 1,
- this._streaming = (j = c.streaming) !== null && j !== void 0 ? j : !1,
- this._length = c.length,
- this._offset = c.offset),
- (($ = Engine.audioEngine) === null || $ === void 0 ? void 0 : $.canUseWebAudio) && Engine.audioEngine.audioContext) {
- this._soundGain = Engine.audioEngine.audioContext.createGain(),
- this._soundGain.gain.value = this._volume,
- this._inputAudioNode = this._soundGain,
- this._outputAudioNode = this._soundGain,
- this.spatialSound && this._createSpatialParameters(),
- this._scene.mainSoundTrack.addSound(this);
- var _e = !0;
- if (i)
- try {
- 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");
- var et = []
- , tt = !1;
- switch (this._urlType) {
- case "MediaElement":
- this._streaming = !0,
- this._isReadyToPlay = !0,
- this._streamingSource = Engine.audioEngine.audioContext.createMediaElementSource(i),
- this.autoplay && this.play(0, this._offset, this._length),
- this._readyToPlayCallback && this._readyToPlayCallback();
- break;
- case "MediaStream":
- this._streaming = !0,
- this._isReadyToPlay = !0,
- this._streamingSource = Engine.audioEngine.audioContext.createMediaStreamSource(i),
- this.autoplay && this.play(0, this._offset, this._length),
- this._readyToPlayCallback && this._readyToPlayCallback();
- break;
- case "ArrayBuffer":
- i.byteLength > 0 && (tt = !0,
- this._soundLoaded(i));
- break;
- case "String":
- et.push(i);
- case "Array":
- et.length === 0 && (et = i);
- for (var rt = 0; rt < et.length; rt++) {
- var it = et[rt];
- 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,
- tt) {
- this._streaming ? (this._htmlAudioElement = new Audio(it),
- this._htmlAudioElement.controls = !1,
- this._htmlAudioElement.loop = this.loop,
- Tools.SetCorsBehavior(it, this._htmlAudioElement),
- this._htmlAudioElement.preload = "auto",
- this._htmlAudioElement.addEventListener("canplaythrough", function() {
- d._isReadyToPlay = !0,
- d.autoplay && d.play(0, d._offset, d._length),
- d._readyToPlayCallback && d._readyToPlayCallback()
- }),
- document.body.appendChild(this._htmlAudioElement),
- this._htmlAudioElement.load()) : this._scene._loadFile(it, function(nt) {
- d._soundLoaded(nt)
- }, void 0, !0, !0, function(nt) {
- nt && Logger$2.Error("XHR " + nt.status + " error on: " + it + "."),
- Logger$2.Error("Sound creation aborted."),
- d._scene.mainSoundTrack.removeSound(d)
- });
- break
- }
- }
- break;
- default:
- _e = !1;
- break
- }
- _e ? tt || (this._isReadyToPlay = !0,
- this._readyToPlayCallback && window.setTimeout(function() {
- d._readyToPlayCallback && d._readyToPlayCallback()
- }, 1e3)) : Logger$2.Error("Parameter must be a URL to the sound, an Array of URLs (.mp3 & .ogg) or an ArrayBuffer of the sound.")
- } catch {
- Logger$2.Error("Unexpected error. Sound creation aborted."),
- this._scene.mainSoundTrack.removeSound(this)
- }
- } else
- this._scene.mainSoundTrack.addSound(this),
- Engine.audioEngine && !Engine.audioEngine.WarnedWebAudioUnsupported && (Logger$2.Error("Web Audio is not supported by your browser."),
- Engine.audioEngine.WarnedWebAudioUnsupported = !0),
- this._readyToPlayCallback && window.setTimeout(function() {
- d._readyToPlayCallback && d._readyToPlayCallback()
- }, 1e3)
- }
- return Object.defineProperty(a.prototype, "loop", {
- get: function() {
- return this._loop
- },
- set: function(e) {
- e !== this._loop && (this._loop = e,
- this.updateOptions({
- loop: e
- }))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "currentTime", {
- get: function() {
- var e;
- if (this._htmlAudioElement)
- return this._htmlAudioElement.currentTime;
- var i = this._startOffset;
- return this.isPlaying && ((e = Engine.audioEngine) === null || e === void 0 ? void 0 : e.audioContext) && (i += Engine.audioEngine.audioContext.currentTime - this._startTime),
- i
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.dispose = function() {
- var e;
- !((e = Engine.audioEngine) === null || e === void 0) && e.canUseWebAudio && (this.isPlaying && this.stop(),
- this._isReadyToPlay = !1,
- this.soundTrackId === -1 ? this._scene.mainSoundTrack.removeSound(this) : this._scene.soundTracks && this._scene.soundTracks[this.soundTrackId].removeSound(this),
- this._soundGain && (this._soundGain.disconnect(),
- this._soundGain = null),
- this._soundPanner && (this._soundPanner.disconnect(),
- this._soundPanner = null),
- this._soundSource && (this._soundSource.disconnect(),
- this._soundSource = null),
- this._audioBuffer = null,
- this._htmlAudioElement && (this._htmlAudioElement.pause(),
- this._htmlAudioElement.src = "",
- document.body.removeChild(this._htmlAudioElement)),
- this._streamingSource && this._streamingSource.disconnect(),
- this._connectedTransformNode && this._registerFunc && (this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc),
- this._connectedTransformNode = null))
- }
- ,
- a.prototype.isReady = function() {
- return this._isReadyToPlay
- }
- ,
- a.prototype.getClassName = function() {
- return "Sound"
- }
- ,
- a.prototype._soundLoaded = function(e) {
- var i = this, o;
- !(!((o = Engine.audioEngine) === null || o === void 0) && o.audioContext) || Engine.audioEngine.audioContext.decodeAudioData(e, function(s) {
- i._audioBuffer = s,
- i._isReadyToPlay = !0,
- i.autoplay && i.play(0, i._offset, i._length),
- i._readyToPlayCallback && i._readyToPlayCallback()
- }, function(s) {
- Logger$2.Error("Error while decoding audio data for: " + i.name + " / Error: " + s)
- })
- }
- ,
- a.prototype.setAudioBuffer = function(e) {
- var i;
- !((i = Engine.audioEngine) === null || i === void 0) && i.canUseWebAudio && (this._audioBuffer = e,
- this._isReadyToPlay = !0)
- }
- ,
- a.prototype.updateOptions = function(e) {
- var i, o, s, c, d, _, b, k, j;
- e && (this.loop = (i = e.loop) !== null && i !== void 0 ? i : this.loop,
- this.maxDistance = (o = e.maxDistance) !== null && o !== void 0 ? o : this.maxDistance,
- this.useCustomAttenuation = (s = e.useCustomAttenuation) !== null && s !== void 0 ? s : this.useCustomAttenuation,
- this.rolloffFactor = (c = e.rolloffFactor) !== null && c !== void 0 ? c : this.rolloffFactor,
- this.refDistance = (d = e.refDistance) !== null && d !== void 0 ? d : this.refDistance,
- this.distanceModel = (_ = e.distanceModel) !== null && _ !== void 0 ? _ : this.distanceModel,
- this._playbackRate = (b = e.playbackRate) !== null && b !== void 0 ? b : this._playbackRate,
- this._length = (k = e.length) !== null && k !== void 0 ? k : void 0,
- this._offset = (j = e.offset) !== null && j !== void 0 ? j : void 0,
- this._updateSpatialParameters(),
- this.isPlaying && (this._streaming && this._htmlAudioElement ? (this._htmlAudioElement.playbackRate = this._playbackRate,
- this._htmlAudioElement.loop !== this.loop && (this._htmlAudioElement.loop = this.loop)) : this._soundSource && (this._soundSource.playbackRate.value = this._playbackRate,
- this._soundSource.loop !== this.loop && (this._soundSource.loop = this.loop),
- this._offset !== void 0 && this._soundSource.loopStart !== this._offset && (this._soundSource.loopStart = this._offset),
- this._length !== void 0 && this._length !== this._soundSource.loopEnd && (this._soundSource.loopEnd = (this._offset | 0) + this._length))))
- }
- ,
- a.prototype._createSpatialParameters = function() {
- var e;
- ((e = Engine.audioEngine) === null || e === void 0 ? void 0 : e.canUseWebAudio) && Engine.audioEngine.audioContext && (this._scene.headphone && (this._panningModel = "HRTF"),
- this._soundPanner = Engine.audioEngine.audioContext.createPanner(),
- this._soundPanner && this._outputAudioNode && (this._updateSpatialParameters(),
- this._soundPanner.connect(this._outputAudioNode),
- this._inputAudioNode = this._soundPanner))
- }
- ,
- a.prototype._updateSpatialParameters = function() {
- this.spatialSound && this._soundPanner && (this.useCustomAttenuation ? (this._soundPanner.distanceModel = "linear",
- this._soundPanner.maxDistance = Number.MAX_VALUE,
- this._soundPanner.refDistance = 1,
- this._soundPanner.rolloffFactor = 1,
- this._soundPanner.panningModel = this._panningModel) : (this._soundPanner.distanceModel = this.distanceModel,
- this._soundPanner.maxDistance = this.maxDistance,
- this._soundPanner.refDistance = this.refDistance,
- this._soundPanner.rolloffFactor = this.rolloffFactor,
- this._soundPanner.panningModel = this._panningModel))
- }
- ,
- a.prototype.switchPanningModelToHRTF = function() {
- this._panningModel = "HRTF",
- this._switchPanningModel()
- }
- ,
- a.prototype.switchPanningModelToEqualPower = function() {
- this._panningModel = "equalpower",
- this._switchPanningModel()
- }
- ,
- a.prototype._switchPanningModel = function() {
- var e;
- ((e = Engine.audioEngine) === null || e === void 0 ? void 0 : e.canUseWebAudio) && this.spatialSound && this._soundPanner && (this._soundPanner.panningModel = this._panningModel)
- }
- ,
- a.prototype.connectToSoundTrackAudioNode = function(e) {
- var i;
- ((i = Engine.audioEngine) === null || i === void 0 ? void 0 : i.canUseWebAudio) && this._outputAudioNode && (this._isOutputConnected && this._outputAudioNode.disconnect(),
- this._outputAudioNode.connect(e),
- this._isOutputConnected = !0)
- }
- ,
- a.prototype.setDirectionalCone = function(e, i, o) {
- if (i < e) {
- Logger$2.Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.");
- return
- }
- this._coneInnerAngle = e,
- this._coneOuterAngle = i,
- this._coneOuterGain = o,
- this._isDirectional = !0,
- this.isPlaying && this.loop && (this.stop(),
- this.play(0, this._offset, this._length))
- }
- ,
- Object.defineProperty(a.prototype, "directionalConeInnerAngle", {
- get: function() {
- return this._coneInnerAngle
- },
- set: function(e) {
- var i;
- if (e != this._coneInnerAngle) {
- if (this._coneOuterAngle < e) {
- Logger$2.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
- return
- }
- this._coneInnerAngle = e,
- ((i = Engine.audioEngine) === null || i === void 0 ? void 0 : i.canUseWebAudio) && this.spatialSound && this._soundPanner && (this._soundPanner.coneInnerAngle = this._coneInnerAngle)
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "directionalConeOuterAngle", {
- get: function() {
- return this._coneOuterAngle
- },
- set: function(e) {
- var i;
- if (e != this._coneOuterAngle) {
- if (e < this._coneInnerAngle) {
- Logger$2.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
- return
- }
- this._coneOuterAngle = e,
- ((i = Engine.audioEngine) === null || i === void 0 ? void 0 : i.canUseWebAudio) && this.spatialSound && this._soundPanner && (this._soundPanner.coneOuterAngle = this._coneOuterAngle)
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.setPosition = function(e) {
- var i;
- e.equals(this._position) || (this._position.copyFrom(e),
- ((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))
- }
- ,
- a.prototype.setLocalDirectionToMesh = function(e) {
- var i;
- this._localDirection = e,
- ((i = Engine.audioEngine) === null || i === void 0 ? void 0 : i.canUseWebAudio) && this._connectedTransformNode && this.isPlaying && this._updateDirection()
- }
- ,
- a.prototype._updateDirection = function() {
- if (!(!this._connectedTransformNode || !this._soundPanner)) {
- var e = this._connectedTransformNode.getWorldMatrix()
- , i = Vector3.TransformNormal(this._localDirection, e);
- i.normalize(),
- this._soundPanner.setOrientation(i.x, i.y, i.z)
- }
- }
- ,
- a.prototype.updateDistanceFromListener = function() {
- var e;
- if (((e = Engine.audioEngine) === null || e === void 0 ? void 0 : e.canUseWebAudio) && this._connectedTransformNode && this.useCustomAttenuation && this._soundGain && this._scene.activeCamera) {
- var i = this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);
- this._soundGain.gain.value = this._customAttenuationFunction(this._volume, i, this.maxDistance, this.refDistance, this.rolloffFactor)
- }
- }
- ,
- a.prototype.setAttenuationFunction = function(e) {
- this._customAttenuationFunction = e
- }
- ,
- a.prototype.play = function(e, i, o) {
- var s = this, c, d, _, b;
- if (this._isReadyToPlay && this._scene.audioEnabled && ((c = Engine.audioEngine) === null || c === void 0 ? void 0 : c.audioContext))
- try {
- this._startOffset < 0 && (e = -this._startOffset,
- this._startOffset = 0);
- 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;
- 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),
- this._isDirectional && (this._soundPanner.coneInnerAngle = this._coneInnerAngle,
- this._soundPanner.coneOuterAngle = this._coneOuterAngle,
- this._soundPanner.coneOuterGain = this._coneOuterGain,
- this._connectedTransformNode ? this._updateDirection() : this._soundPanner.setOrientation(this._localDirection.x, this._localDirection.y, this._localDirection.z))),
- this._streaming) {
- if (this._streamingSource || (this._streamingSource = Engine.audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement),
- this._htmlAudioElement.onended = function() {
- s._onended()
- }
- ,
- this._htmlAudioElement.playbackRate = this._playbackRate),
- this._streamingSource.disconnect(),
- this._inputAudioNode && this._streamingSource.connect(this._inputAudioNode),
- this._htmlAudioElement) {
- var j = function() {
- var $, _e;
- if (!(($ = Engine.audioEngine) === null || $ === void 0) && $.unlocked) {
- var et = s._htmlAudioElement.play();
- et !== void 0 && et.catch(function(tt) {
- var rt, it;
- (rt = Engine.audioEngine) === null || rt === void 0 || rt.lock(),
- (s.loop || s.autoplay) && ((it = Engine.audioEngine) === null || it === void 0 || it.onAudioUnlockedObservable.addOnce(function() {
- j()
- }))
- })
- } else
- (s.loop || s.autoplay) && ((_e = Engine.audioEngine) === null || _e === void 0 || _e.onAudioUnlockedObservable.addOnce(function() {
- j()
- }))
- };
- j()
- }
- } else {
- var j = function() {
- var _e, et, tt;
- if (!((_e = Engine.audioEngine) === null || _e === void 0) && _e.audioContext) {
- if (o = o || s._length,
- i = i || s._offset,
- s._soundSource) {
- var rt = s._soundSource;
- rt.onended = function() {
- rt.disconnect()
- }
- }
- if (s._soundSource = (et = Engine.audioEngine) === null || et === void 0 ? void 0 : et.audioContext.createBufferSource(),
- s._soundSource && s._inputAudioNode) {
- s._soundSource.buffer = s._audioBuffer,
- s._soundSource.connect(s._inputAudioNode),
- s._soundSource.loop = s.loop,
- i !== void 0 && (s._soundSource.loopStart = i),
- o !== void 0 && (s._soundSource.loopEnd = (i | 0) + o),
- s._soundSource.playbackRate.value = s._playbackRate,
- s._soundSource.onended = function() {
- s._onended()
- }
- ,
- k = e ? ((tt = Engine.audioEngine) === null || tt === void 0 ? void 0 : tt.audioContext.currentTime) + e : Engine.audioEngine.audioContext.currentTime;
- var it = s.isPaused ? s._startOffset % s._soundSource.buffer.duration : i || 0;
- s._soundSource.start(k, it, s.loop ? void 0 : o)
- }
- }
- };
- ((b = Engine.audioEngine) === null || b === void 0 ? void 0 : b.audioContext.state) === "suspended" ? setTimeout(function() {
- var _e;
- ((_e = Engine.audioEngine) === null || _e === void 0 ? void 0 : _e.audioContext.state) === "suspended" ? (Engine.audioEngine.lock(),
- (s.loop || s.autoplay) && Engine.audioEngine.onAudioUnlockedObservable.addOnce(function() {
- j()
- })) : j()
- }, 500) : j()
- }
- this._startTime = k,
- this.isPlaying = !0,
- this.isPaused = !1
- } catch ($) {
- Logger$2.Error("Error while trying to play audio: " + this.name + ", " + $.message)
- }
- }
- ,
- a.prototype._onended = function() {
- this.isPlaying = !1,
- this._startOffset = 0,
- this.onended && this.onended(),
- this.onEndedObservable.notifyObservers(this)
- }
- ,
- a.prototype.stop = function(e) {
- var i = this, o;
- if (this.isPlaying) {
- if (this._streaming)
- this._htmlAudioElement ? (this._htmlAudioElement.pause(),
- this._htmlAudioElement.currentTime > 0 && (this._htmlAudioElement.currentTime = 0)) : this._streamingSource.disconnect(),
- this.isPlaying = !1;
- else if (((o = Engine.audioEngine) === null || o === void 0 ? void 0 : o.audioContext) && this._soundSource) {
- var s = e ? Engine.audioEngine.audioContext.currentTime + e : void 0;
- this._soundSource.stop(s),
- s === void 0 ? (this.isPlaying = !1,
- this._soundSource.onended = function() {}
- ) : this._soundSource.onended = function() {
- i.isPlaying = !1
- }
- ,
- this.isPaused || (this._startOffset = 0)
- }
- }
- }
- ,
- a.prototype.pause = function() {
- var e;
- this.isPlaying && (this.isPaused = !0,
- this._streaming ? (this._htmlAudioElement ? this._htmlAudioElement.pause() : this._streamingSource.disconnect(),
- this.isPlaying = !1) : !((e = Engine.audioEngine) === null || e === void 0) && e.audioContext && (this.stop(0),
- this._startOffset += Engine.audioEngine.audioContext.currentTime - this._startTime))
- }
- ,
- a.prototype.setVolume = function(e, i) {
- var o;
- ((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),
- this._soundGain.gain.setValueAtTime(this._soundGain.gain.value, Engine.audioEngine.audioContext.currentTime),
- this._soundGain.gain.linearRampToValueAtTime(e, Engine.audioEngine.audioContext.currentTime + i)) : this._soundGain.gain.value = e),
- this._volume = e
- }
- ,
- a.prototype.setPlaybackRate = function(e) {
- this._playbackRate = e,
- this.isPlaying && (this._streaming && this._htmlAudioElement ? this._htmlAudioElement.playbackRate = this._playbackRate : this._soundSource && (this._soundSource.playbackRate.value = this._playbackRate))
- }
- ,
- a.prototype.getVolume = function() {
- return this._volume
- }
- ,
- a.prototype.attachToMesh = function(e) {
- var i = this;
- this._connectedTransformNode && this._registerFunc && (this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc),
- this._registerFunc = null),
- this._connectedTransformNode = e,
- this.spatialSound || (this.spatialSound = !0,
- this._createSpatialParameters(),
- this.isPlaying && this.loop && (this.stop(),
- this.play(0, this._offset, this._length))),
- this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode),
- this._registerFunc = function(o) {
- return i._onRegisterAfterWorldMatrixUpdate(o)
- }
- ,
- this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc)
- }
- ,
- a.prototype.detachFromMesh = function() {
- this._connectedTransformNode && this._registerFunc && (this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc),
- this._registerFunc = null,
- this._connectedTransformNode = null)
- }
- ,
- a.prototype._onRegisterAfterWorldMatrixUpdate = function(e) {
- var i;
- if (!e.getBoundingInfo)
- this.setPosition(e.absolutePosition);
- else {
- var o = e
- , s = o.getBoundingInfo();
- this.setPosition(s.boundingSphere.centerWorld)
- }
- ((i = Engine.audioEngine) === null || i === void 0 ? void 0 : i.canUseWebAudio) && this._isDirectional && this.isPlaying && this._updateDirection()
- }
- ,
- a.prototype.clone = function() {
- var e = this;
- if (this._streaming)
- return null;
- var i = function() {
- e._isReadyToPlay ? (s._audioBuffer = e.getAudioBuffer(),
- s._isReadyToPlay = !0,
- s.autoplay && s.play(0, e._offset, e._length)) : window.setTimeout(i, 300)
- }
- , o = {
- autoplay: this.autoplay,
- loop: this.loop,
- volume: this._volume,
- spatialSound: this.spatialSound,
- maxDistance: this.maxDistance,
- useCustomAttenuation: this.useCustomAttenuation,
- rolloffFactor: this.rolloffFactor,
- refDistance: this.refDistance,
- distanceModel: this.distanceModel
- }
- , s = new a(this.name + "_cloned",new ArrayBuffer(0),this._scene,null,o);
- return this.useCustomAttenuation && s.setAttenuationFunction(this._customAttenuationFunction),
- s.setPosition(this._position),
- s.setPlaybackRate(this._playbackRate),
- i(),
- s
- }
- ,
- a.prototype.getAudioBuffer = function() {
- return this._audioBuffer
- }
- ,
- a.prototype.getSoundSource = function() {
- return this._soundSource
- }
- ,
- a.prototype.getSoundGain = function() {
- return this._soundGain
- }
- ,
- a.prototype.serialize = function() {
- var e = {
- name: this.name,
- url: this.name,
- autoplay: this.autoplay,
- loop: this.loop,
- volume: this._volume,
- spatialSound: this.spatialSound,
- maxDistance: this.maxDistance,
- rolloffFactor: this.rolloffFactor,
- refDistance: this.refDistance,
- distanceModel: this.distanceModel,
- playbackRate: this._playbackRate,
- panningModel: this._panningModel,
- soundTrackId: this.soundTrackId,
- metadata: this.metadata
- };
- return this.spatialSound && (this._connectedTransformNode && (e.connectedMeshId = this._connectedTransformNode.id),
- e.position = this._position.asArray(),
- e.refDistance = this.refDistance,
- e.distanceModel = this.distanceModel,
- e.isDirectional = this._isDirectional,
- e.localDirectionToMesh = this._localDirection.asArray(),
- e.coneInnerAngle = this._coneInnerAngle,
- e.coneOuterAngle = this._coneOuterAngle,
- e.coneOuterGain = this._coneOuterGain),
- e
- }
- ,
- a.Parse = function(e, i, o, s) {
- var c = e.name, d;
- e.url ? d = o + e.url : d = o + c;
- var _ = {
- autoplay: e.autoplay,
- loop: e.loop,
- volume: e.volume,
- spatialSound: e.spatialSound,
- maxDistance: e.maxDistance,
- rolloffFactor: e.rolloffFactor,
- refDistance: e.refDistance,
- distanceModel: e.distanceModel,
- playbackRate: e.playbackRate
- }, b;
- if (!s)
- b = new a(c,d,i,function() {
- i._removePendingData(b)
- }
- ,_),
- i._addPendingData(b);
- else {
- var k = function() {
- s._isReadyToPlay ? (b._audioBuffer = s.getAudioBuffer(),
- b._isReadyToPlay = !0,
- b.autoplay && b.play(0, b._offset, b._length)) : window.setTimeout(k, 300)
- };
- b = new a(c,new ArrayBuffer(0),i,null,_),
- k()
- }
- if (e.position) {
- var j = Vector3.FromArray(e.position);
- b.setPosition(j)
- }
- if (e.isDirectional && (b.setDirectionalCone(e.coneInnerAngle || 360, e.coneOuterAngle || 360, e.coneOuterGain || 0),
- e.localDirectionToMesh)) {
- var $ = Vector3.FromArray(e.localDirectionToMesh);
- b.setLocalDirectionToMesh($)
- }
- if (e.connectedMeshId) {
- var _e = i.getMeshById(e.connectedMeshId);
- _e && b.attachToMesh(_e)
- }
- return e.metadata && (b.metadata = e.metadata),
- b
- }
- ,
- a._SceneComponentInitialization = function(e) {
- throw _WarnImport("AudioSceneComponent")
- }
- ,
- a
- }()
- , ThinSprite = function() {
- function a() {
- this.width = 1,
- this.height = 1,
- this.angle = 0,
- this.invertU = !1,
- this.invertV = !1,
- this.isVisible = !0,
- this._animationStarted = !1,
- this._loopAnimation = !1,
- this._fromIndex = 0,
- this._toIndex = 0,
- this._delay = 0,
- this._direction = 1,
- this._time = 0,
- this._onBaseAnimationEnd = null,
- this.position = {
- x: 1,
- y: 1,
- z: 1
- },
- this.color = {
- r: 1,
- g: 1,
- b: 1,
- a: 1
- }
- }
- return Object.defineProperty(a.prototype, "animationStarted", {
- get: function() {
- return this._animationStarted
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "fromIndex", {
- get: function() {
- return this._fromIndex
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "toIndex", {
- get: function() {
- return this._toIndex
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "loopAnimation", {
- get: function() {
- return this._loopAnimation
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "delay", {
- get: function() {
- return Math.max(this._delay, 1)
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.playAnimation = function(e, i, o, s, c) {
- this._fromIndex = e,
- this._toIndex = i,
- this._loopAnimation = o,
- this._delay = s || 1,
- this._animationStarted = !0,
- this._onBaseAnimationEnd = c,
- e < i ? this._direction = 1 : (this._direction = -1,
- this._toIndex = e,
- this._fromIndex = i),
- this.cellIndex = e,
- this._time = 0
- }
- ,
- a.prototype.stopAnimation = function() {
- this._animationStarted = !1
- }
- ,
- a.prototype._animate = function(e) {
- !this._animationStarted || (this._time += e,
- this._time > this._delay && (this._time = this._time % this._delay,
- this.cellIndex += this._direction,
- (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,
- this._animationStarted = !1,
- this._onBaseAnimationEnd && this._onBaseAnimationEnd()))))
- }
- ,
- a
- }()
- , Sprite = function(a) {
- __extends(e, a);
- function e(i, o) {
- var s = a.call(this) || this;
- return s.name = i,
- s.animations = new Array,
- s.isPickable = !1,
- s.useAlphaForPicking = !1,
- s.onDisposeObservable = new Observable,
- s._onAnimationEnd = null,
- s._endAnimation = function() {
- s._onAnimationEnd && s._onAnimationEnd(),
- s.disposeWhenFinishedAnimating && s.dispose()
- }
- ,
- s.color = new Color4(1,1,1,1),
- s.position = Vector3.Zero(),
- s._manager = o,
- s._manager.sprites.push(s),
- s.uniqueId = s._manager.scene.getUniqueId(),
- s
- }
- return Object.defineProperty(e.prototype, "size", {
- get: function() {
- return this.width
- },
- set: function(i) {
- this.width = i,
- this.height = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "manager", {
- get: function() {
- return this._manager
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getClassName = function() {
- return "Sprite"
- }
- ,
- Object.defineProperty(e.prototype, "fromIndex", {
- get: function() {
- return this._fromIndex
- },
- set: function(i) {
- this.playAnimation(i, this._toIndex, this._loopAnimation, this._delay, this._onAnimationEnd)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "toIndex", {
- get: function() {
- return this._toIndex
- },
- set: function(i) {
- this.playAnimation(this._fromIndex, i, this._loopAnimation, this._delay, this._onAnimationEnd)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "loopAnimation", {
- get: function() {
- return this._loopAnimation
- },
- set: function(i) {
- this.playAnimation(this._fromIndex, this._toIndex, i, this._delay, this._onAnimationEnd)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "delay", {
- get: function() {
- return Math.max(this._delay, 1)
- },
- set: function(i) {
- this.playAnimation(this._fromIndex, this._toIndex, this._loopAnimation, i, this._onAnimationEnd)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.playAnimation = function(i, o, s, c, d) {
- d === void 0 && (d = null),
- this._onAnimationEnd = d,
- a.prototype.playAnimation.call(this, i, o, s, c, this._endAnimation)
- }
- ,
- e.prototype.dispose = function() {
- for (var i = 0; i < this._manager.sprites.length; i++)
- this._manager.sprites[i] == this && this._manager.sprites.splice(i, 1);
- this.onDisposeObservable.notifyObservers(this),
- this.onDisposeObservable.clear()
- }
- ,
- e.prototype.serialize = function() {
- var i = {};
- return i.name = this.name,
- i.position = this.position.asArray(),
- i.color = this.color.asArray(),
- i.width = this.width,
- i.height = this.height,
- i.angle = this.angle,
- i.cellIndex = this.cellIndex,
- i.cellRef = this.cellRef,
- i.invertU = this.invertU,
- i.invertV = this.invertV,
- i.disposeWhenFinishedAnimating = this.disposeWhenFinishedAnimating,
- i.isPickable = this.isPickable,
- i.isVisible = this.isVisible,
- i.useAlphaForPicking = this.useAlphaForPicking,
- i.animationStarted = this.animationStarted,
- i.fromIndex = this.fromIndex,
- i.toIndex = this.toIndex,
- i.loopAnimation = this.loopAnimation,
- i.delay = this.delay,
- i
- }
- ,
- e.Parse = function(i, o) {
- var s = new e(i.name,o);
- return s.position = Vector3.FromArray(i.position),
- s.color = Color4.FromArray(i.color),
- s.width = i.width,
- s.height = i.height,
- s.angle = i.angle,
- s.cellIndex = i.cellIndex,
- s.cellRef = i.cellRef,
- s.invertU = i.invertU,
- s.invertV = i.invertV,
- s.disposeWhenFinishedAnimating = i.disposeWhenFinishedAnimating,
- s.isPickable = i.isPickable,
- s.isVisible = i.isVisible,
- s.useAlphaForPicking = i.useAlphaForPicking,
- s.fromIndex = i.fromIndex,
- s.toIndex = i.toIndex,
- s.loopAnimation = i.loopAnimation,
- s.delay = i.delay,
- i.animationStarted && s.playAnimation(s.fromIndex, s.toIndex, s.loopAnimation, s.delay),
- s
- }
- ,
- e
- }(ThinSprite);
- Scene.prototype._internalPickSprites = function(a, e, i, o) {
- if (!PickingInfo)
- return null;
- var s = null;
- if (!o) {
- if (!this.activeCamera)
- return null;
- o = this.activeCamera
- }
- if (this.spriteManagers.length > 0)
- for (var c = 0; c < this.spriteManagers.length; c++) {
- var d = this.spriteManagers[c];
- if (!!d.isPickable) {
- var _ = d.intersects(a, o, e, i);
- if (!(!_ || !_.hit) && !(!i && s != null && _.distance >= s.distance) && (s = _,
- i))
- break
- }
- }
- return s || new PickingInfo
- }
- ;
- Scene.prototype._internalMultiPickSprites = function(a, e, i) {
- if (!PickingInfo)
- return null;
- var o = new Array;
- if (!i) {
- if (!this.activeCamera)
- return null;
- i = this.activeCamera
- }
- if (this.spriteManagers.length > 0)
- for (var s = 0; s < this.spriteManagers.length; s++) {
- var c = this.spriteManagers[s];
- if (!!c.isPickable) {
- var d = c.multiIntersects(a, i, e);
- d !== null && (o = o.concat(d))
- }
- }
- return o
- }
- ;
- Scene.prototype.pickSprite = function(a, e, i, o, s) {
- if (!this._tempSpritePickingRay)
- return null;
- this.createPickingRayInCameraSpaceToRef(a, e, this._tempSpritePickingRay, s);
- var c = this._internalPickSprites(this._tempSpritePickingRay, i, o, s);
- return c && (c.ray = this.createPickingRayInCameraSpace(a, e, s)),
- c
- }
- ;
- Scene.prototype.pickSpriteWithRay = function(a, e, i, o) {
- if (!this._tempSpritePickingRay)
- return null;
- if (!o) {
- if (!this.activeCamera)
- return null;
- o = this.activeCamera
- }
- Ray.TransformToRef(a, o.getViewMatrix(), this._tempSpritePickingRay);
- var s = this._internalPickSprites(this._tempSpritePickingRay, e, i, o);
- return s && (s.ray = a),
- s
- }
- ;
- Scene.prototype.multiPickSprite = function(a, e, i, o) {
- return this.createPickingRayInCameraSpaceToRef(a, e, this._tempSpritePickingRay, o),
- this._internalMultiPickSprites(this._tempSpritePickingRay, i, o)
- }
- ;
- Scene.prototype.multiPickSpriteWithRay = function(a, e, i) {
- if (!this._tempSpritePickingRay)
- return null;
- if (!i) {
- if (!this.activeCamera)
- return null;
- i = this.activeCamera
- }
- return Ray.TransformToRef(a, i.getViewMatrix(), this._tempSpritePickingRay),
- this._internalMultiPickSprites(this._tempSpritePickingRay, e, i)
- }
- ;
- Scene.prototype.setPointerOverSprite = function(a) {
- this._pointerOverSprite !== a && (this._pointerOverSprite && this._pointerOverSprite.actionManager && this._pointerOverSprite.actionManager.processTrigger(10, ActionEvent.CreateNewFromSprite(this._pointerOverSprite, this)),
- this._pointerOverSprite = a,
- this._pointerOverSprite && this._pointerOverSprite.actionManager && this._pointerOverSprite.actionManager.processTrigger(9, ActionEvent.CreateNewFromSprite(this._pointerOverSprite, this)))
- }
- ;
- Scene.prototype.getPointerOverSprite = function() {
- return this._pointerOverSprite
- }
- ;
- var SpriteSceneComponent = function() {
- function a(e) {
- this.name = SceneComponentConstants.NAME_SPRITE,
- this.scene = e,
- this.scene.spriteManagers = new Array,
- this.scene._tempSpritePickingRay = Ray ? Ray.Zero() : null,
- this.scene.onBeforeSpritesRenderingObservable = new Observable,
- this.scene.onAfterSpritesRenderingObservable = new Observable,
- this._spritePredicate = function(i) {
- return i.actionManager ? i.isPickable && i.actionManager.hasPointerTriggers : !1
- }
- }
- return a.prototype.register = function() {
- this.scene._pointerMoveStage.registerStep(SceneComponentConstants.STEP_POINTERMOVE_SPRITE, this, this._pointerMove),
- this.scene._pointerDownStage.registerStep(SceneComponentConstants.STEP_POINTERDOWN_SPRITE, this, this._pointerDown),
- this.scene._pointerUpStage.registerStep(SceneComponentConstants.STEP_POINTERUP_SPRITE, this, this._pointerUp)
- }
- ,
- a.prototype.rebuild = function() {}
- ,
- a.prototype.dispose = function() {
- this.scene.onBeforeSpritesRenderingObservable.clear(),
- this.scene.onAfterSpritesRenderingObservable.clear();
- for (var e = this.scene.spriteManagers; e.length; )
- e[0].dispose()
- }
- ,
- a.prototype._pickSpriteButKeepRay = function(e, i, o, s, c) {
- var d = this.scene.pickSprite(i, o, this._spritePredicate, s, c);
- return d && (d.ray = e ? e.ray : null),
- d
- }
- ,
- a.prototype._pointerMove = function(e, i, o, s, c) {
- var d = this.scene;
- return s ? d.setPointerOverSprite(null) : (o = this._pickSpriteButKeepRay(o, e, i, !1, d.cameraToUseForPointers || void 0),
- o && o.hit && o.pickedSprite ? (d.setPointerOverSprite(o.pickedSprite),
- !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)),
- o
- }
- ,
- a.prototype._pointerDown = function(e, i, o, s) {
- var c = this.scene;
- if (c._pickedDownSprite = null,
- c.spriteManagers.length > 0 && (o = c.pickSprite(e, i, this._spritePredicate, !1, c.cameraToUseForPointers || void 0),
- o && o.hit && o.pickedSprite && o.pickedSprite.actionManager)) {
- switch (c._pickedDownSprite = o.pickedSprite,
- s.button) {
- case 0:
- o.pickedSprite.actionManager.processTrigger(2, ActionEvent.CreateNewFromSprite(o.pickedSprite, c, s));
- break;
- case 1:
- o.pickedSprite.actionManager.processTrigger(4, ActionEvent.CreateNewFromSprite(o.pickedSprite, c, s));
- break;
- case 2:
- o.pickedSprite.actionManager.processTrigger(3, ActionEvent.CreateNewFromSprite(o.pickedSprite, c, s));
- break
- }
- o.pickedSprite.actionManager && o.pickedSprite.actionManager.processTrigger(5, ActionEvent.CreateNewFromSprite(o.pickedSprite, c, s))
- }
- return o
- }
- ,
- a.prototype._pointerUp = function(e, i, o, s) {
- var c = this.scene;
- if (c.spriteManagers.length > 0) {
- var d = c.pickSprite(e, i, this._spritePredicate, !1, c.cameraToUseForPointers || void 0);
- d && (d.hit && d.pickedSprite && d.pickedSprite.actionManager && (d.pickedSprite.actionManager.processTrigger(7, ActionEvent.CreateNewFromSprite(d.pickedSprite, c, s)),
- d.pickedSprite.actionManager && (this.scene._inputManager._isPointerSwiping() || d.pickedSprite.actionManager.processTrigger(1, ActionEvent.CreateNewFromSprite(d.pickedSprite, c, s)))),
- c._pickedDownSprite && c._pickedDownSprite.actionManager && c._pickedDownSprite !== d.pickedSprite && c._pickedDownSprite.actionManager.processTrigger(16, ActionEvent.CreateNewFromSprite(c._pickedDownSprite, c, s)))
- }
- return o
- }
- ,
- a
- }()
- , name$l = "spritesPixelShader"
- , shader$l = `uniform bool alphaTest;
- varying vec4 vColor;
- varying vec2 vUV;
- uniform sampler2D diffuseSampler;
- #include<fogFragmentDeclaration>
- void main(void) {
- vec4 color=texture2D(diffuseSampler,vUV);
- if (alphaTest)
- {
- if (color.a<0.95)
- discard;
- }
- color*=vColor;
- #include<fogFragment>
- gl_FragColor=color;
- #include<imageProcessingCompatibility>
- }`;
- ShaderStore.ShadersStore[name$l] = shader$l;
- var name$k = "spritesVertexShader"
- , shader$k = `
- attribute vec4 position;
- attribute vec2 options;
- attribute vec2 offsets;
- attribute vec2 inverts;
- attribute vec4 cellInfo;
- attribute vec4 color;
- uniform mat4 view;
- uniform mat4 projection;
- varying vec2 vUV;
- varying vec4 vColor;
- #include<fogVertexDeclaration>
- void main(void) {
- vec3 viewPos=(view*vec4(position.xyz,1.0)).xyz;
- vec2 cornerPos;
- float angle=position.w;
- vec2 size=vec2(options.x,options.y);
- vec2 offset=offsets.xy;
- cornerPos=vec2(offset.x-0.5,offset.y-0.5)*size;
- vec3 rotatedCorner;
- rotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);
- rotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);
- rotatedCorner.z=0.;
- viewPos+=rotatedCorner;
- gl_Position=projection*vec4(viewPos,1.0);
- vColor=color;
- vec2 uvOffset=vec2(abs(offset.x-inverts.x),abs(1.0-offset.y-inverts.y));
- vec2 uvPlace=cellInfo.xy;
- vec2 uvSize=cellInfo.zw;
- vUV.x=uvPlace.x+uvSize.x*uvOffset.x;
- vUV.y=uvPlace.y+uvSize.y*uvOffset.y;
- #ifdef FOG
- vFogDistance=viewPos;
- #endif
- }`;
- ShaderStore.ShadersStore[name$k] = shader$k;
- var SpriteRenderer = function() {
- function a(e, i, o, s) {
- o === void 0 && (o = .01),
- s === void 0 && (s = null),
- this.blendMode = 2,
- this.autoResetAlpha = !0,
- this.disableDepthWrite = !1,
- this.fogEnabled = !0,
- this._useVAO = !1,
- this._useInstancing = !1,
- this._vertexBuffers = {},
- this._capacity = i,
- this._epsilon = o,
- this._engine = e,
- this._useInstancing = e.getCaps().instancedArrays,
- this._useVAO = e.getCaps().vertexArrayObject && !e.disableVertexArrayObjects,
- this._scene = s,
- this._drawWrapperBase = new DrawWrapper(e),
- this._drawWrapperFog = new DrawWrapper(e),
- this._drawWrapperDepth = new DrawWrapper(e,!1),
- this._drawWrapperFogDepth = new DrawWrapper(e,!1),
- this._useInstancing || this._buildIndexBuffer(),
- this._drawWrapperBase.drawContext && (this._drawWrapperBase.drawContext.useInstancing = this._useInstancing),
- this._drawWrapperFog.drawContext && (this._drawWrapperFog.drawContext.useInstancing = this._useInstancing),
- this._drawWrapperDepth.drawContext && (this._drawWrapperDepth.drawContext.useInstancing = this._useInstancing),
- this._drawWrapperFogDepth.drawContext && (this._drawWrapperFogDepth.drawContext.useInstancing = this._useInstancing),
- this._vertexBufferSize = this._useInstancing ? 16 : 18,
- this._vertexData = new Float32Array(i * this._vertexBufferSize * (this._useInstancing ? 1 : 4)),
- this._buffer = new Buffer(e,this._vertexData,!0,this._vertexBufferSize);
- 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;
- if (this._useInstancing) {
- var k = new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]);
- this._spriteBuffer = new Buffer(e,k,!1,2),
- b = this._spriteBuffer.createVertexBuffer("offsets", 0, 2)
- } else
- b = this._buffer.createVertexBuffer("offsets", _, 2, this._vertexBufferSize, this._useInstancing),
- _ += 2;
- var j = this._buffer.createVertexBuffer("inverts", _, 2, this._vertexBufferSize, this._useInstancing)
- , $ = this._buffer.createVertexBuffer("cellInfo", _ + 2, 4, this._vertexBufferSize, this._useInstancing)
- , _e = this._buffer.createVertexBuffer(VertexBuffer.ColorKind, _ + 6, 4, this._vertexBufferSize, this._useInstancing);
- this._vertexBuffers[VertexBuffer.PositionKind] = c,
- this._vertexBuffers.options = d,
- this._vertexBuffers.offsets = b,
- this._vertexBuffers.inverts = j,
- this._vertexBuffers.cellInfo = $,
- this._vertexBuffers[VertexBuffer.ColorKind] = _e,
- this._drawWrapperBase.effect = this._engine.createEffect("sprites", [VertexBuffer.PositionKind, "options", "offsets", "inverts", "cellInfo", VertexBuffer.ColorKind], ["view", "projection", "textureInfos", "alphaTest"], ["diffuseSampler"], ""),
- this._drawWrapperDepth.effect = this._drawWrapperBase.effect,
- this._drawWrapperDepth.materialContext = this._drawWrapperBase.materialContext,
- 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"),
- this._drawWrapperFogDepth.effect = this._drawWrapperFog.effect,
- this._drawWrapperFogDepth.materialContext = this._drawWrapperFog.materialContext)
- }
- return Object.defineProperty(a.prototype, "capacity", {
- get: function() {
- return this._capacity
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.render = function(e, i, o, s, c) {
- if (c === void 0 && (c = null),
- !(!this.texture || !this.texture.isReady() || !e.length)) {
- var d = this._drawWrapperBase
- , _ = this._drawWrapperDepth
- , b = !1;
- this.fogEnabled && this._scene && this._scene.fogEnabled && this._scene.fogMode !== 0 && (d = this._drawWrapperFog,
- _ = this._drawWrapperFogDepth,
- b = !0);
- var k = d.effect;
- if (!!k.isReady()) {
- 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++) {
- var nt = e[it];
- !nt || !nt.isVisible || (rt = !1,
- nt._animate(i),
- this._appendSpriteVertex(tt++, nt, 0, 0, _e, $, c),
- this._useInstancing || (this._appendSpriteVertex(tt++, nt, 1, 0, _e, $, c),
- this._appendSpriteVertex(tt++, nt, 1, 1, _e, $, c),
- this._appendSpriteVertex(tt++, nt, 0, 1, _e, $, c)))
- }
- if (!rt) {
- this._buffer.update(this._vertexData);
- var ot = j.depthCullingState.cull || !0
- , at = j.depthCullingState.zOffset
- , st = j.depthCullingState.zOffsetUnits;
- if (j.setState(ot, at, !1, !1, void 0, void 0, st),
- j.enableEffect(d),
- k.setTexture("diffuseSampler", this.texture),
- k.setMatrix("view", o),
- k.setMatrix("projection", s),
- b) {
- var ut = this._scene;
- k.setFloat4("vFogInfos", ut.fogMode, ut.fogStart, ut.fogEnd, ut.fogDensity),
- k.setColor3("vFogColor", ut.fogColor)
- }
- this._useVAO ? (this._vertexArrayObject || (this._vertexArrayObject = j.recordVertexArrayObject(this._vertexBuffers, this._indexBuffer, k)),
- j.bindVertexArrayObject(this._vertexArrayObject, this._indexBuffer)) : j.bindBuffers(this._vertexBuffers, this._indexBuffer, k),
- j.depthCullingState.depthFunc = j.useReverseDepthBuffer ? 518 : 515,
- this.disableDepthWrite || (k.setBool("alphaTest", !0),
- j.setColorWrite(!1),
- j.enableEffect(_),
- this._useInstancing ? j.drawArraysType(7, 0, 4, tt) : j.drawElementsType(0, 0, tt / 4 * 6),
- j.enableEffect(d),
- j.setColorWrite(!0),
- k.setBool("alphaTest", !1)),
- j.setAlphaMode(this.blendMode),
- this._useInstancing ? j.drawArraysType(7, 0, 4, tt) : j.drawElementsType(0, 0, tt / 4 * 6),
- this.autoResetAlpha && j.setAlphaMode(0),
- $ && this._scene.getEngine().setState(ot, at, !1, !0, void 0, void 0, st),
- j.unbindInstanceAttributes()
- }
- }
- }
- }
- ,
- a.prototype._appendSpriteVertex = function(e, i, o, s, c, d, _) {
- var b = e * this._vertexBufferSize;
- if (o === 0 ? o = this._epsilon : o === 1 && (o = 1 - this._epsilon),
- s === 0 ? s = this._epsilon : s === 1 && (s = 1 - this._epsilon),
- _)
- _(i, c);
- else {
- i.cellIndex || (i.cellIndex = 0);
- var k = c.width / this.cellWidth
- , j = i.cellIndex / k >> 0;
- i._xOffset = (i.cellIndex - j * k) * this.cellWidth / c.width,
- i._yOffset = j * this.cellHeight / c.height,
- i._xSize = this.cellWidth,
- i._ySize = this.cellHeight
- }
- this._vertexData[b] = i.position.x,
- this._vertexData[b + 1] = i.position.y,
- this._vertexData[b + 2] = i.position.z,
- this._vertexData[b + 3] = i.angle,
- this._vertexData[b + 4] = i.width,
- this._vertexData[b + 5] = i.height,
- this._useInstancing ? b -= 2 : (this._vertexData[b + 6] = o,
- this._vertexData[b + 7] = s),
- d ? this._vertexData[b + 8] = i.invertU ? 0 : 1 : this._vertexData[b + 8] = i.invertU ? 1 : 0,
- this._vertexData[b + 9] = i.invertV ? 1 : 0,
- this._vertexData[b + 10] = i._xOffset,
- this._vertexData[b + 11] = i._yOffset,
- this._vertexData[b + 12] = i._xSize / c.width,
- this._vertexData[b + 13] = i._ySize / c.height,
- this._vertexData[b + 14] = i.color.r,
- this._vertexData[b + 15] = i.color.g,
- this._vertexData[b + 16] = i.color.b,
- this._vertexData[b + 17] = i.color.a
- }
- ,
- a.prototype._buildIndexBuffer = function() {
- for (var e = [], i = 0, o = 0; o < this._capacity; o++)
- e.push(i),
- e.push(i + 1),
- e.push(i + 2),
- e.push(i),
- e.push(i + 2),
- e.push(i + 3),
- i += 4;
- this._indexBuffer = this._engine.createIndexBuffer(e)
- }
- ,
- a.prototype.rebuild = function() {
- var e;
- this._indexBuffer && this._buildIndexBuffer(),
- this._useVAO && (this._vertexArrayObject = void 0),
- this._buffer._rebuild();
- for (var i in this._vertexBuffers) {
- var o = this._vertexBuffers[i];
- o._rebuild()
- }
- (e = this._spriteBuffer) === null || e === void 0 || e._rebuild()
- }
- ,
- a.prototype.dispose = function() {
- this._buffer && (this._buffer.dispose(),
- this._buffer = null),
- this._spriteBuffer && (this._spriteBuffer.dispose(),
- this._spriteBuffer = null),
- this._indexBuffer && (this._engine._releaseBuffer(this._indexBuffer),
- this._indexBuffer = null),
- this._vertexArrayObject && (this._engine.releaseVertexArrayObject(this._vertexArrayObject),
- this._vertexArrayObject = null),
- this.texture && (this.texture.dispose(),
- this.texture = null),
- this._drawWrapperBase.dispose(),
- this._drawWrapperFog.dispose(),
- this._drawWrapperDepth.dispose(),
- this._drawWrapperFogDepth.dispose()
- }
- ,
- a
- }()
- , SpriteManager = function() {
- function a(e, i, o, s, c, d, _, b, k) {
- var j = this;
- d === void 0 && (d = .01),
- _ === void 0 && (_ = Texture.TRILINEAR_SAMPLINGMODE),
- b === void 0 && (b = !1),
- k === void 0 && (k = null),
- this.name = e,
- this.sprites = new Array,
- this.renderingGroupId = 0,
- this.layerMask = 268435455,
- this.isPickable = !1,
- this.onDisposeObservable = new Observable,
- this._disableDepthWrite = !1,
- this._packedAndReady = !1,
- this._customUpdate = function(_e, et) {
- _e.cellRef || (_e.cellIndex = 0);
- var tt = _e.cellIndex;
- typeof tt == "number" && isFinite(tt) && Math.floor(tt) === tt && (_e.cellRef = j._spriteMap[_e.cellIndex]),
- _e._xOffset = j._cellData[_e.cellRef].frame.x / et.width,
- _e._yOffset = j._cellData[_e.cellRef].frame.y / et.height,
- _e._xSize = j._cellData[_e.cellRef].frame.w,
- _e._ySize = j._cellData[_e.cellRef].frame.h
- }
- ,
- c || (c = Engine.LastCreatedScene),
- c._getComponent(SceneComponentConstants.NAME_SPRITE) || c._addComponent(new SpriteSceneComponent(c)),
- this._fromPacked = b,
- this._scene = c;
- var $ = this._scene.getEngine();
- if (this._spriteRenderer = new SpriteRenderer($,o,d,c),
- s.width && s.height)
- this.cellWidth = s.width,
- this.cellHeight = s.height;
- else if (s !== void 0)
- this.cellWidth = s,
- this.cellHeight = s;
- else {
- this._spriteRenderer = null;
- return
- }
- this._scene.spriteManagers.push(this),
- this.uniqueId = this.scene.getUniqueId(),
- i && (this.texture = new Texture(i,c,!0,!1,_)),
- this._fromPacked && this._makePacked(i, k)
- }
- return Object.defineProperty(a.prototype, "onDispose", {
- set: function(e) {
- this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver),
- this._onDisposeObserver = this.onDisposeObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "children", {
- get: function() {
- return this.sprites
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "scene", {
- get: function() {
- return this._scene
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "capacity", {
- get: function() {
- return this._spriteRenderer.capacity
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "texture", {
- get: function() {
- return this._spriteRenderer.texture
- },
- set: function(e) {
- e.wrapU = Texture.CLAMP_ADDRESSMODE,
- e.wrapV = Texture.CLAMP_ADDRESSMODE,
- this._spriteRenderer.texture = e,
- this._textureContent = null
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "cellWidth", {
- get: function() {
- return this._spriteRenderer.cellWidth
- },
- set: function(e) {
- this._spriteRenderer.cellWidth = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "cellHeight", {
- get: function() {
- return this._spriteRenderer.cellHeight
- },
- set: function(e) {
- this._spriteRenderer.cellHeight = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "fogEnabled", {
- get: function() {
- return this._spriteRenderer.fogEnabled
- },
- set: function(e) {
- this._spriteRenderer.fogEnabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "blendMode", {
- get: function() {
- return this._spriteRenderer.blendMode
- },
- set: function(e) {
- this._spriteRenderer.blendMode = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "disableDepthWrite", {
- get: function() {
- return this._disableDepthWrite
- },
- set: function(e) {
- this._disableDepthWrite = e,
- this._spriteRenderer.disableDepthWrite = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.getClassName = function() {
- return "SpriteManager"
- }
- ,
- a.prototype._makePacked = function(e, i) {
- var o = this;
- if (i !== null)
- try {
- var s = void 0;
- if (typeof i == "string" ? s = JSON.parse(i) : s = i,
- s.frames.length) {
- for (var c = {}, d = 0; d < s.frames.length; d++) {
- var _ = s.frames[d];
- if (typeof Object.keys(_)[0] != "string")
- throw new Error("Invalid JSON Format. Check the frame values and make sure the name is the first parameter.");
- var b = _[Object.keys(_)[0]];
- c[b] = _
- }
- s.frames = c
- }
- var k = Reflect.ownKeys(s.frames);
- this._spriteMap = k,
- this._packedAndReady = !0,
- this._cellData = s.frames
- } catch {
- throw this._fromPacked = !1,
- this._packedAndReady = !1,
- new Error("Invalid JSON from string. Spritesheet managed with constant cell size.")
- }
- else {
- var j = /\./g
- , $ = void 0;
- do
- $ = j.lastIndex,
- j.test(e);
- while (j.lastIndex > 0);
- var _e = e.substring(0, $ - 1) + ".json"
- , et = new XMLHttpRequest;
- et.open("GET", _e, !0),
- et.onerror = function() {
- Logger$2.Error("JSON ERROR: Unable to load JSON file."),
- o._fromPacked = !1,
- o._packedAndReady = !1
- }
- ,
- et.onload = function() {
- try {
- var tt = JSON.parse(et.response)
- , rt = Reflect.ownKeys(tt.frames);
- o._spriteMap = rt,
- o._packedAndReady = !0,
- o._cellData = tt.frames
- } catch {
- throw o._fromPacked = !1,
- o._packedAndReady = !1,
- new Error("Invalid JSON format. Please check documentation for format specifications.")
- }
- }
- ,
- et.send()
- }
- }
- ,
- a.prototype._checkTextureAlpha = function(e, i, o, s, c) {
- if (!e.useAlphaForPicking || !this.texture)
- return !0;
- var d = this.texture.getSize();
- this._textureContent || (this._textureContent = new Uint8Array(d.width * d.height * 4),
- this.texture.readPixels(0, 0, this._textureContent));
- var _ = TmpVectors.Vector3[0];
- _.copyFrom(i.direction),
- _.normalize(),
- _.scaleInPlace(o),
- _.addInPlace(i.origin);
- var b = (_.x - s.x) / (c.x - s.x) - .5
- , k = 1 - (_.y - s.y) / (c.y - s.y) - .5
- , j = e.angle
- , $ = .5 + (b * Math.cos(j) - k * Math.sin(j))
- , _e = .5 + (b * Math.sin(j) + k * Math.cos(j))
- , et = e._xOffset * d.width + $ * e._xSize | 0
- , tt = e._yOffset * d.height + _e * e._ySize | 0
- , rt = this._textureContent[(et + tt * d.width) * 4 + 3];
- return rt > .5
- }
- ,
- a.prototype.intersects = function(e, i, o, s) {
- 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++) {
- var it = this.sprites[rt];
- if (!!it) {
- if (o) {
- if (!o(it))
- continue
- } else if (!it.isPickable)
- continue;
- if (Vector3.TransformCoordinatesToRef(it.position, _e, $),
- it.angle ? (Matrix.TranslationToRef(-$.x, -$.y, 0, TmpVectors.Matrix[1]),
- Matrix.TranslationToRef($.x, $.y, 0, TmpVectors.Matrix[2]),
- Matrix.RotationZToRef(it.angle, TmpVectors.Matrix[3]),
- TmpVectors.Matrix[1].multiplyToRef(TmpVectors.Matrix[3], TmpVectors.Matrix[4]),
- TmpVectors.Matrix[4].multiplyToRef(TmpVectors.Matrix[2], TmpVectors.Matrix[0]),
- et = e.clone(),
- Vector3.TransformCoordinatesToRef(e.origin, TmpVectors.Matrix[0], et.origin),
- Vector3.TransformNormalToRef(e.direction, TmpVectors.Matrix[0], et.direction)) : et = e,
- d.copyFromFloats($.x - it.width / 2, $.y - it.height / 2, $.z),
- _.copyFromFloats($.x + it.width / 2, $.y + it.height / 2, $.z),
- et.intersectsBoxMinMax(d, _)) {
- var nt = Vector3.Distance($, et.origin);
- if (b > nt) {
- if (!this._checkTextureAlpha(it, et, nt, d, _))
- continue;
- if (tt = et,
- b = nt,
- k = it,
- s)
- break
- }
- }
- }
- }
- if (k) {
- var ot = new PickingInfo;
- _e.invertToRef(TmpVectors.Matrix[0]),
- ot.hit = !0,
- ot.pickedSprite = k,
- ot.distance = b;
- var at = TmpVectors.Vector3[2];
- return at.copyFrom(tt.direction),
- at.normalize(),
- at.scaleInPlace(b),
- tt.origin.addToRef(at, j),
- ot.pickedPoint = Vector3.TransformCoordinates(j, TmpVectors.Matrix[0]),
- ot
- }
- return null
- }
- ,
- a.prototype.multiIntersects = function(e, i, o) {
- 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++) {
- var et = this.sprites[_e];
- if (!!et) {
- if (o) {
- if (!o(et))
- continue
- } else if (!et.isPickable)
- continue;
- if (Vector3.TransformCoordinatesToRef(et.position, $, j),
- c.copyFromFloats(j.x - et.width / 2, j.y - et.height / 2, j.z),
- d.copyFromFloats(j.x + et.width / 2, j.y + et.height / 2, j.z),
- e.intersectsBoxMinMax(c, d)) {
- if (_ = Vector3.Distance(j, e.origin),
- !this._checkTextureAlpha(et, e, _, c, d))
- continue;
- var tt = new PickingInfo;
- b.push(tt),
- $.invertToRef(TmpVectors.Matrix[0]),
- tt.hit = !0,
- tt.pickedSprite = et,
- tt.distance = _;
- var rt = TmpVectors.Vector3[2];
- rt.copyFrom(e.direction),
- rt.normalize(),
- rt.scaleInPlace(_),
- e.origin.addToRef(rt, k),
- tt.pickedPoint = Vector3.TransformCoordinates(k, TmpVectors.Matrix[0])
- }
- }
- }
- return b
- }
- ,
- a.prototype.render = function() {
- if (!(this._fromPacked && (!this._packedAndReady || !this._spriteMap || !this._cellData))) {
- var e = 16.6;
- 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())
- }
- }
- ,
- a.prototype.rebuild = function() {
- var e;
- (e = this._spriteRenderer) === null || e === void 0 || e.rebuild()
- }
- ,
- a.prototype.dispose = function() {
- this._spriteRenderer && (this._spriteRenderer.dispose(),
- this._spriteRenderer = null),
- this._textureContent = null;
- var e = this._scene.spriteManagers.indexOf(this);
- this._scene.spriteManagers.splice(e, 1),
- this.onDisposeObservable.notifyObservers(this),
- this.onDisposeObservable.clear()
- }
- ,
- a.prototype.serialize = function(e) {
- e === void 0 && (e = !1);
- var i = {};
- i.name = this.name,
- i.capacity = this.capacity,
- i.cellWidth = this.cellWidth,
- i.cellHeight = this.cellHeight,
- this.texture && (e ? i.texture = this.texture.serialize() : (i.textureUrl = this.texture.name,
- i.invertY = this.texture._invertY)),
- i.sprites = [];
- for (var o = 0, s = this.sprites; o < s.length; o++) {
- var c = s[o];
- i.sprites.push(c.serialize())
- }
- return i
- }
- ,
- a.Parse = function(e, i, o) {
- var s = new a(e.name,"",e.capacity,{
- width: e.cellWidth,
- height: e.cellHeight
- },i);
- 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));
- for (var c = 0, d = e.sprites; c < d.length; c++) {
- var _ = d[c];
- Sprite.Parse(_, s)
- }
- return s
- }
- ,
- a.ParseFromFileAsync = function(e, i, o, s) {
- return s === void 0 && (s = ""),
- new Promise(function(c, d) {
- var _ = new WebRequest;
- _.addEventListener("readystatechange", function() {
- if (_.readyState == 4)
- if (_.status == 200) {
- var b = JSON.parse(_.responseText)
- , k = a.Parse(b, o || Engine.LastCreatedScene, s);
- e && (k.name = e),
- c(k)
- } else
- d("Unable to load the sprite manager")
- }),
- _.open("GET", i),
- _.send()
- }
- )
- }
- ,
- a.CreateFromSnippetAsync = function(e, i, o) {
- var s = this;
- return o === void 0 && (o = ""),
- e === "_BLANK" ? Promise.resolve(new a("Default sprite manager","//playground.babylonjs.com/textures/player.png",500,64,i)) : new Promise(function(c, d) {
- var _ = new WebRequest;
- _.addEventListener("readystatechange", function() {
- if (_.readyState == 4)
- if (_.status == 200) {
- var b = JSON.parse(JSON.parse(_.responseText).jsonPayload)
- , k = JSON.parse(b.spriteManager)
- , j = a.Parse(k, i || Engine.LastCreatedScene, o);
- j.snippetId = e,
- c(j)
- } else
- d("Unable to load the snippet " + e)
- }),
- _.open("GET", s.SnippetUrl + "/" + e.replace(/#/g, "/")),
- _.send()
- }
- )
- }
- ,
- a.SnippetUrl = "https://snippet.babylonjs.com",
- a
- }()
- , UtilityLayerRenderer = function() {
- function a(e, i) {
- var o = this;
- i === void 0 && (i = !0),
- this.originalScene = e,
- this._pointerCaptures = {},
- this._lastPointerEvents = {},
- this._sharedGizmoLight = null,
- this._renderCamera = null,
- this.pickUtilitySceneFirst = !0,
- this.shouldRender = !0,
- this.onlyCheckPointerDownEvents = !0,
- this.processAllEvents = !1,
- this.pickingEnabled = !0,
- this.onPointerOutObservable = new Observable,
- this.utilityLayerScene = new Scene(e.getEngine(),{
- virtual: !0
- }),
- this.utilityLayerScene.useRightHandedSystem = e.useRightHandedSystem,
- this.utilityLayerScene._allowPostProcessClearColor = !1,
- this.utilityLayerScene.detachControl(),
- i && (this._originalPointerObserver = e.onPrePointerObservable.add(function(s, c) {
- if (!!o.utilityLayerScene.activeCamera && !!o.pickingEnabled && !(!o.processAllEvents && s.type !== PointerEventTypes.POINTERMOVE && s.type !== PointerEventTypes.POINTERUP && s.type !== PointerEventTypes.POINTERDOWN && s.type !== PointerEventTypes.POINTERDOUBLETAP)) {
- o.utilityLayerScene.pointerX = e.pointerX,
- o.utilityLayerScene.pointerY = e.pointerY;
- var d = s.event;
- if (e.isPointerCaptured(d.pointerId)) {
- o._pointerCaptures[d.pointerId] = !1;
- return
- }
- var _ = function($) {
- var _e = null;
- if (s.nearInteractionPickingInfo)
- s.nearInteractionPickingInfo.pickedMesh.getScene() == $ ? _e = s.nearInteractionPickingInfo : _e = new PickingInfo;
- else {
- var et = null;
- o._renderCamera && (et = $._activeCamera,
- $._activeCamera = o._renderCamera,
- s.ray = null),
- _e = s.ray ? $.pickWithRay(s.ray) : $.pick(e.pointerX, e.pointerY),
- et && ($._activeCamera = et)
- }
- return _e
- }
- , b = _(o.utilityLayerScene);
- if (!s.ray && b && (s.ray = b.ray),
- o.utilityLayerScene.onPrePointerObservable.notifyObservers(s),
- o.onlyCheckPointerDownEvents && s.type != PointerEventTypes.POINTERDOWN) {
- s.skipOnPointerObservable || o.utilityLayerScene.onPointerObservable.notifyObservers(new PointerInfo(s.type,s.event,b), s.type),
- s.type === PointerEventTypes.POINTERUP && o._pointerCaptures[d.pointerId] && (o._pointerCaptures[d.pointerId] = !1);
- return
- }
- if (o.utilityLayerScene.autoClearDepthAndStencil || o.pickUtilitySceneFirst)
- b && b.hit && (s.skipOnPointerObservable || o.utilityLayerScene.onPointerObservable.notifyObservers(new PointerInfo(s.type,s.event,b), s.type),
- s.skipOnPointerObservable = !0);
- else {
- var k = _(e)
- , j = s.event;
- k && b && (b.distance === 0 && k.pickedMesh ? o.mainSceneTrackerPredicate && o.mainSceneTrackerPredicate(k.pickedMesh) ? (o._notifyObservers(s, k, j),
- 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),
- delete o._lastPointerEvents[j.pointerId]),
- o._notifyObservers(s, k, j)) : !o._pointerCaptures[j.pointerId] && (b.distance < k.distance || k.distance === 0) ? (o._notifyObservers(s, b, j),
- 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),
- s.skipOnPointerObservable = !0) : (s.type === PointerEventTypes.POINTERMOVE || s.type === PointerEventTypes.POINTERUP) && (o._lastPointerEvents[j.pointerId] && (o.onPointerOutObservable.notifyObservers(j.pointerId),
- delete o._lastPointerEvents[j.pointerId]),
- o._notifyObservers(s, b, j))),
- s.type === PointerEventTypes.POINTERUP && o._pointerCaptures[j.pointerId] && (o._pointerCaptures[j.pointerId] = !1))
- }
- }
- }),
- this._originalPointerObserver && e.onPrePointerObservable.makeObserverTopPriority(this._originalPointerObserver)),
- this.utilityLayerScene.autoClear = !1,
- this._afterRenderObserver = this.originalScene.onAfterCameraRenderObservable.add(function(s) {
- o.shouldRender && s == o.getRenderCamera() && o.render()
- }),
- this._sceneDisposeObserver = this.originalScene.onDisposeObservable.add(function() {
- o.dispose()
- }),
- this._updateCamera()
- }
- return a.prototype.getRenderCamera = function(e) {
- if (this._renderCamera)
- return this._renderCamera;
- var i = void 0;
- return this.originalScene.activeCameras && this.originalScene.activeCameras.length > 1 ? i = this.originalScene.activeCameras[this.originalScene.activeCameras.length - 1] : i = this.originalScene.activeCamera,
- e && i && i.isRigCamera ? i.rigParent : i
- }
- ,
- a.prototype.setRenderCamera = function(e) {
- this._renderCamera = e
- }
- ,
- a.prototype._getSharedGizmoLight = function() {
- return this._sharedGizmoLight || (this._sharedGizmoLight = new HemisphericLight("shared gizmo light",new Vector3(0,1,0),this.utilityLayerScene),
- this._sharedGizmoLight.intensity = 2,
- this._sharedGizmoLight.groundColor = Color3.Gray()),
- this._sharedGizmoLight
- }
- ,
- Object.defineProperty(a, "DefaultUtilityLayer", {
- get: function() {
- return a._DefaultUtilityLayer == null ? a._CreateDefaultUtilityLayerFromScene(EngineStore.LastCreatedScene) : a._DefaultUtilityLayer
- },
- enumerable: !1,
- configurable: !0
- }),
- a._CreateDefaultUtilityLayerFromScene = function(e) {
- return a._DefaultUtilityLayer = new a(e),
- a._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce(function() {
- a._DefaultUtilityLayer = null
- }),
- a._DefaultUtilityLayer
- }
- ,
- Object.defineProperty(a, "DefaultKeepDepthUtilityLayer", {
- get: function() {
- return a._DefaultKeepDepthUtilityLayer == null && (a._DefaultKeepDepthUtilityLayer = new a(EngineStore.LastCreatedScene),
- a._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = !1,
- a._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce(function() {
- a._DefaultKeepDepthUtilityLayer = null
- })),
- a._DefaultKeepDepthUtilityLayer
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._notifyObservers = function(e, i, o) {
- e.skipOnPointerObservable || (this.utilityLayerScene.onPointerObservable.notifyObservers(new PointerInfo(e.type,e.event,i), e.type),
- this._lastPointerEvents[o.pointerId] = !0)
- }
- ,
- a.prototype.render = function() {
- if (this._updateCamera(),
- this.utilityLayerScene.activeCamera) {
- var e = this.utilityLayerScene.activeCamera.getScene()
- , i = this.utilityLayerScene.activeCamera;
- i._scene = this.utilityLayerScene,
- i.leftCamera && (i.leftCamera._scene = this.utilityLayerScene),
- i.rightCamera && (i.rightCamera._scene = this.utilityLayerScene),
- this.utilityLayerScene.render(!1),
- i._scene = e,
- i.leftCamera && (i.leftCamera._scene = e),
- i.rightCamera && (i.rightCamera._scene = e)
- }
- }
- ,
- a.prototype.dispose = function() {
- this.onPointerOutObservable.clear(),
- this._afterRenderObserver && this.originalScene.onAfterCameraRenderObservable.remove(this._afterRenderObserver),
- this._sceneDisposeObserver && this.originalScene.onDisposeObservable.remove(this._sceneDisposeObserver),
- this._originalPointerObserver && this.originalScene.onPrePointerObservable.remove(this._originalPointerObserver),
- this.utilityLayerScene.dispose()
- }
- ,
- a.prototype._updateCamera = function() {
- this.utilityLayerScene.cameraToUseForPointers = this.getRenderCamera(),
- this.utilityLayerScene.activeCamera = this.getRenderCamera()
- }
- ,
- a._DefaultUtilityLayer = null,
- a._DefaultKeepDepthUtilityLayer = null,
- a
- }()
- , BaseSixDofDragBehavior = function() {
- function a() {
- this._attachedToElement = !1,
- this._virtualMeshesInfo = {},
- this._tmpVector = new Vector3,
- this._tmpQuaternion = new Quaternion,
- this._dragType = {
- NONE: 0,
- DRAG: 1,
- DRAG_WITH_CONTROLLER: 2,
- NEAR_DRAG: 3
- },
- this._moving = !1,
- this._dragging = this._dragType.NONE,
- this.draggableMeshes = null,
- this.zDragFactor = 3,
- this.currentDraggingPointerIds = [],
- this.detachCameraControls = !0,
- this.onDragStartObservable = new Observable,
- this.onDragObservable = new Observable,
- this.onDragEndObservable = new Observable,
- this.allowMultiPointer = !0
- }
- return Object.defineProperty(a.prototype, "currentDraggingPointerId", {
- get: function() {
- return this.currentDraggingPointerIds[0] !== void 0 ? this.currentDraggingPointerIds[0] : -1
- },
- set: function(e) {
- this.currentDraggingPointerIds[0] = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "currentDraggingPointerID", {
- get: function() {
- return this.currentDraggingPointerId
- },
- set: function(e) {
- this.currentDraggingPointerId = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "name", {
- get: function() {
- return "BaseSixDofDrag"
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "isMoving", {
- get: function() {
- return this._moving
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.init = function() {}
- ,
- Object.defineProperty(a.prototype, "_pointerCamera", {
- get: function() {
- return this._scene.cameraToUseForPointers ? this._scene.cameraToUseForPointers : this._scene.activeCamera
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._createVirtualMeshInfo = function() {
- var e = new AbstractMesh("",a._virtualScene);
- e.rotationQuaternion = new Quaternion;
- var i = new AbstractMesh("",a._virtualScene);
- i.rotationQuaternion = new Quaternion;
- var o = new AbstractMesh("",a._virtualScene);
- return o.rotationQuaternion = new Quaternion,
- {
- dragging: !1,
- moving: !1,
- dragMesh: e,
- originMesh: i,
- pivotMesh: o,
- startingPivotPosition: new Vector3,
- startingPivotOrientation: new Quaternion,
- startingPosition: new Vector3,
- startingOrientation: new Quaternion,
- lastOriginPosition: new Vector3,
- lastDragPosition: new Vector3
- }
- }
- ,
- a.prototype._resetVirtualMeshesPosition = function() {
- for (var e = 0; e < this.currentDraggingPointerIds.length; e++)
- this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].pivotMesh.position.copyFrom(this._ownerNode.getAbsolutePivotPoint()),
- this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].pivotMesh.rotationQuaternion.copyFrom(this._ownerNode.rotationQuaternion),
- this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].startingPivotPosition.copyFrom(this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].pivotMesh.position),
- this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].startingPivotOrientation.copyFrom(this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].pivotMesh.rotationQuaternion),
- this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].startingPosition.copyFrom(this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].dragMesh.position),
- this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].startingOrientation.copyFrom(this._virtualMeshesInfo[this.currentDraggingPointerIds[e]].dragMesh.rotationQuaternion)
- }
- ,
- a.prototype._pointerUpdate2D = function(e, i, o) {
- this._pointerCamera && this._pointerCamera.cameraRigMode == Camera$1.RIG_MODE_NONE && !this._pointerCamera._isLeftCamera && !this._pointerCamera._isRightCamera && (e.origin.copyFrom(this._pointerCamera.globalPosition),
- o = 0);
- var s = this._virtualMeshesInfo[i]
- , c = TmpVectors.Vector3[0];
- e.origin.subtractToRef(s.lastOriginPosition, c),
- s.lastOriginPosition.copyFrom(e.origin);
- var d = -Vector3.Dot(c, e.direction);
- s.originMesh.addChild(s.dragMesh),
- s.originMesh.addChild(s.pivotMesh),
- this._applyZOffset(s.dragMesh, d, o),
- this._applyZOffset(s.pivotMesh, d, o),
- s.originMesh.position.copyFrom(e.origin);
- var _ = TmpVectors.Vector3[0];
- e.origin.addToRef(e.direction, _),
- s.originMesh.lookAt(_),
- s.originMesh.removeChild(s.dragMesh),
- s.originMesh.removeChild(s.pivotMesh)
- }
- ,
- a.prototype._pointerUpdateXR = function(e, i, o, s) {
- var c = this._virtualMeshesInfo[o];
- c.originMesh.position.copyFrom(e.position),
- this._dragging === this._dragType.NEAR_DRAG && i ? c.originMesh.rotationQuaternion.copyFrom(i.rotationQuaternion) : c.originMesh.rotationQuaternion.copyFrom(e.rotationQuaternion);
- var d = TmpVectors.Vector3[0]
- , _ = TmpVectors.Vector3[1];
- d.copyFrom(this._pointerCamera.getForwardRay().direction),
- c.originMesh.position.subtractToRef(c.lastOriginPosition, _),
- c.lastOriginPosition.copyFrom(c.originMesh.position);
- var b = _.length();
- _.normalize(),
- c.pivotMesh.computeWorldMatrix(!0),
- c.dragMesh.computeWorldMatrix(!0);
- var k = TmpVectors.Vector3[2]
- , j = TmpVectors.Vector3[3];
- c.dragMesh.absolutePosition.subtractToRef(this._pointerCamera.globalPosition, k),
- c.dragMesh.absolutePosition.subtractToRef(c.originMesh.position, j);
- var $ = j.length();
- k.normalize(),
- j.normalize();
- var _e = Math.abs(Vector3.Dot(_, j)) * Vector3.Dot(_, d)
- , et = _e * s * b * $;
- et + $ < .1 && (et = Math.min($, .1)),
- j.scaleInPlace(et),
- j.addToRef(c.pivotMesh.absolutePosition, this._tmpVector),
- c.pivotMesh.setAbsolutePosition(this._tmpVector),
- j.addToRef(c.dragMesh.absolutePosition, this._tmpVector),
- c.dragMesh.setAbsolutePosition(this._tmpVector)
- }
- ,
- a.prototype.attach = function(e) {
- var i = this;
- this._ownerNode = e,
- this._scene = this._ownerNode.getScene(),
- a._virtualScene || (a._virtualScene = new Scene(this._scene.getEngine(),{
- virtual: !0
- }),
- a._virtualScene.detachControl());
- var o = function(s) {
- return i._ownerNode === s || s.isDescendantOf(i._ownerNode) && (!i.draggableMeshes || i.draggableMeshes.indexOf(s) !== -1)
- };
- this._pointerObserver = this._scene.onPointerObservable.add(function(s, c) {
- var d = s.event.pointerId;
- i._virtualMeshesInfo[d] || (i._virtualMeshesInfo[d] = i._createVirtualMeshInfo());
- var _ = i._virtualMeshesInfo[d]
- , b = s.event.pointerType === "xr";
- if (s.type == PointerEventTypes.POINTERDOWN) {
- if (!_.dragging && s.pickInfo && s.pickInfo.hit && s.pickInfo.pickedMesh && s.pickInfo.pickedPoint && s.pickInfo.ray && (!b || s.pickInfo.aimTransform) && o(s.pickInfo.pickedMesh)) {
- if (!i.allowMultiPointer && i.currentDraggingPointerIds.length > 0)
- return;
- i._pointerCamera && i._pointerCamera.cameraRigMode === Camera$1.RIG_MODE_NONE && !i._pointerCamera._isLeftCamera && !i._pointerCamera._isRightCamera && s.pickInfo.ray.origin.copyFrom(i._pointerCamera.globalPosition),
- i._ownerNode.computeWorldMatrix(!0);
- var k = i._virtualMeshesInfo[d];
- b ? (i._dragging = s.pickInfo.originMesh ? i._dragType.NEAR_DRAG : i._dragType.DRAG_WITH_CONTROLLER,
- k.originMesh.position.copyFrom(s.pickInfo.aimTransform.position),
- 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,
- k.originMesh.position.copyFrom(s.pickInfo.ray.origin)),
- k.lastOriginPosition.copyFrom(k.originMesh.position),
- k.dragMesh.position.copyFrom(s.pickInfo.pickedPoint),
- k.lastDragPosition.copyFrom(s.pickInfo.pickedPoint),
- k.pivotMesh.position.copyFrom(i._ownerNode.getAbsolutePivotPoint()),
- k.pivotMesh.rotationQuaternion.copyFrom(i._ownerNode.absoluteRotationQuaternion),
- k.startingPosition.copyFrom(k.dragMesh.position),
- k.startingPivotPosition.copyFrom(k.pivotMesh.position),
- k.startingOrientation.copyFrom(k.dragMesh.rotationQuaternion),
- k.startingPivotOrientation.copyFrom(k.pivotMesh.rotationQuaternion),
- b ? (k.originMesh.addChild(k.dragMesh),
- k.originMesh.addChild(k.pivotMesh)) : k.originMesh.lookAt(k.dragMesh.position),
- k.dragging = !0,
- i.currentDraggingPointerIds.indexOf(d) === -1 && i.currentDraggingPointerIds.push(d),
- i.detachCameraControls && i._pointerCamera && !i._pointerCamera.leftCamera && (i._pointerCamera.inputs && i._pointerCamera.inputs.attachedToElement ? (i._pointerCamera.detachControl(),
- i._attachedToElement = !0) : i._attachedToElement = !1),
- i._targetDragStart(k.pivotMesh.position, k.pivotMesh.rotationQuaternion, d),
- i.onDragStartObservable.notifyObservers({
- position: k.pivotMesh.position
- })
- }
- } else if (s.type == PointerEventTypes.POINTERUP || s.type == PointerEventTypes.POINTERDOUBLETAP) {
- var j = i.currentDraggingPointerIds.indexOf(d);
- _.dragging = !1,
- j !== -1 && (i.currentDraggingPointerIds.splice(j, 1),
- i.currentDraggingPointerIds.length === 0 && (i._moving = !1,
- i._dragging = i._dragType.NONE,
- i.detachCameraControls && i._attachedToElement && i._pointerCamera && !i._pointerCamera.leftCamera && (i._pointerCamera.attachControl(!0),
- i._attachedToElement = !1)),
- _.originMesh.removeChild(_.dragMesh),
- _.originMesh.removeChild(_.pivotMesh),
- i._targetDragEnd(d),
- i.onDragEndObservable.notifyObservers({}))
- } else if (s.type == PointerEventTypes.POINTERMOVE) {
- var j = i.currentDraggingPointerIds.indexOf(d);
- if (j !== -1 && _.dragging && s.pickInfo && (s.pickInfo.ray || s.pickInfo.aimTransform)) {
- var $ = i.zDragFactor;
- (i.currentDraggingPointerIds.length > 1 || s.pickInfo.originMesh) && ($ = 0),
- i._ownerNode.computeWorldMatrix(!0),
- b ? i._pointerUpdateXR(s.pickInfo.aimTransform, s.pickInfo.gripTransform, d, $) : i._pointerUpdate2D(s.pickInfo.ray, d, $),
- i._tmpQuaternion.copyFrom(_.startingPivotOrientation),
- i._tmpQuaternion.x = -i._tmpQuaternion.x,
- i._tmpQuaternion.y = -i._tmpQuaternion.y,
- i._tmpQuaternion.z = -i._tmpQuaternion.z,
- _.pivotMesh.absoluteRotationQuaternion.multiplyToRef(i._tmpQuaternion, i._tmpQuaternion),
- _.pivotMesh.absolutePosition.subtractToRef(_.startingPivotPosition, i._tmpVector),
- i.onDragObservable.notifyObservers({
- delta: i._tmpVector,
- position: _.pivotMesh.position,
- pickInfo: s.pickInfo
- }),
- i._targetDrag(i._tmpVector, i._tmpQuaternion, d),
- _.lastDragPosition.copyFrom(_.dragMesh.absolutePosition),
- i._moving = !0
- }
- }
- })
- }
- ,
- a.prototype._applyZOffset = function(e, i, o) {
- e.position.z -= e.position.z < 1 ? i * o : i * o * e.position.z,
- e.position.z < 0 && (e.position.z = 0)
- }
- ,
- a.prototype._targetDragStart = function(e, i, o) {}
- ,
- a.prototype._targetDrag = function(e, i, o) {}
- ,
- a.prototype._targetDragEnd = function(e) {}
- ,
- a.prototype.detach = function() {
- this._scene && (this.detachCameraControls && this._attachedToElement && this._pointerCamera && !this._pointerCamera.leftCamera && (this._pointerCamera.attachControl(!0),
- this._attachedToElement = !1),
- this._scene.onPointerObservable.remove(this._pointerObserver));
- for (var e in this._virtualMeshesInfo)
- this._virtualMeshesInfo[e].originMesh.dispose(),
- this._virtualMeshesInfo[e].dragMesh.dispose();
- this.onDragEndObservable.clear(),
- this.onDragObservable.clear(),
- this.onDragStartObservable.clear()
- }
- ,
- a
- }()
- , SixDofDragBehavior = function(a) {
- __extends(e, a);
- function e() {
- var i = a !== null && a.apply(this, arguments) || this;
- return i._sceneRenderObserver = null,
- i._targetPosition = new Vector3(0,0,0),
- i._targetOrientation = new Quaternion,
- i._targetScaling = new Vector3(1,1,1),
- i._startingPosition = new Vector3(0,0,0),
- i._startingOrientation = new Quaternion,
- i._startingScaling = new Vector3(1,1,1),
- i.onPositionChangedObservable = new Observable,
- i.dragDeltaRatio = .2,
- i.rotateDraggedObject = !0,
- i.rotateAroundYOnly = !1,
- i.rotateWithMotionController = !0,
- i.disableMovement = !1,
- i.faceCameraOnDragStart = !1,
- i
- }
- return Object.defineProperty(e.prototype, "name", {
- get: function() {
- return "SixDofDrag"
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.attach = function(i) {
- var o = this;
- a.prototype.attach.call(this, i),
- i.isNearGrabbable = !0,
- this._virtualTransformNode = new TransformNode("virtual_sixDof",BaseSixDofDragBehavior._virtualScene),
- this._virtualTransformNode.rotationQuaternion = Quaternion.Identity(),
- this._sceneRenderObserver = i.getScene().onBeforeRenderObservable.add(function() {
- if (o.currentDraggingPointerIds.length === 1 && o._moving && !o.disableMovement) {
- var s = i.parent;
- i.setParent(null),
- i.position.addInPlace(o._targetPosition.subtract(i.position).scale(o.dragDeltaRatio)),
- o.onPositionChangedObservable.notifyObservers({
- position: i.absolutePosition
- }),
- (!s || s.scaling && !s.scaling.isNonUniformWithinEpsilon(.001)) && Quaternion.SlerpToRef(i.rotationQuaternion, o._targetOrientation, o.dragDeltaRatio, i.rotationQuaternion),
- i.setParent(s)
- }
- })
- }
- ,
- e.prototype._getPositionOffsetAround = function(i, o, s) {
- var c = TmpVectors.Matrix[0]
- , d = TmpVectors.Matrix[1]
- , _ = TmpVectors.Matrix[2]
- , b = TmpVectors.Matrix[3]
- , k = TmpVectors.Matrix[4];
- return Matrix.TranslationToRef(i.x, i.y, i.z, c),
- Matrix.TranslationToRef(-i.x, -i.y, -i.z, d),
- Matrix.FromQuaternionToRef(s, _),
- Matrix.ScalingToRef(o, o, o, b),
- d.multiplyToRef(_, k),
- k.multiplyToRef(b, k),
- k.multiplyToRef(c, k),
- k.getTranslation()
- }
- ,
- e.prototype._onePointerPositionUpdated = function(i, o) {
- var s = TmpVectors.Vector3[0];
- s.setAll(0),
- this._dragging === this._dragType.DRAG ? this.rotateDraggedObject && (this.rotateAroundYOnly ? Quaternion.RotationYawPitchRollToRef(o.toEulerAngles().y, 0, 0, TmpVectors.Quaternion[0]) : TmpVectors.Quaternion[0].copyFrom(o),
- 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),
- this._targetPosition.copyFrom(this._startingPosition).addInPlace(i)
- }
- ,
- e.prototype._twoPointersPositionUpdated = function() {
- var i = this._virtualMeshesInfo[this.currentDraggingPointerIds[0]].startingPosition
- , o = this._virtualMeshesInfo[this.currentDraggingPointerIds[1]].startingPosition
- , s = TmpVectors.Vector3[0];
- i.addToRef(o, s),
- s.scaleInPlace(.5);
- var c = TmpVectors.Vector3[1];
- o.subtractToRef(i, c);
- var d = this._virtualMeshesInfo[this.currentDraggingPointerIds[0]].dragMesh.absolutePosition
- , _ = this._virtualMeshesInfo[this.currentDraggingPointerIds[1]].dragMesh.absolutePosition
- , b = TmpVectors.Vector3[2];
- d.addToRef(_, b),
- b.scaleInPlace(.5);
- var k = TmpVectors.Vector3[3];
- _.subtractToRef(d, k);
- var j = k.length() / c.length()
- , $ = b.subtract(s)
- , _e = Quaternion.FromEulerAngles(0, Vector3.GetAngleBetweenVectorsOnPlane(c.normalize(), k.normalize(), Vector3.UpReadOnly), 0)
- , et = this._ownerNode.parent;
- this._ownerNode.setParent(null);
- var tt = this._getPositionOffsetAround(s.subtract(this._virtualTransformNode.getAbsolutePivotPoint()), j, _e);
- this._virtualTransformNode.rotationQuaternion.multiplyToRef(_e, this._ownerNode.rotationQuaternion),
- this._virtualTransformNode.scaling.scaleToRef(j, this._ownerNode.scaling),
- this._virtualTransformNode.position.addToRef($.addInPlace(tt), this._ownerNode.position),
- this.onPositionChangedObservable.notifyObservers({
- position: this._ownerNode.position
- }),
- this._ownerNode.setParent(et)
- }
- ,
- e.prototype._targetDragStart = function() {
- var i = this.currentDraggingPointerIds.length
- , o = this._ownerNode.parent;
- this._ownerNode.rotationQuaternion || (this._ownerNode.rotationQuaternion = Quaternion.RotationYawPitchRoll(this._ownerNode.rotation.y, this._ownerNode.rotation.x, this._ownerNode.rotation.z));
- var s = this._ownerNode.getAbsolutePivotPoint();
- if (this._ownerNode.setParent(null),
- i === 1) {
- if (this._targetPosition.copyFrom(this._ownerNode.position),
- this._targetOrientation.copyFrom(this._ownerNode.rotationQuaternion),
- this._targetScaling.copyFrom(this._ownerNode.scaling),
- this.faceCameraOnDragStart && this._scene.activeCamera) {
- var c = TmpVectors.Vector3[0];
- this._scene.activeCamera.position.subtractToRef(s, c),
- c.normalize();
- var d = TmpVectors.Quaternion[0];
- this._scene.useRightHandedSystem ? Quaternion.FromLookDirectionRHToRef(c, new Vector3(0,1,0), d) : Quaternion.FromLookDirectionLHToRef(c, new Vector3(0,1,0), d),
- d.normalize(),
- Quaternion.RotationYawPitchRollToRef(d.toEulerAngles().y, 0, 0, TmpVectors.Quaternion[0]),
- this._targetOrientation.copyFrom(TmpVectors.Quaternion[0])
- }
- this._startingPosition.copyFrom(this._targetPosition),
- this._startingOrientation.copyFrom(this._targetOrientation),
- this._startingScaling.copyFrom(this._targetScaling)
- } else
- i === 2 && (this._virtualTransformNode.setPivotPoint(new Vector3(0,0,0), Space.LOCAL),
- this._virtualTransformNode.position.copyFrom(this._ownerNode.position),
- this._virtualTransformNode.scaling.copyFrom(this._ownerNode.scaling),
- this._virtualTransformNode.rotationQuaternion.copyFrom(this._ownerNode.rotationQuaternion),
- this._virtualTransformNode.setPivotPoint(s, Space.WORLD),
- this._resetVirtualMeshesPosition());
- this._ownerNode.setParent(o)
- }
- ,
- e.prototype._targetDrag = function(i, o, s) {
- this.currentDraggingPointerIds.length === 1 ? this._onePointerPositionUpdated(i, o) : this.currentDraggingPointerIds.length === 2 && this._twoPointersPositionUpdated()
- }
- ,
- e.prototype._targetDragEnd = function() {
- if (this.currentDraggingPointerIds.length === 1) {
- this._resetVirtualMeshesPosition();
- var i = this.faceCameraOnDragStart;
- this.faceCameraOnDragStart = !1,
- this._targetDragStart(),
- this.faceCameraOnDragStart = i
- }
- }
- ,
- e.prototype.detach = function() {
- a.prototype.detach.call(this),
- this._ownerNode && (this._ownerNode.isNearGrabbable = !1,
- this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver)),
- this._virtualTransformNode && this._virtualTransformNode.dispose()
- }
- ,
- e
- }(BaseSixDofDragBehavior)
- , Gizmo = function() {
- function a(e) {
- var i = this;
- e === void 0 && (e = UtilityLayerRenderer.DefaultUtilityLayer),
- this.gizmoLayer = e,
- this._attachedMesh = null,
- this._attachedNode = null,
- this._customRotationQuaternion = null,
- this._scaleRatio = 1,
- this._isHovered = !1,
- this._customMeshSet = !1,
- this._updateGizmoRotationToMatchAttachedMesh = !0,
- this.updateGizmoPositionToMatchAttachedMesh = !0,
- this.updateScale = !0,
- this._interactionsEnabled = !0,
- this._tempQuaternion = new Quaternion(0,0,0,1),
- this._tempVector = new Vector3,
- this._tempVector2 = new Vector3,
- this._tempMatrix1 = new Matrix,
- this._tempMatrix2 = new Matrix,
- this._rightHandtoLeftHandMatrix = Matrix.RotationY(Math.PI),
- this._rootMesh = new Mesh("gizmoRootNode",e.utilityLayerScene),
- this._rootMesh.rotationQuaternion = Quaternion.Identity(),
- this._beforeRenderObserver = this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add(function() {
- i._update()
- })
- }
- return Object.defineProperty(a.prototype, "scaleRatio", {
- get: function() {
- return this._scaleRatio
- },
- set: function(e) {
- this._scaleRatio = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "isHovered", {
- get: function() {
- return this._isHovered
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "attachedMesh", {
- get: function() {
- return this._attachedMesh
- },
- set: function(e) {
- this._attachedMesh = e,
- e && (this._attachedNode = e),
- this._rootMesh.setEnabled(!!e),
- this._attachedNodeChanged(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "attachedNode", {
- get: function() {
- return this._attachedNode
- },
- set: function(e) {
- this._attachedNode = e,
- this._attachedMesh = null,
- this._rootMesh.setEnabled(!!e),
- this._attachedNodeChanged(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.setCustomMesh = function(e) {
- if (e.getScene() != this.gizmoLayer.utilityLayerScene)
- throw "When setting a custom mesh on a gizmo, the custom meshes scene must be the same as the gizmos (eg. gizmo.gizmoLayer.utilityLayerScene)";
- this._rootMesh.getChildMeshes().forEach(function(i) {
- i.dispose()
- }),
- e.parent = this._rootMesh,
- this._customMeshSet = !0
- }
- ,
- Object.defineProperty(a.prototype, "updateGizmoRotationToMatchAttachedMesh", {
- get: function() {
- return this._updateGizmoRotationToMatchAttachedMesh
- },
- set: function(e) {
- this._updateGizmoRotationToMatchAttachedMesh = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._attachedNodeChanged = function(e) {}
- ,
- Object.defineProperty(a.prototype, "customRotationQuaternion", {
- get: function() {
- return this._customRotationQuaternion
- },
- set: function(e) {
- this._customRotationQuaternion = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._update = function() {
- if (this.attachedNode) {
- var e = this.attachedNode;
- if (this.attachedMesh && (e = this.attachedMesh._effectiveMesh || this.attachedNode),
- this.updateGizmoPositionToMatchAttachedMesh) {
- var i = e.getWorldMatrix().getRow(3)
- , o = i ? i.toVector3() : new Vector3(0,0,0);
- this._rootMesh.position.copyFrom(o)
- }
- 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),
- this.updateScale) {
- var s = this.gizmoLayer.utilityLayerScene.activeCamera
- , c = s.globalPosition;
- s.devicePosition && (c = s.devicePosition),
- this._rootMesh.position.subtractToRef(c, this._tempVector);
- var d = this._tempVector.length() * this.scaleRatio;
- this._rootMesh.scaling.set(d, d, d),
- e._getWorldMatrixDeterminant() < 0 && (this._rootMesh.scaling.y *= -1)
- } else
- this._rootMesh.scaling.setAll(this.scaleRatio)
- }
- }
- ,
- a.prototype._handlePivot = function() {
- var e = this._attachedNode;
- e.isUsingPivotMatrix && e.isUsingPivotMatrix() && e.position && e.getWorldMatrix().setTranslation(e.position)
- }
- ,
- a.prototype._matrixChanged = function() {
- if (!!this._attachedNode)
- if (this._attachedNode._isCamera) {
- var e = this._attachedNode, i, o;
- if (e.parent) {
- var s = this._tempMatrix2;
- e.parent._worldMatrix.invertToRef(s),
- this._attachedNode._worldMatrix.multiplyToRef(s, this._tempMatrix1),
- i = this._tempMatrix1
- } else
- i = this._attachedNode._worldMatrix;
- e.getScene().useRightHandedSystem ? (this._rightHandtoLeftHandMatrix.multiplyToRef(i, this._tempMatrix2),
- o = this._tempMatrix2) : o = i,
- o.decompose(this._tempVector2, this._tempQuaternion, this._tempVector);
- 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";
- if (c) {
- var d = this._attachedNode;
- d.rotation = this._tempQuaternion.toEulerAngles(),
- d.rotationQuaternion && (d.rotationQuaternion.copyFrom(this._tempQuaternion),
- d.rotationQuaternion.normalize())
- }
- e.position.copyFrom(this._tempVector)
- } else if (this._attachedNode._isMesh || this._attachedNode.getClassName() === "AbstractMesh" || this._attachedNode.getClassName() === "TransformNode" || this._attachedNode.getClassName() === "InstancedMesh") {
- var _ = this._attachedNode;
- if (_.parent) {
- var s = this._tempMatrix1
- , b = this._tempMatrix2;
- _.parent.getWorldMatrix().invertToRef(s),
- this._attachedNode.getWorldMatrix().multiplyToRef(s, b),
- b.decompose(_.scaling, this._tempQuaternion, _.position)
- } else
- this._attachedNode._worldMatrix.decompose(_.scaling, this._tempQuaternion, _.position);
- _.billboardMode || (_.rotationQuaternion ? (_.rotationQuaternion.copyFrom(this._tempQuaternion),
- _.rotationQuaternion.normalize()) : _.rotation = this._tempQuaternion.toEulerAngles())
- } else if (this._attachedNode.getClassName() === "Bone") {
- var k = this._attachedNode
- , j = k.getParent();
- if (j) {
- var $ = this._tempMatrix1
- , _e = this._tempMatrix2;
- j.getWorldMatrix().invertToRef($),
- k.getWorldMatrix().multiplyToRef($, _e);
- var et = k.getLocalMatrix();
- et.copyFrom(_e)
- } else {
- var et = k.getLocalMatrix();
- et.copyFrom(k.getWorldMatrix())
- }
- k.markAsDirty()
- } else {
- var tt = this._attachedNode;
- if (tt.getTypeID) {
- var rt = tt.getTypeID();
- if (rt === Light.LIGHTTYPEID_DIRECTIONALLIGHT || rt === Light.LIGHTTYPEID_SPOTLIGHT || rt === Light.LIGHTTYPEID_POINTLIGHT) {
- var it = tt.parent;
- if (it) {
- var $ = this._tempMatrix1
- , nt = this._tempMatrix2;
- it.getWorldMatrix().invertToRef($),
- tt.getWorldMatrix().multiplyToRef($, nt),
- nt.decompose(void 0, this._tempQuaternion, this._tempVector)
- } else
- this._attachedNode._worldMatrix.decompose(void 0, this._tempQuaternion, this._tempVector);
- tt.position = new Vector3(this._tempVector.x,this._tempVector.y,this._tempVector.z),
- Vector3.Backward(!1).rotateByQuaternionToRef(this._tempQuaternion, this._tempVector),
- tt.direction = new Vector3(this._tempVector.x,this._tempVector.y,this._tempVector.z)
- }
- }
- }
- }
- ,
- a.prototype._setGizmoMeshMaterial = function(e, i) {
- e && e.forEach(function(o) {
- o.material = i,
- o.color && (o.color = i.diffuseColor)
- })
- }
- ,
- a.GizmoAxisPointerObserver = function(e, i) {
- var o = !1
- , s = e.utilityLayerScene.onPointerObservable.add(function(c) {
- var d, _;
- if (c.pickInfo) {
- if (c.type === PointerEventTypes.POINTERMOVE) {
- if (o)
- return;
- i.forEach(function(k) {
- var j, $;
- if (k.colliderMeshes && k.gizmoMeshes) {
- 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
- , et = k.dragBehavior.enabled ? _e || k.active ? k.hoverMaterial : k.material : k.disableMaterial;
- k.gizmoMeshes.forEach(function(tt) {
- tt.material = et,
- tt.color && (tt.color = et.diffuseColor)
- })
- }
- })
- }
- if (c.type === PointerEventTypes.POINTERDOWN && i.has((d = c.pickInfo.pickedMesh) === null || d === void 0 ? void 0 : d.parent)) {
- o = !0;
- var b = i.get((_ = c.pickInfo.pickedMesh) === null || _ === void 0 ? void 0 : _.parent);
- b.active = !0,
- i.forEach(function(k) {
- 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;
- k.gizmoMeshes.forEach(function(tt) {
- tt.material = et,
- tt.color && (tt.color = et.diffuseColor)
- })
- })
- }
- c.type === PointerEventTypes.POINTERUP && i.forEach(function(k) {
- k.active = !1,
- o = !1,
- k.gizmoMeshes.forEach(function(j) {
- j.material = k.dragBehavior.enabled ? k.material : k.disableMaterial,
- j.color && (j.color = k.material.diffuseColor)
- })
- })
- }
- });
- return s
- }
- ,
- a.prototype.dispose = function() {
- this._rootMesh.dispose(),
- this._beforeRenderObserver && this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver)
- }
- ,
- a
- }()
- , PivotTools = function() {
- function a() {}
- return a._RemoveAndStorePivotPoint = function(e) {
- e && a._PivotCached === 0 && (e.getPivotPointToRef(a._OldPivotPoint),
- a._PivotPostMultiplyPivotMatrix = e._postMultiplyPivotMatrix,
- a._OldPivotPoint.equalsToFloats(0, 0, 0) || (e.setPivotMatrix(Matrix.IdentityReadOnly),
- a._OldPivotPoint.subtractToRef(e.getPivotPoint(), a._PivotTranslation),
- a._PivotTmpVector.copyFromFloats(1, 1, 1),
- a._PivotTmpVector.subtractInPlace(e.scaling),
- a._PivotTmpVector.multiplyInPlace(a._PivotTranslation),
- e.position.addInPlace(a._PivotTmpVector))),
- a._PivotCached++
- }
- ,
- a._RestorePivotPoint = function(e) {
- e && !a._OldPivotPoint.equalsToFloats(0, 0, 0) && a._PivotCached === 1 && (e.setPivotPoint(a._OldPivotPoint),
- e._postMultiplyPivotMatrix = a._PivotPostMultiplyPivotMatrix,
- a._PivotTmpVector.copyFromFloats(1, 1, 1),
- a._PivotTmpVector.subtractInPlace(e.scaling),
- a._PivotTmpVector.multiplyInPlace(a._PivotTranslation),
- e.position.subtractInPlace(a._PivotTmpVector)),
- this._PivotCached--
- }
- ,
- a._PivotCached = 0,
- a._OldPivotPoint = new Vector3,
- a._PivotTranslation = new Vector3,
- a._PivotTmpVector = new Vector3,
- a._PivotPostMultiplyPivotMatrix = !1,
- a
- }()
- , PointerDragBehavior = function() {
- function a(e) {
- this._useAlternatePickedPointAboveMaxDragAngleDragSpeed = -1.1,
- this.maxDragAngle = 0,
- this._useAlternatePickedPointAboveMaxDragAngle = !1,
- this.currentDraggingPointerId = -1,
- this.dragging = !1,
- this.dragDeltaRatio = .2,
- this.updateDragPlane = !0,
- this._debugMode = !1,
- this._moving = !1,
- this.onDragObservable = new Observable,
- this.onDragStartObservable = new Observable,
- this.onDragEndObservable = new Observable,
- this.onEnabledObservable = new Observable,
- this.moveAttached = !0,
- this._enabled = !0,
- this.startAndReleaseDragOnPointerEvents = !0,
- this.detachCameraControls = !0,
- this.useObjectOrientationForDragging = !0,
- this.validateDrag = function(o) {
- return !0
- }
- ,
- this._tmpVector = new Vector3(0,0,0),
- this._alternatePickedPoint = new Vector3(0,0,0),
- this._worldDragAxis = new Vector3(0,0,0),
- this._targetPosition = new Vector3(0,0,0),
- this._attachedToElement = !1,
- this._startDragRay = new Ray(new Vector3,new Vector3),
- this._lastPointerRay = {},
- this._dragDelta = new Vector3,
- this._pointA = new Vector3(0,0,0),
- this._pointC = new Vector3(0,0,0),
- this._localAxis = new Vector3(0,0,0),
- this._lookAt = new Vector3(0,0,0),
- this._options = e || {};
- var i = 0;
- if (this._options.dragAxis && i++,
- this._options.dragPlaneNormal && i++,
- i > 1)
- throw "Multiple drag modes specified in dragBehavior options. Only one expected"
- }
- return Object.defineProperty(a.prototype, "currentDraggingPointerID", {
- get: function() {
- return this.currentDraggingPointerId
- },
- set: function(e) {
- this.currentDraggingPointerId = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "enabled", {
- get: function() {
- return this._enabled
- },
- set: function(e) {
- e != this._enabled && this.onEnabledObservable.notifyObservers(e),
- this._enabled = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "options", {
- get: function() {
- return this._options
- },
- set: function(e) {
- this._options = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "name", {
- get: function() {
- return "PointerDrag"
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.init = function() {}
- ,
- a.prototype.attach = function(e, i) {
- var o = this;
- this._scene = e.getScene(),
- e.isNearGrabbable = !0,
- this.attachedNode = e,
- a._planeScene || (this._debugMode ? a._planeScene = this._scene : (a._planeScene = new Scene(this._scene.getEngine(),{
- virtual: !0
- }),
- a._planeScene.detachControl(),
- this._scene.onDisposeObservable.addOnce(function() {
- a._planeScene.dispose(),
- a._planeScene = null
- }))),
- this._dragPlane = CreatePlane("pointerDragPlane", {
- size: this._debugMode ? 1 : 1e4,
- updatable: !1,
- sideOrientation: Mesh.DOUBLESIDE
- }, a._planeScene),
- this.lastDragPosition = new Vector3(0,0,0);
- var s = i || function(c) {
- return o.attachedNode == c || c.isDescendantOf(o.attachedNode)
- }
- ;
- this._pointerObserver = this._scene.onPointerObservable.add(function(c, d) {
- if (!o.enabled) {
- o._attachedToElement && o.releaseDrag();
- return
- }
- if (c.type == PointerEventTypes.POINTERDOWN)
- 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);
- else if (c.type == PointerEventTypes.POINTERUP)
- o.startAndReleaseDragOnPointerEvents && o.currentDraggingPointerId == c.event.pointerId && o.releaseDrag();
- else if (c.type == PointerEventTypes.POINTERMOVE) {
- var _ = c.event.pointerId;
- if (o.currentDraggingPointerId === a._AnyMouseId && _ !== a._AnyMouseId) {
- var b = c.event
- , k = b.pointerType === "mouse" || !o._scene.getEngine().hostInformation.isMobile && b instanceof MouseEvent;
- k && (o._lastPointerRay[o.currentDraggingPointerId] && (o._lastPointerRay[_] = o._lastPointerRay[o.currentDraggingPointerId],
- delete o._lastPointerRay[o.currentDraggingPointerId]),
- o.currentDraggingPointerId = _)
- }
- o._lastPointerRay[_] || (o._lastPointerRay[_] = new Ray(new Vector3,new Vector3)),
- c.pickInfo && c.pickInfo.ray && (o._lastPointerRay[_].origin.copyFrom(c.pickInfo.ray.origin),
- o._lastPointerRay[_].direction.copyFrom(c.pickInfo.ray.direction),
- o.currentDraggingPointerId == _ && o.dragging && o._moveDrag(c.pickInfo.ray))
- }
- }),
- this._beforeRenderObserver = this._scene.onBeforeRenderObservable.add(function() {
- o._moving && o.moveAttached && (PivotTools._RemoveAndStorePivotPoint(o.attachedNode),
- o._targetPosition.subtractToRef(o.attachedNode.absolutePosition, o._tmpVector),
- o._tmpVector.scaleInPlace(o.dragDeltaRatio),
- o.attachedNode.getAbsolutePosition().addToRef(o._tmpVector, o._tmpVector),
- o.validateDrag(o._tmpVector) && o.attachedNode.setAbsolutePosition(o._tmpVector),
- PivotTools._RestorePivotPoint(o.attachedNode))
- })
- }
- ,
- a.prototype.releaseDrag = function() {
- if (this.dragging && (this.dragging = !1,
- this.onDragEndObservable.notifyObservers({
- dragPlanePoint: this.lastDragPosition,
- pointerId: this.currentDraggingPointerId
- })),
- this.currentDraggingPointerId = -1,
- this._moving = !1,
- this.detachCameraControls && this._attachedToElement && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
- if (this._scene.activeCamera.getClassName() === "ArcRotateCamera") {
- var e = this._scene.activeCamera;
- e.attachControl(e.inputs ? e.inputs.noPreventDefault : !0, e._useCtrlForPanning, e._panningMouseButton)
- } else
- this._scene.activeCamera.attachControl(this._scene.activeCamera.inputs ? this._scene.activeCamera.inputs.noPreventDefault : !0);
- this._attachedToElement = !1
- }
- }
- ,
- a.prototype.startDrag = function(e, i, o) {
- e === void 0 && (e = a._AnyMouseId),
- this._startDrag(e, i, o);
- var s = this._lastPointerRay[e];
- e === a._AnyMouseId && (s = this._lastPointerRay[Object.keys(this._lastPointerRay)[0]]),
- s && this._moveDrag(s)
- }
- ,
- a.prototype._startDrag = function(e, i, o) {
- if (!(!this._scene.activeCamera || this.dragging || !this.attachedNode)) {
- PivotTools._RemoveAndStorePivotPoint(this.attachedNode),
- i ? (this._startDragRay.direction.copyFrom(i.direction),
- this._startDragRay.origin.copyFrom(i.origin)) : (this._startDragRay.origin.copyFrom(this._scene.activeCamera.position),
- this.attachedNode.getWorldMatrix().getTranslationToRef(this._tmpVector),
- this._tmpVector.subtractToRef(this._scene.activeCamera.position, this._startDragRay.direction)),
- this._updateDragPlanePosition(this._startDragRay, o || this._tmpVector);
- var s = this._pickWithRayOnDragPlane(this._startDragRay);
- s && (this.dragging = !0,
- this.currentDraggingPointerId = e,
- this.lastDragPosition.copyFrom(s),
- this.onDragStartObservable.notifyObservers({
- dragPlanePoint: s,
- pointerId: this.currentDraggingPointerId
- }),
- this._targetPosition.copyFrom(this.attachedNode.getAbsolutePosition()),
- this.detachCameraControls && this._scene.activeCamera && this._scene.activeCamera.inputs && !this._scene.activeCamera.leftCamera && (this._scene.activeCamera.inputs.attachedToElement ? (this._scene.activeCamera.detachControl(),
- this._attachedToElement = !0) : this._attachedToElement = !1)),
- PivotTools._RestorePivotPoint(this.attachedNode)
- }
- }
- ,
- a.prototype._moveDrag = function(e) {
- this._moving = !0;
- var i = this._pickWithRayOnDragPlane(e);
- if (i) {
- this.updateDragPlane && this._updateDragPlanePosition(e, i);
- var o = 0;
- this._options.dragAxis ? (this.useObjectOrientationForDragging ? Vector3.TransformCoordinatesToRef(this._options.dragAxis, this.attachedNode.getWorldMatrix().getRotationMatrix(), this._worldDragAxis) : this._worldDragAxis.copyFrom(this._options.dragAxis),
- i.subtractToRef(this.lastDragPosition, this._tmpVector),
- o = Vector3.Dot(this._tmpVector, this._worldDragAxis),
- this._worldDragAxis.scaleToRef(o, this._dragDelta)) : (o = this._dragDelta.length(),
- i.subtractToRef(this.lastDragPosition, this._dragDelta)),
- this._targetPosition.addInPlace(this._dragDelta),
- this.onDragObservable.notifyObservers({
- dragDistance: o,
- delta: this._dragDelta,
- dragPlanePoint: i,
- dragPlaneNormal: this._dragPlane.forward,
- pointerId: this.currentDraggingPointerId
- }),
- this.lastDragPosition.copyFrom(i)
- }
- }
- ,
- a.prototype._pickWithRayOnDragPlane = function(e) {
- var i = this;
- if (!e)
- return null;
- var o = Math.acos(Vector3.Dot(this._dragPlane.forward, e.direction));
- if (o > Math.PI / 2 && (o = Math.PI - o),
- this.maxDragAngle > 0 && o > this.maxDragAngle)
- if (this._useAlternatePickedPointAboveMaxDragAngle) {
- this._tmpVector.copyFrom(e.direction),
- this.attachedNode.absolutePosition.subtractToRef(e.origin, this._alternatePickedPoint),
- this._alternatePickedPoint.normalize(),
- this._alternatePickedPoint.scaleInPlace(this._useAlternatePickedPointAboveMaxDragAngleDragSpeed * Vector3.Dot(this._alternatePickedPoint, this._tmpVector)),
- this._tmpVector.addInPlace(this._alternatePickedPoint);
- var s = Vector3.Dot(this._dragPlane.forward, this._tmpVector);
- return this._dragPlane.forward.scaleToRef(-s, this._alternatePickedPoint),
- this._alternatePickedPoint.addInPlace(this._tmpVector),
- this._alternatePickedPoint.addInPlace(this.attachedNode.absolutePosition),
- this._alternatePickedPoint
- } else
- return null;
- var c = a._planeScene.pickWithRay(e, function(d) {
- return d == i._dragPlane
- });
- return c && c.hit && c.pickedMesh && c.pickedPoint ? c.pickedPoint : null
- }
- ,
- a.prototype._updateDragPlanePosition = function(e, i) {
- this._pointA.copyFrom(i),
- this._options.dragAxis ? (this.useObjectOrientationForDragging ? Vector3.TransformCoordinatesToRef(this._options.dragAxis, this.attachedNode.getWorldMatrix().getRotationMatrix(), this._localAxis) : this._localAxis.copyFrom(this._options.dragAxis),
- e.origin.subtractToRef(this._pointA, this._pointC),
- this._pointC.normalize(),
- 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),
- Vector3.CrossToRef(this._localAxis, this._lookAt, this._lookAt),
- this._lookAt.normalize()),
- this._dragPlane.position.copyFrom(this._pointA),
- this._pointA.addToRef(this._lookAt, this._lookAt),
- 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),
- this._dragPlane.position.copyFrom(this._pointA),
- this._pointA.addToRef(this._localAxis, this._lookAt),
- this._dragPlane.lookAt(this._lookAt)) : (this._dragPlane.position.copyFrom(this._pointA),
- this._dragPlane.lookAt(e.origin)),
- this._dragPlane.position.copyFrom(this.attachedNode.getAbsolutePosition()),
- this._dragPlane.computeWorldMatrix(!0)
- }
- ,
- a.prototype.detach = function() {
- this.attachedNode.isNearGrabbable = !1,
- this._pointerObserver && this._scene.onPointerObservable.remove(this._pointerObserver),
- this._beforeRenderObserver && this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver),
- this._dragPlane.dispose(),
- this.releaseDrag()
- }
- ,
- a._AnyMouseId = -2,
- a
- }()
- , PlaneRotationGizmo = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _, b) {
- o === void 0 && (o = Color3.Gray()),
- s === void 0 && (s = UtilityLayerRenderer.DefaultUtilityLayer),
- c === void 0 && (c = 32),
- d === void 0 && (d = null),
- b === void 0 && (b = 1);
- var k, j = a.call(this, s) || this;
- j._pointerObserver = null,
- j.snapDistance = 0,
- j.onSnapObservable = new Observable,
- j.angle = 0,
- j._isEnabled = !0,
- j._parent = null,
- j._dragging = !1,
- j._angles = new Vector3,
- j._parent = d,
- j._coloredMaterial = new StandardMaterial("",s.utilityLayerScene),
- j._coloredMaterial.diffuseColor = o,
- j._coloredMaterial.specularColor = o.subtract(new Color3(.1,.1,.1)),
- j._hoverMaterial = new StandardMaterial("",s.utilityLayerScene),
- j._hoverMaterial.diffuseColor = Color3.Yellow(),
- j._disableMaterial = new StandardMaterial("",s.utilityLayerScene),
- j._disableMaterial.diffuseColor = Color3.Gray(),
- j._disableMaterial.alpha = .4,
- j._gizmoMesh = new Mesh("",s.utilityLayerScene);
- var $ = j._createGizmoMesh(j._gizmoMesh, b, c)
- , _e = $.rotationMesh
- , et = $.collider;
- j._rotationDisplayPlane = CreatePlane("rotationDisplay", {
- size: .6,
- updatable: !1
- }, j.gizmoLayer.utilityLayerScene),
- j._rotationDisplayPlane.rotation.z = Math.PI * .5,
- j._rotationDisplayPlane.parent = j._gizmoMesh,
- j._rotationDisplayPlane.setEnabled(!1),
- Effect.ShadersStore.rotationGizmoVertexShader = e._rotationGizmoVertexShader,
- Effect.ShadersStore.rotationGizmoFragmentShader = e._rotationGizmoFragmentShader,
- j._rotationShaderMaterial = new ShaderMaterial("shader",j.gizmoLayer.utilityLayerScene,{
- vertex: "rotationGizmo",
- fragment: "rotationGizmo"
- },{
- attributes: ["position", "uv"],
- uniforms: ["worldViewProjection", "angles"]
- }),
- j._rotationShaderMaterial.backFaceCulling = !1,
- j._rotationDisplayPlane.material = j._rotationShaderMaterial,
- j._rotationDisplayPlane.visibility = .999,
- j._gizmoMesh.lookAt(j._rootMesh.position.add(i)),
- j._rootMesh.addChild(j._gizmoMesh),
- j._gizmoMesh.scaling.scaleInPlace(1 / 3),
- j.dragBehavior = new PointerDragBehavior({
- dragPlaneNormal: i
- }),
- j.dragBehavior.moveAttached = !1,
- j.dragBehavior.maxDragAngle = e.MaxDragAngle,
- j.dragBehavior._useAlternatePickedPointAboveMaxDragAngle = !0,
- j._rootMesh.addBehavior(j.dragBehavior);
- var tt = new Vector3
- , rt = new Matrix
- , it = new Vector3
- , nt = new Vector3;
- j.dragBehavior.onDragStartObservable.add(function(ft) {
- j.attachedNode && (tt.copyFrom(ft.dragPlanePoint),
- j._rotationDisplayPlane.setEnabled(!0),
- j._rotationDisplayPlane.getWorldMatrix().invertToRef(rt),
- Vector3.TransformCoordinatesToRef(ft.dragPlanePoint, rt, tt),
- j._angles.x = Math.atan2(tt.y, tt.x) + Math.PI,
- j._angles.y = 0,
- j._angles.z = j.updateGizmoRotationToMatchAttachedMesh ? 1 : 0,
- j._dragging = !0,
- tt.copyFrom(ft.dragPlanePoint),
- j._rotationShaderMaterial.setVector3("angles", j._angles),
- j.angle = 0)
- }),
- j.dragBehavior.onDragEndObservable.add(function() {
- j._dragging = !1,
- j._rotationDisplayPlane.setEnabled(!1)
- });
- var ot = {
- snapDistance: 0
- }
- , at = 0
- , st = new Matrix
- , ut = new Quaternion;
- j.dragBehavior.onDragObservable.add(function(ft) {
- if (j.attachedNode) {
- var ht = new Vector3(1,1,1)
- , pt = new Quaternion(0,0,0,1)
- , dt = new Vector3(0,0,0);
- j._handlePivot(),
- j.attachedNode.getWorldMatrix().decompose(ht, pt, dt);
- var _t = ft.dragPlanePoint.subtract(dt).normalize()
- , mt = tt.subtract(dt).normalize()
- , vt = Vector3.Cross(_t, mt)
- , yt = Vector3.Dot(_t, mt)
- , Et = Math.atan2(vt.length(), yt);
- it.copyFrom(i),
- nt.copyFrom(i),
- j.updateGizmoRotationToMatchAttachedMesh && (pt.toRotationMatrix(rt),
- nt = Vector3.TransformCoordinates(it, rt));
- var At = !1;
- if (s.utilityLayerScene.activeCamera) {
- var gt = s.utilityLayerScene.activeCamera.position.subtract(dt).normalize();
- Vector3.Dot(gt, nt) > 0 && (it.scaleInPlace(-1),
- nt.scaleInPlace(-1),
- At = !0)
- }
- var St = Vector3.Dot(nt, vt) > 0;
- St && (Et = -Et);
- var xt = !1;
- if (j.snapDistance != 0)
- if (at += Et,
- Math.abs(at) > j.snapDistance) {
- var bt = Math.floor(Math.abs(at) / j.snapDistance);
- at < 0 && (bt *= -1),
- at = at % j.snapDistance,
- Et = j.snapDistance * bt,
- xt = !0
- } else
- Et = 0;
- var Rt = Math.sin(Et / 2);
- if (ut.set(it.x * Rt, it.y * Rt, it.z * Rt, Math.cos(Et / 2)),
- st.determinant() > 0) {
- var Mt = new Vector3;
- ut.toEulerAnglesToRef(Mt),
- Quaternion.RotationYawPitchRollToRef(Mt.y, -Mt.x, -Mt.z, ut)
- }
- j.updateGizmoRotationToMatchAttachedMesh ? pt.multiplyToRef(ut, pt) : ut.multiplyToRef(pt, pt),
- j.attachedNode.getWorldMatrix().copyFrom(Matrix.Compose(ht, pt, dt)),
- tt.copyFrom(ft.dragPlanePoint),
- xt && (ot.snapDistance = Et,
- j.onSnapObservable.notifyObservers(ot)),
- j._angles.y += Et,
- j.angle += At ? -Et : Et,
- j._rotationShaderMaterial.setVector3("angles", j._angles),
- j._matrixChanged()
- }
- });
- var ct = s._getSharedGizmoLight();
- ct.includedOnlyMeshes = ct.includedOnlyMeshes.concat(j._rootMesh.getChildMeshes(!1));
- var lt = {
- colliderMeshes: [et],
- gizmoMeshes: [_e],
- material: j._coloredMaterial,
- hoverMaterial: j._hoverMaterial,
- disableMaterial: j._disableMaterial,
- active: !1,
- dragBehavior: j.dragBehavior
- };
- return (k = j._parent) === null || k === void 0 || k.addToAxisCache(j._gizmoMesh, lt),
- j._pointerObserver = s.utilityLayerScene.onPointerObservable.add(function(ft) {
- var ht;
- if (!j._customMeshSet && (j.dragBehavior.maxDragAngle = e.MaxDragAngle,
- j._isHovered = lt.colliderMeshes.indexOf((ht = ft == null ? void 0 : ft.pickInfo) === null || ht === void 0 ? void 0 : ht.pickedMesh) != -1,
- !j._parent)) {
- var pt = lt.dragBehavior.enabled ? j._isHovered || j._dragging ? j._hoverMaterial : j._coloredMaterial : j._disableMaterial;
- j._setGizmoMeshMaterial(lt.gizmoMeshes, pt)
- }
- }),
- j.dragBehavior.onEnabledObservable.add(function(ft) {
- j._setGizmoMeshMaterial(lt.gizmoMeshes, ft ? j._coloredMaterial : j._disableMaterial)
- }),
- j
- }
- return e.prototype._createGizmoMesh = function(i, o, s) {
- var c = CreateTorus("ignore", {
- diameter: .6,
- thickness: .03 * o,
- tessellation: s
- }, this.gizmoLayer.utilityLayerScene);
- c.visibility = 0;
- var d = CreateTorus("", {
- diameter: .6,
- thickness: .005 * o,
- tessellation: s
- }, this.gizmoLayer.utilityLayerScene);
- return d.material = this._coloredMaterial,
- d.rotation.x = Math.PI / 2,
- c.rotation.x = Math.PI / 2,
- i.addChild(d),
- i.addChild(c),
- {
- rotationMesh: d,
- collider: c
- }
- }
- ,
- e.prototype._attachedNodeChanged = function(i) {
- this.dragBehavior && (this.dragBehavior.enabled = !!i)
- }
- ,
- Object.defineProperty(e.prototype, "isEnabled", {
- get: function() {
- return this._isEnabled
- },
- set: function(i) {
- this._isEnabled = i,
- i ? this._parent && (this.attachedMesh = this._parent.attachedMesh) : this.attachedMesh = null
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.dispose = function() {
- this.onSnapObservable.clear(),
- this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),
- this.dragBehavior.detach(),
- this._gizmoMesh && this._gizmoMesh.dispose(),
- this._rotationDisplayPlane && this._rotationDisplayPlane.dispose(),
- this._rotationShaderMaterial && this._rotationShaderMaterial.dispose(),
- [this._coloredMaterial, this._hoverMaterial, this._disableMaterial].forEach(function(i) {
- i && i.dispose()
- }),
- a.prototype.dispose.call(this)
- }
- ,
- e.MaxDragAngle = Math.PI * 9 / 20,
- e._rotationGizmoVertexShader = `
- precision highp float;
- attribute vec3 position;
- attribute vec2 uv;
- uniform mat4 worldViewProjection;
- varying vec3 vPosition;
- varying vec2 vUV;
- void main(void) {
- gl_Position = worldViewProjection * vec4(position, 1.0);
- vUV = uv;
- }`,
- e._rotationGizmoFragmentShader = `
- precision highp float;
- varying vec2 vUV;
- varying vec3 vPosition;
- uniform vec3 angles;
- #define twopi 6.283185307
- void main(void) {
- vec2 uv = vUV - vec2(0.5);
- float angle = atan(uv.y, uv.x) + 3.141592;
- float delta = gl_FrontFacing ? angles.y : -angles.y;
- float begin = angles.x - delta * angles.z;
- float start = (begin < (begin + delta)) ? begin : (begin + delta);
- float end = (begin > (begin + delta)) ? begin : (begin + delta);
- float len = sqrt(dot(uv,uv));
- float opacity = 1. - step(0.5, len);
- float base = abs(floor(start / twopi)) * twopi;
- start += base;
- end += base;
- float intensity = 0.;
- for (int i = 0; i < 5; i++)
- {
- intensity += max(step(start, angle) - step(end, angle), 0.);
- angle += twopi;
- }
- gl_FragColor = vec4(1.,1.,0., min(intensity * 0.25, 0.8)) * opacity;
- }`,
- e
- }(Gizmo)
- , RotationGizmo = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _) {
- i === void 0 && (i = UtilityLayerRenderer.DefaultUtilityLayer),
- o === void 0 && (o = 32),
- s === void 0 && (s = !1),
- c === void 0 && (c = 1);
- var b = a.call(this, i) || this;
- b.onDragStartObservable = new Observable,
- b.onDragEndObservable = new Observable,
- b._observables = [],
- b._gizmoAxisCache = new Map;
- var k = _ && _.xOptions && _.xOptions.color ? _.xOptions.color : Color3.Red().scale(.5)
- , j = _ && _.yOptions && _.yOptions.color ? _.yOptions.color : Color3.Green().scale(.5)
- , $ = _ && _.zOptions && _.zOptions.color ? _.zOptions.color : Color3.Blue().scale(.5);
- return b.xGizmo = new PlaneRotationGizmo(new Vector3(1,0,0),k,i,o,b,s,c),
- b.yGizmo = new PlaneRotationGizmo(new Vector3(0,1,0),j,i,o,b,s,c),
- b.zGizmo = new PlaneRotationGizmo(new Vector3(0,0,1),$,i,o,b,s,c),
- [b.xGizmo, b.yGizmo, b.zGizmo].forEach(function(_e) {
- _ && _.updateScale != null && (_e.updateScale = _.updateScale),
- _e.dragBehavior.onDragStartObservable.add(function() {
- b.onDragStartObservable.notifyObservers({})
- }),
- _e.dragBehavior.onDragEndObservable.add(function() {
- b.onDragEndObservable.notifyObservers({})
- })
- }),
- b.attachedMesh = null,
- b.attachedNode = null,
- d ? d.addToAxisCache(b._gizmoAxisCache) : Gizmo.GizmoAxisPointerObserver(i, b._gizmoAxisCache),
- b
- }
- return Object.defineProperty(e.prototype, "attachedMesh", {
- get: function() {
- return this._meshAttached
- },
- set: function(i) {
- this._meshAttached = i,
- this._nodeAttached = i,
- this._checkBillboardTransform(),
- [this.xGizmo, this.yGizmo, this.zGizmo].forEach(function(o) {
- o.isEnabled ? o.attachedMesh = i : o.attachedMesh = null
- })
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "attachedNode", {
- get: function() {
- return this._nodeAttached
- },
- set: function(i) {
- this._meshAttached = null,
- this._nodeAttached = i,
- this._checkBillboardTransform(),
- [this.xGizmo, this.yGizmo, this.zGizmo].forEach(function(o) {
- o.isEnabled ? o.attachedNode = i : o.attachedNode = null
- })
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._checkBillboardTransform = function() {
- this._nodeAttached && this._nodeAttached.billboardMode && console.log("Rotation Gizmo will not work with transforms in billboard mode.")
- }
- ,
- Object.defineProperty(e.prototype, "isHovered", {
- get: function() {
- var i = !1;
- return [this.xGizmo, this.yGizmo, this.zGizmo].forEach(function(o) {
- i = i || o.isHovered
- }),
- i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "updateGizmoRotationToMatchAttachedMesh", {
- get: function() {
- return this.xGizmo.updateGizmoRotationToMatchAttachedMesh
- },
- set: function(i) {
- this.xGizmo && (this.xGizmo.updateGizmoRotationToMatchAttachedMesh = i,
- this.yGizmo.updateGizmoRotationToMatchAttachedMesh = i,
- this.zGizmo.updateGizmoRotationToMatchAttachedMesh = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "snapDistance", {
- get: function() {
- return this.xGizmo.snapDistance
- },
- set: function(i) {
- this.xGizmo && (this.xGizmo.snapDistance = i,
- this.yGizmo.snapDistance = i,
- this.zGizmo.snapDistance = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "scaleRatio", {
- get: function() {
- return this.xGizmo.scaleRatio
- },
- set: function(i) {
- this.xGizmo && (this.xGizmo.scaleRatio = i,
- this.yGizmo.scaleRatio = i,
- this.zGizmo.scaleRatio = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.addToAxisCache = function(i, o) {
- this._gizmoAxisCache.set(i, o)
- }
- ,
- e.prototype.dispose = function() {
- var i = this;
- this.xGizmo.dispose(),
- this.yGizmo.dispose(),
- this.zGizmo.dispose(),
- this.onDragStartObservable.clear(),
- this.onDragEndObservable.clear(),
- this._observables.forEach(function(o) {
- i.gizmoLayer.utilityLayerScene.onPointerObservable.remove(o)
- })
- }
- ,
- e.prototype.setCustomMesh = function(i) {
- 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)")
- }
- ,
- e
- }(Gizmo)
- , AxisDragGizmo = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d) {
- o === void 0 && (o = Color3.Gray()),
- s === void 0 && (s = UtilityLayerRenderer.DefaultUtilityLayer),
- c === void 0 && (c = null),
- d === void 0 && (d = 1);
- var _, b = a.call(this, s) || this;
- b._pointerObserver = null,
- b.snapDistance = 0,
- b.onSnapObservable = new Observable,
- b._isEnabled = !0,
- b._parent = null,
- b._dragging = !1,
- b._parent = c,
- b._coloredMaterial = new StandardMaterial("",s.utilityLayerScene),
- b._coloredMaterial.diffuseColor = o,
- b._coloredMaterial.specularColor = o.subtract(new Color3(.1,.1,.1)),
- b._hoverMaterial = new StandardMaterial("",s.utilityLayerScene),
- b._hoverMaterial.diffuseColor = Color3.Yellow(),
- b._disableMaterial = new StandardMaterial("",s.utilityLayerScene),
- b._disableMaterial.diffuseColor = Color3.Gray(),
- b._disableMaterial.alpha = .4;
- var k = e._CreateArrow(s.utilityLayerScene, b._coloredMaterial, d)
- , j = e._CreateArrow(s.utilityLayerScene, b._coloredMaterial, d + 4, !0);
- b._gizmoMesh = new Mesh("",s.utilityLayerScene),
- b._gizmoMesh.addChild(k),
- b._gizmoMesh.addChild(j),
- b._gizmoMesh.lookAt(b._rootMesh.position.add(i)),
- b._gizmoMesh.scaling.scaleInPlace(1 / 3),
- b._gizmoMesh.parent = b._rootMesh;
- var $ = 0
- , _e = new Vector3
- , et = new Vector3
- , tt = {
- snapDistance: 0
- };
- b.dragBehavior = new PointerDragBehavior({
- dragAxis: i
- }),
- b.dragBehavior.moveAttached = !1,
- b._rootMesh.addBehavior(b.dragBehavior),
- b.dragBehavior.onDragObservable.add(function(nt) {
- if (b.attachedNode) {
- b._handlePivot();
- var ot = !1;
- if (b.snapDistance == 0)
- b.attachedNode.getWorldMatrix().getTranslationToRef(et),
- et.addInPlace(nt.delta),
- b.dragBehavior.validateDrag(et) && (b.attachedNode.position && b.attachedNode.position.addInPlaceFromFloats(nt.delta.x, nt.delta.y, nt.delta.z),
- b.attachedNode.getWorldMatrix().addTranslationFromFloats(nt.delta.x, nt.delta.y, nt.delta.z),
- b.attachedNode.updateCache(),
- ot = !0);
- else if ($ += nt.dragDistance,
- Math.abs($) > b.snapDistance) {
- var at = Math.floor(Math.abs($) / b.snapDistance);
- $ = $ % b.snapDistance,
- nt.delta.normalizeToRef(_e),
- _e.scaleInPlace(b.snapDistance * at),
- b.attachedNode.getWorldMatrix().getTranslationToRef(et),
- et.addInPlace(_e),
- b.dragBehavior.validateDrag(et) && (b.attachedNode.getWorldMatrix().addTranslationFromFloats(_e.x, _e.y, _e.z),
- b.attachedNode.updateCache(),
- tt.snapDistance = b.snapDistance * at,
- b.onSnapObservable.notifyObservers(tt),
- ot = !0)
- }
- ot && b._matrixChanged()
- }
- }),
- b.dragBehavior.onDragStartObservable.add(function() {
- b._dragging = !0
- }),
- b.dragBehavior.onDragEndObservable.add(function() {
- b._dragging = !1
- });
- var rt = s._getSharedGizmoLight();
- rt.includedOnlyMeshes = rt.includedOnlyMeshes.concat(b._rootMesh.getChildMeshes(!1));
- var it = {
- gizmoMeshes: k.getChildMeshes(),
- colliderMeshes: j.getChildMeshes(),
- material: b._coloredMaterial,
- hoverMaterial: b._hoverMaterial,
- disableMaterial: b._disableMaterial,
- active: !1,
- dragBehavior: b.dragBehavior
- };
- return (_ = b._parent) === null || _ === void 0 || _.addToAxisCache(j, it),
- b._pointerObserver = s.utilityLayerScene.onPointerObservable.add(function(nt) {
- var ot;
- if (!b._customMeshSet && (b._isHovered = it.colliderMeshes.indexOf((ot = nt == null ? void 0 : nt.pickInfo) === null || ot === void 0 ? void 0 : ot.pickedMesh) != -1,
- !b._parent)) {
- var at = b.dragBehavior.enabled ? b._isHovered || b._dragging ? b._hoverMaterial : b._coloredMaterial : b._disableMaterial;
- b._setGizmoMeshMaterial(it.gizmoMeshes, at)
- }
- }),
- b.dragBehavior.onEnabledObservable.add(function(nt) {
- b._setGizmoMeshMaterial(it.gizmoMeshes, nt ? it.material : it.disableMaterial)
- }),
- b
- }
- return e._CreateArrow = function(i, o, s, c) {
- s === void 0 && (s = 1),
- c === void 0 && (c = !1);
- var d = new TransformNode("arrow",i)
- , _ = CreateCylinder("cylinder", {
- diameterTop: 0,
- height: .075,
- diameterBottom: .0375 * (1 + (s - 1) / 4),
- tessellation: 96
- }, i)
- , b = CreateCylinder("cylinder", {
- diameterTop: .005 * s,
- height: .275,
- diameterBottom: .005 * s,
- tessellation: 96
- }, i);
- return _.parent = d,
- _.material = o,
- _.rotation.x = Math.PI / 2,
- _.position.z += .3,
- b.parent = d,
- b.material = o,
- b.position.z += .275 / 2,
- b.rotation.x = Math.PI / 2,
- c && (b.visibility = 0,
- _.visibility = 0),
- d
- }
- ,
- e._CreateArrowInstance = function(i, o) {
- for (var s = new TransformNode("arrow",i), c = 0, d = o.getChildMeshes(); c < d.length; c++) {
- var _ = d[c]
- , b = _.createInstance(_.name);
- b.parent = s
- }
- return s
- }
- ,
- e.prototype._attachedNodeChanged = function(i) {
- this.dragBehavior && (this.dragBehavior.enabled = !!i)
- }
- ,
- Object.defineProperty(e.prototype, "isEnabled", {
- get: function() {
- return this._isEnabled
- },
- set: function(i) {
- this._isEnabled = i,
- i ? this._parent && (this.attachedMesh = this._parent.attachedMesh,
- this.attachedNode = this._parent.attachedNode) : (this.attachedMesh = null,
- this.attachedNode = null)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.dispose = function() {
- this.onSnapObservable.clear(),
- this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),
- this.dragBehavior.detach(),
- this._gizmoMesh && this._gizmoMesh.dispose(),
- [this._coloredMaterial, this._hoverMaterial, this._disableMaterial].forEach(function(i) {
- i && i.dispose()
- }),
- a.prototype.dispose.call(this)
- }
- ,
- e
- }(Gizmo)
- , PlaneDragGizmo = function(a) {
- __extends(e, a);
- function e(i, o, s, c) {
- o === void 0 && (o = Color3.Gray()),
- s === void 0 && (s = UtilityLayerRenderer.DefaultUtilityLayer),
- c === void 0 && (c = null);
- var d, _ = a.call(this, s) || this;
- _._pointerObserver = null,
- _.snapDistance = 0,
- _.onSnapObservable = new Observable,
- _._isEnabled = !1,
- _._parent = null,
- _._dragging = !1,
- _._parent = c,
- _._coloredMaterial = new StandardMaterial("",s.utilityLayerScene),
- _._coloredMaterial.diffuseColor = o,
- _._coloredMaterial.specularColor = o.subtract(new Color3(.1,.1,.1)),
- _._hoverMaterial = new StandardMaterial("",s.utilityLayerScene),
- _._hoverMaterial.diffuseColor = Color3.Yellow(),
- _._disableMaterial = new StandardMaterial("",s.utilityLayerScene),
- _._disableMaterial.diffuseColor = Color3.Gray(),
- _._disableMaterial.alpha = .4,
- _._gizmoMesh = e._CreatePlane(s.utilityLayerScene, _._coloredMaterial),
- _._gizmoMesh.lookAt(_._rootMesh.position.add(i)),
- _._gizmoMesh.scaling.scaleInPlace(1 / 3),
- _._gizmoMesh.parent = _._rootMesh;
- var b = 0
- , k = new Vector3
- , j = {
- snapDistance: 0
- };
- _.dragBehavior = new PointerDragBehavior({
- dragPlaneNormal: i
- }),
- _.dragBehavior.moveAttached = !1,
- _._rootMesh.addBehavior(_.dragBehavior),
- _.dragBehavior.onDragObservable.add(function(et) {
- if (_.attachedNode) {
- if (_._handlePivot(),
- _.snapDistance == 0)
- _.attachedNode.getWorldMatrix().addTranslationFromFloats(et.delta.x, et.delta.y, et.delta.z);
- else if (b += et.dragDistance,
- Math.abs(b) > _.snapDistance) {
- var tt = Math.floor(Math.abs(b) / _.snapDistance);
- b = b % _.snapDistance,
- et.delta.normalizeToRef(k),
- k.scaleInPlace(_.snapDistance * tt),
- _.attachedNode.getWorldMatrix().addTranslationFromFloats(k.x, k.y, k.z),
- j.snapDistance = _.snapDistance * tt,
- _.onSnapObservable.notifyObservers(j)
- }
- _._matrixChanged()
- }
- }),
- _.dragBehavior.onDragStartObservable.add(function() {
- _._dragging = !0
- }),
- _.dragBehavior.onDragEndObservable.add(function() {
- _._dragging = !1
- });
- var $ = s._getSharedGizmoLight();
- $.includedOnlyMeshes = $.includedOnlyMeshes.concat(_._rootMesh.getChildMeshes(!1));
- var _e = {
- gizmoMeshes: _._gizmoMesh.getChildMeshes(),
- colliderMeshes: _._gizmoMesh.getChildMeshes(),
- material: _._coloredMaterial,
- hoverMaterial: _._hoverMaterial,
- disableMaterial: _._disableMaterial,
- active: !1,
- dragBehavior: _.dragBehavior
- };
- return (d = _._parent) === null || d === void 0 || d.addToAxisCache(_._gizmoMesh, _e),
- _._pointerObserver = s.utilityLayerScene.onPointerObservable.add(function(et) {
- var tt;
- if (!_._customMeshSet && (_._isHovered = _e.colliderMeshes.indexOf((tt = et == null ? void 0 : et.pickInfo) === null || tt === void 0 ? void 0 : tt.pickedMesh) != -1,
- !_._parent)) {
- var rt = _e.dragBehavior.enabled ? _._isHovered || _._dragging ? _._hoverMaterial : _._coloredMaterial : _._disableMaterial;
- _._setGizmoMeshMaterial(_e.gizmoMeshes, rt)
- }
- }),
- _.dragBehavior.onEnabledObservable.add(function(et) {
- _._setGizmoMeshMaterial(_e.gizmoMeshes, et ? _._coloredMaterial : _._disableMaterial)
- }),
- _
- }
- return e._CreatePlane = function(i, o) {
- var s = new TransformNode("plane",i)
- , c = CreatePlane("dragPlane", {
- width: .1375,
- height: .1375,
- sideOrientation: 2
- }, i);
- return c.material = o,
- c.parent = s,
- s
- }
- ,
- e.prototype._attachedNodeChanged = function(i) {
- this.dragBehavior && (this.dragBehavior.enabled = !!i)
- }
- ,
- Object.defineProperty(e.prototype, "isEnabled", {
- get: function() {
- return this._isEnabled
- },
- set: function(i) {
- this._isEnabled = i,
- i ? this._parent && (this.attachedNode = this._parent.attachedNode) : this.attachedNode = null
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.dispose = function() {
- this.onSnapObservable.clear(),
- this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),
- this.dragBehavior.detach(),
- a.prototype.dispose.call(this),
- this._gizmoMesh && this._gizmoMesh.dispose(),
- [this._coloredMaterial, this._hoverMaterial, this._disableMaterial].forEach(function(i) {
- i && i.dispose()
- })
- }
- ,
- e
- }(Gizmo)
- , PositionGizmo = function(a) {
- __extends(e, a);
- function e(i, o, s) {
- i === void 0 && (i = UtilityLayerRenderer.DefaultUtilityLayer),
- o === void 0 && (o = 1);
- var c = a.call(this, i) || this;
- return c._meshAttached = null,
- c._nodeAttached = null,
- c._observables = [],
- c._gizmoAxisCache = new Map,
- c.onDragStartObservable = new Observable,
- c.onDragEndObservable = new Observable,
- c._planarGizmoEnabled = !1,
- c.xGizmo = new AxisDragGizmo(new Vector3(1,0,0),Color3.Red().scale(.5),i,c,o),
- c.yGizmo = new AxisDragGizmo(new Vector3(0,1,0),Color3.Green().scale(.5),i,c,o),
- c.zGizmo = new AxisDragGizmo(new Vector3(0,0,1),Color3.Blue().scale(.5),i,c,o),
- c.xPlaneGizmo = new PlaneDragGizmo(new Vector3(1,0,0),Color3.Red().scale(.5),c.gizmoLayer,c),
- c.yPlaneGizmo = new PlaneDragGizmo(new Vector3(0,1,0),Color3.Green().scale(.5),c.gizmoLayer,c),
- c.zPlaneGizmo = new PlaneDragGizmo(new Vector3(0,0,1),Color3.Blue().scale(.5),c.gizmoLayer,c),
- [c.xGizmo, c.yGizmo, c.zGizmo, c.xPlaneGizmo, c.yPlaneGizmo, c.zPlaneGizmo].forEach(function(d) {
- d.dragBehavior.onDragStartObservable.add(function() {
- c.onDragStartObservable.notifyObservers({})
- }),
- d.dragBehavior.onDragEndObservable.add(function() {
- c.onDragEndObservable.notifyObservers({})
- })
- }),
- c.attachedMesh = null,
- s ? s.addToAxisCache(c._gizmoAxisCache) : Gizmo.GizmoAxisPointerObserver(i, c._gizmoAxisCache),
- c
- }
- return Object.defineProperty(e.prototype, "attachedMesh", {
- get: function() {
- return this._meshAttached
- },
- set: function(i) {
- this._meshAttached = i,
- this._nodeAttached = i,
- [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function(o) {
- o.isEnabled ? o.attachedMesh = i : o.attachedMesh = null
- })
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "attachedNode", {
- get: function() {
- return this._nodeAttached
- },
- set: function(i) {
- this._meshAttached = null,
- this._nodeAttached = i,
- [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function(o) {
- o.isEnabled ? o.attachedNode = i : o.attachedNode = null
- })
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isHovered", {
- get: function() {
- var i = !1;
- return [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function(o) {
- i = i || o.isHovered
- }),
- i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "planarGizmoEnabled", {
- get: function() {
- return this._planarGizmoEnabled
- },
- set: function(i) {
- var o = this;
- this._planarGizmoEnabled = i,
- [this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function(s) {
- s && (s.isEnabled = i,
- i && (s.attachedMesh ? s.attachedMesh = o.attachedMesh : s.attachedNode = o.attachedNode))
- }, this)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "updateGizmoRotationToMatchAttachedMesh", {
- get: function() {
- return this._updateGizmoRotationToMatchAttachedMesh
- },
- set: function(i) {
- this._updateGizmoRotationToMatchAttachedMesh = i,
- [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function(o) {
- o && (o.updateGizmoRotationToMatchAttachedMesh = i)
- })
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "snapDistance", {
- get: function() {
- return this._snapDistance
- },
- set: function(i) {
- this._snapDistance = i,
- [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function(o) {
- o && (o.snapDistance = i)
- })
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "scaleRatio", {
- get: function() {
- return this._scaleRatio
- },
- set: function(i) {
- this._scaleRatio = i,
- [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function(o) {
- o && (o.scaleRatio = i)
- })
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.addToAxisCache = function(i, o) {
- this._gizmoAxisCache.set(i, o)
- }
- ,
- e.prototype.dispose = function() {
- var i = this;
- [this.xGizmo, this.yGizmo, this.zGizmo, this.xPlaneGizmo, this.yPlaneGizmo, this.zPlaneGizmo].forEach(function(o) {
- o && o.dispose()
- }),
- this._observables.forEach(function(o) {
- i.gizmoLayer.utilityLayerScene.onPointerObservable.remove(o)
- }),
- this.onDragStartObservable.clear(),
- this.onDragEndObservable.clear()
- }
- ,
- e.prototype.setCustomMesh = function(i) {
- 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)")
- }
- ,
- e
- }(Gizmo)
- , AxisScaleGizmo = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d) {
- o === void 0 && (o = Color3.Gray()),
- s === void 0 && (s = UtilityLayerRenderer.DefaultUtilityLayer),
- c === void 0 && (c = null),
- d === void 0 && (d = 1);
- var _, b, k, j, $, _e, et, tt = a.call(this, s) || this;
- tt._pointerObserver = null,
- tt.snapDistance = 0,
- tt.onSnapObservable = new Observable,
- tt.uniformScaling = !1,
- tt.sensitivity = 1,
- tt.dragScale = 1,
- tt._isEnabled = !0,
- tt._parent = null,
- tt._dragging = !1,
- tt._tmpVector = new Vector3,
- tt._tmpMatrix = new Matrix,
- tt._tmpMatrix2 = new Matrix,
- tt._parent = c,
- tt._coloredMaterial = new StandardMaterial("",s.utilityLayerScene),
- tt._coloredMaterial.diffuseColor = o,
- tt._coloredMaterial.specularColor = o.subtract(new Color3(.1,.1,.1)),
- tt._hoverMaterial = new StandardMaterial("",s.utilityLayerScene),
- tt._hoverMaterial.diffuseColor = Color3.Yellow(),
- tt._disableMaterial = new StandardMaterial("",s.utilityLayerScene),
- tt._disableMaterial.diffuseColor = Color3.Gray(),
- tt._disableMaterial.alpha = .4,
- tt._gizmoMesh = new Mesh("axis",s.utilityLayerScene);
- var rt = tt._createGizmoMesh(tt._gizmoMesh, d)
- , it = rt.arrowMesh
- , nt = rt.arrowTail
- , ot = tt._createGizmoMesh(tt._gizmoMesh, d + 4, !0);
- tt._gizmoMesh.lookAt(tt._rootMesh.position.add(i)),
- tt._rootMesh.addChild(tt._gizmoMesh),
- tt._gizmoMesh.scaling.scaleInPlace(1 / 3);
- var at = it.position.clone()
- , st = nt.position.clone()
- , ut = nt.scaling.clone()
- , ct = function(mt) {
- var vt = mt * (3 / tt._rootMesh.scaling.length()) * 6;
- it.position.z += vt / 3.5,
- nt.scaling.y += vt,
- tt.dragScale = nt.scaling.y,
- nt.position.z = it.position.z / 2
- }
- , lt = function() {
- it.position.set(at.x, at.y, at.z),
- nt.position.set(st.x, st.y, st.z),
- nt.scaling.set(ut.x, ut.y, ut.z),
- tt.dragScale = nt.scaling.y,
- tt._dragging = !1
- };
- tt.dragBehavior = new PointerDragBehavior({
- dragAxis: i
- }),
- tt.dragBehavior.moveAttached = !1,
- tt._rootMesh.addBehavior(tt.dragBehavior);
- var ft = 0
- , ht = new Vector3
- , pt = {
- snapDistance: 0
- };
- tt.dragBehavior.onDragObservable.add(function(mt) {
- if (tt.attachedNode) {
- tt._handlePivot();
- var vt = tt.sensitivity * mt.dragDistance * (tt.scaleRatio * 3 / tt._rootMesh.scaling.length())
- , yt = !1
- , Et = 0;
- tt.uniformScaling ? ht.setAll(.57735) : ht.copyFrom(i),
- tt.snapDistance == 0 ? ht.scaleToRef(vt, ht) : (ft += vt,
- Math.abs(ft) > tt.snapDistance ? (Et = Math.floor(Math.abs(ft) / tt.snapDistance),
- ft < 0 && (Et *= -1),
- ft = ft % tt.snapDistance,
- ht.scaleToRef(tt.snapDistance * Et, ht),
- yt = !0) : ht.scaleInPlace(0)),
- Matrix.ScalingToRef(1 + ht.x, 1 + ht.y, 1 + ht.z, tt._tmpMatrix2),
- tt._tmpMatrix2.multiplyToRef(tt.attachedNode.getWorldMatrix(), tt._tmpMatrix),
- tt._tmpMatrix.decompose(tt._tmpVector);
- var At = 1e5;
- Math.abs(tt._tmpVector.x) < At && Math.abs(tt._tmpVector.y) < At && Math.abs(tt._tmpVector.z) < At && tt.attachedNode.getWorldMatrix().copyFrom(tt._tmpMatrix),
- yt && (pt.snapDistance = tt.snapDistance * Et,
- tt.onSnapObservable.notifyObservers(pt)),
- tt._matrixChanged()
- }
- }),
- tt.dragBehavior.onDragStartObservable.add(function() {
- tt._dragging = !0
- }),
- tt.dragBehavior.onDragObservable.add(function(mt) {
- return ct(mt.dragDistance)
- }),
- tt.dragBehavior.onDragEndObservable.add(lt),
- (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) {
- return ct(mt.delta.y)
- }),
- (_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);
- var dt = {
- gizmoMeshes: [it, nt],
- colliderMeshes: [ot.arrowMesh, ot.arrowTail],
- material: tt._coloredMaterial,
- hoverMaterial: tt._hoverMaterial,
- disableMaterial: tt._disableMaterial,
- active: !1,
- dragBehavior: tt.dragBehavior
- };
- (et = tt._parent) === null || et === void 0 || et.addToAxisCache(tt._gizmoMesh, dt),
- tt._pointerObserver = s.utilityLayerScene.onPointerObservable.add(function(mt) {
- var vt;
- if (!tt._customMeshSet && (tt._isHovered = dt.colliderMeshes.indexOf((vt = mt == null ? void 0 : mt.pickInfo) === null || vt === void 0 ? void 0 : vt.pickedMesh) != -1,
- !tt._parent)) {
- var yt = tt.dragBehavior.enabled ? tt._isHovered || tt._dragging ? tt._hoverMaterial : tt._coloredMaterial : tt._disableMaterial;
- tt._setGizmoMeshMaterial(dt.gizmoMeshes, yt)
- }
- }),
- tt.dragBehavior.onEnabledObservable.add(function(mt) {
- tt._setGizmoMeshMaterial(dt.gizmoMeshes, mt ? tt._coloredMaterial : tt._disableMaterial)
- });
- var _t = s._getSharedGizmoLight();
- return _t.includedOnlyMeshes = _t.includedOnlyMeshes.concat(tt._rootMesh.getChildMeshes()),
- tt
- }
- return e.prototype._createGizmoMesh = function(i, o, s) {
- s === void 0 && (s = !1);
- var c = CreateBox("yPosMesh", {
- size: .4 * (1 + (o - 1) / 4)
- }, this.gizmoLayer.utilityLayerScene)
- , d = CreateCylinder("cylinder", {
- diameterTop: .005 * o,
- height: .275,
- diameterBottom: .005 * o,
- tessellation: 96
- }, this.gizmoLayer.utilityLayerScene);
- return c.scaling.scaleInPlace(.1),
- c.material = this._coloredMaterial,
- c.rotation.x = Math.PI / 2,
- c.position.z += .3,
- d.material = this._coloredMaterial,
- d.position.z += .275 / 2,
- d.rotation.x = Math.PI / 2,
- s && (c.visibility = 0,
- d.visibility = 0),
- i.addChild(c),
- i.addChild(d),
- {
- arrowMesh: c,
- arrowTail: d
- }
- }
- ,
- e.prototype._attachedNodeChanged = function(i) {
- this.dragBehavior && (this.dragBehavior.enabled = !!i)
- }
- ,
- Object.defineProperty(e.prototype, "isEnabled", {
- get: function() {
- return this._isEnabled
- },
- set: function(i) {
- this._isEnabled = i,
- i ? this._parent && (this.attachedMesh = this._parent.attachedMesh,
- this.attachedNode = this._parent.attachedNode) : (this.attachedMesh = null,
- this.attachedNode = null)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.dispose = function() {
- this.onSnapObservable.clear(),
- this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),
- this.dragBehavior.detach(),
- this._gizmoMesh && this._gizmoMesh.dispose(),
- [this._coloredMaterial, this._hoverMaterial, this._disableMaterial].forEach(function(i) {
- i && i.dispose()
- }),
- a.prototype.dispose.call(this)
- }
- ,
- e.prototype.setCustomMesh = function(i, o) {
- var s = this;
- o === void 0 && (o = !1),
- a.prototype.setCustomMesh.call(this, i),
- o && (this._rootMesh.getChildMeshes().forEach(function(c) {
- c.material = s._coloredMaterial,
- c.color && (c.color = s._coloredMaterial.diffuseColor)
- }),
- this._customMeshSet = !1)
- }
- ,
- e
- }(Gizmo)
- , ScaleGizmo = function(a) {
- __extends(e, a);
- function e(i, o, s) {
- i === void 0 && (i = UtilityLayerRenderer.DefaultUtilityLayer),
- o === void 0 && (o = 1);
- var c = a.call(this, i) || this;
- return c._meshAttached = null,
- c._nodeAttached = null,
- c._sensitivity = 1,
- c._observables = [],
- c._gizmoAxisCache = new Map,
- c.onDragStartObservable = new Observable,
- c.onDragEndObservable = new Observable,
- c.uniformScaleGizmo = c._createUniformScaleMesh(),
- c.xGizmo = new AxisScaleGizmo(new Vector3(1,0,0),Color3.Red().scale(.5),i,c,o),
- c.yGizmo = new AxisScaleGizmo(new Vector3(0,1,0),Color3.Green().scale(.5),i,c,o),
- c.zGizmo = new AxisScaleGizmo(new Vector3(0,0,1),Color3.Blue().scale(.5),i,c,o),
- [c.xGizmo, c.yGizmo, c.zGizmo, c.uniformScaleGizmo].forEach(function(d) {
- d.dragBehavior.onDragStartObservable.add(function() {
- c.onDragStartObservable.notifyObservers({})
- }),
- d.dragBehavior.onDragEndObservable.add(function() {
- c.onDragEndObservable.notifyObservers({})
- })
- }),
- c.attachedMesh = null,
- c.attachedNode = null,
- s ? s.addToAxisCache(c._gizmoAxisCache) : Gizmo.GizmoAxisPointerObserver(i, c._gizmoAxisCache),
- c
- }
- return Object.defineProperty(e.prototype, "attachedMesh", {
- get: function() {
- return this._meshAttached
- },
- set: function(i) {
- this._meshAttached = i,
- this._nodeAttached = i,
- [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach(function(o) {
- o.isEnabled ? o.attachedMesh = i : o.attachedMesh = null
- })
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "attachedNode", {
- get: function() {
- return this._nodeAttached
- },
- set: function(i) {
- this._meshAttached = null,
- this._nodeAttached = i,
- [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach(function(o) {
- o.isEnabled ? o.attachedNode = i : o.attachedNode = null
- })
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "isHovered", {
- get: function() {
- var i = !1;
- return [this.xGizmo, this.yGizmo, this.zGizmo].forEach(function(o) {
- i = i || o.isHovered
- }),
- i
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._createUniformScaleMesh = function() {
- this._coloredMaterial = new StandardMaterial("",this.gizmoLayer.utilityLayerScene),
- this._coloredMaterial.diffuseColor = Color3.Gray(),
- this._hoverMaterial = new StandardMaterial("",this.gizmoLayer.utilityLayerScene),
- this._hoverMaterial.diffuseColor = Color3.Yellow(),
- this._disableMaterial = new StandardMaterial("",this.gizmoLayer.utilityLayerScene),
- this._disableMaterial.diffuseColor = Color3.Gray(),
- this._disableMaterial.alpha = .4;
- var i = new AxisScaleGizmo(new Vector3(0,1,0),Color3.Gray().scale(.5),this.gizmoLayer,this);
- i.updateGizmoRotationToMatchAttachedMesh = !1,
- i.uniformScaling = !0,
- this._uniformScalingMesh = CreatePolyhedron("uniform", {
- type: 1
- }, i.gizmoLayer.utilityLayerScene),
- this._uniformScalingMesh.scaling.scaleInPlace(.01),
- this._uniformScalingMesh.visibility = 0,
- this._octahedron = CreatePolyhedron("", {
- type: 1
- }, i.gizmoLayer.utilityLayerScene),
- this._octahedron.scaling.scaleInPlace(.007),
- this._uniformScalingMesh.addChild(this._octahedron),
- i.setCustomMesh(this._uniformScalingMesh, !0);
- var o = this.gizmoLayer._getSharedGizmoLight();
- o.includedOnlyMeshes = o.includedOnlyMeshes.concat(this._octahedron);
- var s = {
- gizmoMeshes: [this._octahedron, this._uniformScalingMesh],
- colliderMeshes: [this._uniformScalingMesh],
- material: this._coloredMaterial,
- hoverMaterial: this._hoverMaterial,
- disableMaterial: this._disableMaterial,
- active: !1,
- dragBehavior: i.dragBehavior
- };
- return this.addToAxisCache(i._rootMesh, s),
- i
- }
- ,
- Object.defineProperty(e.prototype, "updateGizmoRotationToMatchAttachedMesh", {
- get: function() {
- return this._updateGizmoRotationToMatchAttachedMesh
- },
- set: function(i) {
- i ? (this._updateGizmoRotationToMatchAttachedMesh = i,
- [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach(function(o) {
- o && (o.updateGizmoRotationToMatchAttachedMesh = i)
- })) : Logger$2.Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported.")
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "snapDistance", {
- get: function() {
- return this._snapDistance
- },
- set: function(i) {
- this._snapDistance = i,
- [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach(function(o) {
- o && (o.snapDistance = i)
- })
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "scaleRatio", {
- get: function() {
- return this._scaleRatio
- },
- set: function(i) {
- this._scaleRatio = i,
- [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach(function(o) {
- o && (o.scaleRatio = i)
- })
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "sensitivity", {
- get: function() {
- return this._sensitivity
- },
- set: function(i) {
- this._sensitivity = i,
- [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach(function(o) {
- o && (o.sensitivity = i)
- })
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.addToAxisCache = function(i, o) {
- this._gizmoAxisCache.set(i, o)
- }
- ,
- e.prototype.dispose = function() {
- var i = this;
- [this.xGizmo, this.yGizmo, this.zGizmo, this.uniformScaleGizmo].forEach(function(o) {
- o && o.dispose()
- }),
- this._observables.forEach(function(o) {
- i.gizmoLayer.utilityLayerScene.onPointerObservable.remove(o)
- }),
- this.onDragStartObservable.clear(),
- this.onDragEndObservable.clear(),
- [this._uniformScalingMesh, this._octahedron].forEach(function(o) {
- o && o.dispose()
- }),
- [this._coloredMaterial, this._hoverMaterial, this._disableMaterial].forEach(function(o) {
- o && o.dispose()
- })
- }
- ,
- e
- }(Gizmo)
- , BoundingBoxGizmo = function(a) {
- __extends(e, a);
- function e(i, o) {
- i === void 0 && (i = Color3.Gray()),
- o === void 0 && (o = UtilityLayerRenderer.DefaultKeepDepthUtilityLayer);
- var s = a.call(this, o) || this;
- s._boundingDimensions = new Vector3(1,1,1),
- s._renderObserver = null,
- s._pointerObserver = null,
- s._scaleDragSpeed = .2,
- s._tmpQuaternion = new Quaternion,
- s._tmpVector = new Vector3(0,0,0),
- s._tmpRotationMatrix = new Matrix,
- s.ignoreChildren = !1,
- s.includeChildPredicate = null,
- s.rotationSphereSize = .1,
- s.scaleBoxSize = .1,
- s.fixedDragMeshScreenSize = !1,
- s.fixedDragMeshBoundsSize = !1,
- s.fixedDragMeshScreenSizeDistanceFactor = 10,
- s.onDragStartObservable = new Observable,
- s.onScaleBoxDragObservable = new Observable,
- s.onScaleBoxDragEndObservable = new Observable,
- s.onRotationSphereDragObservable = new Observable,
- s.onRotationSphereDragEndObservable = new Observable,
- s.scalePivot = null,
- s._axisFactor = new Vector3(1,1,1),
- s._existingMeshScale = new Vector3,
- s._dragMesh = null,
- s.pointerDragBehavior = new PointerDragBehavior,
- s.updateScale = !1,
- s._anchorMesh = new AbstractMesh("anchor",o.utilityLayerScene),
- s.coloredMaterial = new StandardMaterial("",o.utilityLayerScene),
- s.coloredMaterial.disableLighting = !0,
- s.hoverColoredMaterial = new StandardMaterial("",o.utilityLayerScene),
- s.hoverColoredMaterial.disableLighting = !0,
- s._lineBoundingBox = new AbstractMesh("",o.utilityLayerScene),
- s._lineBoundingBox.rotationQuaternion = new Quaternion;
- var c = [];
- c.push(CreateLines("lines", {
- points: [new Vector3(0,0,0), new Vector3(s._boundingDimensions.x,0,0)]
- }, o.utilityLayerScene)),
- c.push(CreateLines("lines", {
- points: [new Vector3(0,0,0), new Vector3(0,s._boundingDimensions.y,0)]
- }, o.utilityLayerScene)),
- c.push(CreateLines("lines", {
- points: [new Vector3(0,0,0), new Vector3(0,0,s._boundingDimensions.z)]
- }, o.utilityLayerScene)),
- c.push(CreateLines("lines", {
- points: [new Vector3(s._boundingDimensions.x,0,0), new Vector3(s._boundingDimensions.x,s._boundingDimensions.y,0)]
- }, o.utilityLayerScene)),
- c.push(CreateLines("lines", {
- points: [new Vector3(s._boundingDimensions.x,0,0), new Vector3(s._boundingDimensions.x,0,s._boundingDimensions.z)]
- }, o.utilityLayerScene)),
- c.push(CreateLines("lines", {
- points: [new Vector3(0,s._boundingDimensions.y,0), new Vector3(s._boundingDimensions.x,s._boundingDimensions.y,0)]
- }, o.utilityLayerScene)),
- c.push(CreateLines("lines", {
- points: [new Vector3(0,s._boundingDimensions.y,0), new Vector3(0,s._boundingDimensions.y,s._boundingDimensions.z)]
- }, o.utilityLayerScene)),
- c.push(CreateLines("lines", {
- points: [new Vector3(0,0,s._boundingDimensions.z), new Vector3(s._boundingDimensions.x,0,s._boundingDimensions.z)]
- }, o.utilityLayerScene)),
- c.push(CreateLines("lines", {
- points: [new Vector3(0,0,s._boundingDimensions.z), new Vector3(0,s._boundingDimensions.y,s._boundingDimensions.z)]
- }, o.utilityLayerScene)),
- c.push(CreateLines("lines", {
- points: [new Vector3(s._boundingDimensions.x,s._boundingDimensions.y,s._boundingDimensions.z), new Vector3(0,s._boundingDimensions.y,s._boundingDimensions.z)]
- }, o.utilityLayerScene)),
- c.push(CreateLines("lines", {
- points: [new Vector3(s._boundingDimensions.x,s._boundingDimensions.y,s._boundingDimensions.z), new Vector3(s._boundingDimensions.x,0,s._boundingDimensions.z)]
- }, o.utilityLayerScene)),
- c.push(CreateLines("lines", {
- points: [new Vector3(s._boundingDimensions.x,s._boundingDimensions.y,s._boundingDimensions.z), new Vector3(s._boundingDimensions.x,s._boundingDimensions.y,0)]
- }, o.utilityLayerScene)),
- c.forEach(function(it) {
- it.color = i,
- it.position.addInPlace(new Vector3(-s._boundingDimensions.x / 2,-s._boundingDimensions.y / 2,-s._boundingDimensions.z / 2)),
- it.isPickable = !1,
- s._lineBoundingBox.addChild(it)
- }),
- s._rootMesh.addChild(s._lineBoundingBox),
- s.setColor(i),
- s._rotateSpheresParent = new AbstractMesh("",o.utilityLayerScene),
- s._rotateSpheresParent.rotationQuaternion = new Quaternion;
- for (var d = function(it) {
- var nt = CreateSphere("", {
- diameter: 1
- }, o.utilityLayerScene);
- nt.rotationQuaternion = new Quaternion,
- nt.material = _.coloredMaterial,
- nt.isNearGrabbable = !0,
- b = new PointerDragBehavior({}),
- b.moveAttached = !1,
- b.updateDragPlane = !1,
- nt.addBehavior(b);
- var ot = new Vector3(1,0,0)
- , at = 0;
- b.onDragStartObservable.add(function() {
- ot.copyFrom(nt.forward),
- at = 0
- }),
- b.onDragObservable.add(function(st) {
- if (s.onRotationSphereDragObservable.notifyObservers({}),
- s.attachedMesh) {
- var ut = s.attachedMesh.parent;
- if (ut && ut.scaling && ut.scaling.isNonUniformWithinEpsilon(.001)) {
- Logger$2.Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
- return
- }
- PivotTools._RemoveAndStorePivotPoint(s.attachedMesh);
- var ct = ot
- , lt = st.dragPlaneNormal.scale(Vector3.Dot(st.dragPlaneNormal, ct))
- , ft = ct.subtract(lt).normalizeToNew()
- , ht = Vector3.Dot(ft, st.delta) < 0 ? Math.abs(st.delta.length()) : -Math.abs(st.delta.length());
- ht = ht / s._boundingDimensions.length() * s._anchorMesh.scaling.length(),
- s.attachedMesh.rotationQuaternion || (s.attachedMesh.rotationQuaternion = Quaternion.RotationYawPitchRoll(s.attachedMesh.rotation.y, s.attachedMesh.rotation.x, s.attachedMesh.rotation.z)),
- s._anchorMesh.rotationQuaternion || (s._anchorMesh.rotationQuaternion = Quaternion.RotationYawPitchRoll(s._anchorMesh.rotation.y, s._anchorMesh.rotation.x, s._anchorMesh.rotation.z)),
- at += ht,
- 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),
- s._anchorMesh.addChild(s.attachedMesh),
- s._anchorMesh.rotationQuaternion.multiplyToRef(s._tmpQuaternion, s._anchorMesh.rotationQuaternion),
- s._anchorMesh.removeChild(s.attachedMesh),
- s.attachedMesh.setParent(ut)),
- s.updateBoundingBox(),
- PivotTools._RestorePivotPoint(s.attachedMesh)
- }
- s._updateDummy()
- }),
- b.onDragStartObservable.add(function() {
- s.onDragStartObservable.notifyObservers({}),
- s._selectNode(nt)
- }),
- b.onDragEndObservable.add(function() {
- s.onRotationSphereDragEndObservable.notifyObservers({}),
- s._selectNode(null),
- s._updateDummy()
- }),
- _._rotateSpheresParent.addChild(nt)
- }, _ = this, b, k = 0; k < 12; k++)
- d(k);
- s._rootMesh.addChild(s._rotateSpheresParent),
- s._scaleBoxesParent = new AbstractMesh("",o.utilityLayerScene),
- s._scaleBoxesParent.rotationQuaternion = new Quaternion;
- for (var j = 0; j < 3; j++)
- for (var $ = 0; $ < 3; $++)
- for (var _e = function() {
- var nt = (j === 1 ? 1 : 0) + ($ === 1 ? 1 : 0) + (tt === 1 ? 1 : 0);
- if (nt === 1 || nt === 3)
- return "continue";
- var ot = CreateBox("", {
- size: 1
- }, o.utilityLayerScene);
- ot.material = et.coloredMaterial,
- ot.metadata = nt === 2,
- ot.isNearGrabbable = !0;
- var at = new Vector3(j - 1,$ - 1,tt - 1).normalize();
- b = new PointerDragBehavior({
- dragAxis: at
- }),
- b.updateDragPlane = !1,
- b.moveAttached = !1,
- ot.addBehavior(b),
- b.onDragObservable.add(function(st) {
- if (s.onScaleBoxDragObservable.notifyObservers({}),
- s.attachedMesh) {
- var ut = s.attachedMesh.parent;
- if (ut && ut.scaling && ut.scaling.isNonUniformWithinEpsilon(.001)) {
- Logger$2.Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
- return
- }
- PivotTools._RemoveAndStorePivotPoint(s.attachedMesh);
- var ct = st.dragDistance / s._boundingDimensions.length() * s._anchorMesh.scaling.length()
- , lt = new Vector3(ct,ct,ct);
- nt === 2 && (lt.x *= Math.abs(at.x),
- lt.y *= Math.abs(at.y),
- lt.z *= Math.abs(at.z)),
- lt.scaleInPlace(s._scaleDragSpeed),
- lt.multiplyInPlace(s._axisFactor),
- s.updateBoundingBox(),
- s.scalePivot ? (s.attachedMesh.getWorldMatrix().getRotationMatrixToRef(s._tmpRotationMatrix),
- s._boundingDimensions.scaleToRef(.5, s._tmpVector),
- Vector3.TransformCoordinatesToRef(s._tmpVector, s._tmpRotationMatrix, s._tmpVector),
- s._anchorMesh.position.subtractInPlace(s._tmpVector),
- s._boundingDimensions.multiplyToRef(s.scalePivot, s._tmpVector),
- Vector3.TransformCoordinatesToRef(s._tmpVector, s._tmpRotationMatrix, s._tmpVector),
- s._anchorMesh.position.addInPlace(s._tmpVector)) : (ot.absolutePosition.subtractToRef(s._anchorMesh.position, s._tmpVector),
- s._anchorMesh.position.subtractInPlace(s._tmpVector)),
- s._anchorMesh.addChild(s.attachedMesh),
- s._anchorMesh.scaling.addInPlace(lt),
- (s._anchorMesh.scaling.x < 0 || s._anchorMesh.scaling.y < 0 || s._anchorMesh.scaling.z < 0) && s._anchorMesh.scaling.subtractInPlace(lt),
- s._anchorMesh.removeChild(s.attachedMesh),
- s.attachedMesh.setParent(ut),
- PivotTools._RestorePivotPoint(s.attachedMesh)
- }
- s._updateDummy()
- }),
- b.onDragStartObservable.add(function() {
- s.onDragStartObservable.notifyObservers({}),
- s._selectNode(ot)
- }),
- b.onDragEndObservable.add(function() {
- s.onScaleBoxDragEndObservable.notifyObservers({}),
- s._selectNode(null),
- s._updateDummy()
- }),
- et._scaleBoxesParent.addChild(ot)
- }, et = this, b, tt = 0; tt < 3; tt++)
- _e();
- s._rootMesh.addChild(s._scaleBoxesParent);
- var rt = new Array;
- return s._pointerObserver = o.utilityLayerScene.onPointerObservable.add(function(it) {
- rt[it.event.pointerId] ? it.pickInfo && it.pickInfo.pickedMesh != rt[it.event.pointerId] && (rt[it.event.pointerId].material = s.coloredMaterial,
- delete rt[it.event.pointerId]) : s._rotateSpheresParent.getChildMeshes().concat(s._scaleBoxesParent.getChildMeshes()).forEach(function(nt) {
- it.pickInfo && it.pickInfo.pickedMesh == nt && (rt[it.event.pointerId] = nt,
- nt.material = s.hoverColoredMaterial)
- })
- }),
- s._renderObserver = s.gizmoLayer.originalScene.onBeforeRenderObservable.add(function() {
- s.attachedMesh && !s._existingMeshScale.equals(s.attachedMesh.scaling) ? s.updateBoundingBox() : (s.fixedDragMeshScreenSize || s.fixedDragMeshBoundsSize) && (s._updateRotationSpheres(),
- s._updateScaleBoxes()),
- s._dragMesh && s.attachedMesh && s.pointerDragBehavior.dragging && (s._lineBoundingBox.position.rotateByQuaternionToRef(s._rootMesh.rotationQuaternion, s._tmpVector),
- s.attachedMesh.setAbsolutePosition(s._dragMesh.position.add(s._tmpVector.scale(-1))))
- }),
- s.updateBoundingBox(),
- s
- }
- return Object.defineProperty(e.prototype, "axisFactor", {
- get: function() {
- return this._axisFactor
- },
- set: function(i) {
- this._axisFactor = i;
- for (var o = this._scaleBoxesParent.getChildMeshes(), s = 0, c = 0; c < 3; c++)
- for (var d = 0; d < 3; d++)
- for (var _ = 0; _ < 3; _++) {
- var b = (c === 1 ? 1 : 0) + (d === 1 ? 1 : 0) + (_ === 1 ? 1 : 0);
- if (!(b === 1 || b === 3)) {
- if (o[s]) {
- var k = new Vector3(c - 1,d - 1,_ - 1);
- k.multiplyInPlace(this._axisFactor),
- o[s].setEnabled(k.lengthSquared() > Epsilon)
- }
- s++
- }
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "scaleDragSpeed", {
- get: function() {
- return this._scaleDragSpeed
- },
- set: function(i) {
- this._scaleDragSpeed = i
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.setColor = function(i) {
- this.coloredMaterial.emissiveColor = i,
- this.hoverColoredMaterial.emissiveColor = i.clone().add(new Color3(.3,.3,.3)),
- this._lineBoundingBox.getChildren().forEach(function(o) {
- o.color && (o.color = i)
- })
- }
- ,
- e.prototype._attachedNodeChanged = function(i) {
- var o = this;
- if (i) {
- this._anchorMesh.scaling.setAll(1),
- PivotTools._RemoveAndStorePivotPoint(i);
- var s = i.parent;
- this._anchorMesh.addChild(i),
- this._anchorMesh.removeChild(i),
- i.setParent(s),
- PivotTools._RestorePivotPoint(i),
- this.updateBoundingBox(),
- i.getChildMeshes(!1).forEach(function(c) {
- c.markAsDirty("scaling")
- }),
- this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce(function() {
- o._updateDummy()
- })
- }
- }
- ,
- e.prototype._selectNode = function(i) {
- this._rotateSpheresParent.getChildMeshes().concat(this._scaleBoxesParent.getChildMeshes()).forEach(function(o) {
- o.isVisible = !i || o == i
- })
- }
- ,
- e.prototype.updateBoundingBox = function() {
- if (this.attachedMesh) {
- PivotTools._RemoveAndStorePivotPoint(this.attachedMesh);
- var i = this.attachedMesh.parent;
- this.attachedMesh.setParent(null);
- var o = null;
- this.attachedMesh.skeleton && (o = this.attachedMesh.skeleton.overrideMesh,
- this.attachedMesh.skeleton.overrideMesh = null),
- this._update(),
- this.attachedMesh.rotationQuaternion || (this.attachedMesh.rotationQuaternion = Quaternion.RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z)),
- this._anchorMesh.rotationQuaternion || (this._anchorMesh.rotationQuaternion = Quaternion.RotationYawPitchRoll(this._anchorMesh.rotation.y, this._anchorMesh.rotation.x, this._anchorMesh.rotation.z)),
- this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion),
- this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion),
- this._tmpVector.copyFrom(this.attachedMesh.position),
- this.attachedMesh.rotationQuaternion.set(0, 0, 0, 1),
- this.attachedMesh.position.set(0, 0, 0);
- var s = this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren, this.includeChildPredicate);
- s.max.subtractToRef(s.min, this._boundingDimensions),
- this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions),
- 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),
- this._rotateSpheresParent.position.copyFrom(this._lineBoundingBox.position),
- this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position),
- this._lineBoundingBox.computeWorldMatrix(),
- this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition),
- this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion),
- this.attachedMesh.position.copyFrom(this._tmpVector),
- this.attachedMesh.setParent(i),
- this.attachedMesh.skeleton && (this.attachedMesh.skeleton.overrideMesh = o)
- }
- this._updateRotationSpheres(),
- this._updateScaleBoxes(),
- this.attachedMesh && (this._existingMeshScale.copyFrom(this.attachedMesh.scaling),
- PivotTools._RestorePivotPoint(this.attachedMesh))
- }
- ,
- e.prototype._updateRotationSpheres = function() {
- for (var i = this._rotateSpheresParent.getChildMeshes(), o = 0; o < 3; o++)
- for (var s = 0; s < 2; s++)
- for (var c = 0; c < 2; c++) {
- var d = o * 4 + s * 2 + c;
- if (o == 0 && (i[d].position.set(this._boundingDimensions.x / 2, this._boundingDimensions.y * s, this._boundingDimensions.z * c),
- i[d].position.addInPlace(new Vector3(-this._boundingDimensions.x / 2,-this._boundingDimensions.y / 2,-this._boundingDimensions.z / 2)),
- i[d].lookAt(Vector3.Cross(i[d].position.normalizeToNew(), Vector3.Right()).normalizeToNew().add(i[d].position))),
- o == 1 && (i[d].position.set(this._boundingDimensions.x * s, this._boundingDimensions.y / 2, this._boundingDimensions.z * c),
- i[d].position.addInPlace(new Vector3(-this._boundingDimensions.x / 2,-this._boundingDimensions.y / 2,-this._boundingDimensions.z / 2)),
- i[d].lookAt(Vector3.Cross(i[d].position.normalizeToNew(), Vector3.Up()).normalizeToNew().add(i[d].position))),
- o == 2 && (i[d].position.set(this._boundingDimensions.x * s, this._boundingDimensions.y * c, this._boundingDimensions.z / 2),
- i[d].position.addInPlace(new Vector3(-this._boundingDimensions.x / 2,-this._boundingDimensions.y / 2,-this._boundingDimensions.z / 2)),
- i[d].lookAt(Vector3.Cross(i[d].position.normalizeToNew(), Vector3.Forward()).normalizeToNew().add(i[d].position))),
- this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
- i[d].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
- var _ = this.rotationSphereSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
- i[d].scaling.set(_, _, _)
- } else
- 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)
- }
- }
- ,
- e.prototype._updateScaleBoxes = function() {
- for (var i = this._scaleBoxesParent.getChildMeshes(), o = 0, s = 0; s < 3; s++)
- for (var c = 0; c < 3; c++)
- for (var d = 0; d < 3; d++) {
- var _ = (s === 1 ? 1 : 0) + (c === 1 ? 1 : 0) + (d === 1 ? 1 : 0);
- if (!(_ === 1 || _ === 3)) {
- if (i[o])
- if (i[o].position.set(this._boundingDimensions.x * (s / 2), this._boundingDimensions.y * (c / 2), this._boundingDimensions.z * (d / 2)),
- i[o].position.addInPlace(new Vector3(-this._boundingDimensions.x / 2,-this._boundingDimensions.y / 2,-this._boundingDimensions.z / 2)),
- this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
- i[o].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
- var b = this.scaleBoxSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
- i[o].scaling.set(b, b, b)
- } else
- 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);
- o++
- }
- }
- }
- ,
- e.prototype.setEnabledRotationAxis = function(i) {
- this._rotateSpheresParent.getChildMeshes().forEach(function(o, s) {
- s < 4 ? o.setEnabled(i.indexOf("x") != -1) : s < 8 ? o.setEnabled(i.indexOf("y") != -1) : o.setEnabled(i.indexOf("z") != -1)
- })
- }
- ,
- e.prototype.setEnabledScaling = function(i, o) {
- o === void 0 && (o = !1),
- this._scaleBoxesParent.getChildMeshes().forEach(function(s, c) {
- var d = i;
- o && s.metadata === !0 && (d = !1),
- s.setEnabled(d)
- })
- }
- ,
- e.prototype._updateDummy = function() {
- this._dragMesh && (this._dragMesh.position.copyFrom(this._lineBoundingBox.getAbsolutePosition()),
- this._dragMesh.scaling.copyFrom(this._lineBoundingBox.scaling),
- this._dragMesh.rotationQuaternion.copyFrom(this._rootMesh.rotationQuaternion))
- }
- ,
- e.prototype.enableDragBehavior = function() {
- this._dragMesh = CreateBox("dummy", {
- size: 1
- }, this.gizmoLayer.utilityLayerScene),
- this._dragMesh.visibility = 0,
- this._dragMesh.rotationQuaternion = new Quaternion,
- this.pointerDragBehavior.useObjectOrientationForDragging = !1,
- this._dragMesh.addBehavior(this.pointerDragBehavior)
- }
- ,
- e.prototype.dispose = function() {
- this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),
- this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver),
- this._lineBoundingBox.dispose(),
- this._rotateSpheresParent.dispose(),
- this._scaleBoxesParent.dispose(),
- this._dragMesh && this._dragMesh.dispose(),
- a.prototype.dispose.call(this)
- }
- ,
- e.MakeNotPickableAndWrapInBoundingBox = function(i) {
- var o = function(b) {
- b.isPickable = !1,
- b.getChildMeshes().forEach(function(k) {
- o(k)
- })
- };
- o(i),
- i.rotationQuaternion || (i.rotationQuaternion = Quaternion.RotationYawPitchRoll(i.rotation.y, i.rotation.x, i.rotation.z));
- var s = i.position.clone()
- , c = i.rotationQuaternion.clone();
- i.rotationQuaternion.set(0, 0, 0, 1),
- i.position.set(0, 0, 0);
- var d = CreateBox("box", {
- size: 1
- }, i.getScene())
- , _ = i.getHierarchyBoundingVectors();
- return _.max.subtractToRef(_.min, d.scaling),
- d.scaling.y === 0 && (d.scaling.y = Epsilon),
- d.scaling.x === 0 && (d.scaling.x = Epsilon),
- d.scaling.z === 0 && (d.scaling.z = Epsilon),
- d.position.set((_.max.x + _.min.x) / 2, (_.max.y + _.min.y) / 2, (_.max.z + _.min.z) / 2),
- i.addChild(d),
- i.rotationQuaternion.copyFrom(c),
- i.position.copyFrom(s),
- i.removeChild(d),
- d.addChild(i),
- d.visibility = 0,
- d
- }
- ,
- e.prototype.setCustomMesh = function(i) {
- Logger$2.Error("Custom meshes are not supported on this gizmo")
- }
- ,
- e
- }(Gizmo);
- (function() {
- function a(e, i, o, s) {
- i === void 0 && (i = 1),
- o === void 0 && (o = UtilityLayerRenderer.DefaultUtilityLayer),
- s === void 0 && (s = UtilityLayerRenderer.DefaultKeepDepthUtilityLayer),
- this.scene = e,
- this.clearGizmoOnEmptyPointerEvent = !1,
- this.onAttachedToMeshObservable = new Observable,
- this.onAttachedToNodeObservable = new Observable,
- this._gizmosEnabled = {
- positionGizmo: !1,
- rotationGizmo: !1,
- scaleGizmo: !1,
- boundingBoxGizmo: !1
- },
- this._pointerObservers = [],
- this._attachedMesh = null,
- this._attachedNode = null,
- this._boundingBoxColor = Color3.FromHexString("#0984e3"),
- this._thickness = 1,
- this._scaleRatio = 1,
- this._gizmoAxisCache = new Map,
- this.boundingBoxDragBehavior = new SixDofDragBehavior,
- this.attachableMeshes = null,
- this.attachableNodes = null,
- this.usePointerToAttachGizmos = !0,
- this._defaultUtilityLayer = o,
- this._defaultKeepDepthUtilityLayer = s,
- this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = !1,
- this._thickness = i,
- this.gizmos = {
- positionGizmo: null,
- rotationGizmo: null,
- scaleGizmo: null,
- boundingBoxGizmo: null
- };
- var c = this._attachToMeshPointerObserver(e)
- , d = Gizmo.GizmoAxisPointerObserver(this._defaultUtilityLayer, this._gizmoAxisCache);
- this._pointerObservers = [c, d]
- }
- return Object.defineProperty(a.prototype, "keepDepthUtilityLayer", {
- get: function() {
- return this._defaultKeepDepthUtilityLayer
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "utilityLayer", {
- get: function() {
- return this._defaultUtilityLayer
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "isHovered", {
- get: function() {
- var e = !1;
- for (var i in this.gizmos) {
- var o = this.gizmos[i];
- if (o && o.isHovered) {
- e = !0;
- break
- }
- }
- return e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "scaleRatio", {
- get: function() {
- return this._scaleRatio
- },
- set: function(e) {
- this._scaleRatio = e,
- [this.gizmos.positionGizmo, this.gizmos.rotationGizmo, this.gizmos.scaleGizmo].forEach(function(i) {
- i && (i.scaleRatio = e)
- })
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._attachToMeshPointerObserver = function(e) {
- var i = this
- , o = e.onPointerObservable.add(function(s) {
- if (!!i.usePointerToAttachGizmos && s.type == PointerEventTypes.POINTERDOWN)
- if (s.pickInfo && s.pickInfo.pickedMesh) {
- var c = s.pickInfo.pickedMesh;
- if (i.attachableMeshes == null)
- for (; c && c.parent != null; )
- c = c.parent;
- else {
- var d = !1;
- i.attachableMeshes.forEach(function(_) {
- c && (c == _ || c.isDescendantOf(_)) && (c = _,
- d = !0)
- }),
- d || (c = null)
- }
- c instanceof AbstractMesh ? i._attachedMesh != c && i.attachToMesh(c) : i.clearGizmoOnEmptyPointerEvent && i.attachToMesh(null)
- } else
- i.clearGizmoOnEmptyPointerEvent && i.attachToMesh(null)
- });
- return o
- }
- ,
- a.prototype.attachToMesh = function(e) {
- this._attachedMesh && this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior),
- this._attachedNode && this._attachedNode.removeBehavior(this.boundingBoxDragBehavior),
- this._attachedMesh = e,
- this._attachedNode = null;
- for (var i in this.gizmos) {
- var o = this.gizmos[i];
- o && this._gizmosEnabled[i] && (o.attachedMesh = e)
- }
- this.boundingBoxGizmoEnabled && this._attachedMesh && this._attachedMesh.addBehavior(this.boundingBoxDragBehavior),
- this.onAttachedToMeshObservable.notifyObservers(e)
- }
- ,
- a.prototype.attachToNode = function(e) {
- this._attachedMesh && this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior),
- this._attachedNode && this._attachedNode.removeBehavior(this.boundingBoxDragBehavior),
- this._attachedMesh = null,
- this._attachedNode = e;
- for (var i in this.gizmos) {
- var o = this.gizmos[i];
- o && this._gizmosEnabled[i] && (o.attachedNode = e)
- }
- this.boundingBoxGizmoEnabled && this._attachedNode && this._attachedNode.addBehavior(this.boundingBoxDragBehavior),
- this.onAttachedToNodeObservable.notifyObservers(e)
- }
- ,
- Object.defineProperty(a.prototype, "positionGizmoEnabled", {
- get: function() {
- return this._gizmosEnabled.positionGizmo
- },
- set: function(e) {
- e ? (this.gizmos.positionGizmo || (this.gizmos.positionGizmo = new PositionGizmo(this._defaultUtilityLayer,this._thickness,this)),
- this._attachedNode ? this.gizmos.positionGizmo.attachedNode = this._attachedNode : this.gizmos.positionGizmo.attachedMesh = this._attachedMesh) : this.gizmos.positionGizmo && (this.gizmos.positionGizmo.attachedNode = null),
- this._gizmosEnabled.positionGizmo = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "rotationGizmoEnabled", {
- get: function() {
- return this._gizmosEnabled.rotationGizmo
- },
- set: function(e) {
- e ? (this.gizmos.rotationGizmo || (this.gizmos.rotationGizmo = new RotationGizmo(this._defaultUtilityLayer,32,!1,this._thickness,this)),
- this._attachedNode ? this.gizmos.rotationGizmo.attachedNode = this._attachedNode : this.gizmos.rotationGizmo.attachedMesh = this._attachedMesh) : this.gizmos.rotationGizmo && (this.gizmos.rotationGizmo.attachedNode = null),
- this._gizmosEnabled.rotationGizmo = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "scaleGizmoEnabled", {
- get: function() {
- return this._gizmosEnabled.scaleGizmo
- },
- set: function(e) {
- e ? (this.gizmos.scaleGizmo = this.gizmos.scaleGizmo || new ScaleGizmo(this._defaultUtilityLayer,this._thickness,this),
- this._attachedNode ? this.gizmos.scaleGizmo.attachedNode = this._attachedNode : this.gizmos.scaleGizmo.attachedMesh = this._attachedMesh) : this.gizmos.scaleGizmo && (this.gizmos.scaleGizmo.attachedNode = null),
- this._gizmosEnabled.scaleGizmo = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "boundingBoxGizmoEnabled", {
- get: function() {
- return this._gizmosEnabled.boundingBoxGizmo
- },
- set: function(e) {
- e ? (this.gizmos.boundingBoxGizmo = this.gizmos.boundingBoxGizmo || new BoundingBoxGizmo(this._boundingBoxColor,this._defaultKeepDepthUtilityLayer),
- this._attachedMesh ? this.gizmos.boundingBoxGizmo.attachedMesh = this._attachedMesh : this.gizmos.boundingBoxGizmo.attachedNode = this._attachedNode,
- this._attachedMesh ? (this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior),
- this._attachedMesh.addBehavior(this.boundingBoxDragBehavior)) : this._attachedNode && (this._attachedNode.removeBehavior(this.boundingBoxDragBehavior),
- this._attachedNode.addBehavior(this.boundingBoxDragBehavior))) : this.gizmos.boundingBoxGizmo && (this._attachedMesh ? this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior) : this._attachedNode && this._attachedNode.removeBehavior(this.boundingBoxDragBehavior),
- this.gizmos.boundingBoxGizmo.attachedNode = null),
- this._gizmosEnabled.boundingBoxGizmo = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.addToAxisCache = function(e) {
- var i = this;
- e.size > 0 && e.forEach(function(o, s) {
- i._gizmoAxisCache.set(s, o)
- })
- }
- ,
- a.prototype.dispose = function() {
- var e = this, i, o;
- this._pointerObservers.forEach(function(d) {
- e.scene.onPointerObservable.remove(d)
- });
- for (var s in this.gizmos) {
- var c = this.gizmos[s];
- c && c.dispose()
- }
- this._defaultKeepDepthUtilityLayer !== UtilityLayerRenderer._DefaultKeepDepthUtilityLayer && ((i = this._defaultKeepDepthUtilityLayer) === null || i === void 0 || i.dispose()),
- this._defaultUtilityLayer !== UtilityLayerRenderer._DefaultUtilityLayer && ((o = this._defaultUtilityLayer) === null || o === void 0 || o.dispose()),
- this.boundingBoxDragBehavior.detach(),
- this.onAttachedToMeshObservable.clear()
- }
- ,
- a
- }
- )();
- var LayerSceneComponent = function() {
- function a(e) {
- this.name = SceneComponentConstants.NAME_LAYER,
- this.scene = e,
- this._engine = e.getEngine(),
- e.layers = new Array
- }
- return a.prototype.register = function() {
- this.scene._beforeCameraDrawStage.registerStep(SceneComponentConstants.STEP_BEFORECAMERADRAW_LAYER, this, this._drawCameraBackground),
- this.scene._afterCameraDrawStage.registerStep(SceneComponentConstants.STEP_AFTERCAMERADRAW_LAYER, this, this._drawCameraForeground),
- this.scene._beforeRenderTargetDrawStage.registerStep(SceneComponentConstants.STEP_BEFORERENDERTARGETDRAW_LAYER, this, this._drawRenderTargetBackground),
- this.scene._afterRenderTargetDrawStage.registerStep(SceneComponentConstants.STEP_AFTERRENDERTARGETDRAW_LAYER, this, this._drawRenderTargetForeground)
- }
- ,
- a.prototype.rebuild = function() {
- for (var e = this.scene.layers, i = 0, o = e; i < o.length; i++) {
- var s = o[i];
- s._rebuild()
- }
- }
- ,
- a.prototype.dispose = function() {
- for (var e = this.scene.layers; e.length; )
- e[0].dispose()
- }
- ,
- a.prototype._draw = function(e) {
- var i = this.scene.layers;
- if (i.length) {
- this._engine.setDepthBuffer(!1);
- for (var o = 0, s = i; o < s.length; o++) {
- var c = s[o];
- e(c) && c.render()
- }
- this._engine.setDepthBuffer(!0)
- }
- }
- ,
- a.prototype._drawCameraPredicate = function(e, i, o) {
- return !e.renderOnlyInRenderTargetTextures && e.isBackground === i && (e.layerMask & o) !== 0
- }
- ,
- a.prototype._drawCameraBackground = function(e) {
- var i = this;
- this._draw(function(o) {
- return i._drawCameraPredicate(o, !0, e.layerMask)
- })
- }
- ,
- a.prototype._drawCameraForeground = function(e) {
- var i = this;
- this._draw(function(o) {
- return i._drawCameraPredicate(o, !1, e.layerMask)
- })
- }
- ,
- a.prototype._drawRenderTargetPredicate = function(e, i, o, s) {
- return e.renderTargetTextures.length > 0 && e.isBackground === i && e.renderTargetTextures.indexOf(s) > -1 && (e.layerMask & o) !== 0
- }
- ,
- a.prototype._drawRenderTargetBackground = function(e) {
- var i = this;
- this._draw(function(o) {
- return i._drawRenderTargetPredicate(o, !0, i.scene.activeCamera.layerMask, e)
- })
- }
- ,
- a.prototype._drawRenderTargetForeground = function(e) {
- var i = this;
- this._draw(function(o) {
- return i._drawRenderTargetPredicate(o, !1, i.scene.activeCamera.layerMask, e)
- })
- }
- ,
- a.prototype.addFromContainer = function(e) {
- var i = this;
- !e.layers || e.layers.forEach(function(o) {
- i.scene.layers.push(o)
- })
- }
- ,
- a.prototype.removeFromContainer = function(e, i) {
- var o = this;
- i === void 0 && (i = !1),
- e.layers && e.layers.forEach(function(s) {
- var c = o.scene.layers.indexOf(s);
- c !== -1 && o.scene.layers.splice(c, 1),
- i && s.dispose()
- })
- }
- ,
- a
- }()
- , name$j = "layerPixelShader"
- , shader$j = `
- varying vec2 vUV;
- uniform sampler2D textureSampler;
- uniform vec4 color;
- #include<helperFunctions>
- void main(void) {
- vec4 baseColor=texture2D(textureSampler,vUV);
- #ifdef LINEAR
- baseColor.rgb=toGammaSpace(baseColor.rgb);
- #endif
- #ifdef ALPHATEST
- if (baseColor.a<0.4)
- discard;
- #endif
- gl_FragColor=baseColor*color;
- }`;
- ShaderStore.ShadersStore[name$j] = shader$j;
- var name$i = "layerVertexShader"
- , shader$i = `
- attribute vec2 position;
- uniform vec2 scale;
- uniform vec2 offset;
- uniform mat4 textureMatrix;
- varying vec2 vUV;
- const vec2 madd=vec2(0.5,0.5);
- void main(void) {
- vec2 shiftedPosition=position*scale+offset;
- vUV=vec2(textureMatrix*vec4(shiftedPosition*madd+madd,1.0,0.0));
- gl_Position=vec4(shiftedPosition,0.0,1.0);
- }`;
- ShaderStore.ShadersStore[name$i] = shader$i;
- var Layer = function() {
- function a(e, i, o, s, c) {
- this.name = e,
- this.scale = new Vector2(1,1),
- this.offset = new Vector2(0,0),
- this.alphaBlendingMode = 2,
- this.layerMask = 268435455,
- this.renderTargetTextures = [],
- this.renderOnlyInRenderTargetTextures = !1,
- this.isEnabled = !0,
- this._vertexBuffers = {},
- this.onDisposeObservable = new Observable,
- this.onBeforeRenderObservable = new Observable,
- this.onAfterRenderObservable = new Observable,
- this.texture = i ? new Texture(i,o,!0) : null,
- this.isBackground = s === void 0 ? !0 : s,
- this.color = c === void 0 ? new Color4(1,1,1,1) : c,
- this._scene = o || EngineStore.LastCreatedScene;
- var d = this._scene._getComponent(SceneComponentConstants.NAME_LAYER);
- d || (d = new LayerSceneComponent(this._scene),
- this._scene._addComponent(d)),
- this._scene.layers.push(this);
- var _ = this._scene.getEngine();
- this._drawWrapper = new DrawWrapper(_);
- var b = [];
- b.push(1, 1),
- b.push(-1, 1),
- b.push(-1, -1),
- b.push(1, -1);
- var k = new VertexBuffer(_,b,VertexBuffer.PositionKind,!1,!1,2);
- this._vertexBuffers[VertexBuffer.PositionKind] = k,
- this._createIndexBuffer()
- }
- return Object.defineProperty(a.prototype, "onDispose", {
- set: function(e) {
- this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver),
- this._onDisposeObserver = this.onDisposeObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "onBeforeRender", {
- set: function(e) {
- this._onBeforeRenderObserver && this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),
- this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "onAfterRender", {
- set: function(e) {
- this._onAfterRenderObserver && this.onAfterRenderObservable.remove(this._onAfterRenderObserver),
- this._onAfterRenderObserver = this.onAfterRenderObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._createIndexBuffer = function() {
- var e = this._scene.getEngine()
- , i = [];
- i.push(0),
- i.push(1),
- i.push(2),
- i.push(0),
- i.push(2),
- i.push(3),
- this._indexBuffer = e.createIndexBuffer(i)
- }
- ,
- a.prototype._rebuild = function() {
- var e = this._vertexBuffers[VertexBuffer.PositionKind];
- e && e._rebuild(),
- this._createIndexBuffer()
- }
- ,
- a.prototype.render = function() {
- if (!!this.isEnabled) {
- var o = this._scene.getEngine()
- , e = "";
- this.alphaTest && (e = "#define ALPHATEST"),
- this.texture && !this.texture.gammaSpace && (e += `\r
- #define LINEAR`),
- this._previousDefines !== e && (this._previousDefines = e,
- this._drawWrapper.effect = o.createEffect("layer", [VertexBuffer.PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], e));
- var i = this._drawWrapper.effect;
- if (!(!i || !i.isReady() || !this.texture || !this.texture.isReady())) {
- var o = this._scene.getEngine();
- this.onBeforeRenderObservable.notifyObservers(this),
- o.enableEffect(this._drawWrapper),
- o.setState(!1),
- i.setTexture("textureSampler", this.texture),
- i.setMatrix("textureMatrix", this.texture.getTextureMatrix()),
- i.setFloat4("color", this.color.r, this.color.g, this.color.b, this.color.a),
- i.setVector2("offset", this.offset),
- i.setVector2("scale", this.scale),
- o.bindBuffers(this._vertexBuffers, this._indexBuffer, i),
- this.alphaTest ? o.drawElementsType(Material.TriangleFillMode, 0, 6) : (o.setAlphaMode(this.alphaBlendingMode),
- o.drawElementsType(Material.TriangleFillMode, 0, 6),
- o.setAlphaMode(0)),
- this.onAfterRenderObservable.notifyObservers(this)
- }
- }
- }
- ,
- a.prototype.dispose = function() {
- var e = this._vertexBuffers[VertexBuffer.PositionKind];
- e && (e.dispose(),
- this._vertexBuffers[VertexBuffer.PositionKind] = null),
- this._indexBuffer && (this._scene.getEngine()._releaseBuffer(this._indexBuffer),
- this._indexBuffer = null),
- this.texture && (this.texture.dispose(),
- this.texture = null),
- this.renderTargetTextures = [];
- var i = this._scene.layers.indexOf(this);
- this._scene.layers.splice(i, 1),
- this.onDisposeObservable.notifyObservers(this),
- this.onDisposeObservable.clear(),
- this.onAfterRenderObservable.clear(),
- this.onBeforeRenderObservable.clear()
- }
- ,
- a
- }()
- , name$h = "boundingBoxRendererFragmentDeclaration"
- , shader$h = `uniform vec4 color;
- `;
- ShaderStore.IncludesShadersStore[name$h] = shader$h;
- var name$g = "boundingBoxRendererUboDeclaration"
- , shader$g = `layout(std140,column_major) uniform;
- uniform BoundingBoxRenderer {
- vec4 color;
- mat4 world;
- mat4 viewProjection;
- mat4 viewProjectionR;
- };
- `;
- ShaderStore.IncludesShadersStore[name$g] = shader$g;
- var name$f = "boundingBoxRendererPixelShader"
- , shader$f = `#include<__decl__boundingBoxRendererFragment>
- void main(void) {
- gl_FragColor=color;
- }`;
- ShaderStore.ShadersStore[name$f] = shader$f;
- var name$e = "boundingBoxRendererVertexDeclaration"
- , shader$e = `uniform mat4 world;
- uniform mat4 viewProjection;
- #ifdef MULTIVIEW
- uniform mat4 viewProjectionR;
- #endif
- `;
- ShaderStore.IncludesShadersStore[name$e] = shader$e;
- var name$d = "boundingBoxRendererVertexShader"
- , shader$d = `
- attribute vec3 position;
- #include<__decl__boundingBoxRendererVertex>
- void main(void) {
- vec4 worldPos=world*vec4(position,1.0);
- #ifdef MULTIVIEW
- if (gl_ViewID_OVR == 0u) {
- gl_Position=viewProjection*worldPos;
- } else {
- gl_Position=viewProjectionR*worldPos;
- }
- #else
- gl_Position=viewProjection*worldPos;
- #endif
- }
- `;
- ShaderStore.ShadersStore[name$d] = shader$d;
- Object.defineProperty(Scene.prototype, "forceShowBoundingBoxes", {
- get: function() {
- return this._forceShowBoundingBoxes || !1
- },
- set: function(a) {
- this._forceShowBoundingBoxes = a,
- a && this.getBoundingBoxRenderer()
- },
- enumerable: !0,
- configurable: !0
- });
- Scene.prototype.getBoundingBoxRenderer = function() {
- return this._boundingBoxRenderer || (this._boundingBoxRenderer = new BoundingBoxRenderer(this)),
- this._boundingBoxRenderer
- }
- ;
- Object.defineProperty(AbstractMesh.prototype, "showBoundingBox", {
- get: function() {
- return this._showBoundingBox || !1
- },
- set: function(a) {
- this._showBoundingBox = a,
- a && this.getScene().getBoundingBoxRenderer()
- },
- enumerable: !0,
- configurable: !0
- });
- var BoundingBoxRenderer = function() {
- function a(e) {
- this.name = SceneComponentConstants.NAME_BOUNDINGBOXRENDERER,
- this.frontColor = new Color3(1,1,1),
- this.backColor = new Color3(.1,.1,.1),
- this.showBackLines = !0,
- this.onBeforeBoxRenderingObservable = new Observable,
- this.onAfterBoxRenderingObservable = new Observable,
- this.onResourcesReadyObservable = new Observable,
- this.enabled = !0,
- this.renderList = new SmartArray(32),
- this._vertexBuffers = {},
- this._fillIndexBuffer = null,
- this._fillIndexData = null,
- this.scene = e,
- e._addComponent(this),
- this._uniformBufferFront = new UniformBuffer(this.scene.getEngine(),void 0,void 0,"BoundingBoxRendererFront"),
- this._buildUniformLayout(this._uniformBufferFront),
- this._uniformBufferBack = new UniformBuffer(this.scene.getEngine(),void 0,void 0,"BoundingBoxRendererBack"),
- this._buildUniformLayout(this._uniformBufferBack)
- }
- return a.prototype._buildUniformLayout = function(e) {
- e.addUniform("color", 4),
- e.addUniform("world", 16),
- e.addUniform("viewProjection", 16),
- e.addUniform("viewProjectionR", 16),
- e.create()
- }
- ,
- a.prototype.register = function() {
- this.scene._beforeEvaluateActiveMeshStage.registerStep(SceneComponentConstants.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER, this, this.reset),
- this.scene._preActiveMeshStage.registerStep(SceneComponentConstants.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER, this, this._preActiveMesh),
- this.scene._evaluateSubMeshStage.registerStep(SceneComponentConstants.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER, this, this._evaluateSubMesh),
- this.scene._afterRenderingGroupDrawStage.registerStep(SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER, this, this.render)
- }
- ,
- a.prototype._evaluateSubMesh = function(e, i) {
- if (e.showSubMeshesBoundingBox) {
- var o = i.getBoundingInfo();
- o != null && (o.boundingBox._tag = e.renderingGroupId,
- this.renderList.push(o.boundingBox))
- }
- }
- ,
- a.prototype._preActiveMesh = function(e) {
- if (e.showBoundingBox || this.scene.forceShowBoundingBoxes) {
- var i = e.getBoundingInfo();
- i.boundingBox._tag = e.renderingGroupId,
- this.renderList.push(i.boundingBox)
- }
- }
- ,
- a.prototype._prepareResources = function() {
- if (!this._colorShader) {
- this._colorShader = new ShaderMaterial("colorShader",this.scene,"boundingBoxRenderer",{
- attributes: [VertexBuffer.PositionKind],
- uniforms: ["world", "viewProjection", "color"],
- uniformBuffers: ["BoundingBoxRenderer"]
- },!1),
- this._colorShader.reservedDataStore = {
- hidden: !0
- },
- this._colorShaderForOcclusionQuery = new ShaderMaterial("colorShaderOccQuery",this.scene,"boundingBoxRenderer",{
- attributes: [VertexBuffer.PositionKind],
- uniforms: ["world", "viewProjection", "color"],
- uniformBuffers: ["BoundingBoxRenderer"]
- },!0),
- this._colorShaderForOcclusionQuery.reservedDataStore = {
- hidden: !0
- };
- var e = this.scene.getEngine()
- , i = CreateBoxVertexData({
- size: 1
- });
- this._vertexBuffers[VertexBuffer.PositionKind] = new VertexBuffer(e,i.positions,VertexBuffer.PositionKind,!1),
- this._createIndexBuffer(),
- this._fillIndexData = i.indices,
- this.onResourcesReadyObservable.notifyObservers(this)
- }
- }
- ,
- a.prototype._createIndexBuffer = function() {
- var e = this.scene.getEngine();
- 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])
- }
- ,
- a.prototype.rebuild = function() {
- var e = this._vertexBuffers[VertexBuffer.PositionKind];
- e && e._rebuild(),
- this._createIndexBuffer()
- }
- ,
- a.prototype.reset = function() {
- this.renderList.reset()
- }
- ,
- a.prototype.render = function(e) {
- var i, o;
- if (!(this.renderList.length === 0 || !this.enabled) && (this._prepareResources(),
- !!this._colorShader.isReady())) {
- var s = this.scene.getEngine();
- s.setDepthWrite(!1);
- for (var c = this.frontColor.toColor4(), d = this.backColor.toColor4(), _ = this.scene.getTransformMatrix(), b = 0; b < this.renderList.length; b++) {
- var k = this.renderList.data[b];
- if (k._tag === e) {
- this._createWrappersForBoundingBox(k),
- this.onBeforeBoxRenderingObservable.notifyObservers(k);
- var j = k.minimum
- , $ = k.maximum
- , _e = $.subtract(j)
- , et = j.add(_e.scale(.5))
- , tt = Matrix.Scaling(_e.x, _e.y, _e.z).multiply(Matrix.Translation(et.x, et.y, et.z)).multiply(k.getWorldMatrix())
- , rt = s.useReverseDepthBuffer;
- if (this.showBackLines) {
- var it = (i = k._drawWrapperBack) !== null && i !== void 0 ? i : this._colorShader._getDrawWrapper();
- this._colorShader._preBind(it),
- s.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect()),
- rt ? s.setDepthFunctionToLessOrEqual() : s.setDepthFunctionToGreaterOrEqual(),
- this._uniformBufferBack.bindToEffect(it.effect, "BoundingBoxRenderer"),
- this._uniformBufferBack.updateDirectColor4("color", d),
- this._uniformBufferBack.updateMatrix("world", tt),
- this._uniformBufferBack.updateMatrix("viewProjection", _),
- this._uniformBufferBack.update(),
- s.drawElementsType(Material.LineListDrawMode, 0, 24)
- }
- var nt = (o = k._drawWrapperFront) !== null && o !== void 0 ? o : this._colorShader._getDrawWrapper();
- this._colorShader._preBind(nt),
- s.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect()),
- rt ? s.setDepthFunctionToGreater() : s.setDepthFunctionToLess(),
- this._uniformBufferFront.bindToEffect(nt.effect, "BoundingBoxRenderer"),
- this._uniformBufferFront.updateDirectColor4("color", c),
- this._uniformBufferFront.updateMatrix("world", tt),
- this._uniformBufferFront.updateMatrix("viewProjection", _),
- this._uniformBufferFront.update(),
- s.drawElementsType(Material.LineListDrawMode, 0, 24),
- this.onAfterBoxRenderingObservable.notifyObservers(k)
- }
- }
- this._colorShader.unbind(),
- s.setDepthFunctionToLessOrEqual(),
- s.setDepthWrite(!0)
- }
- }
- ,
- a.prototype._createWrappersForBoundingBox = function(e) {
- if (!e._drawWrapperFront) {
- var i = this.scene.getEngine();
- e._drawWrapperFront = new DrawWrapper(i),
- e._drawWrapperBack = new DrawWrapper(i),
- e._drawWrapperFront.setEffect(this._colorShader.getEffect()),
- e._drawWrapperBack.setEffect(this._colorShader.getEffect())
- }
- }
- ,
- a.prototype.renderOcclusionBoundingBox = function(e) {
- var i = this.scene.getEngine();
- this._renderPassIdForOcclusionQuery === void 0 && (this._renderPassIdForOcclusionQuery = i.createRenderPassId("Render pass for occlusion query"));
- var o = i.currentRenderPassId;
- i.currentRenderPassId = this._renderPassIdForOcclusionQuery,
- this._prepareResources();
- var s = e.subMeshes[0];
- if (!this._colorShaderForOcclusionQuery.isReady(e, void 0, s) || !e.hasBoundingInfo) {
- i.currentRenderPassId = o;
- return
- }
- this._fillIndexBuffer || (this._fillIndexBuffer = i.createIndexBuffer(this._fillIndexData));
- var c = i.useReverseDepthBuffer;
- i.setDepthWrite(!1),
- i.setColorWrite(!1);
- var d = e.getBoundingInfo().boundingBox
- , _ = d.minimum
- , b = d.maximum
- , k = b.subtract(_)
- , j = _.add(k.scale(.5))
- , $ = Matrix.Scaling(k.x, k.y, k.z).multiply(Matrix.Translation(j.x, j.y, j.z)).multiply(d.getWorldMatrix())
- , _e = s._drawWrapper;
- this._colorShaderForOcclusionQuery._preBind(_e),
- i.bindBuffers(this._vertexBuffers, this._fillIndexBuffer, _e.effect),
- c ? i.setDepthFunctionToGreater() : i.setDepthFunctionToLess(),
- this.scene.resetCachedMaterial(),
- this._uniformBufferFront.bindToEffect(_e.effect, "BoundingBoxRenderer"),
- this._uniformBufferFront.updateMatrix("world", $),
- this._uniformBufferFront.updateMatrix("viewProjection", this.scene.getTransformMatrix()),
- this._uniformBufferFront.update(),
- i.drawElementsType(Material.TriangleFillMode, 0, 36),
- this._colorShaderForOcclusionQuery.unbind(),
- i.setDepthFunctionToLessOrEqual(),
- i.setDepthWrite(!0),
- i.setColorWrite(!0),
- i.currentRenderPassId = o
- }
- ,
- a.prototype.dispose = function() {
- if (this._renderPassIdForOcclusionQuery !== void 0 && (this.scene.getEngine().releaseRenderPassId(this._renderPassIdForOcclusionQuery),
- this._renderPassIdForOcclusionQuery = void 0),
- !!this._colorShader) {
- this.onBeforeBoxRenderingObservable.clear(),
- this.onAfterBoxRenderingObservable.clear(),
- this.onResourcesReadyObservable.clear(),
- this.renderList.dispose(),
- this._colorShader.dispose(),
- this._colorShaderForOcclusionQuery.dispose(),
- this._uniformBufferFront.dispose(),
- this._uniformBufferBack.dispose();
- var e = this._vertexBuffers[VertexBuffer.PositionKind];
- e && (e.dispose(),
- this._vertexBuffers[VertexBuffer.PositionKind] = null),
- this.scene.getEngine()._releaseBuffer(this._indexBuffer),
- this._fillIndexBuffer && (this.scene.getEngine()._releaseBuffer(this._fillIndexBuffer),
- this._fillIndexBuffer = null)
- }
- }
- ,
- a
- }()
- , DataReader = function() {
- function a(e) {
- this.byteOffset = 0,
- this.buffer = e
- }
- return a.prototype.loadAsync = function(e) {
- var i = this;
- return this.buffer.readAsync(this.byteOffset, e).then(function(o) {
- i._dataView = new DataView(o.buffer,o.byteOffset,o.byteLength),
- i._dataByteOffset = 0
- })
- }
- ,
- a.prototype.readUint32 = function() {
- var e = this._dataView.getUint32(this._dataByteOffset, !0);
- return this._dataByteOffset += 4,
- this.byteOffset += 4,
- e
- }
- ,
- a.prototype.readUint8Array = function(e) {
- var i = new Uint8Array(this._dataView.buffer,this._dataView.byteOffset + this._dataByteOffset,e);
- return this._dataByteOffset += e,
- this.byteOffset += e,
- i
- }
- ,
- a.prototype.readString = function(e) {
- return Decode(this.readUint8Array(e))
- }
- ,
- a.prototype.skipBytes = function(e) {
- this._dataByteOffset += e,
- this.byteOffset += e
- }
- ,
- a
- }();
- function validateAsync(a, e, i, o) {
- var s = {
- externalResourceFunction: function(c) {
- return o(c).then(function(d) {
- return new Uint8Array(d)
- })
- }
- };
- return i && (s.uri = e === "file:" ? i : e + i),
- a instanceof ArrayBuffer ? GLTFValidator.validateBytes(new Uint8Array(a), s) : GLTFValidator.validateString(a, s)
- }
- function workerFunc$1() {
- var a = [];
- onmessage = function(e) {
- var i = e.data;
- switch (i.id) {
- case "init":
- {
- importScripts(i.url);
- break
- }
- case "validate":
- {
- validateAsync(i.data, i.rootUrl, i.fileName, function(o) {
- return new Promise(function(s, c) {
- var d = a.length;
- a.push({
- resolve: s,
- reject: c
- }),
- postMessage({
- id: "getExternalResource",
- index: d,
- uri: o
- })
- }
- )
- }).then(function(o) {
- postMessage({
- id: "validate.resolve",
- value: o
- })
- }, function(o) {
- postMessage({
- id: "validate.reject",
- reason: o
- })
- });
- break
- }
- case "getExternalResource.resolve":
- {
- a[i.index].resolve(i.value);
- break
- }
- case "getExternalResource.reject":
- {
- a[i.index].reject(i.reason);
- break
- }
- }
- }
- }
- var GLTFValidation = function() {
- function a() {}
- return a.ValidateAsync = function(e, i, o, s) {
- var c = this;
- return typeof Worker == "function" ? new Promise(function(d, _) {
- var b = validateAsync + "(" + workerFunc$1 + ")()"
- , k = URL.createObjectURL(new Blob([b],{
- type: "application/javascript"
- }))
- , j = new Worker(k)
- , $ = function(et) {
- j.removeEventListener("error", $),
- j.removeEventListener("message", _e),
- _(et)
- }
- , _e = function(et) {
- var tt = et.data;
- switch (tt.id) {
- case "getExternalResource":
- {
- s(tt.uri).then(function(rt) {
- j.postMessage({
- id: "getExternalResource.resolve",
- index: tt.index,
- value: rt
- }, [rt])
- }, function(rt) {
- j.postMessage({
- id: "getExternalResource.reject",
- index: tt.index,
- reason: rt
- })
- });
- break
- }
- case "validate.resolve":
- {
- j.removeEventListener("error", $),
- j.removeEventListener("message", _e),
- d(tt.value);
- break
- }
- case "validate.reject":
- j.removeEventListener("error", $),
- j.removeEventListener("message", _e),
- _(tt.reason)
- }
- };
- j.addEventListener("error", $),
- j.addEventListener("message", _e),
- j.postMessage({
- id: "init",
- url: c.Configuration.url
- }),
- j.postMessage({
- id: "validate",
- data: e,
- rootUrl: i,
- fileName: o
- })
- }
- ) : (this._LoadScriptPromise || (this._LoadScriptPromise = Tools.LoadScriptAsync(this.Configuration.url)),
- this._LoadScriptPromise.then(function() {
- return validateAsync(e, i, o, s)
- }))
- }
- ,
- a.Configuration = {
- url: "https://preview.babylonjs.com/gltf_validator.js"
- },
- a
- }();
- function readAsync(a, e, i) {
- try {
- return Promise.resolve(new Uint8Array(a,e,i))
- } catch (o) {
- return Promise.reject(o)
- }
- }
- var GLTFLoaderCoordinateSystemMode;
- (function(a) {
- a[a.AUTO = 0] = "AUTO",
- a[a.FORCE_RIGHT_HANDED = 1] = "FORCE_RIGHT_HANDED"
- }
- )(GLTFLoaderCoordinateSystemMode || (GLTFLoaderCoordinateSystemMode = {}));
- var GLTFLoaderAnimationStartMode;
- (function(a) {
- a[a.NONE = 0] = "NONE",
- a[a.FIRST = 1] = "FIRST",
- a[a.ALL = 2] = "ALL"
- }
- )(GLTFLoaderAnimationStartMode || (GLTFLoaderAnimationStartMode = {}));
- var GLTFLoaderState;
- (function(a) {
- a[a.LOADING = 0] = "LOADING",
- a[a.READY = 1] = "READY",
- a[a.COMPLETE = 2] = "COMPLETE"
- }
- )(GLTFLoaderState || (GLTFLoaderState = {}));
- var GLTFFileLoader = function() {
- function a() {
- this.onParsedObservable = new Observable,
- this.coordinateSystemMode = GLTFLoaderCoordinateSystemMode.AUTO,
- this.animationStartMode = GLTFLoaderAnimationStartMode.FIRST,
- this.compileMaterials = !1,
- this.useClipPlane = !1,
- this.compileShadowGenerators = !1,
- this.transparencyAsCoverage = !1,
- this.useRangeRequests = !1,
- this.createInstances = !0,
- this.alwaysComputeBoundingBox = !1,
- this.loadAllMaterials = !1,
- this.useSRGBBuffers = !0,
- this.preprocessUrlAsync = function(e) {
- return Promise.resolve(e)
- }
- ,
- this.onMeshLoadedObservable = new Observable,
- this.onTextureLoadedObservable = new Observable,
- this.onMaterialLoadedObservable = new Observable,
- this.onCameraLoadedObservable = new Observable,
- this.onCompleteObservable = new Observable,
- this.onErrorObservable = new Observable,
- this.onDisposeObservable = new Observable,
- this.onExtensionLoadedObservable = new Observable,
- this.validate = !1,
- this.onValidatedObservable = new Observable,
- this._loader = null,
- this._state = null,
- this._requests = new Array,
- this.name = "gltf",
- this.extensions = {
- ".gltf": {
- isBinary: !1
- },
- ".glb": {
- isBinary: !0
- }
- },
- this.onLoaderStateChangedObservable = new Observable,
- this._logIndentLevel = 0,
- this._loggingEnabled = !1,
- this._log = this._logDisabled,
- this._capturePerformanceCounters = !1,
- this._startPerformanceCounter = this._startPerformanceCounterDisabled,
- this._endPerformanceCounter = this._endPerformanceCounterDisabled
- }
- return Object.defineProperty(a.prototype, "onParsed", {
- set: function(e) {
- this._onParsedObserver && this.onParsedObservable.remove(this._onParsedObserver),
- this._onParsedObserver = this.onParsedObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "onMeshLoaded", {
- set: function(e) {
- this._onMeshLoadedObserver && this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver),
- this._onMeshLoadedObserver = this.onMeshLoadedObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "onTextureLoaded", {
- set: function(e) {
- this._onTextureLoadedObserver && this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver),
- this._onTextureLoadedObserver = this.onTextureLoadedObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "onMaterialLoaded", {
- set: function(e) {
- this._onMaterialLoadedObserver && this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver),
- this._onMaterialLoadedObserver = this.onMaterialLoadedObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "onCameraLoaded", {
- set: function(e) {
- this._onCameraLoadedObserver && this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver),
- this._onCameraLoadedObserver = this.onCameraLoadedObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "onComplete", {
- set: function(e) {
- this._onCompleteObserver && this.onCompleteObservable.remove(this._onCompleteObserver),
- this._onCompleteObserver = this.onCompleteObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "onError", {
- set: function(e) {
- this._onErrorObserver && this.onErrorObservable.remove(this._onErrorObserver),
- this._onErrorObserver = this.onErrorObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "onDispose", {
- set: function(e) {
- this._onDisposeObserver && this.onDisposeObservable.remove(this._onDisposeObserver),
- this._onDisposeObserver = this.onDisposeObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "onExtensionLoaded", {
- set: function(e) {
- this._onExtensionLoadedObserver && this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver),
- this._onExtensionLoadedObserver = this.onExtensionLoadedObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "loggingEnabled", {
- get: function() {
- return this._loggingEnabled
- },
- set: function(e) {
- this._loggingEnabled !== e && (this._loggingEnabled = e,
- this._loggingEnabled ? this._log = this._logEnabled : this._log = this._logDisabled)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "capturePerformanceCounters", {
- get: function() {
- return this._capturePerformanceCounters
- },
- set: function(e) {
- this._capturePerformanceCounters !== e && (this._capturePerformanceCounters = e,
- this._capturePerformanceCounters ? (this._startPerformanceCounter = this._startPerformanceCounterEnabled,
- this._endPerformanceCounter = this._endPerformanceCounterEnabled) : (this._startPerformanceCounter = this._startPerformanceCounterDisabled,
- this._endPerformanceCounter = this._endPerformanceCounterDisabled))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "onValidated", {
- set: function(e) {
- this._onValidatedObserver && this.onValidatedObservable.remove(this._onValidatedObserver),
- this._onValidatedObserver = this.onValidatedObservable.add(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.dispose = function() {
- this._loader && (this._loader.dispose(),
- this._loader = null);
- for (var e = 0, i = this._requests; e < i.length; e++) {
- var o = i[e];
- o.abort()
- }
- this._requests.length = 0,
- delete this._progressCallback,
- this.preprocessUrlAsync = function(s) {
- return Promise.resolve(s)
- }
- ,
- this.onMeshLoadedObservable.clear(),
- this.onTextureLoadedObservable.clear(),
- this.onMaterialLoadedObservable.clear(),
- this.onCameraLoadedObservable.clear(),
- this.onCompleteObservable.clear(),
- this.onExtensionLoadedObservable.clear(),
- this.onDisposeObservable.notifyObservers(void 0),
- this.onDisposeObservable.clear()
- }
- ,
- a.prototype.loadFile = function(e, i, o, s, c, d) {
- var _ = this;
- if (this._progressCallback = s,
- c) {
- if (this.useRangeRequests) {
- this.validate && Logger$2.Warn("glTF validation is not supported when range requests are enabled");
- var b = {
- abort: function() {},
- onCompleteObservable: new Observable
- }
- , k = {
- readAsync: function(j, $) {
- return new Promise(function(_e, et) {
- _._loadFile(e, i, function(tt) {
- _e(new Uint8Array(tt))
- }, !0, function(tt) {
- et(tt)
- }, function(tt) {
- tt.setRequestHeader("Range", "bytes=" + j + "-" + (j + $ - 1))
- })
- }
- )
- },
- byteLength: 0
- };
- return this._unpackBinaryAsync(new DataReader(k)).then(function(j) {
- b.onCompleteObservable.notifyObservers(b),
- o(j)
- }, d ? function(j) {
- return d(void 0, j)
- }
- : void 0),
- b
- }
- return this._loadFile(e, i, function(j) {
- var $ = j;
- _._unpackBinaryAsync(new DataReader({
- readAsync: function(_e, et) {
- return readAsync($, _e, et)
- },
- byteLength: $.byteLength
- })).then(function(_e) {
- o(_e)
- }, d ? function(_e) {
- return d(void 0, _e)
- }
- : void 0)
- }, !0, d)
- }
- return this._loadFile(e, i, function(j) {
- if (i.name)
- _._validate(e, j, "file:", i.name);
- else {
- var $ = i;
- _._validate(e, j, Tools.GetFolderPath($), Tools.GetFilename($))
- }
- o({
- json: _._parseJson(j)
- })
- }, c, d)
- }
- ,
- a.prototype.importMeshAsync = function(e, i, o, s, c, d) {
- var _ = this;
- return Promise.resolve().then(function() {
- return _.onParsedObservable.notifyObservers(o),
- _.onParsedObservable.clear(),
- _._log("Loading " + (d || "")),
- _._loader = _._getLoader(o),
- _._loader.importMeshAsync(e, i, null, o, s, c, d)
- })
- }
- ,
- a.prototype.loadAsync = function(e, i, o, s, c) {
- var d = this;
- return Promise.resolve().then(function() {
- return d.onParsedObservable.notifyObservers(i),
- d.onParsedObservable.clear(),
- d._log("Loading " + (c || "")),
- d._loader = d._getLoader(i),
- d._loader.loadAsync(e, i, o, s, c)
- })
- }
- ,
- a.prototype.loadAssetContainerAsync = function(e, i, o, s, c) {
- var d = this;
- return Promise.resolve().then(function() {
- d.onParsedObservable.notifyObservers(i),
- d.onParsedObservable.clear(),
- d._log("Loading " + (c || "")),
- d._loader = d._getLoader(i);
- var _ = new AssetContainer(e)
- , b = [];
- d.onMaterialLoadedObservable.add(function($) {
- b.push($)
- });
- var k = [];
- d.onTextureLoadedObservable.add(function($) {
- k.push($)
- });
- var j = [];
- return d.onCameraLoadedObservable.add(function($) {
- j.push($)
- }),
- d._loader.importMeshAsync(null, e, _, i, o, s, c).then(function($) {
- return Array.prototype.push.apply(_.geometries, $.geometries),
- Array.prototype.push.apply(_.meshes, $.meshes),
- Array.prototype.push.apply(_.particleSystems, $.particleSystems),
- Array.prototype.push.apply(_.skeletons, $.skeletons),
- Array.prototype.push.apply(_.animationGroups, $.animationGroups),
- Array.prototype.push.apply(_.materials, b),
- Array.prototype.push.apply(_.textures, k),
- Array.prototype.push.apply(_.lights, $.lights),
- Array.prototype.push.apply(_.transformNodes, $.transformNodes),
- Array.prototype.push.apply(_.cameras, j),
- _
- })
- })
- }
- ,
- a.prototype.canDirectLoad = function(e) {
- 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)
- }
- ,
- a.prototype.directLoad = function(e, i) {
- 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)) {
- var o = DecodeBase64UrlToBinary(i);
- return this._validate(e, o),
- this._unpackBinaryAsync(new DataReader({
- readAsync: function(s, c) {
- return readAsync(o, s, c)
- },
- byteLength: o.byteLength
- }))
- }
- return this._validate(e, i),
- Promise.resolve({
- json: this._parseJson(i)
- })
- }
- ,
- a.prototype.createPlugin = function() {
- return new a
- }
- ,
- Object.defineProperty(a.prototype, "loaderState", {
- get: function() {
- return this._state
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.whenCompleteAsync = function() {
- var e = this;
- return new Promise(function(i, o) {
- e.onCompleteObservable.addOnce(function() {
- i()
- }),
- e.onErrorObservable.addOnce(function(s) {
- o(s)
- })
- }
- )
- }
- ,
- a.prototype._setState = function(e) {
- this._state !== e && (this._state = e,
- this.onLoaderStateChangedObservable.notifyObservers(this._state),
- this._log(GLTFLoaderState[this._state]))
- }
- ,
- a.prototype._loadFile = function(e, i, o, s, c, d) {
- var _ = this
- , b = e._loadFile(i, o, function(k) {
- _._onProgress(k, b)
- }, !0, s, c, d);
- return b.onCompleteObservable.add(function(k) {
- _._requests.splice(_._requests.indexOf(k), 1)
- }),
- this._requests.push(b),
- b
- }
- ,
- a.prototype._onProgress = function(e, i) {
- if (!!this._progressCallback) {
- i._lengthComputable = e.lengthComputable,
- i._loaded = e.loaded,
- i._total = e.total;
- for (var o = !0, s = 0, c = 0, d = 0, _ = this._requests; d < _.length; d++) {
- var b = _[d];
- if (b._lengthComputable === void 0 || b._loaded === void 0 || b._total === void 0)
- return;
- o = o && b._lengthComputable,
- s += b._loaded,
- c += b._total
- }
- this._progressCallback({
- lengthComputable: o,
- loaded: s,
- total: o ? c : 0
- })
- }
- }
- ,
- a.prototype._validate = function(e, i, o, s) {
- var c = this;
- o === void 0 && (o = ""),
- s === void 0 && (s = ""),
- this.validate && (this._startPerformanceCounter("Validate JSON"),
- GLTFValidation.ValidateAsync(i, o, s, function(d) {
- return c.preprocessUrlAsync(o + d).then(function(_) {
- return e._loadFileAsync(_, void 0, !0, !0)
- })
- }).then(function(d) {
- c._endPerformanceCounter("Validate JSON"),
- c.onValidatedObservable.notifyObservers(d),
- c.onValidatedObservable.clear()
- }, function(d) {
- c._endPerformanceCounter("Validate JSON"),
- Tools.Warn("Failed to validate: " + d.message),
- c.onValidatedObservable.clear()
- }))
- }
- ,
- a.prototype._getLoader = function(e) {
- var i = e.json.asset || {};
- this._log("Asset version: " + i.version),
- i.minVersion && this._log("Asset minimum version: " + i.minVersion),
- i.generator && this._log("Asset generator: " + i.generator);
- var o = a._parseVersion(i.version);
- if (!o)
- throw new Error("Invalid version: " + i.version);
- if (i.minVersion !== void 0) {
- var s = a._parseVersion(i.minVersion);
- if (!s)
- throw new Error("Invalid minimum version: " + i.minVersion);
- if (a._compareVersion(s, {
- major: 2,
- minor: 0
- }) > 0)
- throw new Error("Incompatible minimum version: " + i.minVersion)
- }
- var c = {
- 1: a._CreateGLTF1Loader,
- 2: a._CreateGLTF2Loader
- }
- , d = c[o.major];
- if (!d)
- throw new Error("Unsupported version: " + i.version);
- return d(this)
- }
- ,
- a.prototype._parseJson = function(e) {
- this._startPerformanceCounter("Parse JSON"),
- this._log("JSON length: " + e.length);
- var i = JSON.parse(e);
- return this._endPerformanceCounter("Parse JSON"),
- i
- }
- ,
- a.prototype._unpackBinaryAsync = function(e) {
- var i = this;
- return this._startPerformanceCounter("Unpack Binary"),
- e.loadAsync(20).then(function() {
- var o = {
- Magic: 1179937895
- }
- , s = e.readUint32();
- if (s !== o.Magic)
- throw new Error("Unexpected magic: " + s);
- var c = e.readUint32();
- i.loggingEnabled && i._log("Binary version: " + c);
- var d = e.readUint32();
- if (e.buffer.byteLength !== 0 && d !== e.buffer.byteLength)
- throw new Error("Length in header does not match actual data length: " + d + " != " + e.buffer.byteLength);
- var _;
- switch (c) {
- case 1:
- {
- _ = i._unpackBinaryV1Async(e, d);
- break
- }
- case 2:
- {
- _ = i._unpackBinaryV2Async(e, d);
- break
- }
- default:
- throw new Error("Unsupported version: " + c)
- }
- return i._endPerformanceCounter("Unpack Binary"),
- _
- })
- }
- ,
- a.prototype._unpackBinaryV1Async = function(e, i) {
- var o = {
- JSON: 0
- }
- , s = e.readUint32()
- , c = e.readUint32();
- if (c !== o.JSON)
- throw new Error("Unexpected content format: " + c);
- var d = i - e.byteOffset
- , _ = {
- json: this._parseJson(e.readString(s)),
- bin: null
- };
- if (d !== 0) {
- var b = e.byteOffset;
- _.bin = {
- readAsync: function(k, j) {
- return e.buffer.readAsync(b + k, j)
- },
- byteLength: d
- }
- }
- return Promise.resolve(_)
- }
- ,
- a.prototype._unpackBinaryV2Async = function(e, i) {
- var o = this
- , s = {
- JSON: 1313821514,
- BIN: 5130562
- }
- , c = e.readUint32()
- , d = e.readUint32();
- if (d !== s.JSON)
- throw new Error("First chunk format is not JSON");
- return e.byteOffset + c === i ? e.loadAsync(c).then(function() {
- return {
- json: o._parseJson(e.readString(c)),
- bin: null
- }
- }) : e.loadAsync(c + 8).then(function() {
- var _ = {
- json: o._parseJson(e.readString(c)),
- bin: null
- }
- , b = function() {
- var k = e.readUint32()
- , j = e.readUint32();
- switch (j) {
- case s.JSON:
- throw new Error("Unexpected JSON chunk");
- case s.BIN:
- {
- var $ = e.byteOffset;
- _.bin = {
- readAsync: function(_e, et) {
- return e.buffer.readAsync($ + _e, et)
- },
- byteLength: k
- },
- e.skipBytes(k);
- break
- }
- default:
- {
- e.skipBytes(k);
- break
- }
- }
- return e.byteOffset !== i ? e.loadAsync(8).then(b) : Promise.resolve(_)
- };
- return b()
- })
- }
- ,
- a._parseVersion = function(e) {
- if (e === "1.0" || e === "1.0.1")
- return {
- major: 1,
- minor: 0
- };
- var i = (e + "").match(/^(\d+)\.(\d+)/);
- return i ? {
- major: parseInt(i[1]),
- minor: parseInt(i[2])
- } : null
- }
- ,
- a._compareVersion = function(e, i) {
- return e.major > i.major ? 1 : e.major < i.major ? -1 : e.minor > i.minor ? 1 : e.minor < i.minor ? -1 : 0
- }
- ,
- a.prototype._logOpen = function(e) {
- this._log(e),
- this._logIndentLevel++
- }
- ,
- a.prototype._logClose = function() {
- --this._logIndentLevel
- }
- ,
- a.prototype._logEnabled = function(e) {
- var i = a._logSpaces.substr(0, this._logIndentLevel * 2);
- Logger$2.Log("" + i + e)
- }
- ,
- a.prototype._logDisabled = function(e) {}
- ,
- a.prototype._startPerformanceCounterEnabled = function(e) {
- Tools.StartPerformanceCounter(e)
- }
- ,
- a.prototype._startPerformanceCounterDisabled = function(e) {}
- ,
- a.prototype._endPerformanceCounterEnabled = function(e) {
- Tools.EndPerformanceCounter(e)
- }
- ,
- a.prototype._endPerformanceCounterDisabled = function(e) {}
- ,
- a.IncrementalLoading = !0,
- a.HomogeneousCoordinates = !1,
- a.magicBase64Encoded = "Z2xURg",
- a._logSpaces = " ",
- a
- }();
- SceneLoader && SceneLoader.RegisterPlugin(new GLTFFileLoader);
- var EComponentType;
- (function(a) {
- a[a.BYTE = 5120] = "BYTE",
- a[a.UNSIGNED_BYTE = 5121] = "UNSIGNED_BYTE",
- a[a.SHORT = 5122] = "SHORT",
- a[a.UNSIGNED_SHORT = 5123] = "UNSIGNED_SHORT",
- a[a.FLOAT = 5126] = "FLOAT"
- }
- )(EComponentType || (EComponentType = {}));
- var EShaderType;
- (function(a) {
- a[a.FRAGMENT = 35632] = "FRAGMENT",
- a[a.VERTEX = 35633] = "VERTEX"
- }
- )(EShaderType || (EShaderType = {}));
- var EParameterType;
- (function(a) {
- a[a.BYTE = 5120] = "BYTE",
- a[a.UNSIGNED_BYTE = 5121] = "UNSIGNED_BYTE",
- a[a.SHORT = 5122] = "SHORT",
- a[a.UNSIGNED_SHORT = 5123] = "UNSIGNED_SHORT",
- a[a.INT = 5124] = "INT",
- a[a.UNSIGNED_INT = 5125] = "UNSIGNED_INT",
- a[a.FLOAT = 5126] = "FLOAT",
- a[a.FLOAT_VEC2 = 35664] = "FLOAT_VEC2",
- a[a.FLOAT_VEC3 = 35665] = "FLOAT_VEC3",
- a[a.FLOAT_VEC4 = 35666] = "FLOAT_VEC4",
- a[a.INT_VEC2 = 35667] = "INT_VEC2",
- a[a.INT_VEC3 = 35668] = "INT_VEC3",
- a[a.INT_VEC4 = 35669] = "INT_VEC4",
- a[a.BOOL = 35670] = "BOOL",
- a[a.BOOL_VEC2 = 35671] = "BOOL_VEC2",
- a[a.BOOL_VEC3 = 35672] = "BOOL_VEC3",
- a[a.BOOL_VEC4 = 35673] = "BOOL_VEC4",
- a[a.FLOAT_MAT2 = 35674] = "FLOAT_MAT2",
- a[a.FLOAT_MAT3 = 35675] = "FLOAT_MAT3",
- a[a.FLOAT_MAT4 = 35676] = "FLOAT_MAT4",
- a[a.SAMPLER_2D = 35678] = "SAMPLER_2D"
- }
- )(EParameterType || (EParameterType = {}));
- var ETextureWrapMode;
- (function(a) {
- a[a.CLAMP_TO_EDGE = 33071] = "CLAMP_TO_EDGE",
- a[a.MIRRORED_REPEAT = 33648] = "MIRRORED_REPEAT",
- a[a.REPEAT = 10497] = "REPEAT"
- }
- )(ETextureWrapMode || (ETextureWrapMode = {}));
- var ETextureFilterType;
- (function(a) {
- a[a.NEAREST = 9728] = "NEAREST",
- a[a.LINEAR = 9728] = "LINEAR",
- a[a.NEAREST_MIPMAP_NEAREST = 9984] = "NEAREST_MIPMAP_NEAREST",
- a[a.LINEAR_MIPMAP_NEAREST = 9985] = "LINEAR_MIPMAP_NEAREST",
- a[a.NEAREST_MIPMAP_LINEAR = 9986] = "NEAREST_MIPMAP_LINEAR",
- a[a.LINEAR_MIPMAP_LINEAR = 9987] = "LINEAR_MIPMAP_LINEAR"
- }
- )(ETextureFilterType || (ETextureFilterType = {}));
- var ETextureFormat;
- (function(a) {
- a[a.ALPHA = 6406] = "ALPHA",
- a[a.RGB = 6407] = "RGB",
- a[a.RGBA = 6408] = "RGBA",
- a[a.LUMINANCE = 6409] = "LUMINANCE",
- a[a.LUMINANCE_ALPHA = 6410] = "LUMINANCE_ALPHA"
- }
- )(ETextureFormat || (ETextureFormat = {}));
- var ECullingType;
- (function(a) {
- a[a.FRONT = 1028] = "FRONT",
- a[a.BACK = 1029] = "BACK",
- a[a.FRONT_AND_BACK = 1032] = "FRONT_AND_BACK"
- }
- )(ECullingType || (ECullingType = {}));
- var EBlendingFunction;
- (function(a) {
- a[a.ZERO = 0] = "ZERO",
- a[a.ONE = 1] = "ONE",
- a[a.SRC_COLOR = 768] = "SRC_COLOR",
- a[a.ONE_MINUS_SRC_COLOR = 769] = "ONE_MINUS_SRC_COLOR",
- a[a.DST_COLOR = 774] = "DST_COLOR",
- a[a.ONE_MINUS_DST_COLOR = 775] = "ONE_MINUS_DST_COLOR",
- a[a.SRC_ALPHA = 770] = "SRC_ALPHA",
- a[a.ONE_MINUS_SRC_ALPHA = 771] = "ONE_MINUS_SRC_ALPHA",
- a[a.DST_ALPHA = 772] = "DST_ALPHA",
- a[a.ONE_MINUS_DST_ALPHA = 773] = "ONE_MINUS_DST_ALPHA",
- a[a.CONSTANT_COLOR = 32769] = "CONSTANT_COLOR",
- a[a.ONE_MINUS_CONSTANT_COLOR = 32770] = "ONE_MINUS_CONSTANT_COLOR",
- a[a.CONSTANT_ALPHA = 32771] = "CONSTANT_ALPHA",
- a[a.ONE_MINUS_CONSTANT_ALPHA = 32772] = "ONE_MINUS_CONSTANT_ALPHA",
- a[a.SRC_ALPHA_SATURATE = 776] = "SRC_ALPHA_SATURATE"
- }
- )(EBlendingFunction || (EBlendingFunction = {}));
- var GLTFUtils = function() {
- function a() {}
- return a.SetMatrix = function(e, i, o, s, c) {
- var d = null;
- if (o.semantic === "MODEL")
- d = i.getWorldMatrix();
- else if (o.semantic === "PROJECTION")
- d = e.getProjectionMatrix();
- else if (o.semantic === "VIEW")
- d = e.getViewMatrix();
- else if (o.semantic === "MODELVIEWINVERSETRANSPOSE")
- d = Matrix.Transpose(i.getWorldMatrix().multiply(e.getViewMatrix()).invert());
- else if (o.semantic === "MODELVIEW")
- d = i.getWorldMatrix().multiply(e.getViewMatrix());
- else if (o.semantic === "MODELVIEWPROJECTION")
- d = i.getWorldMatrix().multiply(e.getTransformMatrix());
- else if (o.semantic === "MODELINVERSE")
- d = i.getWorldMatrix().invert();
- else if (o.semantic === "VIEWINVERSE")
- d = e.getViewMatrix().invert();
- else if (o.semantic === "PROJECTIONINVERSE")
- d = e.getProjectionMatrix().invert();
- else if (o.semantic === "MODELVIEWINVERSE")
- d = i.getWorldMatrix().multiply(e.getViewMatrix()).invert();
- else if (o.semantic === "MODELVIEWPROJECTIONINVERSE")
- d = i.getWorldMatrix().multiply(e.getTransformMatrix()).invert();
- else if (o.semantic === "MODELINVERSETRANSPOSE")
- d = Matrix.Transpose(i.getWorldMatrix().invert());
- else
- debugger ;if (d)
- switch (o.type) {
- case EParameterType.FLOAT_MAT2:
- c.setMatrix2x2(s, Matrix.GetAsMatrix2x2(d));
- break;
- case EParameterType.FLOAT_MAT3:
- c.setMatrix3x3(s, Matrix.GetAsMatrix3x3(d));
- break;
- case EParameterType.FLOAT_MAT4:
- c.setMatrix(s, d);
- break
- }
- }
- ,
- a.SetUniform = function(e, i, o, s) {
- switch (s) {
- case EParameterType.FLOAT:
- return e.setFloat(i, o),
- !0;
- case EParameterType.FLOAT_VEC2:
- return e.setVector2(i, Vector2.FromArray(o)),
- !0;
- case EParameterType.FLOAT_VEC3:
- return e.setVector3(i, Vector3.FromArray(o)),
- !0;
- case EParameterType.FLOAT_VEC4:
- return e.setVector4(i, Vector4.FromArray(o)),
- !0;
- default:
- return !1
- }
- }
- ,
- a.GetWrapMode = function(e) {
- switch (e) {
- case ETextureWrapMode.CLAMP_TO_EDGE:
- return Texture.CLAMP_ADDRESSMODE;
- case ETextureWrapMode.MIRRORED_REPEAT:
- return Texture.MIRROR_ADDRESSMODE;
- case ETextureWrapMode.REPEAT:
- return Texture.WRAP_ADDRESSMODE;
- default:
- return Texture.WRAP_ADDRESSMODE
- }
- }
- ,
- a.GetByteStrideFromType = function(e) {
- var i = e.type;
- switch (i) {
- case "VEC2":
- return 2;
- case "VEC3":
- return 3;
- case "VEC4":
- return 4;
- case "MAT2":
- return 4;
- case "MAT3":
- return 9;
- case "MAT4":
- return 16;
- default:
- return 1
- }
- }
- ,
- a.GetTextureFilterMode = function(e) {
- switch (e) {
- case ETextureFilterType.LINEAR:
- case ETextureFilterType.LINEAR_MIPMAP_NEAREST:
- case ETextureFilterType.LINEAR_MIPMAP_LINEAR:
- return Texture.TRILINEAR_SAMPLINGMODE;
- case ETextureFilterType.NEAREST:
- case ETextureFilterType.NEAREST_MIPMAP_NEAREST:
- return Texture.NEAREST_SAMPLINGMODE;
- default:
- return Texture.BILINEAR_SAMPLINGMODE
- }
- }
- ,
- a.GetBufferFromBufferView = function(e, i, d, s, c) {
- var d = i.byteOffset + d
- , _ = e.loadedBufferViews[i.buffer];
- if (d + s > _.byteLength)
- throw new Error("Buffer access is out of range");
- var b = _.buffer;
- switch (d += _.byteOffset,
- c) {
- case EComponentType.BYTE:
- return new Int8Array(b,d,s);
- case EComponentType.UNSIGNED_BYTE:
- return new Uint8Array(b,d,s);
- case EComponentType.SHORT:
- return new Int16Array(b,d,s);
- case EComponentType.UNSIGNED_SHORT:
- return new Uint16Array(b,d,s);
- default:
- return new Float32Array(b,d,s)
- }
- }
- ,
- a.GetBufferFromAccessor = function(e, i) {
- var o = e.bufferViews[i.bufferView]
- , s = i.count * a.GetByteStrideFromType(i);
- return a.GetBufferFromBufferView(e, o, i.byteOffset, s, i.componentType)
- }
- ,
- a.DecodeBufferToText = function(e) {
- for (var i = "", o = e.byteLength, s = 0; s < o; ++s)
- i += String.fromCharCode(e[s]);
- return i
- }
- ,
- a.GetDefaultMaterial = function(e) {
- if (!a._DefaultMaterial) {
- 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(`
- `),
- Effect.ShadersStore.GLTFDefaultMaterialPixelShader = ["precision highp float;", "", "uniform vec4 u_emission;", "", "void main(void)", "{", " gl_FragColor = u_emission;", "}"].join(`
- `);
- var i = {
- vertex: "GLTFDefaultMaterial",
- fragment: "GLTFDefaultMaterial"
- }
- , o = {
- attributes: ["position"],
- uniforms: ["worldView", "projection", "u_emission"],
- samplers: new Array,
- needAlphaBlending: !1
- };
- a._DefaultMaterial = new ShaderMaterial("GLTFDefaultMaterial",e,i,o),
- a._DefaultMaterial.setColor4("u_emission", new Color4(.5,.5,.5,1))
- }
- return a._DefaultMaterial
- }
- ,
- a._DefaultMaterial = null,
- a
- }(), ETokenType;
- (function(a) {
- a[a.IDENTIFIER = 1] = "IDENTIFIER",
- a[a.UNKNOWN = 2] = "UNKNOWN",
- a[a.END_OF_INPUT = 3] = "END_OF_INPUT"
- }
- )(ETokenType || (ETokenType = {}));
- var Tokenizer = function() {
- function a(e) {
- this._pos = 0,
- this.currentToken = ETokenType.UNKNOWN,
- this.currentIdentifier = "",
- this.currentString = "",
- this.isLetterOrDigitPattern = /^[a-zA-Z0-9]+$/,
- this._toParse = e,
- this._maxPos = e.length
- }
- return a.prototype.getNextToken = function() {
- if (this.isEnd())
- return ETokenType.END_OF_INPUT;
- if (this.currentString = this.read(),
- this.currentToken = ETokenType.UNKNOWN,
- this.currentString === "_" || this.isLetterOrDigitPattern.test(this.currentString))
- for (this.currentToken = ETokenType.IDENTIFIER,
- this.currentIdentifier = this.currentString; !this.isEnd() && (this.isLetterOrDigitPattern.test(this.currentString = this.peek()) || this.currentString === "_"); )
- this.currentIdentifier += this.currentString,
- this.forward();
- return this.currentToken
- }
- ,
- a.prototype.peek = function() {
- return this._toParse[this._pos]
- }
- ,
- a.prototype.read = function() {
- return this._toParse[this._pos++]
- }
- ,
- a.prototype.forward = function() {
- this._pos++
- }
- ,
- a.prototype.isEnd = function() {
- return this._pos >= this._maxPos
- }
- ,
- a
- }()
- , glTFTransforms = ["MODEL", "VIEW", "PROJECTION", "MODELVIEW", "MODELVIEWPROJECTION", "JOINTMATRIX"]
- , babylonTransforms = ["world", "view", "projection", "worldView", "worldViewProjection", "mBones"]
- , glTFAnimationPaths = ["translation", "rotation", "scale"]
- , babylonAnimationPaths = ["position", "rotationQuaternion", "scaling"]
- , parseBuffers = function(a, e) {
- for (var i in a) {
- var o = a[i];
- e.buffers[i] = o,
- e.buffersCount++
- }
- }
- , parseShaders = function(a, e) {
- for (var i in a) {
- var o = a[i];
- e.shaders[i] = o,
- e.shaderscount++
- }
- }
- , parseObject = function(a, e, i) {
- for (var o in a) {
- var s = a[o];
- i[e][o] = s
- }
- }
- , normalizeUVs = function(a) {
- if (!!a)
- for (var e = 0; e < a.length / 2; e++)
- a[e * 2 + 1] = 1 - a[e * 2 + 1]
- }
- , getAttribute = function(a) {
- if (a.semantic === "NORMAL")
- return "normal";
- if (a.semantic === "POSITION")
- return "position";
- if (a.semantic === "JOINT")
- return "matricesIndices";
- if (a.semantic === "WEIGHT")
- return "matricesWeights";
- if (a.semantic === "COLOR")
- return "color";
- if (a.semantic && a.semantic.indexOf("TEXCOORD_") !== -1) {
- var e = Number(a.semantic.split("_")[1]);
- return "uv" + (e === 0 ? "" : e + 1)
- }
- return null
- }
- , loadAnimations = function(a) {
- for (var e in a.animations) {
- var i = a.animations[e];
- if (!(!i.channels || !i.samplers))
- for (var o = null, s = 0; s < i.channels.length; s++) {
- var c = i.channels[s]
- , d = i.samplers[c.sampler];
- if (!!d) {
- var _ = null
- , b = null;
- i.parameters ? (_ = i.parameters[d.input],
- b = i.parameters[d.output]) : (_ = d.input,
- b = d.output);
- var k = GLTFUtils.GetBufferFromAccessor(a, a.accessors[_])
- , j = GLTFUtils.GetBufferFromAccessor(a, a.accessors[b])
- , $ = c.target.id
- , _e = a.scene.getNodeById($);
- if (_e === null && (_e = a.scene.getNodeByName($)),
- _e === null) {
- Tools.Warn("Creating animation named " + e + ". But cannot find node named " + $ + " to attach to");
- continue
- }
- var et = _e instanceof Bone
- , tt = c.target.path
- , rt = glTFAnimationPaths.indexOf(tt);
- rt !== -1 && (tt = babylonAnimationPaths[rt]);
- var it = Animation.ANIMATIONTYPE_MATRIX;
- et || (tt === "rotationQuaternion" ? (it = Animation.ANIMATIONTYPE_QUATERNION,
- _e.rotationQuaternion = new Quaternion) : it = Animation.ANIMATIONTYPE_VECTOR3);
- var nt = null
- , ot = []
- , at = 0
- , st = !1;
- et && o && o.getKeys().length === k.length && (nt = o,
- st = !0),
- st || (a.scene._blockEntityCollection = !!a.assetContainer,
- nt = new Animation(e,et ? "_matrix" : tt,1,it,Animation.ANIMATIONLOOPMODE_CYCLE),
- a.scene._blockEntityCollection = !1);
- for (var ut = 0; ut < k.length; ut++) {
- var ct = null;
- if (tt === "rotationQuaternion" ? (ct = Quaternion.FromArray([j[at], j[at + 1], j[at + 2], j[at + 3]]),
- at += 4) : (ct = Vector3.FromArray([j[at], j[at + 1], j[at + 2]]),
- at += 3),
- et) {
- var lt = _e
- , ft = Vector3.Zero()
- , ht = new Quaternion
- , pt = Vector3.Zero()
- , dt = lt.getBaseMatrix();
- st && o && (dt = o.getKeys()[ut].value),
- dt.decompose(pt, ht, ft),
- tt === "position" ? ft = ct : tt === "rotationQuaternion" ? ht = ct : pt = ct,
- ct = Matrix.Compose(pt, ht, ft)
- }
- st ? o && (o.getKeys()[ut].value = ct) : ot.push({
- frame: k[ut],
- value: ct
- })
- }
- !st && nt && (nt.setKeys(ot),
- _e.animations.push(nt)),
- o = nt,
- a.scene.stopAnimation(_e),
- a.scene.beginAnimation(_e, 0, k[k.length - 1], !0, 1)
- }
- }
- }
- }
- , configureBoneTransformation = function(a) {
- var e = null;
- if (a.translation || a.rotation || a.scale) {
- var i = Vector3.FromArray(a.scale || [1, 1, 1])
- , o = Quaternion.FromArray(a.rotation || [0, 0, 0, 1])
- , s = Vector3.FromArray(a.translation || [0, 0, 0]);
- e = Matrix.Compose(i, o, s)
- } else
- e = Matrix.FromArray(a.matrix);
- return e
- }
- , getParentBone = function(a, e, i, o) {
- for (var s = 0; s < o.bones.length; s++)
- if (o.bones[s].name === i)
- return o.bones[s];
- var c = a.nodes;
- for (var d in c) {
- var _ = c[d];
- if (!!_.jointName)
- for (var b = _.children, s = 0; s < b.length; s++) {
- var k = a.nodes[b[s]];
- if (!!k.jointName && k.jointName === i) {
- var j = configureBoneTransformation(_)
- , $ = new Bone(_.name || "",o,getParentBone(a, e, _.jointName, o),j);
- return $.id = d,
- $
- }
- }
- }
- return null
- }
- , getNodeToRoot = function(a, e) {
- for (var i = 0; i < a.length; i++)
- for (var o = a[i], s = 0; s < o.node.children.length; s++) {
- var c = o.node.children[s];
- if (c === e)
- return o.bone
- }
- return null
- }
- , getJointNode = function(a, e) {
- var i = a.nodes
- , o = i[e];
- if (o)
- return {
- node: o,
- id: e
- };
- for (var s in i)
- if (o = i[s],
- o.jointName === e)
- return {
- node: o,
- id: s
- };
- return null
- }
- , nodeIsInJoints = function(a, e) {
- for (var i = 0; i < a.jointNames.length; i++)
- if (a.jointNames[i] === e)
- return !0;
- return !1
- }
- , getNodesToRoot = function(a, e, i, o) {
- for (var s in a.nodes) {
- var c = a.nodes[s]
- , d = s;
- if (!(!c.jointName || nodeIsInJoints(i, c.jointName))) {
- var _ = configureBoneTransformation(c)
- , b = new Bone(c.name || "",e,null,_);
- b.id = d,
- o.push({
- bone: b,
- node: c,
- id: d
- })
- }
- }
- for (var k = 0; k < o.length; k++)
- for (var j = o[k], $ = j.node.children, _e = 0; _e < $.length; _e++) {
- for (var et = null, tt = 0; tt < o.length; tt++)
- if (o[tt].id === $[_e]) {
- et = o[tt];
- break
- }
- et && (et.bone._parent = j.bone,
- j.bone.children.push(et.bone))
- }
- }
- , importSkeleton = function(a, e, i, o, s) {
- if (o || (o = new Skeleton(e.name || "","",a.scene)),
- !e.babylonSkeleton)
- return o;
- var c = []
- , d = [];
- getNodesToRoot(a, o, e, c),
- o.bones = [];
- for (var _ = 0; _ < e.jointNames.length; _++) {
- var b = getJointNode(a, e.jointNames[_]);
- if (!!b) {
- var k = b.node;
- if (!k) {
- Tools.Warn("Joint named " + e.jointNames[_] + " does not exist");
- continue
- }
- var s = b.id
- , j = a.scene.getBoneById(s);
- if (j) {
- o.bones.push(j);
- continue
- }
- for (var $ = !1, _e = null, et = 0; et < _; et++) {
- var tt = getJointNode(a, e.jointNames[et]);
- if (!!tt) {
- var rt = tt.node;
- if (!rt) {
- Tools.Warn("Joint named " + e.jointNames[et] + " does not exist when looking for parent");
- continue
- }
- var it = rt.children;
- if (!!it) {
- $ = !1;
- for (var nt = 0; nt < it.length; nt++)
- if (it[nt] === s) {
- _e = getParentBone(a, e, e.jointNames[et], o),
- $ = !0;
- break
- }
- if ($)
- break
- }
- }
- }
- var ot = configureBoneTransformation(k);
- !_e && c.length > 0 && (_e = getNodeToRoot(c, s),
- _e && d.indexOf(_e) === -1 && d.push(_e));
- var at = new Bone(k.jointName || "",o,_e,ot);
- at.id = s
- }
- }
- var st = o.bones;
- o.bones = [];
- for (var _ = 0; _ < e.jointNames.length; _++) {
- var b = getJointNode(a, e.jointNames[_]);
- if (!!b) {
- for (var et = 0; et < st.length; et++)
- if (st[et].id === b.id) {
- o.bones.push(st[et]);
- break
- }
- }
- }
- o.prepare();
- for (var _ = 0; _ < d.length; _++)
- o.bones.push(d[_]);
- return o
- }
- , importMesh = function(a, e, i, o, s) {
- if (s || (a.scene._blockEntityCollection = !!a.assetContainer,
- s = new Mesh(e.name || "",a.scene),
- s._parentContainer = a.assetContainer,
- a.scene._blockEntityCollection = !1,
- s.id = o),
- !e.babylonNode)
- return s;
- for (var c = [], d = null, _ = new Array, b = new Array, k = new Array, j = new Array, $ = 0; $ < i.length; $++) {
- var _e = i[$]
- , et = a.meshes[_e];
- if (!!et)
- for (var tt = 0; tt < et.primitives.length; tt++) {
- var rt = new VertexData
- , it = et.primitives[tt];
- it.mode;
- var nt = it.attributes
- , ot = null
- , at = null;
- for (var st in nt)
- if (ot = a.accessors[nt[st]],
- at = GLTFUtils.GetBufferFromAccessor(a, ot),
- st === "NORMAL")
- rt.normals = new Float32Array(at.length),
- rt.normals.set(at);
- else if (st === "POSITION") {
- if (GLTFFileLoader.HomogeneousCoordinates) {
- rt.positions = new Float32Array(at.length - at.length / 4);
- for (var ut = 0; ut < at.length; ut += 4)
- rt.positions[ut] = at[ut],
- rt.positions[ut + 1] = at[ut + 1],
- rt.positions[ut + 2] = at[ut + 2]
- } else
- rt.positions = new Float32Array(at.length),
- rt.positions.set(at);
- b.push(rt.positions.length)
- } else if (st.indexOf("TEXCOORD_") !== -1) {
- var ct = Number(st.split("_")[1])
- , lt = VertexBuffer.UVKind + (ct === 0 ? "" : ct + 1)
- , ft = new Float32Array(at.length);
- ft.set(at),
- normalizeUVs(ft),
- rt.set(ft, lt)
- } else
- st === "JOINT" ? (rt.matricesIndices = new Float32Array(at.length),
- rt.matricesIndices.set(at)) : st === "WEIGHT" ? (rt.matricesWeights = new Float32Array(at.length),
- rt.matricesWeights.set(at)) : st === "COLOR" && (rt.colors = new Float32Array(at.length),
- rt.colors.set(at));
- if (ot = a.accessors[it.indices],
- ot)
- at = GLTFUtils.GetBufferFromAccessor(a, ot),
- rt.indices = new Int32Array(at.length),
- rt.indices.set(at),
- j.push(rt.indices.length);
- else {
- for (var ht = [], ut = 0; ut < rt.positions.length / 3; ut++)
- ht.push(ut);
- rt.indices = new Int32Array(ht),
- j.push(rt.indices.length)
- }
- d ? d.merge(rt) : d = rt;
- var pt = a.scene.getMaterialById(it.material);
- c.push(pt === null ? GLTFUtils.GetDefaultMaterial(a.scene) : pt),
- _.push(_.length === 0 ? 0 : _[_.length - 1] + b[b.length - 2]),
- k.push(k.length === 0 ? 0 : k[k.length - 1] + j[j.length - 2])
- }
- }
- var dt;
- a.scene._blockEntityCollection = !!a.assetContainer,
- c.length > 1 ? (dt = new MultiMaterial("multimat" + o,a.scene),
- dt.subMaterials = c) : dt = new StandardMaterial("multimat" + o,a.scene),
- c.length === 1 && (dt = c[0]),
- dt._parentContainer = a.assetContainer,
- s.material || (s.material = dt),
- new Geometry(o,a.scene,d,!1,s),
- s.computeWorldMatrix(!0),
- a.scene._blockEntityCollection = !1,
- s.subMeshes = [];
- for (var _t = 0, $ = 0; $ < i.length; $++) {
- var _e = i[$]
- , et = a.meshes[_e];
- if (!!et)
- for (var tt = 0; tt < et.primitives.length; tt++)
- et.primitives[tt].mode,
- SubMesh.AddToMesh(_t, _[_t], b[_t], k[_t], j[_t], s, s, !0),
- _t++
- }
- return s
- }
- , configureNode = function(a, e, i, o) {
- a.position && (a.position = e),
- (a.rotationQuaternion || a.rotation) && (a.rotationQuaternion = i),
- a.scaling && (a.scaling = o)
- }
- , configureNodeFromMatrix = function(a, e, i) {
- if (e.matrix) {
- var o = new Vector3(0,0,0)
- , s = new Quaternion
- , c = new Vector3(0,0,0)
- , d = Matrix.FromArray(e.matrix);
- d.decompose(c, s, o),
- configureNode(a, o, s, c)
- } else
- e.translation && e.rotation && e.scale && configureNode(a, Vector3.FromArray(e.translation), Quaternion.FromArray(e.rotation), Vector3.FromArray(e.scale));
- a.computeWorldMatrix(!0)
- }
- , importNode$1 = function(a, e, i, o) {
- var s = null;
- if (a.importOnlyMeshes && (e.skin || e.meshes) && a.importMeshesNames && a.importMeshesNames.length > 0 && a.importMeshesNames.indexOf(e.name || "") === -1)
- return null;
- if (e.skin) {
- if (e.meshes) {
- var c = a.skins[e.skin]
- , d = importMesh(a, e, e.meshes, i, e.babylonNode);
- d.skeleton = a.scene.getLastSkeletonById(e.skin),
- d.skeleton === null && (d.skeleton = importSkeleton(a, c, d, c.babylonSkeleton, e.skin),
- c.babylonSkeleton || (c.babylonSkeleton = d.skeleton)),
- s = d
- }
- } else if (e.meshes) {
- var d = importMesh(a, e, e.mesh ? [e.mesh] : e.meshes, i, e.babylonNode);
- s = d
- } else if (e.light && !e.babylonNode && !a.importOnlyMeshes) {
- var _ = a.lights[e.light];
- if (_) {
- if (_.type === "ambient") {
- var b = _[_.type]
- , k = new HemisphericLight(e.light,Vector3.Zero(),a.scene);
- k.name = e.name || "",
- b.color && (k.diffuse = Color3.FromArray(b.color)),
- s = k
- } else if (_.type === "directional") {
- var j = _[_.type]
- , $ = new DirectionalLight(e.light,Vector3.Zero(),a.scene);
- $.name = e.name || "",
- j.color && ($.diffuse = Color3.FromArray(j.color)),
- s = $
- } else if (_.type === "point") {
- var _e = _[_.type]
- , et = new PointLight(e.light,Vector3.Zero(),a.scene);
- et.name = e.name || "",
- _e.color && (et.diffuse = Color3.FromArray(_e.color)),
- s = et
- } else if (_.type === "spot") {
- var tt = _[_.type]
- , rt = new SpotLight(e.light,Vector3.Zero(),Vector3.Zero(),0,0,a.scene);
- rt.name = e.name || "",
- tt.color && (rt.diffuse = Color3.FromArray(tt.color)),
- tt.fallOfAngle && (rt.angle = tt.fallOfAngle),
- tt.fallOffExponent && (rt.exponent = tt.fallOffExponent),
- s = rt
- }
- }
- } else if (e.camera && !e.babylonNode && !a.importOnlyMeshes) {
- var it = a.cameras[e.camera];
- if (it) {
- if (a.scene._blockEntityCollection = !!a.assetContainer,
- it.type === "orthographic") {
- var nt = new FreeCamera(e.camera,Vector3.Zero(),a.scene,!1);
- nt.name = e.name || "",
- nt.mode = Camera$1.ORTHOGRAPHIC_CAMERA,
- nt.attachControl(),
- s = nt,
- nt._parentContainer = a.assetContainer
- } else if (it.type === "perspective") {
- var ot = it[it.type]
- , at = new FreeCamera(e.camera,Vector3.Zero(),a.scene,!1);
- at.name = e.name || "",
- at.attachControl(),
- ot.aspectRatio || (ot.aspectRatio = a.scene.getEngine().getRenderWidth() / a.scene.getEngine().getRenderHeight()),
- ot.znear && ot.zfar && (at.maxZ = ot.zfar,
- at.minZ = ot.znear),
- s = at,
- at._parentContainer = a.assetContainer
- }
- a.scene._blockEntityCollection = !1
- }
- }
- if (!e.jointName) {
- if (e.babylonNode)
- return e.babylonNode;
- if (s === null) {
- a.scene._blockEntityCollection = !!a.assetContainer;
- var st = new Mesh(e.name || "",a.scene);
- st._parentContainer = a.assetContainer,
- a.scene._blockEntityCollection = !1,
- e.babylonNode = st,
- s = st
- }
- }
- if (s !== null) {
- if (e.matrix && s instanceof Mesh)
- configureNodeFromMatrix(s, e);
- else {
- var ut = e.translation || [0, 0, 0]
- , ct = e.rotation || [0, 0, 0, 1]
- , lt = e.scale || [1, 1, 1];
- configureNode(s, Vector3.FromArray(ut), Quaternion.FromArray(ct), Vector3.FromArray(lt))
- }
- s.updateCache(!0),
- e.babylonNode = s
- }
- return s
- }
- , traverseNodes = function(a, e, i, o) {
- o === void 0 && (o = !1);
- var s = a.nodes[e]
- , c = null;
- if (a.importOnlyMeshes && !o && a.importMeshesNames ? a.importMeshesNames.indexOf(s.name || "") !== -1 || a.importMeshesNames.length === 0 ? o = !0 : o = !1 : o = !0,
- !s.jointName && o && (c = importNode$1(a, s, e),
- c !== null && (c.id = e,
- c.parent = i)),
- s.children)
- for (var d = 0; d < s.children.length; d++)
- traverseNodes(a, s.children[d], c, o)
- }
- , postLoad = function(a) {
- var e = a.currentScene;
- if (e)
- for (var i = 0; i < e.nodes.length; i++)
- traverseNodes(a, e.nodes[i], null);
- else
- for (var o in a.scenes) {
- e = a.scenes[o];
- for (var i = 0; i < e.nodes.length; i++)
- traverseNodes(a, e.nodes[i], null)
- }
- loadAnimations(a);
- for (var i = 0; i < a.scene.skeletons.length; i++) {
- var s = a.scene.skeletons[i];
- a.scene.beginAnimation(s, 0, Number.MAX_VALUE, !0, 1)
- }
- }
- , onBindShaderMaterial = function(a, e, i, o, s, c, d) {
- var _ = c.values || s.parameters;
- for (var b in i) {
- var k = i[b]
- , j = k.type;
- if (j === EParameterType.FLOAT_MAT2 || j === EParameterType.FLOAT_MAT3 || j === EParameterType.FLOAT_MAT4) {
- if (k.semantic && !k.source && !k.node)
- GLTFUtils.SetMatrix(e.scene, a, k, b, o.getEffect());
- else if (k.semantic && (k.source || k.node)) {
- var $ = e.scene.getNodeByName(k.source || k.node || "");
- if ($ === null && ($ = e.scene.getNodeById(k.source || k.node || "")),
- $ === null)
- continue;
- GLTFUtils.SetMatrix(e.scene, $, k, b, o.getEffect())
- }
- } else {
- var _e = _[s.uniforms[b]];
- if (!_e)
- continue;
- if (j === EParameterType.SAMPLER_2D) {
- var et = e.textures[c.values ? _e : k.value].babylonTexture;
- if (et == null)
- continue;
- o.getEffect().setTexture(b, et)
- } else
- GLTFUtils.SetUniform(o.getEffect(), b, _e, j)
- }
- }
- d(o)
- }
- , prepareShaderMaterialUniforms = function(a, e, i, o, s) {
- var c = o.values || i.parameters
- , d = i.uniforms;
- for (var _ in s) {
- var b = s[_]
- , k = b.type
- , j = c[d[_]];
- if (j === void 0 && (j = b.value),
- !!j) {
- var $ = function(_e) {
- return function(et) {
- b.value && _e && (e.setTexture(_e, et),
- delete s[_e])
- }
- };
- k === EParameterType.SAMPLER_2D ? GLTFLoaderExtension.LoadTextureAsync(a, o.values ? j : b.value, $(_), function() {
- return $(null)
- }) : b.value && GLTFUtils.SetUniform(e, _, o.values ? j : b.value, k) && delete s[_]
- }
- }
- }
- , onShaderCompileError = function(a, e, i) {
- return function(o, s) {
- e.dispose(!0),
- i("Cannot compile program named " + a.name + ". Error: " + s + ". Default material will be applied")
- }
- }
- , onShaderCompileSuccess = function(a, e, i, o, s, c) {
- return function(d) {
- prepareShaderMaterialUniforms(a, e, i, o, s),
- e.onBind = function(_) {
- onBindShaderMaterial(_, a, s, e, i, o, c)
- }
- }
- }
- , parseShaderUniforms = function(a, e, i) {
- for (var o in e.uniforms) {
- var s = e.uniforms[o]
- , c = e.parameters[s];
- if (a.currentIdentifier === o && c.semantic && !c.source && !c.node) {
- var d = glTFTransforms.indexOf(c.semantic);
- if (d !== -1)
- return delete i[o],
- babylonTransforms[d]
- }
- }
- return a.currentIdentifier
- }
- , importMaterials = function(a) {
- for (var e in a.materials)
- GLTFLoaderExtension.LoadMaterialAsync(a, e, function(i) {}, function() {})
- }
- , GLTFLoaderBase = function() {
- function a() {}
- return a.CreateRuntime = function(e, i, o) {
- var s = {
- extensions: {},
- accessors: {},
- buffers: {},
- bufferViews: {},
- meshes: {},
- lights: {},
- cameras: {},
- nodes: {},
- images: {},
- textures: {},
- shaders: {},
- programs: {},
- samplers: {},
- techniques: {},
- materials: {},
- animations: {},
- skins: {},
- extensionsUsed: [],
- scenes: {},
- buffersCount: 0,
- shaderscount: 0,
- scene: i,
- rootUrl: o,
- loadedBufferCount: 0,
- loadedBufferViews: {},
- loadedShaderCount: 0,
- importOnlyMeshes: !1,
- dummyNodes: [],
- assetContainer: null
- };
- return e.extensions && parseObject(e.extensions, "extensions", s),
- e.extensionsUsed && parseObject(e.extensionsUsed, "extensionsUsed", s),
- e.buffers && parseBuffers(e.buffers, s),
- e.bufferViews && parseObject(e.bufferViews, "bufferViews", s),
- e.accessors && parseObject(e.accessors, "accessors", s),
- e.meshes && parseObject(e.meshes, "meshes", s),
- e.lights && parseObject(e.lights, "lights", s),
- e.cameras && parseObject(e.cameras, "cameras", s),
- e.nodes && parseObject(e.nodes, "nodes", s),
- e.images && parseObject(e.images, "images", s),
- e.textures && parseObject(e.textures, "textures", s),
- e.shaders && parseShaders(e.shaders, s),
- e.programs && parseObject(e.programs, "programs", s),
- e.samplers && parseObject(e.samplers, "samplers", s),
- e.techniques && parseObject(e.techniques, "techniques", s),
- e.materials && parseObject(e.materials, "materials", s),
- e.animations && parseObject(e.animations, "animations", s),
- e.skins && parseObject(e.skins, "skins", s),
- e.scenes && (s.scenes = e.scenes),
- e.scene && e.scenes && (s.currentScene = e.scenes[e.scene]),
- s
- }
- ,
- a.LoadBufferAsync = function(e, i, o, s, c) {
- var d = e.buffers[i];
- Tools.IsBase64(d.uri) ? setTimeout(function() {
- return o(new Uint8Array(Tools.DecodeBase64(d.uri)))
- }) : Tools.LoadFile(e.rootUrl + d.uri, function(_) {
- return o(new Uint8Array(_))
- }, c, void 0, !0, function(_) {
- _ && s(_.status + " " + _.statusText)
- })
- }
- ,
- a.LoadTextureBufferAsync = function(e, i, o, s) {
- var c = e.textures[i];
- if (!c || !c.source) {
- s("");
- return
- }
- if (c.babylonTexture) {
- o(null);
- return
- }
- var d = e.images[c.source];
- Tools.IsBase64(d.uri) ? setTimeout(function() {
- return o(new Uint8Array(Tools.DecodeBase64(d.uri)))
- }) : Tools.LoadFile(e.rootUrl + d.uri, function(_) {
- return o(new Uint8Array(_))
- }, void 0, void 0, !0, function(_) {
- _ && s(_.status + " " + _.statusText)
- })
- }
- ,
- a.CreateTextureAsync = function(e, i, o, s, c) {
- var d = e.textures[i];
- if (d.babylonTexture) {
- s(d.babylonTexture);
- return
- }
- var _ = e.samplers[d.sampler]
- , b = _.minFilter === ETextureFilterType.NEAREST_MIPMAP_NEAREST || _.minFilter === ETextureFilterType.NEAREST_MIPMAP_LINEAR || _.minFilter === ETextureFilterType.LINEAR_MIPMAP_NEAREST || _.minFilter === ETextureFilterType.LINEAR_MIPMAP_LINEAR
- , k = Texture.BILINEAR_SAMPLINGMODE
- , j = o == null ? new Blob : new Blob([o])
- , $ = URL.createObjectURL(j)
- , _e = function() {
- return URL.revokeObjectURL($)
- }
- , et = new Texture($,e.scene,!b,!0,k,_e,_e);
- _.wrapS !== void 0 && (et.wrapU = GLTFUtils.GetWrapMode(_.wrapS)),
- _.wrapT !== void 0 && (et.wrapV = GLTFUtils.GetWrapMode(_.wrapT)),
- et.name = i,
- d.babylonTexture = et,
- s(et)
- }
- ,
- a.LoadShaderStringAsync = function(e, i, o, s) {
- var c = e.shaders[i];
- if (Tools.IsBase64(c.uri)) {
- var d = atob(c.uri.split(",")[1]);
- o && o(d)
- } else
- Tools.LoadFile(e.rootUrl + c.uri, o, void 0, void 0, !1, function(_) {
- _ && s && s(_.status + " " + _.statusText)
- })
- }
- ,
- a.LoadMaterialAsync = function(e, i, o, s) {
- var c = e.materials[i];
- if (!c.technique) {
- s && s("No technique found.");
- return
- }
- var d = e.techniques[c.technique];
- if (!d) {
- e.scene._blockEntityCollection = !!e.assetContainer;
- var _ = new StandardMaterial(i,e.scene);
- _._parentContainer = e.assetContainer,
- e.scene._blockEntityCollection = !1,
- _.diffuseColor = new Color3(.5,.5,.5),
- _.sideOrientation = Material.CounterClockWiseSideOrientation,
- o(_);
- return
- }
- var b = e.programs[d.program]
- , k = d.states
- , j = Effect.ShadersStore[b.vertexShader + "VertexShader"]
- , $ = Effect.ShadersStore[b.fragmentShader + "PixelShader"]
- , _e = ""
- , et = ""
- , tt = new Tokenizer(j)
- , rt = new Tokenizer($)
- , it = {}
- , nt = []
- , ot = []
- , at = [];
- for (var st in d.uniforms) {
- var ut = d.uniforms[st]
- , ct = d.parameters[ut];
- if (it[st] = ct,
- ct.semantic && !ct.node && !ct.source) {
- var lt = glTFTransforms.indexOf(ct.semantic);
- lt !== -1 ? (nt.push(babylonTransforms[lt]),
- delete it[st]) : nt.push(st)
- } else
- ct.type === EParameterType.SAMPLER_2D ? at.push(st) : nt.push(st)
- }
- for (var ft in d.attributes) {
- var ht = d.attributes[ft]
- , pt = d.parameters[ht];
- if (pt.semantic) {
- var dt = getAttribute(pt);
- dt && ot.push(dt)
- }
- }
- for (; !tt.isEnd() && tt.getNextToken(); ) {
- var _t = tt.currentToken;
- if (_t !== ETokenType.IDENTIFIER) {
- _e += tt.currentString;
- continue
- }
- var mt = !1;
- for (var ft in d.attributes) {
- var ht = d.attributes[ft]
- , pt = d.parameters[ht];
- if (tt.currentIdentifier === ft && pt.semantic) {
- _e += getAttribute(pt),
- mt = !0;
- break
- }
- }
- mt || (_e += parseShaderUniforms(tt, d, it))
- }
- for (; !rt.isEnd() && rt.getNextToken(); ) {
- var _t = rt.currentToken;
- if (_t !== ETokenType.IDENTIFIER) {
- et += rt.currentString;
- continue
- }
- et += parseShaderUniforms(rt, d, it)
- }
- var vt = {
- vertex: b.vertexShader + i,
- fragment: b.fragmentShader + i
- }
- , yt = {
- attributes: ot,
- uniforms: nt,
- samplers: at,
- needAlphaBlending: k && k.enable && k.enable.indexOf(3042) !== -1
- };
- Effect.ShadersStore[b.vertexShader + i + "VertexShader"] = _e,
- Effect.ShadersStore[b.fragmentShader + i + "PixelShader"] = et;
- var Et = new ShaderMaterial(i,e.scene,vt,yt);
- if (Et.onError = onShaderCompileError(b, Et, s),
- Et.onCompiled = onShaderCompileSuccess(e, Et, d, c, it, o),
- Et.sideOrientation = Material.CounterClockWiseSideOrientation,
- k && k.functions) {
- var At = k.functions;
- At.cullFace && At.cullFace[0] !== ECullingType.BACK && (Et.backFaceCulling = !1);
- var gt = At.blendFuncSeparate;
- 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))
- }
- }
- ,
- a
- }()
- , GLTFLoader$1 = function() {
- function a() {}
- return a.RegisterExtension = function(e) {
- if (a.Extensions[e.name]) {
- Tools.Error('Tool with the same name "' + e.name + '" already exists');
- return
- }
- a.Extensions[e.name] = e
- }
- ,
- a.prototype.dispose = function() {}
- ,
- a.prototype._importMeshAsync = function(e, i, o, s, c, d, _, b) {
- var k = this;
- return i.useRightHandedSystem = !0,
- GLTFLoaderExtension.LoadRuntimeAsync(i, o, s, function(j) {
- j.assetContainer = c,
- j.importOnlyMeshes = !0,
- e === "" ? j.importMeshesNames = [] : typeof e == "string" ? j.importMeshesNames = [e] : e && !(e instanceof Array) ? j.importMeshesNames = [e] : (j.importMeshesNames = [],
- Tools.Warn("Argument meshesNames must be of type string or string[]")),
- k._createNodes(j);
- var $ = new Array
- , _e = new Array;
- for (var et in j.nodes) {
- var tt = j.nodes[et];
- tt.babylonNode instanceof AbstractMesh && $.push(tt.babylonNode)
- }
- for (var rt in j.skins) {
- var it = j.skins[rt];
- it.babylonSkeleton instanceof Skeleton && _e.push(it.babylonSkeleton)
- }
- k._loadBuffersAsync(j, function() {
- k._loadShadersAsync(j, function() {
- importMaterials(j),
- postLoad(j),
- !GLTFFileLoader.IncrementalLoading && d && d($, _e)
- })
- }, _),
- GLTFFileLoader.IncrementalLoading && d && d($, _e)
- }, b),
- !0
- }
- ,
- a.prototype.importMeshAsync = function(e, i, o, s, c, d) {
- var _ = this;
- return new Promise(function(b, k) {
- _._importMeshAsync(e, i, s, c, o, function(j, $) {
- b({
- meshes: j,
- particleSystems: [],
- skeletons: $,
- animationGroups: [],
- lights: [],
- transformNodes: [],
- geometries: []
- })
- }, d, function(j) {
- k(new Error(j))
- })
- }
- )
- }
- ,
- a.prototype._loadAsync = function(e, i, o, s, c, d) {
- var _ = this;
- e.useRightHandedSystem = !0,
- GLTFLoaderExtension.LoadRuntimeAsync(e, i, o, function(b) {
- GLTFLoaderExtension.LoadRuntimeExtensionsAsync(b, function() {
- _._createNodes(b),
- _._loadBuffersAsync(b, function() {
- _._loadShadersAsync(b, function() {
- importMaterials(b),
- postLoad(b),
- GLTFFileLoader.IncrementalLoading || s()
- })
- }),
- GLTFFileLoader.IncrementalLoading && s()
- }, d)
- }, d)
- }
- ,
- a.prototype.loadAsync = function(e, i, o, s) {
- var c = this;
- return new Promise(function(d, _) {
- c._loadAsync(e, i, o, function() {
- d()
- }, s, function(b) {
- _(new Error(b))
- })
- }
- )
- }
- ,
- a.prototype._loadShadersAsync = function(e, i) {
- var o = !1
- , s = function(_, b) {
- GLTFLoaderExtension.LoadShaderStringAsync(e, _, function(k) {
- k instanceof ArrayBuffer || (e.loadedShaderCount++,
- k && (Effect.ShadersStore[_ + (b.type === EShaderType.VERTEX ? "VertexShader" : "PixelShader")] = k),
- e.loadedShaderCount === e.shaderscount && i())
- }, function() {
- Tools.Error("Error when loading shader program named " + _ + " located at " + b.uri)
- })
- };
- for (var c in e.shaders) {
- o = !0;
- var d = e.shaders[c];
- d ? s.bind(this, c, d)() : Tools.Error("No shader named: " + c)
- }
- o || i()
- }
- ,
- a.prototype._loadBuffersAsync = function(e, i, o) {
- var s = !1
- , c = function(b, k) {
- GLTFLoaderExtension.LoadBufferAsync(e, b, function(j) {
- e.loadedBufferCount++,
- j && (j.byteLength != e.buffers[b].byteLength && Tools.Error("Buffer named " + b + " is length " + j.byteLength + ". Expected: " + k.byteLength),
- e.loadedBufferViews[b] = j),
- e.loadedBufferCount === e.buffersCount && i()
- }, function() {
- Tools.Error("Error when loading buffer named " + b + " located at " + k.uri)
- })
- };
- for (var d in e.buffers) {
- s = !0;
- var _ = e.buffers[d];
- _ ? c.bind(this, d, _)() : Tools.Error("No buffer named: " + d)
- }
- s || i()
- }
- ,
- a.prototype._createNodes = function(e) {
- var i = e.currentScene;
- if (i)
- for (var o = 0; o < i.nodes.length; o++)
- traverseNodes(e, i.nodes[o], null);
- else
- for (var s in e.scenes) {
- i = e.scenes[s];
- for (var o = 0; o < i.nodes.length; o++)
- traverseNodes(e, i.nodes[o], null)
- }
- }
- ,
- a.Extensions = {},
- a
- }()
- , GLTFLoaderExtension = function() {
- function a(e) {
- this._name = e
- }
- return Object.defineProperty(a.prototype, "name", {
- get: function() {
- return this._name
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.loadRuntimeAsync = function(e, i, o, s, c) {
- return !1
- }
- ,
- a.prototype.loadRuntimeExtensionsAsync = function(e, i, o) {
- return !1
- }
- ,
- a.prototype.loadBufferAsync = function(e, i, o, s, c) {
- return !1
- }
- ,
- a.prototype.loadTextureBufferAsync = function(e, i, o, s) {
- return !1
- }
- ,
- a.prototype.createTextureAsync = function(e, i, o, s, c) {
- return !1
- }
- ,
- a.prototype.loadShaderStringAsync = function(e, i, o, s) {
- return !1
- }
- ,
- a.prototype.loadMaterialAsync = function(e, i, o, s) {
- return !1
- }
- ,
- a.LoadRuntimeAsync = function(e, i, o, s, c) {
- a.ApplyExtensions(function(d) {
- return d.loadRuntimeAsync(e, i, o, s, c)
- }, function() {
- setTimeout(function() {
- !s || s(GLTFLoaderBase.CreateRuntime(i.json, e, o))
- })
- })
- }
- ,
- a.LoadRuntimeExtensionsAsync = function(e, i, o) {
- a.ApplyExtensions(function(s) {
- return s.loadRuntimeExtensionsAsync(e, i, o)
- }, function() {
- setTimeout(function() {
- i()
- })
- })
- }
- ,
- a.LoadBufferAsync = function(e, i, o, s, c) {
- a.ApplyExtensions(function(d) {
- return d.loadBufferAsync(e, i, o, s, c)
- }, function() {
- GLTFLoaderBase.LoadBufferAsync(e, i, o, s, c)
- })
- }
- ,
- a.LoadTextureAsync = function(e, i, o, s) {
- a.LoadTextureBufferAsync(e, i, function(c) {
- c && a.CreateTextureAsync(e, i, c, o, s)
- }, s)
- }
- ,
- a.LoadShaderStringAsync = function(e, i, o, s) {
- a.ApplyExtensions(function(c) {
- return c.loadShaderStringAsync(e, i, o, s)
- }, function() {
- GLTFLoaderBase.LoadShaderStringAsync(e, i, o, s)
- })
- }
- ,
- a.LoadMaterialAsync = function(e, i, o, s) {
- a.ApplyExtensions(function(c) {
- return c.loadMaterialAsync(e, i, o, s)
- }, function() {
- GLTFLoaderBase.LoadMaterialAsync(e, i, o, s)
- })
- }
- ,
- a.LoadTextureBufferAsync = function(e, i, o, s) {
- a.ApplyExtensions(function(c) {
- return c.loadTextureBufferAsync(e, i, o, s)
- }, function() {
- GLTFLoaderBase.LoadTextureBufferAsync(e, i, o, s)
- })
- }
- ,
- a.CreateTextureAsync = function(e, i, o, s, c) {
- a.ApplyExtensions(function(d) {
- return d.createTextureAsync(e, i, o, s, c)
- }, function() {
- GLTFLoaderBase.CreateTextureAsync(e, i, o, s, c)
- })
- }
- ,
- a.ApplyExtensions = function(e, i) {
- for (var o in GLTFLoader$1.Extensions) {
- var s = GLTFLoader$1.Extensions[o];
- if (e(s))
- return
- }
- i()
- }
- ,
- a
- }();
- GLTFFileLoader._CreateGLTF1Loader = function() {
- return new GLTFLoader$1
- }
- ;
- var BinaryExtensionBufferName = "binary_glTF"
- , GLTFBinaryExtension = function(a) {
- __extends(e, a);
- function e() {
- return a.call(this, "KHR_binary_glTF") || this
- }
- return e.prototype.loadRuntimeAsync = function(i, o, s, c, d) {
- var _ = o.json.extensionsUsed;
- return !_ || _.indexOf(this.name) === -1 || !o.bin ? !1 : (this._bin = o.bin,
- c(GLTFLoaderBase.CreateRuntime(o.json, i, s)),
- !0)
- }
- ,
- e.prototype.loadBufferAsync = function(i, o, s, c) {
- return i.extensionsUsed.indexOf(this.name) === -1 || o !== BinaryExtensionBufferName ? !1 : (this._bin.readAsync(0, this._bin.byteLength).then(s, function(d) {
- return c(d.message)
- }),
- !0)
- }
- ,
- e.prototype.loadTextureBufferAsync = function(i, o, s, c) {
- var d = i.textures[o]
- , _ = i.images[d.source];
- if (!_.extensions || !(this.name in _.extensions))
- return !1;
- var b = _.extensions[this.name]
- , k = i.bufferViews[b.bufferView]
- , j = GLTFUtils.GetBufferFromBufferView(i, k, 0, k.byteLength, EComponentType.UNSIGNED_BYTE);
- return s(j),
- !0
- }
- ,
- e.prototype.loadShaderStringAsync = function(i, o, s, c) {
- var d = i.shaders[o];
- if (!d.extensions || !(this.name in d.extensions))
- return !1;
- var _ = d.extensions[this.name]
- , b = i.bufferViews[_.bufferView]
- , k = GLTFUtils.GetBufferFromBufferView(i, b, 0, b.byteLength, EComponentType.UNSIGNED_BYTE);
- return setTimeout(function() {
- var j = GLTFUtils.DecodeBufferToText(k);
- s(j)
- }),
- !0
- }
- ,
- e
- }(GLTFLoaderExtension);
- GLTFLoader$1.RegisterExtension(new GLTFBinaryExtension);
- var GLTFMaterialsCommonExtension = function(a) {
- __extends(e, a);
- function e() {
- return a.call(this, "KHR_materials_common") || this
- }
- return e.prototype.loadRuntimeExtensionsAsync = function(i, o, s) {
- if (!i.extensions)
- return !1;
- var c = i.extensions[this.name];
- if (!c)
- return !1;
- var d = c.lights;
- if (d)
- for (var _ in d) {
- var b = d[_];
- switch (b.type) {
- case "ambient":
- var k = new HemisphericLight(b.name,new Vector3(0,1,0),i.scene)
- , j = b.ambient;
- j && (k.diffuse = Color3.FromArray(j.color || [1, 1, 1]));
- break;
- case "point":
- var $ = new PointLight(b.name,new Vector3(10,10,10),i.scene)
- , _e = b.point;
- _e && ($.diffuse = Color3.FromArray(_e.color || [1, 1, 1]));
- break;
- case "directional":
- var et = new DirectionalLight(b.name,new Vector3(0,-1,0),i.scene)
- , tt = b.directional;
- tt && (et.diffuse = Color3.FromArray(tt.color || [1, 1, 1]));
- break;
- case "spot":
- var rt = b.spot;
- if (rt) {
- 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);
- it.diffuse = Color3.FromArray(rt.color || [1, 1, 1])
- }
- break;
- default:
- Tools.Warn('GLTF Material Common extension: light type "' + b.type + "\u201D not supported");
- break
- }
- }
- return !1
- }
- ,
- e.prototype.loadMaterialAsync = function(i, o, s, c) {
- var d = i.materials[o];
- if (!d || !d.extensions)
- return !1;
- var _ = d.extensions[this.name];
- if (!_)
- return !1;
- var b = new StandardMaterial(o,i.scene);
- return b.sideOrientation = Material.CounterClockWiseSideOrientation,
- _.technique === "CONSTANT" && (b.disableLighting = !0),
- b.backFaceCulling = _.doubleSided === void 0 ? !1 : !_.doubleSided,
- b.alpha = _.values.transparency === void 0 ? 1 : _.values.transparency,
- b.specularPower = _.values.shininess === void 0 ? 0 : _.values.shininess,
- typeof _.values.ambient == "string" ? this._loadTexture(i, _.values.ambient, b, "ambientTexture", c) : b.ambientColor = Color3.FromArray(_.values.ambient || [0, 0, 0]),
- typeof _.values.diffuse == "string" ? this._loadTexture(i, _.values.diffuse, b, "diffuseTexture", c) : b.diffuseColor = Color3.FromArray(_.values.diffuse || [0, 0, 0]),
- typeof _.values.emission == "string" ? this._loadTexture(i, _.values.emission, b, "emissiveTexture", c) : b.emissiveColor = Color3.FromArray(_.values.emission || [0, 0, 0]),
- typeof _.values.specular == "string" ? this._loadTexture(i, _.values.specular, b, "specularTexture", c) : b.specularColor = Color3.FromArray(_.values.specular || [0, 0, 0]),
- !0
- }
- ,
- e.prototype._loadTexture = function(i, o, s, c, d) {
- GLTFLoaderBase.LoadTextureBufferAsync(i, o, function(_) {
- GLTFLoaderBase.CreateTextureAsync(i, o, _, function(b) {
- return s[c] = b
- }, d)
- }, d)
- }
- ,
- e
- }(GLTFLoaderExtension);
- GLTFLoader$1.RegisterExtension(new GLTFMaterialsCommonExtension);
- var Deferred = function() {
- function a() {
- var e = this;
- this.promise = new Promise(function(i, o) {
- e._resolve = i,
- e._reject = o
- }
- )
- }
- return Object.defineProperty(a.prototype, "resolve", {
- get: function() {
- return this._resolve
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "reject", {
- get: function() {
- return this._reject
- },
- enumerable: !1,
- configurable: !0
- }),
- a
- }()
- , PBRMaterial = function(a) {
- __extends(e, a);
- function e(i, o) {
- var s = a.call(this, i, o) || this;
- return s.directIntensity = 1,
- s.emissiveIntensity = 1,
- s.environmentIntensity = 1,
- s.specularIntensity = 1,
- s.disableBumpMap = !1,
- s.ambientTextureStrength = 1,
- s.ambientTextureImpactOnAnalyticalLights = e.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,
- s.metallicF0Factor = 1,
- s.metallicReflectanceColor = Color3.White(),
- s.useOnlyMetallicFromMetallicReflectanceTexture = !1,
- s.ambientColor = new Color3(0,0,0),
- s.albedoColor = new Color3(1,1,1),
- s.reflectivityColor = new Color3(1,1,1),
- s.reflectionColor = new Color3(1,1,1),
- s.emissiveColor = new Color3(0,0,0),
- s.microSurface = 1,
- s.useLightmapAsShadowmap = !1,
- s.useAlphaFromAlbedoTexture = !1,
- s.forceAlphaTest = !1,
- s.alphaCutOff = .4,
- s.useSpecularOverAlpha = !0,
- s.useMicroSurfaceFromReflectivityMapAlpha = !1,
- s.useRoughnessFromMetallicTextureAlpha = !0,
- s.useRoughnessFromMetallicTextureGreen = !1,
- s.useMetallnessFromMetallicTextureBlue = !1,
- s.useAmbientOcclusionFromMetallicTextureRed = !1,
- s.useAmbientInGrayScale = !1,
- s.useAutoMicroSurfaceFromReflectivityMap = !1,
- s.useRadianceOverAlpha = !0,
- s.useObjectSpaceNormalMap = !1,
- s.useParallax = !1,
- s.useParallaxOcclusion = !1,
- s.parallaxScaleBias = .05,
- s.disableLighting = !1,
- s.forceIrradianceInFragment = !1,
- s.maxSimultaneousLights = 4,
- s.invertNormalMapX = !1,
- s.invertNormalMapY = !1,
- s.twoSidedLighting = !1,
- s.useAlphaFresnel = !1,
- s.useLinearAlphaFresnel = !1,
- s.environmentBRDFTexture = null,
- s.forceNormalForward = !1,
- s.enableSpecularAntiAliasing = !1,
- s.useHorizonOcclusion = !0,
- s.useRadianceOcclusion = !0,
- s.unlit = !1,
- s._environmentBRDFTexture = GetEnvironmentBRDFTexture(o),
- s
- }
- return Object.defineProperty(e.prototype, "refractionTexture", {
- get: function() {
- return this.subSurface.refractionTexture
- },
- set: function(i) {
- this.subSurface.refractionTexture = i,
- i ? this.subSurface.isRefractionEnabled = !0 : this.subSurface.linkRefractionWithTransparency || (this.subSurface.isRefractionEnabled = !1)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "indexOfRefraction", {
- get: function() {
- return this.subSurface.indexOfRefraction
- },
- set: function(i) {
- this.subSurface.indexOfRefraction = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "invertRefractionY", {
- get: function() {
- return this.subSurface.invertRefractionY
- },
- set: function(i) {
- this.subSurface.invertRefractionY = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "linkRefractionWithTransparency", {
- get: function() {
- return this.subSurface.linkRefractionWithTransparency
- },
- set: function(i) {
- this.subSurface.linkRefractionWithTransparency = i,
- i && (this.subSurface.isRefractionEnabled = !0)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "usePhysicalLightFalloff", {
- get: function() {
- return this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL
- },
- set: function(i) {
- i !== this.usePhysicalLightFalloff && (this._markAllSubMeshesAsTexturesDirty(),
- i ? this._lightFalloff = PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL : this._lightFalloff = PBRBaseMaterial.LIGHTFALLOFF_STANDARD)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "useGLTFLightFalloff", {
- get: function() {
- return this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_GLTF
- },
- set: function(i) {
- i !== this.useGLTFLightFalloff && (this._markAllSubMeshesAsTexturesDirty(),
- i ? this._lightFalloff = PBRBaseMaterial.LIGHTFALLOFF_GLTF : this._lightFalloff = PBRBaseMaterial.LIGHTFALLOFF_STANDARD)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "imageProcessingConfiguration", {
- get: function() {
- return this._imageProcessingConfiguration
- },
- set: function(i) {
- this._attachImageProcessingConfiguration(i),
- this._markAllSubMeshesAsTexturesDirty()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cameraColorCurvesEnabled", {
- get: function() {
- return this.imageProcessingConfiguration.colorCurvesEnabled
- },
- set: function(i) {
- this.imageProcessingConfiguration.colorCurvesEnabled = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cameraColorGradingEnabled", {
- get: function() {
- return this.imageProcessingConfiguration.colorGradingEnabled
- },
- set: function(i) {
- this.imageProcessingConfiguration.colorGradingEnabled = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cameraToneMappingEnabled", {
- get: function() {
- return this._imageProcessingConfiguration.toneMappingEnabled
- },
- set: function(i) {
- this._imageProcessingConfiguration.toneMappingEnabled = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cameraExposure", {
- get: function() {
- return this._imageProcessingConfiguration.exposure
- },
- set: function(i) {
- this._imageProcessingConfiguration.exposure = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cameraContrast", {
- get: function() {
- return this._imageProcessingConfiguration.contrast
- },
- set: function(i) {
- this._imageProcessingConfiguration.contrast = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cameraColorGradingTexture", {
- get: function() {
- return this._imageProcessingConfiguration.colorGradingTexture
- },
- set: function(i) {
- this._imageProcessingConfiguration.colorGradingTexture = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cameraColorCurves", {
- get: function() {
- return this._imageProcessingConfiguration.colorCurves
- },
- set: function(i) {
- this._imageProcessingConfiguration.colorCurves = i
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getClassName = function() {
- return "PBRMaterial"
- }
- ,
- e.prototype.clone = function(i) {
- var o = this
- , s = SerializationHelper.Clone(function() {
- return new e(i,o.getScene())
- }, this);
- return s.id = i,
- s.name = i,
- this.stencil.copyTo(s.stencil),
- this.clearCoat.copyTo(s.clearCoat),
- this.anisotropy.copyTo(s.anisotropy),
- this.brdf.copyTo(s.brdf),
- this.sheen.copyTo(s.sheen),
- this.subSurface.copyTo(s.subSurface),
- s
- }
- ,
- e.prototype.serialize = function() {
- var i = SerializationHelper.Serialize(this);
- return i.customType = "BABYLON.PBRMaterial",
- i.stencil = this.stencil.serialize(),
- i.clearCoat = this.clearCoat.serialize(),
- i.anisotropy = this.anisotropy.serialize(),
- i.brdf = this.brdf.serialize(),
- i.sheen = this.sheen.serialize(),
- i.subSurface = this.subSurface.serialize(),
- i
- }
- ,
- e.Parse = function(i, o, s) {
- var c = SerializationHelper.Parse(function() {
- return new e(i.name,o)
- }, i, o, s);
- return i.stencil && c.stencil.parse(i.stencil, o, s),
- i.clearCoat && c.clearCoat.parse(i.clearCoat, o, s),
- i.anisotropy && c.anisotropy.parse(i.anisotropy, o, s),
- i.brdf && c.brdf.parse(i.brdf, o, s),
- i.sheen && c.sheen.parse(i.sheen, o, s),
- i.subSurface && c.subSurface.parse(i.subSurface, o, s),
- c
- }
- ,
- e.PBRMATERIAL_OPAQUE = PBRBaseMaterial.PBRMATERIAL_OPAQUE,
- e.PBRMATERIAL_ALPHATEST = PBRBaseMaterial.PBRMATERIAL_ALPHATEST,
- e.PBRMATERIAL_ALPHABLEND = PBRBaseMaterial.PBRMATERIAL_ALPHABLEND,
- e.PBRMATERIAL_ALPHATESTANDBLEND = PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND,
- e.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "directIntensity", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "emissiveIntensity", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "environmentIntensity", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "specularIntensity", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "disableBumpMap", void 0),
- __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "albedoTexture", void 0),
- __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "ambientTexture", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "ambientTextureStrength", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "ambientTextureImpactOnAnalyticalLights", void 0),
- __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")], e.prototype, "opacityTexture", void 0),
- __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "reflectionTexture", void 0),
- __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "emissiveTexture", void 0),
- __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "reflectivityTexture", void 0),
- __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "metallicTexture", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "metallic", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "roughness", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "metallicF0Factor", void 0),
- __decorate([serializeAsColor3(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "metallicReflectanceColor", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useOnlyMetallicFromMetallicReflectanceTexture", void 0),
- __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "metallicReflectanceTexture", void 0),
- __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "reflectanceTexture", void 0),
- __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "microSurfaceTexture", void 0),
- __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "bumpTexture", void 0),
- __decorate([serializeAsTexture(), expandToProperty("_markAllSubMeshesAsTexturesDirty", null)], e.prototype, "lightmapTexture", void 0),
- __decorate([serializeAsColor3("ambient"), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "ambientColor", void 0),
- __decorate([serializeAsColor3("albedo"), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "albedoColor", void 0),
- __decorate([serializeAsColor3("reflectivity"), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "reflectivityColor", void 0),
- __decorate([serializeAsColor3("reflection"), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "reflectionColor", void 0),
- __decorate([serializeAsColor3("emissive"), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "emissiveColor", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "microSurface", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useLightmapAsShadowmap", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")], e.prototype, "useAlphaFromAlbedoTexture", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")], e.prototype, "forceAlphaTest", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")], e.prototype, "alphaCutOff", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useSpecularOverAlpha", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useMicroSurfaceFromReflectivityMapAlpha", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useRoughnessFromMetallicTextureAlpha", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useRoughnessFromMetallicTextureGreen", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useMetallnessFromMetallicTextureBlue", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useAmbientOcclusionFromMetallicTextureRed", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useAmbientInGrayScale", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useAutoMicroSurfaceFromReflectivityMap", void 0),
- __decorate([serialize()], e.prototype, "usePhysicalLightFalloff", null),
- __decorate([serialize()], e.prototype, "useGLTFLightFalloff", null),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useRadianceOverAlpha", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useObjectSpaceNormalMap", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useParallax", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useParallaxOcclusion", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "parallaxScaleBias", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsLightsDirty")], e.prototype, "disableLighting", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "forceIrradianceInFragment", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsLightsDirty")], e.prototype, "maxSimultaneousLights", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "invertNormalMapX", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "invertNormalMapY", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "twoSidedLighting", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useAlphaFresnel", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useLinearAlphaFresnel", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "environmentBRDFTexture", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "forceNormalForward", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "enableSpecularAntiAliasing", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useHorizonOcclusion", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useRadianceOcclusion", void 0),
- __decorate([serialize(), expandToProperty("_markAllSubMeshesAsMiscDirty")], e.prototype, "unlit", void 0),
- e
- }(PBRBaseMaterial);
- RegisterClass("BABYLON.PBRMaterial", PBRMaterial);
- var MorphTarget = function() {
- function a(e, i, o) {
- i === void 0 && (i = 0),
- o === void 0 && (o = null),
- this.name = e,
- this.animations = new Array,
- this._positions = null,
- this._normals = null,
- this._tangents = null,
- this._uvs = null,
- this._uniqueId = 0,
- this.onInfluenceChanged = new Observable,
- this._onDataLayoutChanged = new Observable,
- this._animationPropertiesOverride = null,
- this._scene = o || EngineStore.LastCreatedScene,
- this.influence = i,
- this._scene && (this._uniqueId = this._scene.getUniqueId())
- }
- return Object.defineProperty(a.prototype, "influence", {
- get: function() {
- return this._influence
- },
- set: function(e) {
- if (this._influence !== e) {
- var i = this._influence;
- this._influence = e,
- this.onInfluenceChanged.hasObservers() && this.onInfluenceChanged.notifyObservers(i === 0 || e === 0)
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "animationPropertiesOverride", {
- get: function() {
- return !this._animationPropertiesOverride && this._scene ? this._scene.animationPropertiesOverride : this._animationPropertiesOverride
- },
- set: function(e) {
- this._animationPropertiesOverride = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "uniqueId", {
- get: function() {
- return this._uniqueId
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "hasPositions", {
- get: function() {
- return !!this._positions
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "hasNormals", {
- get: function() {
- return !!this._normals
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "hasTangents", {
- get: function() {
- return !!this._tangents
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "hasUVs", {
- get: function() {
- return !!this._uvs
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.setPositions = function(e) {
- var i = this.hasPositions;
- this._positions = e,
- i !== this.hasPositions && this._onDataLayoutChanged.notifyObservers(void 0)
- }
- ,
- a.prototype.getPositions = function() {
- return this._positions
- }
- ,
- a.prototype.setNormals = function(e) {
- var i = this.hasNormals;
- this._normals = e,
- i !== this.hasNormals && this._onDataLayoutChanged.notifyObservers(void 0)
- }
- ,
- a.prototype.getNormals = function() {
- return this._normals
- }
- ,
- a.prototype.setTangents = function(e) {
- var i = this.hasTangents;
- this._tangents = e,
- i !== this.hasTangents && this._onDataLayoutChanged.notifyObservers(void 0)
- }
- ,
- a.prototype.getTangents = function() {
- return this._tangents
- }
- ,
- a.prototype.setUVs = function(e) {
- var i = this.hasUVs;
- this._uvs = e,
- i !== this.hasUVs && this._onDataLayoutChanged.notifyObservers(void 0)
- }
- ,
- a.prototype.getUVs = function() {
- return this._uvs
- }
- ,
- a.prototype.clone = function() {
- var e = this
- , i = SerializationHelper.Clone(function() {
- return new a(e.name,e.influence,e._scene)
- }, this);
- return i._positions = this._positions,
- i._normals = this._normals,
- i._tangents = this._tangents,
- i._uvs = this._uvs,
- i
- }
- ,
- a.prototype.serialize = function() {
- var e = {};
- return e.name = this.name,
- e.influence = this.influence,
- e.positions = Array.prototype.slice.call(this.getPositions()),
- this.id != null && (e.id = this.id),
- this.hasNormals && (e.normals = Array.prototype.slice.call(this.getNormals())),
- this.hasTangents && (e.tangents = Array.prototype.slice.call(this.getTangents())),
- this.hasUVs && (e.uvs = Array.prototype.slice.call(this.getUVs())),
- SerializationHelper.AppendSerializedAnimations(this, e),
- e
- }
- ,
- a.prototype.getClassName = function() {
- return "MorphTarget"
- }
- ,
- a.Parse = function(e) {
- var i = new a(e.name,e.influence);
- if (i.setPositions(e.positions),
- e.id != null && (i.id = e.id),
- e.normals && i.setNormals(e.normals),
- e.tangents && i.setTangents(e.tangents),
- e.uvs && i.setUVs(e.uvs),
- e.animations)
- for (var o = 0; o < e.animations.length; o++) {
- var s = e.animations[o]
- , c = GetClass("BABYLON.Animation");
- c && i.animations.push(c.Parse(s))
- }
- return i
- }
- ,
- a.FromMesh = function(e, i, o) {
- i || (i = e.name);
- var s = new a(i,o,e.getScene());
- return s.setPositions(e.getVerticesData(VertexBuffer.PositionKind)),
- e.isVerticesDataPresent(VertexBuffer.NormalKind) && s.setNormals(e.getVerticesData(VertexBuffer.NormalKind)),
- e.isVerticesDataPresent(VertexBuffer.TangentKind) && s.setTangents(e.getVerticesData(VertexBuffer.TangentKind)),
- e.isVerticesDataPresent(VertexBuffer.UVKind) && s.setUVs(e.getVerticesData(VertexBuffer.UVKind)),
- s
- }
- ,
- __decorate([serialize()], a.prototype, "id", void 0),
- a
- }()
- , RawTexture2DArray = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _, b, k, j, $) {
- b === void 0 && (b = !0),
- k === void 0 && (k = !1),
- j === void 0 && (j = Texture.TRILINEAR_SAMPLINGMODE),
- $ === void 0 && ($ = 0);
- var _e = a.call(this, null, _, !b, k) || this;
- return _e.format = d,
- _e._texture = _.getEngine().createRawTexture2DArray(i, o, s, c, d, b, k, j, null, $),
- _e._depth = c,
- _e.is2DArray = !0,
- _e
- }
- return Object.defineProperty(e.prototype, "depth", {
- get: function() {
- return this._depth
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.update = function(i) {
- !this._texture || this._getEngine().updateRawTexture2DArray(this._texture, i, this._texture.format, this._texture.invertY, null, this._texture.type)
- }
- ,
- e.CreateRGBATexture = function(i, o, s, c, d, _, b, k, j) {
- return _ === void 0 && (_ = !0),
- b === void 0 && (b = !1),
- k === void 0 && (k = 3),
- j === void 0 && (j = 0),
- new e(i,o,s,c,5,d,_,b,k,j)
- }
- ,
- e
- }(Texture)
- , MorphTargetManager = function() {
- function a(e) {
- if (e === void 0 && (e = null),
- this._targets = new Array,
- this._targetInfluenceChangedObservers = new Array,
- this._targetDataLayoutChangedObservers = new Array,
- this._activeTargets = new SmartArray(16),
- this._supportsNormals = !1,
- this._supportsTangents = !1,
- this._supportsUVs = !1,
- this._vertexCount = 0,
- this._textureVertexStride = 0,
- this._textureWidth = 0,
- this._textureHeight = 1,
- this._uniqueId = 0,
- this._tempInfluences = new Array,
- this._canUseTextureForTargets = !1,
- this._blockCounter = 0,
- this._parentContainer = null,
- this.optimizeInfluencers = !0,
- this.enableNormalMorphing = !0,
- this.enableTangentMorphing = !0,
- this.enableUVMorphing = !0,
- this._useTextureToStoreTargets = !0,
- e || (e = EngineStore.LastCreatedScene),
- this._scene = e,
- this._scene) {
- this._scene.morphTargetManagers.push(this),
- this._uniqueId = this._scene.getUniqueId();
- var i = this._scene.getEngine().getCaps();
- this._canUseTextureForTargets = i.canUseGLVertexID && i.textureFloat && i.maxVertexTextureImageUnits > 0
- }
- }
- return Object.defineProperty(a.prototype, "areUpdatesFrozen", {
- get: function() {
- return this._blockCounter > 0
- },
- set: function(e) {
- e ? this._blockCounter++ : (this._blockCounter--,
- this._blockCounter <= 0 && (this._blockCounter = 0,
- this._syncActiveTargets(!0)))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "uniqueId", {
- get: function() {
- return this._uniqueId
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "vertexCount", {
- get: function() {
- return this._vertexCount
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "supportsNormals", {
- get: function() {
- return this._supportsNormals && this.enableNormalMorphing
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "supportsTangents", {
- get: function() {
- return this._supportsTangents && this.enableTangentMorphing
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "supportsUVs", {
- get: function() {
- return this._supportsUVs && this.enableUVMorphing
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "numTargets", {
- get: function() {
- return this._targets.length
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "numInfluencers", {
- get: function() {
- return this._activeTargets.length
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "influences", {
- get: function() {
- return this._influences
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "useTextureToStoreTargets", {
- get: function() {
- return this._useTextureToStoreTargets
- },
- set: function(e) {
- this._useTextureToStoreTargets = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "isUsingTextureForTargets", {
- get: function() {
- return a.EnableTextureStorage && this.useTextureToStoreTargets && this._canUseTextureForTargets
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.getActiveTarget = function(e) {
- return this._activeTargets.data[e]
- }
- ,
- a.prototype.getTarget = function(e) {
- return this._targets[e]
- }
- ,
- a.prototype.addTarget = function(e) {
- var i = this;
- this._targets.push(e),
- this._targetInfluenceChangedObservers.push(e.onInfluenceChanged.add(function(o) {
- i._syncActiveTargets(o)
- })),
- this._targetDataLayoutChangedObservers.push(e._onDataLayoutChanged.add(function() {
- i._syncActiveTargets(!0)
- })),
- this._syncActiveTargets(!0)
- }
- ,
- a.prototype.removeTarget = function(e) {
- var i = this._targets.indexOf(e);
- i >= 0 && (this._targets.splice(i, 1),
- e.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(i, 1)[0]),
- e._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(i, 1)[0]),
- this._syncActiveTargets(!0))
- }
- ,
- a.prototype._bind = function(e) {
- e.setFloat3("morphTargetTextureInfo", this._textureVertexStride, this._textureWidth, this._textureHeight),
- e.setFloatArray("morphTargetTextureIndices", this._morphTargetTextureIndices),
- e.setTexture("morphTargets", this._targetStoreTexture)
- }
- ,
- a.prototype.clone = function() {
- for (var e = new a(this._scene), i = 0, o = this._targets; i < o.length; i++) {
- var s = o[i];
- e.addTarget(s.clone())
- }
- return e.enableNormalMorphing = this.enableNormalMorphing,
- e.enableTangentMorphing = this.enableTangentMorphing,
- e.enableUVMorphing = this.enableUVMorphing,
- e
- }
- ,
- a.prototype.serialize = function() {
- var e = {};
- e.id = this.uniqueId,
- e.targets = [];
- for (var i = 0, o = this._targets; i < o.length; i++) {
- var s = o[i];
- e.targets.push(s.serialize())
- }
- return e
- }
- ,
- a.prototype._syncActiveTargets = function(e) {
- if (!this.areUpdatesFrozen) {
- var i = 0;
- this._activeTargets.reset(),
- this._supportsNormals = !0,
- this._supportsTangents = !0,
- this._supportsUVs = !0,
- this._vertexCount = 0,
- (!this._morphTargetTextureIndices || this._morphTargetTextureIndices.length !== this._targets.length) && (this._morphTargetTextureIndices = new Float32Array(this._targets.length));
- for (var o = -1, s = 0, c = this._targets; s < c.length; s++) {
- var d = c[s];
- if (o++,
- !(d.influence === 0 && this.optimizeInfluencers)) {
- this._activeTargets.push(d),
- this._morphTargetTextureIndices[i] = o,
- this._tempInfluences[i++] = d.influence,
- this._supportsNormals = this._supportsNormals && d.hasNormals,
- this._supportsTangents = this._supportsTangents && d.hasTangents,
- this._supportsUVs = this._supportsUVs && d.hasUVs;
- var _ = d.getPositions();
- if (_) {
- var b = _.length / 3;
- if (this._vertexCount === 0)
- this._vertexCount = b;
- else if (this._vertexCount !== b) {
- Logger$2.Error("Incompatible target. Targets must all have the same vertices count.");
- return
- }
- }
- }
- }
- (!this._influences || this._influences.length !== i) && (this._influences = new Float32Array(i));
- for (var k = 0; k < i; k++)
- this._influences[k] = this._tempInfluences[k];
- e && this.synchronize()
- }
- }
- ,
- a.prototype.synchronize = function() {
- if (!(!this._scene || this.areUpdatesFrozen)) {
- if (this.isUsingTextureForTargets && this._vertexCount) {
- this._textureVertexStride = 1,
- this._supportsNormals && this._textureVertexStride++,
- this._supportsTangents && this._textureVertexStride++,
- this._supportsUVs && this._textureVertexStride++,
- this._textureWidth = this._vertexCount * this._textureVertexStride,
- this._textureHeight = 1;
- var e = this._scene.getEngine().getCaps().maxTextureSize;
- this._textureWidth > e && (this._textureHeight = Math.ceil(this._textureWidth / e),
- this._textureWidth = e);
- var i = !0;
- if (this._targetStoreTexture) {
- var o = this._targetStoreTexture.getSize();
- o.width === this._textureWidth && o.height === this._textureHeight && this._targetStoreTexture.depth === this._targets.length && (i = !1)
- }
- if (i) {
- this._targetStoreTexture && this._targetStoreTexture.dispose();
- for (var s = this._targets.length, c = new Float32Array(s * this._textureWidth * this._textureHeight * 4), d = 0, _ = 0; _ < s; _++) {
- var b = this._targets[_]
- , k = b.getPositions()
- , j = b.getNormals()
- , $ = b.getUVs()
- , _e = b.getTangents();
- if (!k) {
- _ === 0 && Logger$2.Error("Invalid morph target. Target must have positions.");
- return
- }
- d = _ * this._textureWidth * this._textureHeight * 4;
- for (var et = 0; et < this._vertexCount; et++)
- c[d] = k[et * 3],
- c[d + 1] = k[et * 3 + 1],
- c[d + 2] = k[et * 3 + 2],
- d += 4,
- j && (c[d] = j[et * 3],
- c[d + 1] = j[et * 3 + 1],
- c[d + 2] = j[et * 3 + 2],
- d += 4),
- $ && (c[d] = $[et * 2],
- c[d + 1] = $[et * 2 + 1],
- d += 4),
- _e && (c[d] = _e[et * 3],
- c[d + 1] = _e[et * 3 + 1],
- c[d + 2] = _e[et * 3 + 2],
- d += 4)
- }
- this._targetStoreTexture = RawTexture2DArray.CreateRGBATexture(c, this._textureWidth, this._textureHeight, s, this._scene, !1, !1, 1, 1)
- }
- }
- for (var tt = 0, rt = this._scene.meshes; tt < rt.length; tt++) {
- var it = rt[tt];
- it.morphTargetManager === this && it._syncGeometryWithMorphTargetManager()
- }
- }
- }
- ,
- a.prototype.dispose = function() {
- if (this._targetStoreTexture && this._targetStoreTexture.dispose(),
- this._targetStoreTexture = null,
- this._scene && (this._scene.removeMorphTargetManager(this),
- this._parentContainer)) {
- var e = this._parentContainer.morphTargetManagers.indexOf(this);
- e > -1 && this._parentContainer.morphTargetManagers.splice(e, 1),
- this._parentContainer = null
- }
- }
- ,
- a.Parse = function(e, i) {
- var o = new a(i);
- o._uniqueId = e.id;
- for (var s = 0, c = e.targets; s < c.length; s++) {
- var d = c[s];
- o.addTarget(MorphTarget.Parse(d))
- }
- return o
- }
- ,
- a.EnableTextureStorage = !0,
- a
- }()
- , ArrayItem = function() {
- function a() {}
- return a.Get = function(e, i, o) {
- if (!i || o == null || !i[o])
- throw new Error(e + ": Failed to find index (" + o + ")");
- return i[o]
- }
- ,
- a.Assign = function(e) {
- if (e)
- for (var i = 0; i < e.length; i++)
- e[i].index = i
- }
- ,
- a
- }()
- , GLTFLoader = function() {
- function a(e) {
- this._completePromises = new Array,
- this._assetContainer = null,
- this._babylonLights = [],
- this._disableInstancedMesh = 0,
- this._disposed = !1,
- this._extensions = new Array,
- this._rootBabylonMesh = null,
- this._defaultBabylonMaterialData = {},
- this._parent = e
- }
- return a.RegisterExtension = function(e, i) {
- a.UnregisterExtension(e) && Logger$2.Warn("Extension with the name '" + e + "' already exists"),
- a._RegisteredExtensions[e] = {
- factory: i
- }
- }
- ,
- a.UnregisterExtension = function(e) {
- return a._RegisteredExtensions[e] ? (delete a._RegisteredExtensions[e],
- !0) : !1
- }
- ,
- Object.defineProperty(a.prototype, "gltf", {
- get: function() {
- return this._gltf
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "bin", {
- get: function() {
- return this._bin
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "parent", {
- get: function() {
- return this._parent
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "babylonScene", {
- get: function() {
- return this._babylonScene
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "rootBabylonMesh", {
- get: function() {
- return this._rootBabylonMesh
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.dispose = function() {
- if (!this._disposed) {
- this._disposed = !0,
- this._completePromises.length = 0;
- for (var e in this._extensions) {
- var i = this._extensions[e];
- i.dispose && i.dispose(),
- delete this._extensions[e]
- }
- this._gltf = null,
- this._babylonScene = null,
- this._rootBabylonMesh = null,
- this._parent.dispose()
- }
- }
- ,
- a.prototype.importMeshAsync = function(e, i, o, s, c, d, _) {
- var b = this;
- return _ === void 0 && (_ = ""),
- Promise.resolve().then(function() {
- b._babylonScene = i,
- b._assetContainer = o,
- b._loadData(s);
- var k = null;
- if (e) {
- var j = {};
- if (b._gltf.nodes)
- for (var $ = 0, _e = b._gltf.nodes; $ < _e.length; $++) {
- var et = _e[$];
- et.name && (j[et.name] = et.index)
- }
- var tt = e instanceof Array ? e : [e];
- k = tt.map(function(rt) {
- var it = j[rt];
- if (it === void 0)
- throw new Error("Failed to find node '" + rt + "'");
- return it
- })
- }
- return b._loadAsync(c, _, k, function() {
- return {
- meshes: b._getMeshes(),
- particleSystems: [],
- skeletons: b._getSkeletons(),
- animationGroups: b._getAnimationGroups(),
- lights: b._babylonLights,
- transformNodes: b._getTransformNodes(),
- geometries: b._getGeometries()
- }
- })
- })
- }
- ,
- a.prototype.loadAsync = function(e, i, o, s, c) {
- var d = this;
- return c === void 0 && (c = ""),
- Promise.resolve().then(function() {
- return d._babylonScene = e,
- d._loadData(i),
- d._loadAsync(o, c, null, function() {})
- })
- }
- ,
- a.prototype._loadAsync = function(e, i, o, s) {
- var c = this;
- return Promise.resolve().then(function() {
- c._rootUrl = e,
- c._uniqueRootUrl = !StringTools.StartsWith(e, "file:") && i ? e : "" + e + Date.now() + "/",
- c._fileName = i,
- c._loadExtensions(),
- c._checkExtensions();
- var d = GLTFLoaderState[GLTFLoaderState.LOADING] + " => " + GLTFLoaderState[GLTFLoaderState.READY]
- , _ = GLTFLoaderState[GLTFLoaderState.LOADING] + " => " + GLTFLoaderState[GLTFLoaderState.COMPLETE];
- c._parent._startPerformanceCounter(d),
- c._parent._startPerformanceCounter(_),
- c._parent._setState(GLTFLoaderState.LOADING),
- c._extensionsOnLoading();
- var b = new Array
- , k = c._babylonScene.blockMaterialDirtyMechanism;
- if (c._babylonScene.blockMaterialDirtyMechanism = !0,
- o)
- b.push(c.loadSceneAsync("/nodes", {
- nodes: o,
- index: -1
- }));
- else if (c._gltf.scene != null || c._gltf.scenes && c._gltf.scenes[0]) {
- var j = ArrayItem.Get("/scene", c._gltf.scenes, c._gltf.scene || 0);
- b.push(c.loadSceneAsync("/scenes/" + j.index, j))
- }
- if (c.parent.loadAllMaterials && c._gltf.materials)
- for (var $ = 0; $ < c._gltf.materials.length; ++$) {
- var _e = c._gltf.materials[$]
- , et = "/materials/" + $
- , tt = Material.TriangleFillMode;
- b.push(c._loadMaterialAsync(et, _e, null, tt, function(it) {}))
- }
- c._babylonScene.blockMaterialDirtyMechanism = k,
- c._parent.compileMaterials && b.push(c._compileMaterialsAsync()),
- c._parent.compileShadowGenerators && b.push(c._compileShadowGeneratorsAsync());
- var rt = Promise.all(b).then(function() {
- return c._rootBabylonMesh && c._rootBabylonMesh.setEnabled(!0),
- c._extensionsOnReady(),
- c._parent._setState(GLTFLoaderState.READY),
- c._startAnimations(),
- s()
- });
- return rt.then(function(it) {
- return c._parent._endPerformanceCounter(d),
- Tools.SetImmediate(function() {
- c._disposed || Promise.all(c._completePromises).then(function() {
- c._parent._endPerformanceCounter(_),
- c._parent._setState(GLTFLoaderState.COMPLETE),
- c._parent.onCompleteObservable.notifyObservers(void 0),
- c._parent.onCompleteObservable.clear(),
- c.dispose()
- }, function(nt) {
- c._parent.onErrorObservable.notifyObservers(nt),
- c._parent.onErrorObservable.clear(),
- c.dispose()
- })
- }),
- it
- })
- }).catch(function(d) {
- throw c._disposed || (c._parent.onErrorObservable.notifyObservers(d),
- c._parent.onErrorObservable.clear(),
- c.dispose()),
- d
- })
- }
- ,
- a.prototype._loadData = function(e) {
- if (this._gltf = e.json,
- this._setupData(),
- e.bin) {
- var i = this._gltf.buffers;
- if (i && i[0] && !i[0].uri) {
- var o = i[0];
- (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 + ")"),
- this._bin = e.bin
- } else
- Logger$2.Warn("Unexpected BIN chunk")
- }
- }
- ,
- a.prototype._setupData = function() {
- if (ArrayItem.Assign(this._gltf.accessors),
- ArrayItem.Assign(this._gltf.animations),
- ArrayItem.Assign(this._gltf.buffers),
- ArrayItem.Assign(this._gltf.bufferViews),
- ArrayItem.Assign(this._gltf.cameras),
- ArrayItem.Assign(this._gltf.images),
- ArrayItem.Assign(this._gltf.materials),
- ArrayItem.Assign(this._gltf.meshes),
- ArrayItem.Assign(this._gltf.nodes),
- ArrayItem.Assign(this._gltf.samplers),
- ArrayItem.Assign(this._gltf.scenes),
- ArrayItem.Assign(this._gltf.skins),
- ArrayItem.Assign(this._gltf.textures),
- this._gltf.nodes) {
- for (var e = {}, i = 0, o = this._gltf.nodes; i < o.length; i++) {
- var s = o[i];
- if (s.children)
- for (var c = 0, d = s.children; c < d.length; c++) {
- var _ = d[c];
- e[_] = s.index
- }
- }
- for (var b = this._createRootNode(), k = 0, j = this._gltf.nodes; k < j.length; k++) {
- var s = j[k]
- , $ = e[s.index];
- s.parent = $ === void 0 ? b : this._gltf.nodes[$]
- }
- }
- }
- ,
- a.prototype._loadExtensions = function() {
- for (var e in a._RegisteredExtensions) {
- var i = a._RegisteredExtensions[e].factory(this);
- i.name !== e && Logger$2.Warn("The name of the glTF loader extension instance does not match the registered name: " + i.name + " !== " + e),
- this._extensions.push(i),
- this._parent.onExtensionLoadedObservable.notifyObservers(i)
- }
- this._extensions.sort(function(o, s) {
- return (o.order || Number.MAX_VALUE) - (s.order || Number.MAX_VALUE)
- }),
- this._parent.onExtensionLoadedObservable.clear()
- }
- ,
- a.prototype._checkExtensions = function() {
- if (this._gltf.extensionsRequired)
- for (var e = function(d) {
- var _ = i._extensions.some(function(b) {
- return b.name === d && b.enabled
- });
- if (!_)
- throw new Error("Require extension " + d + " is not available")
- }, i = this, o = 0, s = this._gltf.extensionsRequired; o < s.length; o++) {
- var c = s[o];
- e(c)
- }
- }
- ,
- a.prototype._createRootNode = function() {
- this._babylonScene._blockEntityCollection = !!this._assetContainer,
- this._rootBabylonMesh = new Mesh("__root__",this._babylonScene),
- this._rootBabylonMesh._parentContainer = this._assetContainer,
- this._babylonScene._blockEntityCollection = !1,
- this._rootBabylonMesh.setEnabled(!1);
- var e = {
- _babylonTransformNode: this._rootBabylonMesh,
- index: -1
- };
- switch (this._parent.coordinateSystemMode) {
- case GLTFLoaderCoordinateSystemMode.AUTO:
- {
- this._babylonScene.useRightHandedSystem || (e.rotation = [0, 1, 0, 0],
- e.scale = [1, 1, -1],
- a._LoadTransform(e, this._rootBabylonMesh));
- break
- }
- case GLTFLoaderCoordinateSystemMode.FORCE_RIGHT_HANDED:
- {
- this._babylonScene.useRightHandedSystem = !0;
- break
- }
- default:
- throw new Error("Invalid coordinate system mode (" + this._parent.coordinateSystemMode + ")")
- }
- return this._parent.onMeshLoadedObservable.notifyObservers(this._rootBabylonMesh),
- e
- }
- ,
- a.prototype.loadSceneAsync = function(e, i) {
- var o = this
- , s = this._extensionsLoadSceneAsync(e, i);
- if (s)
- return s;
- var c = new Array;
- if (this.logOpen(e + " " + (i.name || "")),
- i.nodes)
- for (var d = 0, _ = i.nodes; d < _.length; d++) {
- var b = _[d]
- , k = ArrayItem.Get(e + "/nodes/" + b, this._gltf.nodes, b);
- c.push(this.loadNodeAsync("/nodes/" + k.index, k, function(rt) {
- rt.parent = o._rootBabylonMesh
- }))
- }
- if (this._gltf.nodes)
- for (var j = 0, $ = this._gltf.nodes; j < $.length; j++) {
- var k = $[j];
- if (k._babylonTransformNode && k._babylonBones)
- for (var _e = 0, et = k._babylonBones; _e < et.length; _e++) {
- var tt = et[_e];
- tt.linkTransformNode(k._babylonTransformNode)
- }
- }
- return c.push(this._loadAnimationsAsync()),
- this.logClose(),
- Promise.all(c).then(function() {})
- }
- ,
- a.prototype._forEachPrimitive = function(e, i) {
- if (e._primitiveBabylonMeshes)
- for (var o = 0, s = e._primitiveBabylonMeshes; o < s.length; o++) {
- var c = s[o];
- i(c)
- }
- }
- ,
- a.prototype._getGeometries = function() {
- var e = new Array
- , i = this._gltf.nodes;
- if (i)
- for (var o = 0, s = i; o < s.length; o++) {
- var c = s[o];
- this._forEachPrimitive(c, function(d) {
- var _ = d.geometry;
- _ && e.indexOf(_) === -1 && e.push(_)
- })
- }
- return e
- }
- ,
- a.prototype._getMeshes = function() {
- var e = new Array;
- this._rootBabylonMesh && e.push(this._rootBabylonMesh);
- var i = this._gltf.nodes;
- if (i)
- for (var o = 0, s = i; o < s.length; o++) {
- var c = s[o];
- this._forEachPrimitive(c, function(d) {
- e.push(d)
- })
- }
- return e
- }
- ,
- a.prototype._getTransformNodes = function() {
- var e = new Array
- , i = this._gltf.nodes;
- if (i)
- for (var o = 0, s = i; o < s.length; o++) {
- var c = s[o];
- c._babylonTransformNode && c._babylonTransformNode.getClassName() === "TransformNode" && e.push(c._babylonTransformNode)
- }
- return e
- }
- ,
- a.prototype._getSkeletons = function() {
- var e = new Array
- , i = this._gltf.skins;
- if (i)
- for (var o = 0, s = i; o < s.length; o++) {
- var c = s[o];
- c._data && e.push(c._data.babylonSkeleton)
- }
- return e
- }
- ,
- a.prototype._getAnimationGroups = function() {
- var e = new Array
- , i = this._gltf.animations;
- if (i)
- for (var o = 0, s = i; o < s.length; o++) {
- var c = s[o];
- c._babylonAnimationGroup && e.push(c._babylonAnimationGroup)
- }
- return e
- }
- ,
- a.prototype._startAnimations = function() {
- switch (this._parent.animationStartMode) {
- case GLTFLoaderAnimationStartMode.NONE:
- break;
- case GLTFLoaderAnimationStartMode.FIRST:
- {
- var e = this._getAnimationGroups();
- e.length !== 0 && e[0].start(!0);
- break
- }
- case GLTFLoaderAnimationStartMode.ALL:
- {
- for (var e = this._getAnimationGroups(), i = 0, o = e; i < o.length; i++) {
- var s = o[i];
- s.start(!0)
- }
- break
- }
- default:
- {
- Logger$2.Error("Invalid animation start mode (" + this._parent.animationStartMode + ")");
- return
- }
- }
- }
- ,
- a.prototype.loadNodeAsync = function(e, i, o) {
- var s = this;
- o === void 0 && (o = function() {}
- );
- var c = this._extensionsLoadNodeAsync(e, i, o);
- if (c)
- return c;
- if (i._babylonTransformNode)
- throw new Error(e + ": Invalid recursive node hierarchy");
- var d = new Array;
- this.logOpen(e + " " + (i.name || ""));
- var _ = function(j) {
- if (a.AddPointerMetadata(j, e),
- a._LoadTransform(i, j),
- i.camera != null) {
- var $ = ArrayItem.Get(e + "/camera", s._gltf.cameras, i.camera);
- d.push(s.loadCameraAsync("/cameras/" + $.index, $, function(it) {
- it.parent = j
- }))
- }
- if (i.children)
- for (var _e = 0, et = i.children; _e < et.length; _e++) {
- var tt = et[_e]
- , rt = ArrayItem.Get(e + "/children/" + tt, s._gltf.nodes, tt);
- d.push(s.loadNodeAsync("/nodes/" + rt.index, rt, function(it) {
- it.parent = j
- }))
- }
- o(j)
- };
- if (i.mesh == null) {
- var b = i.name || "node" + i.index;
- this._babylonScene._blockEntityCollection = !!this._assetContainer,
- i._babylonTransformNode = new TransformNode(b,this._babylonScene),
- i._babylonTransformNode._parentContainer = this._assetContainer,
- this._babylonScene._blockEntityCollection = !1,
- _(i._babylonTransformNode)
- } else {
- var k = ArrayItem.Get(e + "/mesh", this._gltf.meshes, i.mesh);
- d.push(this._loadMeshAsync("/meshes/" + k.index, i, k, _))
- }
- return this.logClose(),
- Promise.all(d).then(function() {
- return s._forEachPrimitive(i, function(j) {
- j.geometry && j.geometry.useBoundingInfoFromGeometry ? j._updateBoundingInfo() : j.refreshBoundingInfo(!0)
- }),
- i._babylonTransformNode
- })
- }
- ,
- a.prototype._loadMeshAsync = function(e, i, o, s) {
- var c = o.primitives;
- if (!c || !c.length)
- throw new Error(e + ": Primitives are missing");
- c[0].index == null && ArrayItem.Assign(c);
- var d = new Array;
- this.logOpen(e + " " + (o.name || ""));
- var _ = i.name || "node" + i.index;
- if (c.length === 1) {
- var b = o.primitives[0];
- d.push(this._loadMeshPrimitiveAsync(e + "/primitives/" + b.index, _, i, o, b, function(_e) {
- i._babylonTransformNode = _e,
- i._primitiveBabylonMeshes = [_e]
- }))
- } else {
- this._babylonScene._blockEntityCollection = !!this._assetContainer,
- i._babylonTransformNode = new TransformNode(_,this._babylonScene),
- i._babylonTransformNode._parentContainer = this._assetContainer,
- this._babylonScene._blockEntityCollection = !1,
- i._primitiveBabylonMeshes = [];
- for (var k = 0, j = c; k < j.length; k++) {
- var b = j[k];
- d.push(this._loadMeshPrimitiveAsync(e + "/primitives/" + b.index, _ + "_primitive" + b.index, i, o, b, function(et) {
- et.parent = i._babylonTransformNode,
- i._primitiveBabylonMeshes.push(et)
- }))
- }
- }
- if (i.skin != null) {
- var $ = ArrayItem.Get(e + "/skin", this._gltf.skins, i.skin);
- d.push(this._loadSkinAsync("/skins/" + $.index, i, $))
- }
- return s(i._babylonTransformNode),
- this.logClose(),
- Promise.all(d).then(function() {
- return i._babylonTransformNode
- })
- }
- ,
- a.prototype._loadMeshPrimitiveAsync = function(e, i, o, s, c, d) {
- var _ = this
- , b = this._extensionsLoadMeshPrimitiveAsync(e, i, o, s, c, d);
- if (b)
- return b;
- this.logOpen("" + e);
- var k = this._disableInstancedMesh === 0 && this._parent.createInstances && o.skin == null && !s.primitives[0].targets, j, $;
- if (k && c._instanceData)
- this._babylonScene._blockEntityCollection = !!this._assetContainer,
- j = c._instanceData.babylonSourceMesh.createInstance(i),
- j._parentContainer = this._assetContainer,
- this._babylonScene._blockEntityCollection = !1,
- $ = c._instanceData.promise;
- else {
- var _e = new Array;
- this._babylonScene._blockEntityCollection = !!this._assetContainer;
- var et = new Mesh(i,this._babylonScene);
- et._parentContainer = this._assetContainer,
- this._babylonScene._blockEntityCollection = !1,
- et.overrideMaterialSideOrientation = this._babylonScene.useRightHandedSystem ? Material.CounterClockWiseSideOrientation : Material.ClockWiseSideOrientation,
- this._createMorphTargets(e, o, s, c, et),
- _e.push(this._loadVertexDataAsync(e, c, et).then(function(nt) {
- return _._loadMorphTargetsAsync(e, c, et, nt).then(function() {
- _._babylonScene._blockEntityCollection = !!_._assetContainer,
- nt.applyToMesh(et),
- nt._parentContainer = _._assetContainer,
- _._babylonScene._blockEntityCollection = !1
- })
- }));
- var tt = a._GetDrawMode(e, c.mode);
- if (c.material == null) {
- var rt = this._defaultBabylonMaterialData[tt];
- rt || (rt = this._createDefaultMaterial("__GLTFLoader._default", tt),
- this._parent.onMaterialLoadedObservable.notifyObservers(rt),
- this._defaultBabylonMaterialData[tt] = rt),
- et.material = rt
- } else {
- var it = ArrayItem.Get(e + "/material", this._gltf.materials, c.material);
- _e.push(this._loadMaterialAsync("/materials/" + it.index, it, et, tt, function(nt) {
- et.material = nt
- }))
- }
- $ = Promise.all(_e),
- k && (c._instanceData = {
- babylonSourceMesh: et,
- promise: $
- }),
- j = et
- }
- return a.AddPointerMetadata(j, e),
- this._parent.onMeshLoadedObservable.notifyObservers(j),
- d(j),
- this.logClose(),
- $.then(function() {
- return j
- })
- }
- ,
- a.prototype._loadVertexDataAsync = function(e, i, o) {
- var s = this
- , c = this._extensionsLoadVertexDataAsync(e, i, o);
- if (c)
- return c;
- var d = i.attributes;
- if (!d)
- throw new Error(e + ": Attributes are missing");
- var _ = new Array
- , b = new Geometry(o.name,this._babylonScene);
- if (i.indices == null)
- o.isUnIndexed = !0;
- else {
- var k = ArrayItem.Get(e + "/indices", this._gltf.accessors, i.indices);
- _.push(this._loadIndicesAccessorAsync("/accessors/" + k.index, k).then(function($) {
- b.setIndices($)
- }))
- }
- var j = function($, _e, et) {
- if (d[$] != null) {
- o._delayInfo = o._delayInfo || [],
- o._delayInfo.indexOf(_e) === -1 && o._delayInfo.push(_e);
- var tt = ArrayItem.Get(e + "/attributes/" + $, s._gltf.accessors, d[$]);
- _.push(s._loadVertexAccessorAsync("/accessors/" + tt.index, tt, _e).then(function(rt) {
- if (rt.getKind() === VertexBuffer.PositionKind && !s.parent.alwaysComputeBoundingBox && !o.skeleton) {
- var it = tt.min
- , nt = tt.max;
- if (it !== void 0 && nt !== void 0) {
- if (tt.normalized && tt.componentType !== 5126) {
- var ot = 1;
- switch (tt.componentType) {
- case 5120:
- ot = 127;
- break;
- case 5121:
- ot = 255;
- break;
- case 5122:
- ot = 32767;
- break;
- case 5123:
- ot = 65535;
- break
- }
- for (var at = 0; at < 3; ++at)
- it[at] = Math.max(it[at] / ot, -1),
- nt[at] = Math.max(nt[at] / ot, -1)
- }
- var st = TmpVectors.Vector3[0]
- , ut = TmpVectors.Vector3[1];
- st.copyFromFloats.apply(st, it),
- ut.copyFromFloats.apply(ut, nt),
- b._boundingInfo = new BoundingInfo(st,ut),
- b.useBoundingInfoFromGeometry = !0
- }
- }
- b.setVerticesBuffer(rt, tt.count)
- })),
- _e == VertexBuffer.MatricesIndicesExtraKind && (o.numBoneInfluencers = 8),
- et && et(tt)
- }
- };
- return j("POSITION", VertexBuffer.PositionKind),
- j("NORMAL", VertexBuffer.NormalKind),
- j("TANGENT", VertexBuffer.TangentKind),
- j("TEXCOORD_0", VertexBuffer.UVKind),
- j("TEXCOORD_1", VertexBuffer.UV2Kind),
- j("TEXCOORD_2", VertexBuffer.UV3Kind),
- j("TEXCOORD_3", VertexBuffer.UV4Kind),
- j("TEXCOORD_4", VertexBuffer.UV5Kind),
- j("TEXCOORD_5", VertexBuffer.UV6Kind),
- j("JOINTS_0", VertexBuffer.MatricesIndicesKind),
- j("WEIGHTS_0", VertexBuffer.MatricesWeightsKind),
- j("JOINTS_1", VertexBuffer.MatricesIndicesExtraKind),
- j("WEIGHTS_1", VertexBuffer.MatricesWeightsExtraKind),
- j("COLOR_0", VertexBuffer.ColorKind, function($) {
- $.type === "VEC4" && (o.hasVertexAlpha = !0)
- }),
- Promise.all(_).then(function() {
- return b
- })
- }
- ,
- a.prototype._createMorphTargets = function(e, i, o, s, c) {
- if (!!s.targets) {
- if (i._numMorphTargets == null)
- i._numMorphTargets = s.targets.length;
- else if (s.targets.length !== i._numMorphTargets)
- throw new Error(e + ": Primitives do not have the same number of targets");
- var d = o.extras ? o.extras.targetNames : null;
- c.morphTargetManager = new MorphTargetManager(c.getScene()),
- c.morphTargetManager.areUpdatesFrozen = !0;
- for (var _ = 0; _ < s.targets.length; _++) {
- var b = i.weights ? i.weights[_] : o.weights ? o.weights[_] : 0
- , k = d ? d[_] : "morphTarget" + _;
- c.morphTargetManager.addTarget(new MorphTarget(k,b,c.getScene()))
- }
- }
- }
- ,
- a.prototype._loadMorphTargetsAsync = function(e, i, o, s) {
- if (!i.targets)
- return Promise.resolve();
- for (var c = new Array, d = o.morphTargetManager, _ = 0; _ < d.numTargets; _++) {
- var b = d.getTarget(_);
- c.push(this._loadMorphTargetVertexDataAsync(e + "/targets/" + _, s, i.targets[_], b))
- }
- return Promise.all(c).then(function() {
- d.areUpdatesFrozen = !1
- })
- }
- ,
- a.prototype._loadMorphTargetVertexDataAsync = function(e, i, o, s) {
- var c = this
- , d = new Array
- , _ = function(b, k, j) {
- if (o[b] != null) {
- var $ = i.getVertexBuffer(k);
- if (!!$) {
- var _e = ArrayItem.Get(e + "/" + b, c._gltf.accessors, o[b]);
- d.push(c._loadFloatAccessorAsync("/accessors/" + _e.index, _e).then(function(et) {
- j($, et)
- }))
- }
- }
- };
- return _("POSITION", VertexBuffer.PositionKind, function(b, k) {
- var j = new Float32Array(k.length);
- b.forEach(k.length, function($, _e) {
- j[_e] = k[_e] + $
- }),
- s.setPositions(j)
- }),
- _("NORMAL", VertexBuffer.NormalKind, function(b, k) {
- var j = new Float32Array(k.length);
- b.forEach(j.length, function($, _e) {
- j[_e] = k[_e] + $
- }),
- s.setNormals(j)
- }),
- _("TANGENT", VertexBuffer.TangentKind, function(b, k) {
- var j = new Float32Array(k.length / 3 * 4)
- , $ = 0;
- b.forEach(k.length / 3 * 4, function(_e, et) {
- (et + 1) % 4 !== 0 && (j[$] = k[$] + _e,
- $++)
- }),
- s.setTangents(j)
- }),
- Promise.all(d).then(function() {})
- }
- ,
- a._LoadTransform = function(e, i) {
- if (e.skin == null) {
- var o = Vector3.Zero()
- , s = Quaternion.Identity()
- , c = Vector3.One();
- if (e.matrix) {
- var d = Matrix.FromArray(e.matrix);
- d.decompose(c, s, o)
- } else
- e.translation && (o = Vector3.FromArray(e.translation)),
- e.rotation && (s = Quaternion.FromArray(e.rotation)),
- e.scale && (c = Vector3.FromArray(e.scale));
- i.position = o,
- i.rotationQuaternion = s,
- i.scaling = c
- }
- }
- ,
- a.prototype._loadSkinAsync = function(e, i, o) {
- var s = this
- , c = this._extensionsLoadSkinAsync(e, i, o);
- if (c)
- return c;
- var d = function(j) {
- s._forEachPrimitive(i, function($) {
- $.skeleton = j
- })
- };
- if (o._data)
- return d(o._data.babylonSkeleton),
- o._data.promise;
- var _ = "skeleton" + o.index;
- this._babylonScene._blockEntityCollection = !!this._assetContainer;
- var b = new Skeleton(o.name || _,_,this._babylonScene);
- b._parentContainer = this._assetContainer,
- this._babylonScene._blockEntityCollection = !1,
- b.overrideMesh = this._rootBabylonMesh,
- this._loadBones(e, o, b),
- d(b);
- var k = this._loadSkinInverseBindMatricesDataAsync(e, o).then(function(j) {
- s._updateBoneMatrices(b, j)
- });
- return o._data = {
- babylonSkeleton: b,
- promise: k
- },
- k
- }
- ,
- a.prototype._loadBones = function(e, i, o) {
- for (var s = {}, c = 0, d = i.joints; c < d.length; c++) {
- var _ = d[c]
- , b = ArrayItem.Get(e + "/joints/" + _, this._gltf.nodes, _);
- this._loadBone(b, i, o, s)
- }
- }
- ,
- a.prototype._loadBone = function(e, i, o, s) {
- var c = s[e.index];
- if (c)
- return c;
- var d = null;
- e.parent && e.parent._babylonTransformNode !== this._rootBabylonMesh && (d = this._loadBone(e.parent, i, o, s));
- var _ = i.joints.indexOf(e.index);
- return c = new Bone(e.name || "joint" + e.index,o,d,this._getNodeMatrix(e),null,null,_),
- s[e.index] = c,
- e._babylonBones = e._babylonBones || [],
- e._babylonBones.push(c),
- c
- }
- ,
- a.prototype._loadSkinInverseBindMatricesDataAsync = function(e, i) {
- if (i.inverseBindMatrices == null)
- return Promise.resolve(null);
- var o = ArrayItem.Get(e + "/inverseBindMatrices", this._gltf.accessors, i.inverseBindMatrices);
- return this._loadFloatAccessorAsync("/accessors/" + o.index, o)
- }
- ,
- a.prototype._updateBoneMatrices = function(e, i) {
- for (var o = 0, s = e.bones; o < s.length; o++) {
- var c = s[o]
- , d = Matrix.Identity()
- , _ = c._index;
- i && _ !== -1 && (Matrix.FromArrayToRef(i, _ * 16, d),
- d.invertToRef(d));
- var b = c.getParent();
- b && d.multiplyToRef(b.getInvertedAbsoluteTransform(), d),
- c.updateMatrix(d, !1, !1),
- c._updateDifferenceMatrix(void 0, !1)
- }
- }
- ,
- a.prototype._getNodeMatrix = function(e) {
- 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())
- }
- ,
- a.prototype.loadCameraAsync = function(e, i, o) {
- o === void 0 && (o = function() {}
- );
- var s = this._extensionsLoadCameraAsync(e, i, o);
- if (s)
- return s;
- var c = new Array;
- this.logOpen(e + " " + (i.name || "")),
- this._babylonScene._blockEntityCollection = !!this._assetContainer;
- var d = new FreeCamera(i.name || "camera" + i.index,Vector3.Zero(),this._babylonScene,!1);
- switch (d._parentContainer = this._assetContainer,
- this._babylonScene._blockEntityCollection = !1,
- d.ignoreParentScaling = !0,
- d.rotation = new Vector3(0,Math.PI,0),
- i.type) {
- case "perspective":
- {
- var _ = i.perspective;
- if (!_)
- throw new Error(e + ": Camera perspective properties are missing");
- d.fov = _.yfov,
- d.minZ = _.znear,
- d.maxZ = _.zfar || 0;
- break
- }
- case "orthographic":
- {
- if (!i.orthographic)
- throw new Error(e + ": Camera orthographic properties are missing");
- d.mode = Camera$1.ORTHOGRAPHIC_CAMERA,
- d.orthoLeft = -i.orthographic.xmag,
- d.orthoRight = i.orthographic.xmag,
- d.orthoBottom = -i.orthographic.ymag,
- d.orthoTop = i.orthographic.ymag,
- d.minZ = i.orthographic.znear,
- d.maxZ = i.orthographic.zfar;
- break
- }
- default:
- throw new Error(e + ": Invalid camera type (" + i.type + ")")
- }
- return a.AddPointerMetadata(d, e),
- this._parent.onCameraLoadedObservable.notifyObservers(d),
- o(d),
- this.logClose(),
- Promise.all(c).then(function() {
- return d
- })
- }
- ,
- a.prototype._loadAnimationsAsync = function() {
- var e = this._gltf.animations;
- if (!e)
- return Promise.resolve();
- for (var i = new Array, o = 0; o < e.length; o++) {
- var s = e[o];
- i.push(this.loadAnimationAsync("/animations/" + s.index, s).then(function(c) {
- c.targetedAnimations.length === 0 && c.dispose()
- }))
- }
- return Promise.all(i).then(function() {})
- }
- ,
- a.prototype.loadAnimationAsync = function(e, i) {
- var o = this._extensionsLoadAnimationAsync(e, i);
- if (o)
- return o;
- this._babylonScene._blockEntityCollection = !!this._assetContainer;
- var s = new AnimationGroup(i.name || "animation" + i.index,this._babylonScene);
- s._parentContainer = this._assetContainer,
- this._babylonScene._blockEntityCollection = !1,
- i._babylonAnimationGroup = s;
- var c = new Array;
- ArrayItem.Assign(i.channels),
- ArrayItem.Assign(i.samplers);
- for (var d = 0, _ = i.channels; d < _.length; d++) {
- var b = _[d];
- c.push(this._loadAnimationChannelAsync(e + "/channels/" + b.index, e, i, b, s))
- }
- return Promise.all(c).then(function() {
- return s.normalize(0),
- s
- })
- }
- ,
- a.prototype._loadAnimationChannelAsync = function(e, i, o, s, c, d) {
- var _ = this;
- if (d === void 0 && (d = null),
- s.target.node == null)
- return Promise.resolve();
- var b = ArrayItem.Get(e + "/target/node", this._gltf.nodes, s.target.node);
- if (s.target.path === "weights" && !b._numMorphTargets || s.target.path !== "weights" && !b._babylonTransformNode)
- return Promise.resolve();
- var k = ArrayItem.Get(e + "/sampler", o.samplers, s.sampler);
- return this._loadAnimationSamplerAsync(i + "/samplers/" + s.sampler, k).then(function(j) {
- var $, _e;
- switch (s.target.path) {
- case "translation":
- {
- $ = "position",
- _e = Animation.ANIMATIONTYPE_VECTOR3;
- break
- }
- case "rotation":
- {
- $ = "rotationQuaternion",
- _e = Animation.ANIMATIONTYPE_QUATERNION;
- break
- }
- case "scale":
- {
- $ = "scaling",
- _e = Animation.ANIMATIONTYPE_VECTOR3;
- break
- }
- case "weights":
- {
- $ = "influence",
- _e = Animation.ANIMATIONTYPE_FLOAT;
- break
- }
- default:
- throw new Error(e + "/target/path: Invalid value (" + s.target.path + ")")
- }
- var et = 0, tt;
- switch ($) {
- case "position":
- {
- tt = function() {
- var ct = Vector3.FromArray(j.output, et);
- return et += 3,
- ct
- }
- ;
- break
- }
- case "rotationQuaternion":
- {
- tt = function() {
- var ct = Quaternion.FromArray(j.output, et);
- return et += 4,
- ct
- }
- ;
- break
- }
- case "scaling":
- {
- tt = function() {
- var ct = Vector3.FromArray(j.output, et);
- return et += 3,
- ct
- }
- ;
- break
- }
- case "influence":
- {
- tt = function() {
- for (var ct = new Array(b._numMorphTargets), lt = 0; lt < b._numMorphTargets; lt++)
- ct[lt] = j.output[et++];
- return ct
- }
- ;
- break
- }
- }
- var rt;
- switch (j.interpolation) {
- case "STEP":
- {
- rt = function(ct) {
- return {
- frame: j.input[ct],
- value: tt(),
- interpolation: AnimationKeyInterpolation.STEP
- }
- }
- ;
- break
- }
- case "LINEAR":
- {
- rt = function(ct) {
- return {
- frame: j.input[ct],
- value: tt()
- }
- }
- ;
- break
- }
- case "CUBICSPLINE":
- {
- rt = function(ct) {
- return {
- frame: j.input[ct],
- inTangent: tt(),
- value: tt(),
- outTangent: tt()
- }
- }
- ;
- break
- }
- }
- for (var it = new Array(j.input.length), nt = 0; nt < j.input.length; nt++)
- it[nt] = rt(nt);
- if ($ === "influence")
- for (var ot = function(ct) {
- var lt = c.name + "_channel" + c.targetedAnimations.length
- , ft = new Animation(lt,$,1,_e);
- ft.setKeys(it.map(function(ht) {
- return {
- frame: ht.frame,
- inTangent: ht.inTangent ? ht.inTangent[ct] : void 0,
- value: ht.value[ct],
- outTangent: ht.outTangent ? ht.outTangent[ct] : void 0
- }
- })),
- _._forEachPrimitive(b, function(ht) {
- var pt = ht
- , dt = pt.morphTargetManager.getTarget(ct)
- , _t = ft.clone();
- dt.animations.push(_t),
- c.addTargetedAnimation(_t, dt)
- })
- }, at = 0; at < b._numMorphTargets; at++)
- ot(at);
- else {
- var st = c.name + "_channel" + c.targetedAnimations.length
- , ut = new Animation(st,$,1,_e);
- ut.setKeys(it),
- d != null && d.animations != null ? (d.animations.push(ut),
- c.addTargetedAnimation(ut, d)) : (b._babylonTransformNode.animations.push(ut),
- c.addTargetedAnimation(ut, b._babylonTransformNode))
- }
- })
- }
- ,
- a.prototype._loadAnimationSamplerAsync = function(e, i) {
- if (i._data)
- return i._data;
- var o = i.interpolation || "LINEAR";
- switch (o) {
- case "STEP":
- case "LINEAR":
- case "CUBICSPLINE":
- break;
- default:
- throw new Error(e + "/interpolation: Invalid value (" + i.interpolation + ")")
- }
- var s = ArrayItem.Get(e + "/input", this._gltf.accessors, i.input)
- , c = ArrayItem.Get(e + "/output", this._gltf.accessors, i.output);
- return i._data = Promise.all([this._loadFloatAccessorAsync("/accessors/" + s.index, s), this._loadFloatAccessorAsync("/accessors/" + c.index, c)]).then(function(d) {
- var _ = d[0]
- , b = d[1];
- return {
- input: _,
- interpolation: o,
- output: b
- }
- }),
- i._data
- }
- ,
- a.prototype.loadBufferAsync = function(e, i, o, s) {
- var c = this._extensionsLoadBufferAsync(e, i, o, s);
- if (c)
- return c;
- if (!i._data)
- if (i.uri)
- i._data = this.loadUriAsync(e + "/uri", i, i.uri);
- else {
- if (!this._bin)
- throw new Error(e + ": Uri is missing or the binary glTF is missing its binary chunk");
- i._data = this._bin.readAsync(0, i.byteLength)
- }
- return i._data.then(function(d) {
- try {
- return new Uint8Array(d.buffer,d.byteOffset + o,s)
- } catch (_) {
- throw new Error(e + ": " + _.message)
- }
- })
- }
- ,
- a.prototype.loadBufferViewAsync = function(e, i) {
- var o = this._extensionsLoadBufferViewAsync(e, i);
- if (o)
- return o;
- if (i._data)
- return i._data;
- var s = ArrayItem.Get(e + "/buffer", this._gltf.buffers, i.buffer);
- return i._data = this.loadBufferAsync("/buffers/" + s.index, s, i.byteOffset || 0, i.byteLength),
- i._data
- }
- ,
- a.prototype._loadAccessorAsync = function(e, i, o) {
- var s = this;
- if (i._data)
- return i._data;
- var c = a._GetNumComponents(e, i.type)
- , d = c * VertexBuffer.GetTypeByteLength(i.componentType)
- , _ = c * i.count;
- if (i.bufferView == null)
- i._data = Promise.resolve(new o(_));
- else {
- var b = ArrayItem.Get(e + "/bufferView", this._gltf.bufferViews, i.bufferView);
- i._data = this.loadBufferViewAsync("/bufferViews/" + b.index, b).then(function(j) {
- if (i.componentType === 5126 && !i.normalized && (!b.byteStride || b.byteStride === d))
- return a._GetTypedArray(e, i.componentType, j, i.byteOffset, _);
- var $ = new o(_);
- return VertexBuffer.ForEach(j, i.byteOffset || 0, b.byteStride || d, c, i.componentType, $.length, i.normalized || !1, function(_e, et) {
- $[et] = _e
- }),
- $
- })
- }
- if (i.sparse) {
- var k = i.sparse;
- i._data = i._data.then(function(j) {
- var $ = j
- , _e = ArrayItem.Get(e + "/sparse/indices/bufferView", s._gltf.bufferViews, k.indices.bufferView)
- , et = ArrayItem.Get(e + "/sparse/values/bufferView", s._gltf.bufferViews, k.values.bufferView);
- return Promise.all([s.loadBufferViewAsync("/bufferViews/" + _e.index, _e), s.loadBufferViewAsync("/bufferViews/" + et.index, et)]).then(function(tt) {
- 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;
- if (i.componentType === 5126 && !i.normalized)
- at = a._GetTypedArray(e + "/sparse/values", i.componentType, it, k.values.byteOffset, ot);
- else {
- var st = a._GetTypedArray(e + "/sparse/values", i.componentType, it, k.values.byteOffset, ot);
- at = new o(ot),
- VertexBuffer.ForEach(st, 0, d, c, i.componentType, at.length, i.normalized || !1, function(ht, pt) {
- at[pt] = ht
- })
- }
- for (var ut = 0, ct = 0; ct < nt.length; ct++)
- for (var lt = nt[ct] * c, ft = 0; ft < c; ft++)
- $[lt++] = at[ut++];
- return $
- })
- })
- }
- return i._data
- }
- ,
- a.prototype._loadFloatAccessorAsync = function(e, i) {
- return this._loadAccessorAsync(e, i, Float32Array)
- }
- ,
- a.prototype._loadIndicesAccessorAsync = function(e, i) {
- if (i.type !== "SCALAR")
- throw new Error(e + "/type: Invalid value " + i.type);
- if (i.componentType !== 5121 && i.componentType !== 5123 && i.componentType !== 5125)
- throw new Error(e + "/componentType: Invalid value " + i.componentType);
- if (i._data)
- return i._data;
- if (i.sparse) {
- var o = a._GetTypedArrayConstructor(e + "/componentType", i.componentType);
- i._data = this._loadAccessorAsync(e, i, o)
- } else {
- var s = ArrayItem.Get(e + "/bufferView", this._gltf.bufferViews, i.bufferView);
- i._data = this.loadBufferViewAsync("/bufferViews/" + s.index, s).then(function(c) {
- return a._GetTypedArray(e, i.componentType, c, i.byteOffset, i.count)
- })
- }
- return i._data
- }
- ,
- a.prototype._loadVertexBufferViewAsync = function(e, i) {
- var o = this;
- return e._babylonBuffer || (e._babylonBuffer = this.loadBufferViewAsync("/bufferViews/" + e.index, e).then(function(s) {
- return new Buffer(o._babylonScene.getEngine(),s,!1)
- })),
- e._babylonBuffer
- }
- ,
- a.prototype._loadVertexAccessorAsync = function(e, i, o) {
- var s = this, c;
- if (!((c = i._babylonVertexBuffer) === null || c === void 0) && c[o])
- return i._babylonVertexBuffer[o];
- if (i._babylonVertexBuffer || (i._babylonVertexBuffer = {}),
- i.sparse)
- i._babylonVertexBuffer[o] = this._loadFloatAccessorAsync(e, i).then(function(_) {
- return new VertexBuffer(s._babylonScene.getEngine(),_,o,!1)
- });
- else if (o === VertexBuffer.MatricesIndicesKind || o === VertexBuffer.MatricesIndicesExtraKind)
- i._babylonVertexBuffer[o] = this._loadFloatAccessorAsync(e, i).then(function(_) {
- return new VertexBuffer(s._babylonScene.getEngine(),_,o,!1)
- });
- else {
- var d = ArrayItem.Get(e + "/bufferView", this._gltf.bufferViews, i.bufferView);
- i._babylonVertexBuffer[o] = this._loadVertexBufferViewAsync(d, o).then(function(_) {
- var b = a._GetNumComponents(e, i.type);
- return new VertexBuffer(s._babylonScene.getEngine(),_,o,!1,!1,d.byteStride,!1,i.byteOffset,b,i.componentType,i.normalized,!0,1,!0)
- })
- }
- return i._babylonVertexBuffer[o]
- }
- ,
- a.prototype._loadMaterialMetallicRoughnessPropertiesAsync = function(e, i, o) {
- if (!(o instanceof PBRMaterial))
- throw new Error(e + ": Material type not supported");
- var s = new Array;
- return i && (i.baseColorFactor ? (o.albedoColor = Color3.FromArray(i.baseColorFactor),
- o.alpha = i.baseColorFactor[3]) : o.albedoColor = Color3.White(),
- o.metallic = i.metallicFactor == null ? 1 : i.metallicFactor,
- o.roughness = i.roughnessFactor == null ? 1 : i.roughnessFactor,
- i.baseColorTexture && s.push(this.loadTextureInfoAsync(e + "/baseColorTexture", i.baseColorTexture, function(c) {
- c.name = o.name + " (Base Color)",
- o.albedoTexture = c
- })),
- i.metallicRoughnessTexture && (i.metallicRoughnessTexture.nonColorData = !0,
- s.push(this.loadTextureInfoAsync(e + "/metallicRoughnessTexture", i.metallicRoughnessTexture, function(c) {
- c.name = o.name + " (Metallic Roughness)",
- o.metallicTexture = c
- })),
- o.useMetallnessFromMetallicTextureBlue = !0,
- o.useRoughnessFromMetallicTextureGreen = !0,
- o.useRoughnessFromMetallicTextureAlpha = !1)),
- Promise.all(s).then(function() {})
- }
- ,
- a.prototype._loadMaterialAsync = function(e, i, o, s, c) {
- c === void 0 && (c = function() {}
- );
- var d = this._extensionsLoadMaterialAsync(e, i, o, s, c);
- if (d)
- return d;
- i._data = i._data || {};
- var _ = i._data[s];
- if (!_) {
- this.logOpen(e + " " + (i.name || ""));
- var b = this.createMaterial(e, i, s);
- _ = {
- babylonMaterial: b,
- babylonMeshes: [],
- promise: this.loadMaterialPropertiesAsync(e, i, b)
- },
- i._data[s] = _,
- a.AddPointerMetadata(b, e),
- this._parent.onMaterialLoadedObservable.notifyObservers(b),
- this.logClose()
- }
- return o && (_.babylonMeshes.push(o),
- o.onDisposeObservable.addOnce(function() {
- var k = _.babylonMeshes.indexOf(o);
- k !== -1 && _.babylonMeshes.splice(k, 1)
- })),
- c(_.babylonMaterial),
- _.promise.then(function() {
- return _.babylonMaterial
- })
- }
- ,
- a.prototype._createDefaultMaterial = function(e, i) {
- this._babylonScene._blockEntityCollection = !!this._assetContainer;
- var o = new PBRMaterial(e,this._babylonScene);
- return o._parentContainer = this._assetContainer,
- this._babylonScene._blockEntityCollection = !1,
- o.fillMode = i,
- o.enableSpecularAntiAliasing = !0,
- o.useRadianceOverAlpha = !this._parent.transparencyAsCoverage,
- o.useSpecularOverAlpha = !this._parent.transparencyAsCoverage,
- o.transparencyMode = PBRMaterial.PBRMATERIAL_OPAQUE,
- o.metallic = 1,
- o.roughness = 1,
- o
- }
- ,
- a.prototype.createMaterial = function(e, i, o) {
- var s = this._extensionsCreateMaterial(e, i, o);
- if (s)
- return s;
- var c = i.name || "material" + i.index
- , d = this._createDefaultMaterial(c, o);
- return d
- }
- ,
- a.prototype.loadMaterialPropertiesAsync = function(e, i, o) {
- var s = this._extensionsLoadMaterialPropertiesAsync(e, i, o);
- if (s)
- return s;
- var c = new Array;
- return c.push(this.loadMaterialBasePropertiesAsync(e, i, o)),
- i.pbrMetallicRoughness && c.push(this._loadMaterialMetallicRoughnessPropertiesAsync(e + "/pbrMetallicRoughness", i.pbrMetallicRoughness, o)),
- this.loadMaterialAlphaProperties(e, i, o),
- Promise.all(c).then(function() {})
- }
- ,
- a.prototype.loadMaterialBasePropertiesAsync = function(e, i, o) {
- if (!(o instanceof PBRMaterial))
- throw new Error(e + ": Material type not supported");
- var s = new Array;
- return o.emissiveColor = i.emissiveFactor ? Color3.FromArray(i.emissiveFactor) : new Color3(0,0,0),
- i.doubleSided && (o.backFaceCulling = !1,
- o.twoSidedLighting = !0),
- i.normalTexture && (i.normalTexture.nonColorData = !0,
- s.push(this.loadTextureInfoAsync(e + "/normalTexture", i.normalTexture, function(c) {
- c.name = o.name + " (Normal)",
- o.bumpTexture = c
- })),
- o.invertNormalMapX = !this._babylonScene.useRightHandedSystem,
- o.invertNormalMapY = this._babylonScene.useRightHandedSystem,
- i.normalTexture.scale != null && (o.bumpTexture.level = i.normalTexture.scale),
- o.forceIrradianceInFragment = !0),
- i.occlusionTexture && (i.occlusionTexture.nonColorData = !0,
- s.push(this.loadTextureInfoAsync(e + "/occlusionTexture", i.occlusionTexture, function(c) {
- c.name = o.name + " (Occlusion)",
- o.ambientTexture = c
- })),
- o.useAmbientInGrayScale = !0,
- i.occlusionTexture.strength != null && (o.ambientTextureStrength = i.occlusionTexture.strength)),
- i.emissiveTexture && s.push(this.loadTextureInfoAsync(e + "/emissiveTexture", i.emissiveTexture, function(c) {
- c.name = o.name + " (Emissive)",
- o.emissiveTexture = c
- })),
- Promise.all(s).then(function() {})
- }
- ,
- a.prototype.loadMaterialAlphaProperties = function(e, i, o) {
- if (!(o instanceof PBRMaterial))
- throw new Error(e + ": Material type not supported");
- var s = i.alphaMode || "OPAQUE";
- switch (s) {
- case "OPAQUE":
- {
- o.transparencyMode = PBRMaterial.PBRMATERIAL_OPAQUE;
- break
- }
- case "MASK":
- {
- o.transparencyMode = PBRMaterial.PBRMATERIAL_ALPHATEST,
- o.alphaCutOff = i.alphaCutoff == null ? .5 : i.alphaCutoff,
- o.albedoTexture && (o.albedoTexture.hasAlpha = !0);
- break
- }
- case "BLEND":
- {
- o.transparencyMode = PBRMaterial.PBRMATERIAL_ALPHABLEND,
- o.albedoTexture && (o.albedoTexture.hasAlpha = !0,
- o.useAlphaFromAlbedoTexture = !0);
- break
- }
- default:
- throw new Error(e + "/alphaMode: Invalid value (" + i.alphaMode + ")")
- }
- }
- ,
- a.prototype.loadTextureInfoAsync = function(e, i, o) {
- var s = this;
- o === void 0 && (o = function() {}
- );
- var c = this._extensionsLoadTextureInfoAsync(e, i, o);
- if (c)
- return c;
- if (this.logOpen("" + e),
- i.texCoord >= 6)
- throw new Error(e + "/texCoord: Invalid value (" + i.texCoord + ")");
- var d = ArrayItem.Get(e + "/index", this._gltf.textures, i.index);
- d._textureInfo = i;
- var _ = this._loadTextureAsync("/textures/" + i.index, d, function(b) {
- b.coordinatesIndex = i.texCoord || 0,
- a.AddPointerMetadata(b, e),
- s._parent.onTextureLoadedObservable.notifyObservers(b),
- o(b)
- });
- return this.logClose(),
- _
- }
- ,
- a.prototype._loadTextureAsync = function(e, i, o) {
- o === void 0 && (o = function() {}
- );
- var s = this._extensionsLoadTextureAsync(e, i, o);
- if (s)
- return s;
- this.logOpen(e + " " + (i.name || ""));
- var c = i.sampler == null ? a.DefaultSampler : ArrayItem.Get(e + "/sampler", this._gltf.samplers, i.sampler)
- , d = ArrayItem.Get(e + "/source", this._gltf.images, i.source)
- , _ = this._createTextureAsync(e, c, d, o, void 0, !i._textureInfo.nonColorData);
- return this.logClose(),
- _
- }
- ,
- a.prototype._createTextureAsync = function(e, i, o, s, c, d) {
- var _ = this;
- s === void 0 && (s = function() {}
- );
- var b = this._loadSampler("/samplers/" + i.index, i)
- , k = new Array
- , j = new Deferred;
- this._babylonScene._blockEntityCollection = !!this._assetContainer;
- var $ = {
- noMipmap: b.noMipMaps,
- invertY: !1,
- samplingMode: b.samplingMode,
- onLoad: function() {
- _._disposed || j.resolve()
- },
- onError: function(et, tt) {
- _._disposed || j.reject(new Error(e + ": " + (tt && tt.message ? tt.message : et || "Failed to load texture")))
- },
- mimeType: o.mimeType,
- loaderOptions: c,
- useSRGBBuffer: !!d && this._parent.useSRGBBuffers
- }
- , _e = new Texture(null,this._babylonScene,$);
- return _e._parentContainer = this._assetContainer,
- this._babylonScene._blockEntityCollection = !1,
- k.push(j.promise),
- k.push(this.loadImageAsync("/images/" + o.index, o).then(function(et) {
- var tt = o.uri || _._fileName + "#image" + o.index
- , rt = "data:" + _._uniqueRootUrl + tt;
- _e.updateURL(rt, et)
- })),
- _e.wrapU = b.wrapU,
- _e.wrapV = b.wrapV,
- s(_e),
- Promise.all(k).then(function() {
- return _e
- })
- }
- ,
- a.prototype._loadSampler = function(e, i) {
- return i._data || (i._data = {
- noMipMaps: i.minFilter === 9728 || i.minFilter === 9729,
- samplingMode: a._GetTextureSamplingMode(e, i),
- wrapU: a._GetTextureWrapMode(e + "/wrapS", i.wrapS),
- wrapV: a._GetTextureWrapMode(e + "/wrapT", i.wrapT)
- }),
- i._data
- }
- ,
- a.prototype.loadImageAsync = function(e, i) {
- if (!i._data) {
- if (this.logOpen(e + " " + (i.name || "")),
- i.uri)
- i._data = this.loadUriAsync(e + "/uri", i, i.uri);
- else {
- var o = ArrayItem.Get(e + "/bufferView", this._gltf.bufferViews, i.bufferView);
- i._data = this.loadBufferViewAsync("/bufferViews/" + o.index, o)
- }
- this.logClose()
- }
- return i._data
- }
- ,
- a.prototype.loadUriAsync = function(e, i, o) {
- var s = this
- , c = this._extensionsLoadUriAsync(e, i, o);
- if (c)
- return c;
- if (!a._ValidateUri(o))
- throw new Error(e + ": '" + o + "' is invalid");
- if (IsBase64DataUrl(o)) {
- var d = new Uint8Array(DecodeBase64UrlToBinary(o));
- return this.log(e + ": Decoded " + o.substr(0, 64) + "... (" + d.length + " bytes)"),
- Promise.resolve(d)
- }
- return this.log(e + ": Loading " + o),
- this._parent.preprocessUrlAsync(this._rootUrl + o).then(function(_) {
- return new Promise(function(b, k) {
- s._parent._loadFile(s._babylonScene, _, function(j) {
- s._disposed || (s.log(e + ": Loaded " + o + " (" + j.byteLength + " bytes)"),
- b(new Uint8Array(j)))
- }, !0, function(j) {
- k(new LoadFileError(e + ": Failed to load '" + o + "'" + (j ? ": " + j.status + " " + j.statusText : ""),j))
- })
- }
- )
- })
- }
- ,
- a.AddPointerMetadata = function(e, i) {
- var o = e.metadata = e.metadata || {}
- , s = o.gltf = o.gltf || {}
- , c = s.pointers = s.pointers || [];
- c.push(i)
- }
- ,
- a._GetTextureWrapMode = function(e, i) {
- switch (i = i == null ? 10497 : i,
- i) {
- case 33071:
- return Texture.CLAMP_ADDRESSMODE;
- case 33648:
- return Texture.MIRROR_ADDRESSMODE;
- case 10497:
- return Texture.WRAP_ADDRESSMODE;
- default:
- return Logger$2.Warn(e + ": Invalid value (" + i + ")"),
- Texture.WRAP_ADDRESSMODE
- }
- }
- ,
- a._GetTextureSamplingMode = function(e, i) {
- var o = i.magFilter == null ? 9729 : i.magFilter
- , s = i.minFilter == null ? 9987 : i.minFilter;
- if (o === 9729)
- switch (s) {
- case 9728:
- return Texture.LINEAR_NEAREST;
- case 9729:
- return Texture.LINEAR_LINEAR;
- case 9984:
- return Texture.LINEAR_NEAREST_MIPNEAREST;
- case 9985:
- return Texture.LINEAR_LINEAR_MIPNEAREST;
- case 9986:
- return Texture.LINEAR_NEAREST_MIPLINEAR;
- case 9987:
- return Texture.LINEAR_LINEAR_MIPLINEAR;
- default:
- return Logger$2.Warn(e + "/minFilter: Invalid value (" + s + ")"),
- Texture.LINEAR_LINEAR_MIPLINEAR
- }
- else
- switch (o !== 9728 && Logger$2.Warn(e + "/magFilter: Invalid value (" + o + ")"),
- s) {
- case 9728:
- return Texture.NEAREST_NEAREST;
- case 9729:
- return Texture.NEAREST_LINEAR;
- case 9984:
- return Texture.NEAREST_NEAREST_MIPNEAREST;
- case 9985:
- return Texture.NEAREST_LINEAR_MIPNEAREST;
- case 9986:
- return Texture.NEAREST_NEAREST_MIPLINEAR;
- case 9987:
- return Texture.NEAREST_LINEAR_MIPLINEAR;
- default:
- return Logger$2.Warn(e + "/minFilter: Invalid value (" + s + ")"),
- Texture.NEAREST_NEAREST_MIPNEAREST
- }
- }
- ,
- a._GetTypedArrayConstructor = function(e, i) {
- switch (i) {
- case 5120:
- return Int8Array;
- case 5121:
- return Uint8Array;
- case 5122:
- return Int16Array;
- case 5123:
- return Uint16Array;
- case 5125:
- return Uint32Array;
- case 5126:
- return Float32Array;
- default:
- throw new Error(e + ": Invalid component type " + i)
- }
- }
- ,
- a._GetTypedArray = function(e, i, o, s, c) {
- var d = o.buffer;
- s = o.byteOffset + (s || 0);
- var _ = a._GetTypedArrayConstructor(e + "/componentType", i)
- , b = VertexBuffer.GetTypeByteLength(i);
- return s % b !== 0 ? (Logger$2.Warn(e + ": Copying buffer as byte offset (" + s + ") is not a multiple of component type byte length (" + b + ")"),
- new _(d.slice(s, s + c * b),0)) : new _(d,s,c)
- }
- ,
- a._GetNumComponents = function(e, i) {
- switch (i) {
- case "SCALAR":
- return 1;
- case "VEC2":
- return 2;
- case "VEC3":
- return 3;
- case "VEC4":
- return 4;
- case "MAT2":
- return 4;
- case "MAT3":
- return 9;
- case "MAT4":
- return 16
- }
- throw new Error(e + ": Invalid type (" + i + ")")
- }
- ,
- a._ValidateUri = function(e) {
- return Tools.IsBase64(e) || e.indexOf("..") === -1
- }
- ,
- a._GetDrawMode = function(e, i) {
- switch (i == null && (i = 4),
- i) {
- case 0:
- return Material.PointListDrawMode;
- case 1:
- return Material.LineListDrawMode;
- case 2:
- return Material.LineLoopDrawMode;
- case 3:
- return Material.LineStripDrawMode;
- case 4:
- return Material.TriangleFillMode;
- case 5:
- return Material.TriangleStripDrawMode;
- case 6:
- return Material.TriangleFanDrawMode
- }
- throw new Error(e + ": Invalid mesh primitive mode (" + i + ")")
- }
- ,
- a.prototype._compileMaterialsAsync = function() {
- var e = this;
- this._parent._startPerformanceCounter("Compile materials");
- var i = new Array;
- if (this._gltf.materials)
- for (var o = 0, s = this._gltf.materials; o < s.length; o++) {
- var c = s[o];
- if (c._data)
- for (var d in c._data)
- for (var _ = c._data[d], b = 0, k = _.babylonMeshes; b < k.length; b++) {
- var j = k[b];
- j.computeWorldMatrix(!0);
- var $ = _.babylonMaterial;
- i.push($.forceCompilationAsync(j)),
- i.push($.forceCompilationAsync(j, {
- useInstances: !0
- })),
- this._parent.useClipPlane && (i.push($.forceCompilationAsync(j, {
- clipPlane: !0
- })),
- i.push($.forceCompilationAsync(j, {
- clipPlane: !0,
- useInstances: !0
- })))
- }
- }
- return Promise.all(i).then(function() {
- e._parent._endPerformanceCounter("Compile materials")
- })
- }
- ,
- a.prototype._compileShadowGeneratorsAsync = function() {
- var e = this;
- this._parent._startPerformanceCounter("Compile shadow generators");
- for (var i = new Array, o = this._babylonScene.lights, s = 0, c = o; s < c.length; s++) {
- var d = c[s]
- , _ = d.getShadowGenerator();
- _ && i.push(_.forceCompilationAsync())
- }
- return Promise.all(i).then(function() {
- e._parent._endPerformanceCounter("Compile shadow generators")
- })
- }
- ,
- a.prototype._forEachExtensions = function(e) {
- for (var i = 0, o = this._extensions; i < o.length; i++) {
- var s = o[i];
- s.enabled && e(s)
- }
- }
- ,
- a.prototype._applyExtensions = function(e, i, o) {
- for (var s = 0, c = this._extensions; s < c.length; s++) {
- var d = c[s];
- if (d.enabled) {
- var _ = d.name + "." + i
- , b = e;
- b._activeLoaderExtensionFunctions = b._activeLoaderExtensionFunctions || {};
- var k = b._activeLoaderExtensionFunctions;
- if (!k[_]) {
- k[_] = !0;
- try {
- var j = o(d);
- if (j)
- return j
- } finally {
- delete k[_]
- }
- }
- }
- }
- return null
- }
- ,
- a.prototype._extensionsOnLoading = function() {
- this._forEachExtensions(function(e) {
- return e.onLoading && e.onLoading()
- })
- }
- ,
- a.prototype._extensionsOnReady = function() {
- this._forEachExtensions(function(e) {
- return e.onReady && e.onReady()
- })
- }
- ,
- a.prototype._extensionsLoadSceneAsync = function(e, i) {
- return this._applyExtensions(i, "loadScene", function(o) {
- return o.loadSceneAsync && o.loadSceneAsync(e, i)
- })
- }
- ,
- a.prototype._extensionsLoadNodeAsync = function(e, i, o) {
- return this._applyExtensions(i, "loadNode", function(s) {
- return s.loadNodeAsync && s.loadNodeAsync(e, i, o)
- })
- }
- ,
- a.prototype._extensionsLoadCameraAsync = function(e, i, o) {
- return this._applyExtensions(i, "loadCamera", function(s) {
- return s.loadCameraAsync && s.loadCameraAsync(e, i, o)
- })
- }
- ,
- a.prototype._extensionsLoadVertexDataAsync = function(e, i, o) {
- return this._applyExtensions(i, "loadVertexData", function(s) {
- return s._loadVertexDataAsync && s._loadVertexDataAsync(e, i, o)
- })
- }
- ,
- a.prototype._extensionsLoadMeshPrimitiveAsync = function(e, i, o, s, c, d) {
- return this._applyExtensions(c, "loadMeshPrimitive", function(_) {
- return _._loadMeshPrimitiveAsync && _._loadMeshPrimitiveAsync(e, i, o, s, c, d)
- })
- }
- ,
- a.prototype._extensionsLoadMaterialAsync = function(e, i, o, s, c) {
- return this._applyExtensions(i, "loadMaterial", function(d) {
- return d._loadMaterialAsync && d._loadMaterialAsync(e, i, o, s, c)
- })
- }
- ,
- a.prototype._extensionsCreateMaterial = function(e, i, o) {
- return this._applyExtensions(i, "createMaterial", function(s) {
- return s.createMaterial && s.createMaterial(e, i, o)
- })
- }
- ,
- a.prototype._extensionsLoadMaterialPropertiesAsync = function(e, i, o) {
- return this._applyExtensions(i, "loadMaterialProperties", function(s) {
- return s.loadMaterialPropertiesAsync && s.loadMaterialPropertiesAsync(e, i, o)
- })
- }
- ,
- a.prototype._extensionsLoadTextureInfoAsync = function(e, i, o) {
- return this._applyExtensions(i, "loadTextureInfo", function(s) {
- return s.loadTextureInfoAsync && s.loadTextureInfoAsync(e, i, o)
- })
- }
- ,
- a.prototype._extensionsLoadTextureAsync = function(e, i, o) {
- return this._applyExtensions(i, "loadTexture", function(s) {
- return s._loadTextureAsync && s._loadTextureAsync(e, i, o)
- })
- }
- ,
- a.prototype._extensionsLoadAnimationAsync = function(e, i) {
- return this._applyExtensions(i, "loadAnimation", function(o) {
- return o.loadAnimationAsync && o.loadAnimationAsync(e, i)
- })
- }
- ,
- a.prototype._extensionsLoadSkinAsync = function(e, i, o) {
- return this._applyExtensions(o, "loadSkin", function(s) {
- return s._loadSkinAsync && s._loadSkinAsync(e, i, o)
- })
- }
- ,
- a.prototype._extensionsLoadUriAsync = function(e, i, o) {
- return this._applyExtensions(i, "loadUri", function(s) {
- return s._loadUriAsync && s._loadUriAsync(e, i, o)
- })
- }
- ,
- a.prototype._extensionsLoadBufferViewAsync = function(e, i) {
- return this._applyExtensions(i, "loadBufferView", function(o) {
- return o.loadBufferViewAsync && o.loadBufferViewAsync(e, i)
- })
- }
- ,
- a.prototype._extensionsLoadBufferAsync = function(e, i, o, s) {
- return this._applyExtensions(i, "loadBuffer", function(c) {
- return c.loadBufferAsync && c.loadBufferAsync(e, i, o, s)
- })
- }
- ,
- a.LoadExtensionAsync = function(e, i, o, s) {
- if (!i.extensions)
- return null;
- var c = i.extensions
- , d = c[o];
- return d ? s(e + "/extensions/" + o, d) : null
- }
- ,
- a.LoadExtraAsync = function(e, i, o, s) {
- if (!i.extras)
- return null;
- var c = i.extras
- , d = c[o];
- return d ? s(e + "/extras/" + o, d) : null
- }
- ,
- a.prototype.isExtensionUsed = function(e) {
- return !!this._gltf.extensionsUsed && this._gltf.extensionsUsed.indexOf(e) !== -1
- }
- ,
- a.prototype.logOpen = function(e) {
- this._parent._logOpen(e)
- }
- ,
- a.prototype.logClose = function() {
- this._parent._logClose()
- }
- ,
- a.prototype.log = function(e) {
- this._parent._log(e)
- }
- ,
- a.prototype.startPerformanceCounter = function(e) {
- this._parent._startPerformanceCounter(e)
- }
- ,
- a.prototype.endPerformanceCounter = function(e) {
- this._parent._endPerformanceCounter(e)
- }
- ,
- a._RegisteredExtensions = {},
- a.DefaultSampler = {
- index: -1
- },
- a
- }();
- GLTFFileLoader._CreateGLTF2Loader = function(a) {
- return new GLTFLoader(a)
- }
- ;
- var RawCubeTexture = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _, b, k, j) {
- c === void 0 && (c = 5),
- d === void 0 && (d = 0),
- _ === void 0 && (_ = !1),
- b === void 0 && (b = !1),
- k === void 0 && (k = 3),
- j === void 0 && (j = null);
- var $ = a.call(this, "", i) || this;
- return $._texture = i.getEngine().createRawCubeTexture(o, s, c, d, _, b, k, j),
- $
- }
- return e.prototype.update = function(i, o, s, c, d) {
- d === void 0 && (d = null),
- this._texture.getEngine().updateRawCubeTexture(this._texture, i, o, s, c, d)
- }
- ,
- e.prototype.updateRGBDAsync = function(i, o, s, c) {
- return o === void 0 && (o = null),
- s === void 0 && (s = .8),
- c === void 0 && (c = 0),
- _UpdateRGBDAsync(this._texture, i, o, s, c).then(function() {})
- }
- ,
- e.prototype.clone = function() {
- var i = this;
- return SerializationHelper.Clone(function() {
- var o = i.getScene()
- , s = i._texture
- , c = new e(o,s._bufferViewArray,s.width,s.format,s.type,s.generateMipMaps,s.invertY,s.samplingMode,s._compression);
- return s.source === InternalTextureSource.CubeRawRGBD && c.updateRGBDAsync(s._bufferViewArrayArray, s._sphericalPolynomial, s._lodGenerationScale, s._lodGenerationOffset),
- c
- }, this)
- }
- ,
- e
- }(CubeTexture)
- , NAME$u = "EXT_lights_image_based"
- , EXT_lights_image_based = function() {
- function a(e) {
- this.name = NAME$u,
- this._loader = e,
- this.enabled = this._loader.isExtensionUsed(NAME$u)
- }
- return a.prototype.dispose = function() {
- this._loader = null,
- delete this._lights
- }
- ,
- a.prototype.onLoading = function() {
- var e = this._loader.gltf.extensions;
- if (e && e[this.name]) {
- var i = e[this.name];
- this._lights = i.lights
- }
- }
- ,
- a.prototype.loadSceneAsync = function(e, i) {
- var o = this;
- return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(s, c) {
- var d = new Array;
- d.push(o._loader.loadSceneAsync(e, i)),
- o._loader.logOpen("" + s);
- var _ = ArrayItem.Get(s + "/light", o._lights, c.light);
- return d.push(o._loadLightAsync("/extensions/" + o.name + "/lights/" + c.light, _).then(function(b) {
- o._loader.babylonScene.environmentTexture = b
- })),
- o._loader.logClose(),
- Promise.all(d).then(function() {})
- })
- }
- ,
- a.prototype._loadLightAsync = function(e, i) {
- var o = this;
- if (!i._loaded) {
- var s = new Array;
- this._loader.logOpen("" + e);
- for (var c = new Array(i.specularImages.length), d = function(k) {
- var j = i.specularImages[k];
- c[k] = new Array(j.length);
- for (var $ = function(et) {
- var tt = e + "/specularImages/" + k + "/" + et;
- _._loader.logOpen("" + tt);
- var rt = j[et]
- , it = ArrayItem.Get(tt, _._loader.gltf.images, rt);
- s.push(_._loader.loadImageAsync("/images/" + rt, it).then(function(nt) {
- c[k][et] = nt
- })),
- _._loader.logClose()
- }, _e = 0; _e < j.length; _e++)
- $(_e)
- }, _ = this, b = 0; b < i.specularImages.length; b++)
- d(b);
- this._loader.logClose(),
- i._loaded = Promise.all(s).then(function() {
- var k = new RawCubeTexture(o._loader.babylonScene,null,i.specularImageSize);
- if (k.name = i.name || "environment",
- i._babylonTexture = k,
- i.intensity != null && (k.level = i.intensity),
- i.rotation) {
- var j = Quaternion.FromArray(i.rotation);
- o._loader.babylonScene.useRightHandedSystem || (j = Quaternion.Inverse(j)),
- Matrix.FromQuaternionToRef(j, k.getReflectionTextureMatrix())
- }
- if (!i.irradianceCoefficients)
- throw new Error(e + ": Irradiance coefficients are missing");
- var $ = SphericalHarmonics.FromArray(i.irradianceCoefficients);
- $.scaleInPlace(i.intensity),
- $.convertIrradianceToLambertianRadiance();
- var _e = SphericalPolynomial.FromHarmonics($)
- , et = (c.length - 1) / Scalar.Log2(i.specularImageSize);
- return k.updateRGBDAsync(c, _e, et)
- })
- }
- return i._loaded.then(function() {
- return i._babylonTexture
- })
- }
- ,
- a
- }();
- GLTFLoader.RegisterExtension(NAME$u, function(a) {
- return new EXT_lights_image_based(a)
- });
- var NAME$t = "EXT_mesh_gpu_instancing"
- , EXT_mesh_gpu_instancing = function() {
- function a(e) {
- this.name = NAME$t,
- this._loader = e,
- this.enabled = this._loader.isExtensionUsed(NAME$t)
- }
- return a.prototype.dispose = function() {
- this._loader = null
- }
- ,
- a.prototype.loadNodeAsync = function(e, i, o) {
- var s = this;
- return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(c, d) {
- s._loader._disableInstancedMesh++;
- var _ = s._loader.loadNodeAsync("/nodes/" + i.index, i, o);
- if (s._loader._disableInstancedMesh--,
- !i._primitiveBabylonMeshes)
- return _;
- var b = new Array
- , k = 0
- , j = function($) {
- if (d.attributes[$] == null) {
- b.push(Promise.resolve(null));
- return
- }
- var _e = ArrayItem.Get(c + "/attributes/" + $, s._loader.gltf.accessors, d.attributes[$]);
- if (b.push(s._loader._loadFloatAccessorAsync("/accessors/" + _e.bufferView, _e)),
- k === 0)
- k = _e.count;
- else if (k !== _e.count)
- throw new Error(c + "/attributes: Instance buffer accessors do not have the same count.")
- };
- return j("TRANSLATION"),
- j("ROTATION"),
- j("SCALE"),
- _.then(function($) {
- return Promise.all(b).then(function(_e) {
- var et = _e[0]
- , tt = _e[1]
- , rt = _e[2]
- , it = new Float32Array(k * 16);
- TmpVectors.Vector3[0].copyFromFloats(0, 0, 0),
- TmpVectors.Quaternion[0].copyFromFloats(0, 0, 0, 1),
- TmpVectors.Vector3[1].copyFromFloats(1, 1, 1);
- for (var nt = 0; nt < k; ++nt)
- et && Vector3.FromArrayToRef(et, nt * 3, TmpVectors.Vector3[0]),
- tt && Quaternion.FromArrayToRef(tt, nt * 4, TmpVectors.Quaternion[0]),
- rt && Vector3.FromArrayToRef(rt, nt * 3, TmpVectors.Vector3[1]),
- Matrix.ComposeToRef(TmpVectors.Vector3[1], TmpVectors.Quaternion[0], TmpVectors.Vector3[0], TmpVectors.Matrix[0]),
- TmpVectors.Matrix[0].copyToArray(it, nt * 16);
- for (var ot = 0, at = i._primitiveBabylonMeshes; ot < at.length; ot++) {
- var st = at[ot];
- st.thinInstanceSetBuffer("matrix", it, 16, !0)
- }
- return $
- })
- })
- })
- }
- ,
- a
- }();
- GLTFLoader.RegisterExtension(NAME$t, function(a) {
- return new EXT_mesh_gpu_instancing(a)
- });
- var MeshoptCompression = function() {
- function a() {
- var e = a.Configuration.decoder;
- this._decoderModulePromise = Tools.LoadScriptAsync(Tools.GetAbsoluteUrl(e.url)).then(function() {
- return MeshoptDecoder.ready
- })
- }
- return Object.defineProperty(a, "Default", {
- get: function() {
- return a._Default || (a._Default = new a),
- a._Default
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.dispose = function() {
- delete this._decoderModulePromise
- }
- ,
- a.prototype.decodeGltfBufferAsync = function(e, i, o, s, c) {
- return this._decoderModulePromise.then(function() {
- var d = new Uint8Array(i * o);
- return MeshoptDecoder.decodeGltfBuffer(d, i, o, e, s, c),
- d
- })
- }
- ,
- a.Configuration = {
- decoder: {
- url: "https://preview.babylonjs.com/meshopt_decoder.js"
- }
- },
- a._Default = null,
- a
- }()
- , NAME$s = "EXT_meshopt_compression"
- , EXT_meshopt_compression = function() {
- function a(e) {
- this.name = NAME$s,
- this.enabled = e.isExtensionUsed(NAME$s),
- this._loader = e
- }
- return a.prototype.dispose = function() {
- this._loader = null
- }
- ,
- a.prototype.loadBufferViewAsync = function(e, i) {
- var o = this;
- return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(s, c) {
- var d = i;
- if (d._meshOptData)
- return d._meshOptData;
- var _ = ArrayItem.Get(e + "/buffer", o._loader.gltf.buffers, c.buffer);
- return d._meshOptData = o._loader.loadBufferAsync("/buffers/" + _.index, _, c.byteOffset || 0, c.byteLength).then(function(b) {
- return MeshoptCompression.Default.decodeGltfBufferAsync(b, c.count, c.byteStride, c.mode, c.filter)
- }),
- d._meshOptData
- })
- }
- ,
- a
- }();
- GLTFLoader.RegisterExtension(NAME$s, function(a) {
- return new EXT_meshopt_compression(a)
- });
- var NAME$r = "EXT_texture_webp"
- , EXT_texture_webp = function() {
- function a(e) {
- this.name = NAME$r,
- this._loader = e,
- this.enabled = e.isExtensionUsed(NAME$r)
- }
- return a.prototype.dispose = function() {
- this._loader = null
- }
- ,
- a.prototype._loadTextureAsync = function(e, i, o) {
- var s = this;
- return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(c, d) {
- var _ = i.sampler == null ? GLTFLoader.DefaultSampler : ArrayItem.Get(e + "/sampler", s._loader.gltf.samplers, i.sampler)
- , b = ArrayItem.Get(c + "/source", s._loader.gltf.images, d.source);
- return s._loader._createTextureAsync(e, _, b, function(k) {
- o(k)
- }, void 0, !i._textureInfo.nonColorData)
- })
- }
- ,
- a
- }();
- GLTFLoader.RegisterExtension(NAME$r, function(a) {
- return new EXT_texture_webp(a)
- });
- var WorkerPool = function() {
- function a(e) {
- this._pendingActions = new Array,
- this._workerInfos = e.map(function(i) {
- return {
- worker: i,
- active: !1
- }
- })
- }
- return a.prototype.dispose = function() {
- for (var e = 0, i = this._workerInfos; e < i.length; e++) {
- var o = i[e];
- o.worker.terminate()
- }
- this._workerInfos = [],
- this._pendingActions = []
- }
- ,
- a.prototype.push = function(e) {
- for (var i = 0, o = this._workerInfos; i < o.length; i++) {
- var s = o[i];
- if (!s.active) {
- this._execute(s, e);
- return
- }
- }
- this._pendingActions.push(e)
- }
- ,
- a.prototype._execute = function(e, i) {
- var o = this;
- e.active = !0,
- i(e.worker, function() {
- e.active = !1;
- var s = o._pendingActions.shift();
- s && o._execute(e, s)
- })
- }
- ,
- a
- }();
- function createDecoderAsync(a) {
- return new Promise(function(e) {
- DracoDecoderModule({
- wasmBinary: a
- }).then(function(i) {
- e({
- module: i
- })
- })
- }
- )
- }
- function decodeMesh(a, e, i, o, s) {
- var c = new a.DecoderBuffer;
- c.Init(e, e.byteLength);
- var d = new a.Decoder, _, b;
- try {
- var k = d.GetEncodedGeometryType(c);
- switch (k) {
- case a.TRIANGULAR_MESH:
- _ = new a.Mesh,
- b = d.DecodeBufferToMesh(c, _);
- break;
- case a.POINT_CLOUD:
- _ = new a.PointCloud,
- b = d.DecodeBufferToPointCloud(c, _);
- break;
- default:
- throw new Error("Invalid geometry type " + k)
- }
- if (!b.ok() || !_.ptr)
- throw new Error(b.error_msg());
- if (k === a.TRIANGULAR_MESH) {
- var j = _.num_faces()
- , $ = j * 3
- , _e = $ * 4
- , et = a._malloc(_e);
- try {
- d.GetTrianglesUInt32Array(_, _e, et);
- var tt = new Uint32Array($);
- tt.set(new Uint32Array(a.HEAPF32.buffer,et,$)),
- o(tt)
- } finally {
- a._free(et)
- }
- }
- var rt = function(st, ut) {
- var ct = ut.num_components()
- , lt = _.num_points()
- , ft = lt * ct
- , ht = ft * Float32Array.BYTES_PER_ELEMENT
- , pt = a._malloc(ht);
- try {
- d.GetAttributeDataArrayForAllPoints(_, ut, a.DT_FLOAT32, ht, pt);
- var dt = new Float32Array(a.HEAPF32.buffer,pt,ft);
- if (st === "color" && ct === 3) {
- for (var _t = new Float32Array(lt * 4), mt = 0, vt = 0; mt < _t.length; mt += 4,
- vt += ct)
- _t[mt + 0] = dt[vt + 0],
- _t[mt + 1] = dt[vt + 1],
- _t[mt + 2] = dt[vt + 2],
- _t[mt + 3] = 1;
- s(st, _t)
- } else {
- var _t = new Float32Array(ft);
- _t.set(new Float32Array(a.HEAPF32.buffer,pt,ft)),
- s(st, _t)
- }
- } finally {
- a._free(pt)
- }
- };
- if (i)
- for (var it in i) {
- var nt = i[it]
- , ot = d.GetAttributeByUniqueId(_, nt);
- rt(it, ot)
- }
- else {
- var at = {
- position: "POSITION",
- normal: "NORMAL",
- color: "COLOR",
- uv: "TEX_COORD"
- };
- for (var it in at) {
- var nt = d.GetAttributeId(_, a[at[it]]);
- if (nt !== -1) {
- var ot = d.GetAttribute(_, nt);
- rt(it, ot)
- }
- }
- }
- } finally {
- _ && a.destroy(_),
- a.destroy(d),
- a.destroy(c)
- }
- }
- function worker$1() {
- var a;
- onmessage = function(e) {
- var i = e.data;
- switch (i.id) {
- case "init":
- {
- var o = i.decoder;
- o.url && (importScripts(o.url),
- a = DracoDecoderModule({
- wasmBinary: o.wasmBinary
- })),
- postMessage("done");
- break
- }
- case "decodeMesh":
- {
- if (!a)
- throw new Error("Draco decoder module is not available");
- a.then(function(s) {
- decodeMesh(s, i.dataView, i.attributes, function(c) {
- postMessage({
- id: "indices",
- value: c
- }, [c.buffer])
- }, function(c, d) {
- postMessage({
- id: c,
- value: d
- }, [d.buffer])
- }),
- postMessage("done")
- });
- break
- }
- }
- }
- }
- var DracoCompression = function() {
- function a(e) {
- e === void 0 && (e = a.DefaultNumWorkers);
- var i = a.Configuration.decoder
- , o = i.wasmUrl && i.wasmBinaryUrl && typeof WebAssembly == "object" ? {
- url: Tools.GetAbsoluteUrl(i.wasmUrl),
- wasmBinaryPromise: Tools.LoadFileAsync(Tools.GetAbsoluteUrl(i.wasmBinaryUrl))
- } : {
- url: Tools.GetAbsoluteUrl(i.fallbackUrl),
- wasmBinaryPromise: Promise.resolve(void 0)
- };
- e && typeof Worker == "function" ? this._workerPoolPromise = o.wasmBinaryPromise.then(function(s) {
- for (var c = decodeMesh + "(" + worker$1 + ")()", d = URL.createObjectURL(new Blob([c],{
- type: "application/javascript"
- })), _ = new Array(e), b = 0; b < _.length; b++)
- _[b] = new Promise(function(k, j) {
- var $ = new Worker(d)
- , _e = function(tt) {
- $.removeEventListener("error", _e),
- $.removeEventListener("message", et),
- j(tt)
- }
- , et = function(tt) {
- tt.data === "done" && ($.removeEventListener("error", _e),
- $.removeEventListener("message", et),
- k($))
- };
- $.addEventListener("error", _e),
- $.addEventListener("message", et),
- $.postMessage({
- id: "init",
- decoder: {
- url: o.url,
- wasmBinary: s
- }
- })
- }
- );
- return Promise.all(_).then(function(k) {
- return new WorkerPool(k)
- })
- }) : this._decoderModulePromise = o.wasmBinaryPromise.then(function(s) {
- if (!o.url)
- throw new Error("Draco decoder module is not available");
- return Tools.LoadScriptAsync(o.url).then(function() {
- return createDecoderAsync(s)
- })
- })
- }
- return Object.defineProperty(a, "DecoderAvailable", {
- get: function() {
- var e = a.Configuration.decoder;
- return !!(e.wasmUrl && e.wasmBinaryUrl && typeof WebAssembly == "object" || e.fallbackUrl)
- },
- enumerable: !1,
- configurable: !0
- }),
- a.GetDefaultNumWorkers = function() {
- return typeof navigator != "object" || !navigator.hardwareConcurrency ? 1 : Math.min(Math.floor(navigator.hardwareConcurrency * .5), 4)
- }
- ,
- Object.defineProperty(a, "Default", {
- get: function() {
- return a._Default || (a._Default = new a),
- a._Default
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.dispose = function() {
- this._workerPoolPromise && this._workerPoolPromise.then(function(e) {
- e.dispose()
- }),
- delete this._workerPoolPromise,
- delete this._decoderModulePromise
- }
- ,
- a.prototype.whenReadyAsync = function() {
- return this._workerPoolPromise ? this._workerPoolPromise.then(function() {}) : this._decoderModulePromise ? this._decoderModulePromise.then(function() {}) : Promise.resolve()
- }
- ,
- a.prototype.decodeMeshAsync = function(e, i) {
- var o = e instanceof ArrayBuffer ? new Uint8Array(e) : e;
- if (this._workerPoolPromise)
- return this._workerPoolPromise.then(function(s) {
- return new Promise(function(c, d) {
- s.push(function(_, b) {
- var k = new VertexData
- , j = function(et) {
- _.removeEventListener("error", j),
- _.removeEventListener("message", $),
- d(et),
- b()
- }
- , $ = function(et) {
- et.data === "done" ? (_.removeEventListener("error", j),
- _.removeEventListener("message", $),
- c(k),
- b()) : et.data.id === "indices" ? k.indices = et.data.value : k.set(et.data.value, et.data.id)
- };
- _.addEventListener("error", j),
- _.addEventListener("message", $);
- var _e = new Uint8Array(o.byteLength);
- _e.set(new Uint8Array(o.buffer,o.byteOffset,o.byteLength)),
- _.postMessage({
- id: "decodeMesh",
- dataView: _e,
- attributes: i
- }, [_e.buffer])
- })
- }
- )
- });
- if (this._decoderModulePromise)
- return this._decoderModulePromise.then(function(s) {
- var c = new VertexData;
- return decodeMesh(s.module, o, i, function(d) {
- c.indices = d
- }, function(d, _) {
- c.set(_, d)
- }),
- c
- });
- throw new Error("Draco decoder module is not available")
- }
- ,
- a.Configuration = {
- decoder: {
- wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js",
- wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm",
- fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
- }
- },
- a.DefaultNumWorkers = a.GetDefaultNumWorkers(),
- a._Default = null,
- a
- }()
- , NAME$q = "KHR_draco_mesh_compression"
- , KHR_draco_mesh_compression = function() {
- function a(e) {
- this.name = NAME$q,
- this._loader = e,
- this.enabled = DracoCompression.DecoderAvailable && this._loader.isExtensionUsed(NAME$q)
- }
- return a.prototype.dispose = function() {
- delete this.dracoCompression,
- this._loader = null
- }
- ,
- a.prototype._loadVertexDataAsync = function(e, i, o) {
- var s = this;
- return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(c, d) {
- if (i.mode != null) {
- if (i.mode !== 5 && i.mode !== 4)
- throw new Error(e + ": Unsupported mode " + i.mode);
- if (i.mode === 5)
- throw new Error(e + ": Mode " + i.mode + " is not currently supported")
- }
- var _ = {}
- , b = function(j, $) {
- var _e = d.attributes[j];
- _e != null && (o._delayInfo = o._delayInfo || [],
- o._delayInfo.indexOf($) === -1 && o._delayInfo.push($),
- _[$] = _e)
- };
- b("POSITION", VertexBuffer.PositionKind),
- b("NORMAL", VertexBuffer.NormalKind),
- b("TANGENT", VertexBuffer.TangentKind),
- b("TEXCOORD_0", VertexBuffer.UVKind),
- b("TEXCOORD_1", VertexBuffer.UV2Kind),
- b("TEXCOORD_2", VertexBuffer.UV3Kind),
- b("TEXCOORD_3", VertexBuffer.UV4Kind),
- b("TEXCOORD_4", VertexBuffer.UV5Kind),
- b("TEXCOORD_5", VertexBuffer.UV6Kind),
- b("JOINTS_0", VertexBuffer.MatricesIndicesKind),
- b("WEIGHTS_0", VertexBuffer.MatricesWeightsKind),
- b("COLOR_0", VertexBuffer.ColorKind);
- var k = ArrayItem.Get(c, s._loader.gltf.bufferViews, d.bufferView);
- return k._dracoBabylonGeometry || (k._dracoBabylonGeometry = s._loader.loadBufferViewAsync("/bufferViews/" + k.index, k).then(function(j) {
- var $ = s.dracoCompression || DracoCompression.Default;
- return $.decodeMeshAsync(j, _).then(function(_e) {
- var et = new Geometry(o.name,s._loader.babylonScene);
- return _e.applyToGeometry(et),
- et
- }).catch(function(_e) {
- throw new Error(e + ": " + _e.message)
- })
- })),
- k._dracoBabylonGeometry
- })
- }
- ,
- a
- }();
- GLTFLoader.RegisterExtension(NAME$q, function(a) {
- return new KHR_draco_mesh_compression(a)
- });
- var NAME$p = "KHR_lights_punctual"
- , KHR_lights = function() {
- function a(e) {
- this.name = NAME$p,
- this._loader = e,
- this.enabled = this._loader.isExtensionUsed(NAME$p)
- }
- return a.prototype.dispose = function() {
- this._loader = null,
- delete this._lights
- }
- ,
- a.prototype.onLoading = function() {
- var e = this._loader.gltf.extensions;
- if (e && e[this.name]) {
- var i = e[this.name];
- this._lights = i.lights
- }
- }
- ,
- a.prototype.loadNodeAsync = function(e, i, o) {
- var s = this;
- return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(c, d) {
- return s._loader.loadNodeAsync(e, i, function(_) {
- var b, k = ArrayItem.Get(c, s._lights, d.light), j = k.name || _.name;
- switch (s._loader.babylonScene._blockEntityCollection = !!s._loader._assetContainer,
- k.type) {
- case "directional":
- {
- b = new DirectionalLight(j,Vector3.Backward(),s._loader.babylonScene);
- break
- }
- case "point":
- {
- b = new PointLight(j,Vector3.Zero(),s._loader.babylonScene);
- break
- }
- case "spot":
- {
- var $ = new SpotLight(j,Vector3.Zero(),Vector3.Backward(),0,1,s._loader.babylonScene);
- $.angle = (k.spot && k.spot.outerConeAngle || Math.PI / 4) * 2,
- $.innerAngle = (k.spot && k.spot.innerConeAngle || 0) * 2,
- b = $;
- break
- }
- default:
- throw s._loader.babylonScene._blockEntityCollection = !1,
- new Error(c + ": Invalid light type (" + k.type + ")")
- }
- b._parentContainer = s._loader._assetContainer,
- s._loader.babylonScene._blockEntityCollection = !1,
- b.falloffType = Light.FALLOFF_GLTF,
- b.diffuse = k.color ? Color3.FromArray(k.color) : Color3.White(),
- b.intensity = k.intensity == null ? 1 : k.intensity,
- b.range = k.range == null ? Number.MAX_VALUE : k.range,
- b.parent = _,
- s._loader._babylonLights.push(b),
- GLTFLoader.AddPointerMetadata(b, c),
- o(_)
- })
- })
- }
- ,
- a
- }();
- GLTFLoader.RegisterExtension(NAME$p, function(a) {
- return new KHR_lights(a)
- });
- var NAME$o = "KHR_materials_pbrSpecularGlossiness"
- , KHR_materials_pbrSpecularGlossiness = function() {
- function a(e) {
- this.name = NAME$o,
- this.order = 200,
- this._loader = e,
- this.enabled = this._loader.isExtensionUsed(NAME$o)
- }
- return a.prototype.dispose = function() {
- this._loader = null
- }
- ,
- a.prototype.loadMaterialPropertiesAsync = function(e, i, o) {
- var s = this;
- return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(c, d) {
- var _ = new Array;
- return _.push(s._loader.loadMaterialBasePropertiesAsync(e, i, o)),
- _.push(s._loadSpecularGlossinessPropertiesAsync(c, i, d, o)),
- s._loader.loadMaterialAlphaProperties(e, i, o),
- Promise.all(_).then(function() {})
- })
- }
- ,
- a.prototype._loadSpecularGlossinessPropertiesAsync = function(e, i, o, s) {
- if (!(s instanceof PBRMaterial))
- throw new Error(e + ": Material type not supported");
- var c = new Array;
- return s.metallic = null,
- s.roughness = null,
- o.diffuseFactor ? (s.albedoColor = Color3.FromArray(o.diffuseFactor),
- s.alpha = o.diffuseFactor[3]) : s.albedoColor = Color3.White(),
- s.reflectivityColor = o.specularFactor ? Color3.FromArray(o.specularFactor) : Color3.White(),
- s.microSurface = o.glossinessFactor == null ? 1 : o.glossinessFactor,
- o.diffuseTexture && c.push(this._loader.loadTextureInfoAsync(e + "/diffuseTexture", o.diffuseTexture, function(d) {
- d.name = s.name + " (Diffuse)",
- s.albedoTexture = d
- })),
- o.specularGlossinessTexture && (c.push(this._loader.loadTextureInfoAsync(e + "/specularGlossinessTexture", o.specularGlossinessTexture, function(d) {
- d.name = s.name + " (Specular Glossiness)",
- s.reflectivityTexture = d
- })),
- s.reflectivityTexture.hasAlpha = !0,
- s.useMicroSurfaceFromReflectivityMapAlpha = !0),
- Promise.all(c).then(function() {})
- }
- ,
- a
- }();
- GLTFLoader.RegisterExtension(NAME$o, function(a) {
- return new KHR_materials_pbrSpecularGlossiness(a)
- });
- var NAME$n = "KHR_materials_unlit"
- , KHR_materials_unlit$1 = function() {
- function a(e) {
- this.name = NAME$n,
- this.order = 210,
- this._loader = e,
- this.enabled = this._loader.isExtensionUsed(NAME$n)
- }
- return a.prototype.dispose = function() {
- this._loader = null
- }
- ,
- a.prototype.loadMaterialPropertiesAsync = function(e, i, o) {
- var s = this;
- return GLTFLoader.LoadExtensionAsync(e, i, this.name, function() {
- return s._loadUnlitPropertiesAsync(e, i, o)
- })
- }
- ,
- a.prototype._loadUnlitPropertiesAsync = function(e, i, o) {
- if (!(o instanceof PBRMaterial))
- throw new Error(e + ": Material type not supported");
- var s = new Array;
- o.unlit = !0;
- var c = i.pbrMetallicRoughness;
- return c && (c.baseColorFactor ? (o.albedoColor = Color3.FromArray(c.baseColorFactor),
- o.alpha = c.baseColorFactor[3]) : o.albedoColor = Color3.White(),
- c.baseColorTexture && s.push(this._loader.loadTextureInfoAsync(e + "/baseColorTexture", c.baseColorTexture, function(d) {
- d.name = o.name + " (Base Color)",
- o.albedoTexture = d
- }))),
- i.doubleSided && (o.backFaceCulling = !1,
- o.twoSidedLighting = !0),
- this._loader.loadMaterialAlphaProperties(e, i, o),
- Promise.all(s).then(function() {})
- }
- ,
- a
- }();
- GLTFLoader.RegisterExtension(NAME$n, function(a) {
- return new KHR_materials_unlit$1(a)
- });
- var NAME$m = "KHR_materials_clearcoat"
- , KHR_materials_clearcoat$1 = function() {
- function a(e) {
- this.name = NAME$m,
- this.order = 190,
- this._loader = e,
- this.enabled = this._loader.isExtensionUsed(NAME$m)
- }
- return a.prototype.dispose = function() {
- this._loader = null
- }
- ,
- a.prototype.loadMaterialPropertiesAsync = function(e, i, o) {
- var s = this;
- return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(c, d) {
- var _ = new Array;
- return _.push(s._loader.loadMaterialPropertiesAsync(e, i, o)),
- _.push(s._loadClearCoatPropertiesAsync(c, d, o)),
- Promise.all(_).then(function() {})
- })
- }
- ,
- a.prototype._loadClearCoatPropertiesAsync = function(e, i, o) {
- if (!(o instanceof PBRMaterial))
- throw new Error(e + ": Material type not supported");
- var s = new Array;
- return o.clearCoat.isEnabled = !0,
- o.clearCoat.useRoughnessFromMainTexture = !1,
- o.clearCoat.remapF0OnInterfaceChange = !1,
- i.clearcoatFactor != null ? o.clearCoat.intensity = i.clearcoatFactor : o.clearCoat.intensity = 0,
- i.clearcoatTexture && s.push(this._loader.loadTextureInfoAsync(e + "/clearcoatTexture", i.clearcoatTexture, function(c) {
- c.name = o.name + " (ClearCoat Intensity)",
- o.clearCoat.texture = c
- })),
- i.clearcoatRoughnessFactor != null ? o.clearCoat.roughness = i.clearcoatRoughnessFactor : o.clearCoat.roughness = 0,
- i.clearcoatRoughnessTexture && (i.clearcoatRoughnessTexture.nonColorData = !0,
- s.push(this._loader.loadTextureInfoAsync(e + "/clearcoatRoughnessTexture", i.clearcoatRoughnessTexture, function(c) {
- c.name = o.name + " (ClearCoat Roughness)",
- o.clearCoat.textureRoughness = c
- }))),
- i.clearcoatNormalTexture && (i.clearcoatNormalTexture.nonColorData = !0,
- s.push(this._loader.loadTextureInfoAsync(e + "/clearcoatNormalTexture", i.clearcoatNormalTexture, function(c) {
- c.name = o.name + " (ClearCoat Normal)",
- o.clearCoat.bumpTexture = c
- })),
- o.invertNormalMapX = !o.getScene().useRightHandedSystem,
- o.invertNormalMapY = o.getScene().useRightHandedSystem,
- i.clearcoatNormalTexture.scale != null && (o.clearCoat.bumpTexture.level = i.clearcoatNormalTexture.scale)),
- Promise.all(s).then(function() {})
- }
- ,
- a
- }();
- GLTFLoader.RegisterExtension(NAME$m, function(a) {
- return new KHR_materials_clearcoat$1(a)
- });
- var NAME$l = "KHR_materials_emissive_strength"
- , KHR_materials_emissive_strength = function() {
- function a(e) {
- this.name = NAME$l,
- this.order = 170,
- this._loader = e,
- this.enabled = this._loader.isExtensionUsed(NAME$l)
- }
- return a.prototype.dispose = function() {
- this._loader = null
- }
- ,
- a.prototype.loadMaterialPropertiesAsync = function(e, i, o) {
- var s = this;
- return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(c, d) {
- return s._loader.loadMaterialPropertiesAsync(e, i, o).then(function() {
- s._loadEmissiveProperties(c, d, o)
- })
- })
- }
- ,
- a.prototype._loadEmissiveProperties = function(e, i, o) {
- if (!(o instanceof PBRMaterial))
- throw new Error(e + ": Material type not supported");
- i.emissiveStrength !== void 0 && o.emissiveColor.scaleToRef(i.emissiveStrength, o.emissiveColor)
- }
- ,
- a
- }();
- GLTFLoader.RegisterExtension(NAME$l, function(a) {
- return new KHR_materials_emissive_strength(a)
- });
- var NAME$k = "KHR_materials_sheen"
- , KHR_materials_sheen$1 = function() {
- function a(e) {
- this.name = NAME$k,
- this.order = 190,
- this._loader = e,
- this.enabled = this._loader.isExtensionUsed(NAME$k)
- }
- return a.prototype.dispose = function() {
- this._loader = null
- }
- ,
- a.prototype.loadMaterialPropertiesAsync = function(e, i, o) {
- var s = this;
- return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(c, d) {
- var _ = new Array;
- return _.push(s._loader.loadMaterialPropertiesAsync(e, i, o)),
- _.push(s._loadSheenPropertiesAsync(c, d, o)),
- Promise.all(_).then(function() {})
- })
- }
- ,
- a.prototype._loadSheenPropertiesAsync = function(e, i, o) {
- if (!(o instanceof PBRMaterial))
- throw new Error(e + ": Material type not supported");
- var s = new Array;
- return o.sheen.isEnabled = !0,
- o.sheen.intensity = 1,
- i.sheenColorFactor != null ? o.sheen.color = Color3.FromArray(i.sheenColorFactor) : o.sheen.color = Color3.Black(),
- i.sheenColorTexture && s.push(this._loader.loadTextureInfoAsync(e + "/sheenColorTexture", i.sheenColorTexture, function(c) {
- c.name = o.name + " (Sheen Color)",
- o.sheen.texture = c
- })),
- i.sheenRoughnessFactor !== void 0 ? o.sheen.roughness = i.sheenRoughnessFactor : o.sheen.roughness = 0,
- i.sheenRoughnessTexture && (i.sheenRoughnessTexture.nonColorData = !0,
- s.push(this._loader.loadTextureInfoAsync(e + "/sheenRoughnessTexture", i.sheenRoughnessTexture, function(c) {
- c.name = o.name + " (Sheen Roughness)",
- o.sheen.textureRoughness = c
- }))),
- o.sheen.albedoScaling = !0,
- o.sheen.useRoughnessFromMainTexture = !1,
- Promise.all(s).then(function() {})
- }
- ,
- a
- }();
- GLTFLoader.RegisterExtension(NAME$k, function(a) {
- return new KHR_materials_sheen$1(a)
- });
- var NAME$j = "KHR_materials_specular"
- , KHR_materials_specular = function() {
- function a(e) {
- this.name = NAME$j,
- this.order = 190,
- this._loader = e,
- this.enabled = this._loader.isExtensionUsed(NAME$j)
- }
- return a.prototype.dispose = function() {
- this._loader = null
- }
- ,
- a.prototype.loadMaterialPropertiesAsync = function(e, i, o) {
- var s = this;
- return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(c, d) {
- var _ = new Array;
- return _.push(s._loader.loadMaterialPropertiesAsync(e, i, o)),
- _.push(s._loadSpecularPropertiesAsync(c, d, o)),
- Promise.all(_).then(function() {})
- })
- }
- ,
- a.prototype._loadSpecularPropertiesAsync = function(e, i, o) {
- if (!(o instanceof PBRMaterial))
- throw new Error(e + ": Material type not supported");
- var s = new Array;
- return i.specularFactor !== void 0 && (o.metallicF0Factor = i.specularFactor),
- i.specularColorFactor !== void 0 && (o.metallicReflectanceColor = Color3.FromArray(i.specularColorFactor)),
- i.specularTexture && (i.specularTexture.nonColorData = !0,
- s.push(this._loader.loadTextureInfoAsync(e + "/specularTexture", i.specularTexture, function(c) {
- c.name = o.name + " (Specular F0 Strength)",
- o.metallicReflectanceTexture = c,
- o.useOnlyMetallicFromMetallicReflectanceTexture = !0
- }))),
- i.specularColorTexture && s.push(this._loader.loadTextureInfoAsync(e + "/specularColorTexture", i.specularColorTexture, function(c) {
- c.name = o.name + " (Specular F0 Color)",
- o.reflectanceTexture = c
- })),
- Promise.all(s).then(function() {})
- }
- ,
- a
- }();
- GLTFLoader.RegisterExtension(NAME$j, function(a) {
- return new KHR_materials_specular(a)
- });
- var NAME$i = "KHR_materials_ior"
- , KHR_materials_ior = function() {
- function a(e) {
- this.name = NAME$i,
- this.order = 180,
- this._loader = e,
- this.enabled = this._loader.isExtensionUsed(NAME$i)
- }
- return a.prototype.dispose = function() {
- this._loader = null
- }
- ,
- a.prototype.loadMaterialPropertiesAsync = function(e, i, o) {
- var s = this;
- return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(c, d) {
- var _ = new Array;
- return _.push(s._loader.loadMaterialPropertiesAsync(e, i, o)),
- _.push(s._loadIorPropertiesAsync(c, d, o)),
- Promise.all(_).then(function() {})
- })
- }
- ,
- a.prototype._loadIorPropertiesAsync = function(e, i, o) {
- if (!(o instanceof PBRMaterial))
- throw new Error(e + ": Material type not supported");
- return i.ior !== void 0 ? o.indexOfRefraction = i.ior : o.indexOfRefraction = a._DEFAULT_IOR,
- Promise.resolve()
- }
- ,
- a._DEFAULT_IOR = 1.5,
- a
- }();
- GLTFLoader.RegisterExtension(NAME$i, function(a) {
- return new KHR_materials_ior(a)
- });
- var NAME$h = "KHR_materials_variants"
- , KHR_materials_variants = function() {
- function a(e) {
- this.name = NAME$h,
- this._loader = e,
- this.enabled = this._loader.isExtensionUsed(NAME$h)
- }
- return a.prototype.dispose = function() {
- this._loader = null
- }
- ,
- a.GetAvailableVariants = function(e) {
- var i = this._GetExtensionMetadata(e);
- return i ? Object.keys(i.variants) : []
- }
- ,
- a.prototype.getAvailableVariants = function(e) {
- return a.GetAvailableVariants(e)
- }
- ,
- a.SelectVariant = function(e, i) {
- var o = this._GetExtensionMetadata(e);
- if (!o)
- throw new Error("Cannot select variant on a glTF mesh that does not have the " + NAME$h + " extension");
- var s = function(b) {
- var k = o.variants[b];
- if (k)
- for (var j = 0, $ = k; j < $.length; j++) {
- var _e = $[j];
- _e.mesh.material = _e.material
- }
- };
- if (i instanceof Array)
- for (var c = 0, d = i; c < d.length; c++) {
- var _ = d[c];
- s(_)
- }
- else
- s(i);
- o.lastSelected = i
- }
- ,
- a.prototype.selectVariant = function(e, i) {
- return a.SelectVariant(e, i)
- }
- ,
- a.Reset = function(e) {
- var i = this._GetExtensionMetadata(e);
- if (!i)
- throw new Error("Cannot reset on a glTF mesh that does not have the " + NAME$h + " extension");
- for (var o = 0, s = i.original; o < s.length; o++) {
- var c = s[o];
- c.mesh.material = c.material
- }
- i.lastSelected = null
- }
- ,
- a.prototype.reset = function(e) {
- return a.Reset(e)
- }
- ,
- a.GetLastSelectedVariant = function(e) {
- var i = this._GetExtensionMetadata(e);
- if (!i)
- throw new Error("Cannot get the last selected variant on a glTF mesh that does not have the " + NAME$h + " extension");
- return i.lastSelected
- }
- ,
- a.prototype.getLastSelectedVariant = function(e) {
- return a.GetLastSelectedVariant(e)
- }
- ,
- a._GetExtensionMetadata = function(e) {
- var i, o;
- 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
- }
- ,
- a.prototype.onLoading = function() {
- var e = this._loader.gltf.extensions;
- if (e && e[this.name]) {
- var i = e[this.name];
- this._variants = i.variants
- }
- }
- ,
- a.prototype._loadMeshPrimitiveAsync = function(e, i, o, s, c, d) {
- var _ = this;
- return GLTFLoader.LoadExtensionAsync(e, c, this.name, function(b, k) {
- var j = new Array;
- return j.push(_._loader._loadMeshPrimitiveAsync(e, i, o, s, c, function($) {
- if (d($),
- $instanceof Mesh) {
- var _e = GLTFLoader._GetDrawMode(e, c.mode)
- , et = _._loader.rootBabylonMesh
- , tt = et ? et.metadata = et.metadata || {} : {}
- , rt = tt.gltf = tt.gltf || {}
- , it = rt[NAME$h] = rt[NAME$h] || {
- lastSelected: null,
- original: [],
- variants: {}
- };
- it.original.push({
- mesh: $,
- material: $.material
- });
- for (var nt = function(at) {
- var st = k.mappings[at]
- , ut = ArrayItem.Get(b + "/mappings/" + at + "/material", _._loader.gltf.materials, st.material);
- j.push(_._loader._loadMaterialAsync("#/materials/" + st.material, ut, $, _e, function(ct) {
- for (var lt = function(ht) {
- var pt = st.variants[ht]
- , dt = ArrayItem.Get("/extensions/" + NAME$h + "/variants/" + pt, _._variants, pt);
- it.variants[dt.name] = it.variants[dt.name] || [],
- it.variants[dt.name].push({
- mesh: $,
- material: ct
- }),
- $.onClonedObservable.add(function(_t) {
- var mt = _t
- , vt = null
- , yt = mt;
- do {
- if (yt = yt.parent,
- !yt)
- return;
- vt = a._GetExtensionMetadata(yt)
- } while (vt === null);
- if (et && vt === a._GetExtensionMetadata(et)) {
- yt.metadata = {};
- for (var Et in et.metadata)
- yt.metadata[Et] = et.metadata[Et];
- yt.metadata.gltf = [];
- for (var Et in et.metadata.gltf)
- yt.metadata.gltf[Et] = et.metadata.gltf[Et];
- yt.metadata.gltf[NAME$h] = {
- lastSelected: null,
- original: [],
- variants: {}
- };
- for (var At = 0, gt = vt.original; At < gt.length; At++) {
- var St = gt[At];
- yt.metadata.gltf[NAME$h].original.push({
- mesh: St.mesh,
- material: St.material
- })
- }
- for (var Et in vt.variants)
- if (vt.variants.hasOwnProperty(Et)) {
- yt.metadata.gltf[NAME$h].variants[Et] = [];
- for (var xt = 0, bt = vt.variants[Et]; xt < bt.length; xt++) {
- var Rt = bt[xt];
- yt.metadata.gltf[NAME$h].variants[Et].push({
- mesh: Rt.mesh,
- material: Rt.material
- })
- }
- }
- vt = yt.metadata.gltf[NAME$h]
- }
- for (var Mt = 0, Pt = vt.original; Mt < Pt.length; Mt++) {
- var It = Pt[Mt];
- It.mesh === $ && (It.mesh = mt)
- }
- for (var Dt = 0, Ct = vt.variants[dt.name]; Dt < Ct.length; Dt++) {
- var It = Ct[Dt];
- It.mesh === $ && (It.mesh = mt)
- }
- })
- }, ft = 0; ft < st.variants.length; ++ft)
- lt(ft)
- }))
- }, ot = 0; ot < k.mappings.length; ++ot)
- nt(ot)
- }
- })),
- Promise.all(j).then(function($) {
- var _e = $[0];
- return _e
- })
- })
- }
- ,
- a
- }();
- GLTFLoader.RegisterExtension(NAME$h, function(a) {
- return new KHR_materials_variants(a)
- });
- var TransmissionHelper = function() {
- function a(e, i) {
- var o = this;
- this._opaqueRenderTarget = null,
- this._opaqueMeshesCache = [],
- this._transparentMeshesCache = [],
- this._materialObservers = {},
- this._options = __assign(__assign({}, a._getDefaultOptions()), e),
- this._scene = i,
- this._scene._transmissionHelper = this,
- this.onErrorObservable = new Observable,
- this._scene.onDisposeObservable.addOnce(function(s) {
- o.dispose()
- }),
- this._parseScene(),
- this._setupRenderTargets()
- }
- return a._getDefaultOptions = function() {
- return {
- renderSize: 1024,
- samples: 4,
- lodGenerationScale: 1,
- lodGenerationOffset: -4,
- renderTargetTextureType: Constants.TEXTURETYPE_HALF_FLOAT,
- generateMipmaps: !0
- }
- }
- ,
- a.prototype.updateOptions = function(e) {
- var i = this
- , o = Object.keys(e).filter(function(d) {
- return i._options[d] !== e[d]
- });
- if (!!o.length) {
- var s = __assign(__assign({}, this._options), e)
- , c = this._options;
- this._options = s,
- s.renderSize !== c.renderSize || s.renderTargetTextureType !== c.renderTargetTextureType || s.generateMipmaps !== c.generateMipmaps || !this._opaqueRenderTarget ? this._setupRenderTargets() : (this._opaqueRenderTarget.samples = s.samples,
- this._opaqueRenderTarget.lodGenerationScale = s.lodGenerationScale,
- this._opaqueRenderTarget.lodGenerationOffset = s.lodGenerationOffset)
- }
- }
- ,
- a.prototype.getOpaqueTarget = function() {
- return this._opaqueRenderTarget
- }
- ,
- a.prototype.shouldRenderAsTransmission = function(e) {
- return e ? !!(e instanceof PBRMaterial && e.subSurface.isRefractionEnabled) : !1
- }
- ,
- a.prototype._addMesh = function(e) {
- var i = this;
- this._materialObservers[e.uniqueId] = e.onMaterialChangedObservable.add(this._onMeshMaterialChanged.bind(this)),
- Tools.SetImmediate(function() {
- i.shouldRenderAsTransmission(e.material) ? (e.material.refractionTexture = i._opaqueRenderTarget,
- i._transparentMeshesCache.push(e)) : i._opaqueMeshesCache.push(e)
- })
- }
- ,
- a.prototype._removeMesh = function(e) {
- e.onMaterialChangedObservable.remove(this._materialObservers[e.uniqueId]),
- delete this._materialObservers[e.uniqueId];
- var i = this._transparentMeshesCache.indexOf(e);
- i !== -1 && this._transparentMeshesCache.splice(i, 1),
- i = this._opaqueMeshesCache.indexOf(e),
- i !== -1 && this._opaqueMeshesCache.splice(i, 1)
- }
- ,
- a.prototype._parseScene = function() {
- this._scene.meshes.forEach(this._addMesh.bind(this)),
- this._scene.onNewMeshAddedObservable.add(this._addMesh.bind(this)),
- this._scene.onMeshRemovedObservable.add(this._removeMesh.bind(this))
- }
- ,
- a.prototype._onMeshMaterialChanged = function(e) {
- var i = this._transparentMeshesCache.indexOf(e)
- , o = this._opaqueMeshesCache.indexOf(e)
- , s = this.shouldRenderAsTransmission(e.material);
- s ? (e.material instanceof PBRMaterial && (e.material.subSurface.refractionTexture = this._opaqueRenderTarget),
- o !== -1 ? (this._opaqueMeshesCache.splice(o, 1),
- this._transparentMeshesCache.push(e)) : i === -1 && this._transparentMeshesCache.push(e)) : i !== -1 ? (this._transparentMeshesCache.splice(i, 1),
- this._opaqueMeshesCache.push(e)) : o === -1 && this._opaqueMeshesCache.push(e)
- }
- ,
- a.prototype._setupRenderTargets = function() {
- var e = this, i, o;
- this._opaqueRenderTarget && this._opaqueRenderTarget.dispose(),
- this._opaqueRenderTarget = new RenderTargetTexture("opaqueSceneTexture",this._options.renderSize,this._scene,this._options.generateMipmaps,void 0,this._options.renderTargetTextureType),
- this._opaqueRenderTarget.ignoreCameraViewport = !0,
- this._opaqueRenderTarget.renderList = this._opaqueMeshesCache,
- 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(),
- this._opaqueRenderTarget.gammaSpace = !1,
- this._opaqueRenderTarget.lodGenerationScale = this._options.lodGenerationScale,
- this._opaqueRenderTarget.lodGenerationOffset = this._options.lodGenerationOffset,
- this._opaqueRenderTarget.samples = this._options.samples;
- var s, c;
- this._opaqueRenderTarget.onBeforeBindObservable.add(function(d) {
- c = e._scene.environmentIntensity,
- e._scene.environmentIntensity = 1,
- s = e._scene.imageProcessingConfiguration.applyByPostProcess,
- e._options.clearColor ? d.clearColor.copyFrom(e._options.clearColor) : e._scene.clearColor.toLinearSpaceToRef(d.clearColor),
- e._scene.imageProcessingConfiguration._applyByPostProcess = !0
- }),
- this._opaqueRenderTarget.onAfterUnbindObservable.add(function() {
- e._scene.environmentIntensity = c,
- e._scene.imageProcessingConfiguration._applyByPostProcess = s
- }),
- this._transparentMeshesCache.forEach(function(d) {
- e.shouldRenderAsTransmission(d.material) && (d.material.refractionTexture = e._opaqueRenderTarget)
- })
- }
- ,
- a.prototype.dispose = function() {
- this._scene._transmissionHelper = void 0,
- this._opaqueRenderTarget && (this._opaqueRenderTarget.dispose(),
- this._opaqueRenderTarget = null),
- this._transparentMeshesCache = [],
- this._opaqueMeshesCache = []
- }
- ,
- a
- }()
- , NAME$g = "KHR_materials_transmission"
- , KHR_materials_transmission = function() {
- function a(e) {
- this.name = NAME$g,
- this.order = 175,
- this._loader = e,
- this.enabled = this._loader.isExtensionUsed(NAME$g),
- this.enabled && (e.parent.transparencyAsCoverage = !0)
- }
- return a.prototype.dispose = function() {
- this._loader = null
- }
- ,
- a.prototype.loadMaterialPropertiesAsync = function(e, i, o) {
- var s = this;
- return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(c, d) {
- var _ = new Array;
- return _.push(s._loader.loadMaterialBasePropertiesAsync(e, i, o)),
- _.push(s._loader.loadMaterialPropertiesAsync(e, i, o)),
- _.push(s._loadTransparentPropertiesAsync(c, i, o, d)),
- Promise.all(_).then(function() {})
- })
- }
- ,
- a.prototype._loadTransparentPropertiesAsync = function(e, i, o, s) {
- if (!(o instanceof PBRMaterial))
- throw new Error(e + ": Material type not supported");
- var c = o;
- if (c.subSurface.isRefractionEnabled = !0,
- c.subSurface.volumeIndexOfRefraction = 1,
- c.subSurface.useAlbedoToTintRefraction = !0,
- s.transmissionFactor !== void 0) {
- c.subSurface.refractionIntensity = s.transmissionFactor;
- var d = c.getScene();
- c.subSurface.refractionIntensity && !d._transmissionHelper && new TransmissionHelper({},c.getScene())
- } else
- return c.subSurface.refractionIntensity = 0,
- c.subSurface.isRefractionEnabled = !1,
- Promise.resolve();
- return c.subSurface.minimumThickness = 0,
- c.subSurface.maximumThickness = 0,
- s.transmissionTexture ? (s.transmissionTexture.nonColorData = !0,
- this._loader.loadTextureInfoAsync(e + "/transmissionTexture", s.transmissionTexture, void 0).then(function(_) {
- c.subSurface.refractionIntensityTexture = _,
- c.subSurface.useGltfStyleTextures = !0
- })) : Promise.resolve()
- }
- ,
- a
- }();
- GLTFLoader.RegisterExtension(NAME$g, function(a) {
- return new KHR_materials_transmission(a)
- });
- var NAME$f = "KHR_materials_translucency"
- , KHR_materials_translucency = function() {
- function a(e) {
- this.name = NAME$f,
- this.order = 174,
- this._loader = e,
- this.enabled = this._loader.isExtensionUsed(NAME$f),
- this.enabled && (e.parent.transparencyAsCoverage = !0)
- }
- return a.prototype.dispose = function() {
- this._loader = null
- }
- ,
- a.prototype.loadMaterialPropertiesAsync = function(e, i, o) {
- var s = this;
- return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(c, d) {
- var _ = new Array;
- return _.push(s._loader.loadMaterialBasePropertiesAsync(e, i, o)),
- _.push(s._loader.loadMaterialPropertiesAsync(e, i, o)),
- _.push(s._loadTranslucentPropertiesAsync(c, i, o, d)),
- Promise.all(_).then(function() {})
- })
- }
- ,
- a.prototype._loadTranslucentPropertiesAsync = function(e, i, o, s) {
- if (!(o instanceof PBRMaterial))
- throw new Error(e + ": Material type not supported");
- var c = o;
- if (c.subSurface.isTranslucencyEnabled = !0,
- c.subSurface.volumeIndexOfRefraction = 1,
- c.subSurface.minimumThickness = 0,
- c.subSurface.maximumThickness = 0,
- c.subSurface.useAlbedoToTintTranslucency = !0,
- s.translucencyFactor !== void 0)
- c.subSurface.translucencyIntensity = s.translucencyFactor;
- else
- return c.subSurface.translucencyIntensity = 0,
- c.subSurface.isTranslucencyEnabled = !1,
- Promise.resolve();
- return s.translucencyTexture ? (s.translucencyTexture.nonColorData = !0,
- this._loader.loadTextureInfoAsync(e + "/translucencyTexture", s.translucencyTexture).then(function(d) {
- c.subSurface.translucencyIntensityTexture = d
- })) : Promise.resolve()
- }
- ,
- a
- }();
- GLTFLoader.RegisterExtension(NAME$f, function(a) {
- return new KHR_materials_translucency(a)
- });
- var NAME$e = "KHR_materials_volume"
- , KHR_materials_volume = function() {
- function a(e) {
- this.name = NAME$e,
- this.order = 173,
- this._loader = e,
- this.enabled = this._loader.isExtensionUsed(NAME$e),
- this.enabled && this._loader._disableInstancedMesh++
- }
- return a.prototype.dispose = function() {
- this.enabled && this._loader._disableInstancedMesh--,
- this._loader = null
- }
- ,
- a.prototype.loadMaterialPropertiesAsync = function(e, i, o) {
- var s = this;
- return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(c, d) {
- var _ = new Array;
- return _.push(s._loader.loadMaterialBasePropertiesAsync(e, i, o)),
- _.push(s._loader.loadMaterialPropertiesAsync(e, i, o)),
- _.push(s._loadVolumePropertiesAsync(c, i, o, d)),
- Promise.all(_).then(function() {})
- })
- }
- ,
- a.prototype._loadVolumePropertiesAsync = function(e, i, o, s) {
- if (!(o instanceof PBRMaterial))
- throw new Error(e + ": Material type not supported");
- if (!o.subSurface.isRefractionEnabled && !o.subSurface.isTranslucencyEnabled || !s.thicknessFactor)
- return Promise.resolve();
- o.subSurface.volumeIndexOfRefraction = o.indexOfRefraction;
- var c = s.attenuationDistance !== void 0 ? s.attenuationDistance : Number.MAX_VALUE;
- return o.subSurface.tintColorAtDistance = c,
- s.attenuationColor !== void 0 && s.attenuationColor.length == 3 && o.subSurface.tintColor.copyFromFloats(s.attenuationColor[0], s.attenuationColor[1], s.attenuationColor[2]),
- o.subSurface.minimumThickness = 0,
- o.subSurface.maximumThickness = s.thicknessFactor,
- o.subSurface.useThicknessAsDepth = !0,
- s.thicknessTexture ? (s.thicknessTexture.nonColorData = !0,
- this._loader.loadTextureInfoAsync(e + "/thicknessTexture", s.thicknessTexture).then(function(d) {
- o.subSurface.thicknessTexture = d,
- o.subSurface.useGltfStyleTextures = !0
- })) : Promise.resolve()
- }
- ,
- a
- }();
- GLTFLoader.RegisterExtension(NAME$e, function(a) {
- return new KHR_materials_volume(a)
- });
- var NAME$d = "KHR_mesh_quantization"
- , KHR_mesh_quantization = function() {
- function a(e) {
- this.name = NAME$d,
- this.enabled = e.isExtensionUsed(NAME$d)
- }
- return a.prototype.dispose = function() {}
- ,
- a
- }();
- GLTFLoader.RegisterExtension(NAME$d, function(a) {
- return new KHR_mesh_quantization(a)
- });
- var NAME$c = "KHR_texture_basisu"
- , KHR_texture_basisu = function() {
- function a(e) {
- this.name = NAME$c,
- this._loader = e,
- this.enabled = e.isExtensionUsed(NAME$c)
- }
- return a.prototype.dispose = function() {
- this._loader = null
- }
- ,
- a.prototype._loadTextureAsync = function(e, i, o) {
- var s = this;
- return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(c, d) {
- var _ = i.sampler == null ? GLTFLoader.DefaultSampler : ArrayItem.Get(e + "/sampler", s._loader.gltf.samplers, i.sampler)
- , b = ArrayItem.Get(c + "/source", s._loader.gltf.images, d.source);
- return s._loader._createTextureAsync(e, _, b, function(k) {
- o(k)
- }, i._textureInfo.nonColorData ? {
- useRGBAIfASTCBC7NotAvailableWhenUASTC: !0
- } : void 0, !i._textureInfo.nonColorData)
- })
- }
- ,
- a
- }();
- GLTFLoader.RegisterExtension(NAME$c, function(a) {
- return new KHR_texture_basisu(a)
- });
- var NAME$b = "KHR_texture_transform"
- , KHR_texture_transform$1 = function() {
- function a(e) {
- this.name = NAME$b,
- this._loader = e,
- this.enabled = this._loader.isExtensionUsed(NAME$b)
- }
- return a.prototype.dispose = function() {
- this._loader = null
- }
- ,
- a.prototype.loadTextureInfoAsync = function(e, i, o) {
- var s = this;
- return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(c, d) {
- return s._loader.loadTextureInfoAsync(e, i, function(_) {
- if (!(_ instanceof Texture))
- throw new Error(c + ": Texture type not supported");
- d.offset && (_.uOffset = d.offset[0],
- _.vOffset = d.offset[1]),
- _.uRotationCenter = 0,
- _.vRotationCenter = 0,
- d.rotation && (_.wAng = -d.rotation),
- d.scale && (_.uScale = d.scale[0],
- _.vScale = d.scale[1]),
- d.texCoord != null && (_.coordinatesIndex = d.texCoord),
- o(_)
- })
- })
- }
- ,
- a
- }();
- GLTFLoader.RegisterExtension(NAME$b, function(a) {
- return new KHR_texture_transform$1(a)
- });
- var NAME$a = "KHR_xmp_json_ld"
- , KHR_xmp_json_ld = function() {
- function a(e) {
- this.name = NAME$a,
- this.order = 100,
- this._loader = e,
- this.enabled = this._loader.isExtensionUsed(NAME$a)
- }
- return a.prototype.dispose = function() {
- this._loader = null
- }
- ,
- a.prototype.onLoading = function() {
- var e, i, o;
- if (this._loader.rootBabylonMesh !== null) {
- var s = (e = this._loader.gltf.extensions) === null || e === void 0 ? void 0 : e.KHR_xmp_json_ld
- , 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;
- if (s && c) {
- var d = +c.packet;
- s.packets && d < s.packets.length && (this._loader.rootBabylonMesh.metadata = this._loader.rootBabylonMesh.metadata || {},
- this._loader.rootBabylonMesh.metadata.xmp = s.packets[d])
- }
- }
- }
- ,
- a
- }();
- GLTFLoader.RegisterExtension(NAME$a, function(a) {
- return new KHR_xmp_json_ld(a)
- });
- var AnimationEvent = function() {
- function a(e, i, o) {
- this.frame = e,
- this.action = i,
- this.onlyOnce = o,
- this.isDone = !1
- }
- return a.prototype._clone = function() {
- return new a(this.frame,this.action,this.onlyOnce)
- }
- ,
- a
- }()
- , WeightedSound = function() {
- function a(e, i, o) {
- var s = this;
- if (this.loop = !1,
- this._coneInnerAngle = 360,
- this._coneOuterAngle = 360,
- this._volume = 1,
- this.isPlaying = !1,
- this.isPaused = !1,
- this._sounds = [],
- this._weights = [],
- i.length !== o.length)
- throw new Error("Sounds length does not equal weights length");
- this.loop = e,
- this._weights = o;
- for (var c = 0, d = 0, _ = o; d < _.length; d++) {
- var b = _[d];
- c += b
- }
- for (var k = c > 0 ? 1 / c : 0, j = 0; j < this._weights.length; j++)
- this._weights[j] *= k;
- this._sounds = i;
- for (var $ = 0, _e = this._sounds; $ < _e.length; $++) {
- var et = _e[$];
- et.onEndedObservable.add(function() {
- s._onended()
- })
- }
- }
- return Object.defineProperty(a.prototype, "directionalConeInnerAngle", {
- get: function() {
- return this._coneInnerAngle
- },
- set: function(e) {
- if (e !== this._coneInnerAngle) {
- if (this._coneOuterAngle < e) {
- Logger$2.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
- return
- }
- this._coneInnerAngle = e;
- for (var i = 0, o = this._sounds; i < o.length; i++) {
- var s = o[i];
- s.directionalConeInnerAngle = e
- }
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "directionalConeOuterAngle", {
- get: function() {
- return this._coneOuterAngle
- },
- set: function(e) {
- if (e !== this._coneOuterAngle) {
- if (e < this._coneInnerAngle) {
- Logger$2.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
- return
- }
- this._coneOuterAngle = e;
- for (var i = 0, o = this._sounds; i < o.length; i++) {
- var s = o[i];
- s.directionalConeOuterAngle = e
- }
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "volume", {
- get: function() {
- return this._volume
- },
- set: function(e) {
- if (e !== this._volume)
- for (var i = 0, o = this._sounds; i < o.length; i++) {
- var s = o[i];
- s.setVolume(e)
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._onended = function() {
- this._currentIndex !== void 0 && (this._sounds[this._currentIndex].autoplay = !1),
- this.loop && this.isPlaying ? this.play() : this.isPlaying = !1
- }
- ,
- a.prototype.pause = function() {
- this.isPaused = !0,
- this._currentIndex !== void 0 && this._sounds[this._currentIndex].pause()
- }
- ,
- a.prototype.stop = function() {
- this.isPlaying = !1,
- this._currentIndex !== void 0 && this._sounds[this._currentIndex].stop()
- }
- ,
- a.prototype.play = function(e) {
- if (!this.isPaused) {
- this.stop();
- for (var i = Math.random(), o = 0, s = 0; s < this._weights.length; s++)
- if (o += this._weights[s],
- i <= o) {
- this._currentIndex = s;
- break
- }
- }
- var c = this._sounds[this._currentIndex];
- c.isReady() ? c.play(0, this.isPaused ? void 0 : e) : c.autoplay = !0,
- this.isPlaying = !0,
- this.isPaused = !1
- }
- ,
- a
- }()
- , NAME$9 = "MSFT_audio_emitter"
- , MSFT_audio_emitter = function() {
- function a(e) {
- this.name = NAME$9,
- this._loader = e,
- this.enabled = this._loader.isExtensionUsed(NAME$9)
- }
- return a.prototype.dispose = function() {
- this._loader = null,
- this._clips = null,
- this._emitters = null
- }
- ,
- a.prototype.onLoading = function() {
- var e = this._loader.gltf.extensions;
- if (e && e[this.name]) {
- var i = e[this.name];
- this._clips = i.clips,
- this._emitters = i.emitters,
- ArrayItem.Assign(this._clips),
- ArrayItem.Assign(this._emitters)
- }
- }
- ,
- a.prototype.loadSceneAsync = function(e, i) {
- var o = this;
- return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(s, c) {
- var d = new Array;
- d.push(o._loader.loadSceneAsync(e, i));
- for (var _ = 0, b = c.emitters; _ < b.length; _++) {
- var k = b[_]
- , j = ArrayItem.Get(s + "/emitters", o._emitters, k);
- if (j.refDistance != null || j.maxDistance != null || j.rolloffFactor != null || j.distanceModel != null || j.innerAngle != null || j.outerAngle != null)
- throw new Error(s + ": Direction or Distance properties are not allowed on emitters attached to a scene");
- d.push(o._loadEmitterAsync(s + "/emitters/" + j.index, j))
- }
- return Promise.all(d).then(function() {})
- })
- }
- ,
- a.prototype.loadNodeAsync = function(e, i, o) {
- var s = this;
- return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(c, d) {
- var _ = new Array;
- return s._loader.loadNodeAsync(c, i, function(b) {
- for (var k = function(et) {
- var tt = ArrayItem.Get(c + "/emitters", s._emitters, et);
- _.push(s._loadEmitterAsync(c + "/emitters/" + tt.index, tt).then(function() {
- for (var rt = 0, it = tt._babylonSounds; rt < it.length; rt++) {
- var nt = it[rt];
- nt.attachToMesh(b),
- (tt.innerAngle != null || tt.outerAngle != null) && (nt.setLocalDirectionToMesh(Vector3.Forward()),
- nt.setDirectionalCone(2 * Tools.ToDegrees(tt.innerAngle == null ? Math.PI : tt.innerAngle), 2 * Tools.ToDegrees(tt.outerAngle == null ? Math.PI : tt.outerAngle), 0))
- }
- }))
- }, j = 0, $ = d.emitters; j < $.length; j++) {
- var _e = $[j];
- k(_e)
- }
- o(b)
- }).then(function(b) {
- return Promise.all(_).then(function() {
- return b
- })
- })
- })
- }
- ,
- a.prototype.loadAnimationAsync = function(e, i) {
- var o = this;
- return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(s, c) {
- return o._loader.loadAnimationAsync(e, i).then(function(d) {
- var _ = new Array;
- ArrayItem.Assign(c.events);
- for (var b = 0, k = c.events; b < k.length; b++) {
- var j = k[b];
- _.push(o._loadAnimationEventAsync(s + "/events/" + j.index, e, i, j, d))
- }
- return Promise.all(_).then(function() {
- return d
- })
- })
- })
- }
- ,
- a.prototype._loadClipAsync = function(e, i) {
- if (i._objectURL)
- return i._objectURL;
- var o;
- if (i.uri)
- o = this._loader.loadUriAsync(e, i, i.uri);
- else {
- var s = ArrayItem.Get(e + "/bufferView", this._loader.gltf.bufferViews, i.bufferView);
- o = this._loader.loadBufferViewAsync("/bufferViews/" + s.index, s)
- }
- return i._objectURL = o.then(function(c) {
- return URL.createObjectURL(new Blob([c],{
- type: i.mimeType
- }))
- }),
- i._objectURL
- }
- ,
- a.prototype._loadEmitterAsync = function(e, i) {
- var o = this;
- if (i._babylonSounds = i._babylonSounds || [],
- !i._babylonData) {
- for (var s = new Array, c = i.name || "emitter" + i.index, d = {
- loop: !1,
- autoplay: !1,
- volume: i.volume == null ? 1 : i.volume
- }, _ = function($) {
- var _e = "/extensions/" + b.name + "/clips"
- , et = ArrayItem.Get(_e, b._clips, i.clips[$].clip);
- s.push(b._loadClipAsync(_e + "/" + i.clips[$].clip, et).then(function(tt) {
- var rt = i._babylonSounds[$] = new Sound(c,tt,o._loader.babylonScene,null,d);
- rt.refDistance = i.refDistance || 1,
- rt.maxDistance = i.maxDistance || 256,
- rt.rolloffFactor = i.rolloffFactor || 1,
- rt.distanceModel = i.distanceModel || "exponential"
- }))
- }, b = this, k = 0; k < i.clips.length; k++)
- _(k);
- var j = Promise.all(s).then(function() {
- var $ = i.clips.map(function(et) {
- return et.weight || 1
- })
- , _e = new WeightedSound(i.loop || !1,i._babylonSounds,$);
- i.innerAngle && (_e.directionalConeInnerAngle = 2 * Tools.ToDegrees(i.innerAngle)),
- i.outerAngle && (_e.directionalConeOuterAngle = 2 * Tools.ToDegrees(i.outerAngle)),
- i.volume && (_e.volume = i.volume),
- i._babylonData.sound = _e
- });
- i._babylonData = {
- loaded: j
- }
- }
- return i._babylonData.loaded
- }
- ,
- a.prototype._getEventAction = function(e, i, o, s, c) {
- switch (o) {
- case "play":
- return function(d) {
- var _ = (c || 0) + (d - s);
- i.play(_)
- }
- ;
- case "stop":
- return function(d) {
- i.stop()
- }
- ;
- case "pause":
- return function(d) {
- i.pause()
- }
- ;
- default:
- throw new Error(e + ": Unsupported action " + o)
- }
- }
- ,
- a.prototype._loadAnimationEventAsync = function(e, i, o, s, c) {
- var d = this;
- if (c.targetedAnimations.length == 0)
- return Promise.resolve();
- var _ = c.targetedAnimations[0]
- , b = s.emitter
- , k = ArrayItem.Get("/extensions/" + this.name + "/emitters", this._emitters, b);
- return this._loadEmitterAsync(e, k).then(function() {
- var j = k._babylonData.sound;
- if (j) {
- var $ = new AnimationEvent(s.time,d._getEventAction(e, j, s.action, s.time, s.startOffset));
- _.animation.addEvent($),
- c.onAnimationGroupEndObservable.add(function() {
- j.stop()
- }),
- c.onAnimationGroupPauseObservable.add(function() {
- j.pause()
- })
- }
- })
- }
- ,
- a
- }();
- GLTFLoader.RegisterExtension(NAME$9, function(a) {
- return new MSFT_audio_emitter(a)
- });
- var NAME$8 = "MSFT_lod"
- , MSFT_lod = function() {
- function a(e) {
- this.name = NAME$8,
- this.order = 100,
- this.maxLODsToLoad = 10,
- this.onNodeLODsLoadedObservable = new Observable,
- this.onMaterialLODsLoadedObservable = new Observable,
- this._bufferLODs = new Array,
- this._nodeIndexLOD = null,
- this._nodeSignalLODs = new Array,
- this._nodePromiseLODs = new Array,
- this._nodeBufferLODs = new Array,
- this._materialIndexLOD = null,
- this._materialSignalLODs = new Array,
- this._materialPromiseLODs = new Array,
- this._materialBufferLODs = new Array,
- this._loader = e,
- this.enabled = this._loader.isExtensionUsed(NAME$8)
- }
- return a.prototype.dispose = function() {
- this._loader = null,
- this._nodeIndexLOD = null,
- this._nodeSignalLODs.length = 0,
- this._nodePromiseLODs.length = 0,
- this._nodeBufferLODs.length = 0,
- this._materialIndexLOD = null,
- this._materialSignalLODs.length = 0,
- this._materialPromiseLODs.length = 0,
- this._materialBufferLODs.length = 0,
- this.onMaterialLODsLoadedObservable.clear(),
- this.onNodeLODsLoadedObservable.clear()
- }
- ,
- a.prototype.onReady = function() {
- for (var e = this, i = function(_) {
- var b = Promise.all(o._nodePromiseLODs[_]).then(function() {
- _ !== 0 && (e._loader.endPerformanceCounter("Node LOD " + _),
- e._loader.log("Loaded node LOD " + _)),
- e.onNodeLODsLoadedObservable.notifyObservers(_),
- _ !== e._nodePromiseLODs.length - 1 && (e._loader.startPerformanceCounter("Node LOD " + (_ + 1)),
- e._loadBufferLOD(e._nodeBufferLODs, _ + 1),
- e._nodeSignalLODs[_] && e._nodeSignalLODs[_].resolve())
- });
- o._loader._completePromises.push(b)
- }, o = this, s = 0; s < this._nodePromiseLODs.length; s++)
- i(s);
- for (var c = function(_) {
- var b = Promise.all(d._materialPromiseLODs[_]).then(function() {
- _ !== 0 && (e._loader.endPerformanceCounter("Material LOD " + _),
- e._loader.log("Loaded material LOD " + _)),
- e.onMaterialLODsLoadedObservable.notifyObservers(_),
- _ !== e._materialPromiseLODs.length - 1 && (e._loader.startPerformanceCounter("Material LOD " + (_ + 1)),
- e._loadBufferLOD(e._materialBufferLODs, _ + 1),
- e._materialSignalLODs[_] && e._materialSignalLODs[_].resolve())
- });
- d._loader._completePromises.push(b)
- }, d = this, s = 0; s < this._materialPromiseLODs.length; s++)
- c(s)
- }
- ,
- a.prototype.loadSceneAsync = function(e, i) {
- var o = this._loader.loadSceneAsync(e, i);
- return this._loadBufferLOD(this._bufferLODs, 0),
- o
- }
- ,
- a.prototype.loadNodeAsync = function(e, i, o) {
- var s = this;
- return GLTFLoader.LoadExtensionAsync(e, i, this.name, function(c, d) {
- var _, b = s._getLODs(c, i, s._loader.gltf.nodes, d.ids);
- s._loader.logOpen("" + c);
- for (var k = [], j = 0; j < b.length; j++)
- k.push(null);
- for (var $ = function(_e) {
- var et = b[_e];
- _e !== 0 && (s._nodeIndexLOD = _e,
- s._nodeSignalLODs[_e] = s._nodeSignalLODs[_e] || new Deferred);
- var tt = function(it, nt) {
- var ot, at, st;
- it.setEnabled(!1),
- k[nt] = it;
- for (var ut = !0, ct = 0; ct < k.length; ct++)
- k[ct] || (ut = !1);
- var lt = k[k.length - 1];
- if (ut && lt && s._isMesh(lt)) {
- 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;
- if (ft && ft.length) {
- ft.reverse(),
- lt.useLODScreenCoverage = !0;
- for (var ct = 0; ct < k.length - 1; ct++) {
- var ht = k[ct];
- ht && s._isMesh(ht) && lt.addLODLevel(ft[ct + 1], ht)
- }
- ft[0] > 0 && lt.addLODLevel(ft[0], null)
- }
- }
- }
- , rt = s._loader.loadNodeAsync("/nodes/" + et.index, et, function(it) {
- return tt(it, _e)
- }).then(function(it) {
- 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;
- if (_e !== 0 && !st) {
- var ut = b[_e - 1];
- ut._babylonTransformNode && (s._disposeTransformNode(ut._babylonTransformNode),
- delete ut._babylonTransformNode)
- }
- return o(it),
- it.setEnabled(!0),
- it
- });
- s._nodePromiseLODs[_e] = s._nodePromiseLODs[_e] || [],
- _e === 0 ? _ = rt : (s._nodeIndexLOD = null,
- s._nodePromiseLODs[_e].push(rt))
- }, j = 0; j < b.length; j++)
- $(j);
- return s._loader.logClose(),
- _
- })
- }
- ,
- a.prototype._loadMaterialAsync = function(e, i, o, s, c) {
- var d = this;
- return this._nodeIndexLOD ? null : GLTFLoader.LoadExtensionAsync(e, i, this.name, function(_, b) {
- var k, j = d._getLODs(_, i, d._loader.gltf.materials, b.ids);
- d._loader.logOpen("" + _);
- for (var $ = function(et) {
- var tt = j[et];
- et !== 0 && (d._materialIndexLOD = et);
- var rt = d._loader._loadMaterialAsync("/materials/" + tt.index, tt, o, s, function(it) {
- et === 0 && c(it)
- }).then(function(it) {
- if (et !== 0) {
- c(it);
- var nt = j[et - 1]._data;
- nt[s] && (d._disposeMaterials([nt[s].babylonMaterial]),
- delete nt[s])
- }
- return it
- });
- d._materialPromiseLODs[et] = d._materialPromiseLODs[et] || [],
- et === 0 ? k = rt : (d._materialIndexLOD = null,
- d._materialPromiseLODs[et].push(rt))
- }, _e = 0; _e < j.length; _e++)
- $(_e);
- return d._loader.logClose(),
- k
- })
- }
- ,
- a.prototype._loadUriAsync = function(e, i, o) {
- var s = this;
- if (this._nodeIndexLOD !== null) {
- this._loader.log("deferred");
- var c = this._nodeIndexLOD - 1;
- return this._nodeSignalLODs[c] = this._nodeSignalLODs[c] || new Deferred,
- this._nodeSignalLODs[this._nodeIndexLOD - 1].promise.then(function() {
- return s._loader.loadUriAsync(e, i, o)
- })
- } else if (this._materialIndexLOD !== null) {
- this._loader.log("deferred");
- var c = this._materialIndexLOD - 1;
- return this._materialSignalLODs[c] = this._materialSignalLODs[c] || new Deferred,
- this._materialSignalLODs[c].promise.then(function() {
- return s._loader.loadUriAsync(e, i, o)
- })
- }
- return null
- }
- ,
- a.prototype.loadBufferAsync = function(e, i, o, s) {
- if (this._loader.parent.useRangeRequests && !i.uri) {
- if (!this._loader.bin)
- throw new Error(e + ": Uri is missing or the binary glTF is missing its binary chunk");
- var c = function(d, _) {
- var b = o
- , k = b + s - 1
- , j = d[_];
- return j ? (j.start = Math.min(j.start, b),
- j.end = Math.max(j.end, k)) : (j = {
- start: b,
- end: k,
- loaded: new Deferred
- },
- d[_] = j),
- j.loaded.promise.then(function($) {
- return new Uint8Array($.buffer,$.byteOffset + o - j.start,s)
- })
- };
- return this._loader.log("deferred"),
- this._nodeIndexLOD !== null ? c(this._nodeBufferLODs, this._nodeIndexLOD) : this._materialIndexLOD !== null ? c(this._materialBufferLODs, this._materialIndexLOD) : c(this._bufferLODs, 0)
- }
- return null
- }
- ,
- a.prototype._isMesh = function(e) {
- return !!e.addLODLevel
- }
- ,
- a.prototype._loadBufferLOD = function(e, i) {
- var o = e[i];
- o && (this._loader.log("Loading buffer range [" + o.start + "-" + o.end + "]"),
- this._loader.bin.readAsync(o.start, o.end - o.start + 1).then(function(s) {
- o.loaded.resolve(s)
- }, function(s) {
- o.loaded.reject(s)
- }))
- }
- ,
- a.prototype._getLODs = function(e, i, o, s) {
- if (this.maxLODsToLoad <= 0)
- throw new Error("maxLODsToLoad must be greater than zero");
- for (var c = new Array, d = s.length - 1; d >= 0; d--)
- if (c.push(ArrayItem.Get(e + "/ids/" + s[d], o, s[d])),
- c.length === this.maxLODsToLoad)
- return c;
- return c.push(i),
- c
- }
- ,
- a.prototype._disposeTransformNode = function(e) {
- var i = this
- , o = new Array
- , s = e.material;
- s && o.push(s);
- for (var c = 0, d = e.getChildMeshes(); c < d.length; c++) {
- var _ = d[c];
- _.material && o.push(_.material)
- }
- e.dispose();
- var b = o.filter(function(k) {
- return i._loader.babylonScene.meshes.every(function(j) {
- return j.material != k
- })
- });
- this._disposeMaterials(b)
- }
- ,
- a.prototype._disposeMaterials = function(e) {
- for (var i = {}, o = 0, s = e; o < s.length; o++) {
- for (var c = s[o], d = 0, _ = c.getActiveTextures(); d < _.length; d++) {
- var b = _[d];
- i[b.uniqueId] = b
- }
- c.dispose()
- }
- for (var k in i)
- for (var j = 0, $ = this._loader.babylonScene.materials; j < $.length; j++) {
- var c = $[j];
- c.hasTexture(i[k]) && delete i[k]
- }
- for (var k in i)
- i[k].dispose()
- }
- ,
- a
- }();
- GLTFLoader.RegisterExtension(NAME$8, function(a) {
- return new MSFT_lod(a)
- });
- var NAME$7 = "MSFT_minecraftMesh"
- , MSFT_minecraftMesh = function() {
- function a(e) {
- this.name = NAME$7,
- this._loader = e,
- this.enabled = this._loader.isExtensionUsed(NAME$7)
- }
- return a.prototype.dispose = function() {
- this._loader = null
- }
- ,
- a.prototype.loadMaterialPropertiesAsync = function(e, i, o) {
- var s = this;
- return GLTFLoader.LoadExtraAsync(e, i, this.name, function(c, d) {
- if (d) {
- if (!(o instanceof PBRMaterial))
- throw new Error(c + ": Material type not supported");
- var _ = s._loader.loadMaterialPropertiesAsync(e, i, o);
- return o.needAlphaBlending() && (o.forceDepthWrite = !0,
- o.separateCullingPass = !0),
- o.backFaceCulling = o.forceDepthWrite,
- o.twoSidedLighting = !0,
- _
- }
- return null
- })
- }
- ,
- a
- }();
- GLTFLoader.RegisterExtension(NAME$7, function(a) {
- return new MSFT_minecraftMesh(a)
- });
- var NAME$6 = "MSFT_sRGBFactors"
- , MSFT_sRGBFactors = function() {
- function a(e) {
- this.name = NAME$6,
- this._loader = e,
- this.enabled = this._loader.isExtensionUsed(NAME$6)
- }
- return a.prototype.dispose = function() {
- this._loader = null
- }
- ,
- a.prototype.loadMaterialPropertiesAsync = function(e, i, o) {
- var s = this;
- return GLTFLoader.LoadExtraAsync(e, i, this.name, function(c, d) {
- if (d) {
- if (!(o instanceof PBRMaterial))
- throw new Error(c + ": Material type not supported");
- var _ = s._loader.loadMaterialPropertiesAsync(e, i, o);
- return o.albedoTexture || o.albedoColor.toLinearSpaceToRef(o.albedoColor),
- o.reflectivityTexture || o.reflectivityColor.toLinearSpaceToRef(o.reflectivityColor),
- _
- }
- return null
- })
- }
- ,
- a
- }();
- GLTFLoader.RegisterExtension(NAME$6, function(a) {
- return new MSFT_sRGBFactors(a)
- });
- var NAME$5 = "ExtrasAsMetadata"
- , ExtrasAsMetadata = function() {
- function a(e) {
- this.name = NAME$5,
- this.enabled = !0,
- this._loader = e
- }
- return a.prototype._assignExtras = function(e, i) {
- if (i.extras && Object.keys(i.extras).length > 0) {
- var o = e.metadata = e.metadata || {}
- , s = o.gltf = o.gltf || {};
- s.extras = i.extras
- }
- }
- ,
- a.prototype.dispose = function() {
- this._loader = null
- }
- ,
- a.prototype.loadNodeAsync = function(e, i, o) {
- var s = this;
- return this._loader.loadNodeAsync(e, i, function(c) {
- s._assignExtras(c, i),
- o(c)
- })
- }
- ,
- a.prototype.loadCameraAsync = function(e, i, o) {
- var s = this;
- return this._loader.loadCameraAsync(e, i, function(c) {
- s._assignExtras(c, i),
- o(c)
- })
- }
- ,
- a.prototype.createMaterial = function(e, i, o) {
- var s = this._loader.createMaterial(e, i, o);
- return this._assignExtras(s, i),
- s
- }
- ,
- a
- }();
- GLTFLoader.RegisterExtension(NAME$5, function(a) {
- return new ExtrasAsMetadata(a)
- });
- var MTLFileLoader = function() {
- function a() {
- this.materials = []
- }
- return a.prototype.parseMTL = function(e, i, o, s) {
- if (!(i instanceof ArrayBuffer)) {
- for (var c = i.split(`
- `), d = /\s+/, _, b = null, k = 0; k < c.length; k++) {
- var j = c[k].trim();
- if (!(j.length === 0 || j.charAt(0) === "#")) {
- var $ = j.indexOf(" ")
- , _e = $ >= 0 ? j.substring(0, $) : j;
- _e = _e.toLowerCase();
- var et = $ >= 0 ? j.substring($ + 1).trim() : "";
- _e === "newmtl" ? (b && this.materials.push(b),
- e._blockEntityCollection = !!s,
- b = new StandardMaterial(et,e),
- b._parentContainer = s,
- e._blockEntityCollection = !1) : _e === "kd" && b ? (_ = et.split(d, 3).map(parseFloat),
- b.diffuseColor = Color3.FromArray(_)) : _e === "ka" && b ? (_ = et.split(d, 3).map(parseFloat),
- b.ambientColor = Color3.FromArray(_)) : _e === "ks" && b ? (_ = et.split(d, 3).map(parseFloat),
- b.specularColor = Color3.FromArray(_)) : _e === "ke" && b ? (_ = et.split(d, 3).map(parseFloat),
- 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)))
- }
- }
- b && this.materials.push(b)
- }
- }
- ,
- a._getTexture = function(e, i, o) {
- if (!i)
- return null;
- var s = e;
- if (e === "file:") {
- var c = i.lastIndexOf("\\");
- c === -1 && (c = i.lastIndexOf("/")),
- c > -1 ? s += i.substr(c + 1) : s += i
- } else
- s += i;
- return new Texture(s,o,!1,a.INVERT_TEXTURE_Y)
- }
- ,
- a.INVERT_TEXTURE_Y = !0,
- a
- }()
- , SolidParser = function() {
- function a(e, i, o) {
- this._positions = [],
- this._normals = [],
- this._uvs = [],
- this._colors = [],
- this._meshesFromObj = [],
- this._indicesForBabylon = [],
- this._wrappedPositionForBabylon = [],
- this._wrappedUvsForBabylon = [],
- this._wrappedColorsForBabylon = [],
- this._wrappedNormalsForBabylon = [],
- this._tuplePosNorm = [],
- this._curPositionInIndices = 0,
- this._hasMeshes = !1,
- this._unwrappedPositionsForBabylon = [],
- this._unwrappedColorsForBabylon = [],
- this._unwrappedNormalsForBabylon = [],
- this._unwrappedUVForBabylon = [],
- this._triangles = [],
- this._materialNameFromObj = "",
- this._objMeshName = "",
- this._increment = 1,
- this._isFirstMaterial = !0,
- this._grayColor = new Color4(.5,.5,.5,1),
- this._materialToUse = e,
- this._babylonMeshesArray = i,
- this._loadingOptions = o
- }
- return a.prototype._isInArray = function(e, i) {
- e[i[0]] || (e[i[0]] = {
- normals: [],
- idx: []
- });
- var o = e[i[0]].normals.indexOf(i[1]);
- return o === -1 ? -1 : e[i[0]].idx[o]
- }
- ,
- a.prototype._isInArrayUV = function(e, i) {
- e[i[0]] || (e[i[0]] = {
- normals: [],
- idx: [],
- uv: []
- });
- var o = e[i[0]].normals.indexOf(i[1]);
- return o != 1 && i[2] === e[i[0]].uv[o] ? e[i[0]].idx[o] : -1
- }
- ,
- a.prototype._setData = function(e, i, o, s, c, d, _) {
- var b;
- this._loadingOptions.optimizeWithUV ? b = this._isInArrayUV(this._tuplePosNorm, [e, o, i]) : b = this._isInArray(this._tuplePosNorm, [e, o]),
- b === -1 ? (this._indicesForBabylon.push(this._wrappedPositionForBabylon.length),
- this._wrappedPositionForBabylon.push(s),
- this._wrappedUvsForBabylon.push(c),
- this._wrappedNormalsForBabylon.push(d),
- _ !== void 0 && this._wrappedColorsForBabylon.push(_),
- this._tuplePosNorm[e].normals.push(o),
- this._tuplePosNorm[e].idx.push(this._curPositionInIndices++),
- this._loadingOptions.optimizeWithUV && this._tuplePosNorm[e].uv.push(i)) : this._indicesForBabylon.push(b)
- }
- ,
- a.prototype._unwrapData = function() {
- for (var e = 0; e < this._wrappedPositionForBabylon.length; e++)
- this._unwrappedPositionsForBabylon.push(this._wrappedPositionForBabylon[e].x, this._wrappedPositionForBabylon[e].y, this._wrappedPositionForBabylon[e].z),
- this._unwrappedNormalsForBabylon.push(this._wrappedNormalsForBabylon[e].x, this._wrappedNormalsForBabylon[e].y, this._wrappedNormalsForBabylon[e].z),
- this._unwrappedUVForBabylon.push(this._wrappedUvsForBabylon[e].x, this._wrappedUvsForBabylon[e].y),
- this._loadingOptions.importVertexColors && this._unwrappedColorsForBabylon.push(this._wrappedColorsForBabylon[e].r, this._wrappedColorsForBabylon[e].g, this._wrappedColorsForBabylon[e].b, this._wrappedColorsForBabylon[e].a);
- this._wrappedPositionForBabylon = [],
- this._wrappedNormalsForBabylon = [],
- this._wrappedUvsForBabylon = [],
- this._wrappedColorsForBabylon = [],
- this._tuplePosNorm = [],
- this._curPositionInIndices = 0
- }
- ,
- a.prototype._getTriangles = function(e, i) {
- for (var o = i; o < e.length - 1; o++)
- this._triangles.push(e[0], e[o], e[o + 1])
- }
- ,
- a.prototype._setDataForCurrentFaceWithPattern1 = function(e, i) {
- this._getTriangles(e, i);
- for (var o = 0; o < this._triangles.length; o++) {
- var s = parseInt(this._triangles[o]) - 1;
- this._setData(s, 0, 0, this._positions[s], Vector2.Zero(), Vector3.Up(), this._loadingOptions.importVertexColors ? this._colors[s] : void 0)
- }
- this._triangles = []
- }
- ,
- a.prototype._setDataForCurrentFaceWithPattern2 = function(e, i) {
- this._getTriangles(e, i);
- for (var o = 0; o < this._triangles.length; o++) {
- var s = this._triangles[o].split("/")
- , c = parseInt(s[0]) - 1
- , d = parseInt(s[1]) - 1;
- this._setData(c, d, 0, this._positions[c], this._uvs[d], Vector3.Up(), this._loadingOptions.importVertexColors ? this._colors[c] : void 0)
- }
- this._triangles = []
- }
- ,
- a.prototype._setDataForCurrentFaceWithPattern3 = function(e, i) {
- this._getTriangles(e, i);
- for (var o = 0; o < this._triangles.length; o++) {
- var s = this._triangles[o].split("/")
- , c = parseInt(s[0]) - 1
- , d = parseInt(s[1]) - 1
- , _ = parseInt(s[2]) - 1;
- this._setData(c, d, _, this._positions[c], this._uvs[d], this._normals[_])
- }
- this._triangles = []
- }
- ,
- a.prototype._setDataForCurrentFaceWithPattern4 = function(e, i) {
- this._getTriangles(e, i);
- for (var o = 0; o < this._triangles.length; o++) {
- var s = this._triangles[o].split("//")
- , c = parseInt(s[0]) - 1
- , d = parseInt(s[1]) - 1;
- this._setData(c, 1, d, this._positions[c], Vector2.Zero(), this._normals[d], this._loadingOptions.importVertexColors ? this._colors[c] : void 0)
- }
- this._triangles = []
- }
- ,
- a.prototype._setDataForCurrentFaceWithPattern5 = function(e, i) {
- this._getTriangles(e, i);
- for (var o = 0; o < this._triangles.length; o++) {
- var s = this._triangles[o].split("/")
- , c = this._positions.length + parseInt(s[0])
- , d = this._uvs.length + parseInt(s[1])
- , _ = this._normals.length + parseInt(s[2]);
- this._setData(c, d, _, this._positions[c], this._uvs[d], this._normals[_], this._loadingOptions.importVertexColors ? this._colors[c] : void 0)
- }
- this._triangles = []
- }
- ,
- a.prototype._addPreviousObjMesh = function() {
- this._meshesFromObj.length > 0 && (this._handledMesh = this._meshesFromObj[this._meshesFromObj.length - 1],
- this._unwrapData(),
- this._indicesForBabylon.reverse(),
- this._handledMesh.indices = this._indicesForBabylon.slice(),
- this._handledMesh.positions = this._unwrappedPositionsForBabylon.slice(),
- this._handledMesh.normals = this._unwrappedNormalsForBabylon.slice(),
- this._handledMesh.uvs = this._unwrappedUVForBabylon.slice(),
- this._loadingOptions.importVertexColors && (this._handledMesh.colors = this._unwrappedColorsForBabylon.slice()),
- this._indicesForBabylon = [],
- this._unwrappedPositionsForBabylon = [],
- this._unwrappedColorsForBabylon = [],
- this._unwrappedNormalsForBabylon = [],
- this._unwrappedUVForBabylon = [])
- }
- ,
- a.prototype._optimizeNormals = function(e) {
- var i = e.getVerticesData(VertexBuffer.PositionKind)
- , o = e.getVerticesData(VertexBuffer.NormalKind)
- , s = {};
- if (!(!i || !o)) {
- for (var c = 0; c < i.length / 3; c++) {
- var d = i[c * 3 + 0]
- , _ = i[c * 3 + 1]
- , b = i[c * 3 + 2]
- , k = d + "_" + _ + "_" + b
- , j = s[k];
- j || (j = [],
- s[k] = j),
- j.push(c)
- }
- var $ = new Vector3;
- for (var k in s) {
- var j = s[k];
- if (!(j.length < 2)) {
- for (var _e = j[0], c = 1; c < j.length; ++c) {
- var et = j[c];
- o[_e * 3 + 0] += o[et * 3 + 0],
- o[_e * 3 + 1] += o[et * 3 + 1],
- o[_e * 3 + 2] += o[et * 3 + 2]
- }
- $.copyFromFloats(o[_e * 3 + 0], o[_e * 3 + 1], o[_e * 3 + 2]),
- $.normalize();
- for (var c = 0; c < j.length; ++c) {
- var et = j[c];
- o[et * 3 + 0] = $.x,
- o[et * 3 + 1] = $.y,
- o[et * 3 + 2] = $.z
- }
- }
- }
- e.setVerticesData(VertexBuffer.NormalKind, o)
- }
- }
- ,
- a.prototype.parse = function(e, i, o, s, c) {
- for (var d, _ = i.split(`
- `), b = 0; b < _.length; b++) {
- var k = _[b].trim().replace(/\s\s/g, " "), j;
- if (!(k.length === 0 || k.charAt(0) === "#"))
- if (a.VertexPattern.test(k)) {
- if (j = k.match(/[^ ]+/g),
- this._positions.push(new Vector3(parseFloat(j[1]),parseFloat(j[2]),parseFloat(j[3]))),
- this._loadingOptions.importVertexColors)
- if (j.length >= 7) {
- var $ = parseFloat(j[4])
- , _e = parseFloat(j[5])
- , et = parseFloat(j[6]);
- 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])))
- } else
- this._colors.push(this._grayColor)
- } else if ((j = a.NormalPattern.exec(k)) !== null)
- this._normals.push(new Vector3(parseFloat(j[1]),parseFloat(j[2]),parseFloat(j[3])));
- else if ((j = a.UVPattern.exec(k)) !== null)
- this._uvs.push(new Vector2(parseFloat(j[1]) * this._loadingOptions.UVScaling.x,parseFloat(j[2]) * this._loadingOptions.UVScaling.y));
- else if ((j = a.FacePattern3.exec(k)) !== null)
- this._setDataForCurrentFaceWithPattern3(j[1].trim().split(" "), 1);
- else if ((j = a.FacePattern4.exec(k)) !== null)
- this._setDataForCurrentFaceWithPattern4(j[1].trim().split(" "), 1);
- else if ((j = a.FacePattern5.exec(k)) !== null)
- this._setDataForCurrentFaceWithPattern5(j[1].trim().split(" "), 1);
- else if ((j = a.FacePattern2.exec(k)) !== null)
- this._setDataForCurrentFaceWithPattern2(j[1].trim().split(" "), 1);
- else if ((j = a.FacePattern1.exec(k)) !== null)
- this._setDataForCurrentFaceWithPattern1(j[1].trim().split(" "), 1);
- else if (a.GroupDescriptor.test(k) || a.ObjectDescriptor.test(k)) {
- var tt = {
- name: k.substring(2).trim(),
- indices: void 0,
- positions: void 0,
- normals: void 0,
- uvs: void 0,
- colors: void 0,
- materialName: ""
- };
- this._addPreviousObjMesh(),
- this._meshesFromObj.push(tt),
- this._hasMeshes = !0,
- this._isFirstMaterial = !0,
- this._increment = 1
- } else if (a.UseMtlDescriptor.test(k)) {
- if (this._materialNameFromObj = k.substring(7).trim(),
- !this._isFirstMaterial || !this._hasMeshes) {
- this._addPreviousObjMesh();
- var tt = {
- name: (this._objMeshName || "mesh") + "_mm" + this._increment.toString(),
- indices: void 0,
- positions: void 0,
- normals: void 0,
- uvs: void 0,
- colors: void 0,
- materialName: this._materialNameFromObj
- };
- this._increment++,
- this._meshesFromObj.push(tt),
- this._hasMeshes = !0
- }
- this._hasMeshes && this._isFirstMaterial && (this._meshesFromObj[this._meshesFromObj.length - 1].materialName = this._materialNameFromObj,
- this._isFirstMaterial = !1)
- } else
- a.MtlLibGroupDescriptor.test(k) ? c(k.substring(7).trim()) : a.SmoothDescriptor.test(k) || console.log("Unhandled expression at line : " + k)
- }
- if (this._hasMeshes && (this._handledMesh = this._meshesFromObj[this._meshesFromObj.length - 1],
- this._indicesForBabylon.reverse(),
- this._unwrapData(),
- this._handledMesh.indices = this._indicesForBabylon,
- this._handledMesh.positions = this._unwrappedPositionsForBabylon,
- this._handledMesh.normals = this._unwrappedNormalsForBabylon,
- this._handledMesh.uvs = this._unwrappedUVForBabylon,
- this._loadingOptions.importVertexColors && (this._handledMesh.colors = this._unwrappedColorsForBabylon)),
- !this._hasMeshes) {
- var rt = null;
- if (this._indicesForBabylon.length)
- this._indicesForBabylon.reverse(),
- this._unwrapData();
- else {
- for (var it = 0, nt = this._positions; it < nt.length; it++) {
- var ot = nt[it];
- this._unwrappedPositionsForBabylon.push(ot.x, ot.y, ot.z)
- }
- if (this._normals.length)
- for (var at = 0, st = this._normals; at < st.length; at++) {
- var ut = st[at];
- this._unwrappedNormalsForBabylon.push(ut.x, ut.y, ut.z)
- }
- if (this._uvs.length)
- for (var ct = 0, lt = this._uvs; ct < lt.length; ct++) {
- var ft = lt[ct];
- this._unwrappedUVForBabylon.push(ft.x, ft.y)
- }
- if (this._colors.length)
- for (var ht = 0, pt = this._colors; ht < pt.length; ht++) {
- var dt = pt[ht];
- this._unwrappedColorsForBabylon.push(dt.r, dt.g, dt.b, dt.a)
- }
- this._materialNameFromObj || (rt = new StandardMaterial(Geometry.RandomId(),o),
- rt.pointsCloud = !0,
- this._materialNameFromObj = rt.name,
- this._normals.length || (rt.disableLighting = !0,
- rt.emissiveColor = Color3.White()))
- }
- this._meshesFromObj.push({
- name: Geometry.RandomId(),
- indices: this._indicesForBabylon,
- positions: this._unwrappedPositionsForBabylon,
- colors: this._unwrappedColorsForBabylon,
- normals: this._unwrappedNormalsForBabylon,
- uvs: this._unwrappedUVForBabylon,
- materialName: this._materialNameFromObj,
- directMaterial: rt
- })
- }
- for (var _t = 0; _t < this._meshesFromObj.length; _t++) {
- if (e && this._meshesFromObj[_t].name) {
- if (e instanceof Array) {
- if (e.indexOf(this._meshesFromObj[_t].name) === -1)
- continue
- } else if (this._meshesFromObj[_t].name !== e)
- continue
- }
- this._handledMesh = this._meshesFromObj[_t],
- o._blockEntityCollection = !!s;
- var mt = new Mesh(this._meshesFromObj[_t].name,o);
- if (mt._parentContainer = s,
- o._blockEntityCollection = !1,
- this._materialToUse.push(this._meshesFromObj[_t].materialName),
- ((d = this._handledMesh.positions) === null || d === void 0 ? void 0 : d.length) === 0) {
- this._babylonMeshesArray.push(mt);
- continue
- }
- var vt = new VertexData;
- if (vt.uvs = this._handledMesh.uvs,
- vt.indices = this._handledMesh.indices,
- vt.positions = this._handledMesh.positions,
- this._loadingOptions.computeNormals) {
- var yt = new Array;
- VertexData.ComputeNormals(this._handledMesh.positions, this._handledMesh.indices, yt),
- vt.normals = yt
- } else
- vt.normals = this._handledMesh.normals;
- this._loadingOptions.importVertexColors && (vt.colors = this._handledMesh.colors),
- vt.applyToMesh(mt),
- this._loadingOptions.invertY && (mt.scaling.y *= -1),
- this._loadingOptions.optimizeNormals && this._optimizeNormals(mt),
- this._babylonMeshesArray.push(mt),
- this._handledMesh.directMaterial && (mt.material = this._handledMesh.directMaterial)
- }
- }
- ,
- a.ObjectDescriptor = /^o/,
- a.GroupDescriptor = /^g/,
- a.MtlLibGroupDescriptor = /^mtllib /,
- a.UseMtlDescriptor = /^usemtl /,
- a.SmoothDescriptor = /^s /,
- a.VertexPattern = /v(\s+[\d|\.|\+|\-|e|E]+){3,7}/,
- a.NormalPattern = /vn(\s+[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/,
- a.UVPattern = /vt(\s+[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/,
- a.FacePattern1 = /f\s+(([\d]{1,}[\s]?){3,})+/,
- a.FacePattern2 = /f\s+((([\d]{1,}\/[\d]{1,}[\s]?){3,})+)/,
- a.FacePattern3 = /f\s+((([\d]{1,}\/[\d]{1,}\/[\d]{1,}[\s]?){3,})+)/,
- a.FacePattern4 = /f\s+((([\d]{1,}\/\/[\d]{1,}[\s]?){3,})+)/,
- a.FacePattern5 = /f\s+(((-[\d]{1,}\/-[\d]{1,}\/-[\d]{1,}[\s]?){3,})+)/,
- a
- }()
- , OBJFileLoader = function() {
- function a(e) {
- this.name = "obj",
- this.extensions = ".obj",
- this._assetContainer = null,
- this._loadingOptions = e || a.DefaultLoadingOptions
- }
- return Object.defineProperty(a, "INVERT_TEXTURE_Y", {
- get: function() {
- return MTLFileLoader.INVERT_TEXTURE_Y
- },
- set: function(e) {
- MTLFileLoader.INVERT_TEXTURE_Y = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a, "DefaultLoadingOptions", {
- get: function() {
- return {
- computeNormals: a.COMPUTE_NORMALS,
- optimizeNormals: a.OPTIMIZE_NORMALS,
- importVertexColors: a.IMPORT_VERTEX_COLORS,
- invertY: a.INVERT_Y,
- invertTextureY: a.INVERT_TEXTURE_Y,
- UVScaling: a.UV_SCALING,
- materialLoadingFailsSilently: a.MATERIAL_LOADING_FAILS_SILENTLY,
- optimizeWithUV: a.OPTIMIZE_WITH_UV,
- skipMaterials: a.SKIP_MATERIALS
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._loadMTL = function(e, i, o, s) {
- var c = i + e;
- Tools.LoadFile(c, o, void 0, void 0, !1, function(d, _) {
- s(c, _)
- })
- }
- ,
- a.prototype.createPlugin = function() {
- return new a(a.DefaultLoadingOptions)
- }
- ,
- a.prototype.canDirectLoad = function(e) {
- return !1
- }
- ,
- a.prototype.importMeshAsync = function(e, i, o, s, c, d) {
- return this._parseSolid(e, i, o, s).then(function(_) {
- return {
- meshes: _,
- particleSystems: [],
- skeletons: [],
- animationGroups: [],
- transformNodes: [],
- geometries: [],
- lights: []
- }
- })
- }
- ,
- a.prototype.loadAsync = function(e, i, o, s, c) {
- return this.importMeshAsync(null, e, i, o, s).then(function() {})
- }
- ,
- a.prototype.loadAssetContainerAsync = function(e, i, o, s, c) {
- var d = this
- , _ = new AssetContainer(e);
- return this._assetContainer = _,
- this.importMeshAsync(null, e, i, o).then(function(b) {
- return b.meshes.forEach(function(k) {
- return _.meshes.push(k)
- }),
- b.meshes.forEach(function(k) {
- var j = k.material;
- if (j && _.materials.indexOf(j) == -1) {
- _.materials.push(j);
- var $ = j.getActiveTextures();
- $.forEach(function(_e) {
- _.textures.indexOf(_e) == -1 && _.textures.push(_e)
- })
- }
- }),
- d._assetContainer = null,
- _
- }).catch(function(b) {
- throw d._assetContainer = null,
- b
- })
- }
- ,
- a.prototype._parseSolid = function(e, i, o, s) {
- var c = this
- , d = ""
- , _ = new MTLFileLoader
- , b = new Array
- , k = []
- , j = new SolidParser(b,k,this._loadingOptions);
- j.parse(e, o, i, this._assetContainer, function(_e) {
- d = _e
- });
- var $ = [];
- return d !== "" && !this._loadingOptions.skipMaterials && $.push(new Promise(function(_e, et) {
- c._loadMTL(d, s, function(tt) {
- try {
- _.parseMTL(i, tt, s, c._assetContainer);
- for (var rt = 0; rt < _.materials.length; rt++) {
- for (var it = 0, nt = [], ot; (ot = b.indexOf(_.materials[rt].name, it)) > -1; )
- nt.push(ot),
- it = ot + 1;
- if (ot === -1 && nt.length === 0)
- _.materials[rt].dispose();
- else
- for (var at = 0; at < nt.length; at++) {
- var st = k[nt[at]]
- , ut = _.materials[rt];
- st.material = ut,
- st.getTotalIndices() || (ut.pointsCloud = !0)
- }
- }
- _e()
- } catch (ct) {
- Tools.Warn("Error processing MTL file: '" + d + "'"),
- c._loadingOptions.materialLoadingFailsSilently ? _e() : et(ct)
- }
- }, function(tt, rt) {
- Tools.Warn("Error downloading MTL file: '" + d + "'"),
- c._loadingOptions.materialLoadingFailsSilently ? _e() : et(rt)
- })
- }
- )),
- Promise.all($).then(function() {
- return k
- })
- }
- ,
- a.OPTIMIZE_WITH_UV = !0,
- a.INVERT_Y = !1,
- a.IMPORT_VERTEX_COLORS = !1,
- a.COMPUTE_NORMALS = !1,
- a.OPTIMIZE_NORMALS = !1,
- a.UV_SCALING = new Vector2(1,1),
- a.SKIP_MATERIALS = !1,
- a.MATERIAL_LOADING_FAILS_SILENTLY = !0,
- a
- }();
- SceneLoader && SceneLoader.RegisterPlugin(new OBJFileLoader);
- var STLFileLoader = function() {
- function a() {
- this.solidPattern = /solid (\S*)([\S\s]*?)endsolid[ ]*(\S*)/g,
- this.facetsPattern = /facet([\s\S]*?)endfacet/g,
- 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,
- 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,
- this.name = "stl",
- this.extensions = {
- ".stl": {
- isBinary: !0
- }
- }
- }
- return a.prototype.importMesh = function(e, i, o, s, c, d, _) {
- var b;
- if (typeof o != "string") {
- if (this._isBinary(o)) {
- var k = new Mesh("stlmesh",i);
- return this._parseBinary(k, o),
- c && c.push(k),
- !0
- }
- for (var j = new Uint8Array(o), $ = "", _e = 0; _e < o.byteLength; _e++)
- $ += String.fromCharCode(j[_e]);
- o = $
- }
- for (; b = this.solidPattern.exec(o); ) {
- var et = b[1]
- , tt = b[3];
- if (et != tt)
- return Tools.Error("Error in STL, solid name != endsolid name"),
- !1;
- if (e && et) {
- if (e instanceof Array) {
- if (!e.indexOf(et))
- continue
- } else if (et !== e)
- continue
- }
- et = et || "stlmesh";
- var k = new Mesh(et,i);
- this._parseASCII(k, b[2]),
- c && c.push(k)
- }
- return !0
- }
- ,
- a.prototype.load = function(e, i, o) {
- var s = this.importMesh(null, e, i, o, null, null, null);
- return s
- }
- ,
- a.prototype.loadAssetContainer = function(e, i, o, s) {
- var c = new AssetContainer(e);
- return e._blockEntityCollection = !0,
- this.importMesh(null, e, i, o, c.meshes, null, null),
- e._blockEntityCollection = !1,
- c
- }
- ,
- a.prototype._isBinary = function(e) {
- var i, o, s;
- if (s = new DataView(e),
- s.byteLength <= 80)
- return !1;
- if (i = 32 / 8 * 3 + 32 / 8 * 3 * 3 + 16 / 8,
- o = s.getUint32(80, !0),
- 80 + 32 / 8 + o * i === s.byteLength)
- return !0;
- for (var c = s.byteLength, d = 0; d < c; d++)
- if (s.getUint8(d) > 127)
- return !0;
- return !1
- }
- ,
- a.prototype._parseBinary = function(e, i) {
- 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++) {
- 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++) {
- var ot = et + nt * 12;
- b[_] = o.getFloat32(ot, !0),
- k[_] = tt,
- a.DO_NOT_ALTER_FILE_COORDINATES ? (b[_ + 1] = o.getFloat32(ot + 4, !0),
- b[_ + 2] = o.getFloat32(ot + 8, !0),
- k[_ + 1] = rt,
- k[_ + 2] = it) : (b[_ + 2] = o.getFloat32(ot + 4, !0),
- b[_ + 1] = o.getFloat32(ot + 8, !0),
- k[_ + 2] = rt,
- k[_ + 1] = it),
- _ += 3
- }
- j[$] = $++,
- j[$] = $++,
- j[$] = $++
- }
- e.setVerticesData(VertexBuffer.PositionKind, b),
- e.setVerticesData(VertexBuffer.NormalKind, k),
- e.setIndices(j),
- e.computeWorldMatrix(!0)
- }
- ,
- a.prototype._parseASCII = function(e, i) {
- for (var o = [], s = [], c = [], d = 0, _; _ = this.facetsPattern.exec(i); ) {
- var b = _[1]
- , k = this.normalPattern.exec(b);
- if (this.normalPattern.lastIndex = 0,
- !!k) {
- for (var j = [Number(k[1]), Number(k[5]), Number(k[3])], $; $ = this.vertexPattern.exec(b); )
- a.DO_NOT_ALTER_FILE_COORDINATES ? (o.push(Number($[1]), Number($[3]), Number($[5])),
- s.push(j[0], j[2], j[1])) : (o.push(Number($[1]), Number($[5]), Number($[3])),
- s.push(j[0], j[1], j[2]));
- c.push(d++, d++, d++),
- this.vertexPattern.lastIndex = 0
- }
- }
- this.facetsPattern.lastIndex = 0,
- e.setVerticesData(VertexBuffer.PositionKind, o),
- e.setVerticesData(VertexBuffer.NormalKind, s),
- e.setIndices(c),
- e.computeWorldMatrix(!0)
- }
- ,
- a.DO_NOT_ALTER_FILE_COORDINATES = !1,
- a
- }();
- SceneLoader && SceneLoader.RegisterPlugin(new STLFileLoader);
- var SoundTrack = function() {
- function a(e, i) {
- i === void 0 && (i = {}),
- this.id = -1,
- this._isInitialized = !1,
- this._scene = e,
- this.soundCollection = new Array,
- this._options = i,
- !this._options.mainTrack && this._scene.soundTracks && (this._scene.soundTracks.push(this),
- this.id = this._scene.soundTracks.length - 1)
- }
- return a.prototype._initializeSoundTrackAudioGraph = function() {
- var e;
- ((e = Engine.audioEngine) === null || e === void 0 ? void 0 : e.canUseWebAudio) && Engine.audioEngine.audioContext && (this._outputAudioNode = Engine.audioEngine.audioContext.createGain(),
- this._outputAudioNode.connect(Engine.audioEngine.masterGain),
- this._options && this._options.volume && (this._outputAudioNode.gain.value = this._options.volume),
- this._isInitialized = !0)
- }
- ,
- a.prototype.dispose = function() {
- if (Engine.audioEngine && Engine.audioEngine.canUseWebAudio) {
- for (this._connectedAnalyser && this._connectedAnalyser.stopDebugCanvas(); this.soundCollection.length; )
- this.soundCollection[0].dispose();
- this._outputAudioNode && this._outputAudioNode.disconnect(),
- this._outputAudioNode = null
- }
- }
- ,
- a.prototype.addSound = function(e) {
- var i;
- this._isInitialized || this._initializeSoundTrackAudioGraph(),
- ((i = Engine.audioEngine) === null || i === void 0 ? void 0 : i.canUseWebAudio) && this._outputAudioNode && e.connectToSoundTrackAudioNode(this._outputAudioNode),
- e.soundTrackId && (e.soundTrackId === -1 ? this._scene.mainSoundTrack.removeSound(e) : this._scene.soundTracks && this._scene.soundTracks[e.soundTrackId].removeSound(e)),
- this.soundCollection.push(e),
- e.soundTrackId = this.id
- }
- ,
- a.prototype.removeSound = function(e) {
- var i = this.soundCollection.indexOf(e);
- i !== -1 && this.soundCollection.splice(i, 1)
- }
- ,
- a.prototype.setVolume = function(e) {
- var i;
- ((i = Engine.audioEngine) === null || i === void 0 ? void 0 : i.canUseWebAudio) && this._outputAudioNode && (this._outputAudioNode.gain.value = e)
- }
- ,
- a.prototype.switchPanningModelToHRTF = function() {
- var e;
- if (!((e = Engine.audioEngine) === null || e === void 0) && e.canUseWebAudio)
- for (var i = 0; i < this.soundCollection.length; i++)
- this.soundCollection[i].switchPanningModelToHRTF()
- }
- ,
- a.prototype.switchPanningModelToEqualPower = function() {
- var e;
- if (!((e = Engine.audioEngine) === null || e === void 0) && e.canUseWebAudio)
- for (var i = 0; i < this.soundCollection.length; i++)
- this.soundCollection[i].switchPanningModelToEqualPower()
- }
- ,
- a.prototype.connectToAnalyser = function(e) {
- var i;
- this._connectedAnalyser && this._connectedAnalyser.stopDebugCanvas(),
- this._connectedAnalyser = e,
- ((i = Engine.audioEngine) === null || i === void 0 ? void 0 : i.canUseWebAudio) && this._outputAudioNode && (this._outputAudioNode.disconnect(),
- this._connectedAnalyser.connectAudioNodes(this._outputAudioNode, Engine.audioEngine.masterGain))
- }
- ,
- a
- }();
- Engine.AudioEngineFactory = function(a, e, i) {
- return new AudioEngine(a,e,i)
- }
- ;
- var AudioEngine = function() {
- function a(e, i, o) {
- var s = this;
- if (e === void 0 && (e = null),
- i === void 0 && (i = null),
- o === void 0 && (o = null),
- this._audioContext = null,
- this._audioContextInitialized = !1,
- this._muteButton = null,
- this._audioDestination = null,
- this.canUseWebAudio = !1,
- this.WarnedWebAudioUnsupported = !1,
- this.isMP3supported = !1,
- this.isOGGsupported = !1,
- this.unlocked = !0,
- this.useCustomUnlockedButton = !1,
- this.onAudioUnlockedObservable = new Observable,
- this.onAudioLockedObservable = new Observable,
- this._tryToRun = !1,
- this._onResize = function() {
- s._moveButtonToTopLeft()
- }
- ,
- !!IsWindowObjectExist()) {
- (typeof window.AudioContext != "undefined" || typeof window.webkitAudioContext != "undefined") && (window.AudioContext = window.AudioContext || window.webkitAudioContext,
- this.canUseWebAudio = !0);
- var c = document.createElement("audio");
- this._hostElement = e,
- this._audioContext = i,
- this._audioDestination = o;
- try {
- c && !!c.canPlayType && (c.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/, "") || c.canPlayType("audio/mp3").replace(/^no$/, "")) && (this.isMP3supported = !0)
- } catch {}
- try {
- c && !!c.canPlayType && c.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, "") && (this.isOGGsupported = !0)
- } catch {}
- }
- }
- return Object.defineProperty(a.prototype, "audioContext", {
- get: function() {
- return this._audioContextInitialized ? !this.unlocked && !this._muteButton && this._displayMuteButton() : this._initializeAudioContext(),
- this._audioContext
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.lock = function() {
- this._triggerSuspendedState()
- }
- ,
- a.prototype.unlock = function() {
- this._triggerRunningState()
- }
- ,
- a.prototype._resumeAudioContext = function() {
- var e;
- return this._audioContext.resume !== void 0 && (e = this._audioContext.resume()),
- e || Promise.resolve()
- }
- ,
- a.prototype._initializeAudioContext = function() {
- try {
- this.canUseWebAudio && (this._audioContext || (this._audioContext = new AudioContext),
- this.masterGain = this._audioContext.createGain(),
- this.masterGain.gain.value = 1,
- this._audioDestination || (this._audioDestination = this._audioContext.destination),
- this.masterGain.connect(this._audioDestination),
- this._audioContextInitialized = !0,
- this._audioContext.state === "running" && this._triggerRunningState())
- } catch (e) {
- this.canUseWebAudio = !1,
- Logger$2.Error("Web Audio: " + e.message)
- }
- }
- ,
- a.prototype._triggerRunningState = function() {
- var e = this;
- this._tryToRun || (this._tryToRun = !0,
- this._resumeAudioContext().then(function() {
- e._tryToRun = !1,
- e._muteButton && e._hideMuteButton(),
- e.unlocked = !0,
- e.onAudioUnlockedObservable.notifyObservers(e)
- }).catch(function() {
- e._tryToRun = !1,
- e.unlocked = !1
- }))
- }
- ,
- a.prototype._triggerSuspendedState = function() {
- this.unlocked = !1,
- this.onAudioLockedObservable.notifyObservers(this),
- this._displayMuteButton()
- }
- ,
- a.prototype._displayMuteButton = function() {
- var e = this;
- if (!(this.useCustomUnlockedButton || this._muteButton)) {
- this._muteButton = document.createElement("BUTTON"),
- this._muteButton.className = "babylonUnmuteIcon",
- this._muteButton.id = "babylonUnmuteIconBtn",
- this._muteButton.title = "Unmute";
- 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"
- , 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) }"
- , s = document.createElement("style");
- s.appendChild(document.createTextNode(o)),
- document.getElementsByTagName("head")[0].appendChild(s),
- document.body.appendChild(this._muteButton),
- this._moveButtonToTopLeft(),
- this._muteButton.addEventListener("touchend", function() {
- e._triggerRunningState()
- }, !0),
- this._muteButton.addEventListener("click", function() {
- e._triggerRunningState()
- }, !0),
- window.addEventListener("resize", this._onResize)
- }
- }
- ,
- a.prototype._moveButtonToTopLeft = function() {
- this._hostElement && this._muteButton && (this._muteButton.style.top = this._hostElement.offsetTop + 20 + "px",
- this._muteButton.style.left = this._hostElement.offsetLeft + 20 + "px")
- }
- ,
- a.prototype._hideMuteButton = function() {
- this._muteButton && (document.body.removeChild(this._muteButton),
- this._muteButton = null)
- }
- ,
- a.prototype.dispose = function() {
- this.canUseWebAudio && this._audioContextInitialized && (this._connectedAnalyser && this._audioContext && (this._connectedAnalyser.stopDebugCanvas(),
- this._connectedAnalyser.dispose(),
- this.masterGain.disconnect(),
- this.masterGain.connect(this._audioContext.destination),
- this._connectedAnalyser = null),
- this.masterGain.gain.value = 1),
- this.WarnedWebAudioUnsupported = !1,
- this._hideMuteButton(),
- window.removeEventListener("resize", this._onResize),
- this.onAudioUnlockedObservable.clear(),
- this.onAudioLockedObservable.clear()
- }
- ,
- a.prototype.getGlobalVolume = function() {
- return this.canUseWebAudio && this._audioContextInitialized ? this.masterGain.gain.value : -1
- }
- ,
- a.prototype.setGlobalVolume = function(e) {
- this.canUseWebAudio && this._audioContextInitialized && (this.masterGain.gain.value = e)
- }
- ,
- a.prototype.connectToAnalyser = function(e) {
- this._connectedAnalyser && this._connectedAnalyser.stopDebugCanvas(),
- this.canUseWebAudio && this._audioContextInitialized && this._audioContext && (this._connectedAnalyser = e,
- this.masterGain.disconnect(),
- this._connectedAnalyser.connectAudioNodes(this.masterGain, this._audioContext.destination))
- }
- ,
- a
- }();
- AbstractScene.AddParser(SceneComponentConstants.NAME_AUDIO, function(a, e, i, o) {
- var s, c = [], d;
- if (i.sounds = i.sounds || [],
- a.sounds !== void 0 && a.sounds !== null)
- for (var _ = 0, b = a.sounds.length; _ < b; _++) {
- var k = a.sounds[_];
- !((s = Engine.audioEngine) === null || s === void 0) && s.canUseWebAudio ? (k.url || (k.url = k.name),
- c[k.url] ? i.sounds.push(Sound.Parse(k, e, o, c[k.url])) : (d = Sound.Parse(k, e, o),
- c[k.url] = d,
- i.sounds.push(d))) : i.sounds.push(new Sound(k.name,null,e))
- }
- c = []
- });
- Object.defineProperty(Scene.prototype, "mainSoundTrack", {
- get: function() {
- var a = this._getComponent(SceneComponentConstants.NAME_AUDIO);
- return a || (a = new AudioSceneComponent(this),
- this._addComponent(a)),
- this._mainSoundTrack || (this._mainSoundTrack = new SoundTrack(this,{
- mainTrack: !0
- })),
- this._mainSoundTrack
- },
- enumerable: !0,
- configurable: !0
- });
- Scene.prototype.getSoundByName = function(a) {
- var e;
- for (e = 0; e < this.mainSoundTrack.soundCollection.length; e++)
- if (this.mainSoundTrack.soundCollection[e].name === a)
- return this.mainSoundTrack.soundCollection[e];
- if (this.soundTracks) {
- for (var i = 0; i < this.soundTracks.length; i++)
- for (e = 0; e < this.soundTracks[i].soundCollection.length; e++)
- if (this.soundTracks[i].soundCollection[e].name === a)
- return this.soundTracks[i].soundCollection[e]
- }
- return null
- }
- ;
- Object.defineProperty(Scene.prototype, "audioEnabled", {
- get: function() {
- var a = this._getComponent(SceneComponentConstants.NAME_AUDIO);
- return a || (a = new AudioSceneComponent(this),
- this._addComponent(a)),
- a.audioEnabled
- },
- set: function(a) {
- var e = this._getComponent(SceneComponentConstants.NAME_AUDIO);
- e || (e = new AudioSceneComponent(this),
- this._addComponent(e)),
- a ? e.enableAudio() : e.disableAudio()
- },
- enumerable: !0,
- configurable: !0
- });
- Object.defineProperty(Scene.prototype, "headphone", {
- get: function() {
- var a = this._getComponent(SceneComponentConstants.NAME_AUDIO);
- return a || (a = new AudioSceneComponent(this),
- this._addComponent(a)),
- a.headphone
- },
- set: function(a) {
- var e = this._getComponent(SceneComponentConstants.NAME_AUDIO);
- e || (e = new AudioSceneComponent(this),
- this._addComponent(e)),
- a ? e.switchAudioModeForHeadphones() : e.switchAudioModeForNormalSpeakers()
- },
- enumerable: !0,
- configurable: !0
- });
- Object.defineProperty(Scene.prototype, "audioListenerPositionProvider", {
- get: function() {
- var a = this._getComponent(SceneComponentConstants.NAME_AUDIO);
- return a || (a = new AudioSceneComponent(this),
- this._addComponent(a)),
- a.audioListenerPositionProvider
- },
- set: function(a) {
- var e = this._getComponent(SceneComponentConstants.NAME_AUDIO);
- if (e || (e = new AudioSceneComponent(this),
- this._addComponent(e)),
- typeof a != "function")
- throw new Error("The value passed to [Scene.audioListenerPositionProvider] must be a function that returns a Vector3");
- e.audioListenerPositionProvider = a
- },
- enumerable: !0,
- configurable: !0
- });
- Object.defineProperty(Scene.prototype, "audioPositioningRefreshRate", {
- get: function() {
- var a = this._getComponent(SceneComponentConstants.NAME_AUDIO);
- return a || (a = new AudioSceneComponent(this),
- this._addComponent(a)),
- a.audioPositioningRefreshRate
- },
- set: function(a) {
- var e = this._getComponent(SceneComponentConstants.NAME_AUDIO);
- e || (e = new AudioSceneComponent(this),
- this._addComponent(e)),
- e.audioPositioningRefreshRate = a
- },
- enumerable: !0,
- configurable: !0
- });
- var AudioSceneComponent = function() {
- function a(e) {
- this.name = SceneComponentConstants.NAME_AUDIO,
- this._audioEnabled = !0,
- this._headphone = !1,
- this.audioPositioningRefreshRate = 500,
- this._audioListenerPositionProvider = null,
- this._cachedCameraDirection = new Vector3,
- this._cachedCameraPosition = new Vector3,
- this._lastCheck = 0,
- this.scene = e,
- e.soundTracks = new Array,
- e.sounds = new Array
- }
- return Object.defineProperty(a.prototype, "audioEnabled", {
- get: function() {
- return this._audioEnabled
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "headphone", {
- get: function() {
- return this._headphone
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "audioListenerPositionProvider", {
- get: function() {
- return this._audioListenerPositionProvider
- },
- set: function(e) {
- this._audioListenerPositionProvider = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.register = function() {
- this.scene._afterRenderStage.registerStep(SceneComponentConstants.STEP_AFTERRENDER_AUDIO, this, this._afterRender)
- }
- ,
- a.prototype.rebuild = function() {}
- ,
- a.prototype.serialize = function(e) {
- if (e.sounds = [],
- this.scene.soundTracks)
- for (var i = 0; i < this.scene.soundTracks.length; i++)
- for (var o = this.scene.soundTracks[i], s = 0; s < o.soundCollection.length; s++)
- e.sounds.push(o.soundCollection[s].serialize())
- }
- ,
- a.prototype.addFromContainer = function(e) {
- var i = this;
- !e.sounds || e.sounds.forEach(function(o) {
- o.play(),
- o.autoplay = !0,
- i.scene.mainSoundTrack.addSound(o)
- })
- }
- ,
- a.prototype.removeFromContainer = function(e, i) {
- var o = this;
- i === void 0 && (i = !1),
- e.sounds && e.sounds.forEach(function(s) {
- s.stop(),
- s.autoplay = !1,
- o.scene.mainSoundTrack.removeSound(s),
- i && s.dispose()
- })
- }
- ,
- a.prototype.dispose = function() {
- var e = this.scene;
- if (e._mainSoundTrack && e.mainSoundTrack.dispose(),
- e.soundTracks)
- for (var i = 0; i < e.soundTracks.length; i++)
- e.soundTracks[i].dispose()
- }
- ,
- a.prototype.disableAudio = function() {
- var e = this.scene;
- this._audioEnabled = !1,
- Engine.audioEngine && Engine.audioEngine.audioContext && Engine.audioEngine.audioContext.suspend();
- var i;
- for (i = 0; i < e.mainSoundTrack.soundCollection.length; i++)
- e.mainSoundTrack.soundCollection[i].pause();
- if (e.soundTracks)
- for (i = 0; i < e.soundTracks.length; i++)
- for (var o = 0; o < e.soundTracks[i].soundCollection.length; o++)
- e.soundTracks[i].soundCollection[o].pause()
- }
- ,
- a.prototype.enableAudio = function() {
- var e = this.scene;
- this._audioEnabled = !0,
- Engine.audioEngine && Engine.audioEngine.audioContext && Engine.audioEngine.audioContext.resume();
- var i;
- for (i = 0; i < e.mainSoundTrack.soundCollection.length; i++)
- e.mainSoundTrack.soundCollection[i].isPaused && e.mainSoundTrack.soundCollection[i].play();
- if (e.soundTracks)
- for (i = 0; i < e.soundTracks.length; i++)
- for (var o = 0; o < e.soundTracks[i].soundCollection.length; o++)
- e.soundTracks[i].soundCollection[o].isPaused && e.soundTracks[i].soundCollection[o].play()
- }
- ,
- a.prototype.switchAudioModeForHeadphones = function() {
- var e = this.scene;
- if (this._headphone = !0,
- e.mainSoundTrack.switchPanningModelToHRTF(),
- e.soundTracks)
- for (var i = 0; i < e.soundTracks.length; i++)
- e.soundTracks[i].switchPanningModelToHRTF()
- }
- ,
- a.prototype.switchAudioModeForNormalSpeakers = function() {
- var e = this.scene;
- if (this._headphone = !1,
- e.mainSoundTrack.switchPanningModelToEqualPower(),
- e.soundTracks)
- for (var i = 0; i < e.soundTracks.length; i++)
- e.soundTracks[i].switchPanningModelToEqualPower()
- }
- ,
- a.prototype._afterRender = function() {
- var e = PrecisionDate.Now;
- if (!(this._lastCheck && e - this._lastCheck < this.audioPositioningRefreshRate)) {
- this._lastCheck = e;
- var i = this.scene;
- if (!(!this._audioEnabled || !i._mainSoundTrack || !i.soundTracks || i._mainSoundTrack.soundCollection.length === 0 && i.soundTracks.length === 1)) {
- var o = Engine.audioEngine;
- if (!!o && o.audioContext) {
- if (this._audioListenerPositionProvider) {
- var s = this._audioListenerPositionProvider();
- s.x = s.x || 0,
- s.y = s.y || 0,
- s.z = s.z || 0,
- o.audioContext.listener.setPosition(s.x, s.y, s.z)
- } else {
- var c;
- if (i.activeCameras && i.activeCameras.length > 0 ? c = i.activeCameras[0] : c = i.activeCamera,
- c) {
- this._cachedCameraPosition.equals(c.globalPosition) || (this._cachedCameraPosition.copyFrom(c.globalPosition),
- o.audioContext.listener.setPosition(c.globalPosition.x, c.globalPosition.y, c.globalPosition.z)),
- c.rigCameras && c.rigCameras.length > 0 && (c = c.rigCameras[0]);
- var d = Matrix.Invert(c.getViewMatrix())
- , _ = Vector3.TransformNormal(a._CameraDirection, d);
- _.normalize(),
- !isNaN(_.x) && !isNaN(_.y) && !isNaN(_.z) && (this._cachedCameraDirection.equals(_) || (this._cachedCameraDirection.copyFrom(_),
- o.audioContext.listener.setOrientation(_.x, _.y, _.z, 0, 1, 0)))
- } else
- o.audioContext.listener.setPosition(0, 0, 0)
- }
- var b;
- for (b = 0; b < i.mainSoundTrack.soundCollection.length; b++) {
- var k = i.mainSoundTrack.soundCollection[b];
- k.useCustomAttenuation && k.updateDistanceFromListener()
- }
- if (i.soundTracks)
- for (b = 0; b < i.soundTracks.length; b++)
- for (var j = 0; j < i.soundTracks[b].soundCollection.length; j++)
- k = i.soundTracks[b].soundCollection[j],
- k.useCustomAttenuation && k.updateDistanceFromListener()
- }
- }
- }
- }
- ,
- a._CameraDirection = new Vector3(0,0,-1),
- a
- }();
- Sound._SceneComponentInitialization = function(a) {
- var e = a._getComponent(SceneComponentConstants.NAME_AUDIO);
- e || (e = new AudioSceneComponent(a),
- a._addComponent(e))
- }
- ;
- var DefaultLoadingScreen = function() {
- function a(e, i, o) {
- var s = this;
- i === void 0 && (i = ""),
- o === void 0 && (o = "black"),
- this._renderingCanvas = e,
- this._loadingText = i,
- this._loadingDivBackgroundColor = o,
- this._resizeLoadingUI = function() {
- var c = s._renderingCanvas.getBoundingClientRect()
- , d = window.getComputedStyle(s._renderingCanvas).position;
- !s._loadingDiv || (s._loadingDiv.style.position = d === "fixed" ? "fixed" : "absolute",
- s._loadingDiv.style.left = c.left + "px",
- s._loadingDiv.style.top = c.top + "px",
- s._loadingDiv.style.width = c.width + "px",
- s._loadingDiv.style.height = c.height + "px")
- }
- }
- return a.prototype.displayLoadingUI = function() {
- if (!this._loadingDiv) {
- this._loadingDiv = document.createElement("div"),
- this._loadingDiv.id = "babylonjsLoadingDiv",
- this._loadingDiv.style.opacity = "0",
- this._loadingDiv.style.transition = "opacity 1.5s ease",
- this._loadingDiv.style.pointerEvents = "none",
- this._loadingDiv.style.display = "grid",
- this._loadingDiv.style.gridTemplateRows = "100%",
- this._loadingDiv.style.gridTemplateColumns = "100%",
- this._loadingDiv.style.justifyItems = "center",
- this._loadingDiv.style.alignItems = "center",
- this._loadingTextDiv = document.createElement("div"),
- this._loadingTextDiv.style.position = "absolute",
- this._loadingTextDiv.style.left = "0",
- this._loadingTextDiv.style.top = "50%",
- this._loadingTextDiv.style.marginTop = "80px",
- this._loadingTextDiv.style.width = "100%",
- this._loadingTextDiv.style.height = "20px",
- this._loadingTextDiv.style.fontFamily = "Arial",
- this._loadingTextDiv.style.fontSize = "14px",
- this._loadingTextDiv.style.color = "white",
- this._loadingTextDiv.style.textAlign = "center",
- this._loadingTextDiv.style.zIndex = "1",
- this._loadingTextDiv.innerHTML = "Loading",
- this._loadingDiv.appendChild(this._loadingTextDiv),
- this._loadingTextDiv.innerHTML = this._loadingText,
- this._style = document.createElement("style"),
- this._style.type = "text/css";
- var e = `@-webkit-keyframes spin1 { 0% { -webkit-transform: rotate(0deg);}
- 100% { -webkit-transform: rotate(360deg);}
- } @keyframes spin1 { 0% { transform: rotate(0deg);}
- 100% { transform: rotate(360deg);}
- }`;
- this._style.innerHTML = e,
- document.getElementsByTagName("head")[0].appendChild(this._style);
- var i = !!window.SVGSVGElement
- , o = new Image;
- 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",
- o.style.width = "150px",
- o.style.gridColumn = "1",
- o.style.gridRow = "1",
- o.style.top = "50%",
- o.style.left = "50%",
- o.style.transform = "translate(-50%, -50%)",
- o.style.position = "absolute";
- var s = document.createElement("div");
- s.style.width = "300px",
- s.style.gridColumn = "1",
- s.style.gridRow = "1",
- s.style.top = "50%",
- s.style.left = "50%",
- s.style.transform = "translate(-50%, -50%)",
- s.style.position = "absolute";
- var c = new Image;
- 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",
- c.style.animation = "spin1 0.75s infinite linear",
- c.style.webkitAnimation = "spin1 0.75s infinite linear",
- c.style.transformOrigin = "50% 50%",
- c.style.webkitTransformOrigin = "50% 50%",
- !i) {
- var d = {
- w: 16,
- h: 18.5
- }
- , _ = {
- w: 30,
- h: 30
- };
- o.style.width = d.w + "vh",
- o.style.height = d.h + "vh",
- o.style.left = "calc(50% - " + d.w / 2 + "vh)",
- o.style.top = "calc(50% - " + d.h / 2 + "vh)",
- c.style.width = _.w + "vh",
- c.style.height = _.h + "vh",
- c.style.left = "calc(50% - " + _.w / 2 + "vh)",
- c.style.top = "calc(50% - " + _.h / 2 + "vh)"
- }
- s.appendChild(c),
- this._loadingDiv.appendChild(o),
- this._loadingDiv.appendChild(s),
- this._resizeLoadingUI(),
- window.addEventListener("resize", this._resizeLoadingUI),
- this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor,
- document.body.appendChild(this._loadingDiv),
- this._loadingDiv.style.opacity = "1"
- }
- }
- ,
- a.prototype.hideLoadingUI = function() {
- var e = this;
- if (!!this._loadingDiv) {
- var i = function() {
- e._loadingDiv && (e._loadingDiv.parentElement && e._loadingDiv.parentElement.removeChild(e._loadingDiv),
- e._loadingDiv = null),
- e._style && (e._style.parentElement && e._style.parentElement.removeChild(e._style),
- e._style = null),
- window.removeEventListener("resize", e._resizeLoadingUI)
- };
- this._loadingDiv.style.opacity = "0",
- this._loadingDiv.addEventListener("transitionend", i)
- }
- }
- ,
- Object.defineProperty(a.prototype, "loadingUIText", {
- get: function() {
- return this._loadingText
- },
- set: function(e) {
- this._loadingText = e,
- this._loadingTextDiv && (this._loadingTextDiv.innerHTML = this._loadingText)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "loadingUIBackgroundColor", {
- get: function() {
- return this._loadingDivBackgroundColor
- },
- set: function(e) {
- this._loadingDivBackgroundColor = e,
- this._loadingDiv && (this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor)
- },
- enumerable: !1,
- configurable: !0
- }),
- a.DefaultLogoUrl = "",
- a.DefaultSpinnerUrl = "",
- a
- }();
- Engine.DefaultLoadingScreenFactory = function(a) {
- return new DefaultLoadingScreen(a)
- }
- ;
- var PanoramaToCubeMapTools = function() {
- function a() {}
- return a.ConvertPanoramaToCubemap = function(e, i, o, s) {
- if (!e)
- throw "ConvertPanoramaToCubemap: input cannot be null";
- if (e.length != i * o * 3)
- throw "ConvertPanoramaToCubemap: input size is wrong";
- var c = this.CreateCubemapTexture(s, this.FACE_FRONT, e, i, o)
- , d = this.CreateCubemapTexture(s, this.FACE_BACK, e, i, o)
- , _ = this.CreateCubemapTexture(s, this.FACE_LEFT, e, i, o)
- , b = this.CreateCubemapTexture(s, this.FACE_RIGHT, e, i, o)
- , k = this.CreateCubemapTexture(s, this.FACE_UP, e, i, o)
- , j = this.CreateCubemapTexture(s, this.FACE_DOWN, e, i, o);
- return {
- front: c,
- back: d,
- left: _,
- right: b,
- up: k,
- down: j,
- size: s,
- type: 1,
- format: 4,
- gammaSpace: !1
- }
- }
- ,
- a.CreateCubemapTexture = function(e, i, o, s, c) {
- 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++) {
- for (var et = i[0], tt = i[2], rt = 0; rt < e; rt++) {
- var it = tt.subtract(et).scale($).add(et);
- it.normalize();
- var nt = this.CalcProjectionSpherical(it, o, s, c);
- _[_e * e * 3 + rt * 3 + 0] = nt.r,
- _[_e * e * 3 + rt * 3 + 1] = nt.g,
- _[_e * e * 3 + rt * 3 + 2] = nt.b,
- et = et.add(b),
- tt = tt.add(k)
- }
- $ += j
- }
- return _
- }
- ,
- a.CalcProjectionSpherical = function(e, i, o, s) {
- for (var c = Math.atan2(e.z, e.x), d = Math.acos(e.y); c < -Math.PI; )
- c += 2 * Math.PI;
- for (; c > Math.PI; )
- c -= 2 * Math.PI;
- var _ = c / Math.PI
- , b = d / Math.PI;
- _ = _ * .5 + .5;
- var k = Math.round(_ * o);
- k < 0 ? k = 0 : k >= o && (k = o - 1);
- var j = Math.round(b * s);
- j < 0 ? j = 0 : j >= s && (j = s - 1);
- var $ = s - j - 1
- , _e = i[$ * o * 3 + k * 3 + 0]
- , et = i[$ * o * 3 + k * 3 + 1]
- , tt = i[$ * o * 3 + k * 3 + 2];
- return {
- r: _e,
- g: et,
- b: tt
- }
- }
- ,
- a.FACE_LEFT = [new Vector3(-1,-1,-1), new Vector3(1,-1,-1), new Vector3(-1,1,-1), new Vector3(1,1,-1)],
- a.FACE_RIGHT = [new Vector3(1,-1,1), new Vector3(-1,-1,1), new Vector3(1,1,1), new Vector3(-1,1,1)],
- a.FACE_FRONT = [new Vector3(1,-1,-1), new Vector3(1,-1,1), new Vector3(1,1,-1), new Vector3(1,1,1)],
- a.FACE_BACK = [new Vector3(-1,-1,1), new Vector3(-1,-1,-1), new Vector3(-1,1,1), new Vector3(-1,1,-1)],
- a.FACE_DOWN = [new Vector3(1,1,-1), new Vector3(1,1,1), new Vector3(-1,1,-1), new Vector3(-1,1,1)],
- a.FACE_UP = [new Vector3(-1,-1,-1), new Vector3(-1,-1,1), new Vector3(1,-1,-1), new Vector3(1,-1,1)],
- a
- }()
- , HDRTools = function() {
- function a() {}
- return a.Ldexp = function(e, i) {
- 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)
- }
- ,
- a.Rgbe2float = function(e, i, o, s, c, d) {
- c > 0 ? (c = this.Ldexp(1, c - (128 + 8)),
- e[d + 0] = i * c,
- e[d + 1] = o * c,
- e[d + 2] = s * c) : (e[d + 0] = 0,
- e[d + 1] = 0,
- e[d + 2] = 0)
- }
- ,
- a.readStringLine = function(e, i) {
- for (var o = "", s = "", c = i; c < e.length - i && (s = String.fromCharCode(e[c]),
- s != `
- `); c++)
- o += s;
- return o
- }
- ,
- a.RGBE_ReadHeader = function(e) {
- var i = 0
- , o = 0
- , s = this.readStringLine(e, 0);
- if (s[0] != "#" || s[1] != "?")
- throw "Bad HDR Format.";
- var c = !1
- , d = !1
- , _ = 0;
- do
- _ += s.length + 1,
- s = this.readStringLine(e, _),
- s == "FORMAT=32-bit_rle_rgbe" ? d = !0 : s.length == 0 && (c = !0);
- while (!c);
- if (!d)
- throw "HDR Bad header format, unsupported FORMAT";
- _ += s.length + 1,
- s = this.readStringLine(e, _);
- var b = /^\-Y (.*) \+X (.*)$/g
- , k = b.exec(s);
- if (!k || k.length < 3)
- throw "HDR Bad header format, no size";
- if (o = parseInt(k[2]),
- i = parseInt(k[1]),
- o < 8 || o > 32767)
- throw "HDR Bad header format, unsupported size";
- return _ += s.length + 1,
- {
- height: i,
- width: o,
- dataPosition: _
- }
- }
- ,
- a.GetCubeMapTextureData = function(e, i) {
- var o = new Uint8Array(e)
- , s = this.RGBE_ReadHeader(o)
- , c = this.RGBE_ReadPixels(o, s)
- , d = PanoramaToCubeMapTools.ConvertPanoramaToCubemap(c, s.width, s.height, i);
- return d
- }
- ,
- a.RGBE_ReadPixels = function(e, i) {
- return this.RGBE_ReadPixels_RLE(e, i)
- }
- ,
- a.RGBE_ReadPixels_RLE = function(e, i) {
- 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; ) {
- if (c = e[j++],
- d = e[j++],
- _ = e[j++],
- b = e[j++],
- c != 2 || d != 2 || _ & 128 || i.width < 8 || i.width > 32767)
- return this.RGBE_ReadPixels_NOT_RLE(e, i);
- if ((_ << 8 | b) != s)
- throw "HDR Bad header format, wrong scan line width";
- for ($ = 0,
- et = 0; et < 4; et++)
- for (_e = (et + 1) * s; $ < _e; )
- if (c = e[j++],
- d = e[j++],
- c > 128) {
- if (k = c - 128,
- k == 0 || k > _e - $)
- throw "HDR Bad Format, bad scanline data (run)";
- for (; k-- > 0; )
- rt[$++] = d
- } else {
- if (k = c,
- k == 0 || k > _e - $)
- throw "HDR Bad Format, bad scanline data (non-run)";
- if (rt[$++] = d,
- --k > 0)
- for (var ot = 0; ot < k; ot++)
- rt[$++] = e[j++]
- }
- for (et = 0; et < s; et++)
- c = rt[et],
- d = rt[et + s],
- _ = rt[et + 2 * s],
- b = rt[et + 3 * s],
- this.Rgbe2float(nt, c, d, _, b, (i.height - o) * s * 3 + et * 3);
- o--
- }
- return nt
- }
- ,
- a.RGBE_ReadPixels_NOT_RLE = function(e, i) {
- 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; ) {
- for (k = 0; k < i.width; k++)
- c = e[j++],
- d = e[j++],
- _ = e[j++],
- b = e[j++],
- this.Rgbe2float(_e, c, d, _, b, (i.height - o) * s * 3 + k * 3);
- o--
- }
- return _e
- }
- ,
- a
- }()
- , EffectRenderer = function() {
- function a(e, i) {
- var o, s = this;
- i === void 0 && (i = a._DefaultOptions),
- this.engine = e,
- this._fullscreenViewport = new Viewport(0,0,1,1),
- i = __assign(__assign({}, a._DefaultOptions), i),
- this._vertexBuffers = (o = {},
- o[VertexBuffer.PositionKind] = new VertexBuffer(e,i.positions,VertexBuffer.PositionKind,!1,!1,2),
- o),
- this._indexBuffer = e.createIndexBuffer(i.indices),
- this._onContextRestoredObserver = e.onContextRestoredObservable.add(function() {
- s._indexBuffer = e.createIndexBuffer(i.indices);
- for (var c in s._vertexBuffers) {
- var d = s._vertexBuffers[c];
- d._rebuild()
- }
- })
- }
- return a.prototype.setViewport = function(e) {
- e === void 0 && (e = this._fullscreenViewport),
- this.engine.setViewport(e)
- }
- ,
- a.prototype.bindBuffers = function(e) {
- this.engine.bindBuffers(this._vertexBuffers, this._indexBuffer, e)
- }
- ,
- a.prototype.applyEffectWrapper = function(e) {
- this.engine.depthCullingState.depthTest = !1,
- this.engine.stencilState.stencilTest = !1,
- this.engine.enableEffect(e._drawWrapper),
- this.bindBuffers(e.effect),
- e.onApplyObservable.notifyObservers({})
- }
- ,
- a.prototype.restoreStates = function() {
- this.engine.depthCullingState.depthTest = !0,
- this.engine.stencilState.stencilTest = !0
- }
- ,
- a.prototype.draw = function() {
- this.engine.drawElementsType(0, 0, 6)
- }
- ,
- a.prototype.isRenderTargetTexture = function(e) {
- return e.renderTarget !== void 0
- }
- ,
- a.prototype.render = function(e, i) {
- if (i === void 0 && (i = null),
- !!e.effect.isReady()) {
- this.setViewport();
- var o = i === null ? null : this.isRenderTargetTexture(i) ? i.renderTarget : i;
- o && this.engine.bindFramebuffer(o),
- this.applyEffectWrapper(e),
- this.draw(),
- o && this.engine.unBindFramebuffer(o),
- this.restoreStates()
- }
- }
- ,
- a.prototype.dispose = function() {
- var e = this._vertexBuffers[VertexBuffer.PositionKind];
- e && (e.dispose(),
- delete this._vertexBuffers[VertexBuffer.PositionKind]),
- this._indexBuffer && this.engine._releaseBuffer(this._indexBuffer),
- this._onContextRestoredObserver && (this.engine.onContextRestoredObservable.remove(this._onContextRestoredObserver),
- this._onContextRestoredObserver = null)
- }
- ,
- a._DefaultOptions = {
- positions: [1, 1, -1, 1, -1, -1, 1, -1],
- indices: [0, 1, 2, 0, 2, 3]
- },
- a
- }()
- , EffectWrapper = function() {
- function a(e) {
- var i = this;
- this.onApplyObservable = new Observable;
- var o, s = e.uniformNames || [];
- e.vertexShader ? o = {
- fragmentSource: e.fragmentShader,
- vertexSource: e.vertexShader,
- spectorName: e.name || "effectWrapper"
- } : (s.push("scale"),
- o = {
- fragmentSource: e.fragmentShader,
- vertex: "postprocess",
- spectorName: e.name || "effectWrapper"
- },
- this.onApplyObservable.add(function() {
- i.effect.setFloat2("scale", 1, 1)
- }));
- var c = e.defines ? e.defines.join(`
- `) : "";
- this._drawWrapper = new DrawWrapper(e.engine),
- e.useShaderStore ? (o.fragment = o.fragmentSource,
- o.vertex || (o.vertex = o.vertexSource),
- delete o.fragmentSource,
- delete o.vertexSource,
- 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),
- this._onContextRestoredObserver = e.engine.onContextRestoredObservable.add(function() {
- i.effect._pipelineContext = null,
- i.effect._wasPreviouslyReady = !1,
- i.effect._prepareEffect()
- }))
- }
- return Object.defineProperty(a.prototype, "effect", {
- get: function() {
- return this._drawWrapper.effect
- },
- set: function(e) {
- this._drawWrapper.effect = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.dispose = function() {
- this._onContextRestoredObserver && (this.effect.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),
- this._onContextRestoredObserver = null),
- this.effect.dispose()
- }
- ,
- a
- }()
- , name$c = "hdrFilteringVertexShader"
- , shader$c = `
- attribute vec2 position;
- varying vec3 direction;
- uniform vec3 up;
- uniform vec3 right;
- uniform vec3 front;
- void main(void) {
- mat3 view=mat3(up,right,front);
- direction=view*vec3(position,1.0);
- gl_Position=vec4(position,0.0,1.0);
- }`;
- ShaderStore.ShadersStore[name$c] = shader$c;
- var name$b = "hdrFilteringPixelShader"
- , shader$b = `#include<helperFunctions>
- #include<importanceSampling>
- #include<pbrBRDFFunctions>
- #include<hdrFilteringFunctions>
- uniform float alphaG;
- uniform samplerCube inputTexture;
- uniform vec2 vFilteringInfo;
- uniform float hdrScale;
- varying vec3 direction;
- void main() {
- vec3 color=radiance(alphaG,inputTexture,direction,vFilteringInfo);
- gl_FragColor=vec4(color*hdrScale,1.0);
- }`;
- ShaderStore.ShadersStore[name$b] = shader$b;
- var HDRFiltering = function() {
- function a(e, i) {
- i === void 0 && (i = {}),
- this._lodGenerationOffset = 0,
- this._lodGenerationScale = .8,
- this.quality = 4096,
- this.hdrScale = 1,
- this._engine = e,
- this.hdrScale = i.hdrScale || this.hdrScale,
- this.quality = i.hdrScale || this.quality
- }
- return a.prototype._createRenderTarget = function(e) {
- var i = 0;
- this._engine.getCaps().textureHalfFloatRender ? i = 2 : this._engine.getCaps().textureFloatRender && (i = 1);
- var o = this._engine.createRenderTargetCubeTexture(e, {
- format: 5,
- type: i,
- createMipMaps: !0,
- generateMipMaps: !1,
- generateDepthBuffer: !1,
- generateStencilBuffer: !1,
- samplingMode: 1
- });
- return this._engine.updateTextureWrappingMode(o.texture, 0, 0, 0),
- this._engine.updateTextureSamplingMode(3, o.texture, !0),
- o
- }
- ,
- a.prototype._prefilterInternal = function(e) {
- var i = e.getSize().width
- , o = Scalar.ILog2(i) + 1
- , s = this._effectWrapper.effect
- , c = this._createRenderTarget(i);
- this._effectRenderer.setViewport();
- var d = e.getInternalTexture();
- d && this._engine.updateTextureSamplingMode(3, d, !0),
- this._effectRenderer.applyEffectWrapper(this._effectWrapper);
- 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)]];
- s.setFloat("hdrScale", this.hdrScale),
- s.setFloat2("vFilteringInfo", e.getSize().width, o),
- s.setTexture("inputTexture", e);
- for (var b = 0; b < 6; b++) {
- s.setVector3("up", _[b][0]),
- s.setVector3("right", _[b][1]),
- s.setVector3("front", _[b][2]);
- for (var k = 0; k < o; k++) {
- this._engine.bindFramebuffer(c, b, void 0, void 0, !0, k),
- this._effectRenderer.applyEffectWrapper(this._effectWrapper);
- var j = Math.pow(2, (k - this._lodGenerationOffset) / this._lodGenerationScale) / i;
- k === 0 && (j = 0),
- s.setFloat("alphaG", j),
- this._effectRenderer.draw()
- }
- }
- return this._effectRenderer.restoreStates(),
- this._engine.restoreDefaultFramebuffer(),
- this._engine._releaseTexture(e._texture),
- c._swapAndDie(e._texture),
- e._prefiltered = !0,
- e
- }
- ,
- a.prototype._createEffect = function(e, i) {
- var o = [];
- e.gammaSpace && o.push("#define GAMMA_INPUT"),
- o.push("#define NUM_SAMPLES " + this.quality + "u");
- var s = new EffectWrapper({
- engine: this._engine,
- name: "hdrFiltering",
- vertexShader: "hdrFiltering",
- fragmentShader: "hdrFiltering",
- samplerNames: ["inputTexture"],
- uniformNames: ["vSampleDirections", "vWeights", "up", "right", "front", "vFilteringInfo", "hdrScale", "alphaG"],
- useShaderStore: !0,
- defines: o,
- onCompiled: i
- });
- return s
- }
- ,
- a.prototype.isReady = function(e) {
- return e.isReady() && this._effectWrapper.effect.isReady()
- }
- ,
- a.prototype.prefilter = function(e, i) {
- var o = this;
- return i === void 0 && (i = null),
- this._engine._features.allowTexturePrefiltering ? new Promise(function(s) {
- o._effectRenderer = new EffectRenderer(o._engine),
- o._effectWrapper = o._createEffect(e),
- o._effectWrapper.effect.executeWhenCompiled(function() {
- o._prefilterInternal(e),
- o._effectRenderer.dispose(),
- o._effectWrapper.dispose(),
- s(),
- i && i()
- })
- }
- ) : (Logger$2.Warn("HDR prefiltering is not available in WebGL 1., you can use real time filtering instead."),
- Promise.reject("HDR prefiltering is not available in WebGL 1., you can use real time filtering instead."))
- }
- ,
- a
- }()
- , HDRCubeTexture = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _, b, k, j) {
- c === void 0 && (c = !1),
- d === void 0 && (d = !0),
- _ === void 0 && (_ = !1),
- b === void 0 && (b = !1),
- k === void 0 && (k = null),
- j === void 0 && (j = null);
- var $, _e = a.call(this, o) || this;
- return _e._generateHarmonics = !0,
- _e._onError = null,
- _e._isBlocking = !0,
- _e._rotationY = 0,
- _e.boundingBoxPosition = Vector3.Zero(),
- _e.onLoadObservable = new Observable,
- i && (_e._coordinatesMode = Texture.CUBIC_MODE,
- _e.name = i,
- _e.url = i,
- _e.hasAlpha = !1,
- _e.isCube = !0,
- _e._textureMatrix = Matrix.Identity(),
- _e._prefilterOnLoad = b,
- _e._onLoad = function() {
- _e.onLoadObservable.notifyObservers(_e),
- k && k()
- }
- ,
- _e._onError = j,
- _e.gammaSpace = _,
- _e._noMipmap = c,
- _e._size = s,
- _e._generateHarmonics = d,
- _e._texture = _e._getFromCache(i, _e._noMipmap),
- _e._texture ? _e._texture.isReady ? Tools.SetImmediate(function() {
- return _e._onLoad()
- }) : _e._texture.onLoadedObservable.add(_e._onLoad) : !(($ = _e.getScene()) === null || $ === void 0) && $.useDelayedTextureLoading ? _e.delayLoadState = 4 : _e.loadTexture()),
- _e
- }
- return Object.defineProperty(e.prototype, "isBlocking", {
- get: function() {
- return this._isBlocking
- },
- set: function(i) {
- this._isBlocking = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "rotationY", {
- get: function() {
- return this._rotationY
- },
- set: function(i) {
- this._rotationY = i,
- this.setReflectionTextureMatrix(Matrix.RotationY(this._rotationY))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "boundingBoxSize", {
- get: function() {
- return this._boundingBoxSize
- },
- set: function(i) {
- if (!(this._boundingBoxSize && this._boundingBoxSize.equals(i))) {
- this._boundingBoxSize = i;
- var o = this.getScene();
- o && o.markAllMaterialsAsDirty(1)
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getClassName = function() {
- return "HDRCubeTexture"
- }
- ,
- e.prototype.loadTexture = function() {
- var i = this
- , o = this._getEngine()
- , s = o.getCaps()
- , c = 0;
- s.textureFloat && s.textureFloatLinearFiltering ? c = 1 : s.textureHalfFloat && s.textureHalfFloatLinearFiltering && (c = 2);
- var d = function(k) {
- i.lodGenerationOffset = 0,
- i.lodGenerationScale = .8;
- var j = HDRTools.GetCubeMapTextureData(k, i._size);
- if (i._generateHarmonics) {
- var $ = CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial(j);
- i.sphericalPolynomial = $
- }
- for (var _e = [], et = null, tt = null, rt = 0; rt < 6; rt++) {
- c === 2 ? tt = new Uint16Array(i._size * i._size * 3) : c === 0 && (et = new Uint8Array(i._size * i._size * 3));
- var it = j[e._facesMapping[rt]];
- if (i.gammaSpace || tt || et) {
- for (var nt = 0; nt < i._size * i._size; nt++)
- if (i.gammaSpace && (it[nt * 3 + 0] = Math.pow(it[nt * 3 + 0], ToGammaSpace),
- it[nt * 3 + 1] = Math.pow(it[nt * 3 + 1], ToGammaSpace),
- it[nt * 3 + 2] = Math.pow(it[nt * 3 + 2], ToGammaSpace)),
- tt && (tt[nt * 3 + 0] = ToHalfFloat(it[nt * 3 + 0]),
- tt[nt * 3 + 1] = ToHalfFloat(it[nt * 3 + 1]),
- tt[nt * 3 + 2] = ToHalfFloat(it[nt * 3 + 2])),
- et) {
- var ot = Math.max(it[nt * 3 + 0] * 255, 0)
- , at = Math.max(it[nt * 3 + 1] * 255, 0)
- , st = Math.max(it[nt * 3 + 2] * 255, 0)
- , ut = Math.max(Math.max(ot, at), st);
- if (ut > 255) {
- var ct = 255 / ut;
- ot *= ct,
- at *= ct,
- st *= ct
- }
- et[nt * 3 + 0] = ot,
- et[nt * 3 + 1] = at,
- et[nt * 3 + 2] = st
- }
- }
- tt ? _e.push(tt) : et ? _e.push(et) : _e.push(it)
- }
- return _e
- };
- if (o._features.allowTexturePrefiltering && this._prefilterOnLoad) {
- var _ = this._onLoad
- , b = new HDRFiltering(o);
- this._onLoad = function() {
- b.prefilter(i, _)
- }
- }
- this._texture = o.createRawCubeTextureFromUrl(this.url, this.getScene(), this._size, 4, c, this._noMipmap, d, null, this._onLoad, this._onError)
- }
- ,
- e.prototype.clone = function() {
- var i = new e(this.url,this.getScene() || this._getEngine(),this._size,this._noMipmap,this._generateHarmonics,this.gammaSpace);
- return i.level = this.level,
- i.wrapU = this.wrapU,
- i.wrapV = this.wrapV,
- i.coordinatesIndex = this.coordinatesIndex,
- i.coordinatesMode = this.coordinatesMode,
- i
- }
- ,
- e.prototype.delayLoad = function() {
- this.delayLoadState === 4 && (this.delayLoadState = 1,
- this._texture = this._getFromCache(this.url, this._noMipmap),
- this._texture || this.loadTexture())
- }
- ,
- e.prototype.getReflectionTextureMatrix = function() {
- return this._textureMatrix
- }
- ,
- e.prototype.setReflectionTextureMatrix = function(i) {
- var o = this, s;
- this._textureMatrix = i,
- i.updateFlag !== this._textureMatrix.updateFlag && i.isIdentity() !== this._textureMatrix.isIdentity() && ((s = this.getScene()) === null || s === void 0 || s.markAllMaterialsAsDirty(1, function(c) {
- return c.getActiveTextures().indexOf(o) !== -1
- }))
- }
- ,
- e.prototype.dispose = function() {
- this.onLoadObservable.clear(),
- a.prototype.dispose.call(this)
- }
- ,
- e.Parse = function(i, o, s) {
- var c = null;
- return i.name && !i.isRenderTarget && (c = new e(s + i.name,o,i.size,i.noMipmap,i.generateHarmonics,i.useInGammaSpace),
- c.name = i.name,
- c.hasAlpha = i.hasAlpha,
- c.level = i.level,
- c.coordinatesMode = i.coordinatesMode,
- c.isBlocking = i.isBlocking),
- c && (i.boundingBoxPosition && (c.boundingBoxPosition = Vector3.FromArray(i.boundingBoxPosition)),
- i.boundingBoxSize && (c.boundingBoxSize = Vector3.FromArray(i.boundingBoxSize)),
- i.rotationY && (c.rotationY = i.rotationY)),
- c
- }
- ,
- e.prototype.serialize = function() {
- if (!this.name)
- return null;
- var i = {};
- return i.name = this.name,
- i.hasAlpha = this.hasAlpha,
- i.isCube = !0,
- i.level = this.level,
- i.size = this._size,
- i.coordinatesMode = this.coordinatesMode,
- i.useInGammaSpace = this.gammaSpace,
- i.generateHarmonics = this._generateHarmonics,
- i.customType = "BABYLON.HDRCubeTexture",
- i.noMipmap = this._noMipmap,
- i.isBlocking = this._isBlocking,
- i.rotationY = this._rotationY,
- i
- }
- ,
- e._facesMapping = ["right", "left", "up", "down", "front", "back"],
- e
- }(BaseTexture);
- RegisterClass("BABYLON.HDRCubeTexture", HDRCubeTexture);
- var PhysicsJoint = function() {
- function a(e, i) {
- this.type = e,
- this.jointData = i,
- i.nativeParams = i.nativeParams || {}
- }
- return Object.defineProperty(a.prototype, "physicsJoint", {
- get: function() {
- return this._physicsJoint
- },
- set: function(e) {
- this._physicsJoint,
- this._physicsJoint = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "physicsPlugin", {
- set: function(e) {
- this._physicsPlugin = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.executeNativeFunction = function(e) {
- e(this._physicsPlugin.world, this._physicsJoint)
- }
- ,
- a.DistanceJoint = 0,
- a.HingeJoint = 1,
- a.BallAndSocketJoint = 2,
- a.WheelJoint = 3,
- a.SliderJoint = 4,
- a.PrismaticJoint = 5,
- a.UniversalJoint = 6,
- a.Hinge2Joint = a.WheelJoint,
- a.PointToPointJoint = 8,
- a.SpringJoint = 9,
- a.LockJoint = 10,
- a
- }();
- (function(a) {
- __extends(e, a);
- function e(i) {
- return a.call(this, PhysicsJoint.DistanceJoint, i) || this
- }
- return e.prototype.updateDistance = function(i, o) {
- this._physicsPlugin.updateDistanceJoint(this, i, o)
- }
- ,
- e
- }
- )(PhysicsJoint);
- var MotorEnabledJoint = function(a) {
- __extends(e, a);
- function e(i, o) {
- return a.call(this, i, o) || this
- }
- return e.prototype.setMotor = function(i, o) {
- this._physicsPlugin.setMotor(this, i || 0, o)
- }
- ,
- e.prototype.setLimit = function(i, o) {
- this._physicsPlugin.setLimit(this, i, o)
- }
- ,
- e
- }(PhysicsJoint);
- (function(a) {
- __extends(e, a);
- function e(i) {
- return a.call(this, PhysicsJoint.HingeJoint, i) || this
- }
- return e.prototype.setMotor = function(i, o) {
- this._physicsPlugin.setMotor(this, i || 0, o)
- }
- ,
- e.prototype.setLimit = function(i, o) {
- this._physicsPlugin.setLimit(this, i, o)
- }
- ,
- e
- }
- )(MotorEnabledJoint);
- (function(a) {
- __extends(e, a);
- function e(i) {
- return a.call(this, PhysicsJoint.Hinge2Joint, i) || this
- }
- return e.prototype.setMotor = function(i, o, s) {
- s === void 0 && (s = 0),
- this._physicsPlugin.setMotor(this, i || 0, o, s)
- }
- ,
- e.prototype.setLimit = function(i, o, s) {
- s === void 0 && (s = 0),
- this._physicsPlugin.setLimit(this, i, o, s)
- }
- ,
- e
- }
- )(MotorEnabledJoint);
- Mesh._PhysicsImpostorParser = function(a, e, i) {
- return new PhysicsImpostor(e,i.physicsImpostor,{
- mass: i.physicsMass,
- friction: i.physicsFriction,
- restitution: i.physicsRestitution
- },a)
- }
- ;
- var PhysicsImpostor = function() {
- function a(e, i, o, s) {
- var c = this;
- if (o === void 0 && (o = {
- mass: 0
- }),
- this.object = e,
- this.type = i,
- this._options = o,
- this._scene = s,
- this._pluginData = {},
- this._bodyUpdateRequired = !1,
- this._onBeforePhysicsStepCallbacks = new Array,
- this._onAfterPhysicsStepCallbacks = new Array,
- this._onPhysicsCollideCallbacks = [],
- this._deltaPosition = Vector3.Zero(),
- this._isDisposed = !1,
- this.soft = !1,
- this.segments = 0,
- this._tmpQuat = new Quaternion,
- this._tmpQuat2 = new Quaternion,
- this.beforeStep = function() {
- !c._physicsEngine || (c.object.translate(c._deltaPosition, -1),
- c._deltaRotationConjugated && c.object.rotationQuaternion && c.object.rotationQuaternion.multiplyToRef(c._deltaRotationConjugated, c.object.rotationQuaternion),
- c.object.computeWorldMatrix(!1),
- c.object.parent && c.object.rotationQuaternion ? (c.getParentsRotation(),
- c._tmpQuat.multiplyToRef(c.object.rotationQuaternion, c._tmpQuat)) : c._tmpQuat.copyFrom(c.object.rotationQuaternion || new Quaternion),
- c._options.disableBidirectionalTransformation || c.object.rotationQuaternion && c._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(c, c.object.getAbsolutePosition(), c._tmpQuat),
- c._onBeforePhysicsStepCallbacks.forEach(function(d) {
- d(c)
- }))
- }
- ,
- this.afterStep = function() {
- !c._physicsEngine || (c._onAfterPhysicsStepCallbacks.forEach(function(d) {
- d(c)
- }),
- c._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(c),
- c.object.parent && c.object.rotationQuaternion && (c.getParentsRotation(),
- c._tmpQuat.conjugateInPlace(),
- c._tmpQuat.multiplyToRef(c.object.rotationQuaternion, c.object.rotationQuaternion)),
- c.object.setAbsolutePosition(c.object.position),
- c._deltaRotation && c.object.rotationQuaternion && c.object.rotationQuaternion.multiplyToRef(c._deltaRotation, c.object.rotationQuaternion),
- c.object.translate(c._deltaPosition, 1))
- }
- ,
- this.onCollideEvent = null,
- this.onCollide = function(d) {
- if (!(!c._onPhysicsCollideCallbacks.length && !c.onCollideEvent) && !!c._physicsEngine) {
- var _ = c._physicsEngine.getImpostorWithPhysicsBody(d.body);
- _ && (c.onCollideEvent && c.onCollideEvent(c, _),
- c._onPhysicsCollideCallbacks.filter(function(b) {
- return b.otherImpostors.indexOf(_) !== -1
- }).forEach(function(b) {
- b.callback(c, _, d.point)
- }))
- }
- }
- ,
- !this.object) {
- Logger$2.Error("No object was provided. A physics object is obligatory");
- return
- }
- 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."),
- !this._scene && e.getScene && (this._scene = e.getScene()),
- this._scene && (this.type > 100 && (this.soft = !0),
- this._physicsEngine = this._scene.getPhysicsEngine(),
- 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),
- this._options.mass = o.mass === void 0 ? 0 : o.mass,
- this._options.friction = o.friction === void 0 ? .2 : o.friction,
- this._options.restitution = o.restitution === void 0 ? .2 : o.restitution,
- this.soft && (this._options.mass = this._options.mass > 0 ? this._options.mass : 1,
- this._options.pressure = o.pressure === void 0 ? 200 : o.pressure,
- this._options.stiffness = o.stiffness === void 0 ? 1 : o.stiffness,
- this._options.velocityIterations = o.velocityIterations === void 0 ? 20 : o.velocityIterations,
- this._options.positionIterations = o.positionIterations === void 0 ? 20 : o.positionIterations,
- this._options.fixedPoints = o.fixedPoints === void 0 ? 0 : o.fixedPoints,
- this._options.margin = o.margin === void 0 ? 0 : o.margin,
- this._options.damping = o.damping === void 0 ? 0 : o.damping,
- this._options.path = o.path === void 0 ? null : o.path,
- this._options.shape = o.shape === void 0 ? null : o.shape),
- this._joints = [],
- !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."))
- }
- return Object.defineProperty(a.prototype, "isDisposed", {
- get: function() {
- return this._isDisposed
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "mass", {
- get: function() {
- return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyMass(this) : 0
- },
- set: function(e) {
- this.setMass(e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "friction", {
- get: function() {
- return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyFriction(this) : 0
- },
- set: function(e) {
- !this._physicsEngine || this._physicsEngine.getPhysicsPlugin().setBodyFriction(this, e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "restitution", {
- get: function() {
- return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this) : 0
- },
- set: function(e) {
- !this._physicsEngine || this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this, e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "pressure", {
- get: function() {
- if (!this._physicsEngine)
- return 0;
- var e = this._physicsEngine.getPhysicsPlugin();
- return e.setBodyPressure ? e.getBodyPressure(this) : 0
- },
- set: function(e) {
- if (!!this._physicsEngine) {
- var i = this._physicsEngine.getPhysicsPlugin();
- !i.setBodyPressure || i.setBodyPressure(this, e)
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "stiffness", {
- get: function() {
- if (!this._physicsEngine)
- return 0;
- var e = this._physicsEngine.getPhysicsPlugin();
- return e.getBodyStiffness ? e.getBodyStiffness(this) : 0
- },
- set: function(e) {
- if (!!this._physicsEngine) {
- var i = this._physicsEngine.getPhysicsPlugin();
- !i.setBodyStiffness || i.setBodyStiffness(this, e)
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "velocityIterations", {
- get: function() {
- if (!this._physicsEngine)
- return 0;
- var e = this._physicsEngine.getPhysicsPlugin();
- return e.getBodyVelocityIterations ? e.getBodyVelocityIterations(this) : 0
- },
- set: function(e) {
- if (!!this._physicsEngine) {
- var i = this._physicsEngine.getPhysicsPlugin();
- !i.setBodyVelocityIterations || i.setBodyVelocityIterations(this, e)
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "positionIterations", {
- get: function() {
- if (!this._physicsEngine)
- return 0;
- var e = this._physicsEngine.getPhysicsPlugin();
- return e.getBodyPositionIterations ? e.getBodyPositionIterations(this) : 0
- },
- set: function(e) {
- if (!!this._physicsEngine) {
- var i = this._physicsEngine.getPhysicsPlugin();
- !i.setBodyPositionIterations || i.setBodyPositionIterations(this, e)
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._init = function() {
- !this._physicsEngine || (this._physicsEngine.removeImpostor(this),
- this.physicsBody = null,
- this._parent = this._parent || this._getPhysicsParent(),
- !this._isDisposed && (!this.parent || this._options.ignoreParent) && this._physicsEngine.addImpostor(this))
- }
- ,
- a.prototype._getPhysicsParent = function() {
- if (this.object.parent instanceof AbstractMesh) {
- var e = this.object.parent;
- return e.physicsImpostor
- }
- return null
- }
- ,
- a.prototype.isBodyInitRequired = function() {
- return this._bodyUpdateRequired || !this._physicsBody && !this._parent
- }
- ,
- a.prototype.setScalingUpdated = function() {
- this.forceUpdate()
- }
- ,
- a.prototype.forceUpdate = function() {
- this._init(),
- this.parent && !this._options.ignoreParent && this.parent.forceUpdate()
- }
- ,
- Object.defineProperty(a.prototype, "physicsBody", {
- get: function() {
- return this._parent && !this._options.ignoreParent ? this._parent.physicsBody : this._physicsBody
- },
- set: function(e) {
- this._physicsBody && this._physicsEngine && this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this),
- this._physicsBody = e,
- this.resetUpdateFlags()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "parent", {
- get: function() {
- return !this._options.ignoreParent && this._parent ? this._parent : null
- },
- set: function(e) {
- this._parent = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.resetUpdateFlags = function() {
- this._bodyUpdateRequired = !1
- }
- ,
- a.prototype.getObjectExtendSize = function() {
- if (this.object.getBoundingInfo) {
- var e = this.object.rotationQuaternion
- , i = this.object.scaling.clone();
- this.object.rotationQuaternion = a.IDENTITY_QUATERNION;
- var o = this.object.computeWorldMatrix && this.object.computeWorldMatrix(!0);
- o && o.decompose(i, void 0, void 0);
- var s = this.object.getBoundingInfo()
- , c = s.boundingBox.extendSize.scale(2).multiplyInPlace(i);
- return c.x = Math.abs(c.x),
- c.y = Math.abs(c.y),
- c.z = Math.abs(c.z),
- this.object.rotationQuaternion = e,
- this.object.computeWorldMatrix && this.object.computeWorldMatrix(!0),
- c
- } else
- return a.DEFAULT_OBJECT_SIZE
- }
- ,
- a.prototype.getObjectCenter = function() {
- if (this.object.getBoundingInfo) {
- var e = this.object.getBoundingInfo();
- return e.boundingBox.centerWorld
- } else
- return this.object.position
- }
- ,
- a.prototype.getParam = function(e) {
- return this._options[e]
- }
- ,
- a.prototype.setParam = function(e, i) {
- this._options[e] = i,
- this._bodyUpdateRequired = !0
- }
- ,
- a.prototype.setMass = function(e) {
- this.getParam("mass") !== e && this.setParam("mass", e),
- this._physicsEngine && this._physicsEngine.getPhysicsPlugin().setBodyMass(this, e)
- }
- ,
- a.prototype.getLinearVelocity = function() {
- return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this) : Vector3.Zero()
- }
- ,
- a.prototype.setLinearVelocity = function(e) {
- this._physicsEngine && this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this, e)
- }
- ,
- a.prototype.getAngularVelocity = function() {
- return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this) : Vector3.Zero()
- }
- ,
- a.prototype.setAngularVelocity = function(e) {
- this._physicsEngine && this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this, e)
- }
- ,
- a.prototype.executeNativeFunction = function(e) {
- this._physicsEngine && e(this._physicsEngine.getPhysicsPlugin().world, this.physicsBody)
- }
- ,
- a.prototype.registerBeforePhysicsStep = function(e) {
- this._onBeforePhysicsStepCallbacks.push(e)
- }
- ,
- a.prototype.unregisterBeforePhysicsStep = function(e) {
- var i = this._onBeforePhysicsStepCallbacks.indexOf(e);
- i > -1 ? this._onBeforePhysicsStepCallbacks.splice(i, 1) : Logger$2.Warn("Function to remove was not found")
- }
- ,
- a.prototype.registerAfterPhysicsStep = function(e) {
- this._onAfterPhysicsStepCallbacks.push(e)
- }
- ,
- a.prototype.unregisterAfterPhysicsStep = function(e) {
- var i = this._onAfterPhysicsStepCallbacks.indexOf(e);
- i > -1 ? this._onAfterPhysicsStepCallbacks.splice(i, 1) : Logger$2.Warn("Function to remove was not found")
- }
- ,
- a.prototype.registerOnPhysicsCollide = function(e, i) {
- var o = e instanceof Array ? e : [e];
- this._onPhysicsCollideCallbacks.push({
- callback: i,
- otherImpostors: o
- })
- }
- ,
- a.prototype.unregisterOnPhysicsCollide = function(e, i) {
- var o = e instanceof Array ? e : [e]
- , s = -1
- , c = this._onPhysicsCollideCallbacks.some(function(d, _) {
- if (d.callback === i && d.otherImpostors.length === o.length) {
- var b = d.otherImpostors.every(function(k) {
- return o.indexOf(k) > -1
- });
- return b && (s = _),
- b
- }
- return !1
- });
- c ? this._onPhysicsCollideCallbacks.splice(s, 1) : Logger$2.Warn("Function to remove was not found")
- }
- ,
- a.prototype.getParentsRotation = function() {
- var e = this.object.parent;
- for (this._tmpQuat.copyFromFloats(0, 0, 0, 1); e; )
- e.rotationQuaternion ? this._tmpQuat2.copyFrom(e.rotationQuaternion) : Quaternion.RotationYawPitchRollToRef(e.rotation.y, e.rotation.x, e.rotation.z, this._tmpQuat2),
- this._tmpQuat.multiplyToRef(this._tmpQuat2, this._tmpQuat),
- e = e.parent;
- return this._tmpQuat
- }
- ,
- a.prototype.applyForce = function(e, i) {
- return this._physicsEngine && this._physicsEngine.getPhysicsPlugin().applyForce(this, e, i),
- this
- }
- ,
- a.prototype.applyImpulse = function(e, i) {
- return this._physicsEngine && this._physicsEngine.getPhysicsPlugin().applyImpulse(this, e, i),
- this
- }
- ,
- a.prototype.createJoint = function(e, i, o) {
- var s = new PhysicsJoint(i,o);
- return this.addJoint(e, s),
- this
- }
- ,
- a.prototype.addJoint = function(e, i) {
- return this._joints.push({
- otherImpostor: e,
- joint: i
- }),
- this._physicsEngine && this._physicsEngine.addJoint(this, e, i),
- this
- }
- ,
- a.prototype.addAnchor = function(e, i, o, s, c) {
- if (!this._physicsEngine)
- return this;
- var d = this._physicsEngine.getPhysicsPlugin();
- return d.appendAnchor ? (this._physicsEngine && d.appendAnchor(this, e, i, o, s, c),
- this) : this
- }
- ,
- a.prototype.addHook = function(e, i, o, s) {
- if (!this._physicsEngine)
- return this;
- var c = this._physicsEngine.getPhysicsPlugin();
- return c.appendAnchor ? (this._physicsEngine && c.appendHook(this, e, i, o, s),
- this) : this
- }
- ,
- a.prototype.sleep = function() {
- return this._physicsEngine && this._physicsEngine.getPhysicsPlugin().sleepBody(this),
- this
- }
- ,
- a.prototype.wakeUp = function() {
- return this._physicsEngine && this._physicsEngine.getPhysicsPlugin().wakeUpBody(this),
- this
- }
- ,
- a.prototype.clone = function(e) {
- return e ? new a(e,this.type,this._options,this._scene) : null
- }
- ,
- a.prototype.dispose = function() {
- var e = this;
- !this._physicsEngine || (this._joints.forEach(function(i) {
- e._physicsEngine && e._physicsEngine.removeJoint(e, i.otherImpostor, i.joint)
- }),
- this._physicsEngine.removeImpostor(this),
- this.parent && this.parent.forceUpdate(),
- this._isDisposed = !0)
- }
- ,
- a.prototype.setDeltaPosition = function(e) {
- this._deltaPosition.copyFrom(e)
- }
- ,
- a.prototype.setDeltaRotation = function(e) {
- this._deltaRotation || (this._deltaRotation = new Quaternion),
- this._deltaRotation.copyFrom(e),
- this._deltaRotationConjugated = this._deltaRotation.conjugate()
- }
- ,
- a.prototype.getBoxSizeToRef = function(e) {
- return this._physicsEngine && this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this, e),
- this
- }
- ,
- a.prototype.getRadius = function() {
- return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getRadius(this) : 0
- }
- ,
- a.prototype.syncBoneWithImpostor = function(e, i, o, s, c) {
- var d = a._tmpVecs[0]
- , _ = this.object;
- if (_.rotationQuaternion)
- if (c) {
- var b = a._tmpQuat;
- _.rotationQuaternion.multiplyToRef(c, b),
- e.setRotationQuaternion(b, Space.WORLD, i)
- } else
- e.setRotationQuaternion(_.rotationQuaternion, Space.WORLD, i);
- d.x = 0,
- d.y = 0,
- d.z = 0,
- o && (d.x = o.x,
- d.y = o.y,
- d.z = o.z,
- e.getDirectionToRef(d, i, d),
- s == null && (s = o.length()),
- d.x *= s,
- d.y *= s,
- d.z *= s),
- e.getParent() ? (d.addInPlace(_.getAbsolutePosition()),
- e.setAbsolutePosition(d, i)) : (i.setAbsolutePosition(_.getAbsolutePosition()),
- i.position.x -= d.x,
- i.position.y -= d.y,
- i.position.z -= d.z)
- }
- ,
- a.prototype.syncImpostorWithBone = function(e, i, o, s, c, d) {
- var _ = this.object;
- if (_.rotationQuaternion)
- if (c) {
- var b = a._tmpQuat;
- e.getRotationQuaternionToRef(Space.WORLD, i, b),
- b.multiplyToRef(c, _.rotationQuaternion)
- } else
- e.getRotationQuaternionToRef(Space.WORLD, i, _.rotationQuaternion);
- var k = a._tmpVecs[0]
- , j = a._tmpVecs[1];
- d || (d = a._tmpVecs[2],
- d.x = 0,
- d.y = 1,
- d.z = 0),
- e.getDirectionToRef(d, i, j),
- e.getAbsolutePositionToRef(i, k),
- s == null && o && (s = o.length()),
- s != null && (k.x += j.x * s,
- k.y += j.y * s,
- k.z += j.z * s),
- _.setAbsolutePosition(k)
- }
- ,
- a.DEFAULT_OBJECT_SIZE = new Vector3(1,1,1),
- a.IDENTITY_QUATERNION = Quaternion.Identity(),
- a._tmpVecs = ArrayTools.BuildArray(3, Vector3.Zero),
- a._tmpQuat = Quaternion.Identity(),
- a.NoImpostor = 0,
- a.SphereImpostor = 1,
- a.BoxImpostor = 2,
- a.PlaneImpostor = 3,
- a.MeshImpostor = 4,
- a.CapsuleImpostor = 6,
- a.CylinderImpostor = 7,
- a.ParticleImpostor = 8,
- a.HeightmapImpostor = 9,
- a.ConvexHullImpostor = 10,
- a.CustomImpostor = 100,
- a.RopeImpostor = 101,
- a.ClothImpostor = 102,
- a.SoftbodyImpostor = 103,
- a
- }()
- , PhysicsEngine = function() {
- function a(e, i) {
- if (i === void 0 && (i = a.DefaultPluginFactory()),
- this._physicsPlugin = i,
- this._impostors = [],
- this._joints = [],
- this._subTimeStep = 0,
- !this._physicsPlugin.isSupported())
- throw new Error("Physics Engine " + this._physicsPlugin.name + " cannot be found. Please make sure it is included.");
- e = e || new Vector3(0,-9.807,0),
- this.setGravity(e),
- this.setTimeStep()
- }
- return a.DefaultPluginFactory = function() {
- throw _WarnImport("CannonJSPlugin")
- }
- ,
- a.prototype.setGravity = function(e) {
- this.gravity = e,
- this._physicsPlugin.setGravity(this.gravity)
- }
- ,
- a.prototype.setTimeStep = function(e) {
- e === void 0 && (e = 1 / 60),
- this._physicsPlugin.setTimeStep(e)
- }
- ,
- a.prototype.getTimeStep = function() {
- return this._physicsPlugin.getTimeStep()
- }
- ,
- a.prototype.setSubTimeStep = function(e) {
- e === void 0 && (e = 0),
- this._subTimeStep = e
- }
- ,
- a.prototype.getSubTimeStep = function() {
- return this._subTimeStep
- }
- ,
- a.prototype.dispose = function() {
- this._impostors.forEach(function(e) {
- e.dispose()
- }),
- this._physicsPlugin.dispose()
- }
- ,
- a.prototype.getPhysicsPluginName = function() {
- return this._physicsPlugin.name
- }
- ,
- a.prototype.addImpostor = function(e) {
- e.uniqueId = this._impostors.push(e),
- e.parent || this._physicsPlugin.generatePhysicsBody(e)
- }
- ,
- a.prototype.removeImpostor = function(e) {
- var i = this._impostors.indexOf(e);
- if (i > -1) {
- var o = this._impostors.splice(i, 1);
- o.length && this.getPhysicsPlugin().removePhysicsBody(e)
- }
- }
- ,
- a.prototype.addJoint = function(e, i, o) {
- var s = {
- mainImpostor: e,
- connectedImpostor: i,
- joint: o
- };
- o.physicsPlugin = this._physicsPlugin,
- this._joints.push(s),
- this._physicsPlugin.generateJoint(s)
- }
- ,
- a.prototype.removeJoint = function(e, i, o) {
- var s = this._joints.filter(function(c) {
- return c.connectedImpostor === i && c.joint === o && c.mainImpostor === e
- });
- s.length && this._physicsPlugin.removeJoint(s[0])
- }
- ,
- a.prototype._step = function(e) {
- var i = this;
- this._impostors.forEach(function(o) {
- o.isBodyInitRequired() && i._physicsPlugin.generatePhysicsBody(o)
- }),
- e > .1 ? e = .1 : e <= 0 && (e = 1 / 60),
- this._physicsPlugin.executeStep(e, this._impostors)
- }
- ,
- a.prototype.getPhysicsPlugin = function() {
- return this._physicsPlugin
- }
- ,
- a.prototype.getImpostors = function() {
- return this._impostors
- }
- ,
- a.prototype.getImpostorForPhysicsObject = function(e) {
- for (var i = 0; i < this._impostors.length; ++i)
- if (this._impostors[i].object === e)
- return this._impostors[i];
- return null
- }
- ,
- a.prototype.getImpostorWithPhysicsBody = function(e) {
- for (var i = 0; i < this._impostors.length; ++i)
- if (this._impostors[i].physicsBody === e)
- return this._impostors[i];
- return null
- }
- ,
- a.prototype.raycast = function(e, i) {
- return this._physicsPlugin.raycast(e, i)
- }
- ,
- a.Epsilon = .001,
- a
- }()
- , PhysicsRaycastResult = function() {
- function a() {
- this._hasHit = !1,
- this._hitDistance = 0,
- this._hitNormalWorld = Vector3.Zero(),
- this._hitPointWorld = Vector3.Zero(),
- this._rayFromWorld = Vector3.Zero(),
- this._rayToWorld = Vector3.Zero()
- }
- return Object.defineProperty(a.prototype, "hasHit", {
- get: function() {
- return this._hasHit
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "hitDistance", {
- get: function() {
- return this._hitDistance
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "hitNormalWorld", {
- get: function() {
- return this._hitNormalWorld
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "hitPointWorld", {
- get: function() {
- return this._hitPointWorld
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "rayFromWorld", {
- get: function() {
- return this._rayFromWorld
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "rayToWorld", {
- get: function() {
- return this._rayToWorld
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.setHitData = function(e, i) {
- this._hasHit = !0,
- this._hitNormalWorld = new Vector3(e.x,e.y,e.z),
- this._hitPointWorld = new Vector3(i.x,i.y,i.z)
- }
- ,
- a.prototype.setHitDistance = function(e) {
- this._hitDistance = e
- }
- ,
- a.prototype.calculateHitDistance = function() {
- this._hitDistance = Vector3.Distance(this._rayFromWorld, this._hitPointWorld)
- }
- ,
- a.prototype.reset = function(e, i) {
- e === void 0 && (e = Vector3.Zero()),
- i === void 0 && (i = Vector3.Zero()),
- this._rayFromWorld = e,
- this._rayToWorld = i,
- this._hasHit = !1,
- this._hitDistance = 0,
- this._hitNormalWorld = Vector3.Zero(),
- this._hitPointWorld = Vector3.Zero()
- }
- ,
- a
- }()
- , CannonJSPlugin = function() {
- function a(e, i, o) {
- if (e === void 0 && (e = !0),
- i === void 0 && (i = 10),
- o === void 0 && (o = CANNON),
- this._useDeltaForWorldStep = e,
- this.name = "CannonJSPlugin",
- this._physicsMaterials = new Array,
- this._fixedTimeStep = 1 / 60,
- this._physicsBodysToRemoveAfterStep = new Array,
- this._firstFrame = !0,
- this._tmpQuaternion = new Quaternion,
- this._minus90X = new Quaternion(-.7071067811865475,0,0,.7071067811865475),
- this._plus90X = new Quaternion(.7071067811865475,0,0,.7071067811865475),
- this._tmpPosition = Vector3.Zero(),
- this._tmpDeltaPosition = Vector3.Zero(),
- this._tmpUnityRotation = new Quaternion,
- this.BJSCANNON = o,
- !this.isSupported()) {
- Logger$2.Error("CannonJS is not available. Please make sure you included the js file.");
- return
- }
- this._extendNamespace(),
- this.world = new this.BJSCANNON.World,
- this.world.broadphase = new this.BJSCANNON.NaiveBroadphase,
- this.world.solver.iterations = i,
- this._cannonRaycastResult = new this.BJSCANNON.RaycastResult,
- this._raycastResult = new PhysicsRaycastResult
- }
- return a.prototype.setGravity = function(e) {
- var i = e;
- this.world.gravity.set(i.x, i.y, i.z)
- }
- ,
- a.prototype.setTimeStep = function(e) {
- this._fixedTimeStep = e
- }
- ,
- a.prototype.getTimeStep = function() {
- return this._fixedTimeStep
- }
- ,
- a.prototype.executeStep = function(e, i) {
- if (this._firstFrame) {
- this._firstFrame = !1;
- for (var o = 0, s = i; o < s.length; o++) {
- var c = s[o];
- c.type == PhysicsImpostor.HeightmapImpostor || c.type === PhysicsImpostor.PlaneImpostor || c.beforeStep()
- }
- }
- this.world.step(this._useDeltaForWorldStep ? e : this._fixedTimeStep),
- this._removeMarkedPhysicsBodiesFromWorld()
- }
- ,
- a.prototype._removeMarkedPhysicsBodiesFromWorld = function() {
- var e = this;
- this._physicsBodysToRemoveAfterStep.length > 0 && (this._physicsBodysToRemoveAfterStep.forEach(function(i) {
- typeof e.world.removeBody == "function" ? e.world.removeBody(i) : e.world.remove(i)
- }),
- this._physicsBodysToRemoveAfterStep = [])
- }
- ,
- a.prototype.applyImpulse = function(e, i, o) {
- var s = new this.BJSCANNON.Vec3(o.x,o.y,o.z)
- , c = new this.BJSCANNON.Vec3(i.x,i.y,i.z);
- e.physicsBody.applyImpulse(c, s)
- }
- ,
- a.prototype.applyForce = function(e, i, o) {
- var s = new this.BJSCANNON.Vec3(o.x,o.y,o.z)
- , c = new this.BJSCANNON.Vec3(i.x,i.y,i.z);
- e.physicsBody.applyForce(c, s)
- }
- ,
- a.prototype.generatePhysicsBody = function(e) {
- if (this._removeMarkedPhysicsBodiesFromWorld(),
- e.parent) {
- e.physicsBody && (this.removePhysicsBody(e),
- e.forceUpdate());
- return
- }
- if (e.isBodyInitRequired()) {
- var i = this._createShape(e)
- , o = e.physicsBody;
- o && this.removePhysicsBody(e);
- var s = this._addMaterial("mat-" + e.uniqueId, e.getParam("friction"), e.getParam("restitution"))
- , c = {
- mass: e.getParam("mass"),
- material: s
- }
- , d = e.getParam("nativeOptions");
- for (var _ in d)
- d.hasOwnProperty(_) && (c[_] = d[_]);
- e.physicsBody = new this.BJSCANNON.Body(c),
- e.physicsBody.addEventListener("collide", e.onCollide),
- this.world.addEventListener("preStep", e.beforeStep),
- this.world.addEventListener("postStep", e.afterStep),
- e.physicsBody.addShape(i),
- typeof this.world.addBody == "function" ? this.world.addBody(e.physicsBody) : this.world.add(e.physicsBody),
- o && ["force", "torque", "velocity", "angularVelocity"].forEach(function(b) {
- var k = o[b];
- e.physicsBody[b].set(k.x, k.y, k.z)
- }),
- this._processChildMeshes(e)
- }
- this._updatePhysicsBodyTransformation(e)
- }
- ,
- a.prototype._processChildMeshes = function(e) {
- var i = this
- , o = e.object.getChildMeshes ? e.object.getChildMeshes(!0) : []
- , s = e.object.rotationQuaternion;
- if (s ? s.conjugateToRef(this._tmpQuaternion) : this._tmpQuaternion.set(0, 0, 0, 1),
- o.length) {
- var c = function(d) {
- if (!!d.rotationQuaternion) {
- var _ = d.getPhysicsImpostor();
- if (_) {
- var b = _.parent;
- if (b !== e && d.parent) {
- var k = d.getAbsolutePosition().subtract(d.parent.getAbsolutePosition())
- , j = d.rotationQuaternion.multiply(i._tmpQuaternion);
- _.physicsBody && (i.removePhysicsBody(_),
- _.physicsBody = null),
- _.parent = e,
- _.resetUpdateFlags(),
- 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)),
- e.physicsBody.mass += _.getParam("mass")
- }
- }
- d.getChildMeshes(!0).filter(function($) {
- return !!$.physicsImpostor
- }).forEach(c)
- }
- };
- o.filter(function(d) {
- return !!d.physicsImpostor
- }).forEach(c)
- }
- }
- ,
- a.prototype.removePhysicsBody = function(e) {
- e.physicsBody.removeEventListener("collide", e.onCollide),
- this.world.removeEventListener("preStep", e.beforeStep),
- this.world.removeEventListener("postStep", e.afterStep),
- this._physicsBodysToRemoveAfterStep.indexOf(e.physicsBody) === -1 && this._physicsBodysToRemoveAfterStep.push(e.physicsBody)
- }
- ,
- a.prototype.generateJoint = function(e) {
- var i = e.mainImpostor.physicsBody
- , o = e.connectedImpostor.physicsBody;
- if (!(!i || !o)) {
- var s, c = e.joint.jointData, d = {
- pivotA: c.mainPivot ? new this.BJSCANNON.Vec3().set(c.mainPivot.x, c.mainPivot.y, c.mainPivot.z) : null,
- pivotB: c.connectedPivot ? new this.BJSCANNON.Vec3().set(c.connectedPivot.x, c.connectedPivot.y, c.connectedPivot.z) : null,
- axisA: c.mainAxis ? new this.BJSCANNON.Vec3().set(c.mainAxis.x, c.mainAxis.y, c.mainAxis.z) : null,
- axisB: c.connectedAxis ? new this.BJSCANNON.Vec3().set(c.connectedAxis.x, c.connectedAxis.y, c.connectedAxis.z) : null,
- maxForce: c.nativeParams.maxForce,
- collideConnected: !!c.collision
- };
- switch (e.joint.type) {
- case PhysicsJoint.HingeJoint:
- case PhysicsJoint.Hinge2Joint:
- s = new this.BJSCANNON.HingeConstraint(i,o,d);
- break;
- case PhysicsJoint.DistanceJoint:
- s = new this.BJSCANNON.DistanceConstraint(i,o,c.maxDistance || 2);
- break;
- case PhysicsJoint.SpringJoint:
- var _ = c;
- s = new this.BJSCANNON.Spring(i,o,{
- restLength: _.length,
- stiffness: _.stiffness,
- damping: _.damping,
- localAnchorA: d.pivotA,
- localAnchorB: d.pivotB
- });
- break;
- case PhysicsJoint.LockJoint:
- s = new this.BJSCANNON.LockConstraint(i,o,d);
- break;
- case PhysicsJoint.PointToPointJoint:
- case PhysicsJoint.BallAndSocketJoint:
- default:
- s = new this.BJSCANNON.PointToPointConstraint(i,d.pivotA,o,d.pivotB,d.maxForce);
- break
- }
- s.collideConnected = !!c.collision,
- e.joint.physicsJoint = s,
- e.joint.type !== PhysicsJoint.SpringJoint ? this.world.addConstraint(s) : (e.joint.jointData.forceApplicationCallback = e.joint.jointData.forceApplicationCallback || function() {
- s.applyForce()
- }
- ,
- e.mainImpostor.registerAfterPhysicsStep(e.joint.jointData.forceApplicationCallback))
- }
- }
- ,
- a.prototype.removeJoint = function(e) {
- e.joint.type !== PhysicsJoint.SpringJoint ? this.world.removeConstraint(e.joint.physicsJoint) : e.mainImpostor.unregisterAfterPhysicsStep(e.joint.jointData.forceApplicationCallback)
- }
- ,
- a.prototype._addMaterial = function(e, i, o) {
- var s, c;
- for (s = 0; s < this._physicsMaterials.length; s++)
- if (c = this._physicsMaterials[s],
- c.friction === i && c.restitution === o)
- return c;
- var d = new this.BJSCANNON.Material(e);
- return d.friction = i,
- d.restitution = o,
- this._physicsMaterials.push(d),
- d
- }
- ,
- a.prototype._checkWithEpsilon = function(e) {
- return e < PhysicsEngine.Epsilon ? PhysicsEngine.Epsilon : e
- }
- ,
- a.prototype._createShape = function(e) {
- var i = e.object, o, s = e.getObjectExtendSize();
- switch (e.type) {
- case PhysicsImpostor.SphereImpostor:
- var c = s.x
- , d = s.y
- , _ = s.z;
- o = new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(c), this._checkWithEpsilon(d), this._checkWithEpsilon(_)) / 2);
- break;
- case PhysicsImpostor.CylinderImpostor:
- var b = e.getParam("nativeOptions");
- b || (b = {});
- var k = b.radiusTop !== void 0 ? b.radiusTop : this._checkWithEpsilon(s.x) / 2
- , j = b.radiusBottom !== void 0 ? b.radiusBottom : this._checkWithEpsilon(s.x) / 2
- , $ = b.height !== void 0 ? b.height : this._checkWithEpsilon(s.y)
- , _e = b.numSegments !== void 0 ? b.numSegments : 16;
- o = new this.BJSCANNON.Cylinder(k,j,$,_e);
- var et = new this.BJSCANNON.Quaternion;
- et.setFromAxisAngle(new this.BJSCANNON.Vec3(1,0,0), -Math.PI / 2);
- var tt = new this.BJSCANNON.Vec3(0,0,0);
- o.transformAllPoints(tt, et);
- break;
- case PhysicsImpostor.BoxImpostor:
- var rt = s.scale(.5);
- o = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(rt.x),this._checkWithEpsilon(rt.y),this._checkWithEpsilon(rt.z)));
- break;
- case PhysicsImpostor.PlaneImpostor:
- Logger$2.Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead"),
- o = new this.BJSCANNON.Plane;
- break;
- case PhysicsImpostor.MeshImpostor:
- var it = i.getVerticesData ? i.getVerticesData(VertexBuffer.PositionKind) : []
- , nt = i.getIndices ? i.getIndices() : [];
- if (!it)
- return;
- var ot = i.position.clone()
- , at = i.rotation && i.rotation.clone()
- , st = i.rotationQuaternion && i.rotationQuaternion.clone();
- i.position.copyFromFloats(0, 0, 0),
- i.rotation && i.rotation.copyFromFloats(0, 0, 0),
- i.rotationQuaternion && i.rotationQuaternion.copyFrom(e.getParentsRotation()),
- i.rotationQuaternion && i.parent && i.rotationQuaternion.conjugateInPlace();
- var ut = i.computeWorldMatrix(!0), ct = new Array, lt;
- for (lt = 0; lt < it.length; lt += 3)
- Vector3.TransformCoordinates(Vector3.FromArray(it, lt), ut).toArray(ct, lt);
- Logger$2.Warn("MeshImpostor only collides against spheres."),
- o = new this.BJSCANNON.Trimesh(ct,nt),
- i.position.copyFrom(ot),
- at && i.rotation && i.rotation.copyFrom(at),
- st && i.rotationQuaternion && i.rotationQuaternion.copyFrom(st);
- break;
- case PhysicsImpostor.HeightmapImpostor:
- var ft = i.position.clone()
- , ht = i.rotation && i.rotation.clone()
- , pt = i.rotationQuaternion && i.rotationQuaternion.clone();
- i.position.copyFromFloats(0, 0, 0),
- i.rotation && i.rotation.copyFromFloats(0, 0, 0),
- i.rotationQuaternion && i.rotationQuaternion.copyFrom(e.getParentsRotation()),
- i.rotationQuaternion && i.parent && i.rotationQuaternion.conjugateInPlace(),
- i.rotationQuaternion && i.rotationQuaternion.multiplyInPlace(this._minus90X),
- o = this._createHeightmap(i),
- i.position.copyFrom(ft),
- ht && i.rotation && i.rotation.copyFrom(ht),
- pt && i.rotationQuaternion && i.rotationQuaternion.copyFrom(pt),
- i.computeWorldMatrix(!0);
- break;
- case PhysicsImpostor.ParticleImpostor:
- o = new this.BJSCANNON.Particle;
- break;
- case PhysicsImpostor.NoImpostor:
- o = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(0,0,0));
- break
- }
- return o
- }
- ,
- a.prototype._createHeightmap = function(e, i) {
- var o = e.getVerticesData(VertexBuffer.PositionKind), s = e.computeWorldMatrix(!0), c = new Array, d;
- for (d = 0; d < o.length; d += 3)
- Vector3.TransformCoordinates(Vector3.FromArray(o, d), s).toArray(c, d);
- o = c;
- 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) {
- var tt = Math.round(o[et + 0] / _e + b / 2)
- , rt = Math.round((o[et + 1] / _e - b / 2) * -1)
- , it = -o[et + 2] + $;
- _[tt] || (_[tt] = []),
- _[tt][rt] || (_[tt][rt] = it),
- _[tt][rt] = Math.max(it, _[tt][rt])
- }
- for (var tt = 0; tt <= b; ++tt) {
- if (!_[tt]) {
- for (var nt = 1; !_[(tt + nt) % b]; )
- nt++;
- _[tt] = _[(tt + nt) % b].slice()
- }
- for (var rt = 0; rt <= b; ++rt)
- if (!_[tt][rt]) {
- for (var nt = 1, ot; ot === void 0; )
- ot = _[tt][(rt + nt++) % b];
- _[tt][rt] = ot
- }
- }
- var at = new this.BJSCANNON.Heightfield(_,{
- elementSize: _e
- });
- return at.minY = $,
- at
- }
- ,
- a.prototype._updatePhysicsBodyTransformation = function(e) {
- var i = e.object;
- if (i.computeWorldMatrix && i.computeWorldMatrix(!0),
- !!i.getBoundingInfo()) {
- var o = e.getObjectCenter();
- this._tmpDeltaPosition.copyFrom(i.getAbsolutePivotPoint().subtract(o)),
- this._tmpDeltaPosition.divideInPlace(e.object.scaling),
- this._tmpPosition.copyFrom(o);
- var s = i.rotationQuaternion;
- if (!!s) {
- if ((e.type === PhysicsImpostor.PlaneImpostor || e.type === PhysicsImpostor.HeightmapImpostor) && (s = s.multiply(this._minus90X),
- e.setDeltaRotation(this._plus90X)),
- e.type === PhysicsImpostor.HeightmapImpostor) {
- var c = i
- , d = c.getBoundingInfo()
- , _ = c.rotationQuaternion;
- c.rotationQuaternion = this._tmpUnityRotation,
- c.computeWorldMatrix(!0);
- var b = o.clone()
- , k = c.getPivotMatrix();
- k ? k = k.clone() : k = Matrix.Identity();
- var j = Matrix.Translation(d.boundingBox.extendSizeWorld.x, 0, -d.boundingBox.extendSizeWorld.z);
- c.setPreTransformMatrix(j),
- c.computeWorldMatrix(!0),
- d = c.getBoundingInfo();
- var $ = d.boundingBox.centerWorld.subtract(o).subtract(c.position).negate();
- this._tmpPosition.copyFromFloats($.x, $.y - d.boundingBox.extendSizeWorld.y, $.z),
- this._tmpDeltaPosition.copyFrom(d.boundingBox.centerWorld.subtract(b)),
- this._tmpDeltaPosition.y += d.boundingBox.extendSizeWorld.y,
- c.rotationQuaternion = _,
- c.setPreTransformMatrix(k),
- c.computeWorldMatrix(!0)
- } else
- e.type === PhysicsImpostor.MeshImpostor && this._tmpDeltaPosition.copyFromFloats(0, 0, 0);
- e.setDeltaPosition(this._tmpDeltaPosition),
- e.physicsBody.position.set(this._tmpPosition.x, this._tmpPosition.y, this._tmpPosition.z),
- e.physicsBody.quaternion.set(s.x, s.y, s.z, s.w)
- }
- }
- }
- ,
- a.prototype.setTransformationFromPhysicsBody = function(e) {
- if (e.object.position.set(e.physicsBody.position.x, e.physicsBody.position.y, e.physicsBody.position.z),
- e.object.rotationQuaternion) {
- var i = e.physicsBody.quaternion;
- e.object.rotationQuaternion.set(i.x, i.y, i.z, i.w)
- }
- }
- ,
- a.prototype.setPhysicsBodyTransformation = function(e, i, o) {
- e.physicsBody.position.set(i.x, i.y, i.z),
- e.physicsBody.quaternion.set(o.x, o.y, o.z, o.w)
- }
- ,
- a.prototype.isSupported = function() {
- return this.BJSCANNON !== void 0
- }
- ,
- a.prototype.setLinearVelocity = function(e, i) {
- e.physicsBody.velocity.set(i.x, i.y, i.z)
- }
- ,
- a.prototype.setAngularVelocity = function(e, i) {
- e.physicsBody.angularVelocity.set(i.x, i.y, i.z)
- }
- ,
- a.prototype.getLinearVelocity = function(e) {
- var i = e.physicsBody.velocity;
- return i ? new Vector3(i.x,i.y,i.z) : null
- }
- ,
- a.prototype.getAngularVelocity = function(e) {
- var i = e.physicsBody.angularVelocity;
- return i ? new Vector3(i.x,i.y,i.z) : null
- }
- ,
- a.prototype.setBodyMass = function(e, i) {
- e.physicsBody.mass = i,
- e.physicsBody.updateMassProperties()
- }
- ,
- a.prototype.getBodyMass = function(e) {
- return e.physicsBody.mass
- }
- ,
- a.prototype.getBodyFriction = function(e) {
- return e.physicsBody.material.friction
- }
- ,
- a.prototype.setBodyFriction = function(e, i) {
- e.physicsBody.material.friction = i
- }
- ,
- a.prototype.getBodyRestitution = function(e) {
- return e.physicsBody.material.restitution
- }
- ,
- a.prototype.setBodyRestitution = function(e, i) {
- e.physicsBody.material.restitution = i
- }
- ,
- a.prototype.sleepBody = function(e) {
- e.physicsBody.sleep()
- }
- ,
- a.prototype.wakeUpBody = function(e) {
- e.physicsBody.wakeUp()
- }
- ,
- a.prototype.updateDistanceJoint = function(e, i) {
- e.physicsJoint.distance = i
- }
- ,
- a.prototype.setMotor = function(e, i, o, s) {
- s || (e.physicsJoint.enableMotor(),
- e.physicsJoint.setMotorSpeed(i),
- o && this.setLimit(e, o))
- }
- ,
- a.prototype.setLimit = function(e, i, o) {
- e.physicsJoint.motorEquation.maxForce = i,
- e.physicsJoint.motorEquation.minForce = o === void 0 ? -i : o
- }
- ,
- a.prototype.syncMeshWithImpostor = function(e, i) {
- var o = i.physicsBody;
- e.position.x = o.position.x,
- e.position.y = o.position.y,
- e.position.z = o.position.z,
- e.rotationQuaternion && (e.rotationQuaternion.x = o.quaternion.x,
- e.rotationQuaternion.y = o.quaternion.y,
- e.rotationQuaternion.z = o.quaternion.z,
- e.rotationQuaternion.w = o.quaternion.w)
- }
- ,
- a.prototype.getRadius = function(e) {
- var i = e.physicsBody.shapes[0];
- return i.boundingSphereRadius
- }
- ,
- a.prototype.getBoxSizeToRef = function(e, i) {
- var o = e.physicsBody.shapes[0];
- i.x = o.halfExtents.x * 2,
- i.y = o.halfExtents.y * 2,
- i.z = o.halfExtents.z * 2
- }
- ,
- a.prototype.dispose = function() {}
- ,
- a.prototype._extendNamespace = function() {
- var e = new this.BJSCANNON.Vec3
- , i = this.BJSCANNON;
- this.BJSCANNON.World.prototype.step = function(o, s, c) {
- if (c = c || 10,
- s = s || 0,
- s === 0)
- this.internalStep(o),
- this.time += o;
- else {
- var d = Math.floor((this.time + s) / o) - Math.floor(this.time / o);
- d = Math.min(d, c) || 1;
- for (var _ = performance.now(), b = 0; b !== d && (this.internalStep(o),
- !(performance.now() - _ > o * 1e3)); b++)
- ;
- this.time += s;
- for (var k = this.time % o, j = k / o, $ = e, _e = this.bodies, et = 0; et !== _e.length; et++) {
- var tt = _e[et];
- tt.type !== i.Body.STATIC && tt.sleepState !== i.Body.SLEEPING ? (tt.position.vsub(tt.previousPosition, $),
- $.scale(j, $),
- tt.position.vadd($, tt.interpolatedPosition)) : (tt.interpolatedPosition.set(tt.position.x, tt.position.y, tt.position.z),
- tt.interpolatedQuaternion.set(tt.quaternion.x, tt.quaternion.y, tt.quaternion.z, tt.quaternion.w))
- }
- }
- }
- }
- ,
- a.prototype.raycast = function(e, i) {
- return this._cannonRaycastResult.reset(),
- this.world.raycastClosest(e, i, {}, this._cannonRaycastResult),
- this._raycastResult.reset(e, i),
- this._cannonRaycastResult.hasHit && (this._raycastResult.setHitData({
- x: this._cannonRaycastResult.hitNormalWorld.x,
- y: this._cannonRaycastResult.hitNormalWorld.y,
- z: this._cannonRaycastResult.hitNormalWorld.z
- }, {
- x: this._cannonRaycastResult.hitPointWorld.x,
- y: this._cannonRaycastResult.hitPointWorld.y,
- z: this._cannonRaycastResult.hitPointWorld.z
- }),
- this._raycastResult.setHitDistance(this._cannonRaycastResult.distance)),
- this._raycastResult
- }
- ,
- a
- }();
- PhysicsEngine.DefaultPluginFactory = function() {
- return new CannonJSPlugin
- }
- ;
- var OimoJSPlugin = function() {
- function a(e, i, o) {
- e === void 0 && (e = !0),
- o === void 0 && (o = OIMO),
- this._useDeltaForWorldStep = e,
- this.name = "OimoJSPlugin",
- this._fixedTimeStep = 1 / 60,
- this._tmpImpostorsArray = [],
- this._tmpPositionVector = Vector3.Zero(),
- this.BJSOIMO = o,
- this.world = new this.BJSOIMO.World({
- iterations: i
- }),
- this.world.clear(),
- this._raycastResult = new PhysicsRaycastResult
- }
- return a.prototype.setGravity = function(e) {
- this.world.gravity.set(e.x, e.y, e.z)
- }
- ,
- a.prototype.setTimeStep = function(e) {
- this.world.timeStep = e
- }
- ,
- a.prototype.getTimeStep = function() {
- return this.world.timeStep
- }
- ,
- a.prototype.executeStep = function(e, i) {
- var o = this;
- i.forEach(function(_) {
- _.beforeStep()
- }),
- this.world.timeStep = this._useDeltaForWorldStep ? e : this._fixedTimeStep,
- this.world.step(),
- i.forEach(function(_) {
- _.afterStep(),
- o._tmpImpostorsArray[_.uniqueId] = _
- });
- for (var s = this.world.contacts; s !== null; ) {
- if (s.touching && !s.body1.sleeping && !s.body2.sleeping) {
- s = s.next;
- continue
- }
- var c = this._tmpImpostorsArray[+s.body1.name]
- , d = this._tmpImpostorsArray[+s.body2.name];
- if (!c || !d) {
- s = s.next;
- continue
- }
- c.onCollide({
- body: d.physicsBody,
- point: null
- }),
- d.onCollide({
- body: c.physicsBody,
- point: null
- }),
- s = s.next
- }
- }
- ,
- a.prototype.applyImpulse = function(e, i, o) {
- var s = e.physicsBody.mass;
- e.physicsBody.applyImpulse(o.scale(this.world.invScale), i.scale(this.world.invScale * s))
- }
- ,
- a.prototype.applyForce = function(e, i, o) {
- Logger$2.Warn("Oimo doesn't support applying force. Using impule instead."),
- this.applyImpulse(e, i, o)
- }
- ,
- a.prototype.generatePhysicsBody = function(e) {
- var i = this;
- if (e.parent) {
- e.physicsBody && (this.removePhysicsBody(e),
- e.forceUpdate());
- return
- }
- if (e.isBodyInitRequired()) {
- var o = {
- name: e.uniqueId,
- config: [e.getParam("mass") || .001, e.getParam("friction"), e.getParam("restitution")],
- size: [],
- type: [],
- pos: [],
- posShape: [],
- rot: [],
- rotShape: [],
- move: e.getParam("mass") !== 0,
- density: e.getParam("mass"),
- friction: e.getParam("friction"),
- restitution: e.getParam("restitution"),
- world: this.world
- }
- , s = [e]
- , c = function(b) {
- !b.getChildMeshes || b.getChildMeshes().forEach(function(k) {
- k.physicsImpostor && s.push(k.physicsImpostor)
- })
- };
- c(e.object);
- var d = function(b) {
- return Math.max(b, PhysicsEngine.Epsilon)
- }
- , _ = new Quaternion;
- s.forEach(function(b) {
- if (!!b.object.rotationQuaternion) {
- var k = b.object.rotationQuaternion;
- _.copyFrom(k),
- b.object.rotationQuaternion.set(0, 0, 0, 1),
- b.object.computeWorldMatrix(!0);
- var j = _.toEulerAngles()
- , $ = b.getObjectExtendSize()
- , _e = 57.29577951308232;
- if (b === e) {
- var et = e.getObjectCenter();
- e.object.getAbsolutePivotPoint().subtractToRef(et, i._tmpPositionVector),
- i._tmpPositionVector.divideInPlace(e.object.scaling),
- o.pos.push(et.x),
- o.pos.push(et.y),
- o.pos.push(et.z),
- o.posShape.push(0, 0, 0),
- o.rotShape.push(0, 0, 0)
- } else {
- var tt = b.object.position.clone();
- o.posShape.push(tt.x),
- o.posShape.push(tt.y),
- o.posShape.push(tt.z),
- o.rotShape.push(j.x * _e, j.y * _e, j.z * _e)
- }
- switch (b.object.rotationQuaternion.copyFrom(_),
- b.type) {
- case PhysicsImpostor.ParticleImpostor:
- Logger$2.Warn("No Particle support in OIMO.js. using SphereImpostor instead");
- case PhysicsImpostor.SphereImpostor:
- var rt = $.x
- , it = $.y
- , nt = $.z
- , ot = Math.max(d(rt), d(it), d(nt)) / 2;
- o.type.push("sphere"),
- o.size.push(ot),
- o.size.push(ot),
- o.size.push(ot);
- break;
- case PhysicsImpostor.CylinderImpostor:
- var at = d($.x) / 2
- , st = d($.y);
- o.type.push("cylinder"),
- o.size.push(at),
- o.size.push(st),
- o.size.push(st);
- break;
- case PhysicsImpostor.PlaneImpostor:
- case PhysicsImpostor.BoxImpostor:
- default:
- var at = d($.x)
- , st = d($.y)
- , ut = d($.z);
- o.type.push("box"),
- o.size.push(at),
- o.size.push(st),
- o.size.push(ut);
- break
- }
- b.object.rotationQuaternion = k
- }
- }),
- e.physicsBody = this.world.add(o),
- e.physicsBody.resetQuaternion(_),
- e.physicsBody.updatePosition(0)
- } else
- this._tmpPositionVector.copyFromFloats(0, 0, 0);
- e.setDeltaPosition(this._tmpPositionVector)
- }
- ,
- a.prototype.removePhysicsBody = function(e) {
- this.world.removeRigidBody(e.physicsBody)
- }
- ,
- a.prototype.generateJoint = function(e) {
- var i = e.mainImpostor.physicsBody
- , o = e.connectedImpostor.physicsBody;
- if (!(!i || !o)) {
- var s = e.joint.jointData, c = s.nativeParams || {}, d, _ = {
- body1: i,
- body2: o,
- axe1: c.axe1 || (s.mainAxis ? s.mainAxis.asArray() : null),
- axe2: c.axe2 || (s.connectedAxis ? s.connectedAxis.asArray() : null),
- pos1: c.pos1 || (s.mainPivot ? s.mainPivot.asArray() : null),
- pos2: c.pos2 || (s.connectedPivot ? s.connectedPivot.asArray() : null),
- min: c.min,
- max: c.max,
- collision: c.collision || s.collision,
- spring: c.spring,
- world: this.world
- };
- switch (e.joint.type) {
- case PhysicsJoint.BallAndSocketJoint:
- d = "jointBall";
- break;
- case PhysicsJoint.SpringJoint:
- Logger$2.Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");
- var b = s;
- _.min = b.length || _.min,
- _.max = Math.max(_.min, _.max);
- case PhysicsJoint.DistanceJoint:
- d = "jointDistance",
- _.max = s.maxDistance;
- break;
- case PhysicsJoint.PrismaticJoint:
- d = "jointPrisme";
- break;
- case PhysicsJoint.SliderJoint:
- d = "jointSlide";
- break;
- case PhysicsJoint.WheelJoint:
- d = "jointWheel";
- break;
- case PhysicsJoint.HingeJoint:
- default:
- d = "jointHinge";
- break
- }
- _.type = d,
- e.joint.physicsJoint = this.world.add(_)
- }
- }
- ,
- a.prototype.removeJoint = function(e) {
- try {
- this.world.removeJoint(e.joint.physicsJoint)
- } catch (i) {
- Logger$2.Warn(i)
- }
- }
- ,
- a.prototype.isSupported = function() {
- return this.BJSOIMO !== void 0
- }
- ,
- a.prototype.setTransformationFromPhysicsBody = function(e) {
- if (!e.physicsBody.sleeping) {
- if (e.physicsBody.shapes.next) {
- for (var i = e.physicsBody.shapes; i.next; )
- i = i.next;
- e.object.position.set(i.position.x, i.position.y, i.position.z)
- } else {
- var o = e.physicsBody.getPosition();
- e.object.position.set(o.x, o.y, o.z)
- }
- if (e.object.rotationQuaternion) {
- var s = e.physicsBody.getQuaternion();
- e.object.rotationQuaternion.set(s.x, s.y, s.z, s.w)
- }
- }
- }
- ,
- a.prototype.setPhysicsBodyTransformation = function(e, i, o) {
- var s = e.physicsBody;
- e.physicsBody.shapes.next || (s.position.set(i.x, i.y, i.z),
- s.orientation.set(o.x, o.y, o.z, o.w),
- s.syncShapes(),
- s.awake())
- }
- ,
- a.prototype.setLinearVelocity = function(e, i) {
- e.physicsBody.linearVelocity.set(i.x, i.y, i.z)
- }
- ,
- a.prototype.setAngularVelocity = function(e, i) {
- e.physicsBody.angularVelocity.set(i.x, i.y, i.z)
- }
- ,
- a.prototype.getLinearVelocity = function(e) {
- var i = e.physicsBody.linearVelocity;
- return i ? new Vector3(i.x,i.y,i.z) : null
- }
- ,
- a.prototype.getAngularVelocity = function(e) {
- var i = e.physicsBody.angularVelocity;
- return i ? new Vector3(i.x,i.y,i.z) : null
- }
- ,
- a.prototype.setBodyMass = function(e, i) {
- var o = i === 0;
- e.physicsBody.shapes.density = o ? 1 : i,
- e.physicsBody.setupMass(o ? 2 : 1)
- }
- ,
- a.prototype.getBodyMass = function(e) {
- return e.physicsBody.shapes.density
- }
- ,
- a.prototype.getBodyFriction = function(e) {
- return e.physicsBody.shapes.friction
- }
- ,
- a.prototype.setBodyFriction = function(e, i) {
- e.physicsBody.shapes.friction = i
- }
- ,
- a.prototype.getBodyRestitution = function(e) {
- return e.physicsBody.shapes.restitution
- }
- ,
- a.prototype.setBodyRestitution = function(e, i) {
- e.physicsBody.shapes.restitution = i
- }
- ,
- a.prototype.sleepBody = function(e) {
- e.physicsBody.sleep()
- }
- ,
- a.prototype.wakeUpBody = function(e) {
- e.physicsBody.awake()
- }
- ,
- a.prototype.updateDistanceJoint = function(e, i, o) {
- e.physicsJoint.limitMotor.upperLimit = i,
- o !== void 0 && (e.physicsJoint.limitMotor.lowerLimit = o)
- }
- ,
- a.prototype.setMotor = function(e, i, o, s) {
- o !== void 0 ? Logger$2.Warn("OimoJS plugin currently has unexpected behavior when using setMotor with force parameter") : o = 1e6,
- i *= -1;
- var c = s ? e.physicsJoint.rotationalLimitMotor2 : e.physicsJoint.rotationalLimitMotor1 || e.physicsJoint.rotationalLimitMotor || e.physicsJoint.limitMotor;
- c && c.setMotor(i, o)
- }
- ,
- a.prototype.setLimit = function(e, i, o, s) {
- var c = s ? e.physicsJoint.rotationalLimitMotor2 : e.physicsJoint.rotationalLimitMotor1 || e.physicsJoint.rotationalLimitMotor || e.physicsJoint.limitMotor;
- c && c.setLimit(i, o === void 0 ? -i : o)
- }
- ,
- a.prototype.syncMeshWithImpostor = function(e, i) {
- var o = i.physicsBody;
- e.position.x = o.position.x,
- e.position.y = o.position.y,
- e.position.z = o.position.z,
- e.rotationQuaternion && (e.rotationQuaternion.x = o.orientation.x,
- e.rotationQuaternion.y = o.orientation.y,
- e.rotationQuaternion.z = o.orientation.z,
- e.rotationQuaternion.w = o.orientation.s)
- }
- ,
- a.prototype.getRadius = function(e) {
- return e.physicsBody.shapes.radius
- }
- ,
- a.prototype.getBoxSizeToRef = function(e, i) {
- var o = e.physicsBody.shapes;
- i.x = o.halfWidth * 2,
- i.y = o.halfHeight * 2,
- i.z = o.halfDepth * 2
- }
- ,
- a.prototype.dispose = function() {
- this.world.clear()
- }
- ,
- a.prototype.raycast = function(e, i) {
- return Logger$2.Warn("raycast is not currently supported by the Oimo physics plugin"),
- this._raycastResult.reset(e, i),
- this._raycastResult
- }
- ,
- a
- }()
- , AmmoJSPlugin = function() {
- function a(e, i, o) {
- var s = this;
- if (e === void 0 && (e = !0),
- i === void 0 && (i = Ammo),
- o === void 0 && (o = null),
- this._useDeltaForWorldStep = e,
- this.bjsAMMO = {},
- this.name = "AmmoJSPlugin",
- this._timeStep = 1 / 60,
- this._fixedTimeStep = 1 / 60,
- this._maxSteps = 5,
- this._tmpQuaternion = new Quaternion,
- this._tmpContactCallbackResult = !1,
- this._tmpContactPoint = new Vector3,
- this._tmpVec3 = new Vector3,
- this._tmpMatrix = new Matrix,
- typeof i == "function") {
- Logger$2.Error("AmmoJS is not ready. Please make sure you await Ammo() before using the plugin.");
- return
- } else
- this.bjsAMMO = i;
- if (!this.isSupported()) {
- Logger$2.Error("AmmoJS is not available. Please make sure you included the js file.");
- return
- }
- this._collisionConfiguration = new this.bjsAMMO.btSoftBodyRigidBodyCollisionConfiguration,
- this._dispatcher = new this.bjsAMMO.btCollisionDispatcher(this._collisionConfiguration),
- this._overlappingPairCache = o || new this.bjsAMMO.btDbvtBroadphase,
- this._solver = new this.bjsAMMO.btSequentialImpulseConstraintSolver,
- this._softBodySolver = new this.bjsAMMO.btDefaultSoftBodySolver,
- this.world = new this.bjsAMMO.btSoftRigidDynamicsWorld(this._dispatcher,this._overlappingPairCache,this._solver,this._collisionConfiguration,this._softBodySolver),
- this._tmpAmmoConcreteContactResultCallback = new this.bjsAMMO.ConcreteContactResultCallback,
- this._tmpAmmoConcreteContactResultCallback.addSingleResult = function(c, d, _, b) {
- c = s.bjsAMMO.wrapPointer(c, s.bjsAMMO.btManifoldPoint);
- var k = c.getPositionWorldOnA();
- s._tmpContactPoint.x = k.x(),
- s._tmpContactPoint.y = k.y(),
- s._tmpContactPoint.z = k.z(),
- s._tmpContactCallbackResult = !0
- }
- ,
- this._raycastResult = new PhysicsRaycastResult,
- this._tmpAmmoTransform = new this.bjsAMMO.btTransform,
- this._tmpAmmoTransform.setIdentity(),
- this._tmpAmmoQuaternion = new this.bjsAMMO.btQuaternion(0,0,0,1),
- this._tmpAmmoVectorA = new this.bjsAMMO.btVector3(0,0,0),
- this._tmpAmmoVectorB = new this.bjsAMMO.btVector3(0,0,0),
- this._tmpAmmoVectorC = new this.bjsAMMO.btVector3(0,0,0),
- this._tmpAmmoVectorD = new this.bjsAMMO.btVector3(0,0,0)
- }
- return a.prototype.setGravity = function(e) {
- this._tmpAmmoVectorA.setValue(e.x, e.y, e.z),
- this.world.setGravity(this._tmpAmmoVectorA),
- this.world.getWorldInfo().set_m_gravity(this._tmpAmmoVectorA)
- }
- ,
- a.prototype.setTimeStep = function(e) {
- this._timeStep = e
- }
- ,
- a.prototype.setFixedTimeStep = function(e) {
- this._fixedTimeStep = e
- }
- ,
- a.prototype.setMaxSteps = function(e) {
- this._maxSteps = e
- }
- ,
- a.prototype.getTimeStep = function() {
- return this._timeStep
- }
- ,
- a.prototype._isImpostorInContact = function(e) {
- return this._tmpContactCallbackResult = !1,
- this.world.contactTest(e.physicsBody, this._tmpAmmoConcreteContactResultCallback),
- this._tmpContactCallbackResult
- }
- ,
- a.prototype._isImpostorPairInContact = function(e, i) {
- return this._tmpContactCallbackResult = !1,
- this.world.contactPairTest(e.physicsBody, i.physicsBody, this._tmpAmmoConcreteContactResultCallback),
- this._tmpContactCallbackResult
- }
- ,
- a.prototype._stepSimulation = function(e, i, o) {
- if (e === void 0 && (e = 1 / 60),
- i === void 0 && (i = 10),
- o === void 0 && (o = 1 / 60),
- i == 0)
- this.world.stepSimulation(e, 0);
- else
- for (; i > 0 && e > 0; )
- e - o < o ? (this.world.stepSimulation(e, 0),
- e = 0) : (e -= o,
- this.world.stepSimulation(o, 0)),
- i--
- }
- ,
- a.prototype.executeStep = function(e, i) {
- for (var o = 0, s = i; o < s.length; o++) {
- var c = s[o];
- c.soft || c.beforeStep()
- }
- this._stepSimulation(this._useDeltaForWorldStep ? e : this._timeStep, this._maxSteps, this._fixedTimeStep);
- for (var d = 0, _ = i; d < _.length; d++) {
- var b = _[d];
- if (b.soft ? this._afterSoftStep(b) : b.afterStep(),
- b._onPhysicsCollideCallbacks.length > 0 && this._isImpostorInContact(b))
- for (var k = 0, j = b._onPhysicsCollideCallbacks; k < j.length; k++)
- for (var $ = j[k], _e = 0, et = $.otherImpostors; _e < et.length; _e++) {
- var tt = et[_e];
- (b.physicsBody.isActive() || tt.physicsBody.isActive()) && this._isImpostorPairInContact(b, tt) && (b.onCollide({
- body: tt.physicsBody,
- point: this._tmpContactPoint
- }),
- tt.onCollide({
- body: b.physicsBody,
- point: this._tmpContactPoint
- }))
- }
- }
- }
- ,
- a.prototype._afterSoftStep = function(e) {
- e.type === PhysicsImpostor.RopeImpostor ? this._ropeStep(e) : this._softbodyOrClothStep(e)
- }
- ,
- a.prototype._ropeStep = function(e) {
- for (var i = e.physicsBody.get_m_nodes(), o = i.size(), s, c, d, _, b, k = new Array, j = 0; j < o; j++)
- s = i.at(j),
- c = s.get_m_x(),
- d = c.x(),
- _ = c.y(),
- b = c.z(),
- k.push(new Vector3(d,_,b));
- var $ = e.object
- , _e = e.getParam("shape");
- e._isFromLine ? e.object = CreateLines("lines", {
- points: k,
- instance: $
- }) : e.object = ExtrudeShape("ext", {
- shape: _e,
- path: k,
- instance: $
- })
- }
- ,
- a.prototype._softbodyOrClothStep = function(e) {
- var i = e.type === PhysicsImpostor.ClothImpostor ? 1 : -1
- , o = e.object
- , s = o.getVerticesData(VertexBuffer.PositionKind);
- s || (s = []);
- var c = o.getVerticesData(VertexBuffer.NormalKind);
- c || (c = []);
- for (var d = s.length / 3, _ = e.physicsBody.get_m_nodes(), b, k, j, $, _e, et, tt, rt, it, nt = 0; nt < d; nt++) {
- b = _.at(nt),
- k = b.get_m_x(),
- $ = k.x(),
- _e = k.y(),
- et = k.z() * i;
- var j = b.get_m_n();
- tt = j.x(),
- rt = j.y(),
- it = j.z() * i,
- s[3 * nt] = $,
- s[3 * nt + 1] = _e,
- s[3 * nt + 2] = et,
- c[3 * nt] = tt,
- c[3 * nt + 1] = rt,
- c[3 * nt + 2] = it
- }
- var ot = new VertexData;
- ot.positions = s,
- ot.normals = c,
- ot.uvs = o.getVerticesData(VertexBuffer.UVKind),
- ot.colors = o.getVerticesData(VertexBuffer.ColorKind),
- o && o.getIndices && (ot.indices = o.getIndices()),
- ot.applyToMesh(o)
- }
- ,
- a.prototype.applyImpulse = function(e, i, o) {
- if (e.soft)
- Logger$2.Warn("Cannot be applied to a soft body");
- else {
- e.physicsBody.activate();
- var s = this._tmpAmmoVectorA
- , c = this._tmpAmmoVectorB;
- e.object && e.object.getWorldMatrix && o.subtractInPlace(e.object.getWorldMatrix().getTranslation()),
- s.setValue(o.x, o.y, o.z),
- c.setValue(i.x, i.y, i.z),
- e.physicsBody.applyImpulse(c, s)
- }
- }
- ,
- a.prototype.applyForce = function(e, i, o) {
- if (e.soft)
- Logger$2.Warn("Cannot be applied to a soft body");
- else {
- e.physicsBody.activate();
- var s = this._tmpAmmoVectorA
- , c = this._tmpAmmoVectorB;
- if (s.setValue(o.x, o.y, o.z),
- e.object && e.object.getWorldMatrix) {
- var d = e.object.getWorldMatrix().getTranslation();
- s.x -= d.x,
- s.y -= d.y,
- s.z -= d.z
- }
- c.setValue(i.x, i.y, i.z),
- e.physicsBody.applyForce(c, s)
- }
- }
- ,
- a.prototype.generatePhysicsBody = function(e) {
- if (e._pluginData.toDispose = [],
- e.parent) {
- e.physicsBody && (this.removePhysicsBody(e),
- e.forceUpdate());
- return
- }
- if (e.isBodyInitRequired()) {
- var i = this._createShape(e)
- , o = e.getParam("mass");
- if (e._pluginData.mass = o,
- e.soft)
- i.get_m_cfg().set_collisions(17),
- i.get_m_cfg().set_kDP(e.getParam("damping")),
- this.bjsAMMO.castObject(i, this.bjsAMMO.btCollisionObject).getCollisionShape().setMargin(e.getParam("margin")),
- i.setActivationState(a.DISABLE_DEACTIVATION_FLAG),
- this.world.addSoftBody(i, 1, -1),
- e.physicsBody = i,
- e._pluginData.toDispose.push(i),
- this.setBodyPressure(e, 0),
- e.type === PhysicsImpostor.SoftbodyImpostor && this.setBodyPressure(e, e.getParam("pressure")),
- this.setBodyStiffness(e, e.getParam("stiffness")),
- this.setBodyVelocityIterations(e, e.getParam("velocityIterations")),
- this.setBodyPositionIterations(e, e.getParam("positionIterations"));
- else {
- var s = new this.bjsAMMO.btVector3(0,0,0)
- , c = new this.bjsAMMO.btTransform;
- e.object.computeWorldMatrix(!0),
- c.setIdentity(),
- o !== 0 && i.calculateLocalInertia(o, s),
- this._tmpAmmoVectorA.setValue(e.object.position.x, e.object.position.y, e.object.position.z),
- this._tmpAmmoQuaternion.setValue(e.object.rotationQuaternion.x, e.object.rotationQuaternion.y, e.object.rotationQuaternion.z, e.object.rotationQuaternion.w),
- c.setOrigin(this._tmpAmmoVectorA),
- c.setRotation(this._tmpAmmoQuaternion);
- var d = new this.bjsAMMO.btDefaultMotionState(c)
- , _ = new this.bjsAMMO.btRigidBodyConstructionInfo(o,d,i,s)
- , b = new this.bjsAMMO.btRigidBody(_);
- if (o === 0 && (b.setCollisionFlags(b.getCollisionFlags() | a.KINEMATIC_FLAG),
- b.setActivationState(a.DISABLE_DEACTIVATION_FLAG)),
- e.type == PhysicsImpostor.NoImpostor && !i.getChildShape && b.setCollisionFlags(b.getCollisionFlags() | a.DISABLE_COLLISION_FLAG),
- e.type !== PhysicsImpostor.MeshImpostor && e.type !== PhysicsImpostor.NoImpostor) {
- var k = e.object.getBoundingInfo();
- this._tmpVec3.copyFrom(e.object.getAbsolutePosition()),
- this._tmpVec3.subtractInPlace(k.boundingBox.centerWorld),
- this._tmpVec3.x /= e.object.scaling.x,
- this._tmpVec3.y /= e.object.scaling.y,
- this._tmpVec3.z /= e.object.scaling.z,
- e.setDeltaPosition(this._tmpVec3)
- }
- var j = e.getParam("group")
- , $ = e.getParam("mask");
- j && $ ? this.world.addRigidBody(b, j, $) : this.world.addRigidBody(b),
- e.physicsBody = b,
- e._pluginData.toDispose = e._pluginData.toDispose.concat([b, _, d, c, s, i])
- }
- this.setBodyRestitution(e, e.getParam("restitution")),
- this.setBodyFriction(e, e.getParam("friction"))
- }
- }
- ,
- a.prototype.removePhysicsBody = function(e) {
- var i = this;
- this.world && (e.soft ? this.world.removeSoftBody(e.physicsBody) : this.world.removeRigidBody(e.physicsBody),
- e._pluginData && (e._pluginData.toDispose.forEach(function(o) {
- i.bjsAMMO.destroy(o)
- }),
- e._pluginData.toDispose = []))
- }
- ,
- a.prototype.generateJoint = function(e) {
- var i = e.mainImpostor.physicsBody
- , o = e.connectedImpostor.physicsBody;
- if (!(!i || !o)) {
- var s = e.joint.jointData;
- s.mainPivot || (s.mainPivot = new Vector3(0,0,0)),
- s.connectedPivot || (s.connectedPivot = new Vector3(0,0,0));
- var c;
- switch (e.joint.type) {
- case PhysicsJoint.DistanceJoint:
- var d = s.maxDistance;
- d && (s.mainPivot = new Vector3(0,-d / 2,0),
- s.connectedPivot = new Vector3(0,d / 2,0)),
- 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));
- break;
- case PhysicsJoint.HingeJoint:
- s.mainAxis || (s.mainAxis = new Vector3(0,0,0)),
- s.connectedAxis || (s.connectedAxis = new Vector3(0,0,0));
- var _ = new this.bjsAMMO.btVector3(s.mainAxis.x,s.mainAxis.y,s.mainAxis.z)
- , b = new this.bjsAMMO.btVector3(s.connectedAxis.x,s.connectedAxis.y,s.connectedAxis.z);
- 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);
- break;
- case PhysicsJoint.BallAndSocketJoint:
- 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));
- break;
- default:
- Logger$2.Warn("JointType not currently supported by the Ammo plugin, falling back to PhysicsJoint.BallAndSocketJoint"),
- 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));
- break
- }
- this.world.addConstraint(c, !e.joint.jointData.collision),
- e.joint.physicsJoint = c
- }
- }
- ,
- a.prototype.removeJoint = function(e) {
- this.world && this.world.removeConstraint(e.joint.physicsJoint)
- }
- ,
- a.prototype._addMeshVerts = function(e, i, o) {
- var s = this
- , c = 0;
- if (o && o.getIndices && o.getWorldMatrix && o.getChildMeshes) {
- var d = o.getIndices();
- d || (d = []);
- var _ = o.getVerticesData(VertexBuffer.PositionKind);
- _ || (_ = []);
- var b = void 0;
- if (i && i !== o) {
- var k = void 0;
- i.rotationQuaternion ? k = i.rotationQuaternion : i.rotation ? k = Quaternion.FromEulerAngles(i.rotation.x, i.rotation.y, i.rotation.z) : k = Quaternion.Identity();
- var j = Matrix.Compose(Vector3.One(), k, i.position);
- j.invertToRef(this._tmpMatrix);
- var $ = o.computeWorldMatrix(!1);
- b = $.multiply(this._tmpMatrix)
- } else
- Matrix.ScalingToRef(o.scaling.x, o.scaling.y, o.scaling.z, this._tmpMatrix),
- b = this._tmpMatrix;
- for (var _e = d.length / 3, et = 0; et < _e; et++) {
- for (var tt = [], rt = 0; rt < 3; rt++) {
- var it = new Vector3(_[d[et * 3 + rt] * 3 + 0],_[d[et * 3 + rt] * 3 + 1],_[d[et * 3 + rt] * 3 + 2]);
- it = Vector3.TransformCoordinates(it, b);
- var nt;
- rt == 0 ? nt = this._tmpAmmoVectorA : rt == 1 ? nt = this._tmpAmmoVectorB : nt = this._tmpAmmoVectorC,
- nt.setValue(it.x, it.y, it.z),
- tt.push(nt)
- }
- e.addTriangle(tt[0], tt[1], tt[2]),
- c++
- }
- o.getChildMeshes().forEach(function(ot) {
- c += s._addMeshVerts(e, i, ot)
- })
- }
- return c
- }
- ,
- a.prototype._softVertexData = function(e) {
- var i = e.object;
- if (i && i.getIndices && i.getWorldMatrix && i.getChildMeshes) {
- i.getIndices();
- var o = i.getVerticesData(VertexBuffer.PositionKind);
- o || (o = []);
- var s = i.getVerticesData(VertexBuffer.NormalKind);
- s || (s = []),
- i.computeWorldMatrix(!1);
- for (var c = [], d = [], _ = 0; _ < o.length; _ += 3) {
- var b = new Vector3(o[_],o[_ + 1],o[_ + 2])
- , k = new Vector3(s[_],s[_ + 1],s[_ + 2]);
- b = Vector3.TransformCoordinates(b, i.getWorldMatrix()),
- k = Vector3.TransformNormal(k, i.getWorldMatrix()),
- c.push(b.x, b.y, b.z),
- d.push(k.x, k.y, k.z)
- }
- var j = new VertexData;
- return j.positions = c,
- j.normals = d,
- j.uvs = i.getVerticesData(VertexBuffer.UVKind),
- j.colors = i.getVerticesData(VertexBuffer.ColorKind),
- i && i.getIndices && (j.indices = i.getIndices()),
- j.applyToMesh(i),
- i.position = Vector3.Zero(),
- i.rotationQuaternion = null,
- i.rotation = Vector3.Zero(),
- i.computeWorldMatrix(!0),
- j
- }
- return VertexData.ExtractFromMesh(i)
- }
- ,
- a.prototype._createSoftbody = function(e) {
- var i = e.object;
- if (i && i.getIndices) {
- var o = i.getIndices();
- o || (o = []);
- var s = this._softVertexData(e)
- , c = s.positions
- , d = s.normals;
- if (c === null || d === null)
- return new this.bjsAMMO.btCompoundShape;
- for (var _ = [], b = [], k = 0; k < c.length; k += 3) {
- var j = new Vector3(c[k],c[k + 1],c[k + 2])
- , $ = new Vector3(d[k],d[k + 1],d[k + 2]);
- _.push(j.x, j.y, -j.z),
- b.push($.x, $.y, -$.z)
- }
- 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++) {
- rt = tt.at(k);
- var it = rt.get_m_n();
- it.setX(b[3 * k]),
- it.setY(b[3 * k + 1]),
- it.setZ(b[3 * k + 2])
- }
- return _e
- }
- }
- ,
- a.prototype._createCloth = function(e) {
- var i = e.object;
- if (i && i.getIndices) {
- i.getIndices();
- var o = this._softVertexData(e)
- , s = o.positions
- , c = o.normals;
- if (s === null || c === null)
- return new this.bjsAMMO.btCompoundShape;
- var d = s.length
- , _ = Math.sqrt(d / 3);
- e.segments = _;
- var b = _ - 1;
- this._tmpAmmoVectorA.setValue(s[0], s[1], s[2]),
- this._tmpAmmoVectorB.setValue(s[3 * b], s[3 * b + 1], s[3 * b + 2]),
- this._tmpAmmoVectorD.setValue(s[d - 3], s[d - 2], s[d - 1]),
- this._tmpAmmoVectorC.setValue(s[d - 3 - 3 * b], s[d - 2 - 3 * b], s[d - 1 - 3 * b]);
- var k = new this.bjsAMMO.btSoftBodyHelpers().CreatePatch(this.world.getWorldInfo(), this._tmpAmmoVectorA, this._tmpAmmoVectorB, this._tmpAmmoVectorC, this._tmpAmmoVectorD, _, _, e.getParam("fixedPoints"), !0);
- return k
- }
- }
- ,
- a.prototype._createRope = function(e) {
- var i, o, s = this._softVertexData(e), c = s.positions, d = s.normals;
- if (c === null || d === null)
- return new this.bjsAMMO.btCompoundShape;
- s.applyToMesh(e.object, !0),
- e._isFromLine = !0;
- var _ = d.map(function(tt) {
- return tt * tt
- })
- , b = function(tt, rt) {
- return tt + rt
- }
- , k = _.reduce(b);
- if (k === 0)
- i = c.length,
- o = i / 3 - 1,
- this._tmpAmmoVectorA.setValue(c[0], c[1], c[2]),
- this._tmpAmmoVectorB.setValue(c[i - 3], c[i - 2], c[i - 1]);
- else {
- e._isFromLine = !1;
- var j = e.getParam("path")
- , $ = e.getParam("shape");
- if ($ === null)
- return Logger$2.Warn("No shape available for extruded mesh"),
- new this.bjsAMMO.btCompoundShape;
- i = j.length,
- o = i - 1,
- this._tmpAmmoVectorA.setValue(j[0].x, j[0].y, j[0].z),
- this._tmpAmmoVectorB.setValue(j[i - 1].x, j[i - 1].y, j[i - 1].z)
- }
- e.segments = o;
- var _e = e.getParam("fixedPoints");
- _e = _e > 3 ? 3 : _e;
- var et = new this.bjsAMMO.btSoftBodyHelpers().CreateRope(this.world.getWorldInfo(), this._tmpAmmoVectorA, this._tmpAmmoVectorB, o - 1, _e);
- return et.get_m_cfg().set_collisions(17),
- et
- }
- ,
- a.prototype._createCustom = function(e) {
- var i = null;
- return this.onCreateCustomShape && (i = this.onCreateCustomShape(e)),
- i == null && (i = new this.bjsAMMO.btCompoundShape),
- i
- }
- ,
- a.prototype._addHullVerts = function(e, i, o) {
- var s = this
- , c = 0;
- if (o && o.getIndices && o.getWorldMatrix && o.getChildMeshes) {
- var d = o.getIndices();
- d || (d = []);
- var _ = o.getVerticesData(VertexBuffer.PositionKind);
- _ || (_ = []),
- o.computeWorldMatrix(!1);
- for (var b = d.length / 3, k = 0; k < b; k++) {
- for (var j = [], $ = 0; $ < 3; $++) {
- var _e = new Vector3(_[d[k * 3 + $] * 3 + 0],_[d[k * 3 + $] * 3 + 1],_[d[k * 3 + $] * 3 + 2]);
- Matrix.ScalingToRef(o.scaling.x, o.scaling.y, o.scaling.z, this._tmpMatrix),
- _e = Vector3.TransformCoordinates(_e, this._tmpMatrix);
- var et;
- $ == 0 ? et = this._tmpAmmoVectorA : $ == 1 ? et = this._tmpAmmoVectorB : et = this._tmpAmmoVectorC,
- et.setValue(_e.x, _e.y, _e.z),
- j.push(et)
- }
- e.addPoint(j[0], !0),
- e.addPoint(j[1], !0),
- e.addPoint(j[2], !0),
- c++
- }
- o.getChildMeshes().forEach(function(tt) {
- c += s._addHullVerts(e, i, tt)
- })
- }
- return c
- }
- ,
- a.prototype._createShape = function(e, i) {
- var o = this;
- i === void 0 && (i = !1);
- var s = e.object, c, d = e.getObjectExtendSize();
- if (!i) {
- var _ = e.object.getChildMeshes ? e.object.getChildMeshes(!0) : [];
- c = new this.bjsAMMO.btCompoundShape;
- var b = 0;
- if (_.forEach(function(it) {
- var nt = it.getPhysicsImpostor();
- if (nt) {
- if (nt.type == PhysicsImpostor.MeshImpostor)
- throw "A child MeshImpostor is not supported. Only primitive impostors are supported as children (eg. box or sphere)";
- var ot = o._createShape(nt)
- , at = it.parent.getWorldMatrix().clone()
- , st = new Vector3;
- at.decompose(st),
- o._tmpAmmoTransform.getOrigin().setValue(it.position.x * st.x, it.position.y * st.y, it.position.z * st.z),
- o._tmpAmmoQuaternion.setValue(it.rotationQuaternion.x, it.rotationQuaternion.y, it.rotationQuaternion.z, it.rotationQuaternion.w),
- o._tmpAmmoTransform.setRotation(o._tmpAmmoQuaternion),
- c.addChildShape(o._tmpAmmoTransform, ot),
- nt.dispose(),
- b++
- }
- }),
- b > 0) {
- if (e.type != PhysicsImpostor.NoImpostor) {
- var k = this._createShape(e, !0);
- k && (this._tmpAmmoTransform.getOrigin().setValue(0, 0, 0),
- this._tmpAmmoQuaternion.setValue(0, 0, 0, 1),
- this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion),
- c.addChildShape(this._tmpAmmoTransform, k))
- }
- return c
- } else
- this.bjsAMMO.destroy(c),
- c = null
- }
- switch (e.type) {
- case PhysicsImpostor.SphereImpostor:
- if (Scalar.WithinEpsilon(d.x, d.y, 1e-4) && Scalar.WithinEpsilon(d.x, d.z, 1e-4))
- c = new this.bjsAMMO.btSphereShape(d.x / 2);
- else {
- var j = [new this.bjsAMMO.btVector3(0,0,0)]
- , $ = [1];
- c = new this.bjsAMMO.btMultiSphereShape(j,$,1),
- c.setLocalScaling(new this.bjsAMMO.btVector3(d.x / 2,d.y / 2,d.z / 2))
- }
- break;
- case PhysicsImpostor.CapsuleImpostor:
- var _e = d.x / 2;
- c = new this.bjsAMMO.btCapsuleShape(_e,d.y - _e * 2);
- break;
- case PhysicsImpostor.CylinderImpostor:
- this._tmpAmmoVectorA.setValue(d.x / 2, d.y / 2, d.z / 2),
- c = new this.bjsAMMO.btCylinderShape(this._tmpAmmoVectorA);
- break;
- case PhysicsImpostor.PlaneImpostor:
- case PhysicsImpostor.BoxImpostor:
- this._tmpAmmoVectorA.setValue(d.x / 2, d.y / 2, d.z / 2),
- c = new this.bjsAMMO.btBoxShape(this._tmpAmmoVectorA);
- break;
- case PhysicsImpostor.MeshImpostor:
- if (e.getParam("mass") == 0) {
- var et = new this.bjsAMMO.btTriangleMesh;
- e._pluginData.toDispose.push(et);
- var rt = this._addMeshVerts(et, s, s);
- rt == 0 ? c = new this.bjsAMMO.btCompoundShape : c = new this.bjsAMMO.btBvhTriangleMeshShape(et);
- break
- }
- case PhysicsImpostor.ConvexHullImpostor:
- var tt = new this.bjsAMMO.btConvexHullShape
- , rt = this._addHullVerts(tt, s, s);
- rt == 0 ? (e._pluginData.toDispose.push(tt),
- c = new this.bjsAMMO.btCompoundShape) : c = tt;
- break;
- case PhysicsImpostor.NoImpostor:
- c = new this.bjsAMMO.btSphereShape(d.x / 2);
- break;
- case PhysicsImpostor.CustomImpostor:
- c = this._createCustom(e);
- break;
- case PhysicsImpostor.SoftbodyImpostor:
- c = this._createSoftbody(e);
- break;
- case PhysicsImpostor.ClothImpostor:
- c = this._createCloth(e);
- break;
- case PhysicsImpostor.RopeImpostor:
- c = this._createRope(e);
- break;
- default:
- Logger$2.Warn("The impostor type is not currently supported by the ammo plugin.");
- break
- }
- return c
- }
- ,
- a.prototype.setTransformationFromPhysicsBody = function(e) {
- e.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform),
- e.object.position.set(this._tmpAmmoTransform.getOrigin().x(), this._tmpAmmoTransform.getOrigin().y(), this._tmpAmmoTransform.getOrigin().z()),
- 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()),
- this._tmpQuaternion.toEulerAnglesToRef(e.object.rotation))
- }
- ,
- a.prototype.setPhysicsBodyTransformation = function(e, i, o) {
- var s = e.physicsBody.getWorldTransform();
- 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)
- if (this._tmpAmmoVectorA.setValue(i.x, i.y, i.z),
- s.setOrigin(this._tmpAmmoVectorA),
- this._tmpAmmoQuaternion.setValue(o.x, o.y, o.z, o.w),
- s.setRotation(this._tmpAmmoQuaternion),
- e.physicsBody.setWorldTransform(s),
- e.mass == 0) {
- var c = e.physicsBody.getMotionState();
- c && c.setWorldTransform(s)
- } else
- e.physicsBody.activate()
- }
- ,
- a.prototype.isSupported = function() {
- return this.bjsAMMO !== void 0
- }
- ,
- a.prototype.setLinearVelocity = function(e, i) {
- this._tmpAmmoVectorA.setValue(i.x, i.y, i.z),
- e.soft ? e.physicsBody.linearVelocity(this._tmpAmmoVectorA) : e.physicsBody.setLinearVelocity(this._tmpAmmoVectorA)
- }
- ,
- a.prototype.setAngularVelocity = function(e, i) {
- this._tmpAmmoVectorA.setValue(i.x, i.y, i.z),
- e.soft ? e.physicsBody.angularVelocity(this._tmpAmmoVectorA) : e.physicsBody.setAngularVelocity(this._tmpAmmoVectorA)
- }
- ,
- a.prototype.getLinearVelocity = function(e) {
- if (e.soft)
- var i = e.physicsBody.linearVelocity();
- else
- var i = e.physicsBody.getLinearVelocity();
- if (!i)
- return null;
- var o = new Vector3(i.x(),i.y(),i.z());
- return this.bjsAMMO.destroy(i),
- o
- }
- ,
- a.prototype.getAngularVelocity = function(e) {
- if (e.soft)
- var i = e.physicsBody.angularVelocity();
- else
- var i = e.physicsBody.getAngularVelocity();
- if (!i)
- return null;
- var o = new Vector3(i.x(),i.y(),i.z());
- return this.bjsAMMO.destroy(i),
- o
- }
- ,
- a.prototype.setBodyMass = function(e, i) {
- e.soft ? e.physicsBody.setTotalMass(i, !1) : e.physicsBody.setMassProps(i),
- e._pluginData.mass = i
- }
- ,
- a.prototype.getBodyMass = function(e) {
- return e._pluginData.mass || 0
- }
- ,
- a.prototype.getBodyFriction = function(e) {
- return e._pluginData.friction || 0
- }
- ,
- a.prototype.setBodyFriction = function(e, i) {
- e.soft ? e.physicsBody.get_m_cfg().set_kDF(i) : e.physicsBody.setFriction(i),
- e._pluginData.friction = i
- }
- ,
- a.prototype.getBodyRestitution = function(e) {
- return e._pluginData.restitution || 0
- }
- ,
- a.prototype.setBodyRestitution = function(e, i) {
- e.physicsBody.setRestitution(i),
- e._pluginData.restitution = i
- }
- ,
- a.prototype.getBodyPressure = function(e) {
- return e.soft ? e._pluginData.pressure || 0 : (Logger$2.Warn("Pressure is not a property of a rigid body"),
- 0)
- }
- ,
- a.prototype.setBodyPressure = function(e, i) {
- e.soft ? e.type === PhysicsImpostor.SoftbodyImpostor ? (e.physicsBody.get_m_cfg().set_kPR(i),
- e._pluginData.pressure = i) : (e.physicsBody.get_m_cfg().set_kPR(0),
- e._pluginData.pressure = 0) : Logger$2.Warn("Pressure can only be applied to a softbody")
- }
- ,
- a.prototype.getBodyStiffness = function(e) {
- return e.soft ? e._pluginData.stiffness || 0 : (Logger$2.Warn("Stiffness is not a property of a rigid body"),
- 0)
- }
- ,
- a.prototype.setBodyStiffness = function(e, i) {
- e.soft ? (i = i < 0 ? 0 : i,
- i = i > 1 ? 1 : i,
- e.physicsBody.get_m_materials().at(0).set_m_kLST(i),
- e._pluginData.stiffness = i) : Logger$2.Warn("Stiffness cannot be applied to a rigid body")
- }
- ,
- a.prototype.getBodyVelocityIterations = function(e) {
- return e.soft ? e._pluginData.velocityIterations || 0 : (Logger$2.Warn("Velocity iterations is not a property of a rigid body"),
- 0)
- }
- ,
- a.prototype.setBodyVelocityIterations = function(e, i) {
- e.soft ? (i = i < 0 ? 0 : i,
- e.physicsBody.get_m_cfg().set_viterations(i),
- e._pluginData.velocityIterations = i) : Logger$2.Warn("Velocity iterations cannot be applied to a rigid body")
- }
- ,
- a.prototype.getBodyPositionIterations = function(e) {
- return e.soft ? e._pluginData.positionIterations || 0 : (Logger$2.Warn("Position iterations is not a property of a rigid body"),
- 0)
- }
- ,
- a.prototype.setBodyPositionIterations = function(e, i) {
- e.soft ? (i = i < 0 ? 0 : i,
- e.physicsBody.get_m_cfg().set_piterations(i),
- e._pluginData.positionIterations = i) : Logger$2.Warn("Position iterations cannot be applied to a rigid body")
- }
- ,
- a.prototype.appendAnchor = function(e, i, o, s, c, d) {
- c === void 0 && (c = 1),
- d === void 0 && (d = !1);
- var _ = e.segments
- , b = Math.round((_ - 1) * o)
- , k = Math.round((_ - 1) * s)
- , j = _ - 1 - k
- , $ = b + _ * j;
- e.physicsBody.appendAnchor($, i.physicsBody, d, c)
- }
- ,
- a.prototype.appendHook = function(e, i, o, s, c) {
- s === void 0 && (s = 1),
- c === void 0 && (c = !1);
- var d = Math.round(e.segments * o);
- e.physicsBody.appendAnchor(d, i.physicsBody, c, s)
- }
- ,
- a.prototype.sleepBody = function(e) {
- e.physicsBody.forceActivationState(0)
- }
- ,
- a.prototype.wakeUpBody = function(e) {
- e.physicsBody.activate()
- }
- ,
- a.prototype.updateDistanceJoint = function(e, i, o) {
- Logger$2.Warn("updateDistanceJoint is not currently supported by the Ammo physics plugin")
- }
- ,
- a.prototype.setMotor = function(e, i, o, s) {
- e.physicsJoint.enableAngularMotor(!0, i, o)
- }
- ,
- a.prototype.setLimit = function(e, i, o) {
- Logger$2.Warn("setLimit is not currently supported by the Ammo physics plugin")
- }
- ,
- a.prototype.syncMeshWithImpostor = function(e, i) {
- var o = i.physicsBody;
- o.getMotionState().getWorldTransform(this._tmpAmmoTransform),
- e.position.x = this._tmpAmmoTransform.getOrigin().x(),
- e.position.y = this._tmpAmmoTransform.getOrigin().y(),
- e.position.z = this._tmpAmmoTransform.getOrigin().z(),
- e.rotationQuaternion && (e.rotationQuaternion.x = this._tmpAmmoTransform.getRotation().x(),
- e.rotationQuaternion.y = this._tmpAmmoTransform.getRotation().y(),
- e.rotationQuaternion.z = this._tmpAmmoTransform.getRotation().z(),
- e.rotationQuaternion.w = this._tmpAmmoTransform.getRotation().w())
- }
- ,
- a.prototype.getRadius = function(e) {
- var i = e.getObjectExtendSize();
- return i.x / 2
- }
- ,
- a.prototype.getBoxSizeToRef = function(e, i) {
- var o = e.getObjectExtendSize();
- i.x = o.x,
- i.y = o.y,
- i.z = o.z
- }
- ,
- a.prototype.dispose = function() {
- this.bjsAMMO.destroy(this.world),
- this.bjsAMMO.destroy(this._solver),
- this.bjsAMMO.destroy(this._overlappingPairCache),
- this.bjsAMMO.destroy(this._dispatcher),
- this.bjsAMMO.destroy(this._collisionConfiguration),
- this.bjsAMMO.destroy(this._tmpAmmoVectorA),
- this.bjsAMMO.destroy(this._tmpAmmoVectorB),
- this.bjsAMMO.destroy(this._tmpAmmoVectorC),
- this.bjsAMMO.destroy(this._tmpAmmoTransform),
- this.bjsAMMO.destroy(this._tmpAmmoQuaternion),
- this.bjsAMMO.destroy(this._tmpAmmoConcreteContactResultCallback),
- this.world = null
- }
- ,
- a.prototype.raycast = function(e, i) {
- this._tmpAmmoVectorRCA = new this.bjsAMMO.btVector3(e.x,e.y,e.z),
- this._tmpAmmoVectorRCB = new this.bjsAMMO.btVector3(i.x,i.y,i.z);
- var o = new this.bjsAMMO.ClosestRayResultCallback(this._tmpAmmoVectorRCA,this._tmpAmmoVectorRCB);
- return this.world.rayTest(this._tmpAmmoVectorRCA, this._tmpAmmoVectorRCB, o),
- this._raycastResult.reset(e, i),
- o.hasHit() && (this._raycastResult.setHitData({
- x: o.get_m_hitNormalWorld().x(),
- y: o.get_m_hitNormalWorld().y(),
- z: o.get_m_hitNormalWorld().z()
- }, {
- x: o.get_m_hitPointWorld().x(),
- y: o.get_m_hitPointWorld().y(),
- z: o.get_m_hitPointWorld().z()
- }),
- this._raycastResult.calculateHitDistance()),
- this.bjsAMMO.destroy(o),
- this.bjsAMMO.destroy(this._tmpAmmoVectorRCA),
- this.bjsAMMO.destroy(this._tmpAmmoVectorRCB),
- this._raycastResult
- }
- ,
- a.DISABLE_COLLISION_FLAG = 4,
- a.KINEMATIC_FLAG = 2,
- a.DISABLE_DEACTIVATION_FLAG = 4,
- a
- }();
- AbstractScene.prototype.removeReflectionProbe = function(a) {
- if (!this.reflectionProbes)
- return -1;
- var e = this.reflectionProbes.indexOf(a);
- return e !== -1 && this.reflectionProbes.splice(e, 1),
- e
- }
- ;
- AbstractScene.prototype.addReflectionProbe = function(a) {
- this.reflectionProbes || (this.reflectionProbes = []),
- this.reflectionProbes.push(a)
- }
- ;
- var ReflectionProbe = function() {
- function a(e, i, o, s, c, d) {
- var _ = this;
- if (s === void 0 && (s = !0),
- c === void 0 && (c = !1),
- d === void 0 && (d = !1),
- this.name = e,
- this._viewMatrix = Matrix.Identity(),
- this._target = Vector3.Zero(),
- this._add = Vector3.Zero(),
- this._invertYAxis = !1,
- this.position = Vector3.Zero(),
- this._parentContainer = null,
- this._scene = o,
- o.getEngine().supportsUniformBuffers) {
- this._sceneUBOs = [];
- for (var b = 0; b < 6; ++b)
- this._sceneUBOs.push(o.createSceneUniformBuffer('Scene for Reflection Probe (name "' + e + '") face #' + b))
- }
- this._scene.reflectionProbes || (this._scene.reflectionProbes = new Array),
- this._scene.reflectionProbes.push(this);
- var k = 0;
- if (c) {
- var j = this._scene.getEngine().getCaps();
- j.textureHalfFloatRender ? k = 2 : j.textureFloatRender && (k = 1)
- }
- this._renderTargetTexture = new RenderTargetTexture(e,i,o,s,!0,k,!0),
- this._renderTargetTexture.gammaSpace = !d;
- var $ = o.getEngine().useReverseDepthBuffer;
- this._renderTargetTexture.onBeforeRenderObservable.add(function(et) {
- switch (_._sceneUBOs && (o.setSceneUniformBuffer(_._sceneUBOs[et]),
- o.getSceneUniformBuffer().unbindEffect()),
- et) {
- case 0:
- _._add.copyFromFloats(1, 0, 0);
- break;
- case 1:
- _._add.copyFromFloats(-1, 0, 0);
- break;
- case 2:
- _._add.copyFromFloats(0, _._invertYAxis ? 1 : -1, 0);
- break;
- case 3:
- _._add.copyFromFloats(0, _._invertYAxis ? -1 : 1, 0);
- break;
- case 4:
- _._add.copyFromFloats(0, 0, o.useRightHandedSystem ? -1 : 1);
- break;
- case 5:
- _._add.copyFromFloats(0, 0, o.useRightHandedSystem ? 1 : -1);
- break
- }
- _._attachedMesh && _.position.copyFrom(_._attachedMesh.getAbsolutePosition()),
- _.position.addToRef(_._add, _._target);
- var tt = o.useRightHandedSystem ? Matrix.LookAtRHToRef : Matrix.LookAtLHToRef
- , rt = o.useRightHandedSystem ? Matrix.PerspectiveFovRH : Matrix.PerspectiveFovLH;
- tt(_.position, _._target, Vector3.Up(), _._viewMatrix),
- o.activeCamera && (_._projectionMatrix = rt(Math.PI / 2, 1, $ ? o.activeCamera.maxZ : o.activeCamera.minZ, $ ? o.activeCamera.minZ : o.activeCamera.maxZ, _._scene.getEngine().isNDCHalfZRange),
- o.setTransformMatrix(_._viewMatrix, _._projectionMatrix),
- o.activeCamera.isRigCamera && !_._renderTargetTexture.activeCamera && (_._renderTargetTexture.activeCamera = o.activeCamera.rigParent || null)),
- o._forcedViewPosition = _.position
- });
- var _e;
- this._renderTargetTexture.onBeforeBindObservable.add(function() {
- var et, tt;
- _._currentSceneUBO = o.getSceneUniformBuffer(),
- (tt = (et = o.getEngine())._debugPushGroup) === null || tt === void 0 || tt.call(et, "reflection probe generation for " + e, 1),
- _e = _._scene.imageProcessingConfiguration.applyByPostProcess,
- d && (o.imageProcessingConfiguration.applyByPostProcess = !0)
- }),
- this._renderTargetTexture.onAfterUnbindObservable.add(function() {
- var et, tt;
- o.imageProcessingConfiguration.applyByPostProcess = _e,
- o._forcedViewPosition = null,
- _._sceneUBOs && o.setSceneUniformBuffer(_._currentSceneUBO),
- o.updateTransformMatrix(!0),
- (tt = (et = o.getEngine())._debugPopGroup) === null || tt === void 0 || tt.call(et, 1)
- })
- }
- return Object.defineProperty(a.prototype, "samples", {
- get: function() {
- return this._renderTargetTexture.samples
- },
- set: function(e) {
- this._renderTargetTexture.samples = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "refreshRate", {
- get: function() {
- return this._renderTargetTexture.refreshRate
- },
- set: function(e) {
- this._renderTargetTexture.refreshRate = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.getScene = function() {
- return this._scene
- }
- ,
- Object.defineProperty(a.prototype, "cubeTexture", {
- get: function() {
- return this._renderTargetTexture
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "renderList", {
- get: function() {
- return this._renderTargetTexture.renderList
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.attachToMesh = function(e) {
- this._attachedMesh = e
- }
- ,
- a.prototype.setRenderingAutoClearDepthStencil = function(e, i) {
- this._renderTargetTexture.setRenderingAutoClearDepthStencil(e, i)
- }
- ,
- a.prototype.dispose = function() {
- var e = this._scene.reflectionProbes.indexOf(this);
- if (e !== -1 && this._scene.reflectionProbes.splice(e, 1),
- this._parentContainer) {
- var i = this._parentContainer.reflectionProbes.indexOf(this);
- i > -1 && this._parentContainer.reflectionProbes.splice(i, 1),
- this._parentContainer = null
- }
- if (this._renderTargetTexture && (this._renderTargetTexture.dispose(),
- this._renderTargetTexture = null),
- this._sceneUBOs) {
- for (var o = 0, s = this._sceneUBOs; o < s.length; o++) {
- var c = s[o];
- c.dispose()
- }
- this._sceneUBOs = []
- }
- }
- ,
- a.prototype.toString = function(e) {
- var i = "Name: " + this.name;
- return e && (i += ", position: " + this.position.toString(),
- this._attachedMesh && (i += ", attached mesh: " + this._attachedMesh.name)),
- i
- }
- ,
- a.prototype.getClassName = function() {
- return "ReflectionProbe"
- }
- ,
- a.prototype.serialize = function() {
- var e = SerializationHelper.Serialize(this, this._renderTargetTexture.serialize());
- return e.isReflectionProbe = !0,
- e
- }
- ,
- a.Parse = function(e, i, o) {
- var s = null;
- if (i.reflectionProbes)
- for (var c = 0; c < i.reflectionProbes.length; c++) {
- var d = i.reflectionProbes[c];
- if (d.name === e.name) {
- s = d;
- break
- }
- }
- return s = SerializationHelper.Parse(function() {
- return s || new a(e.name,e.renderTargetSize,i,e._generateMipMaps)
- }, e, i, o),
- s.cubeTexture._waitingRenderList = e.renderList,
- e._attachedMesh && s.attachToMesh(i.getMeshById(e._attachedMesh)),
- s
- }
- ,
- __decorate([serializeAsMeshReference()], a.prototype, "_attachedMesh", void 0),
- __decorate([serializeAsVector3()], a.prototype, "position", void 0),
- a
- }()
- , BabylonFileLoaderConfiguration = function() {
- function a() {}
- return a.LoaderInjectedPhysicsEngine = void 0,
- a
- }()
- , tempIndexContainer = {}
- , parseMaterialById = function(a, e, i, o) {
- if (!e.materials)
- return null;
- for (var s = 0, c = e.materials.length; s < c; s++) {
- var d = e.materials[s];
- if (d.id === a)
- return Material.Parse(d, i, o)
- }
- return null
- }
- , isDescendantOf = function(a, e, i) {
- for (var o in e)
- if (a.name === e[o])
- return i.push(a.id),
- !0;
- return a.parentId && i.indexOf(a.parentId) !== -1 ? (i.push(a.id),
- !0) : !1
- }
- , logOperation = function(a, e) {
- return a + " of " + (e ? e.file + " from " + e.name + " version: " + e.version + ", exporter version: " + e.exporter_version : "unknown")
- }
- , loadDetailLevels = function(a, e) {
- var i = e;
- if (e._waitingData.lods) {
- if (e._waitingData.lods.ids && e._waitingData.lods.ids.length > 0) {
- var o = e._waitingData.lods.ids
- , s = i.isEnabled(!1);
- if (e._waitingData.lods.distances) {
- var c = e._waitingData.lods.distances;
- if (c.length >= o.length) {
- var d = c.length > o.length ? c[c.length - 1] : 0;
- i.setEnabled(!1);
- for (var _ = 0; _ < o.length; _++) {
- var b = o[_]
- , k = a.getMeshById(b);
- k != null && i.addLODLevel(c[_], k)
- }
- d > 0 && i.addLODLevel(d, null),
- s === !0 && i.setEnabled(!0)
- } else
- Tools.Warn("Invalid level of detail distances for " + e.name)
- }
- }
- e._waitingData.lods = null
- }
- }
- , findParent = function(a, e) {
- if (typeof a != "number")
- return e.getLastEntryById(a);
- var i = tempIndexContainer[a];
- return i
- }
- , loadAssetContainer = function(a, e, i, o, s) {
- s === void 0 && (s = !1);
- var c = new AssetContainer(a)
- , d = "importScene has failed JSON parse";
- try {
- var _ = JSON.parse(e);
- d = "";
- var b = SceneLoader.loggingLevel === SceneLoader.DETAILED_LOGGING, k, j;
- if (_.environmentTexture !== void 0 && _.environmentTexture !== null) {
- var $ = _.isPBR !== void 0 ? _.isPBR : !0;
- if (_.environmentTextureType && _.environmentTextureType === "BABYLON.HDRCubeTexture") {
- var _e = _.environmentTextureSize ? _.environmentTextureSize : 128
- , et = new HDRCubeTexture((_.environmentTexture.match(/https?:\/\//g) ? "" : i) + _.environmentTexture,a,_e,!0,!$);
- _.environmentTextureRotationY && (et.rotationY = _.environmentTextureRotationY),
- a.environmentTexture = et
- } else if (EndsWith(_.environmentTexture, ".env")) {
- var tt = new CubeTexture((_.environmentTexture.match(/https?:\/\//g) ? "" : i) + _.environmentTexture,a);
- _.environmentTextureRotationY && (tt.rotationY = _.environmentTextureRotationY),
- a.environmentTexture = tt
- } else {
- var rt = CubeTexture.CreateFromPrefilteredData((_.environmentTexture.match(/https?:\/\//g) ? "" : i) + _.environmentTexture, a);
- _.environmentTextureRotationY && (rt.rotationY = _.environmentTextureRotationY),
- a.environmentTexture = rt
- }
- if (_.createDefaultSkybox === !0) {
- var it = a.activeCamera !== void 0 && a.activeCamera !== null ? (a.activeCamera.maxZ - a.activeCamera.minZ) / 2 : 1e3
- , nt = _.skyboxBlurLevel || 0;
- a.createDefaultSkybox(a.environmentTexture, $, it, nt)
- }
- c.environmentTexture = a.environmentTexture
- }
- if (_.environmentIntensity !== void 0 && _.environmentIntensity !== null && (a.environmentIntensity = _.environmentIntensity),
- _.lights !== void 0 && _.lights !== null)
- for (k = 0,
- j = _.lights.length; k < j; k++) {
- var ot = _.lights[k]
- , at = Light.Parse(ot, a);
- at && (tempIndexContainer[ot.uniqueId] = at,
- c.lights.push(at),
- at._parentContainer = c,
- d += k === 0 ? `
- Lights:` : "",
- d += `
- ` + at.toString(b))
- }
- if (_.reflectionProbes !== void 0 && _.reflectionProbes !== null)
- for (k = 0,
- j = _.reflectionProbes.length; k < j; k++) {
- var st = _.reflectionProbes[k]
- , ut = ReflectionProbe.Parse(st, a, i);
- ut && (c.reflectionProbes.push(ut),
- ut._parentContainer = c,
- d += k === 0 ? `
- Reflection Probes:` : "",
- d += `
- ` + ut.toString(b))
- }
- if (_.animations !== void 0 && _.animations !== null)
- for (k = 0,
- j = _.animations.length; k < j; k++) {
- var ct = _.animations[k]
- , lt = GetClass("BABYLON.Animation");
- if (lt) {
- var ft = lt.Parse(ct);
- a.animations.push(ft),
- c.animations.push(ft),
- d += k === 0 ? `
- Animations:` : "",
- d += `
- ` + ft.toString(b)
- }
- }
- if (_.materials !== void 0 && _.materials !== null)
- for (k = 0,
- j = _.materials.length; k < j; k++) {
- var ht = _.materials[k]
- , pt = Material.Parse(ht, a, i);
- if (pt) {
- c.materials.push(pt),
- pt._parentContainer = c,
- d += k === 0 ? `
- Materials:` : "",
- d += `
- ` + pt.toString(b);
- var dt = pt.getActiveTextures();
- dt.forEach(function(jt) {
- c.textures.indexOf(jt) == -1 && (c.textures.push(jt),
- jt._parentContainer = c)
- })
- }
- }
- if (_.multiMaterials !== void 0 && _.multiMaterials !== null)
- for (k = 0,
- j = _.multiMaterials.length; k < j; k++) {
- var _t = _.multiMaterials[k]
- , mt = MultiMaterial.ParseMultiMaterial(_t, a);
- c.multiMaterials.push(mt),
- mt._parentContainer = c,
- d += k === 0 ? `
- MultiMaterials:` : "",
- d += `
- ` + mt.toString(b);
- var dt = mt.getActiveTextures();
- dt.forEach(function(Xt) {
- c.textures.indexOf(Xt) == -1 && (c.textures.push(Xt),
- Xt._parentContainer = c)
- })
- }
- if (_.morphTargetManagers !== void 0 && _.morphTargetManagers !== null)
- for (var vt = 0, yt = _.morphTargetManagers; vt < yt.length; vt++) {
- var Et = yt[vt]
- , At = MorphTargetManager.Parse(Et, a);
- c.morphTargetManagers.push(At),
- At._parentContainer = c
- }
- if (_.skeletons !== void 0 && _.skeletons !== null)
- for (k = 0,
- j = _.skeletons.length; k < j; k++) {
- var gt = _.skeletons[k]
- , St = Skeleton.Parse(gt, a);
- c.skeletons.push(St),
- St._parentContainer = c,
- d += k === 0 ? `
- Skeletons:` : "",
- d += `
- ` + St.toString(b)
- }
- var xt = _.geometries;
- if (xt != null) {
- var bt = new Array
- , Rt = xt.vertexData;
- if (Rt != null)
- for (k = 0,
- j = Rt.length; k < j; k++) {
- var Mt = Rt[k];
- bt.push(Geometry.Parse(Mt, a, i))
- }
- bt.forEach(function(jt) {
- jt && (c.geometries.push(jt),
- jt._parentContainer = c)
- })
- }
- if (_.transformNodes !== void 0 && _.transformNodes !== null)
- for (k = 0,
- j = _.transformNodes.length; k < j; k++) {
- var Pt = _.transformNodes[k]
- , It = TransformNode.Parse(Pt, a, i);
- tempIndexContainer[Pt.uniqueId] = It,
- c.transformNodes.push(It),
- It._parentContainer = c
- }
- if (_.meshes !== void 0 && _.meshes !== null)
- for (k = 0,
- j = _.meshes.length; k < j; k++) {
- var Dt = _.meshes[k]
- , Ct = Mesh.Parse(Dt, a, i);
- if (tempIndexContainer[Dt.uniqueId] = Ct,
- c.meshes.push(Ct),
- Ct._parentContainer = c,
- Ct.hasInstances)
- for (var Ot = 0, wt = Ct.instances; Ot < wt.length; Ot++) {
- var Nt = wt[Ot];
- c.meshes.push(Nt),
- Nt._parentContainer = c
- }
- d += k === 0 ? `
- Meshes:` : "",
- d += `
- ` + Ct.toString(b)
- }
- if (_.cameras !== void 0 && _.cameras !== null)
- for (k = 0,
- j = _.cameras.length; k < j; k++) {
- var Ft = _.cameras[k]
- , Vt = Camera$1.Parse(Ft, a);
- tempIndexContainer[Ft.uniqueId] = Vt,
- c.cameras.push(Vt),
- Vt._parentContainer = c,
- d += k === 0 ? `
- Cameras:` : "",
- d += `
- ` + Vt.toString(b)
- }
- if (_.postProcesses !== void 0 && _.postProcesses !== null)
- for (k = 0,
- j = _.postProcesses.length; k < j; k++) {
- var Lt = _.postProcesses[k]
- , kt = PostProcess.Parse(Lt, a, i);
- kt && (c.postProcesses.push(kt),
- kt._parentContainer = c,
- d += k === 0 ? `
- Postprocesses:` : "",
- d += `
- ` + kt.toString())
- }
- if (_.animationGroups !== void 0 && _.animationGroups !== null)
- for (k = 0,
- j = _.animationGroups.length; k < j; k++) {
- var Bt = _.animationGroups[k]
- , Ut = AnimationGroup.Parse(Bt, a);
- c.animationGroups.push(Ut),
- Ut._parentContainer = c,
- d += k === 0 ? `
- AnimationGroups:` : "",
- d += `
- ` + Ut.toString(b)
- }
- for (k = 0,
- j = a.cameras.length; k < j; k++) {
- var Vt = a.cameras[k];
- Vt._waitingParentId && (Vt.parent = findParent(Vt._waitingParentId, a),
- Vt._waitingParentId = null)
- }
- for (k = 0,
- j = a.lights.length; k < j; k++) {
- var Gt = a.lights[k];
- Gt && Gt._waitingParentId && (Gt.parent = findParent(Gt._waitingParentId, a),
- Gt._waitingParentId = null)
- }
- for (k = 0,
- j = a.transformNodes.length; k < j; k++) {
- var Ht = a.transformNodes[k];
- Ht._waitingParentId && (Ht.parent = findParent(Ht._waitingParentId, a),
- Ht._waitingParentId = null)
- }
- for (k = 0,
- j = a.meshes.length; k < j; k++) {
- var Ct = a.meshes[k];
- Ct._waitingParentId && (Ct.parent = findParent(Ct._waitingParentId, a),
- Ct._waitingParentId = null),
- Ct._waitingData.lods && loadDetailLevels(a, Ct)
- }
- for (k = 0,
- j = a.skeletons.length; k < j; k++) {
- var St = a.skeletons[k];
- St._hasWaitingData && (St.bones != null && St.bones.forEach(function(Xt) {
- if (Xt._waitingTransformNodeId) {
- var nr = a.getLastEntryById(Xt._waitingTransformNodeId);
- nr && Xt.linkTransformNode(nr),
- Xt._waitingTransformNodeId = null
- }
- }),
- St._waitingOverrideMeshId && (St.overrideMesh = a.getMeshById(St._waitingOverrideMeshId),
- St._waitingOverrideMeshId = null),
- St._hasWaitingData = null)
- }
- for (k = 0,
- j = a.meshes.length; k < j; k++) {
- var zt = a.meshes[k];
- zt._waitingData.freezeWorldMatrix ? (zt.freezeWorldMatrix(),
- zt._waitingData.freezeWorldMatrix = null) : zt.computeWorldMatrix(!0)
- }
- for (k = 0,
- j = a.lights.length; k < j; k++) {
- var Wt = a.lights[k];
- if (Wt._excludedMeshesIds.length > 0) {
- for (var Kt = 0; Kt < Wt._excludedMeshesIds.length; Kt++) {
- var Qt = a.getMeshById(Wt._excludedMeshesIds[Kt]);
- Qt && Wt.excludedMeshes.push(Qt)
- }
- Wt._excludedMeshesIds = []
- }
- if (Wt._includedOnlyMeshesIds.length > 0) {
- for (var qt = 0; qt < Wt._includedOnlyMeshesIds.length; qt++) {
- var Yt = a.getMeshById(Wt._includedOnlyMeshesIds[qt]);
- Yt && Wt.includedOnlyMeshes.push(Yt)
- }
- Wt._includedOnlyMeshesIds = []
- }
- }
- for (AbstractScene.Parse(_, a, c, i),
- k = 0,
- j = a.meshes.length; k < j; k++) {
- var Ct = a.meshes[k];
- Ct._waitingData.actions && (ActionManager.Parse(Ct._waitingData.actions, Ct, a),
- Ct._waitingData.actions = null)
- }
- _.actions !== void 0 && _.actions !== null && ActionManager.Parse(_.actions, null, a)
- } catch (jt) {
- var Jt = logOperation("loadAssets", _ ? _.producer : "Unknown") + d;
- if (o)
- o(Jt, jt);
- else
- throw Logger$2.Log(Jt),
- jt
- } finally {
- tempIndexContainer = {},
- s || c.removeAllFromScene(),
- d !== null && SceneLoader.loggingLevel !== SceneLoader.NO_LOGGING && Logger$2.Log(logOperation("loadAssets", _ ? _.producer : "Unknown") + (SceneLoader.loggingLevel !== SceneLoader.MINIMAL_LOGGING ? d : ""))
- }
- return c
- };
- SceneLoader.RegisterPlugin({
- name: "babylon.js",
- extensions: ".babylon",
- canDirectLoad: function(a) {
- return a.indexOf("babylon") !== -1
- },
- importMesh: function(a, e, i, o, s, c, d, _) {
- var b = "importMesh has failed JSON parse";
- try {
- var k = JSON.parse(i);
- b = "";
- var j = SceneLoader.loggingLevel === SceneLoader.DETAILED_LOGGING;
- a ? Array.isArray(a) || (a = [a]) : a = null;
- var $ = new Array;
- if (k.meshes !== void 0 && k.meshes !== null) {
- var _e = [], et = [], tt, rt;
- for (tt = 0,
- rt = k.meshes.length; tt < rt; tt++) {
- var it = k.meshes[tt];
- if (a === null || isDescendantOf(it, a, $)) {
- if (a !== null && delete a[a.indexOf(it.name)],
- it.geometryId !== void 0 && it.geometryId !== null && k.geometries !== void 0 && k.geometries !== null) {
- var nt = !1;
- ["boxes", "spheres", "cylinders", "toruses", "grounds", "planes", "torusKnots", "vertexData"].forEach(function(Pt) {
- nt === !0 || !k.geometries[Pt] || !Array.isArray(k.geometries[Pt]) || k.geometries[Pt].forEach(function(It) {
- if (It.id === it.geometryId) {
- switch (Pt) {
- case "vertexData":
- Geometry.Parse(It, e, o);
- break
- }
- nt = !0
- }
- })
- }),
- nt === !1 && Logger$2.Warn("Geometry not found for mesh " + it.id)
- }
- if (it.materialId) {
- var ot = et.indexOf(it.materialId) !== -1;
- if (ot === !1 && k.multiMaterials !== void 0 && k.multiMaterials !== null)
- for (var at = 0, st = k.multiMaterials.length; at < st; at++) {
- var ut = k.multiMaterials[at];
- if (ut.id === it.materialId) {
- for (var ct = 0, lt = ut.materials.length; ct < lt; ct++) {
- var ft = ut.materials[ct];
- et.push(ft);
- var ht = parseMaterialById(ft, k, e, o);
- ht && (b += `
- Material ` + ht.toString(j))
- }
- et.push(ut.id);
- var pt = MultiMaterial.ParseMultiMaterial(ut, e);
- pt && (ot = !0,
- b += `
- Multi-Material ` + pt.toString(j));
- break
- }
- }
- if (ot === !1) {
- et.push(it.materialId);
- var ht = parseMaterialById(it.materialId, k, e, o);
- ht ? b += `
- Material ` + ht.toString(j) : Logger$2.Warn("Material not found for mesh " + it.id)
- }
- }
- if (it.skeletonId > -1 && k.skeletons !== void 0 && k.skeletons !== null) {
- var dt = _e.indexOf(it.skeletonId) > -1;
- if (dt === !1)
- for (var _t = 0, mt = k.skeletons.length; _t < mt; _t++) {
- var vt = k.skeletons[_t];
- if (vt.id === it.skeletonId) {
- var yt = Skeleton.Parse(vt, e);
- d.push(yt),
- _e.push(vt.id),
- b += `
- Skeleton ` + yt.toString(j)
- }
- }
- }
- if (k.morphTargetManagers !== void 0 && k.morphTargetManagers !== null)
- for (var Et = 0, At = k.morphTargetManagers; Et < At.length; Et++) {
- var gt = At[Et];
- MorphTargetManager.Parse(gt, e)
- }
- var St = Mesh.Parse(it, e, o);
- s.push(St),
- b += `
- Mesh ` + St.toString(j)
- }
- }
- var xt;
- for (tt = 0,
- rt = e.meshes.length; tt < rt; tt++)
- xt = e.meshes[tt],
- xt._waitingParentId && (xt.parent = e.getLastEntryById(xt._waitingParentId),
- xt._waitingParentId = null),
- xt._waitingData.lods && loadDetailLevels(e, xt);
- for (tt = 0,
- rt = e.skeletons.length; tt < rt; tt++) {
- var yt = e.skeletons[tt];
- yt._hasWaitingData && (yt.bones != null && yt.bones.forEach(function(It) {
- if (It._waitingTransformNodeId) {
- var Dt = e.getLastEntryById(It._waitingTransformNodeId);
- Dt && It.linkTransformNode(Dt),
- It._waitingTransformNodeId = null
- }
- }),
- yt._waitingOverrideMeshId && (yt.overrideMesh = e.getMeshById(yt._waitingOverrideMeshId),
- yt._waitingOverrideMeshId = null),
- yt._hasWaitingData = null)
- }
- for (tt = 0,
- rt = e.meshes.length; tt < rt; tt++)
- xt = e.meshes[tt],
- xt._waitingData.freezeWorldMatrix ? (xt.freezeWorldMatrix(),
- xt._waitingData.freezeWorldMatrix = null) : xt.computeWorldMatrix(!0)
- }
- if (k.particleSystems !== void 0 && k.particleSystems !== null) {
- var bt = AbstractScene.GetIndividualParser(SceneComponentConstants.NAME_PARTICLESYSTEM);
- if (bt)
- for (tt = 0,
- rt = k.particleSystems.length; tt < rt; tt++) {
- var Rt = k.particleSystems[tt];
- $.indexOf(Rt.emitterId) !== -1 && c.push(bt(Rt, e, o))
- }
- }
- return !0
- } catch (Pt) {
- var Mt = logOperation("importMesh", k ? k.producer : "Unknown") + b;
- if (_)
- _(Mt, Pt);
- else
- throw Logger$2.Log(Mt),
- Pt
- } finally {
- b !== null && SceneLoader.loggingLevel !== SceneLoader.NO_LOGGING && Logger$2.Log(logOperation("importMesh", k ? k.producer : "Unknown") + (SceneLoader.loggingLevel !== SceneLoader.MINIMAL_LOGGING ? b : ""))
- }
- return !1
- },
- load: function(a, e, i, o) {
- var s = "importScene has failed JSON parse";
- try {
- var c = JSON.parse(e);
- if (s = "",
- c.useDelayedTextureLoading !== void 0 && c.useDelayedTextureLoading !== null && (a.useDelayedTextureLoading = c.useDelayedTextureLoading && !SceneLoader.ForceFullSceneLoadingForIncremental),
- c.autoClear !== void 0 && c.autoClear !== null && (a.autoClear = c.autoClear),
- c.clearColor !== void 0 && c.clearColor !== null && (a.clearColor = Color4.FromArray(c.clearColor)),
- c.ambientColor !== void 0 && c.ambientColor !== null && (a.ambientColor = Color3.FromArray(c.ambientColor)),
- c.gravity !== void 0 && c.gravity !== null && (a.gravity = Vector3.FromArray(c.gravity)),
- c.fogMode && c.fogMode !== 0)
- switch (a.fogMode = c.fogMode,
- a.fogColor = Color3.FromArray(c.fogColor),
- a.fogStart = c.fogStart,
- a.fogEnd = c.fogEnd,
- a.fogDensity = c.fogDensity,
- s += " Fog mode for scene: ",
- a.fogMode) {
- case 1:
- s += `exp
- `;
- break;
- case 2:
- s += `exp2
- `;
- break;
- case 3:
- s += `linear
- `;
- break
- }
- if (c.physicsEnabled) {
- var d;
- 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)),
- s = " Physics engine " + (c.physicsEngine ? c.physicsEngine : "oimo") + ` enabled
- `;
- var _ = c.physicsGravity ? Vector3.FromArray(c.physicsGravity) : null;
- a.enablePhysics(_, d)
- }
- c.metadata !== void 0 && c.metadata !== null && (a.metadata = c.metadata),
- c.collisionsEnabled !== void 0 && c.collisionsEnabled !== null && (a.collisionsEnabled = c.collisionsEnabled);
- var b = loadAssetContainer(a, e, i, o, !0);
- return b ? (c.autoAnimate && a.beginAnimation(a, c.autoAnimateFrom, c.autoAnimateTo, c.autoAnimateLoop, c.autoAnimateSpeed || 1),
- c.activeCameraID !== void 0 && c.activeCameraID !== null && a.setActiveCameraById(c.activeCameraID),
- !0) : !1
- } catch (j) {
- var k = logOperation("importScene", c ? c.producer : "Unknown") + s;
- if (o)
- o(k, j);
- else
- throw Logger$2.Log(k),
- j
- } finally {
- s !== null && SceneLoader.loggingLevel !== SceneLoader.NO_LOGGING && Logger$2.Log(logOperation("importScene", c ? c.producer : "Unknown") + (SceneLoader.loggingLevel !== SceneLoader.MINIMAL_LOGGING ? s : ""))
- }
- return !1
- },
- loadAssetContainer: function(a, e, i, o) {
- var s = loadAssetContainer(a, e, i, o);
- return s
- }
- });
- var name$a = "depthPixelShader"
- , shader$a = `#ifdef ALPHATEST
- varying vec2 vUV;
- uniform sampler2D diffuseSampler;
- #endif
- varying float vDepthMetric;
- #ifdef PACKED
- #include<packingFunctions>
- #endif
- void main(void)
- {
- #ifdef ALPHATEST
- if (texture2D(diffuseSampler,vUV).a<0.4)
- discard;
- #endif
- #ifdef NONLINEARDEPTH
- #ifdef PACKED
- gl_FragColor=pack(gl_FragCoord.z);
- #else
- gl_FragColor=vec4(gl_FragCoord.z,0.0,0.0,0.0);
- #endif
- #else
- #ifdef PACKED
- gl_FragColor=pack(vDepthMetric);
- #else
- gl_FragColor=vec4(vDepthMetric,0.0,0.0,1.0);
- #endif
- #endif
- }`;
- ShaderStore.ShadersStore[name$a] = shader$a;
- var name$9 = "depthVertexShader"
- , shader$9 = `
- attribute vec3 position;
- #include<bonesDeclaration>
- #include<bakedVertexAnimationDeclaration>
- #include<morphTargetsVertexGlobalDeclaration>
- #include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
- #include<instancesDeclaration>
- uniform mat4 viewProjection;
- uniform vec2 depthValues;
- #if defined(ALPHATEST) || defined(NEED_UV)
- varying vec2 vUV;
- uniform mat4 diffuseMatrix;
- #ifdef UV1
- attribute vec2 uv;
- #endif
- #ifdef UV2
- attribute vec2 uv2;
- #endif
- #endif
- varying float vDepthMetric;
- void main(void)
- {
- vec3 positionUpdated=position;
- #ifdef UV1
- vec2 uvUpdated=uv;
- #endif
- #include<morphTargetsVertexGlobal>
- #include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
- #include<instancesVertex>
- #include<bonesVertex>
- #include<bakedVertexAnimation>
- gl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);
- #ifdef USE_REVERSE_DEPTHBUFFER
- vDepthMetric=((-gl_Position.z+depthValues.x)/(depthValues.y));
- #else
- vDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y));
- #endif
- #if defined(ALPHATEST) || defined(BASIC_RENDER)
- #ifdef UV1
- vUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));
- #endif
- #ifdef UV2
- vUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
- #endif
- #endif
- }
- `;
- ShaderStore.ShadersStore[name$9] = shader$9;
- var DepthRenderer = function() {
- function a(e, i, o, s, c) {
- var d = this;
- i === void 0 && (i = 1),
- o === void 0 && (o = null),
- s === void 0 && (s = !1),
- c === void 0 && (c = Texture.TRILINEAR_SAMPLINGMODE),
- this.enabled = !0,
- this.forceDepthWriteTransparentMeshes = !1,
- this.useOnlyInActiveCamera = !1,
- this._scene = e,
- this._storeNonLinearDepth = s,
- this.isPacked = i === 0,
- this.isPacked ? this._clearColor = new Color4(1,1,1,1) : this._clearColor = new Color4(1,0,0,1),
- a._SceneComponentInitialization(this._scene);
- var _ = e.getEngine();
- this._camera = o,
- c !== Texture.NEAREST_SAMPLINGMODE && (i === 1 && !_._caps.textureFloatLinearFiltering && (c = Texture.NEAREST_SAMPLINGMODE),
- i === 2 && !_._caps.textureHalfFloatLinearFiltering && (c = Texture.NEAREST_SAMPLINGMODE));
- var b = this.isPacked || !_._features.supportExtendedTextureFormats ? 5 : 6;
- this._depthMap = new RenderTargetTexture("DepthRenderer",{
- width: _.getRenderWidth(),
- height: _.getRenderHeight()
- },this._scene,!1,!0,i,!1,c,void 0,void 0,void 0,b),
- this._depthMap.wrapU = Texture.CLAMP_ADDRESSMODE,
- this._depthMap.wrapV = Texture.CLAMP_ADDRESSMODE,
- this._depthMap.refreshRate = 1,
- this._depthMap.renderParticles = !1,
- this._depthMap.renderList = null,
- this._depthMap.activeCamera = this._camera,
- this._depthMap.ignoreCameraViewport = !0,
- this._depthMap.useCameraPostProcesses = !1,
- this._depthMap.onClearObservable.add(function(j) {
- j.clear(d._clearColor, !0, !0, !0)
- }),
- this._depthMap.onBeforeBindObservable.add(function() {
- var j;
- (j = _._debugPushGroup) === null || j === void 0 || j.call(_, "depth renderer", 1)
- }),
- this._depthMap.onAfterUnbindObservable.add(function() {
- var j;
- (j = _._debugPopGroup) === null || j === void 0 || j.call(_, 1)
- });
- var k = function(j) {
- var $, _e, et = j.getRenderingMesh(), tt = j.getEffectiveMesh(), rt = d._scene, it = rt.getEngine(), nt = j.getMaterial();
- if (tt._internalAbstractMeshDataInfo._isActiveIntermediate = !1,
- !(!nt || tt.infiniteDistance || nt.disableDepthWrite || j.verticesCount === 0 || j._renderId === rt.getRenderId())) {
- var ot = tt._getWorldMatrixDeterminant() < 0
- , at = ($ = et.overrideMaterialSideOrientation) !== null && $ !== void 0 ? $ : nt.sideOrientation;
- (rt.useRightHandedSystem && !ot || !rt.useRightHandedSystem && ot) && (at = at === 0 ? 1 : 0);
- var st = at === 0;
- it.setState(nt.backFaceCulling, 0, !1, st, nt.cullBackFaces);
- var ut = et._getInstancesRenderList(j._id, !!j.getReplacementMesh());
- if (!ut.mustReturn) {
- var ct = it.getCaps().instancedArrays && (ut.visibleInstances[j._id] !== null && ut.visibleInstances[j._id] !== void 0 || et.hasThinInstances)
- , lt = d._camera || rt.activeCamera;
- if (d.isReady(j, ct) && lt) {
- j._renderId = rt.getRenderId();
- var ft = (_e = tt._internalAbstractMeshDataInfo._materialForRenderPass) === null || _e === void 0 ? void 0 : _e[it.currentRenderPassId]
- , ht = j._getDrawWrapper();
- !ht && ft && (ht = ft._getDrawWrapper());
- var pt = lt.mode === Camera$1.ORTHOGRAPHIC_CAMERA;
- if (!ht)
- return;
- var dt = ht.effect;
- it.enableEffect(ht),
- ct || et._bind(j, dt, nt.fillMode),
- ft ? ft.bindForSubMesh(tt.getWorldMatrix(), tt, j) : (dt.setMatrix("viewProjection", rt.getTransformMatrix()),
- dt.setMatrix("world", tt.getWorldMatrix()));
- var _t = void 0
- , mt = void 0;
- if (pt ? (_t = !it.useReverseDepthBuffer && it.isNDCHalfZRange ? 0 : 1,
- mt = it.useReverseDepthBuffer && it.isNDCHalfZRange ? 0 : 1) : (_t = it.useReverseDepthBuffer && it.isNDCHalfZRange ? lt.minZ : it.isNDCHalfZRange ? 0 : lt.minZ,
- mt = it.useReverseDepthBuffer && it.isNDCHalfZRange ? 0 : lt.maxZ),
- dt.setFloat2("depthValues", _t, _t + mt),
- !ft) {
- if (nt && nt.needAlphaTesting()) {
- var vt = nt.getAlphaTestTexture();
- vt && (dt.setTexture("diffuseSampler", vt),
- dt.setMatrix("diffuseMatrix", vt.getTextureMatrix()))
- }
- if (et.useBones && et.computeBonesUsingShaders && et.skeleton) {
- var yt = et.skeleton;
- if (yt.isUsingTextureForMatrices) {
- var Et = yt.getTransformMatrixTexture(et);
- if (!Et)
- return;
- dt.setTexture("boneSampler", Et),
- dt.setFloat("boneTextureWidth", 4 * (yt.bones.length + 1))
- } else
- dt.setMatrices("mBones", yt.getTransformMatrices(et))
- }
- MaterialHelper.BindMorphTargetParameters(et, dt),
- et.morphTargetManager && et.morphTargetManager.isUsingTextureForTargets && et.morphTargetManager._bind(dt)
- }
- et._processRendering(tt, j, dt, nt.fillMode, ut, ct, function(At, gt) {
- return dt.setMatrix("world", gt)
- })
- }
- }
- }
- };
- this._depthMap.customRenderFunction = function(j, $, _e, et) {
- var tt;
- if (et.length)
- for (tt = 0; tt < et.length; tt++)
- k(et.data[tt]);
- for (tt = 0; tt < j.length; tt++)
- k(j.data[tt]);
- for (tt = 0; tt < $.length; tt++)
- k($.data[tt]);
- if (d.forceDepthWriteTransparentMeshes)
- for (tt = 0; tt < _e.length; tt++)
- k(_e.data[tt]);
- else
- for (tt = 0; tt < _e.length; tt++)
- _e.data[tt].getEffectiveMesh()._internalAbstractMeshDataInfo._isActiveIntermediate = !1
- }
- }
- return a.prototype.setMaterialForRendering = function(e, i) {
- this._depthMap.setMaterialForRendering(e, i)
- }
- ,
- a.prototype.isReady = function(e, i) {
- var o, s = this._scene.getEngine(), c = e.getMesh(), d = (o = c._internalAbstractMeshDataInfo._materialForRenderPass) === null || o === void 0 ? void 0 : o[s.currentRenderPassId];
- if (d)
- return d.isReadyForSubMesh(c, e, i);
- var _ = e.getMaterial();
- if (!_ || _.disableDepthWrite)
- return !1;
- var b = []
- , k = [VertexBuffer.PositionKind];
- if (_ && _.needAlphaTesting() && _.getAlphaTestTexture() && (b.push("#define ALPHATEST"),
- c.isVerticesDataPresent(VertexBuffer.UVKind) && (k.push(VertexBuffer.UVKind),
- b.push("#define UV1")),
- c.isVerticesDataPresent(VertexBuffer.UV2Kind) && (k.push(VertexBuffer.UV2Kind),
- b.push("#define UV2"))),
- c.useBones && c.computeBonesUsingShaders) {
- k.push(VertexBuffer.MatricesIndicesKind),
- k.push(VertexBuffer.MatricesWeightsKind),
- c.numBoneInfluencers > 4 && (k.push(VertexBuffer.MatricesIndicesExtraKind),
- k.push(VertexBuffer.MatricesWeightsExtraKind)),
- b.push("#define NUM_BONE_INFLUENCERS " + c.numBoneInfluencers),
- b.push("#define BonesPerMesh " + (c.skeleton ? c.skeleton.bones.length + 1 : 0));
- var j = e.getRenderingMesh().skeleton;
- j != null && j.isUsingTextureForMatrices && b.push("#define BONETEXTURE")
- } else
- b.push("#define NUM_BONE_INFLUENCERS 0");
- var $ = c.morphTargetManager
- , _e = 0;
- $ && $.numInfluencers > 0 && (_e = $.numInfluencers,
- b.push("#define MORPHTARGETS"),
- b.push("#define NUM_MORPH_INFLUENCERS " + _e),
- $.isUsingTextureForTargets && b.push("#define MORPHTARGETS_TEXTURE"),
- MaterialHelper.PrepareAttributesForMorphTargetsInfluencers(k, c, _e)),
- i && (b.push("#define INSTANCES"),
- MaterialHelper.PushAttributesForInstances(k),
- e.getRenderingMesh().hasThinInstances && b.push("#define THIN_INSTANCES")),
- this._storeNonLinearDepth && b.push("#define NONLINEARDEPTH"),
- this.isPacked && b.push("#define PACKED");
- var et = e._getDrawWrapper(void 0, !0)
- , tt = et.defines
- , rt = b.join(`
- `);
- 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, {
- maxSimultaneousMorphTargets: _e
- }), rt),
- et.effect.isReady()
- }
- ,
- a.prototype.getDepthMap = function() {
- return this._depthMap
- }
- ,
- a.prototype.dispose = function() {
- var e = [];
- for (var i in this._scene._depthRenderer) {
- var o = this._scene._depthRenderer[i];
- o === this && e.push(i)
- }
- if (e.length > 0) {
- this._depthMap.dispose();
- for (var s = 0, c = e; s < c.length; s++) {
- var d = c[s];
- delete this._scene._depthRenderer[d]
- }
- }
- }
- ,
- a._SceneComponentInitialization = function(e) {
- throw _WarnImport("DepthRendererSceneComponent")
- }
- ,
- a
- }()
- , name$8 = "minmaxReduxPixelShader"
- , shader$8 = `varying vec2 vUV;
- uniform sampler2D textureSampler;
- #if defined(INITIAL)
- uniform sampler2D sourceTexture;
- uniform vec2 texSize;
- void main(void)
- {
- ivec2 coord=ivec2(vUV*(texSize-1.0));
- float f1=texelFetch(sourceTexture,coord,0).r;
- float f2=texelFetch(sourceTexture,coord+ivec2(1,0),0).r;
- float f3=texelFetch(sourceTexture,coord+ivec2(1,1),0).r;
- float f4=texelFetch(sourceTexture,coord+ivec2(0,1),0).r;
- float minz=min(min(min(f1,f2),f3),f4);
- #ifdef DEPTH_REDUX
- 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);
- #else
- float maxz=max(max(max(f1,f2),f3),f4);
- #endif
- glFragColor=vec4(minz,maxz,0.,0.);
- }
- #elif defined(MAIN)
- uniform vec2 texSize;
- void main(void)
- {
- ivec2 coord=ivec2(vUV*(texSize-1.0));
- vec2 f1=texelFetch(textureSampler,coord,0).rg;
- vec2 f2=texelFetch(textureSampler,coord+ivec2(1,0),0).rg;
- vec2 f3=texelFetch(textureSampler,coord+ivec2(1,1),0).rg;
- vec2 f4=texelFetch(textureSampler,coord+ivec2(0,1),0).rg;
- float minz=min(min(min(f1.x,f2.x),f3.x),f4.x);
- float maxz=max(max(max(f1.y,f2.y),f3.y),f4.y);
- glFragColor=vec4(minz,maxz,0.,0.);
- }
- #elif defined(ONEBEFORELAST)
- uniform ivec2 texSize;
- void main(void)
- {
- ivec2 coord=ivec2(vUV*vec2(texSize-1));
- vec2 f1=texelFetch(textureSampler,coord % texSize,0).rg;
- vec2 f2=texelFetch(textureSampler,(coord+ivec2(1,0)) % texSize,0).rg;
- vec2 f3=texelFetch(textureSampler,(coord+ivec2(1,1)) % texSize,0).rg;
- vec2 f4=texelFetch(textureSampler,(coord+ivec2(0,1)) % texSize,0).rg;
- float minz=min(f1.x,f2.x);
- float maxz=max(f1.y,f2.y);
- glFragColor=vec4(minz,maxz,0.,0.);
- }
- #elif defined(LAST)
- void main(void)
- {
- glFragColor=vec4(0.);
- discard;
- }
- #endif
- `;
- ShaderStore.ShadersStore[name$8] = shader$8;
- var MinMaxReducer = function() {
- function a(e) {
- var i = this;
- this.onAfterReductionPerformed = new Observable,
- this._forceFullscreenViewport = !0,
- this._activated = !1,
- this._camera = e,
- this._postProcessManager = new PostProcessManager(e.getScene()),
- this._onContextRestoredObserver = e.getEngine().onContextRestoredObservable.add(function() {
- i._postProcessManager._rebuild()
- })
- }
- return Object.defineProperty(a.prototype, "sourceTexture", {
- get: function() {
- return this._sourceTexture
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.setSourceTexture = function(e, i, o, s) {
- var c = this;
- if (o === void 0 && (o = 2),
- s === void 0 && (s = !0),
- e !== this._sourceTexture) {
- this.dispose(!1),
- this._sourceTexture = e,
- this._reductionSteps = [],
- this._forceFullscreenViewport = s;
- var d = this._camera.getScene()
- , _ = new PostProcess("Initial reduction phase","minmaxRedux",["texSize"],["sourceTexture"],1,null,1,d.getEngine(),!1,"#define INITIAL" + (i ? `
- #define DEPTH_REDUX` : ""),o,void 0,void 0,void 0,7);
- _.autoClear = !1,
- _.forceFullscreenViewport = s;
- var b = this._sourceTexture.getRenderWidth()
- , k = this._sourceTexture.getRenderHeight();
- _.onApply = function(et, tt) {
- return function(rt) {
- rt.setTexture("sourceTexture", c._sourceTexture),
- rt.setFloat2("texSize", et, tt)
- }
- }(b, k),
- this._reductionSteps.push(_);
- for (var j = 1; b > 1 || k > 1; ) {
- b = Math.max(Math.round(b / 2), 1),
- k = Math.max(Math.round(k / 2), 1);
- var $ = new PostProcess("Reduction phase " + j,"minmaxRedux",["texSize"],null,{
- width: b,
- height: k
- },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);
- if ($.autoClear = !1,
- $.forceFullscreenViewport = s,
- $.onApply = function(et, tt) {
- return function(rt) {
- et == 1 || tt == 1 ? rt.setInt2("texSize", et, tt) : rt.setFloat2("texSize", et, tt)
- }
- }(b, k),
- this._reductionSteps.push($),
- j++,
- b == 1 && k == 1) {
- var _e = function(et, tt, rt) {
- var it = new Float32Array(4 * et * tt)
- , nt = {
- min: 0,
- max: 0
- };
- return function() {
- d.getEngine()._readTexturePixels(rt.inputTexture.texture, et, tt, -1, 0, it, !1),
- nt.min = it[0],
- nt.max = it[1],
- c.onAfterReductionPerformed.notifyObservers(nt)
- }
- };
- $.onAfterRenderObservable.add(_e(b, k, $))
- }
- }
- }
- }
- ,
- Object.defineProperty(a.prototype, "refreshRate", {
- get: function() {
- return this._sourceTexture ? this._sourceTexture.refreshRate : -1
- },
- set: function(e) {
- this._sourceTexture && (this._sourceTexture.refreshRate = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "activated", {
- get: function() {
- return this._activated
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.activate = function() {
- var e = this;
- this._onAfterUnbindObserver || !this._sourceTexture || (this._onAfterUnbindObserver = this._sourceTexture.onAfterUnbindObservable.add(function() {
- var i, o, s = e._camera.getScene().getEngine();
- (i = s._debugPushGroup) === null || i === void 0 || i.call(s, "min max reduction", 1),
- e._reductionSteps[0].activate(e._camera),
- e._postProcessManager.directRender(e._reductionSteps, e._reductionSteps[0].inputTexture, e._forceFullscreenViewport),
- s.unBindFramebuffer(e._reductionSteps[0].inputTexture, !1),
- (o = s._debugPopGroup) === null || o === void 0 || o.call(s, 1)
- }),
- this._activated = !0)
- }
- ,
- a.prototype.deactivate = function() {
- !this._onAfterUnbindObserver || !this._sourceTexture || (this._sourceTexture.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),
- this._onAfterUnbindObserver = null,
- this._activated = !1)
- }
- ,
- a.prototype.dispose = function(e) {
- if (e === void 0 && (e = !0),
- e && (this.onAfterReductionPerformed.clear(),
- this._onContextRestoredObserver && (this._camera.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),
- this._onContextRestoredObserver = null)),
- this.deactivate(),
- this._reductionSteps) {
- for (var i = 0; i < this._reductionSteps.length; ++i)
- this._reductionSteps[i].dispose();
- this._reductionSteps = null
- }
- this._postProcessManager && e && this._postProcessManager.dispose(),
- this._sourceTexture = null
- }
- ,
- a
- }()
- , DepthReducer = function(a) {
- __extends(e, a);
- function e(i) {
- return a.call(this, i) || this
- }
- return Object.defineProperty(e.prototype, "depthRenderer", {
- get: function() {
- return this._depthRenderer
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.setDepthRenderer = function(i, o, s) {
- i === void 0 && (i = null),
- o === void 0 && (o = 2),
- s === void 0 && (s = !0);
- var c = this._camera.getScene();
- this._depthRenderer && (delete c._depthRenderer[this._depthRendererId],
- this._depthRenderer.dispose(),
- this._depthRenderer = null),
- i === null && (c._depthRenderer || (c._depthRenderer = {}),
- i = this._depthRenderer = new DepthRenderer(c,o,this._camera,!1,1),
- i.enabled = !1,
- this._depthRendererId = "minmax" + this._camera.id,
- c._depthRenderer[this._depthRendererId] = i),
- a.prototype.setSourceTexture.call(this, i.getDepthMap(), !0, o, s)
- }
- ,
- e.prototype.setSourceTexture = function(i, o, s, c) {
- s === void 0 && (s = 2),
- c === void 0 && (c = !0),
- a.prototype.setSourceTexture.call(this, i, o, s, c)
- }
- ,
- e.prototype.activate = function() {
- this._depthRenderer && (this._depthRenderer.enabled = !0),
- a.prototype.activate.call(this)
- }
- ,
- e.prototype.deactivate = function() {
- a.prototype.deactivate.call(this),
- this._depthRenderer && (this._depthRenderer.enabled = !1)
- }
- ,
- e.prototype.dispose = function(i) {
- if (i === void 0 && (i = !0),
- a.prototype.dispose.call(this, i),
- this._depthRenderer && i) {
- var o = this._depthRenderer.getDepthMap().getScene();
- o && delete o._depthRenderer[this._depthRendererId],
- this._depthRenderer.dispose(),
- this._depthRenderer = null
- }
- }
- ,
- e
- }(MinMaxReducer)
- , UpDir = Vector3.Up()
- , ZeroVec = Vector3.Zero()
- , tmpv1 = new Vector3
- , tmpv2 = new Vector3
- , tmpMatrix = new Matrix
- , CascadedShadowGenerator = function(a) {
- __extends(e, a);
- function e(i, o, s) {
- var c = this;
- if (!e.IsSupported) {
- Logger$2.Error("CascadedShadowMap is not supported by the current engine.");
- return
- }
- return c = a.call(this, i, o, s) || this,
- c.usePercentageCloserFiltering = !0,
- c
- }
- return e.prototype._validateFilter = function(i) {
- return i === ShadowGenerator.FILTER_NONE || i === ShadowGenerator.FILTER_PCF || i === ShadowGenerator.FILTER_PCSS ? i : (console.error('Unsupported filter "' + i + '"!'),
- ShadowGenerator.FILTER_NONE)
- }
- ,
- Object.defineProperty(e.prototype, "numCascades", {
- get: function() {
- return this._numCascades
- },
- set: function(i) {
- i = Math.min(Math.max(i, e.MIN_CASCADES_COUNT), e.MAX_CASCADES_COUNT),
- i !== this._numCascades && (this._numCascades = i,
- this.recreateShadowMap(),
- this._recreateSceneUBOs())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "freezeShadowCastersBoundingInfo", {
- get: function() {
- return this._freezeShadowCastersBoundingInfo
- },
- set: function(i) {
- this._freezeShadowCastersBoundingInfoObservable && i && (this._scene.onBeforeRenderObservable.remove(this._freezeShadowCastersBoundingInfoObservable),
- this._freezeShadowCastersBoundingInfoObservable = null),
- !this._freezeShadowCastersBoundingInfoObservable && !i && (this._freezeShadowCastersBoundingInfoObservable = this._scene.onBeforeRenderObservable.add(this._computeShadowCastersBoundingInfo.bind(this))),
- this._freezeShadowCastersBoundingInfo = i,
- i && this._computeShadowCastersBoundingInfo()
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._computeShadowCastersBoundingInfo = function() {
- if (this._scbiMin.copyFromFloats(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE),
- this._scbiMax.copyFromFloats(Number.MIN_VALUE, Number.MIN_VALUE, Number.MIN_VALUE),
- this._shadowMap && this._shadowMap.renderList) {
- for (var i = this._shadowMap.renderList, o = 0; o < i.length; o++) {
- var s = i[o];
- if (!!s) {
- var c = s.getBoundingInfo()
- , d = c.boundingBox;
- this._scbiMin.minimizeInPlace(d.minimumWorld),
- this._scbiMax.maximizeInPlace(d.maximumWorld)
- }
- }
- for (var _ = this._scene.meshes, o = 0; o < _.length; o++) {
- var s = _[o];
- if (!(!s || !s.isVisible || !s.isEnabled || !s.receiveShadows)) {
- var c = s.getBoundingInfo()
- , d = c.boundingBox;
- this._scbiMin.minimizeInPlace(d.minimumWorld),
- this._scbiMax.maximizeInPlace(d.maximumWorld)
- }
- }
- }
- this._shadowCastersBoundingInfo.reConstruct(this._scbiMin, this._scbiMax)
- }
- ,
- Object.defineProperty(e.prototype, "shadowCastersBoundingInfo", {
- get: function() {
- return this._shadowCastersBoundingInfo
- },
- set: function(i) {
- this._shadowCastersBoundingInfo = i
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.setMinMaxDistance = function(i, o) {
- this._minDistance === i && this._maxDistance === o || (i > o && (i = 0,
- o = 1),
- i < 0 && (i = 0),
- o > 1 && (o = 1),
- this._minDistance = i,
- this._maxDistance = o,
- this._breaksAreDirty = !0)
- }
- ,
- Object.defineProperty(e.prototype, "minDistance", {
- get: function() {
- return this._minDistance
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "maxDistance", {
- get: function() {
- return this._maxDistance
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getClassName = function() {
- return e.CLASSNAME
- }
- ,
- e.prototype.getCascadeMinExtents = function(i) {
- return i >= 0 && i < this._numCascades ? this._cascadeMinExtents[i] : null
- }
- ,
- e.prototype.getCascadeMaxExtents = function(i) {
- return i >= 0 && i < this._numCascades ? this._cascadeMaxExtents[i] : null
- }
- ,
- Object.defineProperty(e.prototype, "shadowMaxZ", {
- get: function() {
- return !this._scene || !this._scene.activeCamera ? 0 : this._shadowMaxZ
- },
- set: function(i) {
- if (!this._scene || !this._scene.activeCamera) {
- this._shadowMaxZ = i;
- return
- }
- this._shadowMaxZ === i || i < this._scene.activeCamera.minZ || i > this._scene.activeCamera.maxZ || (this._shadowMaxZ = i,
- this._light._markMeshesAsLightDirty(),
- this._breaksAreDirty = !0)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "debug", {
- get: function() {
- return this._debug
- },
- set: function(i) {
- this._debug = i,
- this._light._markMeshesAsLightDirty()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "depthClamp", {
- get: function() {
- return this._depthClamp
- },
- set: function(i) {
- this._depthClamp = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cascadeBlendPercentage", {
- get: function() {
- return this._cascadeBlendPercentage
- },
- set: function(i) {
- this._cascadeBlendPercentage = i,
- this._light._markMeshesAsLightDirty()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "lambda", {
- get: function() {
- return this._lambda
- },
- set: function(i) {
- var o = Math.min(Math.max(i, 0), 1);
- this._lambda != o && (this._lambda = o,
- this._breaksAreDirty = !0)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getCascadeViewMatrix = function(i) {
- return i >= 0 && i < this._numCascades ? this._viewMatrices[i] : null
- }
- ,
- e.prototype.getCascadeProjectionMatrix = function(i) {
- return i >= 0 && i < this._numCascades ? this._projectionMatrices[i] : null
- }
- ,
- e.prototype.getCascadeTransformMatrix = function(i) {
- return i >= 0 && i < this._numCascades ? this._transformMatrices[i] : null
- }
- ,
- e.prototype.setDepthRenderer = function(i) {
- this._depthRenderer = i,
- this._depthReducer && this._depthReducer.setDepthRenderer(this._depthRenderer)
- }
- ,
- Object.defineProperty(e.prototype, "autoCalcDepthBounds", {
- get: function() {
- return this._autoCalcDepthBounds
- },
- set: function(i) {
- var o = this
- , s = this._scene.activeCamera;
- if (!!s) {
- if (this._autoCalcDepthBounds = i,
- !i) {
- this._depthReducer && this._depthReducer.deactivate(),
- this.setMinMaxDistance(0, 1);
- return
- }
- this._depthReducer || (this._depthReducer = new DepthReducer(s),
- this._depthReducer.onAfterReductionPerformed.add(function(c) {
- var d = c.min
- , _ = c.max;
- d >= _ && (d = 0,
- _ = 1),
- (d != o._minDistance || _ != o._maxDistance) && o.setMinMaxDistance(d, _)
- }),
- this._depthReducer.setDepthRenderer(this._depthRenderer)),
- this._depthReducer.activate()
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "autoCalcDepthBoundsRefreshRate", {
- get: function() {
- var i, o, s;
- 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
- },
- set: function(i) {
- var o;
- !((o = this._depthReducer) === null || o === void 0) && o.depthRenderer && (this._depthReducer.depthRenderer.getDepthMap().refreshRate = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.splitFrustum = function() {
- this._breaksAreDirty = !0
- }
- ,
- e.prototype._splitFrustum = function() {
- var i = this._scene.activeCamera;
- if (!!i) {
- 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) {
- var et = (_e + 1) / this._numCascades
- , tt = b * Math.pow($, et)
- , rt = b + j * et
- , it = this._lambda * (tt - rt) + rt;
- this._cascades[_e].prevBreakDistance = _e === 0 ? d : this._cascades[_e - 1].breakDistance,
- this._cascades[_e].breakDistance = (it - o) / c,
- this._viewSpaceFrustumsZ[_e] = it,
- this._frustumLengths[_e] = (this._cascades[_e].breakDistance - this._cascades[_e].prevBreakDistance) * c
- }
- this._breaksAreDirty = !1
- }
- }
- ,
- e.prototype._computeMatrices = function() {
- var i = this._scene
- , o = i.activeCamera;
- if (!!o) {
- Vector3.NormalizeToRef(this._light.getShadowDirection(0), this._lightDirection),
- Math.abs(Vector3.Dot(this._lightDirection, Vector3.Up())) === 1 && (this._lightDirection.z = 1e-13),
- this._cachedDirection.copyFrom(this._lightDirection);
- for (var s = i.getEngine().useReverseDepthBuffer, c = 0; c < this._numCascades; ++c) {
- this._computeFrustumInWorldSpace(c),
- this._computeCascadeFrustum(c),
- this._cascadeMaxExtents[c].subtractToRef(this._cascadeMinExtents[c], tmpv1),
- this._frustumCenter[c].addToRef(this._lightDirection.scale(this._cascadeMinExtents[c].z), this._shadowCameraPos[c]),
- Matrix.LookAtLHToRef(this._shadowCameraPos[c], this._frustumCenter[c], UpDir, this._viewMatrices[c]);
- var d = 0
- , _ = tmpv1.z
- , b = this._shadowCastersBoundingInfo;
- b.update(this._viewMatrices[c]),
- _ = Math.min(_, b.boundingBox.maximumWorld.z),
- !this._depthClamp || this.filter === ShadowGenerator.FILTER_PCSS ? d = Math.min(d, b.boundingBox.minimumWorld.z) : d = Math.max(d, b.boundingBox.minimumWorld.z),
- 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),
- this._cascadeMinExtents[c].z = d,
- this._cascadeMaxExtents[c].z = _,
- this._viewMatrices[c].multiplyToRef(this._projectionMatrices[c], this._transformMatrices[c]),
- Vector3.TransformCoordinatesToRef(ZeroVec, this._transformMatrices[c], tmpv1),
- tmpv1.scaleInPlace(this._mapSize / 2),
- tmpv2.copyFromFloats(Math.round(tmpv1.x), Math.round(tmpv1.y), Math.round(tmpv1.z)),
- tmpv2.subtractInPlace(tmpv1).scaleInPlace(2 / this._mapSize),
- Matrix.TranslationToRef(tmpv2.x, tmpv2.y, 0, tmpMatrix),
- this._projectionMatrices[c].multiplyToRef(tmpMatrix, this._projectionMatrices[c]),
- this._viewMatrices[c].multiplyToRef(this._projectionMatrices[c], this._transformMatrices[c]),
- this._transformMatrices[c].copyToArray(this._transformMatricesAsArray, c * 16)
- }
- }
- }
- ,
- e.prototype._computeFrustumInWorldSpace = function(i) {
- if (!!this._scene.activeCamera) {
- var o = this._cascades[i].prevBreakDistance
- , s = this._cascades[i].breakDistance
- , c = this._scene.getEngine().isNDCHalfZRange;
- this._scene.activeCamera.getViewMatrix();
- for (var d = Matrix.Invert(this._scene.activeCamera.getTransformationMatrix()), _ = this._scene.getEngine().useReverseDepthBuffer ? 4 : 0, b = 0; b < e.frustumCornersNDCSpace.length; ++b)
- tmpv1.copyFrom(e.frustumCornersNDCSpace[(b + _) % e.frustumCornersNDCSpace.length]),
- c && tmpv1.z === -1 && (tmpv1.z = 0),
- Vector3.TransformCoordinatesToRef(tmpv1, d, this._frustumCornersWorldSpace[i][b]);
- for (var b = 0; b < e.frustumCornersNDCSpace.length / 2; ++b)
- tmpv1.copyFrom(this._frustumCornersWorldSpace[i][b + 4]).subtractInPlace(this._frustumCornersWorldSpace[i][b]),
- tmpv2.copyFrom(tmpv1).scaleInPlace(o),
- tmpv1.scaleInPlace(s),
- tmpv1.addInPlace(this._frustumCornersWorldSpace[i][b]),
- this._frustumCornersWorldSpace[i][b + 4].copyFrom(tmpv1),
- this._frustumCornersWorldSpace[i][b].addInPlace(tmpv2)
- }
- }
- ,
- e.prototype._computeCascadeFrustum = function(i) {
- this._cascadeMinExtents[i].copyFromFloats(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE),
- this._cascadeMaxExtents[i].copyFromFloats(Number.MIN_VALUE, Number.MIN_VALUE, Number.MIN_VALUE),
- this._frustumCenter[i].copyFromFloats(0, 0, 0);
- var o = this._scene.activeCamera;
- if (!!o) {
- for (var s = 0; s < this._frustumCornersWorldSpace[i].length; ++s)
- this._frustumCenter[i].addInPlace(this._frustumCornersWorldSpace[i][s]);
- if (this._frustumCenter[i].scaleInPlace(1 / this._frustumCornersWorldSpace[i].length),
- this.stabilizeCascades) {
- for (var c = 0, s = 0; s < this._frustumCornersWorldSpace[i].length; ++s) {
- var d = this._frustumCornersWorldSpace[i][s].subtractToRef(this._frustumCenter[i], tmpv1).length();
- c = Math.max(c, d)
- }
- c = Math.ceil(c * 16) / 16,
- this._cascadeMaxExtents[i].copyFromFloats(c, c, c),
- this._cascadeMinExtents[i].copyFromFloats(-c, -c, -c)
- } else {
- var _ = this._frustumCenter[i];
- this._frustumCenter[i].addToRef(this._lightDirection, tmpv1),
- Matrix.LookAtLHToRef(_, tmpv1, UpDir, tmpMatrix);
- for (var s = 0; s < this._frustumCornersWorldSpace[i].length; ++s)
- Vector3.TransformCoordinatesToRef(this._frustumCornersWorldSpace[i][s], tmpMatrix, tmpv1),
- this._cascadeMinExtents[i].minimizeInPlace(tmpv1),
- this._cascadeMaxExtents[i].maximizeInPlace(tmpv1)
- }
- }
- }
- ,
- e.prototype._recreateSceneUBOs = function() {
- if (this._disposeSceneUBOs(),
- this._sceneUBOs)
- for (var i = 0; i < this._numCascades; ++i)
- this._sceneUBOs.push(this._scene.createSceneUniformBuffer('Scene for CSM Shadow Generator (light "' + this._light.name + '" cascade #' + i + ")"))
- }
- ,
- Object.defineProperty(e, "IsSupported", {
- get: function() {
- var i = EngineStore.LastCreatedEngine;
- return i ? i._features.supportCSM : !1
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._initializeGenerator = function() {
- var i, o, s, c, d, _, b, k, j, $, _e, et, tt, rt, it, nt, ot, at, st, ut;
- this.penumbraDarkness = (i = this.penumbraDarkness) !== null && i !== void 0 ? i : 1,
- this._numCascades = (o = this._numCascades) !== null && o !== void 0 ? o : e.DEFAULT_CASCADES_COUNT,
- this.stabilizeCascades = (s = this.stabilizeCascades) !== null && s !== void 0 ? s : !1,
- this._freezeShadowCastersBoundingInfoObservable = (c = this._freezeShadowCastersBoundingInfoObservable) !== null && c !== void 0 ? c : null,
- this.freezeShadowCastersBoundingInfo = (d = this.freezeShadowCastersBoundingInfo) !== null && d !== void 0 ? d : !1,
- this._scbiMin = (_ = this._scbiMin) !== null && _ !== void 0 ? _ : new Vector3(0,0,0),
- this._scbiMax = (b = this._scbiMax) !== null && b !== void 0 ? b : new Vector3(0,0,0),
- this._shadowCastersBoundingInfo = (k = this._shadowCastersBoundingInfo) !== null && k !== void 0 ? k : new BoundingInfo(new Vector3(0,0,0),new Vector3(0,0,0)),
- this._breaksAreDirty = (j = this._breaksAreDirty) !== null && j !== void 0 ? j : !0,
- this._minDistance = ($ = this._minDistance) !== null && $ !== void 0 ? $ : 0,
- this._maxDistance = (_e = this._maxDistance) !== null && _e !== void 0 ? _e : 1,
- this._currentLayer = (et = this._currentLayer) !== null && et !== void 0 ? et : 0,
- 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,
- this._debug = (nt = this._debug) !== null && nt !== void 0 ? nt : !1,
- this._depthClamp = (ot = this._depthClamp) !== null && ot !== void 0 ? ot : !0,
- this._cascadeBlendPercentage = (at = this._cascadeBlendPercentage) !== null && at !== void 0 ? at : .1,
- this._lambda = (st = this._lambda) !== null && st !== void 0 ? st : .5,
- this._autoCalcDepthBounds = (ut = this._autoCalcDepthBounds) !== null && ut !== void 0 ? ut : !1,
- this._recreateSceneUBOs(),
- a.prototype._initializeGenerator.call(this)
- }
- ,
- e.prototype._createTargetRenderTexture = function() {
- var i = this._scene.getEngine()
- , o = {
- width: this._mapSize,
- height: this._mapSize,
- layers: this.numCascades
- };
- this._shadowMap = new RenderTargetTexture(this._light.name + "_CSMShadowMap",o,this._scene,!1,!0,this._textureType,!1,void 0,!1,!1,void 0),
- this._shadowMap.createDepthStencilTexture(i.useReverseDepthBuffer ? 516 : 513, !0)
- }
- ,
- e.prototype._initializeShadowMap = function() {
- var i = this;
- if (a.prototype._initializeShadowMap.call(this),
- this._shadowMap !== null) {
- this._transformMatricesAsArray = new Float32Array(this._numCascades * 16),
- this._viewSpaceFrustumsZ = new Array(this._numCascades),
- this._frustumLengths = new Array(this._numCascades),
- this._lightSizeUVCorrection = new Array(this._numCascades * 2),
- this._depthCorrection = new Array(this._numCascades),
- this._cascades = [],
- this._viewMatrices = [],
- this._projectionMatrices = [],
- this._transformMatrices = [],
- this._cascadeMinExtents = [],
- this._cascadeMaxExtents = [],
- this._frustumCenter = [],
- this._shadowCameraPos = [],
- this._frustumCornersWorldSpace = [];
- for (var o = 0; o < this._numCascades; ++o) {
- this._cascades[o] = {
- prevBreakDistance: 0,
- breakDistance: 0
- },
- this._viewMatrices[o] = Matrix.Zero(),
- this._projectionMatrices[o] = Matrix.Zero(),
- this._transformMatrices[o] = Matrix.Zero(),
- this._cascadeMinExtents[o] = new Vector3,
- this._cascadeMaxExtents[o] = new Vector3,
- this._frustumCenter[o] = new Vector3,
- this._shadowCameraPos[o] = new Vector3,
- this._frustumCornersWorldSpace[o] = new Array(e.frustumCornersNDCSpace.length);
- for (var s = 0; s < e.frustumCornersNDCSpace.length; ++s)
- this._frustumCornersWorldSpace[o][s] = new Vector3
- }
- var c = this._scene.getEngine();
- this._shadowMap.onBeforeBindObservable.clear(),
- this._shadowMap.onBeforeRenderObservable.clear(),
- this._shadowMap.onBeforeRenderObservable.add(function(d) {
- i._sceneUBOs && i._scene.setSceneUniformBuffer(i._sceneUBOs[d]),
- i._currentLayer = d,
- i._filter === ShadowGenerator.FILTER_PCF && c.setColorWrite(!1),
- i._scene.setTransformMatrix(i.getCascadeViewMatrix(d), i.getCascadeProjectionMatrix(d)),
- i._useUBO && (i._scene.getSceneUniformBuffer().unbindEffect(),
- i._scene.finalizeSceneUbo())
- }),
- this._shadowMap.onBeforeBindObservable.add(function() {
- var d;
- i._currentSceneUBO = i._scene.getSceneUniformBuffer(),
- (d = c._debugPushGroup) === null || d === void 0 || d.call(c, "cascaded shadow map generation for pass id " + c.currentRenderPassId, 1),
- i._breaksAreDirty && i._splitFrustum(),
- i._computeMatrices()
- }),
- this._splitFrustum()
- }
- }
- ,
- e.prototype._bindCustomEffectForRenderSubMeshForShadowMap = function(i, o, s) {
- o.setMatrix("viewProjection", this.getCascadeTransformMatrix(this._currentLayer))
- }
- ,
- e.prototype._isReadyCustomDefines = function(i, o, s) {
- i.push("#define SM_DEPTHCLAMP " + (this._depthClamp && this._filter !== ShadowGenerator.FILTER_PCSS ? "1" : "0"))
- }
- ,
- e.prototype.prepareDefines = function(i, o) {
- a.prototype.prepareDefines.call(this, i, o);
- var s = this._scene
- , c = this._light;
- if (!(!s.shadowsEnabled || !c.shadowEnabled)) {
- i["SHADOWCSM" + o] = !0,
- i["SHADOWCSMDEBUG" + o] = this.debug,
- i["SHADOWCSMNUM_CASCADES" + o] = this.numCascades,
- i["SHADOWCSM_RIGHTHANDED" + o] = s.useRightHandedSystem;
- var d = s.activeCamera;
- d && this._shadowMaxZ < d.maxZ && (i["SHADOWCSMUSESHADOWMAXZ" + o] = !0),
- this.cascadeBlendPercentage === 0 && (i["SHADOWCSMNOBLEND" + o] = !0)
- }
- }
- ,
- e.prototype.bindShadowLight = function(i, o) {
- var s = this._light
- , c = this._scene;
- if (!(!c.shadowsEnabled || !s.shadowEnabled)) {
- var d = c.activeCamera;
- if (!!d) {
- var _ = this.getShadowMap();
- if (!!_) {
- var b = _.getSize().width;
- if (o.setMatrices("lightMatrix" + i, this._transformMatricesAsArray),
- o.setArray("viewFrustumZ" + i, this._viewSpaceFrustumsZ),
- o.setFloat("cascadeBlendFactor" + i, this.cascadeBlendPercentage === 0 ? 1e4 : 1 / this.cascadeBlendPercentage),
- o.setArray("frustumLengths" + i, this._frustumLengths),
- this._filter === ShadowGenerator.FILTER_PCF)
- o.setDepthStencilTexture("shadowSampler" + i, _),
- s._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), b, 1 / b, this.frustumEdgeFalloff, i);
- else if (this._filter === ShadowGenerator.FILTER_PCSS) {
- for (var k = 0; k < this._numCascades; ++k)
- this._lightSizeUVCorrection[k * 2 + 0] = k === 0 ? 1 : (this._cascadeMaxExtents[0].x - this._cascadeMinExtents[0].x) / (this._cascadeMaxExtents[k].x - this._cascadeMinExtents[k].x),
- this._lightSizeUVCorrection[k * 2 + 1] = k === 0 ? 1 : (this._cascadeMaxExtents[0].y - this._cascadeMinExtents[0].y) / (this._cascadeMaxExtents[k].y - this._cascadeMinExtents[k].y),
- this._depthCorrection[k] = k === 0 ? 1 : (this._cascadeMaxExtents[k].z - this._cascadeMinExtents[k].z) / (this._cascadeMaxExtents[0].z - this._cascadeMinExtents[0].z);
- o.setDepthStencilTexture("shadowSampler" + i, _),
- o.setTexture("depthSampler" + i, _),
- o.setArray2("lightSizeUVCorrection" + i, this._lightSizeUVCorrection),
- o.setArray("depthCorrection" + i, this._depthCorrection),
- o.setFloat("penumbraDarkness" + i, this.penumbraDarkness),
- s._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / b, this._contactHardeningLightSizeUVRatio * b, this.frustumEdgeFalloff, i)
- } else
- o.setTexture("shadowSampler" + i, _),
- s._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), b, 1 / b, this.frustumEdgeFalloff, i);
- s._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(d), this.getLight().getDepthMinZ(d) + this.getLight().getDepthMaxZ(d), i)
- }
- }
- }
- }
- ,
- e.prototype.getTransformMatrix = function() {
- return this.getCascadeTransformMatrix(0)
- }
- ,
- e.prototype.dispose = function() {
- a.prototype.dispose.call(this),
- this._freezeShadowCastersBoundingInfoObservable && (this._scene.onBeforeRenderObservable.remove(this._freezeShadowCastersBoundingInfoObservable),
- this._freezeShadowCastersBoundingInfoObservable = null),
- this._depthReducer && (this._depthReducer.dispose(),
- this._depthReducer = null)
- }
- ,
- e.prototype.serialize = function() {
- var i = a.prototype.serialize.call(this)
- , o = this.getShadowMap();
- if (!o)
- return i;
- if (i.numCascades = this._numCascades,
- i.debug = this._debug,
- i.stabilizeCascades = this.stabilizeCascades,
- i.lambda = this._lambda,
- i.cascadeBlendPercentage = this.cascadeBlendPercentage,
- i.depthClamp = this._depthClamp,
- i.autoCalcDepthBounds = this.autoCalcDepthBounds,
- i.shadowMaxZ = this._shadowMaxZ,
- i.penumbraDarkness = this.penumbraDarkness,
- i.freezeShadowCastersBoundingInfo = this._freezeShadowCastersBoundingInfo,
- i.minDistance = this.minDistance,
- i.maxDistance = this.maxDistance,
- i.renderList = [],
- o.renderList)
- for (var s = 0; s < o.renderList.length; s++) {
- var c = o.renderList[s];
- i.renderList.push(c.id)
- }
- return i
- }
- ,
- e.Parse = function(i, o) {
- var s = ShadowGenerator.Parse(i, o, function(c, d) {
- return new e(c,d)
- });
- return i.numCascades !== void 0 && (s.numCascades = i.numCascades),
- i.debug !== void 0 && (s.debug = i.debug),
- i.stabilizeCascades !== void 0 && (s.stabilizeCascades = i.stabilizeCascades),
- i.lambda !== void 0 && (s.lambda = i.lambda),
- i.cascadeBlendPercentage !== void 0 && (s.cascadeBlendPercentage = i.cascadeBlendPercentage),
- i.depthClamp !== void 0 && (s.depthClamp = i.depthClamp),
- i.autoCalcDepthBounds !== void 0 && (s.autoCalcDepthBounds = i.autoCalcDepthBounds),
- i.shadowMaxZ !== void 0 && (s.shadowMaxZ = i.shadowMaxZ),
- i.penumbraDarkness !== void 0 && (s.penumbraDarkness = i.penumbraDarkness),
- i.freezeShadowCastersBoundingInfo !== void 0 && (s.freezeShadowCastersBoundingInfo = i.freezeShadowCastersBoundingInfo),
- i.minDistance !== void 0 && i.maxDistance !== void 0 && s.setMinMaxDistance(i.minDistance, i.maxDistance),
- s
- }
- ,
- 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)],
- e.CLASSNAME = "CascadedShadowGenerator",
- e.DEFAULT_CASCADES_COUNT = 4,
- e.MIN_CASCADES_COUNT = 2,
- e.MAX_CASCADES_COUNT = 4,
- e._SceneComponentInitialization = function(i) {
- throw _WarnImport("ShadowGeneratorSceneComponent")
- }
- ,
- e
- }(ShadowGenerator);
- AbstractScene.AddParser(SceneComponentConstants.NAME_SHADOWGENERATOR, function(a, e) {
- if (a.shadowGenerators !== void 0 && a.shadowGenerators !== null)
- for (var i = 0, o = a.shadowGenerators.length; i < o; i++) {
- var s = a.shadowGenerators[i];
- s.className === CascadedShadowGenerator.CLASSNAME ? CascadedShadowGenerator.Parse(s, e) : ShadowGenerator.Parse(s, e)
- }
- });
- var ShadowGeneratorSceneComponent = function() {
- function a(e) {
- this.name = SceneComponentConstants.NAME_SHADOWGENERATOR,
- this.scene = e
- }
- return a.prototype.register = function() {
- this.scene._gatherRenderTargetsStage.registerStep(SceneComponentConstants.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR, this, this._gatherRenderTargets)
- }
- ,
- a.prototype.rebuild = function() {}
- ,
- a.prototype.serialize = function(e) {
- e.shadowGenerators = [];
- for (var i = this.scene.lights, o = 0, s = i; o < s.length; o++) {
- var c = s[o]
- , d = c.getShadowGenerator();
- d && e.shadowGenerators.push(d.serialize())
- }
- }
- ,
- a.prototype.addFromContainer = function(e) {}
- ,
- a.prototype.removeFromContainer = function(e, i) {}
- ,
- a.prototype.dispose = function() {}
- ,
- a.prototype._gatherRenderTargets = function(e) {
- var i = this.scene;
- if (this.scene.shadowsEnabled)
- for (var o = 0; o < i.lights.length; o++) {
- var s = i.lights[o]
- , c = s.getShadowGenerator();
- if (s.isEnabled() && s.shadowEnabled && c) {
- var d = c.getShadowMap();
- i.textures.indexOf(d) !== -1 && e.push(d)
- }
- }
- }
- ,
- a
- }();
- ShadowGenerator._SceneComponentInitialization = function(a) {
- var e = a._getComponent(SceneComponentConstants.NAME_SHADOWGENERATOR);
- e || (e = new ShadowGeneratorSceneComponent(a),
- a._addComponent(e))
- }
- ;
- var DDS_MAGIC = 542327876
- , DDSD_MIPMAPCOUNT = 131072
- , DDSCAPS2_CUBEMAP = 512
- , DDPF_FOURCC = 4
- , DDPF_RGB = 64
- , DDPF_LUMINANCE = 131072;
- function FourCCToInt32(a) {
- return a.charCodeAt(0) + (a.charCodeAt(1) << 8) + (a.charCodeAt(2) << 16) + (a.charCodeAt(3) << 24)
- }
- function Int32ToFourCC(a) {
- return String.fromCharCode(a & 255, a >> 8 & 255, a >> 16 & 255, a >> 24 & 255)
- }
- var FOURCC_DXT1 = FourCCToInt32("DXT1")
- , FOURCC_DXT3 = FourCCToInt32("DXT3")
- , FOURCC_DXT5 = FourCCToInt32("DXT5")
- , FOURCC_DX10 = FourCCToInt32("DX10")
- , FOURCC_D3DFMT_R16G16B16A16F = 113
- , FOURCC_D3DFMT_R32G32B32A32F = 116
- , DXGI_FORMAT_R32G32B32A32_FLOAT = 2
- , DXGI_FORMAT_R16G16B16A16_FLOAT = 10
- , DXGI_FORMAT_B8G8R8X8_UNORM = 88
- , headerLengthInt = 31
- , off_magic = 0
- , off_size = 1
- , off_flags = 2
- , off_height = 3
- , off_width = 4
- , off_mipmapCount = 7
- , off_pfFlags = 20
- , off_pfFourCC = 21
- , off_RGBbpp = 22
- , off_RMask = 23
- , off_GMask = 24
- , off_BMask = 25
- , off_AMask = 26
- , off_caps2 = 28
- , off_dxgiFormat = 32
- , DDSTools = function() {
- function a() {}
- return a.GetDDSInfo = function(e) {
- var i = new Int32Array(e.buffer,e.byteOffset,headerLengthInt)
- , o = new Int32Array(e.buffer,e.byteOffset,headerLengthInt + 4)
- , s = 1;
- i[off_flags] & DDSD_MIPMAPCOUNT && (s = Math.max(1, i[off_mipmapCount]));
- var c = i[off_pfFourCC]
- , d = c === FOURCC_DX10 ? o[off_dxgiFormat] : 0
- , _ = 0;
- switch (c) {
- case FOURCC_D3DFMT_R16G16B16A16F:
- _ = 2;
- break;
- case FOURCC_D3DFMT_R32G32B32A32F:
- _ = 1;
- break;
- case FOURCC_DX10:
- if (d === DXGI_FORMAT_R16G16B16A16_FLOAT) {
- _ = 2;
- break
- }
- if (d === DXGI_FORMAT_R32G32B32A32_FLOAT) {
- _ = 1;
- break
- }
- }
- return {
- width: i[off_width],
- height: i[off_height],
- mipmapCount: s,
- isFourCC: (i[off_pfFlags] & DDPF_FOURCC) === DDPF_FOURCC,
- isRGB: (i[off_pfFlags] & DDPF_RGB) === DDPF_RGB,
- isLuminance: (i[off_pfFlags] & DDPF_LUMINANCE) === DDPF_LUMINANCE,
- isCube: (i[off_caps2] & DDSCAPS2_CUBEMAP) === DDSCAPS2_CUBEMAP,
- isCompressed: c === FOURCC_DXT1 || c === FOURCC_DXT3 || c === FOURCC_DXT5,
- dxgiFormat: d,
- textureType: _
- }
- }
- ,
- a._GetHalfFloatAsFloatRGBAArrayBuffer = function(e, i, o, s, c, d) {
- for (var _ = new Float32Array(s), b = new Uint16Array(c,o), k = 0, j = 0; j < i; j++)
- for (var $ = 0; $ < e; $++) {
- var _e = ($ + j * e) * 4;
- _[k] = FromHalfFloat(b[_e]),
- _[k + 1] = FromHalfFloat(b[_e + 1]),
- _[k + 2] = FromHalfFloat(b[_e + 2]),
- a.StoreLODInAlphaChannel ? _[k + 3] = d : _[k + 3] = FromHalfFloat(b[_e + 3]),
- k += 4
- }
- return _
- }
- ,
- a._GetHalfFloatRGBAArrayBuffer = function(e, i, o, s, c, d) {
- if (a.StoreLODInAlphaChannel) {
- for (var _ = new Uint16Array(s), b = new Uint16Array(c,o), k = 0, j = 0; j < i; j++)
- for (var $ = 0; $ < e; $++) {
- var _e = ($ + j * e) * 4;
- _[k] = b[_e],
- _[k + 1] = b[_e + 1],
- _[k + 2] = b[_e + 2],
- _[k + 3] = ToHalfFloat(d),
- k += 4
- }
- return _
- }
- return new Uint16Array(c,o,s)
- }
- ,
- a._GetFloatRGBAArrayBuffer = function(e, i, o, s, c, d) {
- if (a.StoreLODInAlphaChannel) {
- for (var _ = new Float32Array(s), b = new Float32Array(c,o), k = 0, j = 0; j < i; j++)
- for (var $ = 0; $ < e; $++) {
- var _e = ($ + j * e) * 4;
- _[k] = b[_e],
- _[k + 1] = b[_e + 1],
- _[k + 2] = b[_e + 2],
- _[k + 3] = d,
- k += 4
- }
- return _
- }
- return new Float32Array(c,o,s)
- }
- ,
- a._GetFloatAsHalfFloatRGBAArrayBuffer = function(e, i, o, s, c, d) {
- for (var _ = new Uint16Array(s), b = new Float32Array(c,o), k = 0, j = 0; j < i; j++)
- for (var $ = 0; $ < e; $++)
- _[k] = ToHalfFloat(b[k]),
- _[k + 1] = ToHalfFloat(b[k + 1]),
- _[k + 2] = ToHalfFloat(b[k + 2]),
- a.StoreLODInAlphaChannel ? _[k + 3] = ToHalfFloat(d) : _[k + 3] = ToHalfFloat(b[k + 3]),
- k += 4;
- return _
- }
- ,
- a._GetFloatAsUIntRGBAArrayBuffer = function(e, i, o, s, c, d) {
- for (var _ = new Uint8Array(s), b = new Float32Array(c,o), k = 0, j = 0; j < i; j++)
- for (var $ = 0; $ < e; $++) {
- var _e = ($ + j * e) * 4;
- _[k] = Scalar.Clamp(b[_e]) * 255,
- _[k + 1] = Scalar.Clamp(b[_e + 1]) * 255,
- _[k + 2] = Scalar.Clamp(b[_e + 2]) * 255,
- a.StoreLODInAlphaChannel ? _[k + 3] = d : _[k + 3] = Scalar.Clamp(b[_e + 3]) * 255,
- k += 4
- }
- return _
- }
- ,
- a._GetHalfFloatAsUIntRGBAArrayBuffer = function(e, i, o, s, c, d) {
- for (var _ = new Uint8Array(s), b = new Uint16Array(c,o), k = 0, j = 0; j < i; j++)
- for (var $ = 0; $ < e; $++) {
- var _e = ($ + j * e) * 4;
- _[k] = Scalar.Clamp(FromHalfFloat(b[_e])) * 255,
- _[k + 1] = Scalar.Clamp(FromHalfFloat(b[_e + 1])) * 255,
- _[k + 2] = Scalar.Clamp(FromHalfFloat(b[_e + 2])) * 255,
- a.StoreLODInAlphaChannel ? _[k + 3] = d : _[k + 3] = Scalar.Clamp(FromHalfFloat(b[_e + 3])) * 255,
- k += 4
- }
- return _
- }
- ,
- a._GetRGBAArrayBuffer = function(e, i, o, s, c, d, _, b, k) {
- for (var j = new Uint8Array(s), $ = new Uint8Array(c,o), _e = 0, et = 0; et < i; et++)
- for (var tt = 0; tt < e; tt++) {
- var rt = (tt + et * e) * 4;
- j[_e] = $[rt + d],
- j[_e + 1] = $[rt + _],
- j[_e + 2] = $[rt + b],
- j[_e + 3] = $[rt + k],
- _e += 4
- }
- return j
- }
- ,
- a._ExtractLongWordOrder = function(e) {
- return e === 0 || e === 255 || e === -16777216 ? 0 : 1 + a._ExtractLongWordOrder(e >> 8)
- }
- ,
- a._GetRGBArrayBuffer = function(e, i, o, s, c, d, _, b) {
- for (var k = new Uint8Array(s), j = new Uint8Array(c,o), $ = 0, _e = 0; _e < i; _e++)
- for (var et = 0; et < e; et++) {
- var tt = (et + _e * e) * 3;
- k[$] = j[tt + d],
- k[$ + 1] = j[tt + _],
- k[$ + 2] = j[tt + b],
- $ += 3
- }
- return k
- }
- ,
- a._GetLuminanceArrayBuffer = function(e, i, o, s, c) {
- for (var d = new Uint8Array(s), _ = new Uint8Array(c,o), b = 0, k = 0; k < i; k++)
- for (var j = 0; j < e; j++) {
- var $ = j + k * e;
- d[b] = _[$],
- b++
- }
- return d
- }
- ,
- a.UploadDDSLevels = function(e, i, o, s, c, d, _, b, k) {
- _ === void 0 && (_ = -1),
- k === void 0 && (k = !0);
- var j = null;
- s.sphericalPolynomial && (j = new Array);
- var $ = !!e.getCaps().s3tc;
- i.generateMipMaps = c;
- var _e = new Int32Array(o.buffer,o.byteOffset,headerLengthInt), et, tt, rt, it = 0, nt, ot, at, st, ut = 0, ct = 1;
- if (_e[off_magic] !== DDS_MAGIC) {
- Logger$2.Error("Invalid magic number in DDS header");
- return
- }
- if (!s.isFourCC && !s.isRGB && !s.isLuminance) {
- Logger$2.Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");
- return
- }
- if (s.isCompressed && !$) {
- Logger$2.Error("Compressed textures are not supported on this platform.");
- return
- }
- var lt = _e[off_RGBbpp];
- nt = _e[off_size] + 4;
- var ft = !1;
- if (s.isFourCC)
- switch (et = _e[off_pfFourCC],
- et) {
- case FOURCC_DXT1:
- ct = 8,
- ut = 33777;
- break;
- case FOURCC_DXT3:
- ct = 16,
- ut = 33778;
- break;
- case FOURCC_DXT5:
- ct = 16,
- ut = 33779;
- break;
- case FOURCC_D3DFMT_R16G16B16A16F:
- ft = !0;
- break;
- case FOURCC_D3DFMT_R32G32B32A32F:
- ft = !0;
- break;
- case FOURCC_DX10:
- nt += 5 * 4;
- var ht = !1;
- switch (s.dxgiFormat) {
- case DXGI_FORMAT_R16G16B16A16_FLOAT:
- case DXGI_FORMAT_R32G32B32A32_FLOAT:
- ft = !0,
- ht = !0;
- break;
- case DXGI_FORMAT_B8G8R8X8_UNORM:
- s.isRGB = !0,
- s.isFourCC = !1,
- lt = 32,
- ht = !0;
- break
- }
- if (ht)
- break;
- default:
- console.error("Unsupported FourCC code:", Int32ToFourCC(et));
- return
- }
- var pt = a._ExtractLongWordOrder(_e[off_RMask])
- , dt = a._ExtractLongWordOrder(_e[off_GMask])
- , _t = a._ExtractLongWordOrder(_e[off_BMask])
- , mt = a._ExtractLongWordOrder(_e[off_AMask]);
- ft && (ut = e._getRGBABufferInternalSizedFormat(s.textureType)),
- at = 1,
- _e[off_flags] & DDSD_MIPMAPCOUNT && c !== !1 && (at = Math.max(1, _e[off_mipmapCount]));
- for (var vt = b || 0, yt = e.getCaps(), Et = vt; Et < d; Et++) {
- for (tt = _e[off_width],
- rt = _e[off_height],
- st = 0; st < at; ++st) {
- if (_ === -1 || _ === st) {
- var At = _ === -1 ? st : 0;
- if (!s.isCompressed && s.isFourCC) {
- i.format = 5,
- it = tt * rt * 4;
- var gt = null;
- if (e._badOS || e._badDesktopOS || !yt.textureHalfFloat && !yt.textureFloat)
- lt === 128 ? (gt = a._GetFloatAsUIntRGBAArrayBuffer(tt, rt, o.byteOffset + nt, it, o.buffer, At),
- 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),
- j && At == 0 && j.push(a._GetHalfFloatAsFloatRGBAArrayBuffer(tt, rt, o.byteOffset + nt, it, o.buffer, At))),
- i.type = 0;
- else {
- var St = yt.textureFloat && (k && yt.textureFloatLinearFiltering || !k)
- , xt = yt.textureHalfFloat && (k && yt.textureHalfFloatLinearFiltering || !k)
- , bt = (lt === 128 || lt === 64 && !xt) && St ? 1 : (lt === 64 || lt === 128 && !St) && xt ? 2 : 0
- , Rt = void 0
- , Mt = null;
- switch (lt) {
- case 128:
- {
- switch (bt) {
- case 1:
- Rt = a._GetFloatRGBAArrayBuffer,
- Mt = null;
- break;
- case 2:
- Rt = a._GetFloatAsHalfFloatRGBAArrayBuffer,
- Mt = a._GetFloatRGBAArrayBuffer;
- break;
- case 0:
- Rt = a._GetFloatAsUIntRGBAArrayBuffer,
- Mt = a._GetFloatRGBAArrayBuffer;
- break
- }
- break
- }
- default:
- {
- switch (bt) {
- case 1:
- Rt = a._GetHalfFloatAsFloatRGBAArrayBuffer,
- Mt = null;
- break;
- case 2:
- Rt = a._GetHalfFloatRGBAArrayBuffer,
- Mt = a._GetHalfFloatAsFloatRGBAArrayBuffer;
- break;
- case 0:
- Rt = a._GetHalfFloatAsUIntRGBAArrayBuffer,
- Mt = a._GetHalfFloatAsFloatRGBAArrayBuffer;
- break
- }
- break
- }
- }
- i.type = bt,
- gt = Rt(tt, rt, o.byteOffset + nt, it, o.buffer, At),
- j && At == 0 && j.push(Mt ? Mt(tt, rt, o.byteOffset + nt, it, o.buffer, At) : gt)
- }
- gt && e._uploadDataToTextureDirectly(i, gt, Et, At)
- } else if (s.isRGB)
- i.type = 0,
- lt === 24 ? (i.format = 4,
- it = tt * rt * 3,
- ot = a._GetRGBArrayBuffer(tt, rt, o.byteOffset + nt, it, o.buffer, pt, dt, _t),
- e._uploadDataToTextureDirectly(i, ot, Et, At)) : (i.format = 5,
- it = tt * rt * 4,
- ot = a._GetRGBAArrayBuffer(tt, rt, o.byteOffset + nt, it, o.buffer, pt, dt, _t, mt),
- e._uploadDataToTextureDirectly(i, ot, Et, At));
- else if (s.isLuminance) {
- var Pt = e._getUnpackAlignement()
- , It = tt
- , Dt = Math.floor((tt + Pt - 1) / Pt) * Pt;
- it = Dt * (rt - 1) + It,
- ot = a._GetLuminanceArrayBuffer(tt, rt, o.byteOffset + nt, it, o.buffer),
- i.format = 1,
- i.type = 0,
- e._uploadDataToTextureDirectly(i, ot, Et, At)
- } else
- it = Math.max(4, tt) / 4 * Math.max(4, rt) / 4 * ct,
- ot = new Uint8Array(o.buffer,o.byteOffset + nt,it),
- i.type = 0,
- e._uploadCompressedDataToTextureDirectly(i, ut, tt, rt, ot, Et, At)
- }
- nt += lt ? tt * rt * (lt / 8) : it,
- tt *= .5,
- rt *= .5,
- tt = Math.max(1, tt),
- rt = Math.max(1, rt)
- }
- if (b !== void 0)
- break
- }
- j && j.length > 0 ? s.sphericalPolynomial = CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial({
- size: _e[off_width],
- right: j[0],
- left: j[1],
- up: j[2],
- down: j[3],
- front: j[4],
- back: j[5],
- format: 5,
- type: 1,
- gammaSpace: !1
- }) : s.sphericalPolynomial = void 0
- }
- ,
- a.StoreLODInAlphaChannel = !1,
- a
- }();
- ThinEngine.prototype.createPrefilteredCubeTexture = function(a, e, i, o, s, c, d, _, b) {
- var k = this;
- s === void 0 && (s = null),
- c === void 0 && (c = null),
- _ === void 0 && (_ = null),
- b === void 0 && (b = !0);
- var j = function($) {
- if (!$) {
- s && s(null);
- return
- }
- var _e = $.texture;
- if (b ? $.info.sphericalPolynomial && (_e._sphericalPolynomial = $.info.sphericalPolynomial) : _e._sphericalPolynomial = new SphericalPolynomial,
- _e._source = InternalTextureSource.CubePrefiltered,
- k.getCaps().textureLOD) {
- s && s(_e);
- return
- }
- var et = 3
- , tt = k._gl
- , rt = $.width;
- if (!!rt) {
- for (var it = [], nt = 0; nt < et; nt++) {
- var ot = nt / (et - 1)
- , at = 1 - ot
- , st = o
- , ut = Scalar.Log2(rt) * i + o
- , ct = st + (ut - st) * at
- , lt = Math.round(Math.min(Math.max(ct, 0), ut))
- , ft = new InternalTexture(k,InternalTextureSource.Temp);
- if (ft.type = _e.type,
- ft.format = _e.format,
- ft.width = Math.pow(2, Math.max(Scalar.Log2(rt) - lt, 0)),
- ft.height = ft.width,
- ft.isCube = !0,
- ft._cachedWrapU = 0,
- ft._cachedWrapV = 0,
- k._bindTextureDirectly(tt.TEXTURE_CUBE_MAP, ft, !0),
- ft.samplingMode = 2,
- tt.texParameteri(tt.TEXTURE_CUBE_MAP, tt.TEXTURE_MAG_FILTER, tt.LINEAR),
- tt.texParameteri(tt.TEXTURE_CUBE_MAP, tt.TEXTURE_MIN_FILTER, tt.LINEAR),
- tt.texParameteri(tt.TEXTURE_CUBE_MAP, tt.TEXTURE_WRAP_S, tt.CLAMP_TO_EDGE),
- tt.texParameteri(tt.TEXTURE_CUBE_MAP, tt.TEXTURE_WRAP_T, tt.CLAMP_TO_EDGE),
- $.isDDS) {
- var ht = $.info
- , pt = $.data;
- k._unpackFlipY(ht.isCompressed),
- DDSTools.UploadDDSLevels(k, ft, pt, ht, !0, 6, lt)
- } else
- Logger$2.Warn("DDS is the only prefiltered cube map supported so far.");
- k._bindTextureDirectly(tt.TEXTURE_CUBE_MAP, null);
- var dt = new BaseTexture(e);
- dt.isCube = !0,
- dt._texture = ft,
- ft.isReady = !0,
- it.push(dt)
- }
- _e._lodTextureHigh = it[2],
- _e._lodTextureMid = it[1],
- _e._lodTextureLow = it[0],
- s && s(_e)
- }
- };
- return this.createCubeTexture(a, e, null, !1, j, c, d, _, b, i, o)
- }
- ;
- var _DDSTextureLoader = function() {
- function a() {
- this.supportCascades = !0
- }
- return a.prototype.canLoad = function(e) {
- return EndsWith(e, ".dds")
- }
- ,
- a.prototype.loadCubeData = function(e, i, o, s, c) {
- var d = i.getEngine(), _, b = !1;
- if (Array.isArray(e))
- for (var k = 0; k < e.length; k++) {
- var j = e[k];
- _ = DDSTools.GetDDSInfo(j),
- i.width = _.width,
- i.height = _.height,
- b = (_.isRGB || _.isLuminance || _.mipmapCount > 1) && i.generateMipMaps,
- d._unpackFlipY(_.isCompressed),
- DDSTools.UploadDDSLevels(d, i, j, _, b, 6, -1, k),
- !_.isFourCC && _.mipmapCount === 1 && d.generateMipMapsForCubemap(i)
- }
- else {
- var $ = e;
- _ = DDSTools.GetDDSInfo($),
- i.width = _.width,
- i.height = _.height,
- o && (_.sphericalPolynomial = new SphericalPolynomial),
- b = (_.isRGB || _.isLuminance || _.mipmapCount > 1) && i.generateMipMaps,
- d._unpackFlipY(_.isCompressed),
- DDSTools.UploadDDSLevels(d, i, $, _, b, 6),
- !_.isFourCC && _.mipmapCount === 1 && d.generateMipMapsForCubemap(i, !1)
- }
- d._setCubeMapTextureParams(i, b),
- i.isReady = !0,
- i.onLoadedObservable.notifyObservers(i),
- i.onLoadedObservable.clear(),
- s && s({
- isDDS: !0,
- width: i.width,
- info: _,
- data: e,
- texture: i
- })
- }
- ,
- a.prototype.loadData = function(e, i, o) {
- var s = DDSTools.GetDDSInfo(e)
- , c = (s.isRGB || s.isLuminance || s.mipmapCount > 1) && i.generateMipMaps && s.width >> s.mipmapCount - 1 === 1;
- o(s.width, s.height, c, s.isFourCC, function() {
- DDSTools.UploadDDSLevels(i.getEngine(), i, e, s, c, 1)
- })
- }
- ,
- a
- }();
- Engine._TextureLoaders.push(new _DDSTextureLoader);
- var MirrorTexture = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d, _, b) {
- d === void 0 && (d = 0),
- _ === void 0 && (_ = Texture.BILINEAR_SAMPLINGMODE),
- b === void 0 && (b = !0);
- var k = a.call(this, i, o, s, c, !0, d, !1, _, b) || this;
- k.scene = s,
- k.mirrorPlane = new Plane(0,1,0,1),
- k._transformMatrix = Matrix.Zero(),
- k._mirrorMatrix = Matrix.Zero(),
- k._adaptiveBlurKernel = 0,
- k._blurKernelX = 0,
- k._blurKernelY = 0,
- k._blurRatio = 1,
- k.ignoreCameraViewport = !0,
- k._updateGammaSpace(),
- k._imageProcessingConfigChangeObserver = s.imageProcessingConfiguration.onUpdateParameters.add(function() {
- k._updateGammaSpace()
- });
- var j = k.getScene().getEngine();
- j.supportsUniformBuffers && (k._sceneUBO = s.createSceneUniformBuffer('Scene for Mirror Texture (name "' + i + '")')),
- k.onBeforeBindObservable.add(function() {
- var _e;
- (_e = j._debugPushGroup) === null || _e === void 0 || _e.call(j, "mirror generation for " + i, 1)
- }),
- k.onAfterUnbindObservable.add(function() {
- var _e;
- (_e = j._debugPopGroup) === null || _e === void 0 || _e.call(j, 1)
- });
- var $;
- return k.onBeforeRenderObservable.add(function() {
- k._sceneUBO && (k._currentSceneUBO = s.getSceneUniformBuffer(),
- s.setSceneUniformBuffer(k._sceneUBO),
- s.getSceneUniformBuffer().unbindEffect()),
- Matrix.ReflectionToRef(k.mirrorPlane, k._mirrorMatrix),
- k._mirrorMatrix.multiplyToRef(s.getViewMatrix(), k._transformMatrix),
- s.setTransformMatrix(k._transformMatrix, s.getProjectionMatrix()),
- $ = s.clipPlane,
- s.clipPlane = k.mirrorPlane,
- s.getEngine().cullBackFaces = !1,
- s._mirroredCameraPosition = Vector3.TransformCoordinates(s.activeCamera.globalPosition, k._mirrorMatrix)
- }),
- k.onAfterRenderObservable.add(function() {
- k._sceneUBO && s.setSceneUniformBuffer(k._currentSceneUBO),
- s.updateTransformMatrix(),
- s.getEngine().cullBackFaces = null,
- s._mirroredCameraPosition = null,
- s.clipPlane = $
- }),
- k
- }
- return Object.defineProperty(e.prototype, "blurRatio", {
- get: function() {
- return this._blurRatio
- },
- set: function(i) {
- this._blurRatio !== i && (this._blurRatio = i,
- this._preparePostProcesses())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "adaptiveBlurKernel", {
- set: function(i) {
- this._adaptiveBlurKernel = i,
- this._autoComputeBlurKernel()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "blurKernel", {
- set: function(i) {
- this.blurKernelX = i,
- this.blurKernelY = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "blurKernelX", {
- get: function() {
- return this._blurKernelX
- },
- set: function(i) {
- this._blurKernelX !== i && (this._blurKernelX = i,
- this._preparePostProcesses())
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "blurKernelY", {
- get: function() {
- return this._blurKernelY
- },
- set: function(i) {
- this._blurKernelY !== i && (this._blurKernelY = i,
- this._preparePostProcesses())
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._autoComputeBlurKernel = function() {
- var i = this.getScene().getEngine()
- , o = this.getRenderWidth() / i.getRenderWidth()
- , s = this.getRenderHeight() / i.getRenderHeight();
- this.blurKernelX = this._adaptiveBlurKernel * o,
- this.blurKernelY = this._adaptiveBlurKernel * s
- }
- ,
- e.prototype._onRatioRescale = function() {
- this._sizeRatio && (this.resize(this._initialSizeParameter),
- this._adaptiveBlurKernel || this._preparePostProcesses()),
- this._adaptiveBlurKernel && this._autoComputeBlurKernel()
- }
- ,
- e.prototype._updateGammaSpace = function() {
- this.gammaSpace = !this.scene.imageProcessingConfiguration.isEnabled || !this.scene.imageProcessingConfiguration.applyByPostProcess
- }
- ,
- e.prototype._preparePostProcesses = function() {
- if (this.clearPostProcesses(!0),
- this._blurKernelX && this._blurKernelY) {
- var i = this.getScene().getEngine()
- , o = i.getCaps().textureFloatRender && i.getCaps().textureFloatLinearFiltering ? 1 : 2;
- this._blurX = new BlurPostProcess("horizontal blur",new Vector2(1,0),this._blurKernelX,this._blurRatio,null,Texture.BILINEAR_SAMPLINGMODE,i,!1,o),
- this._blurX.autoClear = !1,
- this._blurRatio === 1 && this.samples < 2 && this._texture ? this._blurX.inputTexture = this._renderTarget : this._blurX.alwaysForcePOT = !0,
- this._blurY = new BlurPostProcess("vertical blur",new Vector2(0,1),this._blurKernelY,this._blurRatio,null,Texture.BILINEAR_SAMPLINGMODE,i,!1,o),
- this._blurY.autoClear = !1,
- this._blurY.alwaysForcePOT = this._blurRatio !== 1,
- this.addPostProcess(this._blurX),
- this.addPostProcess(this._blurY)
- } else
- this._blurY && (this.removePostProcess(this._blurY),
- this._blurY.dispose(),
- this._blurY = null),
- this._blurX && (this.removePostProcess(this._blurX),
- this._blurX.dispose(),
- this._blurX = null)
- }
- ,
- e.prototype.clone = function() {
- var i = this.getScene();
- if (!i)
- return this;
- var o = this.getSize()
- , s = new e(this.name,o.width,i,this._renderTargetOptions.generateMipMaps,this._renderTargetOptions.type,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer);
- return s.hasAlpha = this.hasAlpha,
- s.level = this.level,
- s.mirrorPlane = this.mirrorPlane.clone(),
- this.renderList && (s.renderList = this.renderList.slice(0)),
- s
- }
- ,
- e.prototype.serialize = function() {
- if (!this.name)
- return null;
- var i = a.prototype.serialize.call(this);
- return i.mirrorPlane = this.mirrorPlane.asArray(),
- i
- }
- ,
- e.prototype.dispose = function() {
- var i;
- a.prototype.dispose.call(this),
- this.scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver),
- (i = this._sceneUBO) === null || i === void 0 || i.dispose()
- }
- ,
- e
- }(RenderTargetTexture);
- Texture._CreateMirror = function(a, e, i, o) {
- return new MirrorTexture(a,e,i,o)
- }
- ;
- var name$7 = "backgroundFragmentDeclaration"
- , shader$7 = ` uniform vec4 vEyePosition;
- uniform vec4 vPrimaryColor;
- #ifdef USEHIGHLIGHTANDSHADOWCOLORS
- uniform vec4 vPrimaryColorShadow;
- #endif
- uniform float shadowLevel;
- uniform float alpha;
- #ifdef DIFFUSE
- uniform vec2 vDiffuseInfos;
- #endif
- #ifdef REFLECTION
- uniform vec2 vReflectionInfos;
- uniform mat4 reflectionMatrix;
- uniform vec3 vReflectionMicrosurfaceInfos;
- #endif
- #if defined(REFLECTIONFRESNEL) || defined(OPACITYFRESNEL)
- uniform vec3 vBackgroundCenter;
- #endif
- #ifdef REFLECTIONFRESNEL
- uniform vec4 vReflectionControl;
- #endif
- #if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)
- uniform mat4 view;
- #endif`;
- ShaderStore.IncludesShadersStore[name$7] = shader$7;
- var name$6 = "backgroundUboDeclaration"
- , shader$6 = `layout(std140,column_major) uniform;
- uniform Material
- {
- uniform vec4 vPrimaryColor;
- uniform vec4 vPrimaryColorShadow;
- uniform vec2 vDiffuseInfos;
- uniform vec2 vReflectionInfos;
- uniform mat4 diffuseMatrix;
- uniform mat4 reflectionMatrix;
- uniform vec3 vReflectionMicrosurfaceInfos;
- uniform float fFovMultiplier;
- uniform float pointSize;
- uniform float shadowLevel;
- uniform float alpha;
- #if defined(REFLECTIONFRESNEL) || defined(OPACITYFRESNEL)
- uniform vec3 vBackgroundCenter;
- #endif
- #ifdef REFLECTIONFRESNEL
- uniform vec4 vReflectionControl;
- #endif
- };
- #include<sceneUboDeclaration>
- `;
- ShaderStore.IncludesShadersStore[name$6] = shader$6;
- var name$5 = "backgroundPixelShader"
- , shader$5 = `#ifdef TEXTURELODSUPPORT
- #extension GL_EXT_shader_texture_lod : enable
- #endif
- precision highp float;
- #include<__decl__backgroundFragment>
- #include<helperFunctions>
- #define RECIPROCAL_PI2 0.15915494
- varying vec3 vPositionW;
- #ifdef MAINUV1
- varying vec2 vMainUV1;
- #endif
- #ifdef MAINUV2
- varying vec2 vMainUV2;
- #endif
- #ifdef NORMAL
- varying vec3 vNormalW;
- #endif
- #ifdef DIFFUSE
- #if DIFFUSEDIRECTUV == 1
- #define vDiffuseUV vMainUV1
- #elif DIFFUSEDIRECTUV == 2
- #define vDiffuseUV vMainUV2
- #else
- varying vec2 vDiffuseUV;
- #endif
- uniform sampler2D diffuseSampler;
- #endif
- #ifdef REFLECTION
- #ifdef REFLECTIONMAP_3D
- #define sampleReflection(s,c) textureCube(s,c)
- uniform samplerCube reflectionSampler;
- #ifdef TEXTURELODSUPPORT
- #define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)
- #else
- uniform samplerCube reflectionSamplerLow;
- uniform samplerCube reflectionSamplerHigh;
- #endif
- #else
- #define sampleReflection(s,c) texture2D(s,c)
- uniform sampler2D reflectionSampler;
- #ifdef TEXTURELODSUPPORT
- #define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)
- #else
- uniform samplerCube reflectionSamplerLow;
- uniform samplerCube reflectionSamplerHigh;
- #endif
- #endif
- #ifdef REFLECTIONMAP_SKYBOX
- varying vec3 vPositionUVW;
- #else
- #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
- varying vec3 vDirectionW;
- #endif
- #endif
- #include<reflectionFunction>
- #endif
- #ifndef FROMLINEARSPACE
- #define FROMLINEARSPACE;
- #endif
- #ifndef SHADOWONLY
- #define SHADOWONLY;
- #endif
- #include<imageProcessingDeclaration>
- #include<__decl__lightFragment>[0..maxSimultaneousLights]
- #include<lightsFragmentFunctions>
- #include<shadowsFragmentFunctions>
- #include<imageProcessingFunctions>
- #include<clipPlaneFragmentDeclaration>
- #include<fogFragmentDeclaration>
- #ifdef REFLECTIONFRESNEL
- #define FRESNEL_MAXIMUM_ON_ROUGH 0.25
- vec3 fresnelSchlickEnvironmentGGX(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)
- {
- float weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);
- return reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));
- }
- #endif
- void main(void) {
- #include<clipPlaneFragment>
- vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);
- #ifdef NORMAL
- vec3 normalW=normalize(vNormalW);
- #else
- vec3 normalW=vec3(0.0,1.0,0.0);
- #endif
- float shadow=1.;
- float globalShadow=0.;
- float shadowLightCount=0.;
- #include<lightFragment>[0..maxSimultaneousLights]
- #ifdef SHADOWINUSE
- globalShadow/=shadowLightCount;
- #else
- globalShadow=1.0;
- #endif
- #ifndef BACKMAT_SHADOWONLY
- vec4 reflectionColor=vec4(1.,1.,1.,1.);
- #ifdef REFLECTION
- vec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);
- #ifdef REFLECTIONMAP_OPPOSITEZ
- reflectionVector.z*=-1.0;
- #endif
- #ifdef REFLECTIONMAP_3D
- vec3 reflectionCoords=reflectionVector;
- #else
- vec2 reflectionCoords=reflectionVector.xy;
- #ifdef REFLECTIONMAP_PROJECTION
- reflectionCoords/=reflectionVector.z;
- #endif
- reflectionCoords.y=1.0-reflectionCoords.y;
- #endif
- #ifdef REFLECTIONBLUR
- float reflectionLOD=vReflectionInfos.y;
- #ifdef TEXTURELODSUPPORT
- reflectionLOD=reflectionLOD*log2(vReflectionMicrosurfaceInfos.x)*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;
- reflectionColor=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);
- #else
- float lodReflectionNormalized=saturate(reflectionLOD);
- float lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;
- vec4 reflectionSpecularMid=sampleReflection(reflectionSampler,reflectionCoords);
- if(lodReflectionNormalizedDoubled<1.0){
- reflectionColor=mix(
- sampleReflection(reflectionSamplerHigh,reflectionCoords),
- reflectionSpecularMid,
- lodReflectionNormalizedDoubled
- );
- } else {
- reflectionColor=mix(
- reflectionSpecularMid,
- sampleReflection(reflectionSamplerLow,reflectionCoords),
- lodReflectionNormalizedDoubled-1.0
- );
- }
- #endif
- #else
- vec4 reflectionSample=sampleReflection(reflectionSampler,reflectionCoords);
- reflectionColor=reflectionSample;
- #endif
- #ifdef RGBDREFLECTION
- reflectionColor.rgb=fromRGBD(reflectionColor);
- #endif
- #ifdef GAMMAREFLECTION
- reflectionColor.rgb=toLinearSpace(reflectionColor.rgb);
- #endif
- #ifdef REFLECTIONBGR
- reflectionColor.rgb=reflectionColor.bgr;
- #endif
- reflectionColor.rgb*=vReflectionInfos.x;
- #endif
- vec3 diffuseColor=vec3(1.,1.,1.);
- float finalAlpha=alpha;
- #ifdef DIFFUSE
- vec4 diffuseMap=texture2D(diffuseSampler,vDiffuseUV);
- #ifdef GAMMADIFFUSE
- diffuseMap.rgb=toLinearSpace(diffuseMap.rgb);
- #endif
- diffuseMap.rgb*=vDiffuseInfos.y;
- #ifdef DIFFUSEHASALPHA
- finalAlpha*=diffuseMap.a;
- #endif
- diffuseColor=diffuseMap.rgb;
- #endif
- #ifdef REFLECTIONFRESNEL
- vec3 colorBase=diffuseColor;
- #else
- vec3 colorBase=reflectionColor.rgb*diffuseColor;
- #endif
- colorBase=max(colorBase,0.0);
- #ifdef USERGBCOLOR
- vec3 finalColor=colorBase;
- #else
- #ifdef USEHIGHLIGHTANDSHADOWCOLORS
- vec3 mainColor=mix(vPrimaryColorShadow.rgb,vPrimaryColor.rgb,colorBase);
- #else
- vec3 mainColor=vPrimaryColor.rgb;
- #endif
- vec3 finalColor=colorBase*mainColor;
- #endif
- #ifdef REFLECTIONFRESNEL
- vec3 reflectionAmount=vReflectionControl.xxx;
- vec3 reflectionReflectance0=vReflectionControl.yyy;
- vec3 reflectionReflectance90=vReflectionControl.zzz;
- float VdotN=dot(normalize(vEyePosition.xyz),normalW);
- vec3 planarReflectionFresnel=fresnelSchlickEnvironmentGGX(saturate(VdotN),reflectionReflectance0,reflectionReflectance90,1.0);
- reflectionAmount*=planarReflectionFresnel;
- #ifdef REFLECTIONFALLOFF
- float reflectionDistanceFalloff=1.0-saturate(length(vPositionW.xyz-vBackgroundCenter)*vReflectionControl.w);
- reflectionDistanceFalloff*=reflectionDistanceFalloff;
- reflectionAmount*=reflectionDistanceFalloff;
- #endif
- finalColor=mix(finalColor,reflectionColor.rgb,saturate(reflectionAmount));
- #endif
- #ifdef OPACITYFRESNEL
- float viewAngleToFloor=dot(normalW,normalize(vEyePosition.xyz-vBackgroundCenter));
- const float startAngle=0.1;
- float fadeFactor=saturate(viewAngleToFloor/startAngle);
- finalAlpha*=fadeFactor*fadeFactor;
- #endif
- #ifdef SHADOWINUSE
- finalColor=mix(finalColor*shadowLevel,finalColor,globalShadow);
- #endif
- vec4 color=vec4(finalColor,finalAlpha);
- #else
- vec4 color=vec4(vPrimaryColor.rgb,(1.0-clamp(globalShadow,0.,1.))*alpha);
- #endif
- #include<fogFragment>
- #ifdef IMAGEPROCESSINGPOSTPROCESS
- #if !defined(SKIPFINALCOLORCLAMP)
- color.rgb=clamp(color.rgb,0.,30.0);
- #endif
- #else
- color=applyImageProcessing(color);
- #endif
- #ifdef PREMULTIPLYALPHA
- color.rgb*=color.a;
- #endif
- #ifdef NOISE
- color.rgb+=dither(vPositionW.xy,0.5);
- color=max(color,0.0);
- #endif
- gl_FragColor=color;
- }
- `;
- ShaderStore.ShadersStore[name$5] = shader$5;
- var name$4 = "backgroundVertexDeclaration"
- , shader$4 = `uniform mat4 view;
- uniform mat4 viewProjection;
- uniform float shadowLevel;
- #ifdef DIFFUSE
- uniform mat4 diffuseMatrix;
- uniform vec2 vDiffuseInfos;
- #endif
- #ifdef REFLECTION
- uniform vec2 vReflectionInfos;
- uniform mat4 reflectionMatrix;
- uniform vec3 vReflectionMicrosurfaceInfos;
- uniform float fFovMultiplier;
- #endif
- #ifdef POINTSIZE
- uniform float pointSize;
- #endif`;
- ShaderStore.IncludesShadersStore[name$4] = shader$4;
- var name$3 = "backgroundVertexShader"
- , shader$3 = `precision highp float;
- #include<__decl__backgroundVertex>
- #include<helperFunctions>
- attribute vec3 position;
- #ifdef NORMAL
- attribute vec3 normal;
- #endif
- #include<bonesDeclaration>
- #include<bakedVertexAnimationDeclaration>
- #include<instancesDeclaration>
- varying vec3 vPositionW;
- #ifdef NORMAL
- varying vec3 vNormalW;
- #endif
- #ifdef UV1
- attribute vec2 uv;
- #endif
- #ifdef UV2
- attribute vec2 uv2;
- #endif
- #ifdef MAINUV1
- varying vec2 vMainUV1;
- #endif
- #ifdef MAINUV2
- varying vec2 vMainUV2;
- #endif
- #if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0
- varying vec2 vDiffuseUV;
- #endif
- #include<clipPlaneVertexDeclaration>
- #include<fogVertexDeclaration>
- #include<__decl__lightVxFragment>[0..maxSimultaneousLights]
- #ifdef REFLECTIONMAP_SKYBOX
- varying vec3 vPositionUVW;
- #endif
- #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
- varying vec3 vDirectionW;
- #endif
- void main(void) {
- #ifdef REFLECTIONMAP_SKYBOX
- vPositionUVW=position;
- #endif
- #include<instancesVertex>
- #include<bonesVertex>
- #include<bakedVertexAnimation>
- #ifdef MULTIVIEW
- if (gl_ViewID_OVR == 0u) {
- gl_Position=viewProjection*finalWorld*vec4(position,1.0);
- } else {
- gl_Position=viewProjectionR*finalWorld*vec4(position,1.0);
- }
- #else
- gl_Position=viewProjection*finalWorld*vec4(position,1.0);
- #endif
- vec4 worldPos=finalWorld*vec4(position,1.0);
- vPositionW=vec3(worldPos);
- #ifdef NORMAL
- mat3 normalWorld=mat3(finalWorld);
- #ifdef NONUNIFORMSCALING
- normalWorld=transposeMat3(inverseMat3(normalWorld));
- #endif
- vNormalW=normalize(normalWorld*normal);
- #endif
- #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
- vDirectionW=normalize(vec3(finalWorld*vec4(position,0.0)));
- #ifdef EQUIRECTANGULAR_RELFECTION_FOV
- mat3 screenToWorld=inverseMat3(mat3(finalWorld*viewProjection));
- vec3 segment=mix(vDirectionW,screenToWorld*vec3(0.0,0.0,1.0),abs(fFovMultiplier-1.0));
- if (fFovMultiplier<=1.0) {
- vDirectionW=normalize(segment);
- } else {
- vDirectionW=normalize(vDirectionW+(vDirectionW-segment));
- }
- #endif
- #endif
- #ifndef UV1
- vec2 uv=vec2(0.,0.);
- #endif
- #ifndef UV2
- vec2 uv2=vec2(0.,0.);
- #endif
- #ifdef MAINUV1
- vMainUV1=uv;
- #endif
- #ifdef MAINUV2
- vMainUV2=uv2;
- #endif
- #if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0
- if (vDiffuseInfos.x == 0.)
- {
- vDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));
- }
- else
- {
- vDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));
- }
- #endif
- #include<clipPlaneVertex>
- #include<fogVertex>
- #include<shadowsVertex>[0..maxSimultaneousLights]
- #ifdef VERTEXCOLOR
- vColor=color;
- #endif
- #ifdef POINTSIZE
- gl_PointSize=pointSize;
- #endif
- }
- `;
- ShaderStore.ShadersStore[name$3] = shader$3;
- var BackgroundMaterialDefines = function(a) {
- __extends(e, a);
- function e() {
- var i = a.call(this) || this;
- return i.DIFFUSE = !1,
- i.DIFFUSEDIRECTUV = 0,
- i.GAMMADIFFUSE = !1,
- i.DIFFUSEHASALPHA = !1,
- i.OPACITYFRESNEL = !1,
- i.REFLECTIONBLUR = !1,
- i.REFLECTIONFRESNEL = !1,
- i.REFLECTIONFALLOFF = !1,
- i.TEXTURELODSUPPORT = !1,
- i.PREMULTIPLYALPHA = !1,
- i.USERGBCOLOR = !1,
- i.USEHIGHLIGHTANDSHADOWCOLORS = !1,
- i.BACKMAT_SHADOWONLY = !1,
- i.NOISE = !1,
- i.REFLECTIONBGR = !1,
- i.IMAGEPROCESSING = !1,
- i.VIGNETTE = !1,
- i.VIGNETTEBLENDMODEMULTIPLY = !1,
- i.VIGNETTEBLENDMODEOPAQUE = !1,
- i.TONEMAPPING = !1,
- i.TONEMAPPING_ACES = !1,
- i.CONTRAST = !1,
- i.COLORCURVES = !1,
- i.COLORGRADING = !1,
- i.COLORGRADING3D = !1,
- i.SAMPLER3DGREENDEPTH = !1,
- i.SAMPLER3DBGRMAP = !1,
- i.IMAGEPROCESSINGPOSTPROCESS = !1,
- i.SKIPFINALCOLORCLAMP = !1,
- i.EXPOSURE = !1,
- i.MULTIVIEW = !1,
- i.REFLECTION = !1,
- i.REFLECTIONMAP_3D = !1,
- i.REFLECTIONMAP_SPHERICAL = !1,
- i.REFLECTIONMAP_PLANAR = !1,
- i.REFLECTIONMAP_CUBIC = !1,
- i.REFLECTIONMAP_PROJECTION = !1,
- i.REFLECTIONMAP_SKYBOX = !1,
- i.REFLECTIONMAP_EXPLICIT = !1,
- i.REFLECTIONMAP_EQUIRECTANGULAR = !1,
- i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1,
- i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1,
- i.INVERTCUBICMAP = !1,
- i.REFLECTIONMAP_OPPOSITEZ = !1,
- i.LODINREFLECTIONALPHA = !1,
- i.GAMMAREFLECTION = !1,
- i.RGBDREFLECTION = !1,
- i.EQUIRECTANGULAR_RELFECTION_FOV = !1,
- i.MAINUV1 = !1,
- i.MAINUV2 = !1,
- i.UV1 = !1,
- i.UV2 = !1,
- i.CLIPPLANE = !1,
- i.CLIPPLANE2 = !1,
- i.CLIPPLANE3 = !1,
- i.CLIPPLANE4 = !1,
- i.CLIPPLANE5 = !1,
- i.CLIPPLANE6 = !1,
- i.POINTSIZE = !1,
- i.FOG = !1,
- i.NORMAL = !1,
- i.NUM_BONE_INFLUENCERS = 0,
- i.BonesPerMesh = 0,
- i.INSTANCES = !1,
- i.SHADOWFLOAT = !1,
- i.LOGARITHMICDEPTH = !1,
- i.NONUNIFORMSCALING = !1,
- i.ALPHATEST = !1,
- i.rebuild(),
- i
- }
- return e
- }(MaterialDefines)
- , BackgroundMaterial = function(a) {
- __extends(e, a);
- function e(i, o) {
- var s = a.call(this, i, o) || this;
- return s.primaryColor = Color3.White(),
- s._primaryColorShadowLevel = 0,
- s._primaryColorHighlightLevel = 0,
- s.reflectionTexture = null,
- s.reflectionBlur = 0,
- s.diffuseTexture = null,
- s._shadowLights = null,
- s.shadowLights = null,
- s.shadowLevel = 0,
- s.sceneCenter = Vector3.Zero(),
- s.opacityFresnel = !0,
- s.reflectionFresnel = !1,
- s.reflectionFalloffDistance = 0,
- s.reflectionAmount = 1,
- s.reflectionReflectance0 = .05,
- s.reflectionReflectance90 = .5,
- s.useRGBColor = !0,
- s.enableNoise = !1,
- s._fovMultiplier = 1,
- s.useEquirectangularFOV = !1,
- s._maxSimultaneousLights = 4,
- s.maxSimultaneousLights = 4,
- s._shadowOnly = !1,
- s.shadowOnly = !1,
- s._imageProcessingObserver = null,
- s.switchToBGR = !1,
- s._renderTargets = new SmartArray(16),
- s._reflectionControls = Vector4.Zero(),
- s._white = Color3.White(),
- s._primaryShadowColor = Color3.Black(),
- s._primaryHighlightColor = Color3.Black(),
- s._attachImageProcessingConfiguration(null),
- s.getRenderTargetTextures = function() {
- return s._renderTargets.reset(),
- s._diffuseTexture && s._diffuseTexture.isRenderTarget && s._renderTargets.push(s._diffuseTexture),
- s._reflectionTexture && s._reflectionTexture.isRenderTarget && s._renderTargets.push(s._reflectionTexture),
- s._renderTargets
- }
- ,
- s
- }
- return Object.defineProperty(e.prototype, "_perceptualColor", {
- get: function() {
- return this.__perceptualColor
- },
- set: function(i) {
- this.__perceptualColor = i,
- this._computePrimaryColorFromPerceptualColor(),
- this._markAllSubMeshesAsLightsDirty()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "primaryColorShadowLevel", {
- get: function() {
- return this._primaryColorShadowLevel
- },
- set: function(i) {
- this._primaryColorShadowLevel = i,
- this._computePrimaryColors(),
- this._markAllSubMeshesAsLightsDirty()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "primaryColorHighlightLevel", {
- get: function() {
- return this._primaryColorHighlightLevel
- },
- set: function(i) {
- this._primaryColorHighlightLevel = i,
- this._computePrimaryColors(),
- this._markAllSubMeshesAsLightsDirty()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "reflectionStandardFresnelWeight", {
- set: function(i) {
- var o = i;
- o < .5 ? (o = o * 2,
- this.reflectionReflectance0 = e.StandardReflectance0 * o,
- this.reflectionReflectance90 = e.StandardReflectance90 * o) : (o = o * 2 - 1,
- this.reflectionReflectance0 = e.StandardReflectance0 + (1 - e.StandardReflectance0) * o,
- this.reflectionReflectance90 = e.StandardReflectance90 + (1 - e.StandardReflectance90) * o)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "fovMultiplier", {
- get: function() {
- return this._fovMultiplier
- },
- set: function(i) {
- isNaN(i) && (i = 1),
- this._fovMultiplier = Math.max(0, Math.min(2, i))
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._attachImageProcessingConfiguration = function(i) {
- var o = this;
- i !== this._imageProcessingConfiguration && (this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
- i ? this._imageProcessingConfiguration = i : this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration,
- this._imageProcessingConfiguration && (this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function() {
- o._computePrimaryColorFromPerceptualColor(),
- o._markAllSubMeshesAsImageProcessingDirty()
- })))
- }
- ,
- Object.defineProperty(e.prototype, "imageProcessingConfiguration", {
- get: function() {
- return this._imageProcessingConfiguration
- },
- set: function(i) {
- this._attachImageProcessingConfiguration(i),
- this._markAllSubMeshesAsTexturesDirty()
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cameraColorCurvesEnabled", {
- get: function() {
- return this.imageProcessingConfiguration.colorCurvesEnabled
- },
- set: function(i) {
- this.imageProcessingConfiguration.colorCurvesEnabled = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cameraColorGradingEnabled", {
- get: function() {
- return this.imageProcessingConfiguration.colorGradingEnabled
- },
- set: function(i) {
- this.imageProcessingConfiguration.colorGradingEnabled = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cameraToneMappingEnabled", {
- get: function() {
- return this._imageProcessingConfiguration.toneMappingEnabled
- },
- set: function(i) {
- this._imageProcessingConfiguration.toneMappingEnabled = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cameraExposure", {
- get: function() {
- return this._imageProcessingConfiguration.exposure
- },
- set: function(i) {
- this._imageProcessingConfiguration.exposure = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cameraContrast", {
- get: function() {
- return this._imageProcessingConfiguration.contrast
- },
- set: function(i) {
- this._imageProcessingConfiguration.contrast = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cameraColorGradingTexture", {
- get: function() {
- return this._imageProcessingConfiguration.colorGradingTexture
- },
- set: function(i) {
- this.imageProcessingConfiguration.colorGradingTexture = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "cameraColorCurves", {
- get: function() {
- return this.imageProcessingConfiguration.colorCurves
- },
- set: function(i) {
- this.imageProcessingConfiguration.colorCurves = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "hasRenderTargetTextures", {
- get: function() {
- return !!(this._diffuseTexture && this._diffuseTexture.isRenderTarget || this._reflectionTexture && this._reflectionTexture.isRenderTarget)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.needAlphaTesting = function() {
- return !0
- }
- ,
- e.prototype.needAlphaBlending = function() {
- return this.alpha < 1 || this._diffuseTexture != null && this._diffuseTexture.hasAlpha || this._shadowOnly
- }
- ,
- e.prototype.isReadyForSubMesh = function(i, o, s) {
- if (s === void 0 && (s = !1),
- o.effect && this.isFrozen && o.effect._wasPreviouslyReady)
- return !0;
- o.materialDefines || (o.materialDefines = new BackgroundMaterialDefines);
- var c = this.getScene()
- , d = o.materialDefines;
- if (this._isReadyForSubMesh(o))
- return !0;
- var _ = c.getEngine();
- if (MaterialHelper.PrepareDefinesForLights(c, i, d, !1, this._maxSimultaneousLights),
- d._needNormals = !0,
- MaterialHelper.PrepareDefinesForMultiview(c, d),
- d._areTexturesDirty) {
- if (d._needUVs = !1,
- c.texturesEnabled) {
- if (c.getEngine().getCaps().textureLOD && (d.TEXTURELODSUPPORT = !0),
- this._diffuseTexture && MaterialFlags.DiffuseTextureEnabled) {
- if (!this._diffuseTexture.isReadyOrNotBlocking())
- return !1;
- MaterialHelper.PrepareDefinesForMergedUV(this._diffuseTexture, d, "DIFFUSE"),
- d.DIFFUSEHASALPHA = this._diffuseTexture.hasAlpha,
- d.GAMMADIFFUSE = this._diffuseTexture.gammaSpace,
- d.OPACITYFRESNEL = this._opacityFresnel
- } else
- d.DIFFUSE = !1,
- d.DIFFUSEHASALPHA = !1,
- d.GAMMADIFFUSE = !1,
- d.OPACITYFRESNEL = !1;
- var b = this._reflectionTexture;
- if (b && MaterialFlags.ReflectionTextureEnabled) {
- if (!b.isReadyOrNotBlocking())
- return !1;
- switch (d.REFLECTION = !0,
- d.GAMMAREFLECTION = b.gammaSpace,
- d.RGBDREFLECTION = b.isRGBD,
- d.REFLECTIONBLUR = this._reflectionBlur > 0,
- d.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !b.invertZ : b.invertZ,
- d.LODINREFLECTIONALPHA = b.lodLevelInAlpha,
- d.EQUIRECTANGULAR_RELFECTION_FOV = this.useEquirectangularFOV,
- d.REFLECTIONBGR = this.switchToBGR,
- b.coordinatesMode === Texture.INVCUBIC_MODE && (d.INVERTCUBICMAP = !0),
- d.REFLECTIONMAP_3D = b.isCube,
- b.coordinatesMode) {
- case Texture.EXPLICIT_MODE:
- d.REFLECTIONMAP_EXPLICIT = !0;
- break;
- case Texture.PLANAR_MODE:
- d.REFLECTIONMAP_PLANAR = !0;
- break;
- case Texture.PROJECTION_MODE:
- d.REFLECTIONMAP_PROJECTION = !0;
- break;
- case Texture.SKYBOX_MODE:
- d.REFLECTIONMAP_SKYBOX = !0;
- break;
- case Texture.SPHERICAL_MODE:
- d.REFLECTIONMAP_SPHERICAL = !0;
- break;
- case Texture.EQUIRECTANGULAR_MODE:
- d.REFLECTIONMAP_EQUIRECTANGULAR = !0;
- break;
- case Texture.FIXED_EQUIRECTANGULAR_MODE:
- d.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !0;
- break;
- case Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
- d.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !0;
- break;
- case Texture.CUBIC_MODE:
- case Texture.INVCUBIC_MODE:
- default:
- d.REFLECTIONMAP_CUBIC = !0;
- break
- }
- this.reflectionFresnel ? (d.REFLECTIONFRESNEL = !0,
- d.REFLECTIONFALLOFF = this.reflectionFalloffDistance > 0,
- this._reflectionControls.x = this.reflectionAmount,
- this._reflectionControls.y = this.reflectionReflectance0,
- this._reflectionControls.z = this.reflectionReflectance90,
- this._reflectionControls.w = 1 / this.reflectionFalloffDistance) : (d.REFLECTIONFRESNEL = !1,
- d.REFLECTIONFALLOFF = !1)
- } else
- d.REFLECTION = !1,
- d.REFLECTIONFRESNEL = !1,
- d.REFLECTIONFALLOFF = !1,
- d.REFLECTIONBLUR = !1,
- d.REFLECTIONMAP_3D = !1,
- d.REFLECTIONMAP_SPHERICAL = !1,
- d.REFLECTIONMAP_PLANAR = !1,
- d.REFLECTIONMAP_CUBIC = !1,
- d.REFLECTIONMAP_PROJECTION = !1,
- d.REFLECTIONMAP_SKYBOX = !1,
- d.REFLECTIONMAP_EXPLICIT = !1,
- d.REFLECTIONMAP_EQUIRECTANGULAR = !1,
- d.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = !1,
- d.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = !1,
- d.INVERTCUBICMAP = !1,
- d.REFLECTIONMAP_OPPOSITEZ = !1,
- d.LODINREFLECTIONALPHA = !1,
- d.GAMMAREFLECTION = !1,
- d.RGBDREFLECTION = !1
- }
- d.PREMULTIPLYALPHA = this.alphaMode === 7 || this.alphaMode === 8,
- d.USERGBCOLOR = this._useRGBColor,
- d.NOISE = this._enableNoise
- }
- if (d._areLightsDirty && (d.USEHIGHLIGHTANDSHADOWCOLORS = !this._useRGBColor && (this._primaryColorShadowLevel !== 0 || this._primaryColorHighlightLevel !== 0),
- d.BACKMAT_SHADOWONLY = this._shadowOnly),
- d._areImageProcessingDirty && this._imageProcessingConfiguration) {
- if (!this._imageProcessingConfiguration.isReady())
- return !1;
- this._imageProcessingConfiguration.prepareDefines(d)
- }
- if (MaterialHelper.PrepareDefinesForMisc(i, c, !1, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(i), d),
- MaterialHelper.PrepareDefinesForFrameBoundValues(c, _, d, s, null, o.getRenderingMesh().hasThinInstances),
- MaterialHelper.PrepareDefinesForAttributes(i, d, !1, !0, !1) && i && !c.getEngine().getCaps().standardDerivatives && !i.isVerticesDataPresent(VertexBuffer.NormalKind) && (i.createNormals(!0),
- Logger$2.Warn("BackgroundMaterial: Normals have been created for the mesh: " + i.name)),
- d.isDirty) {
- d.markAsProcessed(),
- c.resetCachedMaterial();
- var k = new EffectFallbacks;
- d.FOG && k.addFallback(0, "FOG"),
- d.POINTSIZE && k.addFallback(1, "POINTSIZE"),
- d.MULTIVIEW && k.addFallback(0, "MULTIVIEW"),
- MaterialHelper.HandleFallbacksForShadows(d, k, this._maxSimultaneousLights);
- var j = [VertexBuffer.PositionKind];
- d.NORMAL && j.push(VertexBuffer.NormalKind),
- d.UV1 && j.push(VertexBuffer.UVKind),
- d.UV2 && j.push(VertexBuffer.UV2Kind),
- MaterialHelper.PrepareAttributesForBones(j, i, d, k),
- MaterialHelper.PrepareAttributesForInstances(j, d);
- 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"]
- , _e = ["diffuseSampler", "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh"]
- , et = ["Material", "Scene"];
- ImageProcessingConfiguration && (ImageProcessingConfiguration.PrepareUniforms($, d),
- ImageProcessingConfiguration.PrepareSamplers(_e, d)),
- MaterialHelper.PrepareUniformsAndSamplersList({
- uniformsNames: $,
- uniformBuffersNames: et,
- samplers: _e,
- defines: d,
- maxSimultaneousLights: this._maxSimultaneousLights
- });
- var tt = d.toString()
- , rt = c.getEngine().createEffect("background", {
- attributes: j,
- uniformsNames: $,
- uniformBuffersNames: et,
- samplers: _e,
- defines: tt,
- fallbacks: k,
- onCompiled: this.onCompiled,
- onError: this.onError,
- indexParameters: {
- maxSimultaneousLights: this._maxSimultaneousLights
- }
- }, _);
- o.setEffect(rt, d, this._materialContext),
- this.buildUniformLayout()
- }
- return !o.effect || !o.effect.isReady() ? !1 : (d._renderId = c.getRenderId(),
- o.effect._wasPreviouslyReady = !0,
- !0)
- }
- ,
- e.prototype._computePrimaryColorFromPerceptualColor = function() {
- !this.__perceptualColor || (this._primaryColor.copyFrom(this.__perceptualColor),
- this._primaryColor.toLinearSpaceToRef(this._primaryColor),
- this._imageProcessingConfiguration && this._primaryColor.scaleToRef(1 / this._imageProcessingConfiguration.exposure, this._primaryColor),
- this._computePrimaryColors())
- }
- ,
- e.prototype._computePrimaryColors = function() {
- this._primaryColorShadowLevel === 0 && this._primaryColorHighlightLevel === 0 || (this._primaryColor.scaleToRef(this._primaryColorShadowLevel, this._primaryShadowColor),
- this._primaryColor.subtractToRef(this._primaryShadowColor, this._primaryShadowColor),
- this._white.subtractToRef(this._primaryColor, this._primaryHighlightColor),
- this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel, this._primaryHighlightColor),
- this._primaryColor.addToRef(this._primaryHighlightColor, this._primaryHighlightColor))
- }
- ,
- e.prototype.buildUniformLayout = function() {
- this._uniformBuffer.addUniform("vPrimaryColor", 4),
- this._uniformBuffer.addUniform("vPrimaryColorShadow", 4),
- this._uniformBuffer.addUniform("vDiffuseInfos", 2),
- this._uniformBuffer.addUniform("vReflectionInfos", 2),
- this._uniformBuffer.addUniform("diffuseMatrix", 16),
- this._uniformBuffer.addUniform("reflectionMatrix", 16),
- this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3),
- this._uniformBuffer.addUniform("fFovMultiplier", 1),
- this._uniformBuffer.addUniform("pointSize", 1),
- this._uniformBuffer.addUniform("shadowLevel", 1),
- this._uniformBuffer.addUniform("alpha", 1),
- this._uniformBuffer.addUniform("vBackgroundCenter", 3),
- this._uniformBuffer.addUniform("vReflectionControl", 4),
- this._uniformBuffer.create()
- }
- ,
- e.prototype.unbind = function() {
- this._diffuseTexture && this._diffuseTexture.isRenderTarget && this._uniformBuffer.setTexture("diffuseSampler", null),
- this._reflectionTexture && this._reflectionTexture.isRenderTarget && this._uniformBuffer.setTexture("reflectionSampler", null),
- a.prototype.unbind.call(this)
- }
- ,
- e.prototype.bindOnlyWorldMatrix = function(i) {
- this._activeEffect.setMatrix("world", i)
- }
- ,
- e.prototype.bindForSubMesh = function(i, o, s) {
- var c = this.getScene()
- , d = s.materialDefines;
- if (!!d) {
- var _ = s.effect;
- if (!!_) {
- this._activeEffect = _,
- this.bindOnlyWorldMatrix(i),
- MaterialHelper.BindBonesParameters(o, this._activeEffect);
- var b = this._mustRebind(c, _, o.visibility);
- if (b) {
- this._uniformBuffer.bindToEffect(_, "Material"),
- this.bindViewProjection(_);
- var k = this._reflectionTexture;
- (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) && (c.texturesEnabled && (this._diffuseTexture && MaterialFlags.DiffuseTextureEnabled && (this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level),
- MaterialHelper.BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse")),
- k && MaterialFlags.ReflectionTextureEnabled && (this._uniformBuffer.updateMatrix("reflectionMatrix", k.getReflectionTextureMatrix()),
- this._uniformBuffer.updateFloat2("vReflectionInfos", k.level, this._reflectionBlur),
- this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", k.getSize().width, k.lodGenerationScale, k.lodGenerationOffset))),
- this.shadowLevel > 0 && this._uniformBuffer.updateFloat("shadowLevel", this.shadowLevel),
- this._uniformBuffer.updateFloat("alpha", this.alpha),
- this.pointsCloud && this._uniformBuffer.updateFloat("pointSize", this.pointSize),
- d.USEHIGHLIGHTANDSHADOWCOLORS ? (this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryHighlightColor, 1),
- this._uniformBuffer.updateColor4("vPrimaryColorShadow", this._primaryShadowColor, 1)) : this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryColor, 1)),
- this._uniformBuffer.updateFloat("fFovMultiplier", this._fovMultiplier),
- c.texturesEnabled && (this._diffuseTexture && MaterialFlags.DiffuseTextureEnabled && this._uniformBuffer.setTexture("diffuseSampler", this._diffuseTexture),
- k && MaterialFlags.ReflectionTextureEnabled && (d.REFLECTIONBLUR && d.TEXTURELODSUPPORT ? this._uniformBuffer.setTexture("reflectionSampler", k) : d.REFLECTIONBLUR ? (this._uniformBuffer.setTexture("reflectionSampler", k._lodTextureMid || k),
- this._uniformBuffer.setTexture("reflectionSamplerLow", k._lodTextureLow || k),
- this._uniformBuffer.setTexture("reflectionSamplerHigh", k._lodTextureHigh || k)) : this._uniformBuffer.setTexture("reflectionSampler", k),
- d.REFLECTIONFRESNEL && (this._uniformBuffer.updateFloat3("vBackgroundCenter", this.sceneCenter.x, this.sceneCenter.y, this.sceneCenter.z),
- this._uniformBuffer.updateFloat4("vReflectionControl", this._reflectionControls.x, this._reflectionControls.y, this._reflectionControls.z, this._reflectionControls.w)))),
- MaterialHelper.BindClipPlane(this._activeEffect, c),
- c.bindEyePosition(_)
- } else
- c.getEngine()._features.needToAlwaysBindUniformBuffers && (this._uniformBuffer.bindToEffect(_, "Material"),
- this._needToBindSceneUbo = !0);
- (b || !this.isFrozen) && (c.lightsEnabled && MaterialHelper.BindLights(c, o, this._activeEffect, d, this._maxSimultaneousLights),
- this.bindView(_),
- MaterialHelper.BindFogParameters(c, o, this._activeEffect, !0),
- this._imageProcessingConfiguration && this._imageProcessingConfiguration.bind(this._activeEffect)),
- this._afterBind(o, this._activeEffect),
- this._uniformBuffer.update()
- }
- }
- }
- ,
- e.prototype.hasTexture = function(i) {
- return !!(a.prototype.hasTexture.call(this, i) || this._reflectionTexture === i || this._diffuseTexture === i)
- }
- ,
- e.prototype.dispose = function(i, o) {
- i === void 0 && (i = !1),
- o === void 0 && (o = !1),
- o && (this.diffuseTexture && this.diffuseTexture.dispose(),
- this.reflectionTexture && this.reflectionTexture.dispose()),
- this._renderTargets.dispose(),
- this._imageProcessingConfiguration && this._imageProcessingObserver && this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
- a.prototype.dispose.call(this, i)
- }
- ,
- e.prototype.clone = function(i) {
- var o = this;
- return SerializationHelper.Clone(function() {
- return new e(i,o.getScene())
- }, this)
- }
- ,
- e.prototype.serialize = function() {
- var i = SerializationHelper.Serialize(this);
- return i.customType = "BABYLON.BackgroundMaterial",
- i
- }
- ,
- e.prototype.getClassName = function() {
- return "BackgroundMaterial"
- }
- ,
- e.Parse = function(i, o, s) {
- return SerializationHelper.Parse(function() {
- return new e(i.name,o)
- }, i, o, s)
- }
- ,
- e.StandardReflectance0 = .05,
- e.StandardReflectance90 = .5,
- __decorate([serializeAsColor3()], e.prototype, "_primaryColor", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsLightsDirty")], e.prototype, "primaryColor", void 0),
- __decorate([serializeAsColor3()], e.prototype, "__perceptualColor", void 0),
- __decorate([serialize()], e.prototype, "_primaryColorShadowLevel", void 0),
- __decorate([serialize()], e.prototype, "_primaryColorHighlightLevel", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsLightsDirty")], e.prototype, "primaryColorHighlightLevel", null),
- __decorate([serializeAsTexture()], e.prototype, "_reflectionTexture", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "reflectionTexture", void 0),
- __decorate([serialize()], e.prototype, "_reflectionBlur", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "reflectionBlur", void 0),
- __decorate([serializeAsTexture()], e.prototype, "_diffuseTexture", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "diffuseTexture", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "shadowLights", void 0),
- __decorate([serialize()], e.prototype, "_shadowLevel", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "shadowLevel", void 0),
- __decorate([serializeAsVector3()], e.prototype, "_sceneCenter", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "sceneCenter", void 0),
- __decorate([serialize()], e.prototype, "_opacityFresnel", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "opacityFresnel", void 0),
- __decorate([serialize()], e.prototype, "_reflectionFresnel", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "reflectionFresnel", void 0),
- __decorate([serialize()], e.prototype, "_reflectionFalloffDistance", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "reflectionFalloffDistance", void 0),
- __decorate([serialize()], e.prototype, "_reflectionAmount", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "reflectionAmount", void 0),
- __decorate([serialize()], e.prototype, "_reflectionReflectance0", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "reflectionReflectance0", void 0),
- __decorate([serialize()], e.prototype, "_reflectionReflectance90", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "reflectionReflectance90", void 0),
- __decorate([serialize()], e.prototype, "_useRGBColor", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "useRGBColor", void 0),
- __decorate([serialize()], e.prototype, "_enableNoise", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "enableNoise", void 0),
- __decorate([serialize()], e.prototype, "_maxSimultaneousLights", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsTexturesDirty")], e.prototype, "maxSimultaneousLights", void 0),
- __decorate([serialize()], e.prototype, "_shadowOnly", void 0),
- __decorate([expandToProperty("_markAllSubMeshesAsLightsDirty")], e.prototype, "shadowOnly", void 0),
- __decorate([serializeAsImageProcessingConfiguration()], e.prototype, "_imageProcessingConfiguration", void 0),
- e
- }(PushMaterial);
- RegisterClass("BABYLON.BackgroundMaterial", BackgroundMaterial);
- var EnvironmentHelper = function() {
- function a(e, i) {
- var o = this;
- this._errorHandler = function(s, c) {
- o.onErrorObservable.notifyObservers({
- message: s,
- exception: c
- })
- }
- ,
- this._options = __assign(__assign({}, a._getDefaultOptions()), e),
- this._scene = i,
- this.onErrorObservable = new Observable,
- this._setupBackground(),
- this._setupImageProcessing()
- }
- return a._getDefaultOptions = function() {
- return {
- createGround: !0,
- groundSize: 15,
- groundTexture: this._groundTextureCDNUrl,
- groundColor: new Color3(.2,.2,.3).toLinearSpace().scale(3),
- groundOpacity: .9,
- enableGroundShadow: !0,
- groundShadowLevel: .5,
- enableGroundMirror: !1,
- groundMirrorSizeRatio: .3,
- groundMirrorBlurKernel: 64,
- groundMirrorAmount: 1,
- groundMirrorFresnelWeight: 1,
- groundMirrorFallOffDistance: 0,
- groundMirrorTextureType: 0,
- groundYBias: 1e-5,
- createSkybox: !0,
- skyboxSize: 20,
- skyboxTexture: this._skyboxTextureCDNUrl,
- skyboxColor: new Color3(.2,.2,.3).toLinearSpace().scale(3),
- backgroundYRotation: 0,
- sizeAuto: !0,
- rootPosition: Vector3.Zero(),
- setupImageProcessing: !0,
- environmentTexture: this._environmentTextureCDNUrl,
- cameraExposure: .8,
- cameraContrast: 1.2,
- toneMappingEnabled: !0
- }
- }
- ,
- Object.defineProperty(a.prototype, "rootMesh", {
- get: function() {
- return this._rootMesh
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "skybox", {
- get: function() {
- return this._skybox
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "skyboxTexture", {
- get: function() {
- return this._skyboxTexture
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "skyboxMaterial", {
- get: function() {
- return this._skyboxMaterial
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "ground", {
- get: function() {
- return this._ground
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "groundTexture", {
- get: function() {
- return this._groundTexture
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "groundMirror", {
- get: function() {
- return this._groundMirror
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "groundMirrorRenderList", {
- get: function() {
- return this._groundMirror ? this._groundMirror.renderList : null
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "groundMaterial", {
- get: function() {
- return this._groundMaterial
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.updateOptions = function(e) {
- var i = __assign(__assign({}, this._options), e);
- this._ground && !i.createGround && (this._ground.dispose(),
- this._ground = null),
- this._groundMaterial && !i.createGround && (this._groundMaterial.dispose(),
- this._groundMaterial = null),
- this._groundTexture && this._options.groundTexture != i.groundTexture && (this._groundTexture.dispose(),
- this._groundTexture = null),
- this._skybox && !i.createSkybox && (this._skybox.dispose(),
- this._skybox = null),
- this._skyboxMaterial && !i.createSkybox && (this._skyboxMaterial.dispose(),
- this._skyboxMaterial = null),
- this._skyboxTexture && this._options.skyboxTexture != i.skyboxTexture && (this._skyboxTexture.dispose(),
- this._skyboxTexture = null),
- this._groundMirror && !i.enableGroundMirror && (this._groundMirror.dispose(),
- this._groundMirror = null),
- this._scene.environmentTexture && this._options.environmentTexture != i.environmentTexture && this._scene.environmentTexture.dispose(),
- this._options = i,
- this._setupBackground(),
- this._setupImageProcessing()
- }
- ,
- a.prototype.setMainColor = function(e) {
- this.groundMaterial && (this.groundMaterial.primaryColor = e),
- this.skyboxMaterial && (this.skyboxMaterial.primaryColor = e),
- this.groundMirror && (this.groundMirror.clearColor = new Color4(e.r,e.g,e.b,1))
- }
- ,
- a.prototype._setupImageProcessing = function() {
- this._options.setupImageProcessing && (this._scene.imageProcessingConfiguration.contrast = this._options.cameraContrast,
- this._scene.imageProcessingConfiguration.exposure = this._options.cameraExposure,
- this._scene.imageProcessingConfiguration.toneMappingEnabled = this._options.toneMappingEnabled,
- this._setupEnvironmentTexture())
- }
- ,
- a.prototype._setupEnvironmentTexture = function() {
- if (!this._scene.environmentTexture) {
- if (this._options.environmentTexture instanceof BaseTexture) {
- this._scene.environmentTexture = this._options.environmentTexture;
- return
- }
- var e = CubeTexture.CreateFromPrefilteredData(this._options.environmentTexture, this._scene);
- this._scene.environmentTexture = e
- }
- }
- ,
- a.prototype._setupBackground = function() {
- this._rootMesh || (this._rootMesh = new Mesh("BackgroundHelper",this._scene)),
- this._rootMesh.rotation.y = this._options.backgroundYRotation;
- var e = this._getSceneSize();
- this._options.createGround && (this._setupGround(e),
- this._setupGroundMaterial(),
- this._setupGroundDiffuseTexture(),
- this._options.enableGroundMirror && this._setupGroundMirrorTexture(e),
- this._setupMirrorInGroundMaterial()),
- this._options.createSkybox && (this._setupSkybox(e),
- this._setupSkyboxMaterial(),
- this._setupSkyboxReflectionTexture()),
- this._rootMesh.position.x = e.rootPosition.x,
- this._rootMesh.position.z = e.rootPosition.z,
- this._rootMesh.position.y = e.rootPosition.y
- }
- ,
- a.prototype._getSceneSize = function() {
- var e = this
- , i = this._options.groundSize
- , o = this._options.skyboxSize
- , s = this._options.rootPosition;
- if (!this._scene.meshes || this._scene.meshes.length === 1)
- return {
- groundSize: i,
- skyboxSize: o,
- rootPosition: s
- };
- var c = this._scene.getWorldExtends(function(b) {
- return b !== e._ground && b !== e._rootMesh && b !== e._skybox
- })
- , d = c.max.subtract(c.min);
- if (this._options.sizeAuto) {
- this._scene.activeCamera instanceof ArcRotateCamera && this._scene.activeCamera.upperRadiusLimit && (i = this._scene.activeCamera.upperRadiusLimit * 2,
- o = i);
- var _ = d.length();
- _ > i && (i = _ * 2,
- o = i),
- i *= 1.1,
- o *= 1.5,
- s = c.min.add(d.scale(.5)),
- s.y = c.min.y - this._options.groundYBias
- }
- return {
- groundSize: i,
- skyboxSize: o,
- rootPosition: s
- }
- }
- ,
- a.prototype._setupGround = function(e) {
- var i = this;
- (!this._ground || this._ground.isDisposed()) && (this._ground = CreatePlane("BackgroundPlane", {
- size: e.groundSize
- }, this._scene),
- this._ground.rotation.x = Math.PI / 2,
- this._ground.parent = this._rootMesh,
- this._ground.onDisposeObservable.add(function() {
- i._ground = null
- })),
- this._ground.receiveShadows = this._options.enableGroundShadow
- }
- ,
- a.prototype._setupGroundMaterial = function() {
- this._groundMaterial || (this._groundMaterial = new BackgroundMaterial("BackgroundPlaneMaterial",this._scene)),
- this._groundMaterial.alpha = this._options.groundOpacity,
- this._groundMaterial.alphaMode = 8,
- this._groundMaterial.shadowLevel = this._options.groundShadowLevel,
- this._groundMaterial.primaryColor = this._options.groundColor,
- this._groundMaterial.useRGBColor = !1,
- this._groundMaterial.enableNoise = !0,
- this._ground && (this._ground.material = this._groundMaterial)
- }
- ,
- a.prototype._setupGroundDiffuseTexture = function() {
- if (!!this._groundMaterial && !this._groundTexture) {
- if (this._options.groundTexture instanceof BaseTexture) {
- this._groundMaterial.diffuseTexture = this._options.groundTexture;
- return
- }
- this._groundTexture = new Texture(this._options.groundTexture,this._scene,void 0,void 0,void 0,void 0,this._errorHandler),
- this._groundTexture.gammaSpace = !1,
- this._groundTexture.hasAlpha = !0,
- this._groundMaterial.diffuseTexture = this._groundTexture
- }
- }
- ,
- a.prototype._setupGroundMirrorTexture = function(e) {
- var i = Texture.CLAMP_ADDRESSMODE;
- if (!this._groundMirror && (this._groundMirror = new MirrorTexture("BackgroundPlaneMirrorTexture",{
- ratio: this._options.groundMirrorSizeRatio
- },this._scene,!1,this._options.groundMirrorTextureType,Texture.BILINEAR_SAMPLINGMODE,!0),
- this._groundMirror.mirrorPlane = new Plane(0,-1,0,e.rootPosition.y),
- this._groundMirror.anisotropicFilteringLevel = 1,
- this._groundMirror.wrapU = i,
- this._groundMirror.wrapV = i,
- this._groundMirror.gammaSpace = !1,
- this._groundMirror.renderList))
- for (var o = 0; o < this._scene.meshes.length; o++) {
- var s = this._scene.meshes[o];
- s !== this._ground && s !== this._skybox && s !== this._rootMesh && this._groundMirror.renderList.push(s)
- }
- this._groundMirror.clearColor = new Color4(this._options.groundColor.r,this._options.groundColor.g,this._options.groundColor.b,1),
- this._groundMirror.adaptiveBlurKernel = this._options.groundMirrorBlurKernel
- }
- ,
- a.prototype._setupMirrorInGroundMaterial = function() {
- this._groundMaterial && (this._groundMaterial.reflectionTexture = this._groundMirror,
- this._groundMaterial.reflectionFresnel = !0,
- this._groundMaterial.reflectionAmount = this._options.groundMirrorAmount,
- this._groundMaterial.reflectionStandardFresnelWeight = this._options.groundMirrorFresnelWeight,
- this._groundMaterial.reflectionFalloffDistance = this._options.groundMirrorFallOffDistance)
- }
- ,
- a.prototype._setupSkybox = function(e) {
- var i = this;
- (!this._skybox || this._skybox.isDisposed()) && (this._skybox = CreateBox("BackgroundSkybox", {
- size: e.skyboxSize,
- sideOrientation: Mesh.BACKSIDE
- }, this._scene),
- this._skybox.onDisposeObservable.add(function() {
- i._skybox = null
- })),
- this._skybox.parent = this._rootMesh
- }
- ,
- a.prototype._setupSkyboxMaterial = function() {
- !this._skybox || (this._skyboxMaterial || (this._skyboxMaterial = new BackgroundMaterial("BackgroundSkyboxMaterial",this._scene)),
- this._skyboxMaterial.useRGBColor = !1,
- this._skyboxMaterial.primaryColor = this._options.skyboxColor,
- this._skyboxMaterial.enableNoise = !0,
- this._skybox.material = this._skyboxMaterial)
- }
- ,
- a.prototype._setupSkyboxReflectionTexture = function() {
- if (!!this._skyboxMaterial && !this._skyboxTexture) {
- if (this._options.skyboxTexture instanceof BaseTexture) {
- this._skyboxMaterial.reflectionTexture = this._options.skyboxTexture;
- return
- }
- this._skyboxTexture = new CubeTexture(this._options.skyboxTexture,this._scene,void 0,void 0,void 0,void 0,this._errorHandler),
- this._skyboxTexture.coordinatesMode = Texture.SKYBOX_MODE,
- this._skyboxTexture.gammaSpace = !1,
- this._skyboxMaterial.reflectionTexture = this._skyboxTexture
- }
- }
- ,
- a.prototype.dispose = function() {
- this._groundMaterial && this._groundMaterial.dispose(!0, !0),
- this._skyboxMaterial && this._skyboxMaterial.dispose(!0, !0),
- this._rootMesh.dispose(!1)
- }
- ,
- a._groundTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundGround.png",
- a._skyboxTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundSkybox.dds",
- a._environmentTextureCDNUrl = "https://assets.babylonjs.com/environments/environmentSpecular.env",
- a
- }();
- FreeCameraInputsManager.prototype.addDeviceOrientation = function() {
- return this._deviceOrientationInput || (this._deviceOrientationInput = new FreeCameraDeviceOrientationInput,
- this.add(this._deviceOrientationInput)),
- this
- }
- ;
- var FreeCameraDeviceOrientationInput = function() {
- function a() {
- var e = this;
- this._screenOrientationAngle = 0,
- this._screenQuaternion = new Quaternion,
- this._alpha = 0,
- this._beta = 0,
- this._gamma = 0,
- this._onDeviceOrientationChangedObservable = new Observable,
- this._orientationChanged = function() {
- e._screenOrientationAngle = window.orientation !== void 0 ? +window.orientation : window.screen.orientation && window.screen.orientation.angle ? window.screen.orientation.angle : 0,
- e._screenOrientationAngle = -Tools.ToRadians(e._screenOrientationAngle / 2),
- e._screenQuaternion.copyFromFloats(0, Math.sin(e._screenOrientationAngle), 0, Math.cos(e._screenOrientationAngle))
- }
- ,
- this._deviceOrientation = function(i) {
- e._alpha = i.alpha !== null ? i.alpha : 0,
- e._beta = i.beta !== null ? i.beta : 0,
- e._gamma = i.gamma !== null ? i.gamma : 0,
- i.alpha !== null && e._onDeviceOrientationChangedObservable.notifyObservers()
- }
- ,
- this._constantTranform = new Quaternion(-Math.sqrt(.5),0,0,Math.sqrt(.5)),
- this._orientationChanged()
- }
- return a.WaitForOrientationChangeAsync = function(e) {
- return new Promise(function(i, o) {
- var s = !1
- , c = function() {
- window.removeEventListener("deviceorientation", c),
- s = !0,
- i()
- };
- e && setTimeout(function() {
- s || (window.removeEventListener("deviceorientation", c),
- o("WaitForOrientationChangeAsync timed out"))
- }, e),
- typeof DeviceOrientationEvent != "undefined" && typeof DeviceOrientationEvent.requestPermission == "function" ? DeviceOrientationEvent.requestPermission().then(function(d) {
- d == "granted" ? window.addEventListener("deviceorientation", c) : Tools.Warn("Permission not granted.")
- }).catch(function(d) {
- Tools.Error(d)
- }) : window.addEventListener("deviceorientation", c)
- }
- )
- }
- ,
- Object.defineProperty(a.prototype, "camera", {
- get: function() {
- return this._camera
- },
- set: function(e) {
- var i = this;
- this._camera = e,
- this._camera != null && !this._camera.rotationQuaternion && (this._camera.rotationQuaternion = new Quaternion),
- this._camera && this._camera.onDisposeObservable.add(function() {
- i._onDeviceOrientationChangedObservable.clear()
- })
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.attachControl = function() {
- var e = this
- , i = this.camera.getScene().getEngine().getHostWindow();
- if (i) {
- var o = function() {
- i.addEventListener("orientationchange", e._orientationChanged),
- i.addEventListener("deviceorientation", e._deviceOrientation),
- e._orientationChanged()
- };
- typeof DeviceOrientationEvent != "undefined" && typeof DeviceOrientationEvent.requestPermission == "function" ? DeviceOrientationEvent.requestPermission().then(function(s) {
- s === "granted" ? o() : Tools.Warn("Permission not granted.")
- }).catch(function(s) {
- Tools.Error(s)
- }) : o()
- }
- }
- ,
- a.prototype.detachControl = function(e) {
- window.removeEventListener("orientationchange", this._orientationChanged),
- window.removeEventListener("deviceorientation", this._deviceOrientation),
- this._alpha = 0
- }
- ,
- a.prototype.checkInputs = function() {
- !this._alpha || (Quaternion.RotationYawPitchRollToRef(Tools.ToRadians(this._alpha), Tools.ToRadians(this._beta), -Tools.ToRadians(this._gamma), this.camera.rotationQuaternion),
- this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion),
- this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform),
- this._camera.rotationQuaternion.z *= -1,
- this._camera.rotationQuaternion.w *= -1)
- }
- ,
- a.prototype.getClassName = function() {
- return "FreeCameraDeviceOrientationInput"
- }
- ,
- a.prototype.getSimpleName = function() {
- return "deviceOrientation"
- }
- ,
- a
- }();
- CameraInputTypes.FreeCameraDeviceOrientationInput = FreeCameraDeviceOrientationInput;
- Node$2.AddNodeConstructor("DeviceOrientationCamera", function(a, e) {
- return function() {
- return new DeviceOrientationCamera(a,Vector3.Zero(),e)
- }
- });
- var DeviceOrientationCamera = function(a) {
- __extends(e, a);
- function e(i, o, s) {
- var c = a.call(this, i, o, s) || this;
- return c._tmpDragQuaternion = new Quaternion,
- c._disablePointerInputWhenUsingDeviceOrientation = !0,
- c._dragFactor = 0,
- c._quaternionCache = new Quaternion,
- c.inputs.addDeviceOrientation(),
- c.inputs._deviceOrientationInput && c.inputs._deviceOrientationInput._onDeviceOrientationChangedObservable.addOnce(function() {
- c._disablePointerInputWhenUsingDeviceOrientation && c.inputs._mouseInput && (c.inputs._mouseInput._allowCameraRotation = !1,
- c.inputs._mouseInput.onPointerMovedObservable.add(function(d) {
- c._dragFactor != 0 && (c._initialQuaternion || (c._initialQuaternion = new Quaternion),
- Quaternion.FromEulerAnglesToRef(0, d.offsetX * c._dragFactor, 0, c._tmpDragQuaternion),
- c._initialQuaternion.multiplyToRef(c._tmpDragQuaternion, c._initialQuaternion))
- }))
- }),
- c
- }
- return Object.defineProperty(e.prototype, "disablePointerInputWhenUsingDeviceOrientation", {
- get: function() {
- return this._disablePointerInputWhenUsingDeviceOrientation
- },
- set: function(i) {
- this._disablePointerInputWhenUsingDeviceOrientation = i
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.enableHorizontalDragging = function(i) {
- i === void 0 && (i = 1 / 300),
- this._dragFactor = i
- }
- ,
- e.prototype.getClassName = function() {
- return "DeviceOrientationCamera"
- }
- ,
- e.prototype._checkInputs = function() {
- a.prototype._checkInputs.call(this),
- this._quaternionCache.copyFrom(this.rotationQuaternion),
- this._initialQuaternion && this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion)
- }
- ,
- e.prototype.resetToCurrentRotation = function(i) {
- var o = this;
- i === void 0 && (i = Axis.Y),
- this.rotationQuaternion && (this._initialQuaternion || (this._initialQuaternion = new Quaternion),
- this._initialQuaternion.copyFrom(this._quaternionCache || this.rotationQuaternion),
- ["x", "y", "z"].forEach(function(s) {
- i[s] ? o._initialQuaternion[s] *= -1 : o._initialQuaternion[s] = 0
- }),
- this._initialQuaternion.normalize(),
- this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion))
- }
- ,
- e
- }(FreeCamera)
- , VRCameraMetrics = function() {
- function a() {
- this.compensateDistortion = !0,
- this.multiviewEnabled = !1
- }
- return Object.defineProperty(a.prototype, "aspectRatio", {
- get: function() {
- return this.hResolution / (2 * this.vResolution)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "aspectRatioFov", {
- get: function() {
- return 2 * Math.atan(this.postProcessScaleFactor * this.vScreenSize / (2 * this.eyeToScreenDistance))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "leftHMatrix", {
- get: function() {
- var e = this.hScreenSize / 4 - this.lensSeparationDistance / 2
- , i = 4 * e / this.hScreenSize;
- return Matrix.Translation(i, 0, 0)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "rightHMatrix", {
- get: function() {
- var e = this.hScreenSize / 4 - this.lensSeparationDistance / 2
- , i = 4 * e / this.hScreenSize;
- return Matrix.Translation(-i, 0, 0)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "leftPreViewMatrix", {
- get: function() {
- return Matrix.Translation(.5 * this.interpupillaryDistance, 0, 0)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "rightPreViewMatrix", {
- get: function() {
- return Matrix.Translation(-.5 * this.interpupillaryDistance, 0, 0)
- },
- enumerable: !1,
- configurable: !0
- }),
- a.GetDefault = function() {
- var e = new a;
- return e.hResolution = 1280,
- e.vResolution = 800,
- e.hScreenSize = .149759993,
- e.vScreenSize = .0935999975,
- e.vScreenCenter = .0467999987,
- e.eyeToScreenDistance = .0410000011,
- e.lensSeparationDistance = .063500002,
- e.interpupillaryDistance = .064000003,
- e.distortionK = [1, .219999999, .239999995, 0],
- e.chromaAbCorrection = [.995999992, -.00400000019, 1.01400006, 0],
- e.postProcessScaleFactor = 1.714605507808412,
- e.lensCenterOffset = .151976421,
- e
- }
- ,
- a
- }()
- , name$2 = "vrDistortionCorrectionPixelShader"
- , shader$2 = `
- varying vec2 vUV;
- uniform sampler2D textureSampler;
- uniform vec2 LensCenter;
- uniform vec2 Scale;
- uniform vec2 ScaleIn;
- uniform vec4 HmdWarpParam;
- vec2 HmdWarp(vec2 in01) {
- vec2 theta=(in01-LensCenter)*ScaleIn;
- float rSq=theta.x*theta.x+theta.y*theta.y;
- vec2 rvector=theta*(HmdWarpParam.x+HmdWarpParam.y*rSq+HmdWarpParam.z*rSq*rSq+HmdWarpParam.w*rSq*rSq*rSq);
- return LensCenter+Scale*rvector;
- }
- void main(void)
- {
- vec2 tc=HmdWarp(vUV);
- if (tc.x <0.0 || tc.x>1.0 || tc.y<0.0 || tc.y>1.0)
- gl_FragColor=vec4(0.0,0.0,0.0,0.0);
- else{
- gl_FragColor=texture2D(textureSampler,tc);
- }
- }`;
- ShaderStore.ShadersStore[name$2] = shader$2;
- var VRDistortionCorrectionPostProcess = function(a) {
- __extends(e, a);
- function e(i, o, s, c) {
- var d = a.call(this, i, "vrDistortionCorrection", ["LensCenter", "Scale", "ScaleIn", "HmdWarpParam"], null, c.postProcessScaleFactor, o, Texture.BILINEAR_SAMPLINGMODE) || this;
- return d._isRightEye = s,
- d._distortionFactors = c.distortionK,
- d._postProcessScaleFactor = c.postProcessScaleFactor,
- d._lensCenterOffset = c.lensCenterOffset,
- d.adaptScaleToCurrentViewport = !0,
- d.onSizeChangedObservable.add(function() {
- d._scaleIn = new Vector2(2,2 / d.aspectRatio),
- d._scaleFactor = new Vector2(.5 * (1 / d._postProcessScaleFactor),.5 * (1 / d._postProcessScaleFactor) * d.aspectRatio),
- d._lensCenter = new Vector2(d._isRightEye ? .5 - d._lensCenterOffset * .5 : .5 + d._lensCenterOffset * .5,.5)
- }),
- d.onApplyObservable.add(function(_) {
- _.setFloat2("LensCenter", d._lensCenter.x, d._lensCenter.y),
- _.setFloat2("Scale", d._scaleFactor.x, d._scaleFactor.y),
- _.setFloat2("ScaleIn", d._scaleIn.x, d._scaleIn.y),
- _.setFloat4("HmdWarpParam", d._distortionFactors[0], d._distortionFactors[1], d._distortionFactors[2], d._distortionFactors[3])
- }),
- d
- }
- return e.prototype.getClassName = function() {
- return "VRDistortionCorrectionPostProcess"
- }
- ,
- e
- }(PostProcess)
- , name$1 = "vrMultiviewToSingleviewPixelShader"
- , shader$1 = `precision mediump sampler2DArray;
- varying vec2 vUV;
- uniform sampler2DArray multiviewSampler;
- uniform int imageIndex;
- void main(void)
- {
- gl_FragColor=texture2D(multiviewSampler,vec3(vUV,imageIndex));
- }`;
- ShaderStore.ShadersStore[name$1] = shader$1;
- var VRMultiviewToSingleviewPostProcess = function(a) {
- __extends(e, a);
- function e(i, o, s) {
- var c = a.call(this, i, "vrMultiviewToSingleview", ["imageIndex"], ["multiviewSampler"], s, o, Texture.BILINEAR_SAMPLINGMODE) || this;
- return c.onSizeChangedObservable.add(function() {}),
- c.onApplyObservable.add(function(d) {
- o._scene.activeCamera && o._scene.activeCamera.isLeftCamera ? d.setInt("imageIndex", 0) : d.setInt("imageIndex", 1),
- d.setTexture("multiviewSampler", o._multiviewTexture)
- }),
- c
- }
- return e.prototype.getClassName = function() {
- return "VRMultiviewToSingleviewPostProcess"
- }
- ,
- e
- }(PostProcess);
- function setVRRigMode(a, e) {
- var i = e.vrCameraMetrics || VRCameraMetrics.GetDefault();
- a._rigCameras[0]._cameraRigParams.vrMetrics = i,
- a._rigCameras[0].viewport = new Viewport(0,0,.5,1),
- a._rigCameras[0]._cameraRigParams.vrWorkMatrix = new Matrix,
- a._rigCameras[0]._cameraRigParams.vrHMatrix = i.leftHMatrix,
- a._rigCameras[0]._cameraRigParams.vrPreViewMatrix = i.leftPreViewMatrix,
- a._rigCameras[0].getProjectionMatrix = a._rigCameras[0]._getVRProjectionMatrix,
- a._rigCameras[1]._cameraRigParams.vrMetrics = i,
- a._rigCameras[1].viewport = new Viewport(.5,0,.5,1),
- a._rigCameras[1]._cameraRigParams.vrWorkMatrix = new Matrix,
- a._rigCameras[1]._cameraRigParams.vrHMatrix = i.rightHMatrix,
- a._rigCameras[1]._cameraRigParams.vrPreViewMatrix = i.rightPreViewMatrix,
- a._rigCameras[1].getProjectionMatrix = a._rigCameras[1]._getVRProjectionMatrix,
- i.multiviewEnabled && (a.getScene().getEngine().getCaps().multiview ? (a._useMultiviewToSingleView = !0,
- a._rigPostProcess = new VRMultiviewToSingleviewPostProcess("VRMultiviewToSingleview",a,i.postProcessScaleFactor)) : (Logger$2.Warn("Multiview is not supported, falling back to standard rendering"),
- i.multiviewEnabled = !1)),
- i.compensateDistortion && (a._rigCameras[0]._rigPostProcess = new VRDistortionCorrectionPostProcess("VR_Distort_Compensation_Left",a._rigCameras[0],!1,i),
- a._rigCameras[1]._rigPostProcess = new VRDistortionCorrectionPostProcess("VR_Distort_Compensation_Right",a._rigCameras[1],!0,i))
- }
- Node$2.AddNodeConstructor("VRDeviceOrientationFreeCamera", function(a, e) {
- return function() {
- return new VRDeviceOrientationFreeCamera(a,Vector3.Zero(),e)
- }
- });
- var VRDeviceOrientationFreeCamera = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d) {
- c === void 0 && (c = !0),
- d === void 0 && (d = VRCameraMetrics.GetDefault());
- var _ = a.call(this, i, o, s) || this;
- return _._setRigMode = setVRRigMode.bind(null, _),
- d.compensateDistortion = c,
- _.setCameraRigMode(Camera$1.RIG_MODE_VR, {
- vrCameraMetrics: d
- }),
- _
- }
- return e.prototype.getClassName = function() {
- return "VRDeviceOrientationFreeCamera"
- }
- ,
- e
- }(DeviceOrientationCamera), Gamepad = function() {
- function a(e, i, o, s, c, d, _) {
- s === void 0 && (s = 0),
- c === void 0 && (c = 1),
- d === void 0 && (d = 2),
- _ === void 0 && (_ = 3),
- this.id = e,
- this.index = i,
- this.browserGamepad = o,
- this._leftStick = {
- x: 0,
- y: 0
- },
- this._rightStick = {
- x: 0,
- y: 0
- },
- this._isConnected = !0,
- this._invertLeftStickY = !1,
- this.type = a.GAMEPAD,
- this._leftStickAxisX = s,
- this._leftStickAxisY = c,
- this._rightStickAxisX = d,
- this._rightStickAxisY = _,
- this.browserGamepad.axes.length >= 2 && (this._leftStick = {
- x: this.browserGamepad.axes[this._leftStickAxisX],
- y: this.browserGamepad.axes[this._leftStickAxisY]
- }),
- this.browserGamepad.axes.length >= 4 && (this._rightStick = {
- x: this.browserGamepad.axes[this._rightStickAxisX],
- y: this.browserGamepad.axes[this._rightStickAxisY]
- })
- }
- return Object.defineProperty(a.prototype, "isConnected", {
- get: function() {
- return this._isConnected
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.onleftstickchanged = function(e) {
- this._onleftstickchanged = e
- }
- ,
- a.prototype.onrightstickchanged = function(e) {
- this._onrightstickchanged = e
- }
- ,
- Object.defineProperty(a.prototype, "leftStick", {
- get: function() {
- return this._leftStick
- },
- set: function(e) {
- this._onleftstickchanged && (this._leftStick.x !== e.x || this._leftStick.y !== e.y) && this._onleftstickchanged(e),
- this._leftStick = e
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "rightStick", {
- get: function() {
- return this._rightStick
- },
- set: function(e) {
- this._onrightstickchanged && (this._rightStick.x !== e.x || this._rightStick.y !== e.y) && this._onrightstickchanged(e),
- this._rightStick = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.update = function() {
- this._leftStick && (this.leftStick = {
- x: this.browserGamepad.axes[this._leftStickAxisX],
- y: this.browserGamepad.axes[this._leftStickAxisY]
- },
- this._invertLeftStickY && (this.leftStick.y *= -1)),
- this._rightStick && (this.rightStick = {
- x: this.browserGamepad.axes[this._rightStickAxisX],
- y: this.browserGamepad.axes[this._rightStickAxisY]
- })
- }
- ,
- a.prototype.dispose = function() {}
- ,
- a.GAMEPAD = 0,
- a.GENERIC = 1,
- a.XBOX = 2,
- a.POSE_ENABLED = 3,
- a.DUALSHOCK = 4,
- a
- }(), GenericPad = function(a) {
- __extends(e, a);
- function e(i, o, s) {
- var c = a.call(this, i, o, s) || this;
- return c.onButtonDownObservable = new Observable,
- c.onButtonUpObservable = new Observable,
- c.type = Gamepad.GENERIC,
- c._buttons = new Array(s.buttons.length),
- c
- }
- return e.prototype.onbuttondown = function(i) {
- this._onbuttondown = i
- }
- ,
- e.prototype.onbuttonup = function(i) {
- this._onbuttonup = i
- }
- ,
- e.prototype._setButtonValue = function(i, o, s) {
- return i !== o && (i === 1 && (this._onbuttondown && this._onbuttondown(s),
- this.onButtonDownObservable.notifyObservers(s)),
- i === 0 && (this._onbuttonup && this._onbuttonup(s),
- this.onButtonUpObservable.notifyObservers(s))),
- i
- }
- ,
- e.prototype.update = function() {
- a.prototype.update.call(this);
- for (var i = 0; i < this._buttons.length; i++)
- this._buttons[i] = this._setButtonValue(this.browserGamepad.buttons[i].value, this._buttons[i], i)
- }
- ,
- e.prototype.dispose = function() {
- a.prototype.dispose.call(this),
- this.onButtonDownObservable.clear(),
- this.onButtonUpObservable.clear()
- }
- ,
- e
- }(Gamepad), PoseEnabledControllerType;
- (function(a) {
- a[a.VIVE = 0] = "VIVE",
- a[a.OCULUS = 1] = "OCULUS",
- a[a.WINDOWS = 2] = "WINDOWS",
- a[a.GEAR_VR = 3] = "GEAR_VR",
- a[a.DAYDREAM = 4] = "DAYDREAM",
- a[a.GENERIC = 5] = "GENERIC"
- }
- )(PoseEnabledControllerType || (PoseEnabledControllerType = {}));
- var PoseEnabledControllerHelper = function() {
- function a() {}
- return a.InitiateController = function(e) {
- for (var i = 0, o = this._ControllerFactories; i < o.length; i++) {
- var s = o[i];
- if (s.canCreate(e))
- return s.create(e)
- }
- if (this._DefaultControllerFactory)
- return this._DefaultControllerFactory(e);
- throw "The type of gamepad you are trying to load needs to be imported first or is not supported."
- }
- ,
- a._ControllerFactories = [],
- a._DefaultControllerFactory = null,
- a
- }()
- , PoseEnabledController = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i.id, i.index, i) || this;
- return o.isXR = !1,
- o._deviceRoomPosition = Vector3.Zero(),
- o._deviceRoomRotationQuaternion = new Quaternion,
- o.devicePosition = Vector3.Zero(),
- o.deviceRotationQuaternion = new Quaternion,
- o.deviceScaleFactor = 1,
- o._trackPosition = !0,
- o._maxRotationDistFromHeadset = Math.PI / 5,
- o._draggedRoomRotation = 0,
- o._leftHandSystemQuaternion = new Quaternion,
- o._deviceToWorld = Matrix.Identity(),
- o._pointingPoseNode = null,
- o._workingMatrix = Matrix.Identity(),
- o._meshAttachedObservable = new Observable,
- o.type = Gamepad.POSE_ENABLED,
- o.controllerType = PoseEnabledControllerType.GENERIC,
- o.position = Vector3.Zero(),
- o.rotationQuaternion = new Quaternion,
- o._calculatedPosition = Vector3.Zero(),
- o._calculatedRotation = new Quaternion,
- Quaternion.RotationYawPitchRollToRef(Math.PI, 0, 0, o._leftHandSystemQuaternion),
- o
- }
- return e.prototype._disableTrackPosition = function(i) {
- this._trackPosition && (this._calculatedPosition.copyFrom(i),
- this._trackPosition = !1)
- }
- ,
- e.prototype.update = function() {
- a.prototype.update.call(this),
- this._updatePoseAndMesh()
- }
- ,
- e.prototype._updatePoseAndMesh = function() {
- if (!this.isXR) {
- var i = this.browserGamepad.pose;
- if (this.updateFromDevice(i),
- !this._trackPosition && EngineStore.LastCreatedScene && EngineStore.LastCreatedScene.activeCamera && EngineStore.LastCreatedScene.activeCamera.devicePosition) {
- var o = EngineStore.LastCreatedScene.activeCamera;
- if (o._computeDevicePosition(),
- this._deviceToWorld.setTranslation(o.devicePosition),
- o.deviceRotationQuaternion) {
- var o = o;
- o._deviceRoomRotationQuaternion.toEulerAnglesToRef(TmpVectors.Vector3[0]);
- var s = Math.atan2(Math.sin(TmpVectors.Vector3[0].y - this._draggedRoomRotation), Math.cos(TmpVectors.Vector3[0].y - this._draggedRoomRotation));
- if (Math.abs(s) > this._maxRotationDistFromHeadset) {
- var c = s - (s < 0 ? -this._maxRotationDistFromHeadset : this._maxRotationDistFromHeadset);
- this._draggedRoomRotation += c;
- var d = Math.sin(-c)
- , _ = Math.cos(-c);
- this._calculatedPosition.x = this._calculatedPosition.x * _ - this._calculatedPosition.z * d,
- this._calculatedPosition.z = this._calculatedPosition.x * d + this._calculatedPosition.z * _
- }
- }
- }
- Vector3.TransformCoordinatesToRef(this._calculatedPosition, this._deviceToWorld, this.devicePosition),
- this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix),
- Quaternion.FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion),
- this.deviceRotationQuaternion.multiplyInPlace(this._calculatedRotation),
- this._mesh && (this._mesh.position.copyFrom(this.devicePosition),
- this._mesh.rotationQuaternion && this._mesh.rotationQuaternion.copyFrom(this.deviceRotationQuaternion))
- }
- }
- ,
- e.prototype.updateFromDevice = function(i) {
- if (!this.isXR && i) {
- this.rawPose = i,
- i.position && (this._deviceRoomPosition.copyFromFloats(i.position[0], i.position[1], -i.position[2]),
- this._mesh && this._mesh.getScene().useRightHandedSystem && (this._deviceRoomPosition.z *= -1),
- this._trackPosition && this._deviceRoomPosition.scaleToRef(this.deviceScaleFactor, this._calculatedPosition),
- this._calculatedPosition.addInPlace(this.position));
- var o = this.rawPose;
- i.orientation && o.orientation && o.orientation.length === 4 && (this._deviceRoomRotationQuaternion.copyFromFloats(o.orientation[0], o.orientation[1], -o.orientation[2], -o.orientation[3]),
- this._mesh && (this._mesh.getScene().useRightHandedSystem ? (this._deviceRoomRotationQuaternion.z *= -1,
- this._deviceRoomRotationQuaternion.w *= -1) : this._deviceRoomRotationQuaternion.multiplyToRef(this._leftHandSystemQuaternion, this._deviceRoomRotationQuaternion)),
- this._deviceRoomRotationQuaternion.multiplyToRef(this.rotationQuaternion, this._calculatedRotation))
- }
- }
- ,
- e.prototype.attachToMesh = function(i) {
- if (this._mesh && (this._mesh.parent = null),
- this._mesh = i,
- this._poseControlledCamera && (this._mesh.parent = this._poseControlledCamera),
- this._mesh.rotationQuaternion || (this._mesh.rotationQuaternion = new Quaternion),
- !this.isXR && (this._updatePoseAndMesh(),
- this._pointingPoseNode)) {
- for (var o = [], s = this._pointingPoseNode; s.parent; )
- o.push(s.parent),
- s = s.parent;
- o.reverse().forEach(function(c) {
- c.computeWorldMatrix(!0)
- })
- }
- this._meshAttachedObservable.notifyObservers(i)
- }
- ,
- e.prototype.attachToPoseControlledCamera = function(i) {
- this._poseControlledCamera = i,
- this._mesh && (this._mesh.parent = this._poseControlledCamera)
- }
- ,
- e.prototype.dispose = function() {
- this._mesh && this._mesh.dispose(),
- this._mesh = null,
- a.prototype.dispose.call(this)
- }
- ,
- Object.defineProperty(e.prototype, "mesh", {
- get: function() {
- return this._mesh
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getForwardRay = function(i) {
- if (i === void 0 && (i = 100),
- !this.mesh)
- return new Ray(Vector3.Zero(),new Vector3(0,0,1),i);
- var o = this._pointingPoseNode ? this._pointingPoseNode.getWorldMatrix() : this.mesh.getWorldMatrix()
- , s = o.getTranslation()
- , c = new Vector3(0,0,-1)
- , d = Vector3.TransformNormal(c, o)
- , _ = Vector3.Normalize(d);
- return new Ray(s,_,i)
- }
- ,
- e.POINTING_POSE = "POINTING_POSE",
- e
- }(Gamepad);
- function setWebVRRigMode(a, e) {
- if (e.vrDisplay) {
- var i = e.vrDisplay.getEyeParameters("left")
- , o = e.vrDisplay.getEyeParameters("right");
- a._rigCameras[0].viewport = new Viewport(0,0,.5,1),
- a._rigCameras[0].setCameraRigParameter("left", !0),
- a._rigCameras[0].setCameraRigParameter("specs", e.specs),
- a._rigCameras[0].setCameraRigParameter("eyeParameters", i),
- a._rigCameras[0].setCameraRigParameter("frameData", e.frameData),
- a._rigCameras[0].setCameraRigParameter("parentCamera", e.parentCamera),
- a._rigCameras[0]._cameraRigParams.vrWorkMatrix = new Matrix,
- a._rigCameras[0].getProjectionMatrix = a._getWebVRProjectionMatrix,
- a._rigCameras[0].parent = a,
- a._rigCameras[0]._getViewMatrix = a._getWebVRViewMatrix,
- a._rigCameras[1].viewport = new Viewport(.5,0,.5,1),
- a._rigCameras[1].setCameraRigParameter("eyeParameters", o),
- a._rigCameras[1].setCameraRigParameter("specs", e.specs),
- a._rigCameras[1].setCameraRigParameter("frameData", e.frameData),
- a._rigCameras[1].setCameraRigParameter("parentCamera", e.parentCamera),
- a._rigCameras[1]._cameraRigParams.vrWorkMatrix = new Matrix,
- a._rigCameras[1].getProjectionMatrix = a._getWebVRProjectionMatrix,
- a._rigCameras[1].parent = a,
- a._rigCameras[1]._getViewMatrix = a._getWebVRViewMatrix
- }
- }
- Node$2.AddNodeConstructor("WebVRFreeCamera", function(a, e) {
- return function() {
- return new WebVRFreeCamera(a,Vector3.Zero(),e)
- }
- });
- Node$2.AddNodeConstructor("WebVRGamepadCamera", function(a, e) {
- return function() {
- return new WebVRFreeCamera(a,Vector3.Zero(),e)
- }
- });
- var WebVRFreeCamera = function(a) {
- __extends(e, a);
- function e(i, o, s, c) {
- c === void 0 && (c = {});
- var d = a.call(this, i, o, s) || this;
- d.webVROptions = c,
- d._vrDevice = null,
- d.rawPose = null,
- d._specsVersion = "1.1",
- d._attached = !1,
- d._descendants = [],
- d._deviceRoomPosition = Vector3.Zero(),
- d._deviceRoomRotationQuaternion = Quaternion.Identity(),
- d._standingMatrix = null,
- d.devicePosition = Vector3.Zero(),
- d.deviceRotationQuaternion = Quaternion.Identity(),
- d.deviceScaleFactor = 1,
- d._deviceToWorld = Matrix.Identity(),
- d._worldToDevice = Matrix.Identity(),
- d.controllers = [],
- d.onControllersAttachedObservable = new Observable,
- d.onControllerMeshLoadedObservable = new Observable,
- d.onPoseUpdatedFromDeviceObservable = new Observable,
- d._poseSet = !1,
- d.rigParenting = !0,
- d._defaultHeight = void 0,
- d._setRigMode = setWebVRRigMode.bind(null, d),
- d._detachIfAttached = function() {
- var b = d.getEngine().getVRDevice();
- b && !b.isPresenting && d.detachControl()
- }
- ,
- d._workingVector = Vector3.Zero(),
- d._oneVector = Vector3.One(),
- d._workingMatrix = Matrix.Identity(),
- d._tmpMatrix = new Matrix,
- d._cache.position = Vector3.Zero(),
- c.defaultHeight && (d._defaultHeight = c.defaultHeight,
- d.position.y = d._defaultHeight),
- d.minZ = .1,
- arguments.length === 5 && (d.webVROptions = arguments[4]),
- d.webVROptions.trackPosition == null && (d.webVROptions.trackPosition = !0),
- d.webVROptions.controllerMeshes == null && (d.webVROptions.controllerMeshes = !0),
- d.webVROptions.defaultLightingOnControllers == null && (d.webVROptions.defaultLightingOnControllers = !0),
- d.rotationQuaternion = new Quaternion,
- d.webVROptions && d.webVROptions.positionScale && (d.deviceScaleFactor = d.webVROptions.positionScale);
- var _ = d.getEngine();
- return d._onVREnabled = function(b) {
- b && d.initControllers()
- }
- ,
- _.onVRRequestPresentComplete.add(d._onVREnabled),
- _.initWebVR().add(function(b) {
- !b.vrDisplay || d._vrDevice === b.vrDisplay || (d._vrDevice = b.vrDisplay,
- d.setCameraRigMode(Camera$1.RIG_MODE_WEBVR, {
- parentCamera: d,
- vrDisplay: d._vrDevice,
- frameData: d._frameData,
- specs: d._specsVersion
- }),
- d._attached && d.getEngine().enableVR(d.webVROptions))
- }),
- typeof VRFrameData != "undefined" && (d._frameData = new VRFrameData),
- c.useMultiview && (d.getScene().getEngine().getCaps().multiview ? (d._useMultiviewToSingleView = !0,
- d._rigPostProcess = new VRMultiviewToSingleviewPostProcess("VRMultiviewToSingleview",d,1)) : (Logger$2.Warn("Multiview is not supported, falling back to standard rendering"),
- d._useMultiviewToSingleView = !1)),
- s.onBeforeCameraRenderObservable.add(function(b) {
- b.parent === d && d.rigParenting && (d._descendants = d.getDescendants(!0, function(k) {
- var j = d.controllers.some(function(_e) {
- return _e._mesh === k
- })
- , $ = d._rigCameras.indexOf(k) !== -1;
- return !j && !$
- }),
- d._descendants.forEach(function(k) {
- k.parent = b
- }))
- }),
- s.onAfterCameraRenderObservable.add(function(b) {
- b.parent === d && d.rigParenting && d._descendants.forEach(function(k) {
- k.parent = d
- })
- }),
- d
- }
- return e.prototype.deviceDistanceToRoomGround = function() {
- return this._standingMatrix ? (this._standingMatrix.getTranslationToRef(this._workingVector),
- this._deviceRoomPosition.y + this._workingVector.y) : this._defaultHeight || 0
- }
- ,
- e.prototype.useStandingMatrix = function(i) {
- var o = this;
- i === void 0 && (i = function(s) {}
- ),
- this.getEngine().initWebVRAsync().then(function(s) {
- !s.vrDisplay || !s.vrDisplay.stageParameters || !s.vrDisplay.stageParameters.sittingToStandingTransform || !o.webVROptions.trackPosition ? i(!1) : (o._standingMatrix = new Matrix,
- Matrix.FromFloat32ArrayToRefScaled(s.vrDisplay.stageParameters.sittingToStandingTransform, 0, 1, o._standingMatrix),
- o.getScene().useRightHandedSystem || o._standingMatrix && o._standingMatrix.toggleModelMatrixHandInPlace(),
- i(!0))
- })
- }
- ,
- e.prototype.useStandingMatrixAsync = function() {
- var i = this;
- return new Promise(function(o) {
- i.useStandingMatrix(function(s) {
- o(s)
- })
- }
- )
- }
- ,
- e.prototype.dispose = function() {
- this._detachIfAttached(),
- this.getEngine().onVRRequestPresentComplete.removeCallback(this._onVREnabled),
- this._updateCacheWhenTrackingDisabledObserver && this._scene.onBeforeRenderObservable.remove(this._updateCacheWhenTrackingDisabledObserver),
- a.prototype.dispose.call(this)
- }
- ,
- e.prototype.getControllerByName = function(i) {
- for (var o = 0, s = this.controllers; o < s.length; o++) {
- var c = s[o];
- if (c.hand === i)
- return c
- }
- return null
- }
- ,
- Object.defineProperty(e.prototype, "leftController", {
- get: function() {
- return this._leftController || (this._leftController = this.getControllerByName("left")),
- this._leftController
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "rightController", {
- get: function() {
- return this._rightController || (this._rightController = this.getControllerByName("right")),
- this._rightController
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getForwardRay = function(i) {
- return i === void 0 && (i = 100),
- this.leftCamera ? a.prototype.getForwardRay.call(this, i, this.leftCamera.getWorldMatrix(), this.leftCamera.globalPosition) : a.prototype.getForwardRay.call(this, i)
- }
- ,
- e.prototype._checkInputs = function() {
- this._vrDevice && this._vrDevice.isPresenting && (this._vrDevice.getFrameData(this._frameData),
- this.updateFromDevice(this._frameData.pose)),
- a.prototype._checkInputs.call(this)
- }
- ,
- e.prototype.updateFromDevice = function(i) {
- i && i.orientation && i.orientation.length === 4 && (this.rawPose = i,
- this._deviceRoomRotationQuaternion.copyFromFloats(i.orientation[0], i.orientation[1], -i.orientation[2], -i.orientation[3]),
- this.getScene().useRightHandedSystem && (this._deviceRoomRotationQuaternion.z *= -1,
- this._deviceRoomRotationQuaternion.w *= -1),
- this.webVROptions.trackPosition && this.rawPose.position && (this._deviceRoomPosition.copyFromFloats(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2]),
- this.getScene().useRightHandedSystem && (this._deviceRoomPosition.z *= -1)),
- this._poseSet = !0)
- }
- ,
- e.prototype.attachControl = function(i) {
- i = Tools.BackCompatCameraNoPreventDefault(arguments),
- a.prototype.attachControl.call(this, i),
- this._attached = !0,
- i = Camera$1.ForceAttachControlToAlwaysPreventDefault ? !1 : i,
- this._vrDevice && this.getEngine().enableVR(this.webVROptions);
- var o = this._scene.getEngine().getHostWindow();
- o && o.addEventListener("vrdisplaypresentchange", this._detachIfAttached)
- }
- ,
- e.prototype.detachControl = function(i) {
- this.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver),
- this.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver),
- a.prototype.detachControl.call(this),
- this._attached = !1,
- this.getEngine().disableVR(),
- window.removeEventListener("vrdisplaypresentchange", this._detachIfAttached)
- }
- ,
- e.prototype.getClassName = function() {
- return "WebVRFreeCamera"
- }
- ,
- e.prototype.resetToCurrentRotation = function() {
- this._vrDevice.resetPose()
- }
- ,
- e.prototype._updateRigCameras = function() {
- var i = this._rigCameras[0]
- , o = this._rigCameras[1];
- i.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion),
- o.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion),
- i.position.copyFrom(this._deviceRoomPosition),
- o.position.copyFrom(this._deviceRoomPosition)
- }
- ,
- e.prototype._correctPositionIfNotTrackPosition = function(i, o) {
- o === void 0 && (o = !1),
- this.rawPose && this.rawPose.position && !this.webVROptions.trackPosition && (Matrix.TranslationToRef(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2], this._tmpMatrix),
- o || this._tmpMatrix.invert(),
- this._tmpMatrix.multiplyToRef(i, i))
- }
- ,
- e.prototype._updateCache = function(i) {
- var o = this;
- (!this.rotationQuaternion.equals(this._cache.rotationQuaternion) || !this.position.equals(this._cache.position)) && (this.updateCacheCalled || (this.updateCacheCalled = !0,
- this.update()),
- this.rotationQuaternion.toRotationMatrix(this._workingMatrix),
- Vector3.TransformCoordinatesToRef(this._deviceRoomPosition, this._workingMatrix, this._workingVector),
- this.devicePosition.subtractToRef(this._workingVector, this._workingVector),
- Matrix.ComposeToRef(this._oneVector, this.rotationQuaternion, this._workingVector, this._deviceToWorld),
- this._deviceToWorld.getTranslationToRef(this._workingVector),
- this._workingVector.addInPlace(this.position),
- this._workingVector.subtractInPlace(this._cache.position),
- this._deviceToWorld.setTranslation(this._workingVector),
- this._deviceToWorld.invertToRef(this._worldToDevice),
- this.controllers.forEach(function(s) {
- s._deviceToWorld.copyFrom(o._deviceToWorld),
- o._correctPositionIfNotTrackPosition(s._deviceToWorld),
- s.update()
- })),
- i || a.prototype._updateCache.call(this),
- this.updateCacheCalled = !1
- }
- ,
- e.prototype._computeDevicePosition = function() {
- Vector3.TransformCoordinatesToRef(this._deviceRoomPosition, this._deviceToWorld, this.devicePosition)
- }
- ,
- e.prototype.update = function() {
- this._computeDevicePosition(),
- Matrix.FromQuaternionToRef(this._deviceRoomRotationQuaternion, this._workingMatrix),
- this._workingMatrix.multiplyToRef(this._deviceToWorld, this._workingMatrix),
- Quaternion.FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion),
- this._poseSet && this.onPoseUpdatedFromDeviceObservable.notifyObservers(null),
- a.prototype.update.call(this)
- }
- ,
- e.prototype._getViewMatrix = function() {
- return Matrix.Identity()
- }
- ,
- e.prototype._getWebVRViewMatrix = function() {
- var i = this._cameraRigParams.parentCamera;
- i._updateCache();
- var o = this._cameraRigParams.left ? this._cameraRigParams.frameData.leftViewMatrix : this._cameraRigParams.frameData.rightViewMatrix;
- return Matrix.FromArrayToRef(o, 0, this._webvrViewMatrix),
- this.getScene().useRightHandedSystem || this._webvrViewMatrix.toggleModelMatrixHandInPlace(),
- this._webvrViewMatrix.getRotationMatrixToRef(this._cameraRotationMatrix),
- Vector3.TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint),
- this.position.addToRef(this._transformedReferencePoint, this._currentTarget),
- i.deviceScaleFactor !== 1 && (this._webvrViewMatrix.invert(),
- i.deviceScaleFactor && (this._webvrViewMatrix.multiplyAtIndex(12, i.deviceScaleFactor),
- this._webvrViewMatrix.multiplyAtIndex(13, i.deviceScaleFactor),
- this._webvrViewMatrix.multiplyAtIndex(14, i.deviceScaleFactor)),
- this._webvrViewMatrix.invert()),
- i._correctPositionIfNotTrackPosition(this._webvrViewMatrix, !0),
- i._worldToDevice.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix),
- this._workingMatrix = this._workingMatrix || Matrix.Identity(),
- this._webvrViewMatrix.invertToRef(this._workingMatrix),
- this._workingMatrix.multiplyToRef(i.getWorldMatrix(), this._workingMatrix),
- this._workingMatrix.getTranslationToRef(this._globalPosition),
- this._markSyncedWithParent(),
- this._webvrViewMatrix
- }
- ,
- e.prototype._getWebVRProjectionMatrix = function() {
- var i = this.parent;
- i._vrDevice.depthNear = i.minZ,
- i._vrDevice.depthFar = i.maxZ;
- var o = this._cameraRigParams.left ? this._cameraRigParams.frameData.leftProjectionMatrix : this._cameraRigParams.frameData.rightProjectionMatrix;
- return Matrix.FromArrayToRef(o, 0, this._projectionMatrix),
- this.getScene().useRightHandedSystem || this._projectionMatrix.toggleProjectionMatrixHandInPlace(),
- this._projectionMatrix
- }
- ,
- e.prototype.initControllers = function() {
- var i = this;
- this.controllers = [];
- var o = this.getScene().gamepadManager;
- this._onGamepadDisconnectedObserver = o.onGamepadDisconnectedObservable.add(function(s) {
- if (s.type === Gamepad.POSE_ENABLED) {
- var c = s;
- c.defaultModel && c.defaultModel.setEnabled(!1),
- c.hand === "right" && (i._rightController = null),
- c.hand === "left" && (i._leftController = null);
- var d = i.controllers.indexOf(c);
- d !== -1 && i.controllers.splice(d, 1)
- }
- }),
- this._onGamepadConnectedObserver = o.onGamepadConnectedObservable.add(function(s) {
- if (s.type === Gamepad.POSE_ENABLED) {
- var c = s;
- if (i.webVROptions.trackPosition || (c._disableTrackPosition(new Vector3(c.hand == "left" ? -.15 : .15,-.5,.25)),
- i._updateCacheWhenTrackingDisabledObserver || (i._updateCacheWhenTrackingDisabledObserver = i._scene.onBeforeRenderObservable.add(function() {
- i._updateCache()
- }))),
- c.deviceScaleFactor = i.deviceScaleFactor,
- c._deviceToWorld.copyFrom(i._deviceToWorld),
- i._correctPositionIfNotTrackPosition(c._deviceToWorld),
- i.webVROptions.controllerMeshes && (c.defaultModel ? c.defaultModel.setEnabled(!0) : c.initControllerMesh(i.getScene(), function(b) {
- if (b.scaling.scaleInPlace(i.deviceScaleFactor),
- i.onControllerMeshLoadedObservable.notifyObservers(c),
- i.webVROptions.defaultLightingOnControllers) {
- i._lightOnControllers || (i._lightOnControllers = new HemisphericLight("vrControllersLight",new Vector3(0,1,0),i.getScene()));
- var k = function(j, $) {
- var _e = j.getChildren();
- _e && _e.length !== 0 && _e.forEach(function(et) {
- $.includedOnlyMeshes.push(et),
- k(et, $)
- })
- };
- i._lightOnControllers.includedOnlyMeshes.push(b),
- k(b, i._lightOnControllers)
- }
- })),
- c.attachToPoseControlledCamera(i),
- i.controllers.indexOf(c) === -1) {
- i.controllers.push(c);
- for (var d = !1, _ = 0; _ < i.controllers.length; _++)
- i.controllers[_].controllerType === PoseEnabledControllerType.VIVE && (d ? i.controllers[_].hand = "right" : (d = !0,
- i.controllers[_].hand = "left"));
- i.controllers.length >= 2 && i.onControllersAttachedObservable.notifyObservers(i.controllers)
- }
- }
- })
- }
- ,
- e
- }(FreeCamera), WebVRController = function(a) {
- __extends(e, a);
- function e(i) {
- var o = a.call(this, i) || this;
- return o.onTriggerStateChangedObservable = new Observable,
- o.onMainButtonStateChangedObservable = new Observable,
- o.onSecondaryButtonStateChangedObservable = new Observable,
- o.onPadStateChangedObservable = new Observable,
- o.onPadValuesChangedObservable = new Observable,
- o.pad = {
- x: 0,
- y: 0
- },
- o._changes = {
- pressChanged: !1,
- touchChanged: !1,
- valueChanged: !1,
- changed: !1
- },
- o._buttons = new Array(i.buttons.length),
- o.hand = i.hand,
- o
- }
- return e.prototype.onButtonStateChange = function(i) {
- this._onButtonStateChange = i
- }
- ,
- Object.defineProperty(e.prototype, "defaultModel", {
- get: function() {
- return this._defaultModel
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.update = function() {
- a.prototype.update.call(this);
- for (var i = 0; i < this._buttons.length; i++)
- this._setButtonValue(this.browserGamepad.buttons[i], this._buttons[i], i);
- (this.leftStick.x !== this.pad.x || this.leftStick.y !== this.pad.y) && (this.pad.x = this.leftStick.x,
- this.pad.y = this.leftStick.y,
- this.onPadValuesChangedObservable.notifyObservers(this.pad))
- }
- ,
- e.prototype._setButtonValue = function(i, o, s) {
- if (i || (i = {
- pressed: !1,
- touched: !1,
- value: 0
- }),
- !o) {
- this._buttons[s] = {
- pressed: i.pressed,
- touched: i.touched,
- value: i.value
- };
- return
- }
- this._checkChanges(i, o),
- this._changes.changed && (this._onButtonStateChange && this._onButtonStateChange(this.index, s, i),
- this._handleButtonChange(s, i, this._changes)),
- this._buttons[s].pressed = i.pressed,
- this._buttons[s].touched = i.touched,
- this._buttons[s].value = i.value < 1e-8 ? 0 : i.value
- }
- ,
- e.prototype._checkChanges = function(i, o) {
- return this._changes.pressChanged = i.pressed !== o.pressed,
- this._changes.touchChanged = i.touched !== o.touched,
- this._changes.valueChanged = i.value !== o.value,
- this._changes.changed = this._changes.pressChanged || this._changes.touchChanged || this._changes.valueChanged,
- this._changes
- }
- ,
- e.prototype.dispose = function() {
- a.prototype.dispose.call(this),
- this._defaultModel = null,
- this.onTriggerStateChangedObservable.clear(),
- this.onMainButtonStateChangedObservable.clear(),
- this.onSecondaryButtonStateChangedObservable.clear(),
- this.onPadStateChangedObservable.clear(),
- this.onPadValuesChangedObservable.clear()
- }
- ,
- e
- }(PoseEnabledController), Xbox360Button;
- (function(a) {
- a[a.A = 0] = "A",
- a[a.B = 1] = "B",
- a[a.X = 2] = "X",
- a[a.Y = 3] = "Y",
- a[a.LB = 4] = "LB",
- a[a.RB = 5] = "RB",
- a[a.Back = 8] = "Back",
- a[a.Start = 9] = "Start",
- a[a.LeftStick = 10] = "LeftStick",
- a[a.RightStick = 11] = "RightStick"
- }
- )(Xbox360Button || (Xbox360Button = {}));
- var Xbox360Dpad;
- (function(a) {
- a[a.Up = 12] = "Up",
- a[a.Down = 13] = "Down",
- a[a.Left = 14] = "Left",
- a[a.Right = 15] = "Right"
- }
- )(Xbox360Dpad || (Xbox360Dpad = {}));
- var Xbox360Pad = function(a) {
- __extends(e, a);
- function e(i, o, s, c) {
- c === void 0 && (c = !1);
- var d = a.call(this, i, o, s, 0, 1, 2, 3) || this;
- return d._leftTrigger = 0,
- d._rightTrigger = 0,
- d.onButtonDownObservable = new Observable,
- d.onButtonUpObservable = new Observable,
- d.onPadDownObservable = new Observable,
- d.onPadUpObservable = new Observable,
- d._buttonA = 0,
- d._buttonB = 0,
- d._buttonX = 0,
- d._buttonY = 0,
- d._buttonBack = 0,
- d._buttonStart = 0,
- d._buttonLB = 0,
- d._buttonRB = 0,
- d._buttonLeftStick = 0,
- d._buttonRightStick = 0,
- d._dPadUp = 0,
- d._dPadDown = 0,
- d._dPadLeft = 0,
- d._dPadRight = 0,
- d._isXboxOnePad = !1,
- d.type = Gamepad.XBOX,
- d._isXboxOnePad = c,
- d
- }
- return e.prototype.onlefttriggerchanged = function(i) {
- this._onlefttriggerchanged = i
- }
- ,
- e.prototype.onrighttriggerchanged = function(i) {
- this._onrighttriggerchanged = i
- }
- ,
- Object.defineProperty(e.prototype, "leftTrigger", {
- get: function() {
- return this._leftTrigger
- },
- set: function(i) {
- this._onlefttriggerchanged && this._leftTrigger !== i && this._onlefttriggerchanged(i),
- this._leftTrigger = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "rightTrigger", {
- get: function() {
- return this._rightTrigger
- },
- set: function(i) {
- this._onrighttriggerchanged && this._rightTrigger !== i && this._onrighttriggerchanged(i),
- this._rightTrigger = i
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.onbuttondown = function(i) {
- this._onbuttondown = i
- }
- ,
- e.prototype.onbuttonup = function(i) {
- this._onbuttonup = i
- }
- ,
- e.prototype.ondpaddown = function(i) {
- this._ondpaddown = i
- }
- ,
- e.prototype.ondpadup = function(i) {
- this._ondpadup = i
- }
- ,
- e.prototype._setButtonValue = function(i, o, s) {
- return i !== o && (i === 1 && (this._onbuttondown && this._onbuttondown(s),
- this.onButtonDownObservable.notifyObservers(s)),
- i === 0 && (this._onbuttonup && this._onbuttonup(s),
- this.onButtonUpObservable.notifyObservers(s))),
- i
- }
- ,
- e.prototype._setDPadValue = function(i, o, s) {
- return i !== o && (i === 1 && (this._ondpaddown && this._ondpaddown(s),
- this.onPadDownObservable.notifyObservers(s)),
- i === 0 && (this._ondpadup && this._ondpadup(s),
- this.onPadUpObservable.notifyObservers(s))),
- i
- }
- ,
- Object.defineProperty(e.prototype, "buttonA", {
- get: function() {
- return this._buttonA
- },
- set: function(i) {
- this._buttonA = this._setButtonValue(i, this._buttonA, Xbox360Button.A)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "buttonB", {
- get: function() {
- return this._buttonB
- },
- set: function(i) {
- this._buttonB = this._setButtonValue(i, this._buttonB, Xbox360Button.B)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "buttonX", {
- get: function() {
- return this._buttonX
- },
- set: function(i) {
- this._buttonX = this._setButtonValue(i, this._buttonX, Xbox360Button.X)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "buttonY", {
- get: function() {
- return this._buttonY
- },
- set: function(i) {
- this._buttonY = this._setButtonValue(i, this._buttonY, Xbox360Button.Y)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "buttonStart", {
- get: function() {
- return this._buttonStart
- },
- set: function(i) {
- this._buttonStart = this._setButtonValue(i, this._buttonStart, Xbox360Button.Start)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "buttonBack", {
- get: function() {
- return this._buttonBack
- },
- set: function(i) {
- this._buttonBack = this._setButtonValue(i, this._buttonBack, Xbox360Button.Back)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "buttonLB", {
- get: function() {
- return this._buttonLB
- },
- set: function(i) {
- this._buttonLB = this._setButtonValue(i, this._buttonLB, Xbox360Button.LB)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "buttonRB", {
- get: function() {
- return this._buttonRB
- },
- set: function(i) {
- this._buttonRB = this._setButtonValue(i, this._buttonRB, Xbox360Button.RB)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "buttonLeftStick", {
- get: function() {
- return this._buttonLeftStick
- },
- set: function(i) {
- this._buttonLeftStick = this._setButtonValue(i, this._buttonLeftStick, Xbox360Button.LeftStick)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "buttonRightStick", {
- get: function() {
- return this._buttonRightStick
- },
- set: function(i) {
- this._buttonRightStick = this._setButtonValue(i, this._buttonRightStick, Xbox360Button.RightStick)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "dPadUp", {
- get: function() {
- return this._dPadUp
- },
- set: function(i) {
- this._dPadUp = this._setDPadValue(i, this._dPadUp, Xbox360Dpad.Up)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "dPadDown", {
- get: function() {
- return this._dPadDown
- },
- set: function(i) {
- this._dPadDown = this._setDPadValue(i, this._dPadDown, Xbox360Dpad.Down)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "dPadLeft", {
- get: function() {
- return this._dPadLeft
- },
- set: function(i) {
- this._dPadLeft = this._setDPadValue(i, this._dPadLeft, Xbox360Dpad.Left)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "dPadRight", {
- get: function() {
- return this._dPadRight
- },
- set: function(i) {
- this._dPadRight = this._setDPadValue(i, this._dPadRight, Xbox360Dpad.Right)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.update = function() {
- a.prototype.update.call(this),
- this._isXboxOnePad ? (this.buttonA = this.browserGamepad.buttons[0].value,
- this.buttonB = this.browserGamepad.buttons[1].value,
- this.buttonX = this.browserGamepad.buttons[2].value,
- this.buttonY = this.browserGamepad.buttons[3].value,
- this.buttonLB = this.browserGamepad.buttons[4].value,
- this.buttonRB = this.browserGamepad.buttons[5].value,
- this.leftTrigger = this.browserGamepad.buttons[6].value,
- this.rightTrigger = this.browserGamepad.buttons[7].value,
- this.buttonBack = this.browserGamepad.buttons[8].value,
- this.buttonStart = this.browserGamepad.buttons[9].value,
- this.buttonLeftStick = this.browserGamepad.buttons[10].value,
- this.buttonRightStick = this.browserGamepad.buttons[11].value,
- this.dPadUp = this.browserGamepad.buttons[12].value,
- this.dPadDown = this.browserGamepad.buttons[13].value,
- this.dPadLeft = this.browserGamepad.buttons[14].value,
- this.dPadRight = this.browserGamepad.buttons[15].value) : (this.buttonA = this.browserGamepad.buttons[0].value,
- this.buttonB = this.browserGamepad.buttons[1].value,
- this.buttonX = this.browserGamepad.buttons[2].value,
- this.buttonY = this.browserGamepad.buttons[3].value,
- this.buttonLB = this.browserGamepad.buttons[4].value,
- this.buttonRB = this.browserGamepad.buttons[5].value,
- this.leftTrigger = this.browserGamepad.buttons[6].value,
- this.rightTrigger = this.browserGamepad.buttons[7].value,
- this.buttonBack = this.browserGamepad.buttons[8].value,
- this.buttonStart = this.browserGamepad.buttons[9].value,
- this.buttonLeftStick = this.browserGamepad.buttons[10].value,
- this.buttonRightStick = this.browserGamepad.buttons[11].value,
- this.dPadUp = this.browserGamepad.buttons[12].value,
- this.dPadDown = this.browserGamepad.buttons[13].value,
- this.dPadLeft = this.browserGamepad.buttons[14].value,
- this.dPadRight = this.browserGamepad.buttons[15].value)
- }
- ,
- e.prototype.dispose = function() {
- a.prototype.dispose.call(this),
- this.onButtonDownObservable.clear(),
- this.onButtonUpObservable.clear(),
- this.onPadDownObservable.clear(),
- this.onPadUpObservable.clear()
- }
- ,
- e
- }(Gamepad), DualShockButton;
- (function(a) {
- a[a.Cross = 0] = "Cross",
- a[a.Circle = 1] = "Circle",
- a[a.Square = 2] = "Square",
- a[a.Triangle = 3] = "Triangle",
- a[a.L1 = 4] = "L1",
- a[a.R1 = 5] = "R1",
- a[a.Share = 8] = "Share",
- a[a.Options = 9] = "Options",
- a[a.LeftStick = 10] = "LeftStick",
- a[a.RightStick = 11] = "RightStick"
- }
- )(DualShockButton || (DualShockButton = {}));
- var DualShockDpad;
- (function(a) {
- a[a.Up = 12] = "Up",
- a[a.Down = 13] = "Down",
- a[a.Left = 14] = "Left",
- a[a.Right = 15] = "Right"
- }
- )(DualShockDpad || (DualShockDpad = {}));
- var DualShockPad = function(a) {
- __extends(e, a);
- function e(i, o, s) {
- var c = a.call(this, i.replace("STANDARD GAMEPAD", "SONY PLAYSTATION DUALSHOCK"), o, s, 0, 1, 2, 3) || this;
- return c._leftTrigger = 0,
- c._rightTrigger = 0,
- c.onButtonDownObservable = new Observable,
- c.onButtonUpObservable = new Observable,
- c.onPadDownObservable = new Observable,
- c.onPadUpObservable = new Observable,
- c._buttonCross = 0,
- c._buttonCircle = 0,
- c._buttonSquare = 0,
- c._buttonTriangle = 0,
- c._buttonShare = 0,
- c._buttonOptions = 0,
- c._buttonL1 = 0,
- c._buttonR1 = 0,
- c._buttonLeftStick = 0,
- c._buttonRightStick = 0,
- c._dPadUp = 0,
- c._dPadDown = 0,
- c._dPadLeft = 0,
- c._dPadRight = 0,
- c.type = Gamepad.DUALSHOCK,
- c
- }
- return e.prototype.onlefttriggerchanged = function(i) {
- this._onlefttriggerchanged = i
- }
- ,
- e.prototype.onrighttriggerchanged = function(i) {
- this._onrighttriggerchanged = i
- }
- ,
- Object.defineProperty(e.prototype, "leftTrigger", {
- get: function() {
- return this._leftTrigger
- },
- set: function(i) {
- this._onlefttriggerchanged && this._leftTrigger !== i && this._onlefttriggerchanged(i),
- this._leftTrigger = i
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "rightTrigger", {
- get: function() {
- return this._rightTrigger
- },
- set: function(i) {
- this._onrighttriggerchanged && this._rightTrigger !== i && this._onrighttriggerchanged(i),
- this._rightTrigger = i
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.onbuttondown = function(i) {
- this._onbuttondown = i
- }
- ,
- e.prototype.onbuttonup = function(i) {
- this._onbuttonup = i
- }
- ,
- e.prototype.ondpaddown = function(i) {
- this._ondpaddown = i
- }
- ,
- e.prototype.ondpadup = function(i) {
- this._ondpadup = i
- }
- ,
- e.prototype._setButtonValue = function(i, o, s) {
- return i !== o && (i === 1 && (this._onbuttondown && this._onbuttondown(s),
- this.onButtonDownObservable.notifyObservers(s)),
- i === 0 && (this._onbuttonup && this._onbuttonup(s),
- this.onButtonUpObservable.notifyObservers(s))),
- i
- }
- ,
- e.prototype._setDPadValue = function(i, o, s) {
- return i !== o && (i === 1 && (this._ondpaddown && this._ondpaddown(s),
- this.onPadDownObservable.notifyObservers(s)),
- i === 0 && (this._ondpadup && this._ondpadup(s),
- this.onPadUpObservable.notifyObservers(s))),
- i
- }
- ,
- Object.defineProperty(e.prototype, "buttonCross", {
- get: function() {
- return this._buttonCross
- },
- set: function(i) {
- this._buttonCross = this._setButtonValue(i, this._buttonCross, DualShockButton.Cross)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "buttonCircle", {
- get: function() {
- return this._buttonCircle
- },
- set: function(i) {
- this._buttonCircle = this._setButtonValue(i, this._buttonCircle, DualShockButton.Circle)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "buttonSquare", {
- get: function() {
- return this._buttonSquare
- },
- set: function(i) {
- this._buttonSquare = this._setButtonValue(i, this._buttonSquare, DualShockButton.Square)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "buttonTriangle", {
- get: function() {
- return this._buttonTriangle
- },
- set: function(i) {
- this._buttonTriangle = this._setButtonValue(i, this._buttonTriangle, DualShockButton.Triangle)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "buttonOptions", {
- get: function() {
- return this._buttonOptions
- },
- set: function(i) {
- this._buttonOptions = this._setButtonValue(i, this._buttonOptions, DualShockButton.Options)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "buttonShare", {
- get: function() {
- return this._buttonShare
- },
- set: function(i) {
- this._buttonShare = this._setButtonValue(i, this._buttonShare, DualShockButton.Share)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "buttonL1", {
- get: function() {
- return this._buttonL1
- },
- set: function(i) {
- this._buttonL1 = this._setButtonValue(i, this._buttonL1, DualShockButton.L1)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "buttonR1", {
- get: function() {
- return this._buttonR1
- },
- set: function(i) {
- this._buttonR1 = this._setButtonValue(i, this._buttonR1, DualShockButton.R1)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "buttonLeftStick", {
- get: function() {
- return this._buttonLeftStick
- },
- set: function(i) {
- this._buttonLeftStick = this._setButtonValue(i, this._buttonLeftStick, DualShockButton.LeftStick)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "buttonRightStick", {
- get: function() {
- return this._buttonRightStick
- },
- set: function(i) {
- this._buttonRightStick = this._setButtonValue(i, this._buttonRightStick, DualShockButton.RightStick)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "dPadUp", {
- get: function() {
- return this._dPadUp
- },
- set: function(i) {
- this._dPadUp = this._setDPadValue(i, this._dPadUp, DualShockDpad.Up)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "dPadDown", {
- get: function() {
- return this._dPadDown
- },
- set: function(i) {
- this._dPadDown = this._setDPadValue(i, this._dPadDown, DualShockDpad.Down)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "dPadLeft", {
- get: function() {
- return this._dPadLeft
- },
- set: function(i) {
- this._dPadLeft = this._setDPadValue(i, this._dPadLeft, DualShockDpad.Left)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "dPadRight", {
- get: function() {
- return this._dPadRight
- },
- set: function(i) {
- this._dPadRight = this._setDPadValue(i, this._dPadRight, DualShockDpad.Right)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.update = function() {
- a.prototype.update.call(this),
- this.buttonCross = this.browserGamepad.buttons[0].value,
- this.buttonCircle = this.browserGamepad.buttons[1].value,
- this.buttonSquare = this.browserGamepad.buttons[2].value,
- this.buttonTriangle = this.browserGamepad.buttons[3].value,
- this.buttonL1 = this.browserGamepad.buttons[4].value,
- this.buttonR1 = this.browserGamepad.buttons[5].value,
- this.leftTrigger = this.browserGamepad.buttons[6].value,
- this.rightTrigger = this.browserGamepad.buttons[7].value,
- this.buttonShare = this.browserGamepad.buttons[8].value,
- this.buttonOptions = this.browserGamepad.buttons[9].value,
- this.buttonLeftStick = this.browserGamepad.buttons[10].value,
- this.buttonRightStick = this.browserGamepad.buttons[11].value,
- this.dPadUp = this.browserGamepad.buttons[12].value,
- this.dPadDown = this.browserGamepad.buttons[13].value,
- this.dPadLeft = this.browserGamepad.buttons[14].value,
- this.dPadRight = this.browserGamepad.buttons[15].value
- }
- ,
- e.prototype.dispose = function() {
- a.prototype.dispose.call(this),
- this.onButtonDownObservable.clear(),
- this.onButtonUpObservable.clear(),
- this.onPadDownObservable.clear(),
- this.onPadUpObservable.clear()
- }
- ,
- e
- }(Gamepad)
- , GamepadManager = function() {
- function a(e) {
- var i = this;
- if (this._scene = e,
- this._babylonGamepads = [],
- this._oneGamepadConnected = !1,
- this._isMonitoring = !1,
- this.onGamepadDisconnectedObservable = new Observable,
- IsWindowObjectExist() ? (this._gamepadEventSupported = "GamepadEvent"in window,
- this._gamepadSupport = navigator && (navigator.getGamepads || navigator.webkitGetGamepads || navigator.msGetGamepads || navigator.webkitGamepads)) : this._gamepadEventSupported = !1,
- this.onGamepadConnectedObservable = new Observable(function(s) {
- for (var c in i._babylonGamepads) {
- var d = i._babylonGamepads[c];
- d && d._isConnected && i.onGamepadConnectedObservable.notifyObserver(s, d)
- }
- }
- ),
- this._onGamepadConnectedEvent = function(s) {
- var c = s.gamepad;
- if (!(c.index in i._babylonGamepads && i._babylonGamepads[c.index].isConnected)) {
- var d;
- i._babylonGamepads[c.index] ? (d = i._babylonGamepads[c.index],
- d.browserGamepad = c,
- d._isConnected = !0) : d = i._addNewGamepad(c),
- i.onGamepadConnectedObservable.notifyObservers(d),
- i._startMonitoringGamepads()
- }
- }
- ,
- this._onGamepadDisconnectedEvent = function(s) {
- var c = s.gamepad;
- for (var d in i._babylonGamepads)
- if (i._babylonGamepads[d].index === c.index) {
- var _ = i._babylonGamepads[d];
- _._isConnected = !1,
- i.onGamepadDisconnectedObservable.notifyObservers(_),
- _.dispose && _.dispose();
- break
- }
- }
- ,
- this._gamepadSupport)
- if (this._updateGamepadObjects(),
- this._babylonGamepads.length && this._startMonitoringGamepads(),
- this._gamepadEventSupported) {
- var o = this._scene ? this._scene.getEngine().getHostWindow() : window;
- o && (o.addEventListener("gamepadconnected", this._onGamepadConnectedEvent, !1),
- o.addEventListener("gamepaddisconnected", this._onGamepadDisconnectedEvent, !1))
- } else
- this._startMonitoringGamepads()
- }
- return Object.defineProperty(a.prototype, "gamepads", {
- get: function() {
- return this._babylonGamepads
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.getGamepadByType = function(e) {
- e === void 0 && (e = Gamepad.XBOX);
- for (var i = 0, o = this._babylonGamepads; i < o.length; i++) {
- var s = o[i];
- if (s && s.type === e)
- return s
- }
- return null
- }
- ,
- a.prototype.dispose = function() {
- this._gamepadEventSupported && (this._onGamepadConnectedEvent && window.removeEventListener("gamepadconnected", this._onGamepadConnectedEvent),
- this._onGamepadDisconnectedEvent && window.removeEventListener("gamepaddisconnected", this._onGamepadDisconnectedEvent),
- this._onGamepadConnectedEvent = null,
- this._onGamepadDisconnectedEvent = null),
- this._babylonGamepads.forEach(function(e) {
- e.dispose()
- }),
- this.onGamepadConnectedObservable.clear(),
- this.onGamepadDisconnectedObservable.clear(),
- this._oneGamepadConnected = !1,
- this._stopMonitoringGamepads(),
- this._babylonGamepads = []
- }
- ,
- a.prototype._addNewGamepad = function(e) {
- this._oneGamepadConnected || (this._oneGamepadConnected = !0);
- var i, o = e.id.search("054c") !== -1 && e.id.search("0ce6") === -1, s = e.id.search("Xbox One") !== -1;
- 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),
- this._babylonGamepads[i.index] = i,
- i
- }
- ,
- a.prototype._startMonitoringGamepads = function() {
- this._isMonitoring || (this._isMonitoring = !0,
- this._scene || this._checkGamepadsStatus())
- }
- ,
- a.prototype._stopMonitoringGamepads = function() {
- this._isMonitoring = !1
- }
- ,
- a.prototype._checkGamepadsStatus = function() {
- var e = this;
- this._updateGamepadObjects();
- for (var i in this._babylonGamepads) {
- var o = this._babylonGamepads[i];
- if (!(!o || !o.isConnected))
- try {
- o.update()
- } catch {
- this._loggedErrors.indexOf(o.index) === -1 && (Tools.Warn("Error updating gamepad " + o.id),
- this._loggedErrors.push(o.index))
- }
- }
- this._isMonitoring && !this._scene && Engine.QueueNewFrame(function() {
- e._checkGamepadsStatus()
- })
- }
- ,
- a.prototype._updateGamepadObjects = function() {
- for (var e = navigator.getGamepads ? navigator.getGamepads() : navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : [], i = 0; i < e.length; i++) {
- var o = e[i];
- if (o)
- if (this._babylonGamepads[o.index])
- this._babylonGamepads[i].browserGamepad = o,
- this._babylonGamepads[i].isConnected || (this._babylonGamepads[i]._isConnected = !0,
- this.onGamepadConnectedObservable.notifyObservers(this._babylonGamepads[i]));
- else {
- var s = this._addNewGamepad(o);
- this.onGamepadConnectedObservable.notifyObservers(s)
- }
- }
- }
- ,
- a
- }()
- , FreeCameraGamepadInput = function() {
- function a() {
- this.gamepadAngularSensibility = 200,
- this.gamepadMoveSensibility = 40,
- this.deadzoneDelta = .1,
- this._yAxisScale = 1,
- this._cameraTransform = Matrix.Identity(),
- this._deltaTransform = Vector3.Zero(),
- this._vector3 = Vector3.Zero(),
- this._vector2 = Vector2.Zero()
- }
- return Object.defineProperty(a.prototype, "invertYAxis", {
- get: function() {
- return this._yAxisScale !== 1
- },
- set: function(e) {
- this._yAxisScale = e ? -1 : 1
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.attachControl = function() {
- var e = this
- , i = this.camera.getScene().gamepadManager;
- this._onGamepadConnectedObserver = i.onGamepadConnectedObservable.add(function(o) {
- o.type !== Gamepad.POSE_ENABLED && (!e.gamepad || o.type === Gamepad.XBOX) && (e.gamepad = o)
- }),
- this._onGamepadDisconnectedObserver = i.onGamepadDisconnectedObservable.add(function(o) {
- e.gamepad === o && (e.gamepad = null)
- }),
- this.gamepad = i.getGamepadByType(Gamepad.XBOX),
- !this.gamepad && i.gamepads.length && (this.gamepad = i.gamepads[0])
- }
- ,
- a.prototype.detachControl = function(e) {
- this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver),
- this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver),
- this.gamepad = null
- }
- ,
- a.prototype.checkInputs = function() {
- if (this.gamepad && this.gamepad.leftStick) {
- var e = this.camera
- , i = this.gamepad.leftStick;
- this.gamepadMoveSensibility !== 0 && (i.x = Math.abs(i.x) > this.deadzoneDelta ? i.x / this.gamepadMoveSensibility : 0,
- i.y = Math.abs(i.y) > this.deadzoneDelta ? i.y / this.gamepadMoveSensibility : 0);
- var o = this.gamepad.rightStick;
- o && this.gamepadAngularSensibility !== 0 ? (o.x = Math.abs(o.x) > this.deadzoneDelta ? o.x / this.gamepadAngularSensibility : 0,
- o.y = (Math.abs(o.y) > this.deadzoneDelta ? o.y / this.gamepadAngularSensibility : 0) * this._yAxisScale) : o = {
- x: 0,
- y: 0
- },
- e.rotationQuaternion ? e.rotationQuaternion.toRotationMatrix(this._cameraTransform) : Matrix.RotationYawPitchRollToRef(e.rotation.y, e.rotation.x, 0, this._cameraTransform);
- var s = e._computeLocalCameraSpeed() * 50;
- this._vector3.copyFromFloats(i.x * s, 0, -i.y * s),
- Vector3.TransformCoordinatesToRef(this._vector3, this._cameraTransform, this._deltaTransform),
- e.cameraDirection.addInPlace(this._deltaTransform),
- this._vector2.copyFromFloats(o.y, o.x),
- e.cameraRotation.addInPlace(this._vector2)
- }
- }
- ,
- a.prototype.getClassName = function() {
- return "FreeCameraGamepadInput"
- }
- ,
- a.prototype.getSimpleName = function() {
- return "gamepad"
- }
- ,
- __decorate([serialize()], a.prototype, "gamepadAngularSensibility", void 0),
- __decorate([serialize()], a.prototype, "gamepadMoveSensibility", void 0),
- a
- }();
- CameraInputTypes.FreeCameraGamepadInput = FreeCameraGamepadInput;
- var ArcRotateCameraGamepadInput = function() {
- function a() {
- this.gamepadRotationSensibility = 80,
- this.gamepadMoveSensibility = 40,
- this._yAxisScale = 1
- }
- return Object.defineProperty(a.prototype, "invertYAxis", {
- get: function() {
- return this._yAxisScale !== 1
- },
- set: function(e) {
- this._yAxisScale = e ? -1 : 1
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.attachControl = function() {
- var e = this
- , i = this.camera.getScene().gamepadManager;
- this._onGamepadConnectedObserver = i.onGamepadConnectedObservable.add(function(o) {
- o.type !== Gamepad.POSE_ENABLED && (!e.gamepad || o.type === Gamepad.XBOX) && (e.gamepad = o)
- }),
- this._onGamepadDisconnectedObserver = i.onGamepadDisconnectedObservable.add(function(o) {
- e.gamepad === o && (e.gamepad = null)
- }),
- this.gamepad = i.getGamepadByType(Gamepad.XBOX)
- }
- ,
- a.prototype.detachControl = function(e) {
- this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver),
- this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver),
- this.gamepad = null
- }
- ,
- a.prototype.checkInputs = function() {
- if (this.gamepad) {
- var e = this.camera
- , i = this.gamepad.rightStick;
- if (i) {
- if (i.x != 0) {
- var o = i.x / this.gamepadRotationSensibility;
- o != 0 && Math.abs(o) > .005 && (e.inertialAlphaOffset += o)
- }
- if (i.y != 0) {
- var s = i.y / this.gamepadRotationSensibility * this._yAxisScale;
- s != 0 && Math.abs(s) > .005 && (e.inertialBetaOffset += s)
- }
- }
- var c = this.gamepad.leftStick;
- if (c && c.y != 0) {
- var d = c.y / this.gamepadMoveSensibility;
- d != 0 && Math.abs(d) > .005 && (this.camera.inertialRadiusOffset -= d)
- }
- }
- }
- ,
- a.prototype.getClassName = function() {
- return "ArcRotateCameraGamepadInput"
- }
- ,
- a.prototype.getSimpleName = function() {
- return "gamepad"
- }
- ,
- __decorate([serialize()], a.prototype, "gamepadRotationSensibility", void 0),
- __decorate([serialize()], a.prototype, "gamepadMoveSensibility", void 0),
- a
- }();
- CameraInputTypes.ArcRotateCameraGamepadInput = ArcRotateCameraGamepadInput;
- Object.defineProperty(Scene.prototype, "gamepadManager", {
- get: function() {
- if (!this._gamepadManager) {
- this._gamepadManager = new GamepadManager(this);
- var a = this._getComponent(SceneComponentConstants.NAME_GAMEPAD);
- a || (a = new GamepadSystemSceneComponent(this),
- this._addComponent(a))
- }
- return this._gamepadManager
- },
- enumerable: !0,
- configurable: !0
- });
- FreeCameraInputsManager.prototype.addGamepad = function() {
- return this.add(new FreeCameraGamepadInput),
- this
- }
- ;
- ArcRotateCameraInputsManager.prototype.addGamepad = function() {
- return this.add(new ArcRotateCameraGamepadInput),
- this
- }
- ;
- var GamepadSystemSceneComponent = function() {
- function a(e) {
- this.name = SceneComponentConstants.NAME_GAMEPAD,
- this.scene = e
- }
- return a.prototype.register = function() {
- this.scene._beforeCameraUpdateStage.registerStep(SceneComponentConstants.STEP_BEFORECAMERAUPDATE_GAMEPAD, this, this._beforeCameraUpdate)
- }
- ,
- a.prototype.rebuild = function() {}
- ,
- a.prototype.dispose = function() {
- var e = this.scene._gamepadManager;
- e && (e.dispose(),
- this.scene._gamepadManager = null)
- }
- ,
- a.prototype._beforeCameraUpdate = function() {
- var e = this.scene._gamepadManager;
- e && e._isMonitoring && e._checkGamepadsStatus()
- }
- ,
- a
- }(), WebXRManagedOutputCanvasOptions = function() {
- function a() {}
- return a.GetDefaults = function(e) {
- var i = new a;
- return i.canvasOptions = {
- antialias: !0,
- depth: !0,
- stencil: e ? e.isStencilEnable : !0,
- alpha: !0,
- multiview: !1,
- framebufferScaleFactor: 1
- },
- i.newCanvasCssStyle = "position:absolute; bottom:0px;right:0px;z-index:10;width:90%;height:100%;background-color: #000000;",
- i
- }
- ,
- a
- }(), WebXRManagedOutputCanvas = function() {
- function a(e, i) {
- var o = this;
- if (i === void 0 && (i = WebXRManagedOutputCanvasOptions.GetDefaults()),
- this._options = i,
- this._canvas = null,
- this._engine = null,
- this.xrLayer = null,
- this.onXRLayerInitObservable = new Observable,
- this._engine = e.scene.getEngine(),
- this._engine.onDisposeObservable.addOnce(function() {
- o._engine = null
- }),
- i.canvasElement)
- this._setManagedOutputCanvas(i.canvasElement);
- else {
- var s = document.createElement("canvas");
- s.style.cssText = this._options.newCanvasCssStyle || "position:absolute; bottom:0px;right:0px;",
- this._setManagedOutputCanvas(s)
- }
- e.onXRSessionInit.add(function() {
- o._addCanvas()
- }),
- e.onXRSessionEnded.add(function() {
- o._removeCanvas()
- })
- }
- return a.prototype.dispose = function() {
- this._removeCanvas(),
- this._setManagedOutputCanvas(null)
- }
- ,
- a.prototype.initializeXRLayerAsync = function(e) {
- var i = this
- , o = function() {
- var s = new XRWebGLLayer(e,i.canvasContext,i._options.canvasOptions);
- return i.onXRLayerInitObservable.notifyObservers(s),
- s
- };
- return this.canvasContext.makeXRCompatible ? this.canvasContext.makeXRCompatible().then(function() {}, function() {
- Tools.Warn("Error executing makeXRCompatible. This does not mean that the session will work incorrectly.")
- }).then(function() {
- return i.xrLayer = o(),
- i.xrLayer
- }) : (this.xrLayer = o(),
- Promise.resolve(this.xrLayer))
- }
- ,
- a.prototype._addCanvas = function() {
- var e = this;
- this._canvas && this._engine && this._canvas !== this._engine.getRenderingCanvas() && document.body.appendChild(this._canvas),
- this.xrLayer ? this._setCanvasSize(!0) : this.onXRLayerInitObservable.addOnce(function(i) {
- e._setCanvasSize(!0, i)
- })
- }
- ,
- a.prototype._removeCanvas = function() {
- this._canvas && this._engine && document.body.contains(this._canvas) && this._canvas !== this._engine.getRenderingCanvas() && document.body.removeChild(this._canvas),
- this._setCanvasSize(!1)
- }
- ,
- a.prototype._setCanvasSize = function(e, i) {
- e === void 0 && (e = !0),
- i === void 0 && (i = this.xrLayer),
- !(!this._canvas || !this._engine) && (e ? i && (this._canvas !== this._engine.getRenderingCanvas() ? (this._canvas.style.width = i.framebufferWidth + "px",
- 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",
- this._canvas.style.height = this._originalCanvasSize.height + "px") : this._engine.setSize(this._originalCanvasSize.width, this._originalCanvasSize.height)))
- }
- ,
- a.prototype._setManagedOutputCanvas = function(e) {
- this._removeCanvas(),
- e ? (this._originalCanvasSize = {
- width: e.offsetWidth,
- height: e.offsetHeight
- },
- this._canvas = e,
- this.canvasContext = this._canvas.getContext("webgl2"),
- this.canvasContext || (this.canvasContext = this._canvas.getContext("webgl"))) : (this._canvas = null,
- this.canvasContext = null)
- }
- ,
- a
- }(), WebXRSessionManager = function() {
- function a(e) {
- var i = this;
- this.scene = e,
- this._sessionEnded = !1,
- this._baseLayer = null,
- this._renderTargetTextures = [],
- this.currentTimestamp = -1,
- this.defaultHeightCompensation = 1.7,
- this.onXRFrameObservable = new Observable,
- this.onXRReferenceSpaceChanged = new Observable,
- this.onXRSessionEnded = new Observable,
- this.onXRSessionInit = new Observable,
- this._engine = e.getEngine(),
- this._engine.onDisposeObservable.addOnce(function() {
- i._engine = null
- })
- }
- return Object.defineProperty(a.prototype, "referenceSpace", {
- get: function() {
- return this._referenceSpace
- },
- set: function(e) {
- this._referenceSpace = e,
- this.onXRReferenceSpaceChanged.notifyObservers(this._referenceSpace)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "sessionMode", {
- get: function() {
- return this._sessionMode
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.dispose = function() {
- this._sessionEnded || this.exitXRAsync(),
- this.onXRFrameObservable.clear(),
- this.onXRSessionEnded.clear(),
- this.onXRReferenceSpaceChanged.clear(),
- this.onXRSessionInit.clear()
- }
- ,
- a.prototype.exitXRAsync = function() {
- return this.session && !this._sessionEnded ? (this._sessionEnded = !0,
- this.session.end().catch(function(e) {
- Logger$2.Warn("Could not end XR session.")
- })) : Promise.resolve()
- }
- ,
- a.prototype.getRenderTargetTextureForEye = function(e) {
- return this._rttProvider.getRenderTargetForEye(e)
- }
- ,
- a.prototype.getWebXRRenderTarget = function(e) {
- var i = this.scene.getEngine();
- return this._xrNavigator.xr.native ? this._xrNavigator.xr.getWebXRRenderTarget(i) : (e = e || WebXRManagedOutputCanvasOptions.GetDefaults(i),
- e.canvasElement = e.canvasElement || i.getRenderingCanvas() || void 0,
- new WebXRManagedOutputCanvas(this,e))
- }
- ,
- a.prototype.initializeAsync = function() {
- return this._xrNavigator = navigator,
- this._xrNavigator.xr ? Promise.resolve() : Promise.reject("WebXR not available")
- }
- ,
- a.prototype.initializeSessionAsync = function(e, i) {
- var o = this;
- return e === void 0 && (e = "immersive-vr"),
- i === void 0 && (i = {}),
- this._xrNavigator.xr.requestSession(e, i).then(function(s) {
- return o.session = s,
- o._sessionMode = e,
- o.onXRSessionInit.notifyObservers(s),
- o._sessionEnded = !1,
- o.session.addEventListener("end", function() {
- o._sessionEnded = !0,
- o.onXRSessionEnded.notifyObservers(null),
- o._rttProvider = null,
- o._engine && (o._engine.framebufferDimensionsObject = null,
- o._engine.restoreDefaultFramebuffer(),
- o._engine.customAnimationFrameRequester = null,
- o._engine._renderLoop()),
- o.isNative && (o._renderTargetTextures.forEach(function(c) {
- return c.dispose()
- }),
- o._renderTargetTextures.length = 0)
- }, {
- once: !0
- }),
- o.session
- })
- }
- ,
- a.prototype.isSessionSupportedAsync = function(e) {
- return a.IsSessionSupportedAsync(e)
- }
- ,
- a.prototype.resetReferenceSpace = function() {
- this.referenceSpace = this.baseReferenceSpace
- }
- ,
- a.prototype.runXRRenderLoop = function() {
- var e = this;
- if (!(this._sessionEnded || !this._engine)) {
- if (this._engine.customAnimationFrameRequester = {
- requestAnimationFrame: this.session.requestAnimationFrame.bind(this.session),
- renderFunction: function(d, _) {
- e._sessionEnded || !e._engine || (e.currentFrame = _,
- e.currentTimestamp = d,
- _ && (e._engine.framebufferDimensionsObject = e._baseLayer,
- e.onXRFrameObservable.notifyObservers(_),
- e._engine._renderLoop(),
- e._engine.framebufferDimensionsObject = null))
- }
- },
- this._xrNavigator.xr.native)
- this._rttProvider = this._xrNavigator.xr.getNativeRenderTargetProvider(this.session, this._createRenderTargetTexture.bind(this), this._destroyRenderTargetTexture.bind(this));
- else {
- var i, o, s, c;
- this._rttProvider = {
- getRenderTargetForEye: function() {
- var d = e._baseLayer;
- return (d.framebufferWidth !== o || d.framebufferHeight !== s || d.framebuffer !== c) && (i = e._createRenderTargetTexture(d.framebufferWidth, d.framebufferHeight, d.framebuffer),
- o = d.framebufferWidth,
- s = d.framebufferHeight,
- c = d.framebuffer),
- i
- }
- },
- this._engine.framebufferDimensionsObject = this._baseLayer
- }
- typeof window != "undefined" && window.cancelAnimationFrame && window.cancelAnimationFrame(this._engine._frameHandler),
- this._engine._renderLoop()
- }
- }
- ,
- a.prototype.setReferenceSpaceTypeAsync = function(e) {
- var i = this;
- return e === void 0 && (e = "local-floor"),
- this.session.requestReferenceSpace(e).then(function(o) {
- return o
- }, function(o) {
- return Logger$2.Error("XR.requestReferenceSpace failed for the following reason: "),
- Logger$2.Error(o),
- Logger$2.Log('Defaulting to universally-supported "viewer" reference space type.'),
- i.session.requestReferenceSpace("viewer").then(function(s) {
- var c = new XRRigidTransform({
- x: 0,
- y: -i.defaultHeightCompensation,
- z: 0
- });
- return s.getOffsetReferenceSpace(c)
- }, function(s) {
- throw Logger$2.Error(s),
- 'XR initialization failed: required "viewer" reference space type not supported.'
- })
- }).then(function(o) {
- return i.session.requestReferenceSpace("viewer").then(function(s) {
- return i.viewerReferenceSpace = s,
- o
- })
- }).then(function(o) {
- return i.referenceSpace = i.baseReferenceSpace = o,
- i.referenceSpace
- })
- }
- ,
- a.prototype.updateRenderStateAsync = function(e) {
- return e.baseLayer && (this._baseLayer = e.baseLayer),
- this.session.updateRenderState(e)
- }
- ,
- a.IsSessionSupportedAsync = function(e) {
- if (!navigator.xr)
- return Promise.resolve(!1);
- var i = navigator.xr.isSessionSupported || navigator.xr.supportsSession;
- return i ? i.call(navigator.xr, e).then(function(o) {
- var s = typeof o == "undefined" ? !0 : o;
- return Promise.resolve(s)
- }).catch(function(o) {
- return Logger$2.Warn(o),
- Promise.resolve(!1)
- }) : Promise.resolve(!1)
- }
- ,
- Object.defineProperty(a.prototype, "isNative", {
- get: function() {
- var e;
- return (e = this._xrNavigator.xr.native) !== null && e !== void 0 ? e : !1
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "currentFrameRate", {
- get: function() {
- var e;
- return (e = this.session) === null || e === void 0 ? void 0 : e.frameRate
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "supportedFrameRates", {
- get: function() {
- var e;
- return (e = this.session) === null || e === void 0 ? void 0 : e.supportedFrameRates
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.updateTargetFrameRate = function(e) {
- return this.session.updateTargetFrameRate(e)
- }
- ,
- Object.defineProperty(a.prototype, "isFixedFoveationSupported", {
- get: function() {
- var e;
- return !!(!((e = this._baseLayer) === null || e === void 0) && e.fixedFoveation) !== null
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "fixedFoveation", {
- get: function() {
- var e;
- return ((e = this._baseLayer) === null || e === void 0 ? void 0 : e.fixedFoveation) !== void 0 ? this._baseLayer.fixedFoveation : null
- },
- set: function(e) {
- var i, o = Math.max(0, Math.min(1, e || 0));
- ((i = this._baseLayer) === null || i === void 0 ? void 0 : i.fixedFoveation) !== void 0 && (this._baseLayer.fixedFoveation = o)
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._createRenderTargetTexture = function(e, i, o) {
- if (!this._engine)
- throw new Error("Engine is disposed");
- var s = new InternalTexture(this._engine,InternalTextureSource.Unknown,!0);
- s.width = e,
- s.height = i;
- var c = new RenderTargetTexture("XR renderTargetTexture",{
- width: e,
- height: i
- },this.scene)
- , d = c.renderTarget;
- return d.setTexture(s, 0),
- d._framebuffer = o,
- c._texture = s,
- c.disableRescaling(),
- c.skipInitialClear = !0,
- this._renderTargetTextures.push(c),
- c
- }
- ,
- a.prototype._destroyRenderTargetTexture = function(e) {
- this._renderTargetTextures.splice(this._renderTargetTextures.indexOf(e), 1),
- e.dispose()
- }
- ,
- a
- }(), WebXRState;
- (function(a) {
- a[a.ENTERING_XR = 0] = "ENTERING_XR",
- a[a.EXITING_XR = 1] = "EXITING_XR",
- a[a.IN_XR = 2] = "IN_XR",
- a[a.NOT_IN_XR = 3] = "NOT_IN_XR"
- }
- )(WebXRState || (WebXRState = {}));
- var WebXRTrackingState;
- (function(a) {
- a[a.NOT_TRACKING = 0] = "NOT_TRACKING",
- a[a.TRACKING_LOST = 1] = "TRACKING_LOST",
- a[a.TRACKING = 2] = "TRACKING"
- }
- )(WebXRTrackingState || (WebXRTrackingState = {}));
- var VRExperienceHelperGazer = function() {
- function a(e, i) {
- if (i === void 0 && (i = null),
- this.scene = e,
- this._pointerDownOnMeshAsked = !1,
- this._isActionableMesh = !1,
- this._teleportationRequestInitiated = !1,
- this._teleportationBackRequestInitiated = !1,
- this._rotationRightAsked = !1,
- this._rotationLeftAsked = !1,
- this._dpadPressed = !0,
- this._activePointer = !1,
- this._id = a._idCounter++,
- i)
- this._gazeTracker = i.clone("gazeTracker");
- else {
- this._gazeTracker = CreateTorus("gazeTracker", {
- diameter: .0035,
- thickness: .0025,
- tessellation: 20,
- updatable: !1
- }, e),
- this._gazeTracker.bakeCurrentTransformIntoVertices(),
- this._gazeTracker.isPickable = !1,
- this._gazeTracker.isVisible = !1;
- var o = new StandardMaterial("targetMat",e);
- o.specularColor = Color3.Black(),
- o.emissiveColor = new Color3(.7,.7,.7),
- o.backFaceCulling = !1,
- this._gazeTracker.material = o
- }
- }
- return a.prototype._getForwardRay = function(e) {
- return new Ray(Vector3.Zero(),new Vector3(0,0,e))
- }
- ,
- a.prototype._selectionPointerDown = function() {
- this._pointerDownOnMeshAsked = !0,
- this._currentHit && this.scene.simulatePointerDown(this._currentHit, {
- pointerId: this._id
- })
- }
- ,
- a.prototype._selectionPointerUp = function() {
- this._currentHit && this.scene.simulatePointerUp(this._currentHit, {
- pointerId: this._id
- }),
- this._pointerDownOnMeshAsked = !1
- }
- ,
- a.prototype._activatePointer = function() {
- this._activePointer = !0
- }
- ,
- a.prototype._deactivatePointer = function() {
- this._activePointer = !1
- }
- ,
- a.prototype._updatePointerDistance = function(e) {}
- ,
- a.prototype.dispose = function() {
- this._interactionsEnabled = !1,
- this._teleportationEnabled = !1,
- this._gazeTracker && this._gazeTracker.dispose()
- }
- ,
- a._idCounter = 0,
- a
- }()
- , VRExperienceHelperControllerGazer = function(a) {
- __extends(e, a);
- function e(i, o, s) {
- var c = a.call(this, o, s) || this;
- c.webVRController = i,
- c._laserPointer = CreateCylinder("laserPointer", {
- updatable: !1,
- height: 1,
- diameterTop: .004,
- diameterBottom: 2e-4,
- tessellation: 20,
- subdivisions: 1
- }, o);
- var d = new StandardMaterial("laserPointerMat",o);
- if (d.emissiveColor = new Color3(.7,.7,.7),
- d.alpha = .6,
- c._laserPointer.material = d,
- c._laserPointer.rotation.x = Math.PI / 2,
- c._laserPointer.position.z = -.5,
- c._laserPointer.isVisible = !1,
- c._laserPointer.isPickable = !1,
- !i.mesh) {
- var _ = new Mesh("preloadControllerMesh",o)
- , b = new Mesh(PoseEnabledController.POINTING_POSE,o);
- b.rotation.x = -.7,
- _.addChild(b),
- i.attachToMesh(_)
- }
- return c._setLaserPointerParent(i.mesh),
- c._meshAttachedObserver = i._meshAttachedObservable.add(function(k) {
- c._setLaserPointerParent(k)
- }),
- c
- }
- return e.prototype._getForwardRay = function(i) {
- return this.webVRController.getForwardRay(i)
- }
- ,
- e.prototype._activatePointer = function() {
- a.prototype._activatePointer.call(this),
- this._laserPointer.isVisible = !0
- }
- ,
- e.prototype._deactivatePointer = function() {
- a.prototype._deactivatePointer.call(this),
- this._laserPointer.isVisible = !1
- }
- ,
- e.prototype._setLaserPointerColor = function(i) {
- this._laserPointer.material.emissiveColor = i
- }
- ,
- e.prototype._setLaserPointerLightingDisabled = function(i) {
- this._laserPointer.material.disableLighting = i
- }
- ,
- e.prototype._setLaserPointerParent = function(i) {
- var o = function(_) {
- _.isPickable = !1,
- _.getChildMeshes().forEach(function(b) {
- o(b)
- })
- };
- o(i);
- var s = i.getChildren(void 0, !1)
- , c = i;
- this.webVRController._pointingPoseNode = null;
- for (var d = 0; d < s.length; d++)
- if (s[d].name && s[d].name.indexOf(PoseEnabledController.POINTING_POSE) >= 0) {
- c = s[d],
- this.webVRController._pointingPoseNode = c;
- break
- }
- this._laserPointer.parent = c
- }
- ,
- e.prototype._updatePointerDistance = function(i) {
- i === void 0 && (i = 100),
- this._laserPointer.scaling.y = i,
- this._laserPointer.position.z = -i / 2
- }
- ,
- e.prototype.dispose = function() {
- a.prototype.dispose.call(this),
- this._laserPointer.dispose(),
- this._meshAttachedObserver && this.webVRController._meshAttachedObservable.remove(this._meshAttachedObserver)
- }
- ,
- e
- }(VRExperienceHelperGazer)
- , VRExperienceHelperCameraGazer = function(a) {
- __extends(e, a);
- function e(i, o) {
- var s = a.call(this, o) || this;
- return s.getCamera = i,
- s
- }
- return e.prototype._getForwardRay = function(i) {
- var o = this.getCamera();
- return o ? o.getForwardRay(i) : new Ray(Vector3.Zero(),Vector3.Forward())
- }
- ,
- e
- }(VRExperienceHelperGazer)
- , VRExperienceHelper = function() {
- function a(e, i) {
- var o = this;
- i === void 0 && (i = {}),
- this.webVROptions = i,
- this._webVRsupported = !1,
- this._webVRready = !1,
- this._webVRrequesting = !1,
- this._webVRpresenting = !1,
- this._fullscreenVRpresenting = !1,
- this.enableGazeEvenWhenNoPointerLock = !1,
- this.exitVROnDoubleTap = !0,
- this.onEnteringVRObservable = new Observable,
- this.onAfterEnteringVRObservable = new Observable,
- this.onExitingVRObservable = new Observable,
- this.onControllerMeshLoadedObservable = new Observable,
- this._useCustomVRButton = !1,
- this._teleportationRequested = !1,
- this._teleportActive = !1,
- this._floorMeshesCollection = [],
- this._teleportationMode = a.TELEPORTATIONMODE_CONSTANTTIME,
- this._teleportationTime = 122,
- this._teleportationSpeed = 20,
- this._rotationAllowed = !0,
- this._teleportBackwardsVector = new Vector3(0,-1,-1),
- this._isDefaultTeleportationTarget = !0,
- this._teleportationFillColor = "#444444",
- this._teleportationBorderColor = "#FFFFFF",
- this._rotationAngle = 0,
- this._haloCenter = new Vector3(0,0,0),
- this._padSensibilityUp = .65,
- this._padSensibilityDown = .35,
- this._leftController = null,
- this._rightController = null,
- this._gazeColor = new Color3(.7,.7,.7),
- this._laserColor = new Color3(.7,.7,.7),
- this._pickedLaserColor = new Color3(.2,.2,1),
- this._pickedGazeColor = new Color3(0,0,1),
- this.onNewMeshSelected = new Observable,
- this.onMeshSelectedWithController = new Observable,
- this.onNewMeshPicked = new Observable,
- this.onBeforeCameraTeleport = new Observable,
- this.onAfterCameraTeleport = new Observable,
- this.onSelectedMeshUnselected = new Observable,
- this.teleportationEnabled = !0,
- this._teleportationInitialized = !1,
- this._interactionsEnabled = !1,
- this._interactionsRequested = !1,
- this._displayGaze = !0,
- this._displayLaserPointer = !0,
- this.updateGazeTrackerScale = !0,
- this.updateGazeTrackerColor = !0,
- this.updateControllerLaserColor = !0,
- this.requestPointerLockOnFullScreen = !0,
- this.xrTestDone = !1,
- this._onResize = function() {
- o.moveButtonToBottomRight(),
- o._fullscreenVRpresenting && o._webVRready && o.exitVR()
- }
- ,
- this._onFullscreenChange = function() {
- var d = document;
- 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),
- !o._fullscreenVRpresenting && o._inputElement && (o.exitVR(),
- !o._useCustomVRButton && o._btnVR && (o._btnVR.style.top = o._inputElement.offsetTop + o._inputElement.offsetHeight - 70 + "px",
- o._btnVR.style.left = o._inputElement.offsetLeft + o._inputElement.offsetWidth - 100 + "px",
- o.updateButtonVisibility()))
- }
- ,
- this._cachedAngularSensibility = {
- angularSensibilityX: null,
- angularSensibilityY: null,
- angularSensibility: null
- },
- this.beforeRender = function() {
- o._leftController && o._leftController._activePointer && o._castRayAndSelectObject(o._leftController),
- o._rightController && o._rightController._activePointer && o._castRayAndSelectObject(o._rightController),
- o._noControllerIsActive && (o._scene.getEngine().isPointerLock || o.enableGazeEvenWhenNoPointerLock) ? o._castRayAndSelectObject(o._cameraGazer) : o._cameraGazer._gazeTracker.isVisible = !1
- }
- ,
- this._onNewGamepadConnected = function(d) {
- if (d.type !== Gamepad.POSE_ENABLED)
- d.leftStick && d.onleftstickchanged(function(k) {
- o._teleportationInitialized && o.teleportationEnabled && (!o._leftController && !o._rightController || o._leftController && !o._leftController._activePointer && o._rightController && !o._rightController._activePointer) && (o._checkTeleportWithRay(k, o._cameraGazer),
- o._checkTeleportBackwards(k, o._cameraGazer))
- }),
- d.rightStick && d.onrightstickchanged(function(k) {
- o._teleportationInitialized && o._checkRotate(k, o._cameraGazer)
- }),
- d.type === Gamepad.XBOX && (d.onbuttondown(function(k) {
- o._interactionsEnabled && k === Xbox360Button.A && o._cameraGazer._selectionPointerDown()
- }),
- d.onbuttonup(function(k) {
- o._interactionsEnabled && k === Xbox360Button.A && o._cameraGazer._selectionPointerUp()
- }));
- else {
- var _ = d
- , b = new VRExperienceHelperControllerGazer(_,o._scene,o._cameraGazer._gazeTracker);
- _.hand === "right" || o._leftController && o._leftController.webVRController != _ ? o._rightController = b : o._leftController = b,
- o._tryEnableInteractionOnController(b)
- }
- }
- ,
- this._tryEnableInteractionOnController = function(d) {
- o._interactionsRequested && !d._interactionsEnabled && o._enableInteractionOnController(d),
- o._teleportationRequested && !d._teleportationEnabled && o._enableTeleportationOnController(d)
- }
- ,
- this._onNewGamepadDisconnected = function(d) {
- d instanceof WebVRController && (d.hand === "left" && o._leftController != null && (o._leftController.dispose(),
- o._leftController = null),
- d.hand === "right" && o._rightController != null && (o._rightController.dispose(),
- o._rightController = null))
- }
- ,
- this._workingVector = Vector3.Zero(),
- this._workingQuaternion = Quaternion.Identity(),
- this._workingMatrix = Matrix.Identity(),
- Logger$2.Warn("WebVR is deprecated. Please avoid using this experience helper and use the WebXR experience helper instead"),
- this._scene = e,
- this._inputElement = e.getEngine().getInputElement();
- var s = "getVRDisplays"in navigator;
- if (!s && i.useXR === void 0 && (i.useXR = !0),
- i.createFallbackVRDeviceOrientationFreeCamera === void 0 && (i.createFallbackVRDeviceOrientationFreeCamera = !0),
- i.createDeviceOrientationCamera === void 0 && (i.createDeviceOrientationCamera = !0),
- i.laserToggle === void 0 && (i.laserToggle = !0),
- i.defaultHeight === void 0 && (i.defaultHeight = 1.7),
- i.useCustomVRButton && (this._useCustomVRButton = !0,
- i.customVRButton && (this._btnVR = i.customVRButton)),
- i.rayLength && (this._rayLength = i.rayLength),
- this._defaultHeight = i.defaultHeight,
- i.positionScale && (this._rayLength *= i.positionScale,
- this._defaultHeight *= i.positionScale),
- this._hasEnteredVR = !1,
- this._scene.activeCamera ? this._position = this._scene.activeCamera.position.clone() : this._position = new Vector3(0,this._defaultHeight,0),
- i.createDeviceOrientationCamera || !this._scene.activeCamera) {
- if (this._deviceOrientationCamera = new DeviceOrientationCamera("deviceOrientationVRHelper",this._position.clone(),e),
- this._scene.activeCamera && (this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ,
- this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ,
- this._scene.activeCamera instanceof TargetCamera && this._scene.activeCamera.rotation)) {
- var c = this._scene.activeCamera;
- c.rotationQuaternion ? this._deviceOrientationCamera.rotationQuaternion.copyFrom(c.rotationQuaternion) : this._deviceOrientationCamera.rotationQuaternion.copyFrom(Quaternion.RotationYawPitchRoll(c.rotation.y, c.rotation.x, c.rotation.z)),
- this._deviceOrientationCamera.rotation = c.rotation.clone()
- }
- this._scene.activeCamera = this._deviceOrientationCamera,
- this._inputElement && this._scene.activeCamera.attachControl()
- } else
- this._existingCamera = this._scene.activeCamera;
- this.webVROptions.useXR && navigator.xr ? WebXRSessionManager.IsSessionSupportedAsync("immersive-vr").then(function(d) {
- d ? (Logger$2.Log("Using WebXR. It is recommended to use the WebXRDefaultExperience directly"),
- e.createDefaultXRExperienceAsync({
- floorMeshes: i.floorMeshes || []
- }).then(function(_) {
- o.xr = _,
- o.xrTestDone = !0,
- o._cameraGazer = new VRExperienceHelperCameraGazer(function() {
- return o.xr.baseExperience.camera
- }
- ,e),
- o.xr.baseExperience.onStateChangedObservable.add(function(b) {
- switch (b) {
- case WebXRState.ENTERING_XR:
- o.onEnteringVRObservable.notifyObservers(o),
- o._interactionsEnabled || o.xr.pointerSelection.detach(),
- o.xr.pointerSelection.displayLaserPointer = o._displayLaserPointer;
- break;
- case WebXRState.EXITING_XR:
- o.onExitingVRObservable.notifyObservers(o),
- o._scene.getEngine().resize();
- break;
- case WebXRState.IN_XR:
- o._hasEnteredVR = !0;
- break;
- case WebXRState.NOT_IN_XR:
- o._hasEnteredVR = !1;
- break
- }
- })
- })) : o.completeVRInit(e, i)
- }) : this.completeVRInit(e, i)
- }
- return Object.defineProperty(a.prototype, "onEnteringVR", {
- get: function() {
- return this.onEnteringVRObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "onExitingVR", {
- get: function() {
- return this.onExitingVRObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "onControllerMeshLoaded", {
- get: function() {
- return this.onControllerMeshLoadedObservable
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "teleportationTarget", {
- get: function() {
- return this._teleportationTarget
- },
- set: function(e) {
- e && (e.name = "teleportationTarget",
- this._isDefaultTeleportationTarget = !1,
- this._teleportationTarget = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "gazeTrackerMesh", {
- get: function() {
- return this._cameraGazer._gazeTracker
- },
- set: function(e) {
- e && (this._cameraGazer._gazeTracker && this._cameraGazer._gazeTracker.dispose(),
- this._leftController && this._leftController._gazeTracker && this._leftController._gazeTracker.dispose(),
- this._rightController && this._rightController._gazeTracker && this._rightController._gazeTracker.dispose(),
- this._cameraGazer._gazeTracker = e,
- this._cameraGazer._gazeTracker.bakeCurrentTransformIntoVertices(),
- this._cameraGazer._gazeTracker.isPickable = !1,
- this._cameraGazer._gazeTracker.isVisible = !1,
- this._cameraGazer._gazeTracker.name = "gazeTracker",
- this._leftController && (this._leftController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker")),
- this._rightController && (this._rightController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker")))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "leftControllerGazeTrackerMesh", {
- get: function() {
- return this._leftController ? this._leftController._gazeTracker : null
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "rightControllerGazeTrackerMesh", {
- get: function() {
- return this._rightController ? this._rightController._gazeTracker : null
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "displayGaze", {
- get: function() {
- return this._displayGaze
- },
- set: function(e) {
- this._displayGaze = e,
- e || (this._cameraGazer._gazeTracker.isVisible = !1,
- this._leftController && (this._leftController._gazeTracker.isVisible = !1),
- this._rightController && (this._rightController._gazeTracker.isVisible = !1))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "displayLaserPointer", {
- get: function() {
- return this._displayLaserPointer
- },
- set: function(e) {
- this._displayLaserPointer = e,
- e ? (this._rightController && this._rightController._activatePointer(),
- this._leftController && this._leftController._activatePointer()) : (this._rightController && (this._rightController._deactivatePointer(),
- this._rightController._gazeTracker.isVisible = !1),
- this._leftController && (this._leftController._deactivatePointer(),
- this._leftController._gazeTracker.isVisible = !1))
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "deviceOrientationCamera", {
- get: function() {
- return this._deviceOrientationCamera
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "currentVRCamera", {
- get: function() {
- return this._webVRready ? this._webVRCamera : this._scene.activeCamera
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "webVRCamera", {
- get: function() {
- return this._webVRCamera
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "vrDeviceOrientationCamera", {
- get: function() {
- return this._vrDeviceOrientationCamera
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "vrButton", {
- get: function() {
- return this._btnVR
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "_teleportationRequestInitiated", {
- get: function() {
- var e = this._cameraGazer._teleportationRequestInitiated || this._leftController !== null && this._leftController._teleportationRequestInitiated || this._rightController !== null && this._rightController._teleportationRequestInitiated;
- return e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.completeVRInit = function(e, i) {
- var o = this;
- if (this.xrTestDone = !0,
- i.createFallbackVRDeviceOrientationFreeCamera && (i.useMultiview && (i.vrDeviceOrientationCameraMetrics || (i.vrDeviceOrientationCameraMetrics = VRCameraMetrics.GetDefault()),
- i.vrDeviceOrientationCameraMetrics.multiviewEnabled = !0),
- this._vrDeviceOrientationCamera = new VRDeviceOrientationFreeCamera("VRDeviceOrientationVRHelper",this._position,this._scene,!0,i.vrDeviceOrientationCameraMetrics),
- this._vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE),
- this._webVRCamera = new WebVRFreeCamera("WebVRHelper",this._position,this._scene,i),
- this._webVRCamera.useStandingMatrix(),
- this._cameraGazer = new VRExperienceHelperCameraGazer(function() {
- return o.currentVRCamera
- }
- ,e),
- !this._useCustomVRButton) {
- this._btnVR = document.createElement("BUTTON"),
- this._btnVR.className = "babylonVRicon",
- this._btnVR.id = "babylonVRiconbtn",
- this._btnVR.title = "Click to switch to VR";
- 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"
- , 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) }";
- c += ".babylonVRicon.vrdisplaypresenting { display: none; }";
- var d = document.createElement("style");
- d.appendChild(document.createTextNode(c)),
- document.getElementsByTagName("head")[0].appendChild(d),
- this.moveButtonToBottomRight()
- }
- this._btnVR && this._btnVR.addEventListener("click", function() {
- o.isInVRMode ? o._scene.getEngine().disableVR() : o.enterVR()
- });
- var _ = this._scene.getEngine().getHostWindow();
- !_ || (_.addEventListener("resize", this._onResize),
- document.addEventListener("fullscreenchange", this._onFullscreenChange, !1),
- document.addEventListener("mozfullscreenchange", this._onFullscreenChange, !1),
- document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, !1),
- document.addEventListener("msfullscreenchange", this._onFullscreenChange, !1),
- document.onmsfullscreenchange = this._onFullscreenChange,
- i.createFallbackVRDeviceOrientationFreeCamera ? this.displayVRButton() : this._scene.getEngine().onVRDisplayChangedObservable.add(function(b) {
- b.vrDisplay && o.displayVRButton()
- }),
- this._onKeyDown = function(b) {
- b.keyCode === 27 && o.isInVRMode && o.exitVR()
- }
- ,
- document.addEventListener("keydown", this._onKeyDown),
- this._scene.onPrePointerObservable.add(function() {
- o._hasEnteredVR && o.exitVROnDoubleTap && (o.exitVR(),
- o._fullscreenVRpresenting && o._scene.getEngine().exitFullscreen())
- }, PointerEventTypes.POINTERDOUBLETAP, !1),
- this._onVRDisplayChanged = function(b) {
- return o.onVRDisplayChanged(b)
- }
- ,
- this._onVrDisplayPresentChange = function() {
- return o.onVrDisplayPresentChange()
- }
- ,
- this._onVRRequestPresentStart = function() {
- o._webVRrequesting = !0,
- o.updateButtonVisibility()
- }
- ,
- this._onVRRequestPresentComplete = function() {
- o._webVRrequesting = !1,
- o.updateButtonVisibility()
- }
- ,
- e.getEngine().onVRDisplayChangedObservable.add(this._onVRDisplayChanged),
- e.getEngine().onVRRequestPresentStart.add(this._onVRRequestPresentStart),
- e.getEngine().onVRRequestPresentComplete.add(this._onVRRequestPresentComplete),
- _.addEventListener("vrdisplaypresentchange", this._onVrDisplayPresentChange),
- e.onDisposeObservable.add(function() {
- o.dispose()
- }),
- this._webVRCamera.onControllerMeshLoadedObservable.add(function(b) {
- return o._onDefaultMeshLoaded(b)
- }),
- this._scene.gamepadManager.onGamepadConnectedObservable.add(this._onNewGamepadConnected),
- this._scene.gamepadManager.onGamepadDisconnectedObservable.add(this._onNewGamepadDisconnected),
- this.updateButtonVisibility(),
- this._circleEase = new CircleEase,
- this._circleEase.setEasingMode(EasingFunction.EASINGMODE_EASEINOUT),
- this._teleportationEasing = this._circleEase,
- e.onPointerObservable.add(function(b) {
- o._interactionsEnabled && e.activeCamera === o.vrDeviceOrientationCamera && b.event.pointerType === "mouse" && (b.type === PointerEventTypes.POINTERDOWN ? o._cameraGazer._selectionPointerDown() : b.type === PointerEventTypes.POINTERUP && o._cameraGazer._selectionPointerUp())
- }),
- this.webVROptions.floorMeshes && this.enableTeleportation({
- floorMeshes: this.webVROptions.floorMeshes
- }))
- }
- ,
- a.prototype._onDefaultMeshLoaded = function(e) {
- this._leftController && this._leftController.webVRController == e && e.mesh && this._leftController._setLaserPointerParent(e.mesh),
- this._rightController && this._rightController.webVRController == e && e.mesh && this._rightController._setLaserPointerParent(e.mesh);
- try {
- this.onControllerMeshLoadedObservable.notifyObservers(e)
- } catch (i) {
- Logger$2.Warn("Error in your custom logic onControllerMeshLoaded: " + i)
- }
- }
- ,
- Object.defineProperty(a.prototype, "isInVRMode", {
- get: function() {
- return this.xr && this.webVROptions.useXR && this.xr.baseExperience.state === WebXRState.IN_XR || this._webVRpresenting || this._fullscreenVRpresenting
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.onVrDisplayPresentChange = function() {
- var e = this._scene.getEngine().getVRDevice();
- if (e) {
- var i = this._webVRpresenting;
- this._webVRpresenting = e.isPresenting,
- i && !this._webVRpresenting && this.exitVR()
- } else
- Logger$2.Warn("Detected VRDisplayPresentChange on an unknown VRDisplay. Did you can enterVR on the vrExperienceHelper?");
- this.updateButtonVisibility()
- }
- ,
- a.prototype.onVRDisplayChanged = function(e) {
- this._webVRsupported = e.vrSupported,
- this._webVRready = !!e.vrDisplay,
- this._webVRpresenting = e.vrDisplay && e.vrDisplay.isPresenting,
- this.updateButtonVisibility()
- }
- ,
- a.prototype.moveButtonToBottomRight = function() {
- if (this._inputElement && !this._useCustomVRButton && this._btnVR) {
- var e = this._inputElement.getBoundingClientRect();
- this._btnVR.style.top = e.top + e.height - 70 + "px",
- this._btnVR.style.left = e.left + e.width - 100 + "px"
- }
- }
- ,
- a.prototype.displayVRButton = function() {
- !this._useCustomVRButton && !this._btnVRDisplayed && this._btnVR && (document.body.appendChild(this._btnVR),
- this._btnVRDisplayed = !0)
- }
- ,
- a.prototype.updateButtonVisibility = function() {
- !this._btnVR || this._useCustomVRButton || (this._btnVR.className = "babylonVRicon",
- this.isInVRMode ? this._btnVR.className += " vrdisplaypresenting" : (this._webVRready && (this._btnVR.className += " vrdisplayready"),
- this._webVRsupported && (this._btnVR.className += " vrdisplaysupported"),
- this._webVRrequesting && (this._btnVR.className += " vrdisplayrequesting")))
- }
- ,
- a.prototype.enterVR = function() {
- var e = this;
- if (this.xr) {
- this.xr.baseExperience.enterXRAsync("immersive-vr", "local-floor", this.xr.renderTarget);
- return
- }
- if (this.onEnteringVRObservable)
- try {
- this.onEnteringVRObservable.notifyObservers(this)
- } catch (d) {
- Logger$2.Warn("Error in your custom logic onEnteringVR: " + d)
- }
- if (this._scene.activeCamera) {
- if (this._position = this._scene.activeCamera.position.clone(),
- this.vrDeviceOrientationCamera && (this.vrDeviceOrientationCamera.rotation = Quaternion.FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles(),
- this.vrDeviceOrientationCamera.angularSensibility = 2e3),
- this.webVRCamera) {
- var i = this.webVRCamera.deviceRotationQuaternion.toEulerAngles().y
- , o = Quaternion.FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles().y
- , s = o - i
- , c = this.webVRCamera.rotationQuaternion.toEulerAngles().y;
- this.webVRCamera.rotationQuaternion = Quaternion.FromEulerAngles(0, c + s, 0)
- }
- this._existingCamera = this._scene.activeCamera,
- this._existingCamera.angularSensibilityX && (this._cachedAngularSensibility.angularSensibilityX = this._existingCamera.angularSensibilityX,
- this._existingCamera.angularSensibilityX = Number.MAX_VALUE),
- this._existingCamera.angularSensibilityY && (this._cachedAngularSensibility.angularSensibilityY = this._existingCamera.angularSensibilityY,
- this._existingCamera.angularSensibilityY = Number.MAX_VALUE),
- this._existingCamera.angularSensibility && (this._cachedAngularSensibility.angularSensibility = this._existingCamera.angularSensibility,
- this._existingCamera.angularSensibility = Number.MAX_VALUE)
- }
- this._webVRrequesting || (this._webVRready ? this._webVRpresenting || (this._scene.getEngine().onVRRequestPresentComplete.addOnce(function(d) {
- e.onAfterEnteringVRObservable.notifyObservers({
- success: d
- })
- }),
- this._webVRCamera.position = this._position,
- this._scene.activeCamera = this._webVRCamera) : this._vrDeviceOrientationCamera && (this._vrDeviceOrientationCamera.position = this._position,
- this._scene.activeCamera && (this._vrDeviceOrientationCamera.minZ = this._scene.activeCamera.minZ),
- this._scene.activeCamera = this._vrDeviceOrientationCamera,
- this._scene.getEngine().enterFullscreen(this.requestPointerLockOnFullScreen),
- this.updateButtonVisibility(),
- this._vrDeviceOrientationCamera.onViewMatrixChangedObservable.addOnce(function() {
- e.onAfterEnteringVRObservable.notifyObservers({
- success: !0
- })
- })),
- this._scene.activeCamera && this._inputElement && this._scene.activeCamera.attachControl(),
- this._interactionsEnabled && this._scene.registerBeforeRender(this.beforeRender),
- this._displayLaserPointer && [this._leftController, this._rightController].forEach(function(d) {
- d && d._activatePointer()
- }),
- this._hasEnteredVR = !0)
- }
- ,
- a.prototype.exitVR = function() {
- if (this.xr) {
- this.xr.baseExperience.exitXRAsync();
- return
- }
- if (this._hasEnteredVR) {
- if (this.onExitingVRObservable)
- try {
- this.onExitingVRObservable.notifyObservers(this)
- } catch (i) {
- Logger$2.Warn("Error in your custom logic onExitingVR: " + i)
- }
- this._webVRpresenting && this._scene.getEngine().disableVR(),
- this._scene.activeCamera && (this._position = this._scene.activeCamera.position.clone()),
- this.vrDeviceOrientationCamera && (this.vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE),
- this._deviceOrientationCamera ? (this._deviceOrientationCamera.position = this._position,
- this._scene.activeCamera = this._deviceOrientationCamera,
- this._cachedAngularSensibility.angularSensibilityX && (this._deviceOrientationCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX,
- this._cachedAngularSensibility.angularSensibilityX = null),
- this._cachedAngularSensibility.angularSensibilityY && (this._deviceOrientationCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY,
- this._cachedAngularSensibility.angularSensibilityY = null),
- this._cachedAngularSensibility.angularSensibility && (this._deviceOrientationCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility,
- this._cachedAngularSensibility.angularSensibility = null)) : this._existingCamera && (this._existingCamera.position = this._position,
- this._scene.activeCamera = this._existingCamera,
- this._inputElement && this._scene.activeCamera.attachControl(),
- this._cachedAngularSensibility.angularSensibilityX && (this._existingCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX,
- this._cachedAngularSensibility.angularSensibilityX = null),
- this._cachedAngularSensibility.angularSensibilityY && (this._existingCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY,
- this._cachedAngularSensibility.angularSensibilityY = null),
- this._cachedAngularSensibility.angularSensibility && (this._existingCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility,
- this._cachedAngularSensibility.angularSensibility = null)),
- this.updateButtonVisibility(),
- this._interactionsEnabled && (this._scene.unregisterBeforeRender(this.beforeRender),
- this._cameraGazer._gazeTracker.isVisible = !1,
- this._leftController && (this._leftController._gazeTracker.isVisible = !1),
- this._rightController && (this._rightController._gazeTracker.isVisible = !1)),
- this._scene.getEngine().resize(),
- [this._leftController, this._rightController].forEach(function(i) {
- i && i._deactivatePointer()
- }),
- this._hasEnteredVR = !1;
- var e = this._scene.getEngine();
- e._onVrDisplayPresentChange && e._onVrDisplayPresentChange()
- }
- }
- ,
- Object.defineProperty(a.prototype, "position", {
- get: function() {
- return this._position
- },
- set: function(e) {
- this._position = e,
- this._scene.activeCamera && (this._scene.activeCamera.position = e)
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.enableInteractions = function() {
- var e = this;
- if (!this._interactionsEnabled) {
- if (this._interactionsRequested = !0,
- this.xr) {
- this.xr.baseExperience.state === WebXRState.IN_XR && this.xr.pointerSelection.attach();
- return
- }
- this._leftController && this._enableInteractionOnController(this._leftController),
- this._rightController && this._enableInteractionOnController(this._rightController),
- this.raySelectionPredicate = function(i) {
- return i.isVisible && (i.isPickable || i.name === e._floorMeshName)
- }
- ,
- this.meshSelectionPredicate = function() {
- return !0
- }
- ,
- this._raySelectionPredicate = function(i) {
- return e._isTeleportationFloor(i) || i.name.indexOf("gazeTracker") === -1 && i.name.indexOf("teleportationTarget") === -1 && i.name.indexOf("torusTeleportation") === -1 ? e.raySelectionPredicate(i) : !1
- }
- ,
- this._interactionsEnabled = !0
- }
- }
- ,
- Object.defineProperty(a.prototype, "_noControllerIsActive", {
- get: function() {
- return !(this._leftController && this._leftController._activePointer) && !(this._rightController && this._rightController._activePointer)
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype._isTeleportationFloor = function(e) {
- for (var i = 0; i < this._floorMeshesCollection.length; i++)
- if (this._floorMeshesCollection[i].id === e.id)
- return !0;
- return !!(this._floorMeshName && e.name === this._floorMeshName)
- }
- ,
- a.prototype.addFloorMesh = function(e) {
- !this._floorMeshesCollection || this._floorMeshesCollection.indexOf(e) > -1 || this._floorMeshesCollection.push(e)
- }
- ,
- a.prototype.removeFloorMesh = function(e) {
- if (!!this._floorMeshesCollection) {
- var i = this._floorMeshesCollection.indexOf(e);
- i !== -1 && this._floorMeshesCollection.splice(i, 1)
- }
- }
- ,
- a.prototype.enableTeleportation = function(e) {
- var i = this;
- if (e === void 0 && (e = {}),
- !this._teleportationInitialized) {
- if (this._teleportationRequested = !0,
- this.enableInteractions(),
- this.webVROptions.useXR && (e.floorMeshes || e.floorMeshName)) {
- var o = e.floorMeshes || [];
- if (!o.length) {
- var s = this._scene.getMeshByName(e.floorMeshName);
- s && o.push(s)
- }
- if (this.xr) {
- o.forEach(function(_) {
- i.xr.teleportation.addFloorMesh(_)
- }),
- this.xr.teleportation.attached || this.xr.teleportation.attach();
- return
- } else if (!this.xrTestDone) {
- var c = function() {
- i.xrTestDone && (i._scene.unregisterBeforeRender(c),
- i.xr ? i.xr.teleportation.attached || i.xr.teleportation.attach() : i.enableTeleportation(e))
- };
- this._scene.registerBeforeRender(c);
- return
- }
- }
- e.floorMeshName && (this._floorMeshName = e.floorMeshName),
- e.floorMeshes && (this._floorMeshesCollection = e.floorMeshes),
- e.teleportationMode && (this._teleportationMode = e.teleportationMode),
- e.teleportationTime && e.teleportationTime > 0 && (this._teleportationTime = e.teleportationTime),
- e.teleportationSpeed && e.teleportationSpeed > 0 && (this._teleportationSpeed = e.teleportationSpeed),
- e.easingFunction !== void 0 && (this._teleportationEasing = e.easingFunction),
- this._leftController != null && this._enableTeleportationOnController(this._leftController),
- this._rightController != null && this._enableTeleportationOnController(this._rightController);
- var d = new ImageProcessingConfiguration;
- d.vignetteColor = new Color4(0,0,0,0),
- d.vignetteEnabled = !0,
- this._postProcessMove = new ImageProcessingPostProcess("postProcessMove",1,this._webVRCamera,void 0,void 0,void 0,void 0,d),
- this._webVRCamera.detachPostProcess(this._postProcessMove),
- this._teleportationInitialized = !0,
- this._isDefaultTeleportationTarget && (this._createTeleportationCircles(),
- this._teleportationTarget.scaling.scaleInPlace(this._webVRCamera.deviceScaleFactor))
- }
- }
- ,
- a.prototype._enableInteractionOnController = function(e) {
- var i = this
- , o = e.webVRController.mesh;
- o && (e._interactionsEnabled = !0,
- this.isInVRMode && this._displayLaserPointer && e._activatePointer(),
- this.webVROptions.laserToggle && e.webVRController.onMainButtonStateChangedObservable.add(function(s) {
- i._displayLaserPointer && s.value === 1 && (e._activePointer ? e._deactivatePointer() : e._activatePointer(),
- i.displayGaze && (e._gazeTracker.isVisible = e._activePointer))
- }),
- e.webVRController.onTriggerStateChangedObservable.add(function(s) {
- var c = e;
- i._noControllerIsActive && (c = i._cameraGazer),
- c._pointerDownOnMeshAsked ? s.value < i._padSensibilityDown && c._selectionPointerUp() : s.value > i._padSensibilityUp && c._selectionPointerDown()
- }))
- }
- ,
- a.prototype._checkTeleportWithRay = function(e, i) {
- this._teleportationRequestInitiated && !i._teleportationRequestInitiated || (i._teleportationRequestInitiated ? Math.sqrt(e.y * e.y + e.x * e.x) < this._padSensibilityDown && (this._teleportActive && this.teleportCamera(this._haloCenter),
- i._teleportationRequestInitiated = !1) : e.y < -this._padSensibilityUp && i._dpadPressed && (i._activatePointer(),
- i._teleportationRequestInitiated = !0))
- }
- ,
- a.prototype._checkRotate = function(e, i) {
- i._teleportationRequestInitiated || (i._rotationLeftAsked ? e.x > -this._padSensibilityDown && (i._rotationLeftAsked = !1) : e.x < -this._padSensibilityUp && i._dpadPressed && (i._rotationLeftAsked = !0,
- this._rotationAllowed && this._rotateCamera(!1)),
- i._rotationRightAsked ? e.x < this._padSensibilityDown && (i._rotationRightAsked = !1) : e.x > this._padSensibilityUp && i._dpadPressed && (i._rotationRightAsked = !0,
- this._rotationAllowed && this._rotateCamera(!0)))
- }
- ,
- a.prototype._checkTeleportBackwards = function(e, i) {
- if (!i._teleportationRequestInitiated)
- if (e.y > this._padSensibilityUp && i._dpadPressed) {
- if (!i._teleportationBackRequestInitiated) {
- if (!this.currentVRCamera)
- return;
- var o = Quaternion.FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix())
- , s = this.currentVRCamera.position;
- this.currentVRCamera.devicePosition && this.currentVRCamera.deviceRotationQuaternion && (o = this.currentVRCamera.deviceRotationQuaternion,
- s = this.currentVRCamera.devicePosition),
- o.toEulerAnglesToRef(this._workingVector),
- this._workingVector.z = 0,
- this._workingVector.x = 0,
- Quaternion.RotationYawPitchRollToRef(this._workingVector.y, this._workingVector.x, this._workingVector.z, this._workingQuaternion),
- this._workingQuaternion.toRotationMatrix(this._workingMatrix),
- Vector3.TransformCoordinatesToRef(this._teleportBackwardsVector, this._workingMatrix, this._workingVector);
- var c = new Ray(s,this._workingVector)
- , d = this._scene.pickWithRay(c, this._raySelectionPredicate);
- d && d.pickedPoint && d.pickedMesh && this._isTeleportationFloor(d.pickedMesh) && d.distance < 5 && this.teleportCamera(d.pickedPoint),
- i._teleportationBackRequestInitiated = !0
- }
- } else
- i._teleportationBackRequestInitiated = !1
- }
- ,
- a.prototype._enableTeleportationOnController = function(e) {
- var i = this
- , o = e.webVRController.mesh;
- o && (e._interactionsEnabled || this._enableInteractionOnController(e),
- e._interactionsEnabled = !0,
- e._teleportationEnabled = !0,
- e.webVRController.controllerType === PoseEnabledControllerType.VIVE && (e._dpadPressed = !1,
- e.webVRController.onPadStateChangedObservable.add(function(s) {
- e._dpadPressed = s.pressed,
- e._dpadPressed || (e._rotationLeftAsked = !1,
- e._rotationRightAsked = !1,
- e._teleportationBackRequestInitiated = !1)
- })),
- e.webVRController.onPadValuesChangedObservable.add(function(s) {
- i.teleportationEnabled && (i._checkTeleportBackwards(s, e),
- i._checkTeleportWithRay(s, e)),
- i._checkRotate(s, e)
- }))
- }
- ,
- a.prototype._createTeleportationCircles = function() {
- this._teleportationTarget = CreateGround("teleportationTarget", {
- width: 2,
- height: 2,
- subdivisions: 2
- }, this._scene),
- this._teleportationTarget.isPickable = !1;
- var e = 512
- , i = new DynamicTexture("DynamicTexture",e,this._scene,!0);
- i.hasAlpha = !0;
- var o = i.getContext()
- , s = e / 2
- , c = e / 2
- , d = 200;
- o.beginPath(),
- o.arc(s, c, d, 0, 2 * Math.PI, !1),
- o.fillStyle = this._teleportationFillColor,
- o.fill(),
- o.lineWidth = 10,
- o.strokeStyle = this._teleportationBorderColor,
- o.stroke(),
- o.closePath(),
- i.update();
- var _ = new StandardMaterial("TextPlaneMaterial",this._scene);
- _.diffuseTexture = i,
- this._teleportationTarget.material = _;
- var b = CreateTorus("torusTeleportation", {
- diameter: .75,
- thickness: .1,
- tessellation: 25,
- updatable: !1
- }, this._scene);
- b.isPickable = !1,
- b.parent = this._teleportationTarget;
- var k = new Animation("animationInnerCircle","position.y",30,Animation.ANIMATIONTYPE_FLOAT,Animation.ANIMATIONLOOPMODE_CYCLE)
- , j = [];
- j.push({
- frame: 0,
- value: 0
- }),
- j.push({
- frame: 30,
- value: .4
- }),
- j.push({
- frame: 60,
- value: 0
- }),
- k.setKeys(j);
- var $ = new SineEase;
- $.setEasingMode(EasingFunction.EASINGMODE_EASEINOUT),
- k.setEasingFunction($),
- b.animations = [],
- b.animations.push(k),
- this._scene.beginAnimation(b, 0, 60, !0),
- this._hideTeleportationTarget()
- }
- ,
- a.prototype._displayTeleportationTarget = function() {
- this._teleportActive = !0,
- this._teleportationInitialized && (this._teleportationTarget.isVisible = !0,
- this._isDefaultTeleportationTarget && (this._teleportationTarget.getChildren()[0].isVisible = !0))
- }
- ,
- a.prototype._hideTeleportationTarget = function() {
- this._teleportActive = !1,
- this._teleportationInitialized && (this._teleportationTarget.isVisible = !1,
- this._isDefaultTeleportationTarget && (this._teleportationTarget.getChildren()[0].isVisible = !1))
- }
- ,
- a.prototype._rotateCamera = function(e) {
- var i = this;
- if (this.currentVRCamera instanceof FreeCamera) {
- e ? this._rotationAngle++ : this._rotationAngle--,
- this.currentVRCamera.animations = [];
- var o = Quaternion.FromRotationMatrix(Matrix.RotationY(Math.PI / 4 * this._rotationAngle))
- , s = new Animation("animationRotation","rotationQuaternion",90,Animation.ANIMATIONTYPE_QUATERNION,Animation.ANIMATIONLOOPMODE_CONSTANT)
- , c = [];
- c.push({
- frame: 0,
- value: this.currentVRCamera.rotationQuaternion
- }),
- c.push({
- frame: 6,
- value: o
- }),
- s.setKeys(c),
- s.setEasingFunction(this._circleEase),
- this.currentVRCamera.animations.push(s),
- this._postProcessMove.animations = [];
- var d = new Animation("animationPP","vignetteWeight",90,Animation.ANIMATIONTYPE_FLOAT,Animation.ANIMATIONLOOPMODE_CONSTANT)
- , _ = [];
- _.push({
- frame: 0,
- value: 0
- }),
- _.push({
- frame: 3,
- value: 4
- }),
- _.push({
- frame: 6,
- value: 0
- }),
- d.setKeys(_),
- d.setEasingFunction(this._circleEase),
- this._postProcessMove.animations.push(d);
- var b = new Animation("animationPP2","vignetteStretch",90,Animation.ANIMATIONTYPE_FLOAT,Animation.ANIMATIONLOOPMODE_CONSTANT)
- , k = [];
- k.push({
- frame: 0,
- value: 0
- }),
- k.push({
- frame: 3,
- value: 10
- }),
- k.push({
- frame: 6,
- value: 0
- }),
- b.setKeys(k),
- b.setEasingFunction(this._circleEase),
- this._postProcessMove.animations.push(b),
- this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0,
- this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0,
- this._postProcessMove.samples = 4,
- this._webVRCamera.attachPostProcess(this._postProcessMove),
- this._scene.beginAnimation(this._postProcessMove, 0, 6, !1, 1, function() {
- i._webVRCamera.detachPostProcess(i._postProcessMove)
- }),
- this._scene.beginAnimation(this.currentVRCamera, 0, 6, !1, 1)
- }
- }
- ,
- a.prototype._moveTeleportationSelectorTo = function(e, i, o) {
- if (e.pickedPoint) {
- i._teleportationRequestInitiated && (this._displayTeleportationTarget(),
- this._haloCenter.copyFrom(e.pickedPoint),
- this._teleportationTarget.position.copyFrom(e.pickedPoint));
- var s = this._convertNormalToDirectionOfRay(e.getNormal(!0, !1), o);
- if (s) {
- var c = Vector3.Cross(Axis.Y, s)
- , d = Vector3.Cross(s, c);
- Vector3.RotationFromAxisToRef(d, s, c, this._teleportationTarget.rotation)
- }
- this._teleportationTarget.position.y += .1
- }
- }
- ,
- a.prototype.teleportCamera = function(e) {
- var i = this;
- if (this.currentVRCamera instanceof FreeCamera) {
- this.webVRCamera.leftCamera ? (this._workingVector.copyFrom(this.webVRCamera.leftCamera.globalPosition),
- this._workingVector.subtractInPlace(this.webVRCamera.position),
- e.subtractToRef(this._workingVector, this._workingVector)) : this._workingVector.copyFrom(e),
- this.isInVRMode ? this._workingVector.y += this.webVRCamera.deviceDistanceToRoomGround() * this._webVRCamera.deviceScaleFactor : this._workingVector.y += this._defaultHeight,
- this.onBeforeCameraTeleport.notifyObservers(this._workingVector);
- var o = 90, s, c;
- if (this._teleportationMode == a.TELEPORTATIONMODE_CONSTANTSPEED) {
- c = o;
- var d = Vector3.Distance(this.currentVRCamera.position, this._workingVector);
- s = this._teleportationSpeed / d
- } else
- c = Math.round(this._teleportationTime * o / 1e3),
- s = 1;
- this.currentVRCamera.animations = [];
- var _ = new Animation("animationCameraTeleportation","position",o,Animation.ANIMATIONTYPE_VECTOR3,Animation.ANIMATIONLOOPMODE_CONSTANT)
- , b = [{
- frame: 0,
- value: this.currentVRCamera.position
- }, {
- frame: c,
- value: this._workingVector
- }];
- _.setKeys(b),
- _.setEasingFunction(this._teleportationEasing),
- this.currentVRCamera.animations.push(_),
- this._postProcessMove.animations = [];
- var k = Math.round(c / 2)
- , j = new Animation("animationPP","vignetteWeight",o,Animation.ANIMATIONTYPE_FLOAT,Animation.ANIMATIONLOOPMODE_CONSTANT)
- , $ = [];
- $.push({
- frame: 0,
- value: 0
- }),
- $.push({
- frame: k,
- value: 8
- }),
- $.push({
- frame: c,
- value: 0
- }),
- j.setKeys($),
- this._postProcessMove.animations.push(j);
- var _e = new Animation("animationPP2","vignetteStretch",o,Animation.ANIMATIONTYPE_FLOAT,Animation.ANIMATIONLOOPMODE_CONSTANT)
- , et = [];
- et.push({
- frame: 0,
- value: 0
- }),
- et.push({
- frame: k,
- value: 10
- }),
- et.push({
- frame: c,
- value: 0
- }),
- _e.setKeys(et),
- this._postProcessMove.animations.push(_e),
- this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0,
- this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0,
- this._webVRCamera.attachPostProcess(this._postProcessMove),
- this._scene.beginAnimation(this._postProcessMove, 0, c, !1, s, function() {
- i._webVRCamera.detachPostProcess(i._postProcessMove)
- }),
- this._scene.beginAnimation(this.currentVRCamera, 0, c, !1, s, function() {
- i.onAfterCameraTeleport.notifyObservers(i._workingVector)
- }),
- this._hideTeleportationTarget()
- }
- }
- ,
- a.prototype._convertNormalToDirectionOfRay = function(e, i) {
- if (e) {
- var o = Math.acos(Vector3.Dot(e, i.direction));
- o < Math.PI / 2 && e.scaleInPlace(-1)
- }
- return e
- }
- ,
- a.prototype._castRayAndSelectObject = function(e) {
- if (this.currentVRCamera instanceof FreeCamera) {
- var i = e._getForwardRay(this._rayLength)
- , o = this._scene.pickWithRay(i, this._raySelectionPredicate);
- if (o && this._scene.simulatePointerMove(o, {
- pointerId: e._id
- }),
- e._currentHit = o,
- o && o.pickedPoint) {
- if (this._displayGaze) {
- var s = 1;
- e._gazeTracker.isVisible = !0,
- e._isActionableMesh && (s = 3),
- this.updateGazeTrackerScale && (e._gazeTracker.scaling.x = o.distance * s,
- e._gazeTracker.scaling.y = o.distance * s,
- e._gazeTracker.scaling.z = o.distance * s);
- var c = this._convertNormalToDirectionOfRay(o.getNormal(), i)
- , d = .002;
- if (c) {
- var _ = Vector3.Cross(Axis.Y, c)
- , b = Vector3.Cross(c, _);
- Vector3.RotationFromAxisToRef(b, c, _, e._gazeTracker.rotation)
- }
- e._gazeTracker.position.copyFrom(o.pickedPoint),
- e._gazeTracker.position.x < 0 ? e._gazeTracker.position.x += d : e._gazeTracker.position.x -= d,
- e._gazeTracker.position.y < 0 ? e._gazeTracker.position.y += d : e._gazeTracker.position.y -= d,
- e._gazeTracker.position.z < 0 ? e._gazeTracker.position.z += d : e._gazeTracker.position.z -= d
- }
- e._updatePointerDistance(o.distance)
- } else
- e._updatePointerDistance(),
- e._gazeTracker.isVisible = !1;
- if (o && o.pickedMesh) {
- if (this._teleportationInitialized && this._isTeleportationFloor(o.pickedMesh) && o.pickedPoint) {
- e._currentMeshSelected && !this._isTeleportationFloor(e._currentMeshSelected) && this._notifySelectedMeshUnselected(e._currentMeshSelected),
- e._currentMeshSelected = null,
- e._teleportationRequestInitiated && this._moveTeleportationSelectorTo(o, e, i);
- return
- }
- if (o.pickedMesh !== e._currentMeshSelected)
- if (this.meshSelectionPredicate(o.pickedMesh)) {
- this.onNewMeshPicked.notifyObservers(o),
- e._currentMeshSelected = o.pickedMesh,
- o.pickedMesh.isPickable && o.pickedMesh.actionManager ? (this.changeGazeColor(this._pickedGazeColor),
- this.changeLaserColor(this._pickedLaserColor),
- e._isActionableMesh = !0) : (this.changeGazeColor(this._gazeColor),
- this.changeLaserColor(this._laserColor),
- e._isActionableMesh = !1);
- try {
- this.onNewMeshSelected.notifyObservers(o.pickedMesh);
- var k = e;
- k.webVRController && this.onMeshSelectedWithController.notifyObservers({
- mesh: o.pickedMesh,
- controller: k.webVRController
- })
- } catch (j) {
- Logger$2.Warn("Error while raising onNewMeshSelected or onMeshSelectedWithController: " + j)
- }
- } else
- this._notifySelectedMeshUnselected(e._currentMeshSelected),
- e._currentMeshSelected = null,
- this.changeGazeColor(this._gazeColor),
- this.changeLaserColor(this._laserColor)
- } else
- this._notifySelectedMeshUnselected(e._currentMeshSelected),
- e._currentMeshSelected = null,
- this.changeGazeColor(this._gazeColor),
- this.changeLaserColor(this._laserColor)
- }
- }
- ,
- a.prototype._notifySelectedMeshUnselected = function(e) {
- e && this.onSelectedMeshUnselected.notifyObservers(e)
- }
- ,
- a.prototype.setLaserColor = function(e, i) {
- i === void 0 && (i = this._pickedLaserColor),
- this._laserColor = e,
- this._pickedLaserColor = i
- }
- ,
- a.prototype.setLaserLightingState = function(e) {
- e === void 0 && (e = !0),
- this._leftController && this._leftController._setLaserPointerLightingDisabled(!e),
- this._rightController && this._rightController._setLaserPointerLightingDisabled(!e)
- }
- ,
- a.prototype.setGazeColor = function(e, i) {
- i === void 0 && (i = this._pickedGazeColor),
- this._gazeColor = e,
- this._pickedGazeColor = i
- }
- ,
- a.prototype.changeLaserColor = function(e) {
- !this.updateControllerLaserColor || (this._leftController && this._leftController._setLaserPointerColor(e),
- this._rightController && this._rightController._setLaserPointerColor(e))
- }
- ,
- a.prototype.changeGazeColor = function(e) {
- !this.updateGazeTrackerColor || !this._cameraGazer._gazeTracker.material || (this._cameraGazer._gazeTracker.material.emissiveColor = e,
- this._leftController && (this._leftController._gazeTracker.material.emissiveColor = e),
- this._rightController && (this._rightController._gazeTracker.material.emissiveColor = e))
- }
- ,
- a.prototype.dispose = function() {
- this.isInVRMode && this.exitVR(),
- this._postProcessMove && this._postProcessMove.dispose(),
- this._webVRCamera && this._webVRCamera.dispose(),
- this._vrDeviceOrientationCamera && this._vrDeviceOrientationCamera.dispose(),
- !this._useCustomVRButton && this._btnVR && this._btnVR.parentNode && document.body.removeChild(this._btnVR),
- this._deviceOrientationCamera && this._scene.activeCamera != this._deviceOrientationCamera && this._deviceOrientationCamera.dispose(),
- this._cameraGazer && this._cameraGazer.dispose(),
- this._leftController && this._leftController.dispose(),
- this._rightController && this._rightController.dispose(),
- this._teleportationTarget && this._teleportationTarget.dispose(),
- this.xr && this.xr.dispose(),
- this._floorMeshesCollection = [],
- document.removeEventListener("keydown", this._onKeyDown),
- window.removeEventListener("vrdisplaypresentchange", this._onVrDisplayPresentChange),
- window.removeEventListener("resize", this._onResize),
- document.removeEventListener("fullscreenchange", this._onFullscreenChange),
- document.removeEventListener("mozfullscreenchange", this._onFullscreenChange),
- document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange),
- document.removeEventListener("msfullscreenchange", this._onFullscreenChange),
- document.onmsfullscreenchange = null,
- this._scene.getEngine().onVRDisplayChangedObservable.removeCallback(this._onVRDisplayChanged),
- this._scene.getEngine().onVRRequestPresentStart.removeCallback(this._onVRRequestPresentStart),
- this._scene.getEngine().onVRRequestPresentComplete.removeCallback(this._onVRRequestPresentComplete),
- window.removeEventListener("vrdisplaypresentchange", this._onVrDisplayPresentChange),
- this._scene.gamepadManager.onGamepadConnectedObservable.removeCallback(this._onNewGamepadConnected),
- this._scene.gamepadManager.onGamepadDisconnectedObservable.removeCallback(this._onNewGamepadDisconnected),
- this._scene.unregisterBeforeRender(this.beforeRender)
- }
- ,
- a.prototype.getClassName = function() {
- return "VRExperienceHelper"
- }
- ,
- a.TELEPORTATIONMODE_CONSTANTTIME = 0,
- a.TELEPORTATIONMODE_CONSTANTSPEED = 1,
- a
- }()
- , _ENVTextureLoader = function() {
- function a() {
- this.supportCascades = !1
- }
- return a.prototype.canLoad = function(e) {
- return EndsWith(e, ".env")
- }
- ,
- a.prototype.loadCubeData = function(e, i, o, s, c) {
- if (!Array.isArray(e)) {
- var d = GetEnvInfo(e);
- if (d) {
- i.width = d.width,
- i.height = d.width;
- try {
- UploadEnvSpherical(i, d),
- UploadEnvLevelsAsync(i, e, d).then(function() {
- i.isReady = !0,
- i.onLoadedObservable.notifyObservers(i),
- i.onLoadedObservable.clear(),
- s && s()
- }, function(_) {
- c == null || c("Can not upload environment levels", _)
- })
- } catch (_) {
- c == null || c("Can not upload environment file", _)
- }
- } else
- c && c("Can not parse the environment file", null)
- }
- }
- ,
- a.prototype.loadData = function(e, i, o) {
- throw ".env not supported in 2d."
- }
- ,
- a
- }();
- Engine._TextureLoaders.push(new _ENVTextureLoader);
- var KhronosTextureContainer = function() {
- function a(e, i, o, s) {
- if (this.data = e,
- this.isInvalid = !1,
- !a.IsValid(e)) {
- this.isInvalid = !0,
- Logger$2.Error("texture missing KTX identifier");
- return
- }
- var c = Uint32Array.BYTES_PER_ELEMENT
- , d = new DataView(this.data.buffer,this.data.byteOffset + 12,13 * c)
- , _ = d.getUint32(0, !0)
- , b = _ === 67305985;
- if (this.glType = d.getUint32(1 * c, b),
- this.glTypeSize = d.getUint32(2 * c, b),
- this.glFormat = d.getUint32(3 * c, b),
- this.glInternalFormat = d.getUint32(4 * c, b),
- this.glBaseInternalFormat = d.getUint32(5 * c, b),
- this.pixelWidth = d.getUint32(6 * c, b),
- this.pixelHeight = d.getUint32(7 * c, b),
- this.pixelDepth = d.getUint32(8 * c, b),
- this.numberOfArrayElements = d.getUint32(9 * c, b),
- this.numberOfFaces = d.getUint32(10 * c, b),
- this.numberOfMipmapLevels = d.getUint32(11 * c, b),
- this.bytesOfKeyValueData = d.getUint32(12 * c, b),
- this.glType !== 0) {
- Logger$2.Error("only compressed formats currently supported");
- return
- } else
- this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels);
- if (this.pixelHeight === 0 || this.pixelDepth !== 0) {
- Logger$2.Error("only 2D textures currently supported");
- return
- }
- if (this.numberOfArrayElements !== 0) {
- Logger$2.Error("texture arrays not currently supported");
- return
- }
- if (this.numberOfFaces !== i) {
- Logger$2.Error("number of faces expected" + i + ", but found " + this.numberOfFaces);
- return
- }
- this.loadType = a.COMPRESSED_2D
- }
- return a.prototype.uploadLevels = function(e, i) {
- switch (this.loadType) {
- case a.COMPRESSED_2D:
- this._upload2DCompressedLevels(e, i);
- break
- }
- }
- ,
- a.prototype._upload2DCompressedLevels = function(e, i) {
- for (var o = a.HEADER_LEN + this.bytesOfKeyValueData, s = this.pixelWidth, c = this.pixelHeight, d = i ? this.numberOfMipmapLevels : 1, _ = 0; _ < d; _++) {
- var b = new Int32Array(this.data.buffer,this.data.byteOffset + o,1)[0];
- o += 4;
- for (var k = 0; k < this.numberOfFaces; k++) {
- var j = new Uint8Array(this.data.buffer,this.data.byteOffset + o,b)
- , $ = e.getEngine();
- $._uploadCompressedDataToTextureDirectly(e, this.glInternalFormat, s, c, j, k, _),
- o += b,
- o += 3 - (b + 3) % 4
- }
- s = Math.max(1, s * .5),
- c = Math.max(1, c * .5)
- }
- }
- ,
- a.IsValid = function(e) {
- if (e.byteLength >= 12) {
- var i = new Uint8Array(e.buffer,e.byteOffset,12);
- 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)
- return !0
- }
- return !1
- }
- ,
- a.HEADER_LEN = 12 + 13 * 4,
- a.COMPRESSED_2D = 0,
- a.COMPRESSED_3D = 1,
- a.TEX_2D = 2,
- a.TEX_3D = 3,
- a
- }()
- , KhronosTextureContainer2 = function() {
- function a(e, i) {
- i === void 0 && (i = a.DefaultNumWorkers),
- this._engine = e,
- a._Initialized || a._CreateWorkerPool(i)
- }
- return a.GetDefaultNumWorkers = function() {
- return typeof navigator != "object" || !navigator.hardwareConcurrency ? 1 : Math.min(Math.floor(navigator.hardwareConcurrency * .5), 4)
- }
- ,
- a._CreateWorkerPool = function(e) {
- this._Initialized = !0,
- e && typeof Worker == "function" ? a._WorkerPoolPromise = new Promise(function(i) {
- for (var o = "(" + workerFunc + ")()", s = URL.createObjectURL(new Blob([o],{
- type: "application/javascript"
- })), c = new Array(e), d = 0; d < c.length; d++)
- c[d] = new Promise(function(_, b) {
- var k = new Worker(s)
- , j = function(_e) {
- k.removeEventListener("error", j),
- k.removeEventListener("message", $),
- b(_e)
- }
- , $ = function(_e) {
- _e.data.action === "init" && (k.removeEventListener("error", j),
- k.removeEventListener("message", $),
- _(k))
- };
- k.addEventListener("error", j),
- k.addEventListener("message", $),
- k.postMessage({
- action: "init",
- urls: a.URLConfig
- })
- }
- );
- Promise.all(c).then(function(_) {
- i(new WorkerPool(_))
- })
- }
- ) : typeof KTX2DECODER == "undefined" ? a._NoWorkerPromise = Tools.LoadScriptAsync(a.URLConfig.jsDecoderModule).then(function() {
- KTX2DECODER.MSCTranscoder.UseFromWorkerThread = !1,
- KTX2DECODER.WASMMemoryManager.LoadBinariesFromCurrentThread = !0;
- var i = a.URLConfig;
- i.wasmUASTCToASTC !== null && (KTX2DECODER.LiteTranscoder_UASTC_ASTC.WasmModuleURL = i.wasmUASTCToASTC),
- i.wasmUASTCToBC7 !== null && (KTX2DECODER.LiteTranscoder_UASTC_BC7.WasmModuleURL = i.wasmUASTCToBC7),
- i.wasmUASTCToRGBA_UNORM !== null && (KTX2DECODER.LiteTranscoder_UASTC_RGBA_UNORM.WasmModuleURL = i.wasmUASTCToRGBA_UNORM),
- i.wasmUASTCToRGBA_SRGB !== null && (KTX2DECODER.LiteTranscoder_UASTC_RGBA_SRGB.WasmModuleURL = i.wasmUASTCToRGBA_SRGB),
- i.jsMSCTranscoder !== null && (KTX2DECODER.MSCTranscoder.JSModuleURL = i.jsMSCTranscoder),
- i.wasmMSCTranscoder !== null && (KTX2DECODER.MSCTranscoder.WasmModuleURL = i.wasmMSCTranscoder),
- i.wasmZSTDDecoder !== null && (KTX2DECODER.ZSTDDecoder.WasmModuleURL = i.wasmZSTDDecoder)
- }) : (KTX2DECODER.MSCTranscoder.UseFromWorkerThread = !1,
- KTX2DECODER.WASMMemoryManager.LoadBinariesFromCurrentThread = !0)
- }
- ,
- a.prototype.uploadAsync = function(e, i, o) {
- var s = this
- , c = this._engine.getCaps()
- , d = {
- astc: !!c.astc,
- bptc: !!c.bptc,
- s3tc: !!c.s3tc,
- pvrtc: !!c.pvrtc,
- etc2: !!c.etc2,
- etc1: !!c.etc1
- };
- return a._WorkerPoolPromise ? a._WorkerPoolPromise.then(function(_) {
- return new Promise(function(b, k) {
- _.push(function(j, $) {
- var _e = function(tt) {
- j.removeEventListener("error", _e),
- j.removeEventListener("message", et),
- k(tt),
- $()
- }
- , et = function(tt) {
- if (tt.data.action === "decoded") {
- if (j.removeEventListener("error", _e),
- j.removeEventListener("message", et),
- !tt.data.success)
- k({
- message: tt.data.msg
- });
- else
- try {
- s._createTexture(tt.data.decodedData, i, o),
- b()
- } catch (rt) {
- k({
- message: rt
- })
- }
- $()
- }
- };
- j.addEventListener("error", _e),
- j.addEventListener("message", et),
- j.postMessage({
- action: "decode",
- data: e,
- caps: d,
- options: o
- })
- })
- }
- )
- }) : a._NoWorkerPromise ? a._NoWorkerPromise.then(function() {
- return new Promise(function(_, b) {
- a._Ktx2Decoder || (a._Ktx2Decoder = new KTX2DECODER.KTX2Decoder),
- a._Ktx2Decoder.decode(e, c).then(function(k) {
- s._createTexture(k, i),
- _()
- }).catch(function(k) {
- b({
- message: k
- })
- })
- }
- )
- }) : new Promise(function(_, b) {
- a._Ktx2Decoder || (a._Ktx2Decoder = new KTX2DECODER.KTX2Decoder),
- a._Ktx2Decoder.decode(e, c).then(function(k) {
- s._createTexture(k, i),
- _()
- }).catch(function(k) {
- b({
- message: k
- })
- })
- }
- )
- }
- ,
- a.prototype.dispose = function() {
- a._WorkerPoolPromise && a._WorkerPoolPromise.then(function(e) {
- e.dispose()
- }),
- delete a._WorkerPoolPromise,
- delete a._NoWorkerPromise
- }
- ,
- a.prototype._createTexture = function(e, i, o) {
- var s = 3553;
- if (this._engine._bindTextureDirectly(s, i),
- o && (o.transcodedFormat = e.transcodedFormat,
- o.isInGammaSpace = e.isInGammaSpace,
- o.hasAlpha = e.hasAlpha,
- o.transcoderName = e.transcoderName),
- e.transcodedFormat === 32856 ? (i.type = 0,
- i.format = 5) : i.format = e.transcodedFormat,
- i._gammaSpace = e.isInGammaSpace,
- i.generateMipMaps = e.mipmaps.length > 1,
- e.errors)
- throw new Error("KTX2 container - could not transcode the data. " + e.errors);
- for (var c = 0; c < e.mipmaps.length; ++c) {
- var d = e.mipmaps[c];
- if (!d || !d.data)
- throw new Error("KTX2 container - could not transcode one of the image");
- e.transcodedFormat === 32856 ? (i.width = d.width,
- i.height = d.height,
- 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)
- }
- i._extension = ".ktx2",
- i.width = e.mipmaps[0].width,
- i.height = e.mipmaps[0].height,
- i.isReady = !0,
- this._engine._bindTextureDirectly(s, null)
- }
- ,
- a.IsValid = function(e) {
- if (e.byteLength >= 12) {
- var i = new Uint8Array(e.buffer,e.byteOffset,12);
- 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)
- return !0
- }
- return !1
- }
- ,
- a.URLConfig = {
- jsDecoderModule: "https://app-asset-1258211750.file.myqcloud.com/4/ktx2/ktx2decoder/babylon.ktx2Decoder.js",
- wasmUASTCToASTC: "https://app-asset-1258211750.file.myqcloud.com/4/ktx2/ktx2decoder/ktx2Transcoders/uastc_astc.wasm",
- wasmUASTCToBC7: "https://app-asset-1258211750.file.myqcloud.com/4/ktx2/ktx2decoder/ktx2Transcoders/uastc_bc7.wasm",
- wasmUASTCToRGBA_UNORM: "https://app-asset-1258211750.file.myqcloud.com/4/ktx2/ktx2decoder/ktx2Transcoders/uastc_rgba32_unorm.wasm",
- wasmUASTCToRGBA_SRGB: "https://app-asset-1258211750.file.myqcloud.com/4/ktx2/ktx2decoder/ktx2Transcoders/uastc_rgba32_srgb.wasm",
- jsMSCTranscoder: "https://app-asset-1258211750.file.myqcloud.com/4/ktx2/ktx2decoder/ktx2Transcoders/msc_basis_transcoder.js",
- wasmMSCTranscoder: "https://app-asset-1258211750.file.myqcloud.com/4/ktx2/ktx2decoder/ktx2Transcoders/msc_basis_transcoder.wasm",
- wasmZSTDDecoder: null
- },
- a.DefaultNumWorkers = a.GetDefaultNumWorkers(),
- a
- }();
- function workerFunc() {
- var a;
- onmessage = function(e) {
- if (!!e.data)
- switch (e.data.action) {
- case "init":
- var i = e.data.urls;
- importScripts(i.jsDecoderModule),
- i.wasmUASTCToASTC !== null && (KTX2DECODER.LiteTranscoder_UASTC_ASTC.WasmModuleURL = i.wasmUASTCToASTC),
- i.wasmUASTCToBC7 !== null && (KTX2DECODER.LiteTranscoder_UASTC_BC7.WasmModuleURL = i.wasmUASTCToBC7),
- i.wasmUASTCToRGBA_UNORM !== null && (KTX2DECODER.LiteTranscoder_UASTC_RGBA_UNORM.WasmModuleURL = i.wasmUASTCToRGBA_UNORM),
- i.wasmUASTCToRGBA_SRGB !== null && (KTX2DECODER.LiteTranscoder_UASTC_RGBA_SRGB.WasmModuleURL = i.wasmUASTCToRGBA_SRGB),
- i.jsMSCTranscoder !== null && (KTX2DECODER.MSCTranscoder.JSModuleURL = i.jsMSCTranscoder),
- i.wasmMSCTranscoder !== null && (KTX2DECODER.MSCTranscoder.WasmModuleURL = i.wasmMSCTranscoder),
- i.wasmZSTDDecoder !== null && (KTX2DECODER.ZSTDDecoder.WasmModuleURL = i.wasmZSTDDecoder),
- a = new KTX2DECODER.KTX2Decoder,
- postMessage({
- action: "init"
- });
- break;
- case "decode":
- a.decode(e.data.data, e.data.caps, e.data.options).then(function(o) {
- for (var s = [], c = 0; c < o.mipmaps.length; ++c) {
- var d = o.mipmaps[c];
- d && d.data && s.push(d.data.buffer)
- }
- postMessage({
- action: "decoded",
- success: !0,
- decodedData: o
- }, s)
- }).catch(function(o) {
- postMessage({
- action: "decoded",
- success: !1,
- msg: o
- })
- });
- break
- }
- }
- }
- var _KTXTextureLoader = function() {
- function a() {
- this.supportCascades = !1
- }
- return a.prototype.canLoad = function(e, i) {
- return EndsWith(e, ".ktx") || EndsWith(e, ".ktx2") || i === "image/ktx" || i === "image/ktx2"
- }
- ,
- a.prototype.loadCubeData = function(e, i, o, s, c) {
- if (!Array.isArray(e)) {
- i._invertVScale = !i.invertY;
- var d = i.getEngine()
- , _ = new KhronosTextureContainer(e,6)
- , b = _.numberOfMipmapLevels > 1 && i.generateMipMaps;
- d._unpackFlipY(!0),
- _.uploadLevels(i, i.generateMipMaps),
- i.width = _.pixelWidth,
- i.height = _.pixelHeight,
- d._setCubeMapTextureParams(i, b),
- i.isReady = !0,
- i.onLoadedObservable.notifyObservers(i),
- i.onLoadedObservable.clear(),
- s && s()
- }
- }
- ,
- a.prototype.loadData = function(e, i, o, s) {
- if (KhronosTextureContainer.IsValid(e)) {
- i._invertVScale = !i.invertY;
- var c = new KhronosTextureContainer(e,1);
- o(c.pixelWidth, c.pixelHeight, i.generateMipMaps, !0, function() {
- c.uploadLevels(i, i.generateMipMaps)
- }, c.isInvalid)
- } else if (KhronosTextureContainer2.IsValid(e)) {
- var d = new KhronosTextureContainer2(i.getEngine());
- d.uploadAsync(e, i, s).then(function() {
- o(i.width, i.height, i.generateMipMaps, !0, function() {}, !1)
- }, function(_) {
- Logger$2.Warn("Failed to load KTX2 texture data: " + _.message),
- o(0, 0, !1, !1, function() {}, !0)
- })
- } else
- Logger$2.Error("texture missing KTX identifier"),
- o(0, 0, !1, !1, function() {}, !0)
- }
- ,
- a
- }();
- Engine._TextureLoaders.unshift(new _KTXTextureLoader);
- var WebXRCamera = function(a) {
- __extends(e, a);
- function e(i, o, s) {
- var c = a.call(this, i, Vector3.Zero(), o) || this;
- return c._xrSessionManager = s,
- c._firstFrame = !1,
- c._referenceQuaternion = Quaternion.Identity(),
- c._referencedPosition = new Vector3,
- c._trackingState = WebXRTrackingState.NOT_TRACKING,
- c.onBeforeCameraTeleport = new Observable,
- c.onAfterCameraTeleport = new Observable,
- c.onTrackingStateChanged = new Observable,
- c.compensateOnFirstFrame = !0,
- c._rotate180 = new Quaternion(0,1,0,0),
- c.minZ = .1,
- c.rotationQuaternion = new Quaternion,
- c.cameraRigMode = Camera$1.RIG_MODE_CUSTOM,
- c.updateUpVectorFromRotation = !0,
- c._updateNumberOfRigCameras(1),
- c.freezeProjectionMatrix(),
- c._xrSessionManager.onXRSessionInit.add(function() {
- c._referencedPosition.copyFromFloats(0, 0, 0),
- c._referenceQuaternion.copyFromFloats(0, 0, 0, 1),
- c._firstFrame = c.compensateOnFirstFrame
- }),
- c._xrSessionManager.onXRFrameObservable.add(function(d) {
- c._firstFrame && c._updateFromXRSession(),
- c._updateReferenceSpace(),
- c._updateFromXRSession()
- }, void 0, !0),
- c
- }
- return Object.defineProperty(e.prototype, "trackingState", {
- get: function() {
- return this._trackingState
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._setTrackingState = function(i) {
- this._trackingState !== i && (this._trackingState = i,
- this.onTrackingStateChanged.notifyObservers(i))
- }
- ,
- Object.defineProperty(e.prototype, "realWorldHeight", {
- get: function() {
- var i = this._xrSessionManager.currentFrame && this._xrSessionManager.currentFrame.getViewerPose(this._xrSessionManager.baseReferenceSpace);
- return i && i.transform ? i.transform.position.y : 0
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._updateForDualEyeDebugging = function() {
- this._updateNumberOfRigCameras(2),
- this.rigCameras[0].viewport = new Viewport(0,0,.5,1),
- this.rigCameras[0].outputRenderTarget = null,
- this.rigCameras[1].viewport = new Viewport(.5,0,.5,1),
- this.rigCameras[1].outputRenderTarget = null
- }
- ,
- e.prototype.setTransformationFromNonVRCamera = function(i, o) {
- if (i === void 0 && (i = this.getScene().activeCamera),
- o === void 0 && (o = !0),
- !(!i || i === this)) {
- var s = i.computeWorldMatrix();
- s.decompose(void 0, this.rotationQuaternion, this.position),
- this.position.y = 0,
- Quaternion.FromEulerAnglesToRef(0, this.rotationQuaternion.toEulerAngles().y, 0, this.rotationQuaternion),
- this._firstFrame = !0,
- o && this._xrSessionManager.resetReferenceSpace()
- }
- }
- ,
- e.prototype.getClassName = function() {
- return "WebXRCamera"
- }
- ,
- e.prototype.dispose = function() {
- a.prototype.dispose.call(this),
- this._lastXRViewerPose = void 0
- }
- ,
- e.prototype._updateFromXRSession = function() {
- var i = this
- , o = this._xrSessionManager.currentFrame && this._xrSessionManager.currentFrame.getViewerPose(this._xrSessionManager.referenceSpace);
- if (this._lastXRViewerPose = o || void 0,
- !o) {
- this._setTrackingState(WebXRTrackingState.NOT_TRACKING);
- return
- }
- var s = o.emulatedPosition ? WebXRTrackingState.TRACKING_LOST : WebXRTrackingState.TRACKING;
- if (this._setTrackingState(s),
- o.transform) {
- var c = o.transform.orientation;
- if (o.transform.orientation.x === void 0)
- return;
- var d = o.transform.position;
- this._referencedPosition.set(d.x, d.y, d.z),
- this._referenceQuaternion.set(c.x, c.y, c.z, c.w),
- this._scene.useRightHandedSystem || (this._referencedPosition.z *= -1,
- this._referenceQuaternion.z *= -1,
- this._referenceQuaternion.w *= -1),
- this._firstFrame ? (this._firstFrame = !1,
- this.position.y += this._referencedPosition.y,
- this._referenceQuaternion.copyFromFloats(0, 0, 0, 1)) : (this.rotationQuaternion.copyFrom(this._referenceQuaternion),
- this.position.copyFrom(this._referencedPosition))
- }
- this.rigCameras.length !== o.views.length && this._updateNumberOfRigCameras(o.views.length),
- o.views.forEach(function(_, b) {
- var k = i.rigCameras[b];
- !k.isLeftCamera && !k.isRightCamera && (_.eye === "right" ? k._isRightCamera = !0 : _.eye === "left" && (k._isLeftCamera = !0));
- var j = _.transform.position
- , $ = _.transform.orientation;
- if (k.parent = i.parent,
- k.position.set(j.x, j.y, j.z),
- k.rotationQuaternion.set($.x, $.y, $.z, $.w),
- i._scene.useRightHandedSystem ? k.rotationQuaternion.multiplyInPlace(i._rotate180) : (k.position.z *= -1,
- k.rotationQuaternion.z *= -1,
- k.rotationQuaternion.w *= -1),
- Matrix.FromFloat32ArrayToRefScaled(_.projectionMatrix, 0, 1, k._projectionMatrix),
- i._scene.useRightHandedSystem || k._projectionMatrix.toggleProjectionMatrixHandInPlace(),
- b === 0 && i._projectionMatrix.copyFrom(k._projectionMatrix),
- i._xrSessionManager.session.renderState.baseLayer) {
- var _e = i._xrSessionManager.session.renderState.baseLayer.getViewport(_)
- , et = i._xrSessionManager.session.renderState.baseLayer.framebufferWidth
- , tt = i._xrSessionManager.session.renderState.baseLayer.framebufferHeight;
- k.viewport.width = _e.width / et,
- k.viewport.height = _e.height / tt,
- k.viewport.x = _e.x / et,
- k.viewport.y = _e.y / tt
- }
- k.outputRenderTarget = i._xrSessionManager.getRenderTargetTextureForEye(_.eye)
- })
- }
- ,
- e.prototype._updateNumberOfRigCameras = function(i) {
- for (i === void 0 && (i = 1); this.rigCameras.length < i; ) {
- var o = new TargetCamera("XR-RigCamera: " + this.rigCameras.length,Vector3.Zero(),this.getScene());
- o.minZ = .1,
- o.rotationQuaternion = new Quaternion,
- o.updateUpVectorFromRotation = !0,
- o.isRigCamera = !0,
- o.rigParent = this,
- o.freezeProjectionMatrix(),
- this.rigCameras.push(o)
- }
- for (; this.rigCameras.length > i; ) {
- var s = this.rigCameras.pop();
- s && s.dispose()
- }
- }
- ,
- e.prototype._updateReferenceSpace = function() {
- if (!this.position.equals(this._referencedPosition) || !this.rotationQuaternion.equals(this._referenceQuaternion)) {
- var i = TmpVectors.Matrix[0]
- , o = TmpVectors.Matrix[1]
- , s = TmpVectors.Matrix[2];
- Matrix.ComposeToRef(e._ScaleReadOnly, this._referenceQuaternion, this._referencedPosition, i),
- Matrix.ComposeToRef(e._ScaleReadOnly, this.rotationQuaternion, this.position, o),
- i.invert().multiplyToRef(o, s),
- s.invert(),
- this._scene.useRightHandedSystem || s.toggleModelMatrixHandInPlace(),
- s.decompose(void 0, this._referenceQuaternion, this._referencedPosition);
- var c = new XRRigidTransform({
- x: this._referencedPosition.x,
- y: this._referencedPosition.y,
- z: this._referencedPosition.z
- },{
- x: this._referenceQuaternion.x,
- y: this._referenceQuaternion.y,
- z: this._referenceQuaternion.z,
- w: this._referenceQuaternion.w
- });
- this._xrSessionManager.referenceSpace = this._xrSessionManager.referenceSpace.getOffsetReferenceSpace(c)
- }
- }
- ,
- e._ScaleReadOnly = Vector3.One(),
- e
- }(FreeCamera), _a, WebXRFeatureName = function() {
- function a() {}
- return a.ANCHOR_SYSTEM = "xr-anchor-system",
- a.BACKGROUND_REMOVER = "xr-background-remover",
- a.HIT_TEST = "xr-hit-test",
- a.MESH_DETECTION = "xr-mesh-detection",
- a.PHYSICS_CONTROLLERS = "xr-physics-controller",
- a.PLANE_DETECTION = "xr-plane-detection",
- a.POINTER_SELECTION = "xr-controller-pointer-selection",
- a.TELEPORTATION = "xr-controller-teleportation",
- a.FEATURE_POINTS = "xr-feature-points",
- a.HAND_TRACKING = "xr-hand-tracking",
- a.IMAGE_TRACKING = "xr-image-tracking",
- a.NEAR_INTERACTION = "xr-near-interaction",
- a.DOM_OVERLAY = "xr-dom-overlay",
- a.MOVEMENT = "xr-controller-movement",
- a.LIGHT_ESTIMATION = "xr-light-estimation",
- a.EYE_TRACKING = "xr-eye-tracking",
- a.WALKING_LOCOMOTION = "xr-walking-locomotion",
- a
- }(), WebXRFeaturesManager = function() {
- function a(e) {
- var i = this;
- this._xrSessionManager = e,
- this._features = {},
- this._xrSessionManager.onXRSessionInit.add(function() {
- i.getEnabledFeatures().forEach(function(o) {
- var s = i._features[o];
- s.enabled && !s.featureImplementation.attached && !s.featureImplementation.disableAutoAttach && i.attachFeature(o)
- })
- }),
- this._xrSessionManager.onXRSessionEnded.add(function() {
- i.getEnabledFeatures().forEach(function(o) {
- var s = i._features[o];
- s.enabled && s.featureImplementation.attached && i.detachFeature(o)
- })
- })
- }
- return a.AddWebXRFeature = function(e, i, o, s) {
- o === void 0 && (o = 1),
- s === void 0 && (s = !1),
- this._AvailableFeatures[e] = this._AvailableFeatures[e] || {
- latest: o
- },
- o > this._AvailableFeatures[e].latest && (this._AvailableFeatures[e].latest = o),
- s && (this._AvailableFeatures[e].stable = o),
- this._AvailableFeatures[e][o] = i
- }
- ,
- a.ConstructFeature = function(e, i, o, s) {
- i === void 0 && (i = 1);
- var c = this._AvailableFeatures[e][i];
- if (!c)
- throw new Error("feature not found");
- return c(o, s)
- }
- ,
- a.GetAvailableFeatures = function() {
- return Object.keys(this._AvailableFeatures)
- }
- ,
- a.GetAvailableVersions = function(e) {
- return Object.keys(this._AvailableFeatures[e])
- }
- ,
- a.GetLatestVersionOfFeature = function(e) {
- return this._AvailableFeatures[e] && this._AvailableFeatures[e].latest || -1
- }
- ,
- a.GetStableVersionOfFeature = function(e) {
- return this._AvailableFeatures[e] && this._AvailableFeatures[e].stable || -1
- }
- ,
- a.prototype.attachFeature = function(e) {
- var i = this._features[e];
- i && i.enabled && !i.featureImplementation.attached && i.featureImplementation.attach()
- }
- ,
- a.prototype.detachFeature = function(e) {
- var i = this._features[e];
- i && i.featureImplementation.attached && i.featureImplementation.detach()
- }
- ,
- a.prototype.disableFeature = function(e) {
- var i = typeof e == "string" ? e : e.Name
- , o = this._features[i];
- return o && o.enabled ? (o.enabled = !1,
- this.detachFeature(i),
- o.featureImplementation.dispose(),
- delete this._features[i],
- !0) : !1
- }
- ,
- a.prototype.dispose = function() {
- var e = this;
- this.getEnabledFeatures().forEach(function(i) {
- e.disableFeature(i)
- })
- }
- ,
- a.prototype.enableFeature = function(e, i, o, s, c) {
- var d = this;
- i === void 0 && (i = "latest"),
- o === void 0 && (o = {}),
- s === void 0 && (s = !0),
- c === void 0 && (c = !0);
- var _ = typeof e == "string" ? e : e.Name
- , b = 0;
- if (typeof i == "string") {
- if (!i)
- throw new Error("Error in provided version - " + _ + " (" + i + ")");
- if (i === "stable" ? b = a.GetStableVersionOfFeature(_) : i === "latest" ? b = a.GetLatestVersionOfFeature(_) : b = +i,
- b === -1 || isNaN(b))
- throw new Error("feature not found - " + _ + " (" + i + ")")
- } else
- b = i;
- var k = a._ConflictingFeatures[_];
- if (k !== void 0 && this.getEnabledFeatures().indexOf(k) !== -1)
- throw new Error("Feature " + _ + " cannot be enabled while " + k + " is enabled.");
- var j = this._features[_]
- , $ = a.ConstructFeature(_, b, this._xrSessionManager, o);
- if (!$)
- throw new Error("feature not found - " + _);
- j && this.disableFeature(_);
- var _e = $();
- if (_e.dependsOn) {
- var et = _e.dependsOn.every(function(tt) {
- return !!d._features[tt]
- });
- if (!et)
- throw new Error("Dependant features missing. Make sure the following features are enabled - " + _e.dependsOn.join(", "))
- }
- if (_e.isCompatible())
- return this._features[_] = {
- featureImplementation: _e,
- enabled: !0,
- version: b,
- required: c
- },
- s ? this._xrSessionManager.session && !this._features[_].featureImplementation.attached && this.attachFeature(_) : this._features[_].featureImplementation.disableAutoAttach = !0,
- this._features[_].featureImplementation;
- if (c)
- throw new Error("required feature not compatible");
- return Tools.Warn("Feature " + _ + " not compatible with the current environment/browser and was not enabled."),
- _e
- }
- ,
- a.prototype.getEnabledFeature = function(e) {
- return this._features[e] && this._features[e].featureImplementation
- }
- ,
- a.prototype.getEnabledFeatures = function() {
- return Object.keys(this._features)
- }
- ,
- a.prototype._extendXRSessionInitObject = function(e) {
- return __awaiter(this, void 0, void 0, function() {
- var i, o, s, c, d, _, b;
- return __generator(this, function(k) {
- switch (k.label) {
- case 0:
- i = this.getEnabledFeatures(),
- o = 0,
- s = i,
- k.label = 1;
- case 1:
- return o < s.length ? (c = s[o],
- d = this._features[c],
- _ = d.featureImplementation.xrNativeFeatureName,
- _ && (d.required ? (e.requiredFeatures = e.requiredFeatures || [],
- e.requiredFeatures.indexOf(_) === -1 && e.requiredFeatures.push(_)) : (e.optionalFeatures = e.optionalFeatures || [],
- e.optionalFeatures.indexOf(_) === -1 && e.optionalFeatures.push(_))),
- d.featureImplementation.getXRSessionInitExtension ? [4, d.featureImplementation.getXRSessionInitExtension()] : [3, 3]) : [3, 4];
- case 2:
- b = k.sent(),
- e = __assign(__assign({}, e), b),
- k.label = 3;
- case 3:
- return o++,
- [3, 1];
- case 4:
- return [2, e]
- }
- })
- })
- }
- ,
- a._AvailableFeatures = {},
- a._ConflictingFeatures = (_a = {},
- _a[WebXRFeatureName.TELEPORTATION] = WebXRFeatureName.MOVEMENT,
- _a[WebXRFeatureName.MOVEMENT] = WebXRFeatureName.TELEPORTATION,
- _a),
- a
- }();
- Node$2.AddNodeConstructor("TouchCamera", function(a, e) {
- return function() {
- return new TouchCamera(a,Vector3.Zero(),e)
- }
- });
- var TouchCamera = function(a) {
- __extends(e, a);
- function e(i, o, s) {
- var c = a.call(this, i, o, s) || this;
- return c.inputs.addTouch(),
- c._setupInputs(),
- c
- }
- return Object.defineProperty(e.prototype, "touchAngularSensibility", {
- get: function() {
- var i = this.inputs.attached.touch;
- return i ? i.touchAngularSensibility : 0
- },
- set: function(i) {
- var o = this.inputs.attached.touch;
- o && (o.touchAngularSensibility = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "touchMoveSensibility", {
- get: function() {
- var i = this.inputs.attached.touch;
- return i ? i.touchMoveSensibility : 0
- },
- set: function(i) {
- var o = this.inputs.attached.touch;
- o && (o.touchMoveSensibility = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getClassName = function() {
- return "TouchCamera"
- }
- ,
- e.prototype._setupInputs = function() {
- var i = this.inputs.attached.touch
- , o = this.inputs.attached.mouse;
- o ? o.touchEnabled = !1 : i.allowMouse = !0
- }
- ,
- e
- }(FreeCamera);
- Node$2.AddNodeConstructor("FreeCamera", function(a, e) {
- return function() {
- return new UniversalCamera(a,Vector3.Zero(),e)
- }
- });
- var UniversalCamera = function(a) {
- __extends(e, a);
- function e(i, o, s) {
- var c = a.call(this, i, o, s) || this;
- return c.inputs.addGamepad(),
- c
- }
- return Object.defineProperty(e.prototype, "gamepadAngularSensibility", {
- get: function() {
- var i = this.inputs.attached.gamepad;
- return i ? i.gamepadAngularSensibility : 0
- },
- set: function(i) {
- var o = this.inputs.attached.gamepad;
- o && (o.gamepadAngularSensibility = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "gamepadMoveSensibility", {
- get: function() {
- var i = this.inputs.attached.gamepad;
- return i ? i.gamepadMoveSensibility : 0
- },
- set: function(i) {
- var o = this.inputs.attached.gamepad;
- o && (o.gamepadMoveSensibility = i)
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.getClassName = function() {
- return "UniversalCamera"
- }
- ,
- e
- }(TouchCamera);
- Camera$1._createDefaultParsedCamera = function(a, e) {
- return new UniversalCamera(a,Vector3.Zero(),e)
- }
- ;
- var WebXRExperienceHelper = function() {
- function a(e) {
- var i = this;
- this.scene = e,
- this._nonVRCamera = null,
- this._attachedToElement = !1,
- this._spectatorCamera = null,
- this._originalSceneAutoClear = !0,
- this._supported = !1,
- this._spectatorMode = !1,
- this.onInitialXRPoseSetObservable = new Observable,
- this.onStateChangedObservable = new Observable,
- this.state = WebXRState.NOT_IN_XR,
- this.sessionManager = new WebXRSessionManager(e),
- this.camera = new WebXRCamera("webxr",e,this.sessionManager),
- this.featuresManager = new WebXRFeaturesManager(this.sessionManager),
- e.onDisposeObservable.add(function() {
- i.exitXRAsync()
- })
- }
- return a.CreateAsync = function(e) {
- var i = new a(e);
- return i.sessionManager.initializeAsync().then(function() {
- return i._supported = !0,
- i
- }).catch(function(o) {
- throw i._setState(WebXRState.NOT_IN_XR),
- i.dispose(),
- o
- })
- }
- ,
- a.prototype.dispose = function() {
- var e;
- this.camera.dispose(),
- this.onStateChangedObservable.clear(),
- this.onInitialXRPoseSetObservable.clear(),
- this.sessionManager.dispose(),
- (e = this._spectatorCamera) === null || e === void 0 || e.dispose(),
- this._nonVRCamera && (this.scene.activeCamera = this._nonVRCamera)
- }
- ,
- a.prototype.enterXRAsync = function(e, i, o, s) {
- var c, d;
- return o === void 0 && (o = this.sessionManager.getWebXRRenderTarget()),
- s === void 0 && (s = {}),
- __awaiter(this, void 0, void 0, function() {
- var _, b = this;
- return __generator(this, function(k) {
- switch (k.label) {
- case 0:
- if (!this._supported)
- throw "WebXR not supported in this browser or environment";
- return this._setState(WebXRState.ENTERING_XR),
- i !== "viewer" && i !== "local" && (s.optionalFeatures = s.optionalFeatures || [],
- s.optionalFeatures.push(i)),
- [4, this.featuresManager._extendXRSessionInitObject(s)];
- case 1:
- s = k.sent(),
- e === "immersive-ar" && i !== "unbounded" && Logger$2.Warn("We recommend using 'unbounded' reference space type when using 'immersive-ar' session mode"),
- k.label = 2;
- case 2:
- return k.trys.push([2, 7, , 8]),
- [4, this.sessionManager.initializeSessionAsync(e, s)];
- case 3:
- return k.sent(),
- [4, this.sessionManager.setReferenceSpaceTypeAsync(i)];
- case 4:
- return k.sent(),
- [4, o.initializeXRLayerAsync(this.sessionManager.session)];
- case 5:
- return k.sent(),
- [4, this.sessionManager.updateRenderStateAsync({
- depthFar: this.camera.maxZ,
- depthNear: this.camera.minZ,
- baseLayer: o.xrLayer
- })];
- case 6:
- return k.sent(),
- this.sessionManager.runXRRenderLoop(),
- this._originalSceneAutoClear = this.scene.autoClear,
- this._nonVRCamera = this.scene.activeCamera,
- this._attachedToElement = !!(!((c = this._nonVRCamera) === null || c === void 0) && c.inputs.attachedToElement),
- (d = this._nonVRCamera) === null || d === void 0 || d.detachControl(),
- this.scene.activeCamera = this.camera,
- e !== "immersive-ar" ? this._nonXRToXRCamera() : (this.scene.autoClear = !1,
- this.camera.compensateOnFirstFrame = !1),
- this.sessionManager.onXRSessionEnded.addOnce(function() {
- b.camera.rigCameras.forEach(function(j) {
- j.outputRenderTarget = null
- }),
- b.scene.autoClear = b._originalSceneAutoClear,
- b.scene.activeCamera = b._nonVRCamera,
- b._attachedToElement && b._nonVRCamera && b._nonVRCamera.attachControl(!!b._nonVRCamera.inputs.noPreventDefault),
- e !== "immersive-ar" && b.camera.compensateOnFirstFrame && (b._nonVRCamera.setPosition ? b._nonVRCamera.setPosition(b.camera.position) : b._nonVRCamera.position.copyFrom(b.camera.position)),
- b._setState(WebXRState.NOT_IN_XR)
- }),
- this.sessionManager.onXRFrameObservable.addOnce(function() {
- b._setState(WebXRState.IN_XR)
- }),
- [2, this.sessionManager];
- case 7:
- throw _ = k.sent(),
- console.log(_),
- console.log(_.message),
- this._setState(WebXRState.NOT_IN_XR),
- _;
- case 8:
- return [2]
- }
- })
- })
- }
- ,
- a.prototype.exitXRAsync = function() {
- return this.state !== WebXRState.IN_XR ? Promise.resolve() : (this._setState(WebXRState.EXITING_XR),
- this.sessionManager.exitXRAsync())
- }
- ,
- a.prototype.enableSpectatorMode = function() {
- var e = this;
- if (!this._spectatorMode) {
- var i = function() {
- e._spectatorCamera && (e._spectatorCamera.position.copyFrom(e.camera.rigCameras[0].globalPosition),
- e._spectatorCamera.rotationQuaternion.copyFrom(e.camera.rigCameras[0].absoluteRotation))
- }
- , o = function() {
- e.state === WebXRState.IN_XR ? (e._spectatorCamera = new UniversalCamera("webxr-spectator",Vector3.Zero(),e.scene),
- e._spectatorCamera.rotationQuaternion = new Quaternion,
- e.scene.activeCameras = [e.camera, e._spectatorCamera],
- e.sessionManager.onXRFrameObservable.add(i),
- e.scene.onAfterRenderCameraObservable.add(function(s) {
- s === e.camera && (e.scene.getEngine().framebufferDimensionsObject = null)
- })) : e.state === WebXRState.EXITING_XR && (e.sessionManager.onXRFrameObservable.removeCallback(i),
- e.scene.activeCameras = null)
- };
- this._spectatorMode = !0,
- this.onStateChangedObservable.add(o),
- o()
- }
- }
- ,
- a.prototype._nonXRToXRCamera = function() {
- this.camera.setTransformationFromNonVRCamera(this._nonVRCamera),
- this.onInitialXRPoseSetObservable.notifyObservers(this.camera)
- }
- ,
- a.prototype._setState = function(e) {
- this.state !== e && (this.state = e,
- this.onStateChangedObservable.notifyObservers(this.state))
- }
- ,
- a
- }()
- , WebXRControllerComponent = function() {
- function a(e, i, o, s) {
- o === void 0 && (o = -1),
- s === void 0 && (s = []),
- this.id = e,
- this.type = i,
- this._buttonIndex = o,
- this._axesIndices = s,
- this._axes = {
- x: 0,
- y: 0
- },
- this._changes = {},
- this._currentValue = 0,
- this._hasChanges = !1,
- this._pressed = !1,
- this._touched = !1,
- this.onAxisValueChangedObservable = new Observable,
- this.onButtonStateChangedObservable = new Observable
- }
- return Object.defineProperty(a.prototype, "axes", {
- get: function() {
- return this._axes
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "changes", {
- get: function() {
- return this._changes
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "hasChanges", {
- get: function() {
- return this._hasChanges
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "pressed", {
- get: function() {
- return this._pressed
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "touched", {
- get: function() {
- return this._touched
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(a.prototype, "value", {
- get: function() {
- return this._currentValue
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.dispose = function() {
- this.onAxisValueChangedObservable.clear(),
- this.onButtonStateChangedObservable.clear()
- }
- ,
- a.prototype.isAxes = function() {
- return this._axesIndices.length !== 0
- }
- ,
- a.prototype.isButton = function() {
- return this._buttonIndex !== -1
- }
- ,
- a.prototype.update = function(e) {
- var i = !1
- , o = !1;
- if (this._hasChanges = !1,
- this._changes = {},
- this.isButton()) {
- var s = e.buttons[this._buttonIndex];
- if (!s)
- return;
- this._currentValue !== s.value && (this.changes.value = {
- current: s.value,
- previous: this._currentValue
- },
- i = !0,
- this._currentValue = s.value),
- this._touched !== s.touched && (this.changes.touched = {
- current: s.touched,
- previous: this._touched
- },
- i = !0,
- this._touched = s.touched),
- this._pressed !== s.pressed && (this.changes.pressed = {
- current: s.pressed,
- previous: this._pressed
- },
- i = !0,
- this._pressed = s.pressed)
- }
- this.isAxes() && (this._axes.x !== e.axes[this._axesIndices[0]] && (this.changes.axes = {
- current: {
- x: e.axes[this._axesIndices[0]],
- y: this._axes.y
- },
- previous: {
- x: this._axes.x,
- y: this._axes.y
- }
- },
- this._axes.x = e.axes[this._axesIndices[0]],
- o = !0),
- this._axes.y !== e.axes[this._axesIndices[1]] && (this.changes.axes ? this.changes.axes.current.y = e.axes[this._axesIndices[1]] : this.changes.axes = {
- current: {
- x: this._axes.x,
- y: e.axes[this._axesIndices[1]]
- },
- previous: {
- x: this._axes.x,
- y: this._axes.y
- }
- },
- this._axes.y = e.axes[this._axesIndices[1]],
- o = !0)),
- i && (this._hasChanges = !0,
- this.onButtonStateChangedObservable.notifyObservers(this)),
- o && (this._hasChanges = !0,
- this.onAxisValueChangedObservable.notifyObservers(this._axes))
- }
- ,
- a.BUTTON_TYPE = "button",
- a.SQUEEZE_TYPE = "squeeze",
- a.THUMBSTICK_TYPE = "thumbstick",
- a.TOUCHPAD_TYPE = "touchpad",
- a.TRIGGER_TYPE = "trigger",
- a
- }()
- , WebXRAbstractMotionController = function() {
- function a(e, i, o, s, c, d) {
- var _ = this;
- c === void 0 && (c = !1),
- this.scene = e,
- this.layout = i,
- this.gamepadObject = o,
- this.handedness = s,
- this._doNotLoadControllerMesh = c,
- this._controllerCache = d,
- this._initComponent = function(b) {
- if (!!b) {
- var k = _.layout.components[b]
- , j = k.type
- , $ = k.gamepadIndices.button
- , _e = [];
- k.gamepadIndices.xAxis !== void 0 && k.gamepadIndices.yAxis !== void 0 && _e.push(k.gamepadIndices.xAxis, k.gamepadIndices.yAxis),
- _.components[b] = new WebXRControllerComponent(b,j,$,_e)
- }
- }
- ,
- this._modelReady = !1,
- this.components = {},
- this.disableAnimation = !1,
- this.onModelLoadedObservable = new Observable,
- i.components && Object.keys(i.components).forEach(this._initComponent)
- }
- return a.prototype.dispose = function() {
- var e = this;
- this.getComponentIds().forEach(function(i) {
- return e.getComponent(i).dispose()
- }),
- this.rootMesh && (this.rootMesh.getChildren(void 0, !0).forEach(function(i) {
- i.setEnabled(!1)
- }),
- this.rootMesh.dispose(!!this._controllerCache, !this._controllerCache))
- }
- ,
- a.prototype.getAllComponentsOfType = function(e) {
- var i = this;
- return this.getComponentIds().map(function(o) {
- return i.components[o]
- }).filter(function(o) {
- return o.type === e
- })
- }
- ,
- a.prototype.getComponent = function(e) {
- return this.components[e]
- }
- ,
- a.prototype.getComponentIds = function() {
- return Object.keys(this.components)
- }
- ,
- a.prototype.getComponentOfType = function(e) {
- return this.getAllComponentsOfType(e)[0] || null
- }
- ,
- a.prototype.getMainComponent = function() {
- return this.getComponent(this.layout.selectComponentId)
- }
- ,
- a.prototype.loadModel = function() {
- return __awaiter(this, void 0, void 0, function() {
- var e, i, o = this;
- return __generator(this, function(s) {
- return e = !this._getModelLoadingConstraints(),
- i = this._getGenericFilenameAndPath(),
- e ? Logger$2.Warn("Falling back to generic models") : i = this._getFilenameAndPath(),
- [2, new Promise(function(c, d) {
- var _ = function(k) {
- e ? o._getGenericParentMesh(k) : o._setRootMesh(k),
- o._processLoadedModel(k),
- o._modelReady = !0,
- o.onModelLoadedObservable.notifyObservers(o),
- c(!0)
- };
- if (o._controllerCache) {
- var b = o._controllerCache.filter(function(k) {
- return k.filename === i.filename && k.path === i.path
- });
- if (b[0]) {
- b[0].meshes.forEach(function(k) {
- return k.setEnabled(!0)
- }),
- _(b[0].meshes);
- return
- }
- }
- SceneLoader.ImportMesh("", i.path, i.filename, o.scene, function(k) {
- o._controllerCache && o._controllerCache.push(__assign(__assign({}, i), {
- meshes: k
- })),
- _(k)
- }, null, function(k, j) {
- Logger$2.Log(j),
- Logger$2.Warn("Failed to retrieve controller model of type " + o.profileId + " from the remote server: " + i.path + i.filename),
- d(j)
- })
- }
- )]
- })
- })
- }
- ,
- a.prototype.updateFromXRFrame = function(e) {
- var i = this;
- this.getComponentIds().forEach(function(o) {
- return i.getComponent(o).update(i.gamepadObject)
- }),
- this.updateModel(e)
- }
- ,
- Object.defineProperty(a.prototype, "handness", {
- get: function() {
- return this.handedness
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.pulse = function(e, i, o) {
- return o === void 0 && (o = 0),
- this.gamepadObject.hapticActuators && this.gamepadObject.hapticActuators[o] ? this.gamepadObject.hapticActuators[o].pulse(e, i) : Promise.resolve(!1)
- }
- ,
- a.prototype._getChildByName = function(e, i) {
- return e.getChildren(function(o) {
- return o.name === i
- }, !1)[0]
- }
- ,
- a.prototype._getImmediateChildByName = function(e, i) {
- return e.getChildren(function(o) {
- return o.name == i
- }, !0)[0]
- }
- ,
- a.prototype._lerpTransform = function(e, i, o) {
- if (!(!e.minMesh || !e.maxMesh || !e.valueMesh) && !(!e.minMesh.rotationQuaternion || !e.maxMesh.rotationQuaternion || !e.valueMesh.rotationQuaternion)) {
- var s = o ? i * .5 + .5 : i;
- Quaternion.SlerpToRef(e.minMesh.rotationQuaternion, e.maxMesh.rotationQuaternion, s, e.valueMesh.rotationQuaternion),
- Vector3.LerpToRef(e.minMesh.position, e.maxMesh.position, s, e.valueMesh.position)
- }
- }
- ,
- a.prototype.updateModel = function(e) {
- !this._modelReady || this._updateModel(e)
- }
- ,
- a.prototype._getGenericFilenameAndPath = function() {
- return {
- filename: "generic.babylon",
- path: "https://controllers.babylonjs.com/generic/"
- }
- }
- ,
- a.prototype._getGenericParentMesh = function(e) {
- var i = this;
- this.rootMesh = new Mesh(this.profileId + " " + this.handedness,this.scene),
- e.forEach(function(o) {
- o.parent || (o.isPickable = !1,
- o.setParent(i.rootMesh))
- }),
- this.rootMesh.rotationQuaternion = Quaternion.FromEulerAngles(0, Math.PI, 0)
- }
- ,
- a
- }()
- , WebXRGenericTriggerMotionController = function(a) {
- __extends(e, a);
- function e(i, o, s) {
- var c = a.call(this, i, GenericTriggerLayout[s], o, s) || this;
- return c.profileId = e.ProfileId,
- c
- }
- return e.prototype._getFilenameAndPath = function() {
- return {
- filename: "generic.babylon",
- path: "https://controllers.babylonjs.com/generic/"
- }
- }
- ,
- e.prototype._getModelLoadingConstraints = function() {
- return !0
- }
- ,
- e.prototype._processLoadedModel = function(i) {}
- ,
- e.prototype._setRootMesh = function(i) {
- var o = this;
- this.rootMesh = new Mesh(this.profileId + " " + this.handedness,this.scene),
- i.forEach(function(s) {
- s.isPickable = !1,
- s.parent || s.setParent(o.rootMesh)
- }),
- this.rootMesh.rotationQuaternion = Quaternion.FromEulerAngles(0, Math.PI, 0)
- }
- ,
- e.prototype._updateModel = function() {}
- ,
- e.ProfileId = "generic-trigger",
- e
- }(WebXRAbstractMotionController)
- , GenericTriggerLayout = {
- left: {
- selectComponentId: "xr-standard-trigger",
- components: {
- "xr-standard-trigger": {
- type: "trigger",
- gamepadIndices: {
- button: 0
- },
- rootNodeName: "xr_standard_trigger",
- visualResponses: {}
- }
- },
- gamepadMapping: "xr-standard",
- rootNodeName: "generic-trigger-left",
- assetPath: "left.glb"
- },
- right: {
- selectComponentId: "xr-standard-trigger",
- components: {
- "xr-standard-trigger": {
- type: "trigger",
- gamepadIndices: {
- button: 0
- },
- rootNodeName: "xr_standard_trigger",
- visualResponses: {}
- }
- },
- gamepadMapping: "xr-standard",
- rootNodeName: "generic-trigger-right",
- assetPath: "right.glb"
- },
- none: {
- selectComponentId: "xr-standard-trigger",
- components: {
- "xr-standard-trigger": {
- type: "trigger",
- gamepadIndices: {
- button: 0
- },
- rootNodeName: "xr_standard_trigger",
- visualResponses: {}
- }
- },
- gamepadMapping: "xr-standard",
- rootNodeName: "generic-trigger-none",
- assetPath: "none.glb"
- }
- }
- , WebXRProfiledMotionController = function(a) {
- __extends(e, a);
- function e(i, o, s, c, d) {
- var _ = a.call(this, i, s.layouts[o.handedness || "none"], o.gamepad, o.handedness, void 0, d) || this;
- return _._repositoryUrl = c,
- _.controllerCache = d,
- _._buttonMeshMapping = {},
- _._touchDots = {},
- _.profileId = s.profileId,
- _
- }
- return e.prototype.dispose = function() {
- var i = this;
- a.prototype.dispose.call(this),
- this.controllerCache || Object.keys(this._touchDots).forEach(function(o) {
- i._touchDots[o].dispose()
- })
- }
- ,
- e.prototype._getFilenameAndPath = function() {
- return {
- filename: this.layout.assetPath,
- path: this._repositoryUrl + "/profiles/" + this.profileId + "/"
- }
- }
- ,
- e.prototype._getModelLoadingConstraints = function() {
- var i = SceneLoader.IsPluginForExtensionAvailable(".glb");
- return i || Logger$2.Warn("glTF / glb loader was not registered, using generic controller instead"),
- i
- }
- ,
- e.prototype._processLoadedModel = function(i) {
- var o = this;
- this.getComponentIds().forEach(function(s) {
- var c = o.layout.components[s];
- o._buttonMeshMapping[s] = {
- mainMesh: o._getChildByName(o.rootMesh, c.rootNodeName),
- states: {}
- },
- Object.keys(c.visualResponses).forEach(function(d) {
- var _ = c.visualResponses[d];
- if (_.valueNodeProperty === "transform")
- o._buttonMeshMapping[s].states[d] = {
- valueMesh: o._getChildByName(o.rootMesh, _.valueNodeName),
- minMesh: o._getChildByName(o.rootMesh, _.minNodeName),
- maxMesh: o._getChildByName(o.rootMesh, _.maxNodeName)
- };
- else {
- var b = c.type === WebXRControllerComponent.TOUCHPAD_TYPE && c.touchPointNodeName ? c.touchPointNodeName : _.valueNodeName;
- if (o._buttonMeshMapping[s].states[d] = {
- valueMesh: o._getChildByName(o.rootMesh, b)
- },
- c.type === WebXRControllerComponent.TOUCHPAD_TYPE && !o._touchDots[d]) {
- var k = CreateSphere(d + "dot", {
- diameter: .0015,
- segments: 8
- }, o.scene);
- k.material = new StandardMaterial(d + "mat",o.scene),
- k.material.diffuseColor = Color3.Red(),
- k.parent = o._buttonMeshMapping[s].states[d].valueMesh || null,
- k.isVisible = !1,
- o._touchDots[d] = k
- }
- }
- })
- })
- }
- ,
- e.prototype._setRootMesh = function(i) {
- this.rootMesh = new Mesh(this.profileId + "-" + this.handedness,this.scene),
- this.rootMesh.isPickable = !1;
- for (var o, s = 0; s < i.length; s++) {
- var c = i[s];
- c.isPickable = !1,
- c.parent || (o = c)
- }
- o && o.setParent(this.rootMesh),
- this.scene.useRightHandedSystem || this.rootMesh.rotate(Axis.Y, Math.PI, Space.WORLD)
- }
- ,
- e.prototype._updateModel = function(i) {
- var o = this;
- this.disableAnimation || this.getComponentIds().forEach(function(s) {
- var c = o.getComponent(s);
- if (!!c.hasChanges) {
- var d = o._buttonMeshMapping[s]
- , _ = o.layout.components[s];
- Object.keys(_.visualResponses).forEach(function(b) {
- var k = _.visualResponses[b]
- , j = c.value;
- if (k.componentProperty === "xAxis" ? j = c.axes.x : k.componentProperty === "yAxis" && (j = c.axes.y),
- k.valueNodeProperty === "transform")
- o._lerpTransform(d.states[b], j, k.componentProperty !== "button");
- else {
- var $ = d.states[b].valueMesh;
- $ && ($.isVisible = c.touched || c.pressed),
- o._touchDots[b] && (o._touchDots[b].isVisible = c.touched || c.pressed)
- }
- })
- }
- })
- }
- ,
- e
- }(WebXRAbstractMotionController)
- , controllerCache = []
- , WebXRMotionControllerManager = function() {
- function a() {}
- return a.ClearProfilesCache = function() {
- this._ProfilesList = null,
- this._ProfileLoadingPromises = {}
- }
- ,
- a.DefaultFallbacks = function() {
- this.RegisterFallbacksForProfileId("google-daydream", ["generic-touchpad"]),
- this.RegisterFallbacksForProfileId("htc-vive-focus", ["generic-trigger-touchpad"]),
- this.RegisterFallbacksForProfileId("htc-vive", ["generic-trigger-squeeze-touchpad"]),
- this.RegisterFallbacksForProfileId("magicleap-one", ["generic-trigger-squeeze-touchpad"]),
- this.RegisterFallbacksForProfileId("windows-mixed-reality", ["generic-trigger-squeeze-touchpad-thumbstick"]),
- this.RegisterFallbacksForProfileId("microsoft-mixed-reality", ["windows-mixed-reality", "generic-trigger-squeeze-touchpad-thumbstick"]),
- this.RegisterFallbacksForProfileId("oculus-go", ["generic-trigger-touchpad"]),
- this.RegisterFallbacksForProfileId("oculus-touch-v2", ["oculus-touch", "generic-trigger-squeeze-thumbstick"]),
- this.RegisterFallbacksForProfileId("oculus-touch", ["generic-trigger-squeeze-thumbstick"]),
- this.RegisterFallbacksForProfileId("samsung-gearvr", ["windows-mixed-reality", "generic-trigger-squeeze-touchpad-thumbstick"]),
- this.RegisterFallbacksForProfileId("samsung-odyssey", ["generic-touchpad"]),
- this.RegisterFallbacksForProfileId("valve-index", ["generic-trigger-squeeze-touchpad-thumbstick"]),
- this.RegisterFallbacksForProfileId("generic-hand-select", ["generic-trigger"])
- }
- ,
- a.FindFallbackWithProfileId = function(e) {
- var i = this._Fallbacks[e] || [];
- return i.unshift(e),
- i
- }
- ,
- a.GetMotionControllerWithXRInput = function(e, i, o) {
- var s = this
- , c = [];
- if (o && c.push(o),
- c.push.apply(c, e.profiles || []),
- c.length && !c[0] && c.pop(),
- e.gamepad && e.gamepad.id)
- switch (e.gamepad.id) {
- case (e.gamepad.id.match(/oculus touch/gi) ? e.gamepad.id : void 0):
- c.push("oculus-touch-v2");
- break
- }
- var d = c.indexOf("windows-mixed-reality");
- if (d !== -1 && c.splice(d, 0, "microsoft-mixed-reality"),
- c.length || c.push("generic-trigger"),
- this.UseOnlineRepository) {
- var _ = this.PrioritizeOnlineRepository ? this._LoadProfileFromRepository : this._LoadProfilesFromAvailableControllers
- , b = this.PrioritizeOnlineRepository ? this._LoadProfilesFromAvailableControllers : this._LoadProfileFromRepository;
- return _.call(this, c, e, i).catch(function() {
- return b.call(s, c, e, i)
- })
- } else
- return this._LoadProfilesFromAvailableControllers(c, e, i)
- }
- ,
- a.RegisterController = function(e, i) {
- this._AvailableControllers[e] = i
- }
- ,
- a.RegisterFallbacksForProfileId = function(e, i) {
- var o;
- this._Fallbacks[e] ? (o = this._Fallbacks[e]).push.apply(o, i) : this._Fallbacks[e] = i
- }
- ,
- a.UpdateProfilesList = function() {
- return this._ProfilesList = Tools.LoadFileAsync(this.BaseRepositoryUrl + "/profiles/profilesList.json", !1).then(function(e) {
- return JSON.parse(e.toString())
- }),
- this._ProfilesList
- }
- ,
- a.ClearControllerCache = function() {
- controllerCache.forEach(function(e) {
- e.meshes.forEach(function(i) {
- i.dispose(!1, !0)
- })
- }),
- controllerCache.length = 0
- }
- ,
- a._LoadProfileFromRepository = function(e, i, o) {
- var s = this;
- return Promise.resolve().then(function() {
- return s._ProfilesList ? s._ProfilesList : s.UpdateProfilesList()
- }).then(function(c) {
- for (var d = 0; d < e.length; ++d)
- if (!!e[d] && c[e[d]])
- return e[d];
- throw new Error("neither controller " + e[0] + " nor all fallbacks were found in the repository,")
- }).then(function(c) {
- return s._ProfileLoadingPromises[c] || (s._ProfileLoadingPromises[c] = Tools.LoadFileAsync(s.BaseRepositoryUrl + "/profiles/" + c + "/profile.json", !1).then(function(d) {
- return JSON.parse(d)
- })),
- s._ProfileLoadingPromises[c]
- }).then(function(c) {
- return new WebXRProfiledMotionController(o,i,c,s.BaseRepositoryUrl,s.DisableControllerCache ? void 0 : controllerCache)
- })
- }
- ,
- a._LoadProfilesFromAvailableControllers = function(e, i, o) {
- for (var s = 0; s < e.length; ++s)
- if (!!e[s])
- for (var c = this.FindFallbackWithProfileId(e[s]), d = 0; d < c.length; ++d) {
- var _ = this._AvailableControllers[c[d]];
- if (_)
- return Promise.resolve(_(i, o))
- }
- throw new Error("no controller requested was found in the available controllers list")
- }
- ,
- a._AvailableControllers = {},
- a._Fallbacks = {},
- a._ProfileLoadingPromises = {},
- a.BaseRepositoryUrl = "https://immersive-web.github.io/webxr-input-profiles/packages/viewer/dist",
- a.PrioritizeOnlineRepository = !0,
- a.UseOnlineRepository = !0,
- a.DisableControllerCache = !0,
- a
- }();
- WebXRMotionControllerManager.RegisterController(WebXRGenericTriggerMotionController.ProfileId, function(a, e) {
- return new WebXRGenericTriggerMotionController(e,a.gamepad,a.handedness)
- });
- WebXRMotionControllerManager.DefaultFallbacks();
- var idCount = 0
- , WebXRInputSource = function() {
- function a(e, i, o) {
- var s = this;
- o === void 0 && (o = {}),
- this._scene = e,
- this.inputSource = i,
- this._options = o,
- this._tmpVector = new Vector3,
- this._disposed = !1,
- this.onDisposeObservable = new Observable,
- this.onMeshLoadedObservable = new Observable,
- this.onMotionControllerInitObservable = new Observable,
- this._uniqueId = "controller-" + idCount++ + "-" + i.targetRayMode + "-" + i.handedness,
- this.pointer = new AbstractMesh(this._uniqueId + "-pointer",e),
- this.pointer.rotationQuaternion = new Quaternion,
- this.inputSource.gripSpace && (this.grip = new AbstractMesh(this._uniqueId + "-grip",this._scene),
- this.grip.rotationQuaternion = new Quaternion),
- this._tmpVector.set(0, 0, this._scene.useRightHandedSystem ? -1 : 1),
- this.inputSource.gamepad && this.inputSource.targetRayMode === "tracked-pointer" && WebXRMotionControllerManager.GetMotionControllerWithXRInput(i, e, this._options.forceControllerProfile).then(function(c) {
- s.motionController = c,
- s.onMotionControllerInitObservable.notifyObservers(c),
- !s._options.doNotLoadControllerMesh && !s.motionController._doNotLoadControllerMesh && s.motionController.loadModel().then(function(d) {
- var _;
- d && s.motionController && s.motionController.rootMesh && (s._options.renderingGroupId && (s.motionController.rootMesh.renderingGroupId = s._options.renderingGroupId,
- s.motionController.rootMesh.getChildMeshes(!1).forEach(function(b) {
- return b.renderingGroupId = s._options.renderingGroupId
- })),
- s.onMeshLoadedObservable.notifyObservers(s.motionController.rootMesh),
- s.motionController.rootMesh.parent = s.grip || s.pointer,
- s.motionController.disableAnimation = !!s._options.disableMotionControllerAnimation),
- s._disposed && ((_ = s.motionController) === null || _ === void 0 || _.dispose())
- })
- }, function() {
- Tools.Warn("Could not find a matching motion controller for the registered input source")
- })
- }
- return Object.defineProperty(a.prototype, "uniqueId", {
- get: function() {
- return this._uniqueId
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.dispose = function() {
- this.grip && this.grip.dispose(!0),
- this.motionController && this.motionController.dispose(),
- this.pointer.dispose(!0),
- this.onMotionControllerInitObservable.clear(),
- this.onMeshLoadedObservable.clear(),
- this.onDisposeObservable.notifyObservers(this),
- this.onDisposeObservable.clear(),
- this._disposed = !0
- }
- ,
- a.prototype.getWorldPointerRayToRef = function(e, i) {
- i === void 0 && (i = !1);
- var o = i && this.grip ? this.grip : this.pointer;
- Vector3.TransformNormalToRef(this._tmpVector, o.getWorldMatrix(), e.direction),
- e.direction.normalize(),
- e.origin.copyFrom(o.absolutePosition),
- e.length = 1e3
- }
- ,
- a.prototype.updateFromXRFrame = function(e, i, o) {
- var s = e.getPose(this.inputSource.targetRaySpace, i);
- if (this._lastXRPose = s,
- s) {
- var c = s.transform.position;
- this.pointer.position.set(c.x, c.y, c.z);
- var d = s.transform.orientation;
- this.pointer.rotationQuaternion.set(d.x, d.y, d.z, d.w),
- this._scene.useRightHandedSystem || (this.pointer.position.z *= -1,
- this.pointer.rotationQuaternion.z *= -1,
- this.pointer.rotationQuaternion.w *= -1),
- this.pointer.parent = o.parent
- }
- if (this.inputSource.gripSpace && this.grip) {
- var _ = e.getPose(this.inputSource.gripSpace, i);
- if (_) {
- var c = _.transform.position
- , b = _.transform.orientation;
- this.grip.position.set(c.x, c.y, c.z),
- this.grip.rotationQuaternion.set(b.x, b.y, b.z, b.w),
- this._scene.useRightHandedSystem || (this.grip.position.z *= -1,
- this.grip.rotationQuaternion.z *= -1,
- this.grip.rotationQuaternion.w *= -1)
- }
- this.grip.parent = o.parent
- }
- this.motionController && this.motionController.updateFromXRFrame(e)
- }
- ,
- a
- }()
- , WebXRInput = function() {
- function a(e, i, o) {
- var s = this;
- if (o === void 0 && (o = {}),
- this.xrSessionManager = e,
- this.xrCamera = i,
- this.options = o,
- this.controllers = [],
- this.onControllerAddedObservable = new Observable,
- this.onControllerRemovedObservable = new Observable,
- this._onInputSourcesChange = function(c) {
- s._addAndRemoveControllers(c.added, c.removed)
- }
- ,
- this._sessionEndedObserver = this.xrSessionManager.onXRSessionEnded.add(function() {
- s._addAndRemoveControllers([], s.controllers.map(function(c) {
- return c.inputSource
- }))
- }),
- this._sessionInitObserver = this.xrSessionManager.onXRSessionInit.add(function(c) {
- c.addEventListener("inputsourceschange", s._onInputSourcesChange)
- }),
- this._frameObserver = this.xrSessionManager.onXRFrameObservable.add(function(c) {
- s.controllers.forEach(function(d) {
- d.updateFromXRFrame(c, s.xrSessionManager.referenceSpace, s.xrCamera)
- })
- }),
- this.options.customControllersRepositoryURL && (WebXRMotionControllerManager.BaseRepositoryUrl = this.options.customControllersRepositoryURL),
- WebXRMotionControllerManager.UseOnlineRepository = !this.options.disableOnlineControllerRepository,
- WebXRMotionControllerManager.UseOnlineRepository)
- try {
- WebXRMotionControllerManager.UpdateProfilesList().catch(function() {
- WebXRMotionControllerManager.UseOnlineRepository = !1
- })
- } catch {
- WebXRMotionControllerManager.UseOnlineRepository = !1
- }
- }
- return a.prototype._addAndRemoveControllers = function(e, i) {
- for (var o = this, s = this.controllers.map(function($) {
- return $.inputSource
- }), c = 0, d = e; c < d.length; c++) {
- var _ = d[c];
- if (s.indexOf(_) === -1) {
- var b = new WebXRInputSource(this.xrSessionManager.scene,_,__assign(__assign({}, this.options.controllerOptions || {}), {
- forceControllerProfile: this.options.forceInputProfile,
- doNotLoadControllerMesh: this.options.doNotLoadControllerMeshes,
- disableMotionControllerAnimation: this.options.disableControllerAnimation
- }));
- this.controllers.push(b),
- this.onControllerAddedObservable.notifyObservers(b)
- }
- }
- var k = []
- , j = [];
- this.controllers.forEach(function($) {
- i.indexOf($.inputSource) === -1 ? k.push($) : j.push($)
- }),
- this.controllers = k,
- j.forEach(function($) {
- o.onControllerRemovedObservable.notifyObservers($),
- $.dispose()
- })
- }
- ,
- a.prototype.dispose = function() {
- this.controllers.forEach(function(e) {
- e.dispose()
- }),
- this.xrSessionManager.onXRFrameObservable.remove(this._frameObserver),
- this.xrSessionManager.onXRSessionInit.remove(this._sessionInitObserver),
- this.xrSessionManager.onXRSessionEnded.remove(this._sessionEndedObserver),
- this.onControllerAddedObservable.clear(),
- this.onControllerRemovedObservable.clear(),
- WebXRMotionControllerManager.ClearControllerCache()
- }
- ,
- a
- }()
- , WebXRAbstractFeature = function() {
- function a(e) {
- this._xrSessionManager = e,
- this._attached = !1,
- this._removeOnDetach = [],
- this.isDisposed = !1,
- this.disableAutoAttach = !1,
- this.xrNativeFeatureName = ""
- }
- return Object.defineProperty(a.prototype, "attached", {
- get: function() {
- return this._attached
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.attach = function(e) {
- var i = this;
- if (this.isDisposed)
- return !1;
- if (e)
- this.attached && this.detach();
- else if (this.attached)
- return !1;
- return this._attached = !0,
- this._addNewAttachObserver(this._xrSessionManager.onXRFrameObservable, function(o) {
- return i._onXRFrame(o)
- }),
- !0
- }
- ,
- a.prototype.detach = function() {
- return this._attached ? (this._attached = !1,
- this._removeOnDetach.forEach(function(e) {
- e.observable.remove(e.observer)
- }),
- !0) : (this.disableAutoAttach = !0,
- !1)
- }
- ,
- a.prototype.dispose = function() {
- this.detach(),
- this.isDisposed = !0
- }
- ,
- a.prototype.isCompatible = function() {
- return !0
- }
- ,
- a.prototype._addNewAttachObserver = function(e, i) {
- this._removeOnDetach.push({
- observable: e,
- observer: e.add(i)
- })
- }
- ,
- a
- }()
- , WebXRControllerPointerSelection = function(a) {
- __extends(e, a);
- function e(i, o) {
- var s = a.call(this, i) || this;
- return s._options = o,
- s._attachController = function(c) {
- if (!s._controllers[c.uniqueId]) {
- var d = s._generateNewMeshPair(c.pointer)
- , _ = d.laserPointer
- , b = d.selectionMesh;
- switch (s._controllers[c.uniqueId] = {
- xrController: c,
- laserPointer: _,
- selectionMesh: b,
- meshUnderPointer: null,
- pick: null,
- tmpRay: new Ray(new Vector3,new Vector3),
- disabledByNearInteraction: !1,
- id: e._idCounter++
- },
- 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),
- c.inputSource.targetRayMode) {
- case "tracked-pointer":
- return s._attachTrackedPointerRayMode(c);
- case "gaze":
- return s._attachGazeMode(c);
- case "screen":
- return s._attachScreenRayMode(c)
- }
- }
- }
- ,
- s._controllers = {},
- s._tmpVectorForPickCompare = new Vector3,
- s.disablePointerLighting = !0,
- s.disableSelectionMeshLighting = !0,
- s.displayLaserPointer = !0,
- s.displaySelectionMesh = !0,
- s.laserPointerPickedColor = new Color3(.9,.9,.9),
- s.laserPointerDefaultColor = new Color3(.7,.7,.7),
- s.selectionMeshDefaultColor = new Color3(.8,.8,.8),
- s.selectionMeshPickedColor = new Color3(.3,.3,1),
- s._identityMatrix = Matrix.Identity(),
- s._screenCoordinatesRef = Vector3.Zero(),
- s._viewportRef = new Viewport(0,0,0,0),
- s._scene = s._xrSessionManager.scene,
- s
- }
- return e.prototype.attach = function() {
- var i = this;
- if (!a.prototype.attach.call(this))
- return !1;
- if (this._options.xrInput.controllers.forEach(this._attachController),
- this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable, this._attachController),
- this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable, function(_) {
- i._detachController(_.uniqueId)
- }),
- this._scene.constantlyUpdateMeshUnderPointer = !0,
- this._options.gazeCamera) {
- var o = this._options.gazeCamera
- , s = this._generateNewMeshPair(o)
- , c = s.laserPointer
- , d = s.selectionMesh;
- this._controllers.camera = {
- webXRCamera: o,
- laserPointer: c,
- selectionMesh: d,
- meshUnderPointer: null,
- pick: null,
- tmpRay: new Ray(new Vector3,new Vector3),
- disabledByNearInteraction: !1,
- id: e._idCounter++
- },
- this._attachGazeMode()
- }
- return !0
- }
- ,
- e.prototype.detach = function() {
- var i = this;
- return a.prototype.detach.call(this) ? (Object.keys(this._controllers).forEach(function(o) {
- i._detachController(o)
- }),
- !0) : !1
- }
- ,
- e.prototype.getMeshUnderPointer = function(i) {
- return this._controllers[i] ? this._controllers[i].meshUnderPointer : null
- }
- ,
- e.prototype.getXRControllerByPointerId = function(i) {
- for (var o = Object.keys(this._controllers), s = 0; s < o.length; ++s)
- if (this._controllers[o[s]].id === i)
- return this._controllers[o[s]].xrController || null;
- return null
- }
- ,
- e.prototype._getPointerSelectionDisabledByPointerId = function(i) {
- for (var o = Object.keys(this._controllers), s = 0; s < o.length; ++s)
- if (this._controllers[o[s]].id === i)
- return this._controllers[o[s]].disabledByNearInteraction;
- return !0
- }
- ,
- e.prototype._setPointerSelectionDisabledByPointerId = function(i, o) {
- for (var s = Object.keys(this._controllers), c = 0; c < s.length; ++c)
- if (this._controllers[s[c]].id === i) {
- this._controllers[s[c]].disabledByNearInteraction = o;
- return
- }
- }
- ,
- e.prototype._onXRFrame = function(i) {
- var o = this;
- Object.keys(this._controllers).forEach(function(s) {
- var c = o._controllers[s];
- if (!o._options.enablePointerSelectionOnAllControllers && s !== o._attachedController || c.disabledByNearInteraction) {
- c.selectionMesh.isVisible = !1,
- c.laserPointer.isVisible = !1,
- c.pick = null;
- return
- }
- c.laserPointer.isVisible = o.displayLaserPointer;
- var d;
- if (c.xrController)
- d = c.xrController.pointer.position,
- c.xrController.getWorldPointerRayToRef(c.tmpRay);
- else if (c.webXRCamera)
- d = c.webXRCamera.position,
- c.webXRCamera.getForwardRayToRef(c.tmpRay);
- else
- return;
- if (o._options.maxPointerDistance && (c.tmpRay.length = o._options.maxPointerDistance),
- !o._options.disableScenePointerVectorUpdate && d) {
- var _ = o._xrSessionManager.scene
- , b = o._options.xrInput.xrCamera;
- b && (b.viewport.toGlobalToRef(_.getEngine().getRenderWidth(), _.getEngine().getRenderHeight(), o._viewportRef),
- Vector3.ProjectToRef(d, o._identityMatrix, _.getTransformMatrix(), o._viewportRef, o._screenCoordinatesRef),
- typeof o._screenCoordinatesRef.x == "number" && typeof o._screenCoordinatesRef.y == "number" && !isNaN(o._screenCoordinatesRef.x) && !isNaN(o._screenCoordinatesRef.y) && (_.pointerX = o._screenCoordinatesRef.x,
- _.pointerY = o._screenCoordinatesRef.y,
- c.screenCoordinates = {
- x: o._screenCoordinatesRef.x,
- y: o._screenCoordinatesRef.y
- }))
- }
- var k = null;
- o._utilityLayerScene && (k = o._utilityLayerScene.pickWithRay(c.tmpRay, o._utilityLayerScene.pointerMovePredicate || o.raySelectionPredicate));
- var j = o._scene.pickWithRay(c.tmpRay, o._scene.pointerMovePredicate || o.raySelectionPredicate);
- !k || !k.hit ? c.pick = j : !j || !j.hit || k.distance < j.distance ? c.pick = k : c.pick = j,
- c.pick && c.xrController && (c.pick.aimTransform = c.xrController.pointer,
- c.pick.gripTransform = c.xrController.grip || null);
- var $ = c.pick;
- if ($ && $.pickedPoint && $.hit) {
- o._updatePointerDistance(c.laserPointer, $.distance),
- c.selectionMesh.position.copyFrom($.pickedPoint),
- c.selectionMesh.scaling.x = Math.sqrt($.distance),
- c.selectionMesh.scaling.y = Math.sqrt($.distance),
- c.selectionMesh.scaling.z = Math.sqrt($.distance);
- var _e = o._convertNormalToDirectionOfRay($.getNormal(!0), c.tmpRay)
- , et = .001;
- if (c.selectionMesh.position.copyFrom($.pickedPoint),
- _e) {
- var tt = Vector3.Cross(Axis.Y, _e)
- , rt = Vector3.Cross(_e, tt);
- Vector3.RotationFromAxisToRef(rt, _e, tt, c.selectionMesh.rotation),
- c.selectionMesh.position.addInPlace(_e.scale(et))
- }
- c.selectionMesh.isVisible = o.displaySelectionMesh,
- c.meshUnderPointer = $.pickedMesh
- } else
- c.selectionMesh.isVisible = !1,
- o._updatePointerDistance(c.laserPointer, 1),
- c.meshUnderPointer = null
- })
- }
- ,
- Object.defineProperty(e.prototype, "_utilityLayerScene", {
- get: function() {
- return this._options.customUtilityLayerScene || UtilityLayerRenderer.DefaultUtilityLayer.utilityLayerScene
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._attachGazeMode = function(i) {
- var o = this
- , s = this._controllers[i && i.uniqueId || "camera"]
- , c = this._options.timeToSelect || 3e3
- , d = this._options.useUtilityLayer ? this._utilityLayerScene : this._scene
- , _ = new PickingInfo
- , b = CreateTorus("selection", {
- diameter: .0035 * 15,
- thickness: .0025 * 6,
- tessellation: 20
- }, d);
- b.isVisible = !1,
- b.isPickable = !1,
- b.parent = s.selectionMesh;
- var k = 0
- , j = !1
- , $ = {
- pointerId: s.id,
- pointerType: "xr"
- };
- s.onFrameObserver = this._xrSessionManager.onXRFrameObservable.add(function() {
- if (!!s.pick) {
- if (o._augmentPointerInit($, s.id, s.screenCoordinates),
- s.laserPointer.material.alpha = 0,
- b.isVisible = !1,
- s.pick.hit)
- if (o._pickingMoved(_, s.pick))
- j && (o._options.disablePointerUpOnTouchOut || o._scene.simulatePointerUp(s.pick, $)),
- j = !1,
- k = 0;
- else if (k > c / 10 && (b.isVisible = !0),
- k += o._scene.getEngine().getDeltaTime(),
- k >= c)
- o._scene.simulatePointerDown(s.pick, $),
- j = !0,
- o._options.disablePointerUpOnTouchOut && o._scene.simulatePointerUp(s.pick, $),
- b.isVisible = !1;
- else {
- var _e = 1 - k / c;
- b.scaling.set(_e, _e, _e)
- }
- else
- j = !1,
- k = 0;
- o._scene.simulatePointerMove(s.pick, $),
- _ = s.pick
- }
- }),
- this._options.renderingGroupId !== void 0 && (b.renderingGroupId = this._options.renderingGroupId),
- i && i.onDisposeObservable.addOnce(function() {
- s.pick && !o._options.disablePointerUpOnTouchOut && j && (o._scene.simulatePointerUp(s.pick, $),
- s.finalPointerUpTriggered = !0),
- b.dispose()
- })
- }
- ,
- e.prototype._attachScreenRayMode = function(i) {
- var o = this
- , s = this._controllers[i.uniqueId]
- , c = !1
- , d = {
- pointerId: s.id,
- pointerType: "xr"
- };
- s.onFrameObserver = this._xrSessionManager.onXRFrameObservable.add(function() {
- o._augmentPointerInit(d, s.id, s.screenCoordinates),
- !(!s.pick || o._options.disablePointerUpOnTouchOut && c) && (c ? o._scene.simulatePointerMove(s.pick, d) : (o._scene.simulatePointerDown(s.pick, d),
- c = !0,
- o._options.disablePointerUpOnTouchOut && o._scene.simulatePointerUp(s.pick, d)))
- }),
- i.onDisposeObservable.addOnce(function() {
- o._augmentPointerInit(d, s.id, s.screenCoordinates),
- s.pick && c && !o._options.disablePointerUpOnTouchOut && (o._scene.simulatePointerUp(s.pick, d),
- s.finalPointerUpTriggered = !0)
- })
- }
- ,
- e.prototype._attachTrackedPointerRayMode = function(i) {
- var o = this
- , s = this._controllers[i.uniqueId];
- if (this._options.forceGazeMode)
- return this._attachGazeMode(i);
- var c = {
- pointerId: s.id,
- pointerType: "xr"
- };
- if (s.onFrameObserver = this._xrSessionManager.onXRFrameObservable.add(function() {
- s.laserPointer.material.disableLighting = o.disablePointerLighting,
- s.selectionMesh.material.disableLighting = o.disableSelectionMeshLighting,
- s.pick && (o._augmentPointerInit(c, s.id, s.screenCoordinates),
- o._scene.simulatePointerMove(s.pick, c))
- }),
- i.inputSource.gamepad) {
- var d = function(k) {
- o._options.overrideButtonId && (s.selectionComponent = k.getComponent(o._options.overrideButtonId)),
- s.selectionComponent || (s.selectionComponent = k.getMainComponent()),
- s.onButtonChangedObserver = s.selectionComponent.onButtonStateChangedObservable.add(function(j) {
- if (j.changes.pressed) {
- var $ = j.changes.pressed.current;
- s.pick ? (o._options.enablePointerSelectionOnAllControllers || i.uniqueId === o._attachedController) && (o._augmentPointerInit(c, s.id, s.screenCoordinates),
- $ ? (o._scene.simulatePointerDown(s.pick, c),
- s.selectionMesh.material.emissiveColor = o.selectionMeshPickedColor,
- s.laserPointer.material.emissiveColor = o.laserPointerPickedColor) : (o._scene.simulatePointerUp(s.pick, c),
- s.selectionMesh.material.emissiveColor = o.selectionMeshDefaultColor,
- s.laserPointer.material.emissiveColor = o.laserPointerDefaultColor)) : $ && !o._options.enablePointerSelectionOnAllControllers && !o._options.disableSwitchOnClick && (o._attachedController = i.uniqueId)
- }
- })
- };
- i.motionController ? d(i.motionController) : i.onMotionControllerInitObservable.add(d)
- } else {
- var _ = function(k) {
- o._augmentPointerInit(c, s.id, s.screenCoordinates),
- s.xrController && k.inputSource === s.xrController.inputSource && s.pick && (o._scene.simulatePointerDown(s.pick, c),
- s.selectionMesh.material.emissiveColor = o.selectionMeshPickedColor,
- s.laserPointer.material.emissiveColor = o.laserPointerPickedColor)
- }
- , b = function(k) {
- o._augmentPointerInit(c, s.id, s.screenCoordinates),
- s.xrController && k.inputSource === s.xrController.inputSource && s.pick && (o._scene.simulatePointerUp(s.pick, c),
- s.selectionMesh.material.emissiveColor = o.selectionMeshDefaultColor,
- s.laserPointer.material.emissiveColor = o.laserPointerDefaultColor)
- };
- s.eventListeners = {
- selectend: b,
- selectstart: _
- },
- this._xrSessionManager.session.addEventListener("selectstart", _),
- this._xrSessionManager.session.addEventListener("selectend", b)
- }
- }
- ,
- e.prototype._convertNormalToDirectionOfRay = function(i, o) {
- if (i) {
- var s = Math.acos(Vector3.Dot(i, o.direction));
- s < Math.PI / 2 && i.scaleInPlace(-1)
- }
- return i
- }
- ,
- e.prototype._detachController = function(i) {
- var o = this
- , s = this._controllers[i];
- !s || (s.selectionComponent && s.onButtonChangedObserver && s.selectionComponent.onButtonStateChangedObservable.remove(s.onButtonChangedObserver),
- s.onFrameObserver && this._xrSessionManager.onXRFrameObservable.remove(s.onFrameObserver),
- s.eventListeners && Object.keys(s.eventListeners).forEach(function(c) {
- var d = s.eventListeners && s.eventListeners[c];
- d && o._xrSessionManager.session.removeEventListener(c, d)
- }),
- this._xrSessionManager.scene.onBeforeRenderObservable.addOnce(function() {
- try {
- if (!s.finalPointerUpTriggered) {
- var c = {
- pointerId: s.id,
- pointerType: "xr"
- };
- o._augmentPointerInit(c, s.id, s.screenCoordinates),
- o._scene.simulatePointerUp(new PickingInfo, c)
- }
- if (s.selectionMesh.dispose(),
- s.laserPointer.dispose(),
- delete o._controllers[i],
- o._attachedController === i) {
- var d = Object.keys(o._controllers);
- d.length ? o._attachedController = d[0] : o._attachedController = ""
- }
- } catch {
- Tools.Warn("controller already detached.")
- }
- }))
- }
- ,
- e.prototype._generateNewMeshPair = function(i) {
- var o = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || UtilityLayerRenderer.DefaultUtilityLayer.utilityLayerScene : this._scene
- , s = this._options.customLasterPointerMeshGenerator ? this._options.customLasterPointerMeshGenerator() : CreateCylinder("laserPointer", {
- height: 1,
- diameterTop: 2e-4,
- diameterBottom: .004,
- tessellation: 20,
- subdivisions: 1
- }, o);
- s.parent = i;
- var c = new StandardMaterial("laserPointerMat",o);
- c.emissiveColor = this.laserPointerDefaultColor,
- c.alpha = .7,
- s.material = c,
- s.rotation.x = Math.PI / 2,
- this._updatePointerDistance(s, 1),
- s.isPickable = !1,
- s.isVisible = !1;
- var d = this._options.customSelectionMeshGenerator ? this._options.customSelectionMeshGenerator() : CreateTorus("gazeTracker", {
- diameter: .0035 * 3,
- thickness: .0025 * 3,
- tessellation: 20
- }, o);
- d.bakeCurrentTransformIntoVertices(),
- d.isPickable = !1,
- d.isVisible = !1;
- var _ = new StandardMaterial("targetMat",o);
- return _.specularColor = Color3.Black(),
- _.emissiveColor = this.selectionMeshDefaultColor,
- _.backFaceCulling = !1,
- d.material = _,
- this._options.renderingGroupId !== void 0 && (s.renderingGroupId = this._options.renderingGroupId,
- d.renderingGroupId = this._options.renderingGroupId),
- {
- laserPointer: s,
- selectionMesh: d
- }
- }
- ,
- e.prototype._pickingMoved = function(i, o) {
- var s;
- if (!i.hit || !o.hit || !i.pickedMesh || !i.pickedPoint || !o.pickedMesh || !o.pickedPoint || i.pickedMesh !== o.pickedMesh)
- return !0;
- (s = i.pickedPoint) === null || s === void 0 || s.subtractToRef(o.pickedPoint, this._tmpVectorForPickCompare),
- this._tmpVectorForPickCompare.set(Math.abs(this._tmpVectorForPickCompare.x), Math.abs(this._tmpVectorForPickCompare.y), Math.abs(this._tmpVectorForPickCompare.z));
- var c = (this._options.gazeModePointerMovedFactor || 1) * .01 * o.distance
- , d = this._tmpVectorForPickCompare.length();
- return d > c
- }
- ,
- e.prototype._updatePointerDistance = function(i, o) {
- o === void 0 && (o = 100),
- i.scaling.y = o,
- this._scene.useRightHandedSystem && (o *= -1),
- i.position.z = o / 2 + .05
- }
- ,
- e.prototype._augmentPointerInit = function(i, o, s) {
- i.pointerId = o,
- i.pointerType = "xr",
- s && (i.screenX = s.x,
- i.screenY = s.y)
- }
- ,
- Object.defineProperty(e.prototype, "lasterPointerDefaultColor", {
- get: function() {
- return this.laserPointerDefaultColor
- },
- enumerable: !1,
- configurable: !0
- }),
- e._idCounter = 200,
- e.Name = WebXRFeatureName.POINTER_SELECTION,
- e.Version = 1,
- e
- }(WebXRAbstractFeature);
- WebXRFeaturesManager.AddWebXRFeature(WebXRControllerPointerSelection.Name, function(a, e) {
- return function() {
- return new WebXRControllerPointerSelection(a,e)
- }
- }, WebXRControllerPointerSelection.Version, !0);
- SubMesh.prototype._projectOnTrianglesToRef = function(a, e, i, o, s, c) {
- for (var d = TmpVectors.Vector3[0], _ = TmpVectors.Vector3[1], b = 1 / 0, k = this.indexStart; k < this.indexStart + this.indexCount - (3 - o); k += o) {
- var j = i[k]
- , $ = i[k + 1]
- , _e = i[k + 2];
- if (s && _e === 4294967295) {
- k += 2;
- continue
- }
- var et = e[j]
- , tt = e[$]
- , rt = e[_e];
- if (!(!et || !tt || !rt)) {
- var it = Vector3.ProjectOnTriangleToRef(a, et, tt, rt, _);
- it < b && (d.copyFrom(_),
- b = it)
- }
- }
- return c.copyFrom(d),
- b
- }
- ;
- SubMesh.prototype._projectOnUnIndexedTrianglesToRef = function(a, e, i, o) {
- for (var s = TmpVectors.Vector3[0], c = TmpVectors.Vector3[1], d = 1 / 0, _ = this.verticesStart; _ < this.verticesStart + this.verticesCount; _ += 3) {
- var b = e[_]
- , k = e[_ + 1]
- , j = e[_ + 2]
- , $ = Vector3.ProjectOnTriangleToRef(a, b, k, j, c);
- $ < d && (s.copyFrom(c),
- d = $)
- }
- return o.copyFrom(s),
- d
- }
- ;
- SubMesh.prototype.projectToRef = function(a, e, i, o) {
- var s = this.getMaterial();
- if (!s)
- return -1;
- var c = 3
- , d = !1;
- switch (s.fillMode) {
- case 3:
- case 4:
- case 5:
- case 6:
- case 8:
- return -1;
- case 7:
- c = 1,
- d = !0;
- break
- }
- 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)
- }
- ;
- var WebXRNearInteraction = function(a) {
- __extends(e, a);
- function e(i, o) {
- var s = a.call(this, i) || this;
- return s._options = o,
- s._attachController = function(c) {
- if (!s._controllers[c.uniqueId]) {
- var d = s._generateNewHandTipMesh()
- , _ = s._generateVisualCue();
- switch (s._controllers[c.uniqueId] = {
- xrController: c,
- meshUnderPointer: null,
- nearInteractionMesh: null,
- pick: null,
- pickIndexMeshTip: d,
- grabRay: new Ray(new Vector3,new Vector3),
- hoverInteraction: !1,
- nearInteraction: !1,
- grabInteraction: !1,
- id: e._idCounter++,
- pickedPointVisualCue: _
- },
- 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),
- c.inputSource.targetRayMode) {
- case "tracked-pointer":
- return s._attachNearInteractionMode(c);
- case "gaze":
- return null;
- case "screen":
- return null
- }
- }
- }
- ,
- s._controllers = {},
- s._farInteractionFeature = null,
- s.selectionMeshDefaultColor = new Color3(.8,.8,.8),
- s.selectionMeshPickedColor = new Color3(.3,.3,1),
- s._hoverRadius = .1,
- s._pickRadius = .02,
- s._nearGrabLengthScale = 5,
- s._indexTipQuaternion = new Quaternion,
- s._indexTipOrientationVector = Vector3.Zero(),
- s._scene = s._xrSessionManager.scene,
- s._options.farInteractionFeature && (s._farInteractionFeature = s._options.farInteractionFeature),
- s
- }
- return e.prototype.attach = function() {
- var i = this;
- return a.prototype.attach.call(this) ? (this._options.xrInput.controllers.forEach(this._attachController),
- this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable, this._attachController),
- this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable, function(o) {
- i._detachController(o.uniqueId)
- }),
- this._scene.constantlyUpdateMeshUnderPointer = !0,
- !0) : !1
- }
- ,
- e.prototype.detach = function() {
- var i = this;
- return a.prototype.detach.call(this) ? (Object.keys(this._controllers).forEach(function(o) {
- i._detachController(o)
- }),
- !0) : !1
- }
- ,
- e.prototype.getMeshUnderPointer = function(i) {
- return this._controllers[i] ? this._controllers[i].meshUnderPointer : null
- }
- ,
- e.prototype.getXRControllerByPointerId = function(i) {
- for (var o = Object.keys(this._controllers), s = 0; s < o.length; ++s)
- if (this._controllers[o[s]].id === i)
- return this._controllers[o[s]].xrController || null;
- return null
- }
- ,
- e.prototype.setFarInteractionFeature = function(i) {
- this._farInteractionFeature = i
- }
- ,
- e.prototype._nearPickPredicate = function(i) {
- return i.isEnabled() && i.isVisible && i.isPickable && i.isNearPickable
- }
- ,
- e.prototype._nearGrabPredicate = function(i) {
- return i.isEnabled() && i.isVisible && i.isPickable && i.isNearGrabbable
- }
- ,
- e.prototype._nearInteractionPredicate = function(i) {
- return i.isEnabled() && i.isVisible && i.isPickable && (i.isNearPickable || i.isNearGrabbable)
- }
- ,
- e.prototype._controllerAvailablePredicate = function(i, o) {
- for (var s = i; s; ) {
- if (s.reservedDataStore && s.reservedDataStore.nearInteraction && s.reservedDataStore.nearInteraction.excludedControllerId === o)
- return !1;
- s = s.parent
- }
- return !0
- }
- ,
- e.prototype._onXRFrame = function(i) {
- var o = this;
- Object.keys(this._controllers).forEach(function(s) {
- var c = o._controllers[s];
- if (!o._options.enableNearInteractionOnAllControllers && s !== o._attachedController || !c.xrController || !c.xrController.inputSource.hand) {
- c.pick = null;
- return
- }
- if (c.hoverInteraction = !1,
- c.nearInteraction = !1,
- c.xrController) {
- var d = c.xrController.inputSource.hand;
- if (d) {
- var _ = d.get("index-finger-tip");
- if (_) {
- var b = i.getJointPose(_, o._xrSessionManager.referenceSpace);
- if (b && b.transform) {
- var k = o._scene.useRightHandedSystem ? 1 : -1
- , j = b.transform.position
- , $ = b.transform.orientation;
- o._indexTipQuaternion.set($.x, $.y, $.z * k, $.w * k),
- c.pickIndexMeshTip && c.pickIndexMeshTip.position.set(j.x, j.y, j.z * k);
- var _e = o._nearGrabLengthScale * o._hoverRadius;
- c.grabRay.origin.set(j.x, j.y, j.z * k),
- o._indexTipQuaternion.toEulerAnglesToRef(o._indexTipOrientationVector),
- c.grabRay.direction.set(o._indexTipOrientationVector.x, o._indexTipOrientationVector.y, o._indexTipOrientationVector.z),
- c.grabRay.length = _e
- }
- }
- }
- } else
- return;
- var et = function(lt, ft) {
- var ht = null;
- return !ft || !ft.hit ? ht = lt : !lt || !lt.hit || ft.distance < lt.distance ? ht = ft : ht = lt,
- ht
- }
- , tt = function(lt) {
- var ft = new PickingInfo
- , ht = !1
- , pt = lt && lt.pickedPoint && lt.hit;
- return lt != null && lt.pickedPoint && (ht = lt.pickedPoint.x === 0 && lt.pickedPoint.y === 0 && lt.pickedPoint.z === 0),
- pt && !ht && (ft = lt),
- ft
- };
- if (!c.grabInteraction) {
- var rt = null
- , it = null;
- o._options.useUtilityLayer && o._utilityLayerScene && (it = o._pickWithSphere(c, o._hoverRadius, o._utilityLayerScene, function(lt) {
- return o._nearInteractionPredicate(lt)
- }));
- var nt = o._pickWithSphere(c, o._hoverRadius, o._scene, function(lt) {
- return o._nearInteractionPredicate(lt)
- })
- , ot = et(nt, it);
- if (ot && ot.hit && (rt = tt(ot),
- rt.hit && (c.hoverInteraction = !0)),
- c.pickIndexMeshTip && c.hoverInteraction) {
- var at = null;
- o._options.useUtilityLayer && o._utilityLayerScene && (at = o._pickWithSphere(c, o._pickRadius, o._utilityLayerScene, function(lt) {
- return o._nearPickPredicate(lt)
- }));
- var st = o._pickWithSphere(c, o._pickRadius, o._scene, function(lt) {
- return o._nearPickPredicate(lt)
- })
- , ut = et(st, at)
- , ct = tt(ut);
- ct.hit && (rt = ct,
- c.nearInteraction = !0)
- }
- c.pick = rt,
- c.pick && c.pick.pickedPoint && c.pick.hit ? (c.meshUnderPointer = c.pick.pickedMesh,
- c.pickedPointVisualCue.position.copyFrom(c.pick.pickedPoint),
- c.pickedPointVisualCue.isVisible = !0,
- o._farInteractionFeature && o._farInteractionFeature.attached && o._farInteractionFeature._setPointerSelectionDisabledByPointerId(c.id, !0)) : (c.meshUnderPointer = null,
- c.pickedPointVisualCue.isVisible = !1,
- o._farInteractionFeature && o._farInteractionFeature.attached && o._farInteractionFeature._setPointerSelectionDisabledByPointerId(c.id, !1))
- }
- })
- }
- ,
- Object.defineProperty(e.prototype, "_utilityLayerScene", {
- get: function() {
- return this._options.customUtilityLayerScene || UtilityLayerRenderer.DefaultUtilityLayer.utilityLayerScene
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype._generateVisualCue = function() {
- var i = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || UtilityLayerRenderer.DefaultUtilityLayer.utilityLayerScene : this._scene
- , o = CreateSphere("nearInteraction", {
- diameter: .0035 * 3
- }, i);
- o.bakeCurrentTransformIntoVertices(),
- o.isPickable = !1,
- o.isVisible = !1,
- o.rotationQuaternion = Quaternion.Identity();
- var s = new StandardMaterial("targetMat",i);
- return s.specularColor = Color3.Black(),
- s.emissiveColor = this.selectionMeshDefaultColor,
- s.backFaceCulling = !1,
- o.material = s,
- o
- }
- ,
- e.prototype._isControllerReadyForNearInteraction = function(i) {
- return this._farInteractionFeature ? this._farInteractionFeature._getPointerSelectionDisabledByPointerId(i) : !0
- }
- ,
- e.prototype._attachNearInteractionMode = function(i) {
- var o = this
- , s = this._controllers[i.uniqueId]
- , c = {
- pointerId: s.id,
- pointerType: "xr"
- };
- s.onFrameObserver = this._xrSessionManager.onXRFrameObservable.add(function() {
- !o._options.enableNearInteractionOnAllControllers && i.uniqueId !== o._attachedController || !s.xrController || !s.xrController.inputSource.hand || (s.pick && (s.pick.ray = s.grabRay),
- s.pick && o._isControllerReadyForNearInteraction(s.id) && o._scene.simulatePointerMove(s.pick, c),
- s.nearInteraction && s.pick && s.pick.hit ? s.nearInteractionMesh || (o._scene.simulatePointerDown(s.pick, c),
- s.nearInteractionMesh = s.meshUnderPointer) : s.nearInteractionMesh && s.pick && (o._scene.simulatePointerUp(s.pick, c),
- s.nearInteractionMesh = null))
- });
- var d = function(j) {
- o._options.enableNearInteractionOnAllControllers || i.uniqueId === o._attachedController && o._isControllerReadyForNearInteraction(s.id) ? (s.pick && (s.pick.ray = s.grabRay),
- j && s.pick && s.meshUnderPointer && o._nearGrabPredicate(s.meshUnderPointer) ? (s.grabInteraction = !0,
- s.pickedPointVisualCue.isVisible = !1,
- o._scene.simulatePointerDown(s.pick, c)) : !j && s.pick && s.grabInteraction && (o._scene.simulatePointerUp(s.pick, c),
- s.grabInteraction = !1,
- s.pickedPointVisualCue.isVisible = !0)) : j && !o._options.enableNearInteractionOnAllControllers && !o._options.disableSwitchOnClick && (o._attachedController = i.uniqueId)
- };
- if (i.inputSource.gamepad) {
- var _ = function(j) {
- s.squeezeComponent = j.getComponent("grasp"),
- s.squeezeComponent ? s.onSqueezeButtonChangedObserver = s.squeezeComponent.onButtonStateChangedObservable.add(function($) {
- if ($.changes.pressed) {
- var _e = $.changes.pressed.current;
- d(_e)
- }
- }) : (s.selectionComponent = j.getMainComponent(),
- s.onButtonChangedObserver = s.selectionComponent.onButtonStateChangedObservable.add(function($) {
- if ($.changes.pressed) {
- var _e = $.changes.pressed.current;
- d(_e)
- }
- }))
- };
- i.motionController ? _(i.motionController) : i.onMotionControllerInitObservable.add(_)
- } else {
- var b = function(j) {
- s.xrController && j.inputSource === s.xrController.inputSource && s.pick && o._isControllerReadyForNearInteraction(s.id) && s.meshUnderPointer && o._nearGrabPredicate(s.meshUnderPointer) && (s.grabInteraction = !0,
- s.pickedPointVisualCue.isVisible = !1,
- o._scene.simulatePointerDown(s.pick, c))
- }
- , k = function(j) {
- s.xrController && j.inputSource === s.xrController.inputSource && s.pick && o._isControllerReadyForNearInteraction(s.id) && (o._scene.simulatePointerUp(s.pick, c),
- s.grabInteraction = !1,
- s.pickedPointVisualCue.isVisible = !0)
- };
- s.eventListeners = {
- selectend: k,
- selectstart: b
- },
- this._xrSessionManager.session.addEventListener("selectstart", b),
- this._xrSessionManager.session.addEventListener("selectend", k)
- }
- }
- ,
- e.prototype._detachController = function(i) {
- var o = this, s, c = this._controllers[i];
- if (!!c) {
- c.squeezeComponent && c.onSqueezeButtonChangedObserver && c.squeezeComponent.onButtonStateChangedObservable.remove(c.onSqueezeButtonChangedObserver),
- c.selectionComponent && c.onButtonChangedObserver && c.selectionComponent.onButtonStateChangedObservable.remove(c.onButtonChangedObserver),
- c.onFrameObserver && this._xrSessionManager.onXRFrameObservable.remove(c.onFrameObserver),
- c.eventListeners && Object.keys(c.eventListeners).forEach(function(b) {
- var k = c.eventListeners && c.eventListeners[b];
- k && o._xrSessionManager.session.removeEventListener(b, k)
- }),
- (s = c.pickIndexMeshTip) === null || s === void 0 || s.dispose(),
- c.pickedPointVisualCue.dispose();
- var d = {
- pointerId: c.id,
- pointerType: "xr"
- };
- if (this._scene.simulatePointerUp(new PickingInfo, d),
- delete this._controllers[i],
- this._attachedController === i) {
- var _ = Object.keys(this._controllers);
- _.length ? this._attachedController = _[0] : this._attachedController = ""
- }
- }
- }
- ,
- e.prototype._generateNewHandTipMesh = function() {
- var i = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || UtilityLayerRenderer.DefaultUtilityLayer.utilityLayerScene : this._scene
- , o = null
- , s = function(c, d, _) {
- var b = null;
- return b = CreateSphere(c, {
- diameter: 1
- }, _),
- b.scaling.set(d, d, d),
- b.isVisible = !1,
- b
- };
- return o = s("IndexPickSphere", this._pickRadius, i),
- o
- }
- ,
- e.prototype._pickWithSphere = function(i, o, s, c) {
- var d = new PickingInfo;
- if (d.distance = 1 / 0,
- i.pickIndexMeshTip && i.xrController)
- for (var _ = i.pickIndexMeshTip.position, b = BoundingSphere.CreateFromCenterAndRadius(_, o), k = 0; k < s.meshes.length; k++) {
- var j = s.meshes[k];
- if (!(!c(j) || !this._controllerAvailablePredicate(j, i.xrController.uniqueId))) {
- var $ = e.PickMeshWithSphere(j, b);
- $ && $.hit && $.distance < d.distance && (d.hit = $.hit,
- d.pickedMesh = j,
- d.pickedPoint = $.pickedPoint,
- d.aimTransform = i.xrController.pointer,
- d.gripTransform = i.xrController.grip || null,
- d.originMesh = i.pickIndexMeshTip,
- d.distance = $.distance)
- }
- }
- return d
- }
- ,
- e.PickMeshWithSphere = function(i, o, s) {
- s === void 0 && (s = !1);
- var c = i.subMeshes
- , d = new PickingInfo
- , _ = i.getBoundingInfo();
- if (!i._generatePointsArray() || !i.subMeshes || !_ || !s && !BoundingSphere.Intersects(_.boundingSphere, o))
- return d;
- var b = TmpVectors.Vector3[0], k = TmpVectors.Vector3[1], j = 1 / 0, $, _e, et, tt = TmpVectors.Vector3[2], rt = TmpVectors.Matrix[0];
- rt.copyFrom(i.getWorldMatrix()),
- rt.invert(),
- Vector3.TransformCoordinatesToRef(o.center, rt, tt);
- for (var it = 0; it < c.length; it++) {
- var nt = c[it];
- nt.projectToRef(tt, i._positions, i.getIndices(), k),
- Vector3.TransformCoordinatesToRef(k, i.getWorldMatrix(), k),
- $ = Vector3.Distance(k, o.center),
- et = Vector3.Distance(k, i.getAbsolutePosition()),
- _e = Vector3.Distance(o.center, i.getAbsolutePosition()),
- _e !== -1 && et !== -1 && et > _e && ($ = 0,
- k.copyFrom(o.center)),
- $ !== -1 && $ < j && (j = $,
- b.copyFrom(k))
- }
- return j < o.radius && (d.hit = !0,
- d.distance = j,
- d.pickedMesh = i,
- d.pickedPoint = b.clone()),
- d
- }
- ,
- e._idCounter = 200,
- e.Name = WebXRFeatureName.NEAR_INTERACTION,
- e.Version = 1,
- e
- }(WebXRAbstractFeature);
- WebXRFeaturesManager.AddWebXRFeature(WebXRNearInteraction.Name, function(a, e) {
- return function() {
- return new WebXRNearInteraction(a,e)
- }
- }, WebXRNearInteraction.Version, !0);
- var WebXREnterExitUIButton = function() {
- function a(e, i, o) {
- this.element = e,
- this.sessionMode = i,
- this.referenceSpaceType = o
- }
- return a.prototype.update = function(e) {}
- ,
- a
- }(), WebXREnterExitUI = function() {
- function a(e, i) {
- var o = this;
- if (this.scene = e,
- this.options = i,
- this._activeButton = null,
- this._buttons = [],
- this.activeButtonChangedObservable = new Observable,
- this._onSessionGranted = function($) {
- o._helper && o._enterXRWithButtonIndex(0)
- }
- ,
- this.overlay = document.createElement("div"),
- this.overlay.classList.add("xr-button-overlay"),
- this.overlay.style.cssText = "z-index:11;position: absolute; right: 20px;bottom: 50px;",
- !i.ignoreSessionGrantedEvent && navigator.xr && navigator.xr.addEventListener("sessiongranted", this._onSessionGranted),
- typeof window != "undefined" && window.location && window.location.protocol === "http:" && window.location.hostname !== "localhost")
- throw Tools.Warn("WebXR can only be served over HTTPS"),
- new Error("WebXR can only be served over HTTPS");
- if (i.customButtons)
- this._buttons = i.customButtons;
- else {
- var s = i.sessionMode || "immersive-vr"
- , c = i.referenceSpaceType || "local-floor"
- , 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"
- , _ = ".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) }";
- _ += '.babylonVRicon.vrdisplaypresenting { background-image: none;} .vrdisplaypresenting::after { content: "EXIT"} .xr-error::after { content: "ERROR"}';
- var b = document.createElement("style");
- b.appendChild(document.createTextNode(_)),
- document.getElementsByTagName("head")[0].appendChild(b);
- var k = document.createElement("button");
- k.className = "babylonVRicon",
- k.title = s + " - " + c,
- this._buttons.push(new WebXREnterExitUIButton(k,s,c)),
- this._buttons[this._buttons.length - 1].update = function($) {
- this.element.style.display = $ === null || $ === this ? "" : "none",
- k.className = "babylonVRicon" + ($ === this ? " vrdisplaypresenting" : "")
- }
- ,
- this._updateButtons(null)
- }
- var j = e.getEngine().getInputElement();
- j && j.parentNode && (j.parentNode.appendChild(this.overlay),
- e.onDisposeObservable.addOnce(function() {
- o.dispose()
- }))
- }
- return a.prototype.setHelperAsync = function(e, i) {
- return __awaiter(this, void 0, void 0, function() {
- var o, s, c = this;
- return __generator(this, function(d) {
- switch (d.label) {
- case 0:
- return this._helper = e,
- this._renderTarget = i,
- o = this._buttons.map(function(_) {
- return e.sessionManager.isSessionSupportedAsync(_.sessionMode)
- }),
- e.onStateChangedObservable.add(function(_) {
- _ == WebXRState.NOT_IN_XR && c._updateButtons(null)
- }),
- [4, Promise.all(o)];
- case 1:
- return s = d.sent(),
- s.forEach(function(_, b) {
- _ ? (c.overlay.appendChild(c._buttons[b].element),
- c._buttons[b].element.onclick = c._enterXRWithButtonIndex.bind(c, b)) : Tools.Warn('Session mode "' + c._buttons[b].sessionMode + '" not supported in browser')
- }),
- [2]
- }
- })
- })
- }
- ,
- a.CreateAsync = function(e, i, o) {
- return __awaiter(this, void 0, void 0, function() {
- var s;
- return __generator(this, function(c) {
- switch (c.label) {
- case 0:
- return s = new a(e,o),
- [4, s.setHelperAsync(i, o.renderTarget || void 0)];
- case 1:
- return c.sent(),
- [2, s]
- }
- })
- })
- }
- ,
- a.prototype._enterXRWithButtonIndex = function(e) {
- return e === void 0 && (e = 0),
- __awaiter(this, void 0, void 0, function() {
- var i, o, s;
- return __generator(this, function(c) {
- switch (c.label) {
- case 0:
- return this._helper.state != WebXRState.IN_XR ? [3, 2] : [4, this._helper.exitXRAsync()];
- case 1:
- return c.sent(),
- this._updateButtons(null),
- [3, 6];
- case 2:
- if (this._helper.state != WebXRState.NOT_IN_XR)
- return [3, 6];
- c.label = 3;
- case 3:
- return c.trys.push([3, 5, , 6]),
- [4, this._helper.enterXRAsync(this._buttons[e].sessionMode, this._buttons[e].referenceSpaceType, this._renderTarget, {
- optionalFeatures: this.options.optionalFeatures,
- requiredFeatures: this.options.requiredFeatures
- })];
- case 4:
- return c.sent(),
- this._updateButtons(this._buttons[e]),
- [3, 6];
- case 5:
- return i = c.sent(),
- this._updateButtons(null),
- o = this._buttons[e].element,
- s = o.title,
- o.title = "Error entering XR session : " + s,
- o.classList.add("xr-error"),
- this.options.onError && this.options.onError(i),
- [3, 6];
- case 6:
- return [2]
- }
- })
- })
- }
- ,
- a.prototype.dispose = function() {
- var e = this.scene.getEngine().getInputElement();
- e && e.parentNode && e.parentNode.contains(this.overlay) && e.parentNode.removeChild(this.overlay),
- this.activeButtonChangedObservable.clear(),
- navigator.xr.removeEventListener("sessiongranted", this._onSessionGranted)
- }
- ,
- a.prototype._updateButtons = function(e) {
- var i = this;
- this._activeButton = e,
- this._buttons.forEach(function(o) {
- o.update(i._activeButton)
- }),
- this.activeButtonChangedObservable.notifyObservers(this._activeButton)
- }
- ,
- a
- }(), TimerState;
- (function(a) {
- a[a.INIT = 0] = "INIT",
- a[a.STARTED = 1] = "STARTED",
- a[a.ENDED = 2] = "ENDED"
- }
- )(TimerState || (TimerState = {}));
- function setAndStartTimer(a) {
- var e, i = 0, o = Date.now();
- a.observableParameters = (e = a.observableParameters) !== null && e !== void 0 ? e : {};
- var s = a.contextObservable.add(function(c) {
- var d = Date.now();
- i = d - o;
- var _ = {
- startTime: o,
- currentTime: d,
- deltaTime: i,
- completeRate: i / a.timeout,
- payload: c
- };
- a.onTick && a.onTick(_),
- a.breakCondition && a.breakCondition() && (a.contextObservable.remove(s),
- a.onAborted && a.onAborted(_)),
- i >= a.timeout && (a.contextObservable.remove(s),
- a.onEnded && a.onEnded(_))
- }, a.observableParameters.mask, a.observableParameters.insertFirst, a.observableParameters.scope);
- return s
- }
- (function() {
- function a(e) {
- var i = this, o, s;
- this.onEachCountObservable = new Observable,
- this.onTimerAbortedObservable = new Observable,
- this.onTimerEndedObservable = new Observable,
- this.onStateChangedObservable = new Observable,
- this._observer = null,
- this._breakOnNextTick = !1,
- this._tick = function(c) {
- var d = Date.now();
- i._timer = d - i._startTime;
- var _ = {
- startTime: i._startTime,
- currentTime: d,
- deltaTime: i._timer,
- completeRate: i._timer / i._timeToEnd,
- payload: c
- }
- , b = i._breakOnNextTick || i._breakCondition(_);
- b || i._timer >= i._timeToEnd ? i._stop(_, b) : i.onEachCountObservable.notifyObservers(_)
- }
- ,
- this._setState(TimerState.INIT),
- this._contextObservable = e.contextObservable,
- this._observableParameters = (o = e.observableParameters) !== null && o !== void 0 ? o : {},
- this._breakCondition = (s = e.breakCondition) !== null && s !== void 0 ? s : function() {
- return !1
- }
- ,
- e.onEnded && this.onTimerEndedObservable.add(e.onEnded),
- e.onTick && this.onEachCountObservable.add(e.onTick),
- e.onAborted && this.onTimerAbortedObservable.add(e.onAborted)
- }
- return Object.defineProperty(a.prototype, "breakCondition", {
- set: function(e) {
- this._breakCondition = e
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.clearObservables = function() {
- this.onEachCountObservable.clear(),
- this.onTimerAbortedObservable.clear(),
- this.onTimerEndedObservable.clear(),
- this.onStateChangedObservable.clear()
- }
- ,
- a.prototype.start = function(e) {
- if (e === void 0 && (e = this._timeToEnd),
- this._state === TimerState.STARTED)
- throw new Error("Timer already started. Please stop it before starting again");
- this._timeToEnd = e,
- this._startTime = Date.now(),
- this._timer = 0,
- this._observer = this._contextObservable.add(this._tick, this._observableParameters.mask, this._observableParameters.insertFirst, this._observableParameters.scope),
- this._setState(TimerState.STARTED)
- }
- ,
- a.prototype.stop = function() {
- this._state === TimerState.STARTED && (this._breakOnNextTick = !0)
- }
- ,
- a.prototype.dispose = function() {
- this._observer && this._contextObservable.remove(this._observer),
- this.clearObservables()
- }
- ,
- a.prototype._setState = function(e) {
- this._state = e,
- this.onStateChangedObservable.notifyObservers(this._state)
- }
- ,
- a.prototype._stop = function(e, i) {
- i === void 0 && (i = !1),
- this._contextObservable.remove(this._observer),
- this._setState(TimerState.ENDED),
- i ? this.onTimerAbortedObservable.notifyObservers(e) : this.onTimerEndedObservable.notifyObservers(e)
- }
- ,
- a
- }
- )();
- var WebXRMotionControllerTeleportation = function(a) {
- __extends(e, a);
- function e(i, o) {
- var s = a.call(this, i) || this;
- return s._options = o,
- s._controllers = {},
- s._snappedToPoint = !1,
- s._tmpRay = new Ray(new Vector3,new Vector3),
- s._tmpVector = new Vector3,
- s._tmpQuaternion = new Quaternion,
- s.skipNextTeleportation = !1,
- s.backwardsMovementEnabled = !0,
- s.backwardsTeleportationDistance = .7,
- s.parabolicCheckRadius = 5,
- s.parabolicRayEnabled = !0,
- s.straightRayEnabled = !0,
- s.rotationAngle = Math.PI / 8,
- s.onTargetMeshPositionUpdatedObservable = new Observable,
- s.teleportationEnabled = !0,
- s._rotationEnabled = !0,
- s._attachController = function(c) {
- if (!(s._controllers[c.uniqueId] || s._options.forceHandedness && c.inputSource.handedness !== s._options.forceHandedness)) {
- s._controllers[c.uniqueId] = {
- xrController: c,
- teleportationState: {
- forward: !1,
- backwards: !1,
- rotating: !1,
- currentRotation: 0,
- baseRotation: 0
- }
- };
- var d = s._controllers[c.uniqueId];
- if (d.xrController.inputSource.targetRayMode === "tracked-pointer" && d.xrController.inputSource.gamepad) {
- var _ = function() {
- if (c.motionController) {
- var b = c.motionController.getComponentOfType(WebXRControllerComponent.THUMBSTICK_TYPE) || c.motionController.getComponentOfType(WebXRControllerComponent.TOUCHPAD_TYPE);
- if (!b || s._options.useMainComponentOnly) {
- var k = c.motionController.getMainComponent();
- if (!k)
- return;
- d.teleportationComponent = k,
- d.onButtonChangedObserver = k.onButtonStateChangedObservable.add(function() {
- if (!!s.teleportationEnabled && k.changes.pressed)
- if (k.changes.pressed.current) {
- d.teleportationState.forward = !0,
- s._currentTeleportationControllerId = d.xrController.uniqueId,
- d.teleportationState.baseRotation = s._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y,
- d.teleportationState.currentRotation = 0;
- var j = s._options.timeToTeleport || 3e3;
- setAndStartTimer({
- timeout: j,
- contextObservable: s._xrSessionManager.onXRFrameObservable,
- breakCondition: function() {
- return !k.pressed
- },
- onEnded: function() {
- s._currentTeleportationControllerId === d.xrController.uniqueId && d.teleportationState.forward && s._teleportForward(c.uniqueId)
- }
- })
- } else
- d.teleportationState.forward = !1,
- s._currentTeleportationControllerId = ""
- })
- } else
- d.teleportationComponent = b,
- d.onAxisChangedObserver = b.onAxisValueChangedObservable.add(function(j) {
- if (j.y <= .7 && d.teleportationState.backwards && (d.teleportationState.backwards = !1),
- j.y > .7 && !d.teleportationState.forward && s.backwardsMovementEnabled && !s.snapPointsOnly && !d.teleportationState.backwards) {
- d.teleportationState.backwards = !0,
- s._tmpQuaternion.copyFrom(s._options.xrInput.xrCamera.rotationQuaternion),
- s._tmpQuaternion.toEulerAnglesToRef(s._tmpVector),
- s._tmpVector.x = 0,
- s._tmpVector.z = 0,
- Quaternion.FromEulerVectorToRef(s._tmpVector, s._tmpQuaternion),
- s._tmpVector.set(0, 0, s.backwardsTeleportationDistance * (s._xrSessionManager.scene.useRightHandedSystem ? 1 : -1)),
- s._tmpVector.rotateByQuaternionToRef(s._tmpQuaternion, s._tmpVector),
- s._tmpVector.addInPlace(s._options.xrInput.xrCamera.position),
- s._tmpRay.origin.copyFrom(s._tmpVector),
- s._tmpRay.length = s._options.xrInput.xrCamera.realWorldHeight + .1,
- s._tmpRay.direction.set(0, -1, 0);
- var $ = s._xrSessionManager.scene.pickWithRay(s._tmpRay, function(et) {
- return s._floorMeshes.indexOf(et) !== -1
- });
- $ && $.pickedPoint && (s._options.xrInput.xrCamera.position.x = $.pickedPoint.x,
- s._options.xrInput.xrCamera.position.z = $.pickedPoint.z)
- }
- if (j.y < -.7 && !s._currentTeleportationControllerId && !d.teleportationState.rotating && s.teleportationEnabled && (d.teleportationState.forward = !0,
- s._currentTeleportationControllerId = d.xrController.uniqueId,
- d.teleportationState.baseRotation = s._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y),
- j.x) {
- if (d.teleportationState.forward)
- s._currentTeleportationControllerId === d.xrController.uniqueId && (s.rotationEnabled ? setTimeout(function() {
- d.teleportationState.currentRotation = Math.atan2(j.x, j.y * (s._xrSessionManager.scene.useRightHandedSystem ? 1 : -1))
- }) : d.teleportationState.currentRotation = 0);
- else if (!d.teleportationState.rotating && Math.abs(j.x) > .7) {
- d.teleportationState.rotating = !0;
- var _e = s.rotationAngle * (j.x > 0 ? 1 : -1) * (s._xrSessionManager.scene.useRightHandedSystem ? -1 : 1);
- Quaternion.FromEulerAngles(0, _e, 0).multiplyToRef(s._options.xrInput.xrCamera.rotationQuaternion, s._options.xrInput.xrCamera.rotationQuaternion)
- }
- } else
- d.teleportationState.rotating = !1;
- j.x === 0 && j.y === 0 && d.teleportationState.forward && s._teleportForward(c.uniqueId)
- })
- }
- };
- c.motionController ? _() : c.onMotionControllerInitObservable.addOnce(function() {
- _()
- })
- } else
- s._xrSessionManager.scene.onPointerObservable.add(function(b) {
- if (b.type === PointerEventTypes.POINTERDOWN) {
- d.teleportationState.forward = !0,
- s._currentTeleportationControllerId = d.xrController.uniqueId,
- d.teleportationState.baseRotation = s._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y,
- d.teleportationState.currentRotation = 0;
- var k = s._options.timeToTeleport || 3e3;
- setAndStartTimer({
- timeout: k,
- contextObservable: s._xrSessionManager.onXRFrameObservable,
- onEnded: function() {
- s._currentTeleportationControllerId === d.xrController.uniqueId && d.teleportationState.forward && s._teleportForward(c.uniqueId)
- }
- })
- } else
- b.type === PointerEventTypes.POINTERUP && (d.teleportationState.forward = !1,
- s._currentTeleportationControllerId = "")
- })
- }
- }
- ,
- s._options.teleportationTargetMesh || s._createDefaultTargetMesh(),
- s._floorMeshes = s._options.floorMeshes || [],
- s._snapToPositions = s._options.snapPositions || [],
- s._setTargetMeshVisibility(!1),
- s
- }
- return Object.defineProperty(e.prototype, "rotationEnabled", {
- get: function() {
- return this._rotationEnabled
- },
- set: function(i) {
- if (this._rotationEnabled = i,
- this._options.teleportationTargetMesh) {
- var o = this._options.teleportationTargetMesh.getChildMeshes(!1, function(s) {
- return s.name === "rotationCone"
- });
- o[0] && o[0].setEnabled(i)
- }
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "teleportationTargetMesh", {
- get: function() {
- return this._options.teleportationTargetMesh || null
- },
- enumerable: !1,
- configurable: !0
- }),
- Object.defineProperty(e.prototype, "snapPointsOnly", {
- get: function() {
- return !!this._options.snapPointsOnly
- },
- set: function(i) {
- this._options.snapPointsOnly = i
- },
- enumerable: !1,
- configurable: !0
- }),
- e.prototype.addFloorMesh = function(i) {
- this._floorMeshes.push(i)
- }
- ,
- e.prototype.addBlockerMesh = function(i) {
- this._options.pickBlockerMeshes = this._options.pickBlockerMeshes || [],
- this._options.pickBlockerMeshes.push(i)
- }
- ,
- e.prototype.addSnapPoint = function(i) {
- this._snapToPositions.push(i)
- }
- ,
- e.prototype.attach = function() {
- var i = this;
- return a.prototype.attach.call(this) ? (this._currentTeleportationControllerId = "",
- this._options.xrInput.controllers.forEach(this._attachController),
- this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable, this._attachController),
- this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable, function(o) {
- i._detachController(o.uniqueId)
- }),
- !0) : !1
- }
- ,
- e.prototype.detach = function() {
- var i = this;
- return a.prototype.detach.call(this) ? (Object.keys(this._controllers).forEach(function(o) {
- i._detachController(o)
- }),
- this._setTargetMeshVisibility(!1),
- this._currentTeleportationControllerId = "",
- this._controllers = {},
- !0) : !1
- }
- ,
- e.prototype.dispose = function() {
- a.prototype.dispose.call(this),
- this._options.teleportationTargetMesh && this._options.teleportationTargetMesh.dispose(!1, !0)
- }
- ,
- e.prototype.removeFloorMesh = function(i) {
- var o = this._floorMeshes.indexOf(i);
- o !== -1 && this._floorMeshes.splice(o, 1)
- }
- ,
- e.prototype.removeBlockerMesh = function(i) {
- this._options.pickBlockerMeshes = this._options.pickBlockerMeshes || [];
- var o = this._options.pickBlockerMeshes.indexOf(i);
- o !== -1 && this._options.pickBlockerMeshes.splice(o, 1)
- }
- ,
- e.prototype.removeFloorMeshByName = function(i) {
- var o = this._xrSessionManager.scene.getMeshByName(i);
- o && this.removeFloorMesh(o)
- }
- ,
- e.prototype.removeSnapPoint = function(i) {
- var o = this._snapToPositions.indexOf(i);
- if (o === -1) {
- for (var s = 0; s < this._snapToPositions.length; ++s)
- if (this._snapToPositions[s].equals(i)) {
- o = s;
- break
- }
- }
- return o !== -1 ? (this._snapToPositions.splice(o, 1),
- !0) : !1
- }
- ,
- e.prototype.setSelectionFeature = function(i) {
- this._selectionFeature = i
- }
- ,
- e.prototype._onXRFrame = function(i) {
- var o = this
- , s = this._xrSessionManager.currentFrame
- , c = this._xrSessionManager.scene;
- if (!(!this.attach || !s)) {
- var d = this._options.teleportationTargetMesh;
- if (this._currentTeleportationControllerId) {
- if (!d)
- return;
- d.rotationQuaternion = d.rotationQuaternion || new Quaternion;
- var _ = this._controllers[this._currentTeleportationControllerId];
- if (_ && _.teleportationState.forward) {
- Quaternion.RotationYawPitchRollToRef(_.teleportationState.currentRotation + _.teleportationState.baseRotation, 0, 0, d.rotationQuaternion);
- var b = !1;
- if (_.xrController.getWorldPointerRayToRef(this._tmpRay),
- this.straightRayEnabled) {
- var k = c.pickWithRay(this._tmpRay, function(et) {
- if (o._options.pickBlockerMeshes && o._options.pickBlockerMeshes.indexOf(et) !== -1)
- return !0;
- var tt = o._floorMeshes.indexOf(et);
- return tt === -1 ? !1 : o._floorMeshes[tt].absolutePosition.y < o._options.xrInput.xrCamera.globalPosition.y
- });
- if (k && k.pickedMesh && this._options.pickBlockerMeshes && this._options.pickBlockerMeshes.indexOf(k.pickedMesh) !== -1)
- return;
- k && k.pickedPoint && (b = !0,
- this._setTargetMeshPosition(k),
- this._setTargetMeshVisibility(!0),
- this._showParabolicPath(k))
- }
- if (this.parabolicRayEnabled && !b) {
- var j = _.xrController.pointer.rotationQuaternion.toEulerAngles().x
- , $ = 1 + (Math.PI / 2 - Math.abs(j))
- , _e = this.parabolicCheckRadius * $;
- this._tmpRay.origin.addToRef(this._tmpRay.direction.scale(_e * 2), this._tmpVector),
- this._tmpVector.y = this._tmpRay.origin.y,
- this._tmpRay.origin.addInPlace(this._tmpRay.direction.scale(_e)),
- this._tmpVector.subtractToRef(this._tmpRay.origin, this._tmpRay.direction),
- this._tmpRay.direction.normalize();
- var k = c.pickWithRay(this._tmpRay, function(tt) {
- return o._options.pickBlockerMeshes && o._options.pickBlockerMeshes.indexOf(tt) !== -1 ? !0 : o._floorMeshes.indexOf(tt) !== -1
- });
- if (k && k.pickedMesh && this._options.pickBlockerMeshes && this._options.pickBlockerMeshes.indexOf(k.pickedMesh) !== -1)
- return;
- k && k.pickedPoint && (b = !0,
- this._setTargetMeshPosition(k),
- this._setTargetMeshVisibility(!0),
- this._showParabolicPath(k))
- }
- this._setTargetMeshVisibility(b)
- } else
- this._setTargetMeshVisibility(!1)
- } else
- this._setTargetMeshVisibility(!1)
- }
- }
- ,
- e.prototype._createDefaultTargetMesh = function() {
- this._options.defaultTargetMeshOptions = this._options.defaultTargetMeshOptions || {};
- var i = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || UtilityLayerRenderer.DefaultUtilityLayer.utilityLayerScene : this._xrSessionManager.scene
- , o = CreateGround("teleportationTarget", {
- width: 2,
- height: 2,
- subdivisions: 2
- }, i);
- o.isPickable = !1;
- var s = 512
- , c = new DynamicTexture("teleportationPlaneDynamicTexture",s,i,!0);
- c.hasAlpha = !0;
- var d = c.getContext()
- , _ = s / 2
- , b = s / 2
- , k = 200;
- d.beginPath(),
- d.arc(_, b, k, 0, 2 * Math.PI, !1),
- d.fillStyle = this._options.defaultTargetMeshOptions.teleportationFillColor || "#444444",
- d.fill(),
- d.lineWidth = 10,
- d.strokeStyle = this._options.defaultTargetMeshOptions.teleportationBorderColor || "#FFFFFF",
- d.stroke(),
- d.closePath(),
- c.update();
- var j = new StandardMaterial("teleportationPlaneMaterial",i);
- j.diffuseTexture = c,
- o.material = j;
- var $ = CreateTorus("torusTeleportation", {
- diameter: .75,
- thickness: .1,
- tessellation: 20
- }, i);
- if ($.isPickable = !1,
- $.parent = o,
- !this._options.defaultTargetMeshOptions.disableAnimation) {
- var _e = new Animation("animationInnerCircle","position.y",30,Animation.ANIMATIONTYPE_FLOAT,Animation.ANIMATIONLOOPMODE_CYCLE)
- , et = [];
- et.push({
- frame: 0,
- value: 0
- }),
- et.push({
- frame: 30,
- value: .4
- }),
- et.push({
- frame: 60,
- value: 0
- }),
- _e.setKeys(et);
- var tt = new SineEase;
- tt.setEasingMode(EasingFunction.EASINGMODE_EASEINOUT),
- _e.setEasingFunction(tt),
- $.animations = [],
- $.animations.push(_e),
- i.beginAnimation($, 0, 60, !0)
- }
- var rt = CreateCylinder("rotationCone", {
- diameterTop: 0,
- tessellation: 4
- }, i);
- if (rt.isPickable = !1,
- rt.scaling.set(.5, .12, .2),
- rt.rotate(Axis.X, Math.PI / 2),
- rt.position.z = .6,
- rt.parent = $,
- this._options.defaultTargetMeshOptions.torusArrowMaterial)
- $.material = this._options.defaultTargetMeshOptions.torusArrowMaterial,
- rt.material = this._options.defaultTargetMeshOptions.torusArrowMaterial;
- else {
- var it = new StandardMaterial("torusConsMat",i);
- it.disableLighting = !!this._options.defaultTargetMeshOptions.disableLighting,
- it.disableLighting ? it.emissiveColor = new Color3(.3,.3,1) : it.diffuseColor = new Color3(.3,.3,1),
- it.alpha = .9,
- $.material = it,
- rt.material = it,
- this._teleportationRingMaterial = it
- }
- this._options.renderingGroupId !== void 0 && (o.renderingGroupId = this._options.renderingGroupId,
- $.renderingGroupId = this._options.renderingGroupId,
- rt.renderingGroupId = this._options.renderingGroupId),
- this._options.teleportationTargetMesh = o
- }
- ,
- e.prototype._detachController = function(i) {
- var o = this._controllers[i];
- !o || (o.teleportationComponent && (o.onAxisChangedObserver && o.teleportationComponent.onAxisValueChangedObservable.remove(o.onAxisChangedObserver),
- o.onButtonChangedObserver && o.teleportationComponent.onButtonStateChangedObservable.remove(o.onButtonChangedObserver)),
- delete this._controllers[i])
- }
- ,
- e.prototype._findClosestSnapPointWithRadius = function(i, o) {
- o === void 0 && (o = this._options.snapToPositionRadius || .8);
- var s = null
- , c = Number.MAX_VALUE;
- if (this._snapToPositions.length) {
- var d = o * o;
- this._snapToPositions.forEach(function(_) {
- var b = Vector3.DistanceSquared(_, i);
- b <= d && b < c && (c = b,
- s = _)
- })
- }
- return s
- }
- ,
- e.prototype._setTargetMeshPosition = function(i) {
- var o = i.pickedPoint;
- if (!(!this._options.teleportationTargetMesh || !o)) {
- var s = this._findClosestSnapPointWithRadius(o);
- this._snappedToPoint = !!s,
- 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),
- this._options.teleportationTargetMesh.position.copyFrom(s || o),
- this._options.teleportationTargetMesh.position.y += .01,
- this.onTargetMeshPositionUpdatedObservable.notifyObservers(i)
- }
- }
- ,
- e.prototype._setTargetMeshVisibility = function(i) {
- !this._options.teleportationTargetMesh || this._options.teleportationTargetMesh.isVisible !== i && (this._options.teleportationTargetMesh.isVisible = i,
- this._options.teleportationTargetMesh.getChildren(void 0, !1).forEach(function(o) {
- o.isVisible = i
- }),
- i ? this._selectionFeature && this._selectionFeature.detach() : (this._quadraticBezierCurve && (this._quadraticBezierCurve.dispose(),
- this._quadraticBezierCurve = null),
- this._selectionFeature && this._selectionFeature.attach()))
- }
- ,
- e.prototype._showParabolicPath = function(i) {
- if (!!i.pickedPoint) {
- var o = this._options.useUtilityLayer ? this._options.customUtilityLayerScene || UtilityLayerRenderer.DefaultUtilityLayer.utilityLayerScene : this._xrSessionManager.scene
- , s = this._controllers[this._currentTeleportationControllerId]
- , c = Curve3.CreateQuadraticBezier(s.xrController.pointer.absolutePosition, i.ray.origin, i.pickedPoint, 25);
- this._options.generateRayPathMesh ? this._quadraticBezierCurve = this._options.generateRayPathMesh(c.getPoints(), i) : this._quadraticBezierCurve = CreateLines("teleportation path line", {
- points: c.getPoints(),
- instance: this._quadraticBezierCurve,
- updatable: !0
- }, o),
- this._quadraticBezierCurve.isPickable = !1,
- this._options.renderingGroupId !== void 0 && (this._quadraticBezierCurve.renderingGroupId = this._options.renderingGroupId)
- }
- }
- ,
- e.prototype._teleportForward = function(i) {
- var o = this._controllers[i];
- if (!(!o || !o.teleportationState.forward || !this.teleportationEnabled) && (o.teleportationState.forward = !1,
- this._currentTeleportationControllerId = "",
- !(this.snapPointsOnly && !this._snappedToPoint))) {
- if (this.skipNextTeleportation) {
- this.skipNextTeleportation = !1;
- return
- }
- if (this._options.teleportationTargetMesh && this._options.teleportationTargetMesh.isVisible) {
- var s = this._options.xrInput.xrCamera.realWorldHeight;
- this._options.xrInput.xrCamera.onBeforeCameraTeleport.notifyObservers(this._options.xrInput.xrCamera.position),
- this._options.xrInput.xrCamera.position.copyFrom(this._options.teleportationTargetMesh.position),
- this._options.xrInput.xrCamera.position.y += s,
- 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),
- this._options.xrInput.xrCamera.onAfterCameraTeleport.notifyObservers(this._options.xrInput.xrCamera.position)
- }
- }
- }
- ,
- e.Name = WebXRFeatureName.TELEPORTATION,
- e.Version = 1,
- e
- }(WebXRAbstractFeature);
- WebXRFeaturesManager.AddWebXRFeature(WebXRMotionControllerTeleportation.Name, function(a, e) {
- return function() {
- return new WebXRMotionControllerTeleportation(a,e)
- }
- }, WebXRMotionControllerTeleportation.Version, !0);
- var WebXRDefaultExperience = function() {
- function a() {}
- return a.CreateAsync = function(e, i) {
- i === void 0 && (i = {});
- var o = new a;
- if (!i.disableDefaultUI) {
- var s = __assign({
- renderTarget: o.renderTarget
- }, i.uiOptions || {});
- i.optionalFeatures && (typeof i.optionalFeatures == "boolean" ? s.optionalFeatures = ["hit-test", "anchors", "plane-detection", "hand-tracking"] : s.optionalFeatures = i.optionalFeatures),
- o.enterExitUI = new WebXREnterExitUI(e,s)
- }
- return WebXRExperienceHelper.CreateAsync(e).then(function(c) {
- if (o.baseExperience = c,
- i.ignoreNativeCameraTransformation && (o.baseExperience.camera.compensateOnFirstFrame = !1),
- o.input = new WebXRInput(c.sessionManager,c.camera,__assign({
- controllerOptions: {
- renderingGroupId: i.renderingGroupId
- }
- }, i.inputOptions || {})),
- !i.disablePointerSelection) {
- var d = __assign(__assign({}, i.pointerSelectionOptions), {
- xrInput: o.input,
- renderingGroupId: i.renderingGroupId
- });
- o.pointerSelection = o.baseExperience.featuresManager.enableFeature(WebXRControllerPointerSelection.Name, i.useStablePlugins ? "stable" : "latest", d),
- i.disableTeleportation || (o.teleportation = o.baseExperience.featuresManager.enableFeature(WebXRMotionControllerTeleportation.Name, i.useStablePlugins ? "stable" : "latest", {
- floorMeshes: i.floorMeshes,
- xrInput: o.input,
- renderingGroupId: i.renderingGroupId
- }),
- o.teleportation.setSelectionFeature(o.pointerSelection))
- }
- if (i.disableNearInteraction || (o.nearInteraction = o.baseExperience.featuresManager.enableFeature(WebXRNearInteraction.Name, i.useStablePlugins ? "stable" : "latest", {
- xrInput: o.input,
- farInteractionFeature: o.pointerSelection,
- renderingGroupId: i.renderingGroupId,
- useUtilityLayer: !0,
- enableNearInteractionOnAllControllers: !0
- })),
- o.renderTarget = o.baseExperience.sessionManager.getWebXRRenderTarget(i.outputCanvasOptions),
- !i.disableDefaultUI)
- return o.enterExitUI.setHelperAsync(o.baseExperience, o.renderTarget)
- }).then(function() {
- return o
- }).catch(function(c) {
- return Logger$2.Error("Error initializing XR"),
- Logger$2.Error(c),
- o
- })
- }
- ,
- a.prototype.dispose = function() {
- this.baseExperience && this.baseExperience.dispose(),
- this.input && this.input.dispose(),
- this.enterExitUI && this.enterExitUI.dispose(),
- this.renderTarget && this.renderTarget.dispose()
- }
- ,
- a
- }();
- Scene.prototype.createDefaultLight = function(a) {
- if (a === void 0 && (a = !1),
- a && this.lights)
- for (var e = 0; e < this.lights.length; e++)
- this.lights[e].dispose();
- this.lights.length === 0 && new HemisphericLight("default light",Vector3.Up(),this)
- }
- ;
- Scene.prototype.createDefaultCamera = function(a, e, i) {
- if (a === void 0 && (a = !1),
- e === void 0 && (e = !1),
- i === void 0 && (i = !1),
- e && this.activeCamera && (this.activeCamera.dispose(),
- this.activeCamera = null),
- !this.activeCamera) {
- var o = this.getWorldExtends(function(j) {
- return j.isVisible && j.isEnabled()
- }), s = o.max.subtract(o.min), c = o.min.add(s.scale(.5)), d, _ = s.length() * 1.5;
- if (isFinite(_) || (_ = 1,
- c.copyFromFloats(0, 0, 0)),
- a) {
- var b = new ArcRotateCamera("default camera",-(Math.PI / 2),Math.PI / 2,_,c,this);
- b.lowerRadiusLimit = _ * .01,
- b.wheelPrecision = 100 / _,
- d = b
- } else {
- var k = new FreeCamera("default camera",new Vector3(c.x,c.y,-_),this);
- k.setTarget(c),
- d = k
- }
- d.minZ = _ * .01,
- d.maxZ = _ * 1e3,
- d.speed = _ * .2,
- this.activeCamera = d,
- i && d.attachControl()
- }
- }
- ;
- Scene.prototype.createDefaultCameraOrLight = function(a, e, i) {
- a === void 0 && (a = !1),
- e === void 0 && (e = !1),
- i === void 0 && (i = !1),
- this.createDefaultLight(e),
- this.createDefaultCamera(a, e, i)
- }
- ;
- Scene.prototype.createDefaultSkybox = function(a, e, i, o, s) {
- if (e === void 0 && (e = !1),
- i === void 0 && (i = 1e3),
- o === void 0 && (o = 0),
- s === void 0 && (s = !0),
- !a)
- return Logger$2.Warn("Can not create default skybox without environment texture."),
- null;
- s && a && (this.environmentTexture = a);
- var c = CreateBox("hdrSkyBox", {
- size: i
- }, this);
- if (e) {
- var d = new PBRMaterial("skyBox",this);
- d.backFaceCulling = !1,
- d.reflectionTexture = a.clone(),
- d.reflectionTexture && (d.reflectionTexture.coordinatesMode = Texture.SKYBOX_MODE),
- d.microSurface = 1 - o,
- d.disableLighting = !0,
- d.twoSidedLighting = !0,
- c.material = d
- } else {
- var _ = new StandardMaterial("skyBox",this);
- _.backFaceCulling = !1,
- _.reflectionTexture = a.clone(),
- _.reflectionTexture && (_.reflectionTexture.coordinatesMode = Texture.SKYBOX_MODE),
- _.disableLighting = !0,
- c.material = _
- }
- return c.isPickable = !1,
- c.infiniteDistance = !0,
- c.ignoreCameraMaxZ = !0,
- c
- }
- ;
- Scene.prototype.createDefaultEnvironment = function(a) {
- return EnvironmentHelper ? new EnvironmentHelper(a,this) : null
- }
- ;
- Scene.prototype.createDefaultVRExperience = function(a) {
- return a === void 0 && (a = {}),
- new VRExperienceHelper(this,a)
- }
- ;
- Scene.prototype.createDefaultXRExperienceAsync = function(a) {
- return a === void 0 && (a = {}),
- WebXRDefaultExperience.CreateAsync(this, a).then(function(e) {
- return e
- })
- }
- ;
- var EMeshType = (a=>(a.XAvatar = "XAvatar",
- a.XStaticMesh = "XStaticMesh",
- a.XBreathPoint = "breathpoint",
- a.Decal = "decal",
- a.Cgplane = "cgplane",
- a.Tv = "tv",
- a.XSubSequence = "XSubSequence",
- a.XBillboard = "XBillboard",
- a))(EMeshType || {});
- const checkOS = ()=>{
- const a = navigator.userAgent
- , e = /(?:Windows Phone)/.test(a)
- , i = /(?:SymbianOS)/.test(a) || e
- , o = /(?:Android)/.test(a)
- , s = /(?:Firefox)/.test(a);
- /(?:Chrome|CriOS)/.test(a);
- const c = /(?:iPad|PlayBook)/.test(a) || o && !/(?:Mobile)/.test(a) || s && /(?:Tablet)/.test(a)
- , d = /(?:iPhone|ipad|ipod)/.test(a) && !c
- , _ = !d && !o && !i;
- return {
- isTablet: c,
- isPhone: d,
- isIOS: /iPhone|iPod|iPad/.test(navigator.userAgent),
- isAndroid: o,
- isPc: _
- }
- }
- , ue4Rotation2Xverse = a=>isRotationCorrect() ? (a.pitch >= 89.5 ? a.pitch = 89.5 : a.pitch <= -89.5 && (a.pitch = -89.5),
- 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
- , 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
- , scaleFromUE4toXverse = 100
- , ue4Scaling2Xverse = a=>isScalingCorrect() ? new Vector3(a.x,a.z,-1 * a.y) : null
- , ue4Position2Xverse = a=>isPositionCorrect() ? new Vector3(a.x * .01,a.z * .01,-1 * a.y * .01) : null
- , xversePosition2Ue4 = a=>isPositionCorrect() ? {
- x: a.x * 100,
- y: -1 * a.z * 100,
- z: a.y * 100
- } : null
- , xverseRotation2Ue4 = a=>{
- if (isPositionCorrect()) {
- let e = 0;
- return a.z == 0 ? e = 0 : e = 180 * a.z / Math.PI,
- {
- pitch: 180 * a.x * -1 / Math.PI,
- yaw: (a.y + Math.PI * 27 / 18) * 180 / Math.PI,
- roll: e
- }
- } else
- return null
- }
- , xverseRotation2Ue4_mesh = a=>{
- if (isPositionCorrect()) {
- let e = 0;
- return a.z == 0 ? e = 0 : e = -1 * (180 * a.z) / Math.PI,
- {
- pitch: 180 * a.x / Math.PI,
- yaw: a.y * 180 / Math.PI,
- roll: e
- }
- } else
- return null
- }
- , 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))
- , 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))
- , isPositionCorrect = a=>!0
- , isScalingCorrect = a=>!0
- , 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))
- , isRotationCorrect = a=>!0
- , getStringBoundaries = (a,e,i=new Map)=>{
- let o = 0
- , s = ""
- , c = -1
- , d = 0;
- const _ = [0];
- for (let b = 0; b < a.length; b++) {
- const k = a.codePointAt(b);
- let j = i.get(k);
- if (j)
- o += j,
- s += a[b],
- k > 64 && k < 91 || k > 96 && k < 123 ? (c == -1 && (c = b),
- d += j) : (c = -1,
- d = 0);
- else if (k < 975 || k > 1024 && k < 1920)
- j = 1,
- o++,
- s += a[b],
- k > 64 && k < 91 || k > 96 && k < 123 ? (c == -1 && (c = b),
- d += j) : (c = -1,
- d = 0);
- 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)
- j = 2,
- o += 2,
- c = -1,
- d = 0,
- s += a[b];
- else if (k > 9311 && k < 11158) {
- j = 2,
- o += 2,
- c = -1,
- d = 0,
- s += a[b];
- const $ = a.codePointAt(b + 1);
- $ > 65023 && $ < 65040 && (s += a[b + 1],
- b++)
- } else
- k > 126979 && k < 129783 && (j = 2,
- o += 2,
- c = -1,
- d = 0,
- b++,
- s += String.fromCodePoint(k));
- if (b == _[_.length - 1] + 1 && c > 0 ? (_[_.length - 1] = c,
- o = 0 + d) : o > e && (_.push(b),
- d >= o && (d = 0 + j,
- c = 0),
- o = 0 + j),
- b >= a.length - 1)
- break
- }
- return _[_.length - 1] != a.length && _.push(a.length),
- [s, _]
- }
- , getAlphaWidthMap = (a,e)=>{
- const i = new DynamicTexture("test",3,e)
- , o = new Map;
- for (let s = 32; s < 127; s++) {
- const c = String.fromCodePoint(s)
- , d = 2 + "px " + a;
- i.drawText(c, null, null, d, "#000000", "#ffffff", !0);
- const _ = i.getContext();
- _.font = d;
- const b = _.measureText(c).width;
- o.set(s, b)
- }
- return i.dispose(),
- o
- }
- , _RegisteredClass = {};
- function RegisterXObjectClass(a, e) {
- _RegisteredClass[a] = e
- }
- function GetXObjectClass(a) {
- return _RegisteredClass[a]
- }
- const DEFAULT_LOGGER = {
- debug: console.log,
- info: console.log,
- warn: console.warn,
- error: console.error
- }
- , _Logger = class {
- static setLogger(a) {
- _Logger.instance = a
- }
- constructor(a) {
- this.module = a
- }
- debug(...a) {
- return _Logger.instance.debug(...a)
- }
- info(...a) {
- return _Logger.instance.info(...a)
- }
- warn(...a) {
- return _Logger.instance.warn(...a)
- }
- error(...a) {
- return _Logger.instance.error(...a)
- }
- }
- ;
- let Logger$1 = _Logger;
- Logger$1.instance = DEFAULT_LOGGER;
- new Logger$1("Serialization");
- const __decoratorInitialStore = {}
- , __mergedStore = {}
- , deepCopy = function(a, e, i) {
- let o;
- if (e || (e = ""),
- i || (i = !1),
- a == null || typeof a != "object")
- return a;
- if (a instanceof Date)
- return o = new Date,
- o.setTime(a.getTime()),
- o;
- if (a instanceof Array) {
- o = [];
- for (let s = 0, c = a.length; s < c; s++)
- o[s] = deepCopy(a[s], e, i);
- return o
- }
- if (a instanceof Object) {
- if (a instanceof XObject)
- return o = _copySource(a, e, i),
- o;
- if (a instanceof AssetContainer)
- return i ? o = a.clone(e, !1, {
- doNotInstantiate: !0
- }, !1) : o = a.clone(e),
- o;
- for (const s in a)
- Object.prototype.hasOwnProperty.call(a, s) && (o[s] = deepCopy(a[s]));
- return o
- }
- throw new Error("Unable to copy obj! Its type isn't supported.")
- }
- , _copySource = function(a, e, i) {
- const o = GetXObjectClass(a.getClassName())
- , s = new o
- , c = getPropertiesMarkAsSerializable(s);
- e || (e = ""),
- i || (i = !1);
- for (const d in c) {
- const _ = a[d];
- if (_ != null) {
- const b = s;
- _ instanceof XObject ? b[d] = _copySource(_, e, i) : b[d] = deepCopy(_, e, i)
- }
- }
- return s.name = e,
- s
- };
- function getDirectStore(a) {
- const e = a.getClassName();
- return __decoratorInitialStore[e] || (__decoratorInitialStore[e] = {}),
- __decoratorInitialStore[e]
- }
- function generateSerializableMember(a, e) {
- return (i,o)=>{
- const s = getDirectStore(i);
- s[o] || (s[o] = {
- type: a,
- sourceName: e
- })
- }
- }
- function xProperty(a) {
- return generateSerializableMember(0, a)
- }
- function getPropertiesMarkAsSerializable(a) {
- const e = a.getClassName();
- if (__mergedStore[e])
- return __mergedStore[e];
- __mergedStore[e] = {};
- const i = __mergedStore[e];
- let o = a
- , s = e;
- for (; s; ) {
- const c = __decoratorInitialStore[s];
- for (const b in c)
- i[b] = c[b];
- let d, _ = !1;
- do {
- if (d = Object.getPrototypeOf(o),
- !d.getClassName) {
- _ = !0;
- break
- }
- if (d.getClassName() !== s)
- break;
- o = d
- } while (d);
- if (_)
- break;
- s = d.getClassName(),
- o = d
- }
- return i
- }
- class XArchive {
- constructor() {
- this.loadingPromises = new Array
- }
- static serialize(e) {
- if (!e.outer)
- return {
- className: "",
- uuid: 0,
- xobjectInfo: {},
- sceneInfo: ""
- };
- const o = e.outer.uuid
- , s = {
- className: "",
- uuid: 0,
- xobjectInfo: {},
- sceneInfo: ""
- };
- s.className = e.getClassName(),
- s.uuid = o;
- const c = getPropertiesMarkAsSerializable(e);
- for (const d in c) {
- const b = c[d].sourceName || d
- , k = e[d];
- s.xobjectInfo[b] = k
- }
- return s
- }
- async deserializeObject(e, i="") {
- if (e == null || typeof e != "object" || e instanceof Date)
- return e;
- if (e instanceof Array) {
- for (let o = 0, s = e.length; o < s; o++)
- e[o] = this.deserializeObject(e[o], i);
- return e
- }
- if (e instanceof Object) {
- if (e.className)
- GetXObjectClass(e.className) && this.deserialize(e, i);
- else
- return e;
- return e
- }
- throw new Error("Unable to copy obj! Its type isn't supported.")
- }
- async deserialize(e, i="") {
- const o = GetXObjectClass(e.className);
- if (!o)
- throw new Error("Unable to deserialize obj! Its type isn't XObject.");
- const s = new o
- , c = getPropertiesMarkAsSerializable(s);
- for (const d in c) {
- const _ = c[d]
- , b = e.xobjectInfo[_.sourceName || d];
- if (b != null)
- if (s[d]instanceof AssetContainer) {
- const k = await SceneLoader.LoadAssetContainerAsync(i, b.sceneInfo, EngineStore.LastCreatedScene);
- s[d] = k,
- k.addAllToScene()
- } else
- s[d]instanceof XObject ? s[d] = await this.deserialize(b, i) : s[d] = await this.deserializeObject(b, i)
- }
- return s.postLoad(),
- s
- }
- static clone(e, i, o) {
- return deepCopy(e, i, o)
- }
- }
- var __defProp$3 = Object.defineProperty
- , __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor
- , __decorateClass$3 = (a,e,i,o)=>{
- for (var s = o > 1 ? void 0 : o ? __getOwnPropDesc$3(e, i) : e, c = a.length - 1, d; c >= 0; c--)
- (d = a[c]) && (s = (o ? d(e, i, s) : d(s)) || s);
- return o && s && __defProp$3(e, i, s),
- s
- }
- ;
- class XObject {
- constructor() {
- this._name = "",
- this._outer = null
- }
- set outer(e) {
- this._outer = e
- }
- get outer() {
- return this._outer
- }
- get name() {
- return this._name
- }
- set name(e) {
- this._name = e
- }
- getClassName() {
- return "XObject"
- }
- toJSON() {
- return XArchive.serialize(this)
- }
- dispose() {}
- postLoad() {}
- clone(e) {
- return XArchive.clone(this, e)
- }
- }
- __decorateClass$3([xProperty("name")], XObject.prototype, "_name", 2);
- RegisterXObjectClass("XObject", XObject);
- var Codes$2 = (a=>(a[a.Success = 0] = "Success",
- a[a.Timeout = 1003] = "Timeout",
- a))(Codes$2 || {});
- const COMPONENT_LIST_PREFIX = "/component_list.json";
- class XverseError$1 extends Error {
- constructor(e, i) {
- super(i),
- this.code = e
- }
- toJSON() {
- return {
- code: this.code,
- message: this.message
- }
- }
- toString() {
- if (Object(this) !== this)
- throw new TypeError;
- let i = this.name;
- i = i === void 0 ? "Error" : String(i);
- let o = this.message;
- o = o === void 0 ? "" : String(o);
- const s = this.code;
- return o = s === void 0 ? o : s + "," + o,
- i === "" ? o : o === "" ? i : i + ": " + o
- }
- }
- class AvatarAssetLoadingError extends XverseError$1 {
- constructor(e) {
- super(5100, e || "[Engine] \u89D2\u8272\u8D44\u4EA7\u52A0\u8F7D\u5931\u8D25")
- }
- }
- class AvatarAnimationError extends XverseError$1 {
- constructor(e) {
- super(5101, e || "[Engine] \u89D2\u8272\u52A8\u753B\u64AD\u653E\u5931\u8D25")
- }
- }
- class TimeoutError$1 extends XverseError$1 {
- constructor(e) {
- super(Codes$2.Timeout, e || "[Engine] \u8D85\u65F6\u9519\u8BEF")
- }
- }
- class DuplicateAvatarIDError extends XverseError$1 {
- constructor(e) {
- super(5103, e || "[Engine] \u89D2\u8272id\u91CD\u590D")
- }
- }
- class ContainerLoadingFailedError extends XverseError$1 {
- constructor(e) {
- super(5104, e || "[Engine] \u89D2\u8272\u8D44\u4EA7\u62C9\u53D6\u9519\u8BEF")
- }
- }
- class XTvMediaUrlError extends XverseError$1 {
- constructor(e) {
- super(5201, e || "[Engine] \u4F20\u5165Url\u9519\u8BEF")
- }
- }
- class XTvVideoElementError extends XverseError$1 {
- constructor(e) {
- super(5202, e || "[Engine] \u4F20\u5165video DOM\u9519\u8BEF")
- }
- }
- class XTvModelError extends XverseError$1 {
- constructor(e) {
- super(5203, e || "[Engine] \u4F20\u5165TV\u6A21\u578Burl\u9519\u8BEF")
- }
- }
- class XLowpolyModelError extends XverseError$1 {
- constructor(e) {
- super(5204, e || "[Engine] \u4F20\u5165\u6A21\u578Burl\u9519\u8BEF")
- }
- }
- class XLowpolyJsonError extends XverseError$1 {
- constructor(e) {
- super(5205, e || "[Engine] \u4F20\u5165\u6A21\u578Bjson\u9519\u8BEF")
- }
- }
- class XDecalError extends XverseError$1 {
- constructor(e) {
- super(5206, e || "[Engine] Decal\u6A21\u578B\u9519\u8BEF")
- }
- }
- class XDecalTextureError extends XverseError$1 {
- constructor(e) {
- super(5207, e || "[Engine] decal\u7EB9\u7406\u9519\u8BEF")
- }
- }
- class XBreathPointError extends XverseError$1 {
- constructor(e) {
- super(5208, e || "[Engine] \u547C\u5438\u70B9\u9519\u8BEF")
- }
- }
- class XMaterialError extends XverseError$1 {
- constructor(e) {
- super(5210, e || "[Engine] Material\u9519\u8BEF")
- }
- }
- class ExceedMaxAvatarNumError extends XverseError$1 {
- constructor(e) {
- super(5211, e || "[Engine] \u89D2\u8272\u4E2A\u6570\u8D85\u51FA\u4E0A\u9650")
- }
- }
- const avatarSetting = {
- fileType: ".glb",
- lodType: "_lod",
- lod: [{
- level: "lod0",
- fileName: ".glb",
- quota: 5,
- dist: 1e3
- }, {
- level: "lod1",
- fileName: "_lod2.glb",
- quota: 5,
- dist: 2e3
- }, {
- level: "lod2",
- fileName: "_lod4.glb",
- quota: 0,
- dist: 7500
- }],
- isRayCastEnable: !0,
- maxAvatarNum: 40,
- maxBillBoardDist: 7500,
- body: "body",
- head: "head",
- hair: "hair",
- suit: "suit",
- pants: "pants",
- shoes: "shoes",
- clothes: "clothes",
- animations: "animations",
- defaultIdle: "Idle",
- cullingDistance: 200,
- defaultMove: "Walking"
- }
- , avatarResources = {
- ygb: {
- name: "ygb",
- mat: "NM_ygb",
- mesh: "ygb"
- }
- }
- , action = {
- GiftClap: {
- animName: "GiftClap",
- keyTime: 1760
- },
- Cheering: {
- animName: "Cheering",
- attachPair: [{
- bone: "mixamorig_MiddleFinger2_R",
- obj: "ygb",
- offset: {
- x: 0,
- y: 0,
- z: 0
- },
- rotate: {
- x: 0,
- y: 3.84,
- z: 0
- },
- scale: {
- x: 1,
- y: 1,
- z: 1
- }
- }, {
- bone: "mixamorig_MiddleFinger2_L",
- obj: "ygb",
- offset: {
- x: 0,
- y: 0,
- z: 0
- },
- rotate: {
- x: 0,
- y: 3.49,
- z: 0
- },
- scale: {
- x: 1,
- y: 1,
- z: 1
- }
- }]
- }
- }
- , getAnimationKey = (a,e)=>e + "_" + a;
- var _GLTFUtilities = function() {
- function a() {}
- return a._CreateBufferView = function(e, i, o, s, c) {
- var d = {
- buffer: e,
- byteLength: o
- };
- return i && (d.byteOffset = i),
- c && (d.name = c),
- s && (d.byteStride = s),
- d
- }
- ,
- a._CreateAccessor = function(e, i, o, s, c, d, _, b) {
- var k = {
- name: i,
- bufferView: e,
- componentType: s,
- count: c,
- type: o
- };
- return _ != null && (k.min = _),
- b != null && (k.max = b),
- d != null && (k.byteOffset = d),
- k
- }
- ,
- a._CalculateMinMaxPositions = function(e, i, o, s) {
- var c = [1 / 0, 1 / 0, 1 / 0], d = [-1 / 0, -1 / 0, -1 / 0], _ = 3, b, k, j;
- if (o)
- for (var $ = i, _e = i + o; $ < _e; ++$) {
- b = _ * $,
- k = Vector3.FromArray(e, b),
- s && a._GetRightHandedPositionVector3FromRef(k),
- j = k.asArray();
- for (var et = 0; et < _; ++et) {
- var tt = j[et];
- tt < c[et] && (c[et] = tt),
- tt > d[et] && (d[et] = tt),
- ++b
- }
- }
- return {
- min: c,
- max: d
- }
- }
- ,
- a._GetRightHandedPositionVector3 = function(e) {
- return new Vector3(e.x,e.y,-e.z)
- }
- ,
- a._GetRightHandedPositionVector3FromRef = function(e) {
- e.z *= -1
- }
- ,
- a._GetRightHandedPositionArray3FromRef = function(e) {
- e[2] *= -1
- }
- ,
- a._GetRightHandedNormalVector3 = function(e) {
- return new Vector3(e.x,e.y,-e.z)
- }
- ,
- a._GetRightHandedNormalVector3FromRef = function(e) {
- e.z *= -1
- }
- ,
- a._GetRightHandedNormalArray3FromRef = function(e) {
- e[2] *= -1
- }
- ,
- a._GetRightHandedVector4FromRef = function(e) {
- e.z *= -1,
- e.w *= -1
- }
- ,
- a._GetRightHandedArray4FromRef = function(e) {
- e[2] *= -1,
- e[3] *= -1
- }
- ,
- a._GetRightHandedQuaternionFromRef = function(e) {
- e.x *= -1,
- e.y *= -1
- }
- ,
- a._GetRightHandedQuaternionArrayFromRef = function(e) {
- e[0] *= -1,
- e[1] *= -1
- }
- ,
- a._NormalizeTangentFromRef = function(e) {
- var i = Math.sqrt(e.x * e.x + e.y * e.y + e.z * e.z);
- i > 0 && (e.x /= i,
- e.y /= i,
- e.z /= i)
- }
- ,
- a._GetDataAccessorElementCount = function(e) {
- switch (e) {
- case "MAT2":
- return 4;
- case "MAT3":
- return 9;
- case "MAT4":
- return 16;
- case "SCALAR":
- return 1;
- case "VEC2":
- return 2;
- case "VEC3":
- return 3;
- case "VEC4":
- return 4
- }
- }
- ,
- a
- }(), _TangentType;
- (function(a) {
- a[a.INTANGENT = 0] = "INTANGENT",
- a[a.OUTTANGENT = 1] = "OUTTANGENT"
- }
- )(_TangentType || (_TangentType = {}));
- var _GLTFAnimation = function() {
- function a() {}
- return a._CreateNodeAnimation = function(e, i, o, s, c, d) {
- var _ = []
- , b = []
- , k = i.getKeys()
- , j = a.calculateMinMaxKeyFrames(k)
- , $ = a._DeduceInterpolation(k, o, c)
- , _e = j.max - j.min
- , et = $.interpolationType
- , tt = $.shouldBakeAnimation;
- 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),
- _.length && b.length) {
- var rt = {
- inputs: _,
- outputs: b,
- samplerInterpolation: et,
- inputsMin: tt ? j.min : Tools.FloatRound(j.min / i.framePerSecond),
- inputsMax: tt ? j.max : Tools.FloatRound(j.max / i.framePerSecond)
- };
- return rt
- }
- return null
- }
- ,
- a._DeduceAnimationInfo = function(e) {
- var i = null
- , o = "VEC3"
- , s = !1
- , c = e.targetProperty.split(".");
- switch (c[0]) {
- case "scaling":
- {
- i = "scale";
- break
- }
- case "position":
- {
- i = "translation";
- break
- }
- case "rotation":
- {
- o = "VEC4",
- i = "rotation";
- break
- }
- case "rotationQuaternion":
- {
- o = "VEC4",
- s = !0,
- i = "rotation";
- break
- }
- case "influence":
- {
- o = "SCALAR",
- i = "weights";
- break
- }
- default:
- Tools.Error("Unsupported animatable property " + c[0])
- }
- return i ? {
- animationChannelTargetPath: i,
- dataAccessorType: o,
- useQuaternion: s
- } : (Tools.Error("animation channel target path and data accessor type could be deduced"),
- null)
- }
- ,
- a._CreateNodeAnimationFromNodeAnimations = function(e, i, o, s, c, d, _, b, k, j) {
- var $;
- if (e instanceof TransformNode && e.animations)
- for (var _e = 0, et = e.animations; _e < et.length; _e++) {
- var tt = et[_e]
- , rt = a._DeduceAnimationInfo(tt);
- rt && ($ = {
- name: tt.name,
- samplers: [],
- channels: []
- },
- a.AddAnimation("" + tt.name, tt.hasRunningRuntimeAnimations ? i : $, e, tt, rt.dataAccessorType, rt.animationChannelTargetPath, s, d, _, b, k, rt.useQuaternion, j),
- $.samplers.length && $.channels.length && o.push($))
- }
- }
- ,
- a._CreateMorphTargetAnimationFromMorphTargetAnimations = function(e, i, o, s, c, d, _, b, k, j) {
- var $;
- if (e instanceof Mesh) {
- var _e = e.morphTargetManager;
- if (_e)
- for (var et = 0; et < _e.numTargets; ++et)
- for (var tt = _e.getTarget(et), rt = 0, it = tt.animations; rt < it.length; rt++) {
- 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)
- for (var ct = st[ut], lt = 0; lt < _e.numTargets; ++lt)
- lt == et ? at.push(ct) : at.push({
- frame: ct.frame,
- value: 0
- });
- ot.setKeys(at);
- var ft = a._DeduceAnimationInfo(ot);
- ft && ($ = {
- name: ot.name,
- samplers: [],
- channels: []
- },
- a.AddAnimation(nt.name, nt.hasRunningRuntimeAnimations ? i : $, e, ot, ft.dataAccessorType, ft.animationChannelTargetPath, s, d, _, b, k, ft.useQuaternion, j, _e.numTargets),
- $.samplers.length && $.channels.length && o.push($))
- }
- }
- }
- ,
- a._CreateNodeAndMorphAnimationFromAnimationGroups = function(e, i, o, s, c, d, _, b, k) {
- var j, $;
- if (e.animationGroups)
- for (var _e = e.animationGroups, et = function(nt) {
- var ot = new Map
- , at = new Map
- , st = new Set
- , ut = nt.to - nt.from;
- $ = {
- name: nt.name,
- channels: [],
- samplers: []
- };
- for (var ct = function(ft) {
- var ht = nt.targetedAnimations[ft]
- , pt = ht.target
- , dt = ht.animation;
- if (pt instanceof TransformNode || pt.length === 1 && pt[0]instanceof TransformNode) {
- var _t = a._DeduceAnimationInfo(ht.animation);
- if (_t) {
- var mt = pt instanceof TransformNode ? pt : pt[0]
- , vt = b[mt.uniqueId];
- a.AddAnimation("" + dt.name, $, mt, dt, _t.dataAccessorType, _t.animationChannelTargetPath, o, c, d, _, vt, _t.useQuaternion, k)
- }
- } else if (pt instanceof MorphTarget || pt.length === 1 && pt[0]instanceof MorphTarget) {
- var _t = a._DeduceAnimationInfo(ht.animation);
- if (_t) {
- var yt = pt instanceof MorphTarget ? pt : pt[0];
- if (yt) {
- var Et = e.morphTargetManagers.find(function(St) {
- for (var xt = 0; xt < St.numTargets; ++xt)
- if (St.getTarget(xt) === yt)
- return !0;
- return !1
- });
- if (Et) {
- var At = e.meshes.find(function(St) {
- return St.morphTargetManager === Et
- });
- At && (ot.has(At) || ot.set(At, new Map),
- (j = ot.get(At)) === null || j === void 0 || j.set(yt, dt),
- st.add(At),
- at.set(At, dt))
- }
- }
- }
- }
- }, lt = 0; lt < nt.targetedAnimations.length; ++lt)
- ct(lt);
- st.forEach(function(ft) {
- for (var ht = ft.morphTargetManager, pt = null, dt = [], _t = at.get(ft), mt = _t.getKeys(), vt = mt.length, yt = 0; yt < vt; ++yt)
- for (var Et = 0; Et < ht.numTargets; ++Et) {
- var At = ht.getTarget(Et)
- , gt = ot.get(ft);
- if (gt) {
- var St = gt.get(At);
- St ? (pt || (pt = new Animation(nt.name + "_" + ft.name + "_MorphWeightAnimation","influence",St.framePerSecond,Animation.ANIMATIONTYPE_FLOAT,St.loopMode,St.enableBlending)),
- dt.push(St.getKeys()[yt])) : dt.push({
- frame: nt.from + ut / vt * yt,
- value: At.influence,
- inTangent: mt[0].inTangent ? 0 : void 0,
- outTangent: mt[0].outTangent ? 0 : void 0
- })
- }
- }
- pt.setKeys(dt);
- var xt = a._DeduceAnimationInfo(pt);
- 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)
- }),
- $.channels.length && $.samplers.length && i.push($)
- }, tt = 0, rt = _e; tt < rt.length; tt++) {
- var it = rt[tt];
- et(it)
- }
- }
- ,
- a.AddAnimation = function(e, i, o, s, c, d, _, b, k, j, $, _e, et, tt) {
- var rt = a._CreateNodeAnimation(o, s, d, $, _e, et), it, nt, ot, at, st, ut, ct;
- if (rt) {
- if (tt) {
- for (var lt = 0, ft = 0, ht = []; rt.inputs.length > 0; )
- ft = rt.inputs.shift(),
- lt % tt == 0 && ht.push(ft),
- lt++;
- rt.inputs = ht
- }
- var pt = _[o.uniqueId]
- , dt = rt.inputs.length * 4;
- it = _GLTFUtilities._CreateBufferView(0, b.getByteOffset(), dt, void 0, e + " keyframe data view"),
- k.push(it),
- rt.inputs.forEach(function(_t) {
- b.setFloat32(_t)
- }),
- nt = _GLTFUtilities._CreateAccessor(k.length - 1, e + " keyframes", "SCALAR", 5126, rt.inputs.length, null, [rt.inputsMin], [rt.inputsMax]),
- j.push(nt),
- ot = j.length - 1,
- st = rt.outputs.length,
- dt = _GLTFUtilities._GetDataAccessorElementCount(c) * 4 * rt.outputs.length,
- it = _GLTFUtilities._CreateBufferView(0, b.getByteOffset(), dt, void 0, e + " data view"),
- k.push(it),
- rt.outputs.forEach(function(_t) {
- _t.forEach(function(mt) {
- b.setFloat32(mt)
- })
- }),
- nt = _GLTFUtilities._CreateAccessor(k.length - 1, e + " data", c, 5126, st, null, null, null),
- j.push(nt),
- at = j.length - 1,
- ut = {
- interpolation: rt.samplerInterpolation,
- input: ot,
- output: at
- },
- i.samplers.push(ut),
- ct = {
- sampler: i.samplers.length - 1,
- target: {
- node: pt,
- path: d
- }
- },
- i.channels.push(ct)
- }
- }
- ,
- a._CreateBakedAnimation = function(e, i, o, s, c, d, _, b, k, j, $, _e) {
- var et, tt = Quaternion.Identity(), rt = null, it, nt = null, ot = null, at = null, st = null, ut = null;
- j.min = Tools.FloatRound(s / d);
- for (var ct = i.getKeys(), lt = 0, ft = ct.length; lt < ft; ++lt) {
- if (ut = null,
- ot = ct[lt],
- lt + 1 < ft)
- if (at = ct[lt + 1],
- ot.value.equals && ot.value.equals(at.value) || ot.value === at.value)
- if (lt === 0)
- ut = ot.frame;
- else
- continue;
- else
- ut = at.frame;
- else {
- if (st = ct[lt - 1],
- ot.value.equals && ot.value.equals(st.value) || ot.value === st.value)
- continue;
- ut = c
- }
- if (ut) {
- for (var ht = ot.frame; ht <= ut; ht += _)
- if (it = Tools.FloatRound(ht / d),
- it !== rt) {
- rt = it,
- nt = it;
- var pt = {
- key: 0,
- repeatCount: 0,
- loopMode: i.loopMode
- };
- et = i._interpolate(ht, pt),
- a._SetInterpolatedValue(e, et, it, i, o, tt, b, k, $, _e)
- }
- }
- }
- nt && (j.max = nt)
- }
- ,
- a._ConvertFactorToVector3OrQuaternion = function(e, i, o, s, c, d, _) {
- var b, k, j = null, $ = a._GetBasePositionRotationOrScale(i, c, d, _);
- if (s === Animation.ANIMATIONTYPE_FLOAT)
- switch (b = o.targetProperty.split("."),
- k = b ? b[1] : "",
- j = _ ? Quaternion.FromArray($).normalize() : Vector3.FromArray($),
- k) {
- case "x":
- {
- j[k] = d && _ && c !== "scale" ? -e : e;
- break
- }
- case "y":
- {
- j[k] = d && _ && c !== "scale" ? -e : e;
- break
- }
- case "z":
- {
- j[k] = d && !_ && c !== "scale" ? -e : e;
- break
- }
- case "w":
- {
- j.w = e;
- break
- }
- default:
- Tools.Error('glTFAnimation: Unsupported component type "' + k + '" for scale animation!')
- }
- return j
- }
- ,
- a._SetInterpolatedValue = function(e, i, o, s, c, d, _, b, k, j) {
- var $ = s.dataType, _e;
- _.push(o),
- typeof i == "number" && e instanceof TransformNode && (i = this._ConvertFactorToVector3OrQuaternion(i, e, s, $, c, k, j)),
- i && (c === "rotation" ? (j ? d = i : (_e = i,
- Quaternion.RotationYawPitchRollToRef(_e.y, _e.x, _e.z, d)),
- k && (_GLTFUtilities._GetRightHandedQuaternionFromRef(d),
- e.parent || (d = Quaternion.FromArray([0, 1, 0, 0]).multiply(d))),
- b.push(d.asArray())) : c === "weights" ? b.push([i]) : (_e = i,
- k && c !== "scale" && (_GLTFUtilities._GetRightHandedPositionVector3FromRef(_e),
- e.parent || (_e.x *= -1,
- _e.z *= -1)),
- b.push(_e.asArray())))
- }
- ,
- a._CreateLinearOrStepAnimation = function(e, i, o, s, c, d, _, b) {
- for (var k = 0, j = i.getKeys(); k < j.length; k++) {
- var $ = j[k];
- c.push($.frame / i.framePerSecond),
- a._AddKeyframeValue($, i, d, o, e, _, b)
- }
- }
- ,
- a._CreateCubicSplineAnimation = function(e, i, o, s, c, d, _, b) {
- i.getKeys().forEach(function(k) {
- c.push(k.frame / i.framePerSecond),
- a.AddSplineTangent(e, _TangentType.INTANGENT, d, o, "CUBICSPLINE", k, s, b, _),
- a._AddKeyframeValue(k, i, d, o, e, _, b),
- a.AddSplineTangent(e, _TangentType.OUTTANGENT, d, o, "CUBICSPLINE", k, s, b, _)
- })
- }
- ,
- a._GetBasePositionRotationOrScale = function(e, i, o, s) {
- var c;
- return i === "rotation" ? s ? e.rotationQuaternion ? (c = e.rotationQuaternion.asArray(),
- o && (_GLTFUtilities._GetRightHandedQuaternionArrayFromRef(c),
- e.parent || (c = Quaternion.FromArray([0, 1, 0, 0]).multiply(Quaternion.FromArray(c)).asArray()))) : c = Quaternion.Identity().asArray() : (c = e.rotation.asArray(),
- _GLTFUtilities._GetRightHandedNormalArray3FromRef(c)) : i === "translation" ? (c = e.position.asArray(),
- o && _GLTFUtilities._GetRightHandedPositionArray3FromRef(c)) : c = e.scaling.asArray(),
- c
- }
- ,
- a._AddKeyframeValue = function(e, i, o, s, c, d, _) {
- var b, k, j = i.dataType;
- if (j === Animation.ANIMATIONTYPE_VECTOR3) {
- if (b = e.value.asArray(),
- s === "rotation") {
- var $ = Vector3.FromArray(b)
- , _e = Quaternion.RotationYawPitchRoll($.y, $.x, $.z);
- d && (_GLTFUtilities._GetRightHandedQuaternionFromRef(_e),
- c.parent || (_e = Quaternion.FromArray([0, 1, 0, 0]).multiply(_e))),
- b = _e.asArray()
- } else
- s === "translation" && d && (_GLTFUtilities._GetRightHandedNormalArray3FromRef(b),
- c.parent || (b[0] *= -1,
- b[2] *= -1));
- o.push(b)
- } else if (j === Animation.ANIMATIONTYPE_FLOAT) {
- if (s === "weights")
- o.push([e.value]);
- else if (k = this._ConvertFactorToVector3OrQuaternion(e.value, c, i, j, s, d, _),
- k) {
- if (s === "rotation") {
- var et = _ ? k : Quaternion.RotationYawPitchRoll(k.y, k.x, k.z).normalize();
- d && (_GLTFUtilities._GetRightHandedQuaternionFromRef(et),
- c.parent || (et = Quaternion.FromArray([0, 1, 0, 0]).multiply(et))),
- o.push(et.asArray())
- } else
- s === "translation" && d && (_GLTFUtilities._GetRightHandedNormalVector3FromRef(k),
- c.parent || (k.x *= -1,
- k.z *= -1));
- o.push(k.asArray())
- }
- } else
- j === Animation.ANIMATIONTYPE_QUATERNION ? (b = e.value.normalize().asArray(),
- d && (_GLTFUtilities._GetRightHandedQuaternionArrayFromRef(b),
- c.parent || (b = Quaternion.FromArray([0, 1, 0, 0]).multiply(Quaternion.FromArray(b)).asArray())),
- o.push(b)) : Tools.Error("glTFAnimation: Unsupported key frame values for animation!")
- }
- ,
- a._DeduceInterpolation = function(e, i, o) {
- var s, c = !1, d;
- if (i === "rotation" && !o)
- return {
- interpolationType: "LINEAR",
- shouldBakeAnimation: !0
- };
- for (var _ = 0, b = e.length; _ < b; ++_)
- if (d = e[_],
- d.inTangent || d.outTangent)
- if (s) {
- if (s !== "CUBICSPLINE") {
- s = "LINEAR",
- c = !0;
- break
- }
- } else
- s = "CUBICSPLINE";
- else if (s) {
- if (s === "CUBICSPLINE" || d.interpolation && d.interpolation === AnimationKeyInterpolation.STEP && s !== "STEP") {
- s = "LINEAR",
- c = !0;
- break
- }
- } else
- d.interpolation && d.interpolation === AnimationKeyInterpolation.STEP ? s = "STEP" : s = "LINEAR";
- return s || (s = "LINEAR"),
- {
- interpolationType: s,
- shouldBakeAnimation: c
- }
- }
- ,
- a.AddSplineTangent = function(e, i, o, s, c, d, _, b, k) {
- var j, $ = i === _TangentType.INTANGENT ? d.inTangent : d.outTangent;
- if (c === "CUBICSPLINE") {
- if (s === "rotation")
- if ($) {
- if (b)
- j = $.asArray();
- else {
- var _e = $;
- j = Quaternion.RotationYawPitchRoll(_e.y, _e.x, _e.z).asArray()
- }
- k && (_GLTFUtilities._GetRightHandedQuaternionArrayFromRef(j),
- e.parent || (j = Quaternion.FromArray([0, 1, 0, 0]).multiply(Quaternion.FromArray(j)).asArray()))
- } else
- j = [0, 0, 0, 0];
- else
- s === "weights" ? $ ? j = [$] : j = [0] : $ ? (j = $.asArray(),
- k && s === "translation" && (_GLTFUtilities._GetRightHandedPositionArray3FromRef(j),
- e.parent || (j[0] *= -1,
- j[2] *= -1))) : j = [0, 0, 0];
- o.push(j)
- }
- }
- ,
- a.calculateMinMaxKeyFrames = function(e) {
- var i = 1 / 0
- , o = -1 / 0;
- return e.forEach(function(s) {
- i = Math.min(i, s.frame),
- o = Math.max(o, s.frame)
- }),
- {
- min: i,
- max: o
- }
- }
- ,
- a
- }()
- , GLTFData = function() {
- function a() {
- this.glTFFiles = {}
- }
- return a.prototype.downloadFiles = function() {
- function e(d, _) {
- return d.indexOf(_, d.length - _.length) !== -1
- }
- for (var i in this.glTFFiles) {
- var o = document.createElement("a");
- document.body.appendChild(o),
- o.setAttribute("type", "hidden"),
- o.download = i;
- var s = this.glTFFiles[i]
- , c = void 0;
- e(i, ".glb") ? c = {
- type: "model/gltf-binary"
- } : e(i, ".bin") ? c = {
- type: "application/octet-stream"
- } : e(i, ".gltf") ? c = {
- type: "model/gltf+json"
- } : e(i, ".jpeg") || e(i, ".jpg") ? c = {
- type: "image/jpeg"
- } : e(i, ".png") && (c = {
- type: "image/png"
- }),
- o.href = window.URL.createObjectURL(new Blob([s],c)),
- o.click()
- }
- }
- ,
- a
- }()
- , _GLTFMaterialExporter = function() {
- function a(e) {
- this._textureMap = {},
- this._textureMap = {},
- this._exporter = e
- }
- return a.FuzzyEquals = function(e, i, o) {
- return Scalar.WithinEpsilon(e.r, i.r, o) && Scalar.WithinEpsilon(e.g, i.g, o) && Scalar.WithinEpsilon(e.b, i.b, o)
- }
- ,
- a.prototype._convertMaterialsToGLTFAsync = function(e, i, o) {
- for (var s = [], c = 0, d = e; c < d.length; c++) {
- var _ = d[c];
- _.getClassName() === "StandardMaterial" ? s.push(this._convertStandardMaterialAsync(_, i, o)) : _.getClassName().indexOf("PBR") !== -1 ? s.push(this._convertPBRMaterialAsync(_, i, o)) : Tools.Warn("Unsupported material type: " + _.name)
- }
- return Promise.all(s).then(function() {})
- }
- ,
- a.prototype._stripTexturesFromMaterial = function(e) {
- var i = {};
- if (e) {
- i.name = e.name,
- i.doubleSided = e.doubleSided,
- i.alphaMode = e.alphaMode,
- i.alphaCutoff = e.alphaCutoff,
- i.emissiveFactor = e.emissiveFactor;
- var o = e.pbrMetallicRoughness;
- o && (i.pbrMetallicRoughness = {},
- i.pbrMetallicRoughness.baseColorFactor = o.baseColorFactor,
- i.pbrMetallicRoughness.metallicFactor = o.metallicFactor,
- i.pbrMetallicRoughness.roughnessFactor = o.roughnessFactor)
- }
- return i
- }
- ,
- a.prototype._hasTexturesPresent = function(e) {
- var i;
- if (e.emissiveTexture || e.normalTexture || e.occlusionTexture)
- return !0;
- var o = e.pbrMetallicRoughness;
- if (o && (o.baseColorTexture || o.metallicRoughnessTexture))
- return !0;
- if (e.extensions)
- for (var s in e.extensions) {
- var c = e.extensions[s];
- if (c)
- return (i = c.hasTextures) === null || i === void 0 ? void 0 : i.call(c)
- }
- return !1
- }
- ,
- a.prototype._getTextureInfo = function(e) {
- if (e) {
- var i = e.uid;
- if (i in this._textureMap)
- return this._textureMap[i]
- }
- return null
- }
- ,
- a.prototype._convertToGLTFPBRMetallicRoughness = function(e) {
- var i = new Vector2(0,1)
- , o = new Vector2(0,.1)
- , s = new Vector2(0,.1)
- , c = new Vector2(1300,.1);
- function d(et, tt, rt, it, nt) {
- 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
- }
- function _(et) {
- var tt = Math.pow(et / c.x, .333333);
- return d(tt, i.y, o.y, s.y, c.y)
- }
- var b = e.diffuseColor.toLinearSpace().scale(.5)
- , k = e.alpha
- , j = Scalar.Clamp(e.specularPower, 0, a._MaxSpecularPower)
- , $ = _(j)
- , _e = {
- baseColorFactor: [b.r, b.g, b.b, k],
- metallicFactor: 0,
- roughnessFactor: $
- };
- return _e
- }
- ,
- a._SolveMetallic = function(e, i, o) {
- if (i < this._DielectricSpecular.r)
- return this._DielectricSpecular,
- 0;
- var s = this._DielectricSpecular.r
- , c = e * o / (1 - this._DielectricSpecular.r) + i - 2 * this._DielectricSpecular.r
- , d = this._DielectricSpecular.r - i
- , _ = c * c - 4 * s * d;
- return Scalar.Clamp((-c + Math.sqrt(_)) / (2 * s), 0, 1)
- }
- ,
- a._SetAlphaMode = function(e, i) {
- i.needAlphaBlending() ? e.alphaMode = "BLEND" : i.needAlphaTesting() && (e.alphaMode = "MASK",
- e.alphaCutoff = i.alphaCutOff)
- }
- ,
- a.prototype._convertStandardMaterialAsync = function(e, i, o) {
- var s = this._exporter._materialMap
- , c = this._exporter._materials
- , d = []
- , _ = this._convertToGLTFPBRMetallicRoughness(e)
- , b = {
- name: e.name
- };
- 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."),
- b.doubleSided = !0),
- o && (e.diffuseTexture && d.push(this._exportTextureAsync(e.diffuseTexture, i).then(function(k) {
- k && (_.baseColorTexture = k)
- })),
- e.bumpTexture && d.push(this._exportTextureAsync(e.bumpTexture, i).then(function(k) {
- k && (b.normalTexture = k,
- e.bumpTexture != null && e.bumpTexture.level !== 1 && (b.normalTexture.scale = e.bumpTexture.level))
- })),
- e.emissiveTexture && (b.emissiveFactor = [1, 1, 1],
- d.push(this._exportTextureAsync(e.emissiveTexture, i).then(function(k) {
- k && (b.emissiveTexture = k)
- }))),
- e.ambientTexture && d.push(this._exportTextureAsync(e.ambientTexture, i).then(function(k) {
- if (k) {
- var j = {
- index: k.index
- };
- b.occlusionTexture = j,
- j.strength = 1
- }
- }))),
- (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())),
- e.emissiveColor && !a.FuzzyEquals(e.emissiveColor, Color3.Black(), a._Epsilon) && (b.emissiveFactor = e.emissiveColor.asArray()),
- b.pbrMetallicRoughness = _,
- a._SetAlphaMode(b, e),
- c.push(b),
- s[e.uniqueId] = c.length - 1,
- this._finishMaterial(d, b, e, i)
- }
- ,
- a.prototype._finishMaterial = function(e, i, o, s) {
- var c = this;
- return Promise.all(e).then(function() {
- for (var d = c._exporter._extensionsPostExportMaterialAdditionalTextures("exportMaterial", i, o), _ = null, b = 0, k = d; b < k.length; b++) {
- var j = k[b];
- _ || (_ = []),
- _.push(c._exportTextureAsync(j, s))
- }
- return _ || (_ = [Promise.resolve(null)]),
- Promise.all(_).then(function() {
- var $ = c._exporter._extensionsPostExportMaterialAsync("exportMaterial", i, o);
- return $ ? $.then(function() {
- return i
- }) : i
- })
- })
- }
- ,
- a.prototype._convertPBRMetallicRoughnessMaterialAsync = function(e, i, o) {
- var s = this._exporter._materialMap
- , c = this._exporter._materials
- , d = []
- , _ = {};
- e.baseColor && (_.baseColorFactor = [e.baseColor.r, e.baseColor.g, e.baseColor.b, e.alpha]),
- e.metallic != null && e.metallic !== 1 && (_.metallicFactor = e.metallic),
- e.roughness != null && e.roughness !== 1 && (_.roughnessFactor = e.roughness);
- var b = {
- name: e.name
- };
- return e.doubleSided && (b.doubleSided = e.doubleSided),
- a._SetAlphaMode(b, e),
- o && (e.baseTexture != null && d.push(this._exportTextureAsync(e.baseTexture, i).then(function(k) {
- k && (_.baseColorTexture = k)
- })),
- e.normalTexture && d.push(this._exportTextureAsync(e.normalTexture, i).then(function(k) {
- k && (b.normalTexture = k,
- e.normalTexture.level !== 1 && (b.normalTexture.scale = e.normalTexture.level))
- })),
- e.occlusionTexture && d.push(this._exportTextureAsync(e.occlusionTexture, i).then(function(k) {
- k && (b.occlusionTexture = k,
- e.occlusionStrength != null && (b.occlusionTexture.strength = e.occlusionStrength))
- })),
- e.emissiveTexture && d.push(this._exportTextureAsync(e.emissiveTexture, i).then(function(k) {
- k && (b.emissiveTexture = k)
- }))),
- a.FuzzyEquals(e.emissiveColor, Color3.Black(), a._Epsilon) && (b.emissiveFactor = e.emissiveColor.asArray()),
- b.pbrMetallicRoughness = _,
- c.push(b),
- s[e.uniqueId] = c.length - 1,
- this._finishMaterial(d, b, e, i)
- }
- ,
- a.prototype._createBase64FromCanvasAsync = function(e, i, o, s) {
- var c = this;
- return new Promise(function(d, _) {
- return __awaiter(c, void 0, void 0, function() {
- var b, k, j, $, _e, et;
- return __generator(this, function(tt) {
- switch (tt.label) {
- case 0:
- return b = Constants.TEXTURETYPE_UNSIGNED_INT,
- k = this._exporter._babylonScene,
- j = k.getEngine(),
- $ = j.createRawTexture(e, i, o, Constants.TEXTUREFORMAT_RGBA, !1, !0, Texture.NEAREST_SAMPLINGMODE, null, b),
- [4, TextureTools.ApplyPostProcess("pass", $, k, b, Constants.TEXTURE_NEAREST_SAMPLINGMODE, Constants.TEXTUREFORMAT_RGBA)];
- case 1:
- return tt.sent(),
- [4, j._readTexturePixels($, i, o)];
- case 2:
- return _e = tt.sent(),
- [4, Tools.DumpDataAsync(i, o, _e, s, void 0, !0, !1)];
- case 3:
- return et = tt.sent(),
- d(et),
- [2]
- }
- })
- })
- }
- )
- }
- ,
- a.prototype._createWhiteTexture = function(e, i, o) {
- for (var s = new Uint8Array(e * i * 4), c = 0; c < s.length; c = c + 4)
- s[c] = s[c + 1] = s[c + 2] = s[c + 3] = 255;
- var d = RawTexture.CreateRGBATexture(s, e, i, o);
- return d
- }
- ,
- a.prototype._resizeTexturesToSameDimensions = function(e, i, o) {
- var s = e ? e.getSize() : {
- width: 0,
- height: 0
- }, c = i ? i.getSize() : {
- width: 0,
- height: 0
- }, d, _;
- 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),
- _ = i) : s.width > c.width ? (i && i instanceof Texture ? _ = TextureTools.CreateResizedCopy(i, s.width, s.height, !0) : _ = this._createWhiteTexture(s.width, s.height, o),
- d = e) : (d = e,
- _ = i),
- {
- texture1: d,
- texture2: _
- }
- }
- ,
- a.prototype._convertPixelArrayToFloat32 = function(e) {
- if (e instanceof Uint8Array) {
- for (var i = e.length, o = new Float32Array(e.length), s = 0; s < i; ++s)
- o[s] = e[s] / 255;
- return o
- } else {
- if (e instanceof Float32Array)
- return e;
- throw new Error("Unsupported pixel format!")
- }
- }
- ,
- a.prototype._convertSpecularGlossinessTexturesToMetallicRoughnessAsync = function(e, i, o, s) {
- var c;
- return __awaiter(this, void 0, void 0, function() {
- 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;
- return __generator(this, function(Mt) {
- switch (Mt.label) {
- case 0:
- return d = [],
- e || i ? (_ = e ? e.getScene() : i ? i.getScene() : null,
- _ ? (b = this._resizeTexturesToSameDimensions(e, i, _),
- k = (c = b.texture1) === null || c === void 0 ? void 0 : c.getSize(),
- j = void 0,
- $ = void 0,
- _e = k.width,
- et = k.height,
- [4, b.texture1.readPixels()]) : [3, 3]) : [2, Promise.reject("_ConvertSpecularGlosinessTexturesToMetallicRoughness: diffuse and specular glossiness textures are not defined!")];
- case 1:
- return tt = Mt.sent(),
- [4, b.texture2.readPixels()];
- case 2:
- if (rt = Mt.sent(),
- tt)
- j = this._convertPixelArrayToFloat32(tt);
- else
- return [2, Promise.reject("Failed to retrieve pixels from diffuse texture!")];
- if (rt)
- $ = this._convertPixelArrayToFloat32(rt);
- else
- return [2, Promise.reject("Failed to retrieve pixels from specular glossiness texture!")];
- for (it = $.byteLength,
- nt = new Uint8Array(it),
- ot = new Uint8Array(it),
- at = 4,
- st = Color3.Black(),
- ut = 0,
- ct = 0,
- Et = 0; Et < et; ++Et)
- for (At = 0; At < _e; ++At)
- lt = (_e * Et + At) * at,
- ft = new Color3(j[lt],j[lt + 1],j[lt + 2]).toLinearSpace().multiply(o.diffuseColor),
- ht = new Color3($[lt],$[lt + 1],$[lt + 2]).toLinearSpace().multiply(o.specularColor),
- pt = $[lt + 3] * o.glossiness,
- dt = {
- diffuseColor: ft,
- specularColor: ht,
- glossiness: pt
- },
- _t = this._convertSpecularGlossinessToMetallicRoughness(dt),
- st.r = Math.max(st.r, _t.baseColor.r),
- st.g = Math.max(st.g, _t.baseColor.g),
- st.b = Math.max(st.b, _t.baseColor.b),
- ut = Math.max(ut, _t.metallic),
- ct = Math.max(ct, _t.roughness),
- ot[lt] = _t.baseColor.r * 255,
- ot[lt + 1] = _t.baseColor.g * 255,
- ot[lt + 2] = _t.baseColor.b * 255,
- ot[lt + 3] = b.texture1.hasAlpha ? j[lt + 3] * 255 : 255,
- nt[lt] = 0,
- nt[lt + 1] = _t.roughness * 255,
- nt[lt + 2] = _t.metallic * 255,
- nt[lt + 3] = 255;
- for (mt = {
- baseColor: st,
- metallic: ut,
- roughness: ct
- },
- vt = !1,
- yt = !1,
- Et = 0; Et < et; ++Et)
- for (At = 0; At < _e; ++At)
- gt = (_e * Et + At) * at,
- ot[gt] /= mt.baseColor.r > a._Epsilon ? mt.baseColor.r : 1,
- ot[gt + 1] /= mt.baseColor.g > a._Epsilon ? mt.baseColor.g : 1,
- ot[gt + 2] /= mt.baseColor.b > a._Epsilon ? mt.baseColor.b : 1,
- St = Color3.FromInts(ot[gt], ot[gt + 1], ot[gt + 2]),
- xt = St.toGammaSpace(),
- ot[gt] = xt.r * 255,
- ot[gt + 1] = xt.g * 255,
- ot[gt + 2] = xt.b * 255,
- a.FuzzyEquals(xt, Color3.White(), a._Epsilon) || (yt = !0),
- nt[gt + 1] /= mt.roughness > a._Epsilon ? mt.roughness : 1,
- nt[gt + 2] /= mt.metallic > a._Epsilon ? mt.metallic : 1,
- bt = Color3.FromInts(255, nt[gt + 1], nt[gt + 2]),
- a.FuzzyEquals(bt, Color3.White(), a._Epsilon) || (vt = !0);
- return vt && (Rt = this._createBase64FromCanvasAsync(nt, _e, et, s).then(function(Pt) {
- mt.metallicRoughnessTextureBase64 = Pt
- }),
- d.push(Rt)),
- yt && (Rt = this._createBase64FromCanvasAsync(ot, _e, et, s).then(function(Pt) {
- mt.baseColorTextureBase64 = Pt
- }),
- d.push(Rt)),
- [2, Promise.all(d).then(function() {
- return mt
- })];
- case 3:
- return [2, Promise.reject("_ConvertSpecularGlossinessTexturesToMetallicRoughness: Scene from textures is missing!")]
- }
- })
- })
- }
- ,
- a.prototype._convertSpecularGlossinessToMetallicRoughness = function(e) {
- var i = this._getPerceivedBrightness(e.diffuseColor)
- , o = this._getPerceivedBrightness(e.specularColor)
- , s = 1 - this._getMaxComponent(e.specularColor)
- , c = a._SolveMetallic(i, o, s)
- , d = e.diffuseColor.scale(s / (1 - a._DielectricSpecular.r) / Math.max(1 - c, a._Epsilon))
- , _ = e.specularColor.subtract(a._DielectricSpecular.scale(1 - c)).scale(1 / Math.max(c, a._Epsilon))
- , b = Color3.Lerp(d, _, c * c);
- b = b.clampToRef(0, 1, b);
- var k = {
- baseColor: b,
- metallic: c,
- roughness: 1 - e.glossiness
- };
- return k
- }
- ,
- a.prototype._getPerceivedBrightness = function(e) {
- return e ? Math.sqrt(.299 * e.r * e.r + .587 * e.g * e.g + .114 * e.b * e.b) : 0
- }
- ,
- a.prototype._getMaxComponent = function(e) {
- return e ? Math.max(e.r, Math.max(e.g, e.b)) : 0
- }
- ,
- a.prototype._convertMetalRoughFactorsToMetallicRoughnessAsync = function(e, i, o, s) {
- var c = []
- , d = e._albedoColor
- , _ = e._metallic
- , b = e._roughness
- , k = {
- baseColor: d,
- metallic: _,
- roughness: b
- };
- if (s) {
- var j = e._albedoTexture;
- j && c.push(this._exportTextureAsync(e._albedoTexture, i).then(function(_e) {
- _e && (o.baseColorTexture = _e)
- }));
- var $ = e._metallicTexture;
- $ && c.push(this._exportTextureAsync($, i).then(function(_e) {
- _e && (o.metallicRoughnessTexture = _e)
- }))
- }
- return Promise.all(c).then(function() {
- return k
- })
- }
- ,
- a.prototype._getGLTFTextureSampler = function(e) {
- var i = this._getGLTFTextureWrapModesSampler(e)
- , o = e instanceof Texture ? e.samplingMode : null;
- if (o != null)
- switch (o) {
- case Texture.LINEAR_LINEAR:
- {
- i.magFilter = 9729,
- i.minFilter = 9729;
- break
- }
- case Texture.LINEAR_NEAREST:
- {
- i.magFilter = 9729,
- i.minFilter = 9728;
- break
- }
- case Texture.NEAREST_LINEAR:
- {
- i.magFilter = 9728,
- i.minFilter = 9729;
- break
- }
- case Texture.NEAREST_LINEAR_MIPLINEAR:
- {
- i.magFilter = 9728,
- i.minFilter = 9987;
- break
- }
- case Texture.NEAREST_NEAREST:
- {
- i.magFilter = 9728,
- i.minFilter = 9728;
- break
- }
- case Texture.NEAREST_LINEAR_MIPNEAREST:
- {
- i.magFilter = 9728,
- i.minFilter = 9985;
- break
- }
- case Texture.LINEAR_NEAREST_MIPNEAREST:
- {
- i.magFilter = 9729,
- i.minFilter = 9984;
- break
- }
- case Texture.LINEAR_NEAREST_MIPLINEAR:
- {
- i.magFilter = 9729,
- i.minFilter = 9986;
- break
- }
- case Texture.NEAREST_NEAREST_MIPLINEAR:
- {
- i.magFilter = 9728,
- i.minFilter = 9986;
- break
- }
- case Texture.LINEAR_LINEAR_MIPLINEAR:
- {
- i.magFilter = 9729,
- i.minFilter = 9987;
- break
- }
- case Texture.LINEAR_LINEAR_MIPNEAREST:
- {
- i.magFilter = 9729,
- i.minFilter = 9985;
- break
- }
- case Texture.NEAREST_NEAREST_MIPNEAREST:
- {
- i.magFilter = 9728,
- i.minFilter = 9984;
- break
- }
- }
- return i
- }
- ,
- a.prototype._getGLTFTextureWrapMode = function(e) {
- switch (e) {
- case Texture.WRAP_ADDRESSMODE:
- return 10497;
- case Texture.CLAMP_ADDRESSMODE:
- return 33071;
- case Texture.MIRROR_ADDRESSMODE:
- return 33648;
- default:
- return Tools.Error("Unsupported Texture Wrap Mode " + e + "!"),
- 10497
- }
- }
- ,
- a.prototype._getGLTFTextureWrapModesSampler = function(e) {
- var i = this._getGLTFTextureWrapMode(e instanceof Texture ? e.wrapU : Texture.WRAP_ADDRESSMODE)
- , o = this._getGLTFTextureWrapMode(e instanceof Texture ? e.wrapV : Texture.WRAP_ADDRESSMODE);
- return i === 10497 && o === 10497 ? {} : {
- wrapS: i,
- wrapT: o
- }
- }
- ,
- a.prototype._convertSpecGlossFactorsToMetallicRoughnessAsync = function(e, i, o, s) {
- var c = this;
- return Promise.resolve().then(function() {
- var d = c._exporter._samplers
- , _ = c._exporter._textures
- , b = e._albedoColor
- , k = e._reflectivityColor
- , j = e._microSurface
- , $ = {
- diffuseColor: b,
- specularColor: k,
- glossiness: j
- }
- , _e = null
- , et = e._albedoTexture
- , tt = e._reflectivityTexture;
- if (et) {
- var rt = c._getGLTFTextureSampler(et);
- rt.magFilter != null && rt.minFilter != null && rt.wrapS != null && rt.wrapT != null && (d.push(rt),
- _e = d.length - 1)
- }
- var it = e._useMicroSurfaceFromReflectivityMapAlpha;
- 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) {
- if (nt.baseColorTextureBase64) {
- var ot = c._getTextureInfoFromBase64(nt.baseColorTextureBase64, "bjsBaseColorTexture_" + _.length + ".png", i, et ? et.coordinatesIndex : null, _e);
- ot && (o.baseColorTexture = ot)
- }
- if (nt.metallicRoughnessTextureBase64) {
- var at = c._getTextureInfoFromBase64(nt.metallicRoughnessTextureBase64, "bjsMetallicRoughnessTexture_" + _.length + ".png", i, tt ? tt.coordinatesIndex : null, _e);
- at && (o.metallicRoughnessTexture = at)
- }
- return nt
- }) : c._convertSpecularGlossinessToMetallicRoughness($)
- })
- }
- ,
- a.prototype._convertPBRMaterialAsync = function(e, i, o) {
- var s = this
- , c = {}
- , d = {
- name: e.name
- }
- , _ = e.isMetallicWorkflow();
- if (_) {
- var b = e._albedoColor
- , k = e.alpha;
- return b && (c.baseColorFactor = [b.r, b.g, b.b, k]),
- this._convertMetalRoughFactorsToMetallicRoughnessAsync(e, i, c, o).then(function(j) {
- return s.setMetallicRoughnessPbrMaterial(j, e, d, c, i, o)
- })
- } else
- return this._convertSpecGlossFactorsToMetallicRoughnessAsync(e, i, c, o).then(function(j) {
- return s.setMetallicRoughnessPbrMaterial(j, e, d, c, i, o)
- })
- }
- ,
- a.prototype.setMetallicRoughnessPbrMaterial = function(e, i, o, s, c, d) {
- var _ = this._exporter._materialMap
- , b = this._exporter._materials
- , k = [];
- if (e) {
- if (a._SetAlphaMode(o, i),
- 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]),
- e.metallic != null && e.metallic !== 1 && (s.metallicFactor = e.metallic),
- e.roughness != null && e.roughness !== 1 && (s.roughnessFactor = e.roughness),
- 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."),
- o.doubleSided = !0),
- d) {
- var j = i._bumpTexture;
- if (j) {
- var $ = this._exportTextureAsync(j, c).then(function(rt) {
- rt && (o.normalTexture = rt,
- j.level !== 1 && (o.normalTexture.scale = j.level))
- });
- k.push($)
- }
- var _e = i._ambientTexture;
- if (_e) {
- var $ = this._exportTextureAsync(_e, c).then(function(it) {
- if (it) {
- var nt = {
- index: it.index,
- texCoord: it.texCoord
- };
- o.occlusionTexture = nt;
- var ot = i._ambientTextureStrength;
- ot && (nt.strength = ot)
- }
- });
- k.push($)
- }
- var et = i._emissiveTexture;
- if (et) {
- var $ = this._exportTextureAsync(et, c).then(function(it) {
- it && (o.emissiveTexture = it)
- });
- k.push($)
- }
- }
- var tt = i._emissiveColor;
- a.FuzzyEquals(tt, Color3.Black(), a._Epsilon) || (o.emissiveFactor = tt.asArray()),
- o.pbrMetallicRoughness = s,
- b.push(o),
- _[i.uniqueId] = b.length - 1
- }
- return this._finishMaterial(k, o, i, c)
- }
- ,
- a.prototype.getPixelsFromTexture = function(e) {
- var i = (e.textureType === Constants.TEXTURETYPE_UNSIGNED_INT,
- e.readPixels());
- return i
- }
- ,
- a.prototype._exportTextureAsync = function(e, i) {
- var o = this
- , s = this._exporter._extensionsPreExportTextureAsync("exporter", e, i);
- return s ? s.then(function(c) {
- return c ? o._exportTextureInfoAsync(c, i) : o._exportTextureInfoAsync(e, i)
- }) : this._exportTextureInfoAsync(e, i)
- }
- ,
- a.prototype._exportTextureInfoAsync = function(e, i) {
- var o = this;
- return Promise.resolve().then(function() {
- return __awaiter(o, void 0, void 0, function() {
- var s, c, d, _, b, k, j, $, _e, et = this;
- return __generator(this, function(tt) {
- switch (tt.label) {
- case 0:
- return s = e.uid,
- s in this._textureMap ? [2, this._textureMap[s]] : [3, 1];
- case 1:
- return [4, this.getPixelsFromTexture(e)];
- case 2:
- if (c = tt.sent(),
- !c)
- return [2, null];
- for (d = this._exporter._samplers,
- _ = this._getGLTFTextureSampler(e),
- b = null,
- k = null,
- j = 0; j < d.length; ++j)
- if ($ = d[j],
- $.minFilter === _.minFilter && $.magFilter === _.magFilter && $.wrapS === _.wrapS && $.wrapT === _.wrapT) {
- k = j;
- break
- }
- if (k == null ? (d.push(_),
- b = d.length - 1) : b = k,
- _e = e.getSize(),
- e.mimeType)
- switch (e.mimeType) {
- case "image/jpeg":
- i = "image/jpeg";
- break;
- case "image/png":
- i = "image/png";
- break
- }
- return [2, this._createBase64FromCanvasAsync(c, _e.width, _e.height, i).then(function(rt) {
- var it = et._getTextureInfoFromBase64(rt, e.name.replace(/\.\/|\/|\.\\|\\/g, "_"), i, e.coordinatesIndex, b);
- return it && (et._textureMap[s] = it,
- et._exporter._extensionsPostExportTextures("linkTextureInfo", it, e)),
- it
- })]
- }
- })
- })
- })
- }
- ,
- a.prototype._getTextureInfoFromBase64 = function(e, i, o, s, c) {
- var d = this._exporter._textures
- , _ = this._exporter._images
- , b = this._exporter._imageData
- , k = null
- , j = {
- source: _.length,
- name: i
- };
- c != null && (j.sampler = c);
- for (var $ = atob(e.split(",")[1]), _e = new ArrayBuffer($.length), et = new Uint8Array(_e), tt = 0, rt = $.length; tt < rt; ++tt)
- et[tt] = $.charCodeAt(tt);
- var it = {
- data: et,
- mimeType: o
- }
- , nt = o === "image/jpeg" ? ".jpeg" : ".png"
- , ot = i + nt
- , at = ot;
- if (ot in b && (ot = i + "_" + Tools.RandomId() + nt),
- b[ot] = it,
- o === "image/jpeg" || o === "image/png") {
- for (var st = {
- name: i,
- uri: ot
- }, ut = null, tt = 0; tt < _.length; ++tt)
- if (_[tt].uri === at) {
- ut = tt;
- break
- }
- ut == null ? (_.push(st),
- j.source = _.length - 1) : j.source = ut,
- d.push(j),
- k = {
- index: d.length - 1
- },
- s != null && (k.texCoord = s)
- } else
- Tools.Error("Unsupported texture mime type " + o);
- return k
- }
- ,
- a._DielectricSpecular = new Color3(.04,.04,.04),
- a._MaxSpecularPower = 1024,
- a._Epsilon = 1e-6,
- a
- }()
- , _Exporter = function() {
- function a(e, i) {
- this._includeCoordinateSystemConversionNodes = !1,
- this._extensions = {},
- this._glTF = {
- asset: {
- generator: "BabylonJS",
- version: "2.0"
- }
- },
- this._babylonScene = e,
- this._bufferViews = [],
- this._accessors = [],
- this._meshes = [],
- this._scenes = [],
- this._nodes = [],
- this._images = [],
- this._materials = [],
- this._materialMap = [],
- this._textures = [],
- this._samplers = [],
- this._skins = [],
- this._animations = [],
- this._imageData = {},
- this._orderedImageData = [],
- this._options = i || {},
- this._animationSampleRate = i && i.animationSampleRate ? i.animationSampleRate : 1 / 60,
- this._includeCoordinateSystemConversionNodes = !!(i && i.includeCoordinateSystemConversionNodes),
- this._glTFMaterialExporter = new _GLTFMaterialExporter(this),
- this._loadExtensions()
- }
- return a.prototype._applyExtension = function(e, i, o, s) {
- var c = this;
- if (o >= i.length)
- return Promise.resolve(e);
- var d = s(i[o], e);
- return d ? d.then(function(_) {
- return c._applyExtension(_, i, o + 1, s)
- }) : this._applyExtension(e, i, o + 1, s)
- }
- ,
- a.prototype._applyExtensions = function(e, i) {
- for (var o = [], s = 0, c = a._ExtensionNames; s < c.length; s++) {
- var d = c[s];
- o.push(this._extensions[d])
- }
- return this._applyExtension(e, o, 0, i)
- }
- ,
- a.prototype._extensionsPreExportTextureAsync = function(e, i, o) {
- return this._applyExtensions(i, function(s, c) {
- return s.preExportTextureAsync && s.preExportTextureAsync(e, c, o)
- })
- }
- ,
- a.prototype._extensionsPostExportMeshPrimitiveAsync = function(e, i, o, s) {
- return this._applyExtensions(i, function(c, d) {
- return c.postExportMeshPrimitiveAsync && c.postExportMeshPrimitiveAsync(e, d, o, s)
- })
- }
- ,
- a.prototype._extensionsPostExportNodeAsync = function(e, i, o, s) {
- return this._applyExtensions(i, function(c, d) {
- return c.postExportNodeAsync && c.postExportNodeAsync(e, d, o, s)
- })
- }
- ,
- a.prototype._extensionsPostExportMaterialAsync = function(e, i, o) {
- return this._applyExtensions(i, function(s, c) {
- return s.postExportMaterialAsync && s.postExportMaterialAsync(e, c, o)
- })
- }
- ,
- a.prototype._extensionsPostExportMaterialAdditionalTextures = function(e, i, o) {
- for (var s = [], c = 0, d = a._ExtensionNames; c < d.length; c++) {
- var _ = d[c]
- , b = this._extensions[_];
- b.postExportMaterialAdditionalTextures && s.push.apply(s, b.postExportMaterialAdditionalTextures(e, i, o))
- }
- return s
- }
- ,
- a.prototype._extensionsPostExportTextures = function(e, i, o) {
- for (var s = 0, c = a._ExtensionNames; s < c.length; s++) {
- var d = c[s]
- , _ = this._extensions[d];
- _.postExportTexture && _.postExportTexture(e, i, o)
- }
- }
- ,
- a.prototype._forEachExtensions = function(e) {
- for (var i = 0, o = a._ExtensionNames; i < o.length; i++) {
- var s = o[i]
- , c = this._extensions[s];
- c.enabled && e(c)
- }
- }
- ,
- a.prototype._extensionsOnExporting = function() {
- var e = this;
- this._forEachExtensions(function(i) {
- i.wasUsed && (e._glTF.extensionsUsed == null && (e._glTF.extensionsUsed = []),
- e._glTF.extensionsUsed.indexOf(i.name) === -1 && e._glTF.extensionsUsed.push(i.name),
- i.required && (e._glTF.extensionsRequired == null && (e._glTF.extensionsRequired = []),
- e._glTF.extensionsRequired.indexOf(i.name) === -1 && e._glTF.extensionsRequired.push(i.name)),
- e._glTF.extensions == null && (e._glTF.extensions = {}),
- i.onExporting && i.onExporting())
- })
- }
- ,
- a.prototype._loadExtensions = function() {
- for (var e = 0, i = a._ExtensionNames; e < i.length; e++) {
- var o = i[e]
- , s = a._ExtensionFactories[o](this);
- this._extensions[o] = s
- }
- }
- ,
- a.prototype.dispose = function() {
- for (var e in this._extensions) {
- var i = this._extensions[e];
- i.dispose()
- }
- }
- ,
- a.RegisterExtension = function(e, i) {
- a.UnregisterExtension(e) && Tools.Warn("Extension with the name " + e + " already exists"),
- a._ExtensionFactories[e] = i,
- a._ExtensionNames.push(e)
- }
- ,
- a.UnregisterExtension = function(e) {
- if (!a._ExtensionFactories[e])
- return !1;
- delete a._ExtensionFactories[e];
- var i = a._ExtensionNames.indexOf(e);
- return i !== -1 && a._ExtensionNames.splice(i, 1),
- !0
- }
- ,
- a.prototype.reorderIndicesBasedOnPrimitiveMode = function(e, i, o, s, c) {
- switch (i) {
- case Material.TriangleFillMode:
- {
- s || (s = 0);
- for (var d = e.indexStart, _ = e.indexStart + e.indexCount; d < _; d = d + 3) {
- var b = s + d * 4
- , k = c.getUInt32(b + 4)
- , j = c.getUInt32(b + 8);
- c.setUInt32(j, b + 4),
- c.setUInt32(k, b + 8)
- }
- break
- }
- case Material.TriangleFanDrawMode:
- {
- for (var d = e.indexStart + e.indexCount - 1, $ = e.indexStart; d >= $; --d)
- c.setUInt32(o[d], s),
- s += 4;
- break
- }
- case Material.TriangleStripDrawMode:
- {
- e.indexCount >= 3 && (c.setUInt32(o[e.indexStart + 2], s + 4),
- c.setUInt32(o[e.indexStart + 1], s + 8));
- break
- }
- }
- }
- ,
- a.prototype.reorderVertexAttributeDataBasedOnPrimitiveMode = function(e, i, o, s, c, d, _, b) {
- if (b && o === Material.ClockWiseSideOrientation)
- switch (i) {
- case Material.TriangleFillMode:
- {
- this.reorderTriangleFillMode(e, i, o, s, c, d, _, b);
- break
- }
- case Material.TriangleStripDrawMode:
- {
- this.reorderTriangleStripDrawMode(e, i, o, s, c, d, _, b);
- break
- }
- case Material.TriangleFanDrawMode:
- {
- this.reorderTriangleFanMode(e, i, o, s, c, d, _, b);
- break
- }
- }
- }
- ,
- a.prototype.reorderTriangleFillMode = function(e, i, o, s, c, d, _, b) {
- var k = this.getVertexBufferFromMesh(s, e.getMesh());
- if (k) {
- var j = k.byteStride / VertexBuffer.GetTypeByteLength(k.type);
- if (e.verticesCount % 3 !== 0)
- Tools.Error("The submesh vertices for the triangle fill mode is not divisible by 3!");
- else {
- var $ = []
- , _e = 0;
- switch (s) {
- case VertexBuffer.PositionKind:
- case VertexBuffer.NormalKind:
- {
- for (var et = e.verticesStart; et < e.verticesStart + e.verticesCount; et = et + 3)
- _e = et * j,
- $.push(Vector3.FromArray(c, _e)),
- $.push(Vector3.FromArray(c, _e + 2 * j)),
- $.push(Vector3.FromArray(c, _e + j));
- break
- }
- case VertexBuffer.TangentKind:
- {
- for (var et = e.verticesStart; et < e.verticesStart + e.verticesCount; et = et + 3)
- _e = et * j,
- $.push(Vector4.FromArray(c, _e)),
- $.push(Vector4.FromArray(c, _e + 2 * j)),
- $.push(Vector4.FromArray(c, _e + j));
- break
- }
- case VertexBuffer.ColorKind:
- {
- for (var tt = k.getSize(), et = e.verticesStart; et < e.verticesStart + e.verticesCount; et = et + tt)
- _e = et * j,
- tt === 4 ? ($.push(Vector4.FromArray(c, _e)),
- $.push(Vector4.FromArray(c, _e + 2 * j)),
- $.push(Vector4.FromArray(c, _e + j))) : ($.push(Vector3.FromArray(c, _e)),
- $.push(Vector3.FromArray(c, _e + 2 * j)),
- $.push(Vector3.FromArray(c, _e + j)));
- break
- }
- case VertexBuffer.UVKind:
- case VertexBuffer.UV2Kind:
- {
- for (var et = e.verticesStart; et < e.verticesStart + e.verticesCount; et = et + 3)
- _e = et * j,
- $.push(Vector2.FromArray(c, _e)),
- $.push(Vector2.FromArray(c, _e + 2 * j)),
- $.push(Vector2.FromArray(c, _e + j));
- break
- }
- default:
- Tools.Error("Unsupported Vertex Buffer type: " + s)
- }
- this.writeVertexAttributeData($, d, s, c, _, b)
- }
- } else
- Tools.Warn("reorderTriangleFillMode: Vertex Buffer Kind " + s + " not present!")
- }
- ,
- a.prototype.reorderTriangleStripDrawMode = function(e, i, o, s, c, d, _, b) {
- var k = this.getVertexBufferFromMesh(s, e.getMesh());
- if (k) {
- var j = k.byteStride / VertexBuffer.GetTypeByteLength(k.type)
- , $ = []
- , _e = 0;
- switch (s) {
- case VertexBuffer.PositionKind:
- case VertexBuffer.NormalKind:
- {
- _e = e.verticesStart,
- $.push(Vector3.FromArray(c, _e + 2 * j)),
- $.push(Vector3.FromArray(c, _e + j));
- break
- }
- case VertexBuffer.TangentKind:
- {
- for (var et = e.verticesStart + e.verticesCount - 1; et >= e.verticesStart; --et)
- _e = et * j,
- $.push(Vector4.FromArray(c, _e));
- break
- }
- case VertexBuffer.ColorKind:
- {
- for (var et = e.verticesStart + e.verticesCount - 1; et >= e.verticesStart; --et)
- _e = et * j,
- k.getSize() === 4 ? $.push(Vector4.FromArray(c, _e)) : $.push(Vector3.FromArray(c, _e));
- break
- }
- case VertexBuffer.UVKind:
- case VertexBuffer.UV2Kind:
- {
- for (var et = e.verticesStart + e.verticesCount - 1; et >= e.verticesStart; --et)
- _e = et * j,
- $.push(Vector2.FromArray(c, _e));
- break
- }
- default:
- Tools.Error("Unsupported Vertex Buffer type: " + s)
- }
- this.writeVertexAttributeData($, d + 12, s, c, _, b)
- } else
- Tools.Warn("reorderTriangleStripDrawMode: Vertex buffer kind " + s + " not present!")
- }
- ,
- a.prototype.reorderTriangleFanMode = function(e, i, o, s, c, d, _, b) {
- var k = this.getVertexBufferFromMesh(s, e.getMesh());
- if (k) {
- var j = k.byteStride / VertexBuffer.GetTypeByteLength(k.type)
- , $ = []
- , _e = 0;
- switch (s) {
- case VertexBuffer.PositionKind:
- case VertexBuffer.NormalKind:
- {
- for (var et = e.verticesStart + e.verticesCount - 1; et >= e.verticesStart; --et)
- _e = et * j,
- $.push(Vector3.FromArray(c, _e));
- break
- }
- case VertexBuffer.TangentKind:
- {
- for (var et = e.verticesStart + e.verticesCount - 1; et >= e.verticesStart; --et)
- _e = et * j,
- $.push(Vector4.FromArray(c, _e));
- break
- }
- case VertexBuffer.ColorKind:
- {
- for (var et = e.verticesStart + e.verticesCount - 1; et >= e.verticesStart; --et)
- _e = et * j,
- $.push(Vector4.FromArray(c, _e)),
- k.getSize() === 4 ? $.push(Vector4.FromArray(c, _e)) : $.push(Vector3.FromArray(c, _e));
- break
- }
- case VertexBuffer.UVKind:
- case VertexBuffer.UV2Kind:
- {
- for (var et = e.verticesStart + e.verticesCount - 1; et >= e.verticesStart; --et)
- _e = et * j,
- $.push(Vector2.FromArray(c, _e));
- break
- }
- default:
- Tools.Error("Unsupported Vertex Buffer type: " + s)
- }
- this.writeVertexAttributeData($, d, s, c, _, b)
- } else
- Tools.Warn("reorderTriangleFanMode: Vertex buffer kind " + s + " not present!")
- }
- ,
- a.prototype.writeVertexAttributeData = function(e, i, o, s, c, d) {
- for (var _ = 0, b = e; _ < b.length; _++) {
- var k = b[_];
- 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)),
- o === VertexBuffer.NormalKind ? k.normalize() : o === VertexBuffer.TangentKind && k instanceof Vector4 && _GLTFUtilities._NormalizeTangentFromRef(k);
- for (var j = 0, $ = k.asArray(); j < $.length; j++) {
- var _e = $[j];
- c.setFloat32(_e, i),
- i += 4
- }
- }
- }
- ,
- a.prototype.writeAttributeData = function(e, i, o, s, c, d, _) {
- var b = [], k;
- switch (e) {
- case VertexBuffer.PositionKind:
- {
- for (var j = 0, $ = o.length / s; j < $; ++j) {
- k = j * s;
- var _e = Vector3.FromArray(o, k);
- d && _GLTFUtilities._GetRightHandedPositionVector3FromRef(_e),
- b.push(_e.asArray())
- }
- break
- }
- case VertexBuffer.NormalKind:
- {
- for (var j = 0, et = o.length / s; j < et; ++j) {
- k = j * s;
- var _e = Vector3.FromArray(o, k);
- d && _GLTFUtilities._GetRightHandedNormalVector3FromRef(_e),
- _e.normalize(),
- b.push(_e.asArray())
- }
- break
- }
- case VertexBuffer.TangentKind:
- {
- for (var j = 0, tt = o.length / s; j < tt; ++j) {
- k = j * s;
- var _e = Vector4.FromArray(o, k);
- d && _GLTFUtilities._GetRightHandedVector4FromRef(_e),
- _GLTFUtilities._NormalizeTangentFromRef(_e),
- b.push(_e.asArray())
- }
- break
- }
- case VertexBuffer.ColorKind:
- {
- 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)
- k = j * s,
- s === 3 ? (Color3.FromArrayToRef(o, k, _e),
- it && _e.toLinearSpaceToRef(_e)) : (Color4.FromArrayToRef(o, k, _e),
- it && _e.toLinearSpaceToRef(_e)),
- b.push(_e.asArray());
- break
- }
- case VertexBuffer.UVKind:
- case VertexBuffer.UV2Kind:
- {
- for (var j = 0, ot = o.length / s; j < ot; ++j)
- k = j * s,
- b.push(d ? [o[k], o[k + 1]] : [o[k], o[k + 1]]);
- break
- }
- case VertexBuffer.MatricesIndicesKind:
- case VertexBuffer.MatricesIndicesExtraKind:
- {
- for (var j = 0, at = o.length / s; j < at; ++j) {
- k = j * s;
- var _e = Vector4.FromArray(o, k);
- b.push(_e.asArray())
- }
- break
- }
- case VertexBuffer.MatricesWeightsKind:
- case VertexBuffer.MatricesWeightsExtraKind:
- {
- for (var j = 0, st = o.length / s; j < st; ++j) {
- k = j * s;
- var _e = Vector4.FromArray(o, k);
- b.push(_e.asArray())
- }
- break
- }
- default:
- Tools.Warn("Unsupported Vertex Buffer Type: " + e),
- b = []
- }
- var ut;
- switch (i) {
- case 5121:
- {
- ut = c.setUInt8.bind(c);
- break
- }
- case 5123:
- {
- ut = c.setUInt16.bind(c);
- break
- }
- case 5125:
- ut = c.setUInt32.bind(c);
- case 5126:
- {
- ut = c.setFloat32.bind(c);
- break
- }
- default:
- {
- Tools.Warn("Unsupported Attribute Component kind: " + i);
- return
- }
- }
- for (var ct = 0, lt = b; ct < lt.length; ct++)
- for (var ft = lt[ct], ht = 0, pt = ft; ht < pt.length; ht++) {
- var dt = pt[ht];
- ut(dt)
- }
- }
- ,
- a.prototype.writeMorphTargetAttributeData = function(e, i, o, s, c, d, _, b, k, j) {
- var $ = [], _e, et = new Vector3, tt = new Vector4(0,0,0,0);
- switch (e) {
- case VertexBuffer.PositionKind:
- {
- for (var rt = o.verticesStart; rt < o.verticesCount; ++rt) {
- _e = o.indexStart + rt * _;
- var it = Vector3.FromArray(c, _e)
- , nt = Vector3.FromArray(d, _e);
- et = nt.subtractToRef(it, et),
- k && _GLTFUtilities._GetRightHandedPositionVector3FromRef(et),
- 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)),
- j.max.copyFromFloats(Math.max(et.x, j.max.x), Math.max(et.y, j.max.y), Math.max(et.z, j.max.z))),
- $.push(et.asArray())
- }
- break
- }
- case VertexBuffer.NormalKind:
- {
- for (var rt = o.verticesStart; rt < o.verticesCount; ++rt) {
- _e = o.indexStart + rt * _;
- var it = Vector3.FromArray(c, _e);
- it.normalize();
- var nt = Vector3.FromArray(d, _e);
- nt.normalize(),
- et = nt.subtractToRef(it, et),
- k && _GLTFUtilities._GetRightHandedNormalVector3FromRef(et),
- $.push(et.asArray())
- }
- break
- }
- case VertexBuffer.TangentKind:
- {
- for (var rt = o.verticesStart; rt < o.verticesCount; ++rt) {
- _e = o.indexStart + rt * (_ + 1);
- var it = Vector4.FromArray(c, _e);
- _GLTFUtilities._NormalizeTangentFromRef(it);
- var nt = Vector4.FromArray(d, _e);
- _GLTFUtilities._NormalizeTangentFromRef(nt),
- tt = nt.subtractToRef(it, tt),
- k && _GLTFUtilities._GetRightHandedVector4FromRef(tt),
- $.push([tt.x, tt.y, tt.z])
- }
- break
- }
- default:
- Tools.Warn("Unsupported Vertex Buffer Type: " + e),
- $ = []
- }
- var ot;
- switch (i) {
- case 5121:
- {
- ot = b.setUInt8.bind(b);
- break
- }
- case 5123:
- {
- ot = b.setUInt16.bind(b);
- break
- }
- case 5125:
- ot = b.setUInt32.bind(b);
- case 5126:
- {
- ot = b.setFloat32.bind(b);
- break
- }
- default:
- {
- Tools.Warn("Unsupported Attribute Component kind: " + i);
- return
- }
- }
- for (var at = 0, st = $; at < st.length; at++)
- for (var ut = st[at], ct = 0, lt = ut; ct < lt.length; ct++) {
- var ft = lt[ct];
- ot(ft)
- }
- }
- ,
- a.prototype.generateJSON = function(e, i, o) {
- var s = this, c = {
- byteLength: this._totalByteLength
- }, d, _, b, k = this._totalByteLength;
- c.byteLength && (this._glTF.buffers = [c]),
- this._nodes && this._nodes.length && (this._glTF.nodes = this._nodes),
- this._meshes && this._meshes.length && (this._glTF.meshes = this._meshes),
- this._scenes && this._scenes.length && (this._glTF.scenes = this._scenes,
- this._glTF.scene = 0),
- this._bufferViews && this._bufferViews.length && (this._glTF.bufferViews = this._bufferViews),
- this._accessors && this._accessors.length && (this._glTF.accessors = this._accessors),
- this._animations && this._animations.length && (this._glTF.animations = this._animations),
- this._materials && this._materials.length && (this._glTF.materials = this._materials),
- this._textures && this._textures.length && (this._glTF.textures = this._textures),
- this._samplers && this._samplers.length && (this._glTF.samplers = this._samplers),
- this._skins && this._skins.length && (this._glTF.skins = this._skins),
- this._images && this._images.length && (e ? (this._glTF.images = [],
- this._images.forEach(function($) {
- $.uri && (_ = s._imageData[$.uri],
- s._orderedImageData.push(_),
- d = $.uri.split(".")[0] + " image",
- b = _GLTFUtilities._CreateBufferView(0, k, _.data.length, void 0, d),
- k += _.data.buffer.byteLength,
- s._bufferViews.push(b),
- $.bufferView = s._bufferViews.length - 1,
- $.name = d,
- $.mimeType = _.mimeType,
- $.uri = void 0,
- s._glTF.images || (s._glTF.images = []),
- s._glTF.images.push($))
- }),
- c.byteLength = k) : this._glTF.images = this._images),
- e || (c.uri = i + ".bin");
- var j = o ? JSON.stringify(this._glTF, null, 2) : JSON.stringify(this._glTF);
- return j
- }
- ,
- a.prototype._generateGLTFAsync = function(e, i) {
- var o = this;
- return i === void 0 && (i = !0),
- this._generateBinaryAsync().then(function(s) {
- o._extensionsOnExporting();
- var c = o.generateJSON(!1, e, !0)
- , d = new Blob([s],{
- type: "application/octet-stream"
- })
- , _ = e + ".gltf"
- , b = e + ".bin"
- , k = new GLTFData;
- if (k.glTFFiles[_] = c,
- k.glTFFiles[b] = d,
- o._imageData)
- for (var j in o._imageData)
- k.glTFFiles[j] = new Blob([o._imageData[j].data],{
- type: o._imageData[j].mimeType
- });
- return i && o.dispose(),
- k
- })
- }
- ,
- a.prototype._generateBinaryAsync = function() {
- var e = this
- , i = new _BinaryWriter(4);
- return this.createSceneAsync(this._babylonScene, i).then(function() {
- return e._localEngine && e._localEngine.dispose(),
- i.getArrayBuffer()
- })
- }
- ,
- a.prototype._getPadding = function(e) {
- var i = e % 4
- , o = i === 0 ? i : 4 - i;
- return o
- }
- ,
- a.prototype._generateGLBAsync = function(e, i) {
- var o = this;
- return i === void 0 && (i = !0),
- this._generateBinaryAsync().then(function(s) {
- o._extensionsOnExporting();
- var c = o.generateJSON(!0), d = e + ".glb", _ = 12, b = 8, k = c.length, j, $ = 0;
- if (typeof TextEncoder != "undefined") {
- var _e = new TextEncoder;
- j = _e.encode(c),
- k = j.length
- }
- for (var et = 0; et < o._orderedImageData.length; ++et)
- $ += o._orderedImageData[et].data.byteLength;
- var tt = o._getPadding(k)
- , rt = o._getPadding(s.byteLength)
- , it = o._getPadding($)
- , nt = _ + 2 * b + k + tt + s.byteLength + rt + $ + it
- , ot = new ArrayBuffer(_)
- , at = new DataView(ot);
- at.setUint32(0, 1179937895, !0),
- at.setUint32(4, 2, !0),
- at.setUint32(8, nt, !0);
- var st = new ArrayBuffer(b + k + tt)
- , ut = new DataView(st);
- ut.setUint32(0, k + tt, !0),
- ut.setUint32(4, 1313821514, !0);
- var ct = new Uint8Array(st,b);
- if (j)
- ct.set(j);
- else
- for (var lt = "_".charCodeAt(0), et = 0; et < k; ++et) {
- var ft = c.charCodeAt(et);
- ft != c.codePointAt(et) ? ct[et] = lt : ct[et] = ft
- }
- for (var ht = new Uint8Array(st,b + k), et = 0; et < tt; ++et)
- ht[et] = 32;
- var pt = new ArrayBuffer(b)
- , dt = new DataView(pt);
- dt.setUint32(0, s.byteLength + $ + it, !0),
- dt.setUint32(4, 5130562, !0);
- for (var _t = new ArrayBuffer(rt), mt = new Uint8Array(_t), et = 0; et < rt; ++et)
- mt[et] = 0;
- for (var vt = new ArrayBuffer(it), yt = new Uint8Array(vt), et = 0; et < it; ++et)
- yt[et] = 0;
- for (var Et = [ot, st, pt, s], et = 0; et < o._orderedImageData.length; ++et)
- Et.push(o._orderedImageData[et].data.buffer);
- Et.push(_t),
- Et.push(vt);
- var At = new Blob(Et,{
- type: "application/octet-stream"
- })
- , gt = new GLTFData;
- return gt.glTFFiles[d] = At,
- o._localEngine != null && o._localEngine.dispose(),
- i && o.dispose(),
- gt
- })
- }
- ,
- a.prototype.setNodeTransformation = function(e, i, o) {
- i.getPivotPoint().equalsToFloats(0, 0, 0) || Tools.Warn("Pivot points are not supported in the glTF serializer"),
- i.position.equalsToFloats(0, 0, 0) || (e.translation = o ? _GLTFUtilities._GetRightHandedPositionVector3(i.position).asArray() : i.position.asArray()),
- i.scaling.equalsToFloats(1, 1, 1) || (e.scale = i.scaling.asArray());
- var s = Quaternion.RotationYawPitchRoll(i.rotation.y, i.rotation.x, i.rotation.z);
- i.rotationQuaternion && s.multiplyInPlace(i.rotationQuaternion),
- s.x === 0 && s.y === 0 && s.z === 0 && s.w === 1 || (o && _GLTFUtilities._GetRightHandedQuaternionFromRef(s),
- e.rotation = s.normalize().asArray())
- }
- ,
- a.prototype.getVertexBufferFromMesh = function(e, i) {
- if (i.isVerticesDataPresent(e)) {
- var o = i.getVertexBuffer(e);
- if (o)
- return o
- }
- return null
- }
- ,
- a.prototype.createBufferViewKind = function(e, i, o, s, c, d) {
- var _ = o instanceof Mesh ? o : o instanceof InstancedMesh ? o.sourceMesh : null;
- if (_) {
- var b = _.getVertexBuffer(e)
- , k = _.getVerticesData(e);
- if (b && k) {
- var j = VertexBuffer.GetTypeByteLength(i)
- , $ = k.length * j
- , _e = _GLTFUtilities._CreateBufferView(0, s.getByteOffset(), $, c, e + " - " + _.name);
- this._bufferViews.push(_e),
- this.writeAttributeData(e, i, k, c / j, s, d, o)
- }
- }
- }
- ,
- a.prototype.setMorphTargetAttributes = function(e, i, o, s, c) {
- if (o) {
- i.targets || (i.targets = []);
- var d = {};
- if (o.hasNormals) {
- var _ = e.getMesh().getVerticesData(VertexBuffer.NormalKind)
- , b = o.getNormals()
- , k = e.verticesCount
- , j = 12
- , $ = k * j
- , _e = _GLTFUtilities._CreateBufferView(0, s.getByteOffset(), $, j, o.name + "_NORMAL");
- this._bufferViews.push(_e);
- var et = this._bufferViews.length - 1
- , tt = _GLTFUtilities._CreateAccessor(et, o.name + " - NORMAL", "VEC3", 5126, k, 0, null, null);
- this._accessors.push(tt),
- d.NORMAL = this._accessors.length - 1,
- this.writeMorphTargetAttributeData(VertexBuffer.NormalKind, 5126, e, o, _, b, j / 4, s, c)
- }
- if (o.hasPositions) {
- var rt = e.getMesh().getVerticesData(VertexBuffer.PositionKind)
- , it = o.getPositions()
- , k = e.verticesCount
- , j = 12
- , $ = k * j
- , _e = _GLTFUtilities._CreateBufferView(0, s.getByteOffset(), $, j, o.name + "_POSITION");
- this._bufferViews.push(_e);
- var et = this._bufferViews.length - 1
- , nt = {
- min: new Vector3(1 / 0,1 / 0,1 / 0),
- max: new Vector3(-1 / 0,-1 / 0,-1 / 0)
- }
- , tt = _GLTFUtilities._CreateAccessor(et, o.name + " - POSITION", "VEC3", 5126, k, 0, null, null);
- this._accessors.push(tt),
- d.POSITION = this._accessors.length - 1,
- this.writeMorphTargetAttributeData(VertexBuffer.PositionKind, 5126, e, o, rt, it, j / 4, s, c, nt),
- tt.min = nt.min.asArray(),
- tt.max = nt.max.asArray()
- }
- if (o.hasTangents) {
- var ot = e.getMesh().getVerticesData(VertexBuffer.TangentKind)
- , at = o.getTangents()
- , k = e.verticesCount
- , j = 12
- , $ = k * j
- , _e = _GLTFUtilities._CreateBufferView(0, s.getByteOffset(), $, j, o.name + "_NORMAL");
- this._bufferViews.push(_e);
- var et = this._bufferViews.length - 1
- , tt = _GLTFUtilities._CreateAccessor(et, o.name + " - TANGENT", "VEC3", 5126, k, 0, null, null);
- this._accessors.push(tt),
- d.TANGENT = this._accessors.length - 1,
- this.writeMorphTargetAttributeData(VertexBuffer.TangentKind, 5126, e, o, ot, at, j / 4, s, c)
- }
- i.targets.push(d)
- }
- }
- ,
- a.prototype.getMeshPrimitiveMode = function(e) {
- return e instanceof LinesMesh ? Material.LineListDrawMode : e.material ? e.material.fillMode : Material.TriangleFillMode
- }
- ,
- a.prototype.setPrimitiveMode = function(e, i) {
- switch (i) {
- case Material.TriangleFillMode:
- break;
- case Material.TriangleStripDrawMode:
- {
- e.mode = 5;
- break
- }
- case Material.TriangleFanDrawMode:
- {
- e.mode = 6;
- break
- }
- case Material.PointListDrawMode:
- e.mode = 0;
- case Material.PointFillMode:
- {
- e.mode = 0;
- break
- }
- case Material.LineLoopDrawMode:
- {
- e.mode = 2;
- break
- }
- case Material.LineListDrawMode:
- {
- e.mode = 1;
- break
- }
- case Material.LineStripDrawMode:
- {
- e.mode = 3;
- break
- }
- }
- }
- ,
- a.prototype.setAttributeKind = function(e, i) {
- switch (i) {
- case VertexBuffer.PositionKind:
- {
- e.attributes.POSITION = this._accessors.length - 1;
- break
- }
- case VertexBuffer.NormalKind:
- {
- e.attributes.NORMAL = this._accessors.length - 1;
- break
- }
- case VertexBuffer.ColorKind:
- {
- e.attributes.COLOR_0 = this._accessors.length - 1;
- break
- }
- case VertexBuffer.TangentKind:
- {
- e.attributes.TANGENT = this._accessors.length - 1;
- break
- }
- case VertexBuffer.UVKind:
- {
- e.attributes.TEXCOORD_0 = this._accessors.length - 1;
- break
- }
- case VertexBuffer.UV2Kind:
- {
- e.attributes.TEXCOORD_1 = this._accessors.length - 1;
- break
- }
- case VertexBuffer.MatricesIndicesKind:
- {
- e.attributes.JOINTS_0 = this._accessors.length - 1;
- break
- }
- case VertexBuffer.MatricesIndicesExtraKind:
- {
- e.attributes.JOINTS_1 = this._accessors.length - 1;
- break
- }
- case VertexBuffer.MatricesWeightsKind:
- {
- e.attributes.WEIGHTS_0 = this._accessors.length - 1;
- break
- }
- case VertexBuffer.MatricesWeightsExtraKind:
- {
- e.attributes.WEIGHTS_1 = this._accessors.length - 1;
- break
- }
- default:
- Tools.Warn("Unsupported Vertex Buffer Type: " + i)
- }
- }
- ,
- a.prototype.setPrimitiveAttributesAsync = function(e, i, o, s) {
- var c, d = [], _ = null, b, k;
- i instanceof Mesh ? _ = i : i instanceof InstancedMesh && (_ = i.sourceMesh);
- var j = [{
- kind: VertexBuffer.PositionKind,
- accessorType: "VEC3",
- accessorComponentType: 5126,
- byteStride: 12
- }, {
- kind: VertexBuffer.NormalKind,
- accessorType: "VEC3",
- accessorComponentType: 5126,
- byteStride: 12
- }, {
- kind: VertexBuffer.ColorKind,
- accessorType: "VEC4",
- accessorComponentType: 5126,
- byteStride: 16
- }, {
- kind: VertexBuffer.TangentKind,
- accessorType: "VEC4",
- accessorComponentType: 5126,
- byteStride: 16
- }, {
- kind: VertexBuffer.UVKind,
- accessorType: "VEC2",
- accessorComponentType: 5126,
- byteStride: 8
- }, {
- kind: VertexBuffer.UV2Kind,
- accessorType: "VEC2",
- accessorComponentType: 5126,
- byteStride: 8
- }, {
- kind: VertexBuffer.MatricesIndicesKind,
- accessorType: "VEC4",
- accessorComponentType: 5123,
- byteStride: 8
- }, {
- kind: VertexBuffer.MatricesIndicesExtraKind,
- accessorType: "VEC4",
- accessorComponentType: 5123,
- byteStride: 8
- }, {
- kind: VertexBuffer.MatricesWeightsKind,
- accessorType: "VEC4",
- accessorComponentType: 5126,
- byteStride: 16
- }, {
- kind: VertexBuffer.MatricesWeightsExtraKind,
- accessorType: "VEC4",
- accessorComponentType: 5126,
- byteStride: 16
- }];
- if (_) {
- for (var $ = null, _e = this.getMeshPrimitiveMode(_), et = {}, tt = _.morphTargetManager, rt = 0, it = j; rt < it.length; rt++) {
- var nt = it[rt]
- , ot = nt.kind
- , at = nt.accessorComponentType;
- if (_.isVerticesDataPresent(ot)) {
- var st = this.getVertexBufferFromMesh(ot, _);
- nt.byteStride = st ? st.getSize() * VertexBuffer.GetTypeByteLength(nt.accessorComponentType) : VertexBuffer.DeduceStride(ot) * 4,
- nt.byteStride === 12 && (nt.accessorType = "VEC3"),
- this.createBufferViewKind(ot, at, i, o, nt.byteStride, s),
- nt.bufferViewIndex = this._bufferViews.length - 1,
- et[ot] = nt.bufferViewIndex
- }
- }
- if (_.getTotalIndices()) {
- var ut = _.getIndices();
- if (ut) {
- var ct = ut.length * 4;
- b = _GLTFUtilities._CreateBufferView(0, o.getByteOffset(), ct, void 0, "Indices - " + _.name),
- this._bufferViews.push(b),
- $ = this._bufferViews.length - 1;
- for (var lt = 0, ft = ut.length; lt < ft; ++lt)
- o.setUInt32(ut[lt])
- }
- }
- if (_.subMeshes)
- for (var ht = 0, pt = _.subMeshes; ht < pt.length; ht++) {
- var dt = pt[ht]
- , _t = dt.getMaterial() || _.getScene().defaultMaterial
- , mt = null;
- if (_t)
- if (_ instanceof LinesMesh) {
- var vt = {
- name: _.name + " material"
- };
- (!_.color.equals(Color3.White()) || _.alpha < 1) && (vt.pbrMetallicRoughness = {
- baseColorFactor: _.color.asArray().concat([_.alpha])
- }),
- this._materials.push(vt),
- mt = this._materials.length - 1
- } else if (_t.getClassName() === "MultiMaterial") {
- var yt = _t.subMaterials[dt.materialIndex];
- yt && (_t = yt,
- mt = this._materialMap[_t.uniqueId])
- } else
- mt = this._materialMap[_t.uniqueId];
- var Et = mt != null ? this._materials[mt] : null
- , At = {
- attributes: {}
- };
- this.setPrimitiveMode(At, _e);
- for (var gt = 0, St = j; gt < St.length; gt++) {
- var nt = St[gt]
- , ot = nt.kind;
- if (!((ot === VertexBuffer.UVKind || ot === VertexBuffer.UV2Kind) && !this._options.exportUnusedUVs && Et && !this._glTFMaterialExporter._hasTexturesPresent(Et))) {
- var xt = _.getVerticesData(ot);
- if (xt) {
- var st = this.getVertexBufferFromMesh(ot, _);
- if (st) {
- var bt = st.getSize()
- , Rt = nt.bufferViewIndex;
- if (Rt != null) {
- k = {
- min: null,
- max: null
- },
- ot == VertexBuffer.PositionKind && (k = _GLTFUtilities._CalculateMinMaxPositions(xt, 0, xt.length / bt, s));
- var Mt = _GLTFUtilities._CreateAccessor(Rt, ot + " - " + i.name, nt.accessorType, nt.accessorComponentType, xt.length / bt, 0, k.min, k.max);
- this._accessors.push(Mt),
- this.setAttributeKind(At, ot)
- }
- }
- }
- }
- }
- if ($) {
- var Mt = _GLTFUtilities._CreateAccessor($, "indices - " + i.name, "SCALAR", 5125, dt.indexCount, dt.indexStart * 4, null, null);
- this._accessors.push(Mt),
- At.indices = this._accessors.length - 1
- }
- if (mt != null && Object.keys(At.attributes).length > 0) {
- var Pt = _.overrideMaterialSideOrientation !== null ? _.overrideMaterialSideOrientation : _t.sideOrientation;
- if (Pt == Material.ClockWiseSideOrientation && this._babylonScene.useRightHandedSystem || Pt == Material.ClockWiseSideOrientation && s && _.overrideMaterialSideOrientation !== ((c = _.material) === null || c === void 0 ? void 0 : c.sideOrientation)) {
- var It = $ != null ? this._bufferViews[$].byteOffset : null;
- It == null && (It = 0);
- var Dt = null;
- if ($ != null && (Dt = _.getIndices()),
- Dt)
- this.reorderIndicesBasedOnPrimitiveMode(dt, _e, Dt, It, o);
- else
- for (var Ct = 0, Ot = j; Ct < Ot.length; Ct++) {
- var nt = Ot[Ct]
- , xt = _.getVerticesData(nt.kind);
- if (xt) {
- var wt = this._bufferViews[et[nt.kind]].byteOffset;
- wt || (wt = 0),
- this.reorderVertexAttributeDataBasedOnPrimitiveMode(dt, _e, Pt, nt.kind, xt, wt, o, s)
- }
- }
- }
- At.material = mt
- }
- if (tt)
- for (var Nt = void 0, Ft = 0; Ft < tt.numTargets; ++Ft)
- Nt = tt.getTarget(Ft),
- this.setMorphTargetAttributes(dt, At, Nt, o, s);
- e.primitives.push(At),
- this._extensionsPostExportMeshPrimitiveAsync("postExport", At, dt, o),
- d.push()
- }
- }
- return Promise.all(d).then(function() {})
- }
- ,
- a.prototype.isBabylonCoordinateSystemConvertingNode = function(e) {
- if (e instanceof TransformNode) {
- if (e.name !== "__root__")
- return !1;
- 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++)
- if (Math.abs(s.m[d] - c.m[d]) > Epsilon)
- return !1;
- return !(e instanceof Mesh && e.geometry !== null || e instanceof InstancedMesh && e.sourceMesh.geometry !== null || this._includeCoordinateSystemConversionNodes)
- }
- return !1
- }
- ,
- a.prototype.createSceneAsync = function(e, i) {
- var o = this, s = {
- nodes: []
- }, c, d, _, b = __spreadArray(__spreadArray(__spreadArray([], e.transformNodes, !0), e.meshes, !0), e.lights, !0), k = [];
- return this._convertToRightHandedSystem = !e.useRightHandedSystem,
- this._convertToRightHandedSystemMap = {},
- e.rootNodes.forEach(function(j) {
- o._convertToRightHandedSystemMap[j.uniqueId] = o._convertToRightHandedSystem,
- j.getDescendants(!1).forEach(function($) {
- o._convertToRightHandedSystemMap[$.uniqueId] = o._convertToRightHandedSystem
- })
- }),
- e.rootNodes.forEach(function(j) {
- if (o.isBabylonCoordinateSystemConvertingNode(j)) {
- k.push(j);
- var $ = b.indexOf(j);
- $ !== -1 && b.splice($, 1),
- j.getDescendants(!1).forEach(function(_e) {
- o._convertToRightHandedSystemMap[_e.uniqueId] = !1
- })
- }
- }),
- this._glTFMaterialExporter._convertMaterialsToGLTFAsync(e.materials, "image/png", !0).then(function() {
- return o.createNodeMapAndAnimationsAsync(e, b, i).then(function(j) {
- return o.createSkinsAsync(e, j, i).then(function($) {
- if (o._nodeMap = j,
- o._totalByteLength = i.getByteOffset(),
- o._totalByteLength == null)
- throw new Error("undefined byte length!");
- for (var _e = 0, et = b; _e < et.length; _e++) {
- var tt = et[_e];
- if (c = o._nodeMap[tt.uniqueId],
- c !== void 0) {
- if (d = o._nodes[c],
- tt.metadata && (o._options.metadataSelector ? d.extras = o._options.metadataSelector(tt.metadata) : tt.metadata.gltf && (d.extras = tt.metadata.gltf.extras)),
- !tt.parent || k.indexOf(tt.parent) !== -1)
- if (o._options.shouldExportNode && !o._options.shouldExportNode(tt))
- Tools.Log("Omitting " + tt.name + " from scene.");
- else {
- var rt = o._convertToRightHandedSystemMap[tt.uniqueId];
- rt && (d.translation && (d.translation[2] *= -1,
- d.translation[0] *= -1),
- d.rotation = d.rotation ? Quaternion.FromArray([0, 1, 0, 0]).multiply(Quaternion.FromArray(d.rotation)).asArray() : Quaternion.FromArray([0, 1, 0, 0]).asArray()),
- s.nodes.push(c)
- }
- if (tt instanceof Mesh) {
- var it = tt;
- it.skeleton && (d.skin = $[it.skeleton.uniqueId])
- }
- if (_ = tt.getDescendants(!0),
- !d.children && _ && _.length) {
- for (var nt = [], ot = 0, at = _; ot < at.length; ot++) {
- var st = at[ot];
- o._nodeMap[st.uniqueId] != null && nt.push(o._nodeMap[st.uniqueId])
- }
- nt.length && (d.children = nt)
- }
- }
- }
- s.nodes.length && o._scenes.push(s)
- })
- })
- })
- }
- ,
- a.prototype.createNodeMapAndAnimationsAsync = function(e, i, o) {
- for (var s = this, c = Promise.resolve(), d = {}, _, b = {
- name: "runtime animations",
- channels: [],
- samplers: []
- }, k = [], j = function(rt) {
- !$._options.shouldExportNode || $._options.shouldExportNode(rt) ? c = c.then(function() {
- var it = s._convertToRightHandedSystemMap[rt.uniqueId];
- return s.createNodeAsync(rt, o, it, d).then(function(nt) {
- var ot = s._extensionsPostExportNodeAsync("createNodeAsync", nt, rt, d);
- return ot == null ? (Tools.Warn("Not exporting node " + rt.name),
- Promise.resolve()) : ot.then(function(at) {
- !at || (s._nodes.push(at),
- _ = s._nodes.length - 1,
- d[rt.uniqueId] = _,
- e.animationGroups.length || (_GLTFAnimation._CreateMorphTargetAnimationFromMorphTargetAnimations(rt, b, k, d, s._nodes, o, s._bufferViews, s._accessors, it, s._animationSampleRate),
- rt.animations.length && _GLTFAnimation._CreateNodeAnimationFromNodeAnimations(rt, b, k, d, s._nodes, o, s._bufferViews, s._accessors, it, s._animationSampleRate)))
- })
- })
- }) : "" + rt.name
- }, $ = this, _e = 0, et = i; _e < et.length; _e++) {
- var tt = et[_e];
- j(tt)
- }
- return c.then(function() {
- return b.channels.length && b.samplers.length && s._animations.push(b),
- k.forEach(function(rt) {
- rt.channels.length && rt.samplers.length && s._animations.push(rt)
- }),
- e.animationGroups.length && _GLTFAnimation._CreateNodeAndMorphAnimationFromAnimationGroups(e, s._animations, d, s._nodes, o, s._bufferViews, s._accessors, s._convertToRightHandedSystemMap, s._animationSampleRate),
- d
- })
- }
- ,
- a.prototype.createNodeAsync = function(e, i, o, s) {
- var c = this;
- return Promise.resolve().then(function() {
- var d = {}
- , _ = {
- primitives: []
- };
- if (e.name && (d.name = e.name),
- e instanceof TransformNode) {
- if (c.setNodeTransformation(d, e, o),
- e instanceof Mesh) {
- var b = e.morphTargetManager;
- if (b && b.numTargets > 0) {
- _.weights = [];
- for (var k = 0; k < b.numTargets; ++k)
- _.weights.push(b.getTarget(k).influence)
- }
- }
- return c.setPrimitiveAttributesAsync(_, e, i, o).then(function() {
- return _.primitives.length && (c._meshes.push(_),
- d.mesh = c._meshes.length - 1),
- d
- })
- } else
- return d
- })
- }
- ,
- a.prototype.createSkinsAsync = function(e, i, o) {
- for (var s, c = Promise.resolve(), d = {}, _ = 0, b = e.skeletons; _ < b.length; _++) {
- for (var k = b[_], j = {
- joints: []
- }, $ = [], _e = {}, et = -1, tt = 0; tt < k.bones.length; ++tt) {
- var rt = k.bones[tt]
- , it = (s = rt.getIndex()) !== null && s !== void 0 ? s : tt;
- it !== -1 && (_e[it] = rt,
- it > et && (et = it))
- }
- for (var it = 0; it <= et; ++it) {
- var rt = _e[it];
- $.push(rt.getInvertedAbsoluteTransform());
- var nt = rt.getTransformNode();
- nt ? j.joints.push(i[nt.uniqueId]) : Tools.Warn("Exporting a bone without a linked transform node is currently unsupported")
- }
- var ot = 64
- , at = $.length * ot
- , st = o.getByteOffset()
- , ut = _GLTFUtilities._CreateBufferView(0, st, at, void 0, "InverseBindMatrices - " + k.name);
- this._bufferViews.push(ut);
- var ct = this._bufferViews.length - 1
- , lt = _GLTFUtilities._CreateAccessor(ct, "InverseBindMatrices - " + k.name, "MAT4", 5126, $.length, null, null, null)
- , ft = this._accessors.push(lt) - 1;
- j.inverseBindMatrices = ft,
- this._skins.push(j),
- d[k.uniqueId] = this._skins.length - 1,
- $.forEach(function(ht) {
- ht.m.forEach(function(pt) {
- o.setFloat32(pt)
- })
- })
- }
- return c.then(function() {
- return d
- })
- }
- ,
- a._ExtensionNames = new Array,
- a._ExtensionFactories = {},
- a
- }()
- , _BinaryWriter = function() {
- function a(e) {
- this._arrayBuffer = new ArrayBuffer(e),
- this._dataView = new DataView(this._arrayBuffer),
- this._byteOffset = 0
- }
- return a.prototype.resizeBuffer = function(e) {
- for (var i = new ArrayBuffer(e), o = new Uint8Array(this._arrayBuffer), s = new Uint8Array(i), c = 0, d = s.byteLength; c < d; ++c)
- s[c] = o[c];
- return this._arrayBuffer = i,
- this._dataView = new DataView(this._arrayBuffer),
- i
- }
- ,
- a.prototype.getArrayBuffer = function() {
- return this.resizeBuffer(this.getByteOffset())
- }
- ,
- a.prototype.getByteOffset = function() {
- if (this._byteOffset == null)
- throw new Error("Byte offset is undefined!");
- return this._byteOffset
- }
- ,
- a.prototype.setUInt8 = function(e, i) {
- 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),
- this._dataView.setUint8(this._byteOffset, e),
- this._byteOffset += 1)
- }
- ,
- a.prototype.setUInt16 = function(e, i) {
- 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),
- this._dataView.setUint16(this._byteOffset, e, !0),
- this._byteOffset += 2)
- }
- ,
- a.prototype.getUInt32 = function(e) {
- if (e < this._byteOffset)
- return this._dataView.getUint32(e, !0);
- throw Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"),
- new Error("BinaryWriter: byteoffset is greater than the current binary buffer length!")
- }
- ,
- a.prototype.getVector3Float32FromRef = function(e, i) {
- i + 8 > this._byteOffset ? Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!") : (e.x = this._dataView.getFloat32(i, !0),
- e.y = this._dataView.getFloat32(i + 4, !0),
- e.z = this._dataView.getFloat32(i + 8, !0))
- }
- ,
- a.prototype.setVector3Float32FromRef = function(e, i) {
- i + 8 > this._byteOffset ? Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!") : (this._dataView.setFloat32(i, e.x, !0),
- this._dataView.setFloat32(i + 4, e.y, !0),
- this._dataView.setFloat32(i + 8, e.z, !0))
- }
- ,
- a.prototype.getVector4Float32FromRef = function(e, i) {
- i + 12 > this._byteOffset ? Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!") : (e.x = this._dataView.getFloat32(i, !0),
- e.y = this._dataView.getFloat32(i + 4, !0),
- e.z = this._dataView.getFloat32(i + 8, !0),
- e.w = this._dataView.getFloat32(i + 12, !0))
- }
- ,
- a.prototype.setVector4Float32FromRef = function(e, i) {
- i + 12 > this._byteOffset ? Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!") : (this._dataView.setFloat32(i, e.x, !0),
- this._dataView.setFloat32(i + 4, e.y, !0),
- this._dataView.setFloat32(i + 8, e.z, !0),
- this._dataView.setFloat32(i + 12, e.w, !0))
- }
- ,
- a.prototype.setFloat32 = function(e, i) {
- isNaN(e) && Tools.Error("Invalid data being written!"),
- i != null && (i < this._byteOffset ? this._dataView.setFloat32(i, e, !0) : Tools.Error("BinaryWriter: byteoffset is greater than the current binary length!")),
- this._byteOffset + 4 > this._arrayBuffer.byteLength && this.resizeBuffer(this._arrayBuffer.byteLength * 2),
- this._dataView.setFloat32(this._byteOffset, e, !0),
- this._byteOffset += 4
- }
- ,
- a.prototype.setUInt32 = function(e, i) {
- 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),
- this._dataView.setUint32(this._byteOffset, e, !0),
- this._byteOffset += 4)
- }
- ,
- a
- }()
- , name = "textureTransformPixelShader"
- , shader = `precision highp float;
- varying vec2 vUV;
- uniform sampler2D textureSampler;
- uniform mat4 textureTransformMat;
- void main(void) {
- vec2 uvTransformed=(textureTransformMat*vec4(vUV.xy,1,1)).xy;
- gl_FragColor=texture2D(textureSampler,uvTransformed);
- }`;
- ShaderStore.ShadersStore[name] = shader;
- var NAME$4 = "KHR_texture_transform"
- , KHR_texture_transform = function() {
- function a(e) {
- this._recordedTextures = [],
- this.name = NAME$4,
- this.enabled = !0,
- this.required = !1,
- this._wasUsed = !1
- }
- return a.prototype.dispose = function() {
- for (var e = 0, i = this._recordedTextures; e < i.length; e++) {
- var o = i[e];
- o.dispose()
- }
- }
- ,
- Object.defineProperty(a.prototype, "wasUsed", {
- get: function() {
- return this._wasUsed
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.postExportTexture = function(e, i, o) {
- var s = o && (o.uAng === 0 && o.wAng === 0 && o.vAng === 0 || o.uRotationCenter === 0 && o.vRotationCenter === 0);
- if (s) {
- var c = {}
- , d = !1;
- if ((o.uOffset !== 0 || o.vOffset !== 0) && (c.offset = [o.uOffset, o.vOffset],
- d = !0),
- (o.uScale !== 1 || o.vScale !== 1) && (c.scale = [o.uScale, o.vScale],
- d = !0),
- o.wAng !== 0 && (c.rotation = o.wAng,
- d = !0),
- o.coordinatesIndex !== 0 && (c.texCoord = o.coordinatesIndex,
- d = !0),
- !d)
- return;
- this._wasUsed = !0,
- i.extensions || (i.extensions = {}),
- i.extensions[NAME$4] = c
- }
- }
- ,
- a.prototype.preExportTextureAsync = function(e, i, o) {
- var s = this;
- return new Promise(function(c, d) {
- var _ = i.getScene();
- if (!_) {
- d(e + ': "scene" is not defined for Babylon texture ' + i.name + "!");
- return
- }
- var b = !1;
- if ((i.uAng !== 0 || i.wAng !== 0 || i.vAng !== 0) && (i.uRotationCenter !== 0 || i.vRotationCenter !== 0) && (b = !0),
- !b) {
- c(i);
- return
- }
- return s._textureTransformTextureAsync(i, _).then(function(k) {
- c(k)
- }).catch(function(k) {
- d(k)
- })
- }
- )
- }
- ,
- a.prototype._textureTransformTextureAsync = function(e, i) {
- var o = this;
- return new Promise(function(s) {
- var c = new ProceduralTexture("" + e.name,e.getSize(),"textureTransform",i);
- c || (Tools.Log("Cannot create procedural texture for " + e.name + "!"),
- s(e)),
- c.reservedDataStore = {
- hidden: !0,
- source: e
- },
- o._recordedTextures.push(c),
- c.coordinatesIndex = e.coordinatesIndex,
- c.setTexture("textureSampler", e),
- c.setMatrix("textureTransformMat", e.getTextureMatrix()),
- c.isReady() ? (c.render(),
- s(c)) : c.getEffect().executeWhenCompiled(function() {
- c.render(),
- s(c)
- })
- }
- )
- }
- ,
- a
- }();
- _Exporter.RegisterExtension(NAME$4, function(a) {
- return new KHR_texture_transform(a)
- });
- var NAME$3 = "KHR_lights_punctual"
- , KHR_lights_punctual = function() {
- function a(e) {
- this.name = NAME$3,
- this.enabled = !0,
- this.required = !1,
- this._exporter = e
- }
- return a.prototype.dispose = function() {
- this._lights = null
- }
- ,
- Object.defineProperty(a.prototype, "wasUsed", {
- get: function() {
- return !!this._lights
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.onExporting = function() {
- this._exporter._glTF.extensions[NAME$3] = this._lights
- }
- ,
- a.prototype.postExportNodeAsync = function(e, i, o, s) {
- var c = this;
- return new Promise(function(d, _) {
- if (i && o instanceof ShadowLight) {
- var b = o
- , k = void 0
- , j = b.getTypeID() == Light.LIGHTTYPEID_POINTLIGHT ? "point" : b.getTypeID() == Light.LIGHTTYPEID_DIRECTIONALLIGHT ? "directional" : b.getTypeID() == Light.LIGHTTYPEID_SPOTLIGHT ? "spot" : null;
- if (j == null)
- Logger$2.Warn(e + ": Light " + b.name + " is not supported in " + NAME$3);
- else {
- var $ = b.position.clone()
- , _e = c._exporter._convertToRightHandedSystemMap[o.uniqueId];
- if ($.equals(Vector3.Zero()) || (_e && _GLTFUtilities._GetRightHandedPositionVector3FromRef($),
- i.translation = $.asArray()),
- j !== "point") {
- var et = b.direction
- , tt = -Math.atan2(et.z * (c._exporter._babylonScene.useRightHandedSystem ? -1 : 1), et.x) + Math.PI / 2
- , rt = Math.sqrt(et.x * et.x + et.z * et.z)
- , it = -Math.atan2(et.y, rt)
- , nt = Quaternion.RotationYawPitchRoll(tt, it, 0);
- _e && _GLTFUtilities._GetRightHandedQuaternionFromRef(nt),
- nt.equals(Quaternion.Identity()) || (i.rotation = nt.asArray())
- }
- if (b.falloffType !== Light.FALLOFF_GLTF && Logger$2.Warn(e + ": Light falloff for " + b.name + " does not match the " + NAME$3 + " specification!"),
- k = {
- type: j
- },
- b.diffuse.equals(Color3.White()) || (k.color = b.diffuse.asArray()),
- b.intensity !== 1 && (k.intensity = b.intensity),
- b.range !== Number.MAX_VALUE && (k.range = b.range),
- j === "spot") {
- var ot = b;
- ot.angle !== Math.PI / 2 && (k.spot == null && (k.spot = {}),
- k.spot.outerConeAngle = ot.angle / 2),
- ot.innerAngle !== 0 && (k.spot == null && (k.spot = {}),
- k.spot.innerConeAngle = ot.innerAngle / 2)
- }
- c._lights == null && (c._lights = {
- lights: []
- }),
- c._lights.lights.push(k);
- var at = {
- light: c._lights.lights.length - 1
- }
- , st = o.parent;
- if (st && st.getChildren().length == 1) {
- var ut = c._exporter._nodes[s[st.uniqueId]];
- if (ut) {
- var ct = TmpVectors.Matrix[0]
- , lt = TmpVectors.Matrix[1]
- , ft = ut.translation ? new Vector3(ut.translation[0],ut.translation[1],ut.translation[2]) : Vector3.Zero()
- , ht = ut.rotation ? new Quaternion(ut.rotation[0],ut.rotation[1],ut.rotation[2],ut.rotation[3]) : Quaternion.Identity()
- , pt = ut.scale ? new Vector3(ut.scale[0],ut.scale[1],ut.scale[2]) : Vector3.One();
- Matrix.ComposeToRef(pt, ht, ft, ct),
- ct.invertToRef(lt);
- var dt = TmpVectors.Matrix[2]
- , _t = i.translation ? new Vector3(i.translation[0],i.translation[1],i.translation[2]) : Vector3.Zero();
- b instanceof DirectionalLight && _t.subtractInPlace(c._exporter._babylonScene.useRightHandedSystem ? b.direction : _GLTFUtilities._GetRightHandedPositionVector3(b.direction));
- var mt = c._exporter._babylonScene.useRightHandedSystem ? Quaternion.Identity() : new Quaternion(0,1,0,0);
- i.rotation && mt.multiplyInPlace(new Quaternion(i.rotation[0],i.rotation[1],i.rotation[2],i.rotation[3]));
- var vt = i.scale ? new Vector3(i.scale[0],i.scale[1],i.scale[2]) : Vector3.One();
- Matrix.ComposeToRef(vt, mt, _t, dt),
- dt.multiplyToRef(lt, dt);
- var yt = TmpVectors.Vector3[0]
- , Et = TmpVectors.Quaternion[0]
- , At = TmpVectors.Vector3[1];
- dt.decompose(yt, Et, At),
- ut.scale = yt.asArray(),
- ut.rotation = Et.asArray(),
- ut.translation = At.asArray(),
- ut.extensions == null && (ut.extensions = {}),
- ut.extensions[NAME$3] = at,
- d(null);
- return
- }
- }
- i.extensions == null && (i.extensions = {}),
- i.extensions[NAME$3] = at
- }
- }
- d(i)
- }
- )
- }
- ,
- a
- }();
- _Exporter.RegisterExtension(NAME$3, function(a) {
- return new KHR_lights_punctual(a)
- });
- var NAME$2 = "KHR_materials_clearcoat"
- , KHR_materials_clearcoat = function() {
- function a(e) {
- this.name = NAME$2,
- this.enabled = !0,
- this.required = !1,
- this._wasUsed = !1,
- this._exporter = e
- }
- return a.prototype.dispose = function() {}
- ,
- Object.defineProperty(a.prototype, "wasUsed", {
- get: function() {
- return this._wasUsed
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.postExportMaterialAdditionalTextures = function(e, i, o) {
- var s = [];
- return o instanceof PBRBaseMaterial && o.clearCoat.isEnabled ? (o.clearCoat.texture && s.push(o.clearCoat.texture),
- !o.clearCoat.useRoughnessFromMainTexture && o.clearCoat.textureRoughness && s.push(o.clearCoat.textureRoughness),
- o.clearCoat.bumpTexture && s.push(o.clearCoat.bumpTexture),
- s) : []
- }
- ,
- a.prototype.postExportMaterialAsync = function(e, i, o) {
- var s = this;
- return new Promise(function(c, d) {
- if (o instanceof PBRBaseMaterial) {
- if (!o.clearCoat.isEnabled) {
- c(i);
- return
- }
- s._wasUsed = !0,
- i.extensions = i.extensions || {};
- var _ = s._exporter._glTFMaterialExporter._getTextureInfo(o.clearCoat.texture)
- , b = void 0;
- o.clearCoat.useRoughnessFromMainTexture ? b = s._exporter._glTFMaterialExporter._getTextureInfo(o.clearCoat.texture) : b = s._exporter._glTFMaterialExporter._getTextureInfo(o.clearCoat.textureRoughness),
- o.clearCoat.isTintEnabled && Tools.Warn("Clear Color tint is not supported for glTF export. Ignoring for: " + o.name),
- o.clearCoat.remapF0OnInterfaceChange && Tools.Warn("Clear Color F0 remapping is not supported for glTF export. Ignoring for: " + o.name);
- var k = s._exporter._glTFMaterialExporter._getTextureInfo(o.clearCoat.bumpTexture)
- , j = {
- clearcoatFactor: o.clearCoat.intensity,
- clearcoatTexture: _ != null ? _ : void 0,
- clearcoatRoughnessFactor: o.clearCoat.roughness,
- clearcoatRoughnessTexture: b != null ? b : void 0,
- clearcoatNormalTexture: k != null ? k : void 0,
- hasTextures: function() {
- return j.clearcoatTexture !== null || j.clearcoatRoughnessTexture !== null || j.clearcoatRoughnessTexture !== null
- }
- };
- i.extensions[NAME$2] = j
- }
- c(i)
- }
- )
- }
- ,
- a
- }();
- _Exporter.RegisterExtension(NAME$2, function(a) {
- return new KHR_materials_clearcoat(a)
- });
- var NAME$1 = "KHR_materials_sheen"
- , KHR_materials_sheen = function() {
- function a(e) {
- this.name = NAME$1,
- this.enabled = !0,
- this.required = !1,
- this._wasUsed = !1,
- this._exporter = e
- }
- return a.prototype.dispose = function() {}
- ,
- Object.defineProperty(a.prototype, "wasUsed", {
- get: function() {
- return this._wasUsed
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.postExportMaterialAdditionalTextures = function(e, i, o) {
- return o instanceof PBRMaterial && o.sheen.isEnabled && o.sheen.texture ? [o.sheen.texture] : []
- }
- ,
- a.prototype.postExportMaterialAsync = function(e, i, o) {
- var s = this;
- return new Promise(function(c, d) {
- var _, b, k, j;
- if (o instanceof PBRMaterial) {
- if (!o.sheen.isEnabled) {
- c(i);
- return
- }
- s._wasUsed = !0,
- i.extensions == null && (i.extensions = {});
- var $ = {
- sheenColorFactor: o.sheen.color.asArray(),
- sheenRoughnessFactor: (_ = o.sheen.roughness) !== null && _ !== void 0 ? _ : 0,
- hasTextures: function() {
- return $.sheenColorTexture !== null || $.sheenRoughnessTexture !== null
- }
- };
- o.sheen.texture && ($.sheenColorTexture = (b = s._exporter._glTFMaterialExporter._getTextureInfo(o.sheen.texture)) !== null && b !== void 0 ? b : void 0),
- 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),
- i.extensions[NAME$1] = $
- }
- c(i)
- }
- )
- }
- ,
- a
- }();
- _Exporter.RegisterExtension(NAME$1, function(a) {
- return new KHR_materials_sheen(a)
- });
- var NAME = "KHR_materials_unlit"
- , KHR_materials_unlit = function() {
- function a(e) {
- this.name = NAME,
- this.enabled = !0,
- this.required = !1,
- this._wasUsed = !1
- }
- return Object.defineProperty(a.prototype, "wasUsed", {
- get: function() {
- return this._wasUsed
- },
- enumerable: !1,
- configurable: !0
- }),
- a.prototype.dispose = function() {}
- ,
- a.prototype.postExportMaterialAsync = function(e, i, o) {
- var s = this;
- return new Promise(function(c, d) {
- var _ = !1;
- o instanceof PBRMaterial ? _ = o.unlit : o instanceof StandardMaterial && (_ = o.disableLighting),
- _ && (s._wasUsed = !0,
- i.extensions == null && (i.extensions = {}),
- i.extensions[NAME] = {}),
- c(i)
- }
- )
- }
- ,
- a
- }();
- _Exporter.RegisterExtension(NAME, function(a) {
- return new KHR_materials_unlit(a)
- });
- new Logger$1("XPackage");
- function LoadXObject(a, e) {
- return new Promise((i,o)=>{
- const s = JSON.parse(e);
- new XArchive().deserialize(s, a).then(d=>{
- i(d)
- }
- ).catch(d=>{
- o(d)
- }
- )
- }
- )
- }
- const log$K = new Logger$1("AvatarManager");
- class XAvatarLoader {
- constructor() {
- this.containers = new Map,
- this.meshes = new Map,
- this.animations = new Map,
- this.aniPath = new Map,
- this.binPath = new Map,
- this.texPath = new Map,
- this.matPath = new Map,
- this.mshPath = new Map,
- this.rootPath = new Map,
- this.meshTexList = new Map,
- this._enableIdb = !0,
- this._mappings = new Map,
- this._sharedTex = new Map,
- this.avaliableAnimation = new Map,
- this.enableShareTexture = !0,
- this.enableShareAnimation = !0,
- this.fillEmptyLod = !0,
- this.pendantMap = new Map;
- const e = new GLTFFileLoader;
- SceneLoader.RegisterPlugin(e),
- e.preprocessUrlAsync = function(i) {
- const o = avatarLoader._mappings.get(i);
- return o ? Promise.resolve(o) : Promise.resolve(i)
- }
- }
- _parsePendant(e, i) {
- if (!e || !i) {
- log$K.error("[Engine] invalid id or url when loading pendant");
- return
- }
- const o = ".zip"
- , s = i.replace(o, "/");
- this.pendantMap.set(e, s)
- }
- pullAndLoadXObject(e, i) {
- const o = avatarLoader.pendantMap.get(i);
- return Tools.LoadFileAsync(o + `${i}.json`, !1).then(s=>{
- if (!(s instanceof ArrayBuffer))
- return LoadXObject(o, s).then(c=>c)
- }
- )
- }
- getParsedUrl(e, i, o, s="") {
- return new Promise((c,d)=>{
- if (!o || o.indexOf(".zip") === -1)
- return c(o);
- const _ = this.rootPath.get(o);
- if (_)
- return c(_);
- {
- const b = ".zip"
- , k = o.replace(b, "") + COMPONENT_LIST_PREFIX;
- e.urlTransformer(k, !0).then(j=>{
- if (!j)
- return d("Loading Failed");
- new Response(j).json().then($=>{
- var tt, rt, it, nt, ot, at, st;
- const _e = o.replace(b, "")
- , et = _e + ((tt = $ == null ? void 0 : $.components) == null ? void 0 : tt.url.replace("./", ""));
- if (this.rootPath.set(o, et),
- $.components ? ($.components.url && this.mshPath.set(i, _e + "/" + ((rt = $ == null ? void 0 : $.components) == null ? void 0 : rt.url.replace("./", ""))),
- $.components.url_lod2 && this.mshPath.set(i + "_" + avatarSetting.lod[1].level, _e + "/" + ((it = $ == null ? void 0 : $.components) == null ? void 0 : it.url_lod2.replace("./", ""))),
- $.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("./", ""))),
- $.meshes.url_lod2 && this.mshPath.set(i + "_" + avatarSetting.lod[1].level, _e + "/" + ((at = $ == null ? void 0 : $.meshes) == null ? void 0 : at.url_lod2.replace("./", ""))),
- $.meshes.url_lod4 && this.mshPath.set(i + "_" + avatarSetting.lod[2].level, _e + "/" + ((st = $ == null ? void 0 : $.meshes) == null ? void 0 : st.url_lod4.replace("./", "")))),
- $.materials && $.materials.forEach(ut=>{
- const ct = _e + "/" + ut.url;
- this.matPath.set(ut.name, ct)
- }
- ),
- $.bin) {
- const ut = _e + "/" + $.bin.url;
- this.binPath.set(i, ut);
- const ct = _e + "/" + $.bin.url_lod2;
- this.binPath.set(i + "_" + avatarSetting.lod[1].level, ct);
- const lt = _e + "/" + $.bin.url_lod4;
- this.binPath.set(i + "_" + avatarSetting.lod[2].level, lt)
- }
- return $.textures && $.textures.forEach(ut=>{
- const ct = _e + "/" + ut.url;
- this.texPath.set(ut.url, ct);
- const lt = this.meshTexList.get($.components.url);
- ut.type === "png" && (lt ? lt.find(ft=>ft === ut.name) || lt.push(ut.url) : this.meshTexList.set(i, [ut.name]))
- }
- ),
- c(et)
- }
- ).catch($=>{
- d(`[Engine] parse json file error,${$}`)
- }
- )
- }
- ).catch(j=>{
- d(`[Engine] ulrtransform error, cannot find resource in db,${j}`)
- }
- )
- }
- }
- )
- }
- async parse(e, i) {
- const o = [];
- i.forEach(s=>{
- this._setAnimationList(s.id, s.animations),
- o.push(this.getParsedUrl(e, s.id, s.url)),
- s.components.forEach(c=>{
- c.name === "pendant" ? c.units.forEach(d=>{
- this._parsePendant(d.id, d.url)
- }
- ) : c.units.forEach(d=>{
- o.push(this.getParsedUrl(e, d.name, d.url))
- }
- )
- }
- )
- }
- ),
- await Promise.all(o)
- }
- _setAnimationList(e, i) {
- i ? i.forEach(o=>{
- this.aniPath.set(e + "_" + o.name, o.url)
- }
- ) : log$K.error("[Engine] no animation list exist, please check config for details")
- }
- disposeContainer() {
- const e = [];
- this.containers.forEach((i,o)=>{
- if (i.xReferenceCount < 1) {
- if (this.enableShareTexture && i.textures.length > 0) {
- for (let s = 0; s < i.textures.length; ++s)
- i.textures[s].xReferenceCount != null ? i.textures[s].xReferenceCount-- : i.textures[s].xReferenceCount = 0,
- i.textures[s]._parentContainer = null;
- i.textures = []
- }
- e.push(o)
- }
- }
- ),
- e.forEach(i=>{
- var o, s;
- (o = this.containers.get(i)) == null || o.removeAllFromScene(),
- (s = this.containers.get(i)) == null || s.dispose(),
- this.containers.delete(i)
- }
- ),
- this._sharedTex.forEach((i,o)=>{
- i.xReferenceCount == 0 && (i.dispose(),
- this._sharedTex.delete(o))
- }
- )
- }
- set enableIdb(e) {
- this._enableIdb = e
- }
- getGlbPath(e) {
- return this.aniPath.get(e + ".glb")
- }
- getGltfPath(e) {
- return this.mshPath.get(e + ".gltf")
- }
- getPngUrl(e) {
- return this.texPath.get(e + ".png")
- }
- getMeshUrl(e) {
- return this.mshPath.get(e)
- }
- _getSourceKey(e, i) {
- return i && avatarSetting.lod[i] ? e + avatarSetting.lod[i].fileName.split(".")[0] : e
- }
- _getAnimPath(e, i) {
- let o = this.aniPath.get(i + "_animations_" + i.split("_")[1]);
- return o || (o = this.aniPath.get(i + "_" + e)),
- o
- }
- load(e, i, o, s) {
- return this.loadGlb(e, i, o).then(c=>c || Promise.reject("[Engine] container load failed")).catch(()=>Promise.reject("[Engine] container load failed"))
- }
- _searchAnimation(e, i) {
- let o;
- return this.containers.forEach((s,c)=>{
- const d = i.split("_")[0];
- c.indexOf(d) != -1 && c.indexOf(e) != -1 && (o = s)
- }
- ),
- o
- }
- loadAnimRes(e, i, o) {
- const s = this._getAnimPath(i, o)
- , c = getAnimationKey(i, o);
- 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),
- d.dispose(),
- Promise.reject("container does not contains animation data")) : d) : Promise.reject("no such url")
- }
- loadGlb(e, i, o) {
- let s = this.getMeshUrl(this._getSourceKey(i, o));
- return !s && this.fillEmptyLod && (o = 0,
- s = this.getMeshUrl(this._getSourceKey(i, o))),
- 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")
- }
- loadGltf(e, i, o, s) {
- const c = this._getSourceKey(i, o || 0);
- let d = this.getGltfPath(c);
- return !d && this.fillEmptyLod && (d = this.getGltfPath(i)),
- 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()
- }
- loadSubsequence() {}
- loadVAT() {}
- getResourceName(e) {
- return this.meshTexList.get(e)
- }
- _loadGltfFromUrl(e, i, o) {
- return SceneLoader.LoadAssetContainerAsync(o, i + ".gltf", e.Scene, null, ".gltf")
- }
- _loadGlbFromBlob(e, i, o) {
- return e.urlTransformer(o).then(s=>SceneLoader.LoadAssetContainerAsync("", s, e.Scene, null, ".glb").then(c=>{
- if (c) {
- if (this.containers.get(o))
- return c.dispose(),
- this.containers.get(o);
- if (c.addAllToScene(),
- this.enableShareTexture && c.textures.length > 0) {
- const d = [];
- let _ = !1;
- c.meshes.forEach(b=>{
- if (b.material) {
- const k = b.material._albedoTexture;
- if (k) {
- let j = k.name;
- j = j.replace(" (Base Color)", "").split(".")[0];
- const $ = this._sharedTex.get(j);
- $ ? (_ = !0,
- b.material._albedoTexture = $,
- d.push($),
- $._parentContainer = c,
- $.xReferenceCount++) : (this._sharedTex.set(j, k),
- c.textures[0].xReferenceCount = 1)
- }
- }
- }
- ),
- _ && (c.textures.forEach(b=>{
- e.Scene.removeTexture(b),
- b.dispose()
- }
- ),
- c.textures = d)
- }
- return c.xReferenceCount = 0,
- c.meshes.forEach(d=>{
- d.setEnabled(!1)
- }
- ),
- this.containers.set(o, c),
- Promise.resolve(c)
- } else
- return Promise.reject("glb file load failed")
- }
- ))
- }
- _loadGlbFromUrl(e, i, o) {
- return SceneLoader.LoadAssetContainerAsync("", o, e.Scene, null, ".glb").then(s=>s ? (s.addAllToScene(),
- s.meshes.forEach(c=>{
- c.setEnabled(!1)
- }
- ),
- this.enableShareTexture && s.textures.length > 0 ? (s.meshes.forEach(c=>{
- if (c.material) {
- const d = c.material._albedoTexture;
- if (d) {
- let _ = d.name;
- _ = _.replace(" (Base Color)", "").split(".")[0];
- const b = this._sharedTex.get(_);
- b ? (c.material._albedoTexture = b,
- b.xReferenceCount++) : (this._sharedTex.set(_, d),
- s.textures[0].xReferenceCount = 1)
- }
- }
- }
- ),
- s.xReferenceCount = 0,
- this.containers.set(o, s),
- Promise.resolve(s)) : Promise.reject("glb file load failed"),
- s.xReferenceCount = 0,
- this.containers.set(o, s),
- Promise.resolve(s)) : Promise.reject("glb file load failed"))
- }
- _loadGltfFromBlob(e, i, o, s) {
- return new Promise((c,d)=>{
- const _ = [];
- let b = this._getSourceKey(i, o)
- , k = this.getGltfPath(b);
- if (!k && this.fillEmptyLod && (o = 0,
- b = this._getSourceKey(i, o),
- k = this.getGltfPath(b)),
- !k)
- return d(`[Engine] gltf path incorrect ${b},cancel.`);
- const j = this.mshPath.get(b + ".gltf");
- if (!j)
- return d("cannot find asset mshPath");
- const $ = this.binPath.get(b + ".bin");
- if (!$)
- return d("cannot find asset binPath");
- if (!s) {
- const tt = this.meshTexList.get(i);
- if (!tt || tt.length == 0)
- return d("cannot find texture");
- s = tt[0]
- }
- const _e = this.texPath.get(s + ".png");
- if (!_e)
- return d();
- const et = this.texPath.get(s + "-astc.ktx");
- if (!et)
- return d();
- _.push(this._blobMapping(e, j)),
- _.push(this._blobMapping(e, $)),
- _.push(this._blobMapping(e, _e)),
- _.push(this._blobMapping(e, et)),
- Promise.all(_).then(()=>{
- const tt = k.replace(b + ".gltf", "");
- SceneLoader.LoadAssetContainerAsync(tt, b + ".gltf", e.Scene, null, ".gltf").then(rt=>{
- var nt;
- this.containers.set(k, rt),
- rt.addAllToScene(),
- rt.meshes.forEach(ot=>{
- ot.setEnabled(!1)
- }
- );
- const it = this._sharedTex.get(i);
- it ? ((nt = rt.meshes[1].material._albedoTexture) == null || nt.dispose(),
- rt.meshes[1].material._albedoTexture = it) : this._sharedTex.set(i, rt.meshes[1].material._albedoTexture),
- c(rt)
- }
- )
- }
- )
- }
- )
- }
- _blobMapping(e, i) {
- return new Promise((o,s)=>{
- e.urlTransformer(i).then(c=>c ? (this._mappings.set(i, c),
- o(i)) : s(`[Engine] url urlTransformer parse error ${i}`))
- }
- )
- }
- }
- const avatarLoader = new XAvatarLoader
- , log$J = new Logger$1("AnimationController");
- class XAnimationController {
- constructor(e) {
- this.iBodyAnim = void 0,
- this.animations = [],
- this.defaultAnimation = "Idle",
- this.onPlay = "Idle",
- this.loop = !0,
- this.animationExtras = [],
- this.enableBlend = !1,
- this.enableSkLod = !1,
- this._boneMap = new Map,
- this._lodMask = new Map,
- this.activeFaceAnimation = void 0,
- this.iFaceAnim = void 0,
- this.onPlayObservable = new Observable,
- this.playAnimation = (i,o,s=0,c,d,_)=>new Promise((b,k)=>{
- if (this._isPlaying(i, s) || (this._registerAnimInfo(i, o, s, c, d, _),
- !this._isAnimate()))
- return b(null);
- this._prerocess(i, o),
- this._avatar.avatarManager.loadAnimation(this._avatar.avatarType, i).then(j=>{
- if (!j)
- return k(new AvatarAnimationError("animation group does not exist"));
- const $ = this._mappingSkeleton(j);
- if (!$)
- return k(new AvatarAnimationError("mapping animation failed"));
- if ($ && this._isAnimationValid($))
- return $.dispose(),
- k(new AvatarAnimationError("mapping animation failed"));
- if (this.enableSkLod && this.skeletonMask($, s),
- this.detachAnimation(s),
- s == 0 ? this.iBodyAnim.animGroup = $ : s == 1 && (this.iFaceAnim.animGroup = $),
- !this._playAnimation(s))
- return k(new AvatarAnimationError("[Engine] play animation failed, animtion resource does not match current character"));
- this._playEffect(),
- this.postObserver = $.onAnimationEndObservable.addOnce(()=>(this._postprocess(s),
- b(null)))
- }
- )
- }
- ),
- this.stopAnimation = (i=0)=>{
- var o, s, c, d;
- switch (i) {
- case 0:
- this.iBodyAnim && this.iBodyAnim.animGroup && ((o = this.iBodyAnim) == null || o.animGroup.stop());
- break;
- case 1:
- this.iFaceAnim && this.iFaceAnim.animGroup && ((s = this.iFaceAnim) == null || s.animGroup.stop());
- break;
- case 2:
- this.iBodyAnim && this.iBodyAnim.animGroup && ((c = this.iBodyAnim) == null || c.animGroup.stop()),
- this.iFaceAnim && this.iFaceAnim.animGroup && ((d = this.iFaceAnim) == null || d.animGroup.stop());
- break
- }
- }
- ,
- this.pauseAnimation = (i=0)=>{
- var o, s, c, d;
- switch (i) {
- case 0:
- this.iBodyAnim && this.iBodyAnim.animGroup && ((o = this.iBodyAnim) == null || o.animGroup.pause());
- break;
- case 1:
- this.iFaceAnim && this.iFaceAnim.animGroup && ((s = this.iFaceAnim) == null || s.animGroup.pause());
- break;
- case 2:
- this.iBodyAnim && this.iBodyAnim.animGroup && ((c = this.iBodyAnim) == null || c.animGroup.pause()),
- this.iFaceAnim && this.iFaceAnim.animGroup && ((d = this.iFaceAnim) == null || d.animGroup.pause());
- break
- }
- }
- ,
- this.resetAnimation = (i=0)=>{
- var o, s, c, d;
- switch (i) {
- case 0:
- this.iBodyAnim && this.iBodyAnim.animGroup && ((o = this.iBodyAnim) == null || o.animGroup.reset());
- break;
- case 1:
- this.iFaceAnim && this.iFaceAnim.animGroup && ((s = this.iFaceAnim) == null || s.animGroup.reset());
- break;
- case 2:
- this.iBodyAnim && this.iBodyAnim.animGroup && ((c = this.iBodyAnim) == null || c.animGroup.reset()),
- this.iFaceAnim && this.iFaceAnim.animGroup && ((d = this.iFaceAnim) == null || d.animGroup.reset());
- break
- }
- }
- ,
- this._avatar = e,
- this._scene = e.avatarManager.scene,
- this.animationExtras.push(action.Cheering.animName),
- this._boneMap = new Map
- }
- _isPlaying(e, i) {
- 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)
- }
- activeAnimation(e=0) {
- var i, o;
- switch (e) {
- case 0:
- return (i = this.iBodyAnim) == null ? void 0 : i.animGroup;
- case 1:
- return (o = this.iFaceAnim) == null ? void 0 : o.animGroup;
- default:
- return
- }
- }
- enableAnimationBlend(e=.1, i=0) {
- var o, s, c, d;
- if (i == 0 && ((o = this.iBodyAnim) == null ? void 0 : o.animGroup))
- for (const _ of (s = this.iBodyAnim) == null ? void 0 : s.animGroup.targetedAnimations)
- _.animation.enableBlending = !0,
- _.animation.blendingSpeed = e;
- else if (i == 0 && ((c = this.iFaceAnim) == null ? void 0 : c.animGroup))
- for (const _ of (d = this.iFaceAnim) == null ? void 0 : d.animGroup.targetedAnimations)
- _.animation.enableBlending = !0,
- _.animation.blendingSpeed = e
- }
- disableAnimationBlend(e=0) {
- var i, o, s, c;
- if (e == 0 && ((i = this.iBodyAnim) == null ? void 0 : i.animGroup))
- for (const d of (o = this.iBodyAnim) == null ? void 0 : o.animGroup.targetedAnimations)
- d.animation.enableBlending = !1;
- else if (e == 0 && ((s = this.iFaceAnim) == null ? void 0 : s.animGroup))
- for (const d of (c = this.iFaceAnim) == null ? void 0 : c.animGroup.targetedAnimations)
- d.animation.enableBlending = !1
- }
- skeletonMask(e, i=0) {
- if (i == 0) {
- const o = this._lodMask.get(this._avatar.distLevel);
- if (o)
- for (let s = 0; s < e.targetedAnimations.length; ++s)
- o.includes(e.targetedAnimations[s].target.name) || (e.targetedAnimations.splice(s, 1),
- s--);
- return !0
- }
- return !1
- }
- detachAnimation(e=2) {
- var i, o;
- switch (e) {
- case 0:
- this.iBodyAnim && this.iBodyAnim.animGroup && (this.iBodyAnim.animGroup._parentContainer.xReferenceCount && this.iBodyAnim.animGroup._parentContainer.xReferenceCount--,
- this.iBodyAnim.animGroup.stop(),
- this.iBodyAnim.animGroup.dispose(),
- this.iBodyAnim.animGroup = void 0);
- break;
- case 1:
- this.iFaceAnim && this.iFaceAnim.animGroup && (this.iFaceAnim.animGroup._parentContainer.xReferenceCount && this.iFaceAnim.animGroup._parentContainer.xReferenceCount--,
- this.iFaceAnim.animGroup.stop(),
- this.iFaceAnim.animGroup.dispose(),
- this.iFaceAnim.animGroup = void 0);
- break;
- case 2:
- this.iBodyAnim && this.iBodyAnim.animGroup && (this.iBodyAnim.animGroup._parentContainer.xReferenceCount && this.iBodyAnim.animGroup._parentContainer.xReferenceCount--,
- (i = this.iBodyAnim) == null || i.animGroup.stop(),
- (o = this.iBodyAnim) == null || o.animGroup.dispose(),
- this.iBodyAnim.animGroup = void 0),
- this.iFaceAnim && this.iFaceAnim.animGroup && (this.iFaceAnim.animGroup._parentContainer.xReferenceCount && this.iFaceAnim.animGroup._parentContainer.xReferenceCount--,
- this.iFaceAnim.animGroup.stop(),
- this.iFaceAnim.animGroup.dispose(),
- this.iFaceAnim.animGroup = void 0);
- break
- }
- }
- blendAnimation() {}
- getAnimation(e, i) {
- return avatarLoader.animations.get(getAnimationKey(i, e))
- }
- _mappingSkeleton(e) {
- if (e) {
- const i = e.clone(e.name, o=>{
- var c, d, _;
- const s = o.name.split(" ").length > 2 ? o.name.split(" ")[2] : o.name;
- if (this._boneMap.size === ((c = this._avatar.skeleton) == null ? void 0 : c.bones.length))
- return this._boneMap.get(s);
- {
- 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();
- return b && (b.name = s,
- this._boneMap.set(s, b)),
- b
- }
- }
- );
- return i._parentContainer = e._parentContainer,
- i
- } else
- return
- }
- removeAnimation(e) {
- const i = avatarLoader.containers.get(e.name);
- i && (i.dispose(),
- avatarLoader.containers.delete(e.name),
- avatarLoader.animations.delete(getAnimationKey(e.name, e.skType)))
- }
- _setPosition(e, i) {
- this._avatar.priority === 0 && this._avatar.isRender && e === this.defaultAnimation && e != this.onPlay && !this._avatar.isSelected && this._avatar.setPosition(this._avatar.position, !0)
- }
- _registerAnimInfo(e, i, o=0, s, c, d) {
- const _ = {
- name: e,
- skType: this._avatar.avatarType,
- loop: i,
- playSpeed: s,
- currentFrame: 0,
- startFrame: c,
- endFrame: d
- };
- o == 0 ? this.iBodyAnim == null ? this.iBodyAnim = _ : (this.iBodyAnim.name = e,
- this.iBodyAnim.skType = this._avatar.avatarType,
- this.iBodyAnim.loop = i,
- this.iBodyAnim.playSpeed = s,
- this.iBodyAnim.currentFrame = 0,
- this.iBodyAnim.startFrame = c,
- this.iBodyAnim.endFrame = d) : o == 1 && (this.iFaceAnim == null ? this.iFaceAnim = _ : (this.iFaceAnim.name = e,
- this.iFaceAnim.skType = this._avatar.avatarType,
- this.iFaceAnim.loop = i,
- this.iFaceAnim.playSpeed = s,
- this.iFaceAnim.currentFrame = 0,
- this.iFaceAnim.startFrame = c,
- this.iFaceAnim.endFrame = d)),
- this.onPlay = e,
- this.loop = i
- }
- _isAnimate() {
- var e;
- return !(!this._avatar.isRender || !this._avatar.skeleton || ((e = this._avatar.rootNode) == null ? void 0 : e.getChildMeshes().length) == 0)
- }
- _prerocess(e, i) {
- this._avatar.isRayCastEnable && this._setPosition(e, i),
- this._avatar.priority === 0 && log$J.info(`start play animation: ${e} on avatar ${this._avatar.id}`)
- }
- _playEffect() {
- this.animationExtras.indexOf(this.iBodyAnim.name) != -1 && action.Cheering.attachPair.forEach(i=>{
- 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)),
- this._avatar.showExtra(i.obj)
- }
- )
- }
- _playAnimation(e=0) {
- var i, o;
- return e == 0 && this.iBodyAnim && ((i = this.iBodyAnim) == null ? void 0 : i.animGroup) ? (this.onPlayObservable.notifyObservers(this._scene),
- this.iBodyAnim.animGroup.start(this.loop, this.iBodyAnim.playSpeed, this.iBodyAnim.startFrame, this.iBodyAnim.endFrame, !1),
- !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),
- !0) : !1
- }
- _postprocess(e) {
- var o, s;
- let i;
- e == 0 ? i = (o = this.iBodyAnim) == null ? void 0 : o.name : e == 1 && (i = (s = this.iFaceAnim) == null ? void 0 : s.name),
- i === action.Cheering.animName && this._avatar.disposeExtra()
- }
- _isAnimationValid(e) {
- for (let i = 0; i < e.targetedAnimations.length; ++i)
- if (e.targetedAnimations[i].target)
- return !1;
- return !0
- }
- }
- const log$I = new Logger$1("XAvatarComopnent");
- class XAvatarComopnent {
- constructor() {
- this.resourceIdList = [],
- this.skeleton = void 0,
- this.extraProp = void 0,
- this.extras = [],
- this.body = void 0,
- this.accessories = new Map
- }
- addBodyComp(e, i) {
- return !e.rootNode || i.root.getChildMeshes().length === 0 ? (i.isRender = !1,
- !1) : (this.body = i,
- this.body.root.parent = e.rootNode,
- i.isRender = !0,
- this.body.root.getChildMeshes()[0] && (this.body.root.getChildMeshes()[0].xtype = EMeshType.XAvatar,
- this.body.root.getChildMeshes()[0].xid = e.id),
- this.skeleton = i.skeleton,
- !0)
- }
- addClothesComp(e, i) {
- return !e.rootNode || !this.skeleton || !i.root ? (i.isRender = !1,
- !1) : (i.root.xtype = EMeshType.XAvatar,
- i.root.xid = e.id,
- i.isRender = !0,
- i.root.parent = e.rootNode.getChildMeshes()[0],
- this.resourceIdList.push(i),
- i.root.skeleton = this.skeleton,
- i.root.getChildMeshes().forEach(o=>{
- o.skeleton = this.skeleton
- }
- ),
- !0)
- }
- clearClothesComp(e) {
- e.root.getChildMeshes().forEach(i=>{
- i.skeleton = null,
- i.dispose(),
- i.xid = void 0
- }
- ),
- e.root.dispose(),
- this.resourceIdList = this.resourceIdList.filter(i=>i.uId != e.uId)
- }
- clearAllClothesComps() {
- this.resourceIdList.forEach(e=>{
- var i;
- e.root.parent = null,
- e.root._parentContainer.xReferenceCount && (e.root._parentContainer.xReferenceCount--,
- e.root._parentContainer = null),
- e.isRender = !1,
- e.isSelected = !1,
- e.root.getChildMeshes().forEach(o=>{
- o.skeleton = null,
- o.dispose()
- }
- ),
- (i = e.root.skeleton) == null || i.dispose(),
- e.root.dispose()
- }
- ),
- this.resourceIdList = []
- }
- dispose(e) {
- this.body ? (this.body.root._parentContainer.xReferenceCount && (this.body.root._parentContainer.xReferenceCount--,
- this.body.root._parentContainer = null),
- this.clearAllClothesComps(),
- this.body.isRender = !1,
- this.body.skeleton.dispose(),
- this.body.skeleton = null,
- this.body.root.dispose(),
- this.body = void 0,
- this.skeleton && (this.skeleton.dispose(),
- this.skeleton = void 0)) : log$I.warn("[Engine] no body to dispose")
- }
- async attachPendant(e, i) {
- return Promise.resolve(avatarLoader.pullAndLoadXObject(e.avatarManager.sceneManager, i).then(o=>{
- const s = o
- , c = this.accessories.get(s.pointId);
- return c ? (c.dispose(),
- this.accessories.set(s.pointId, s),
- 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),
- s.attachTo(e),
- s
- }
- ))
- }
- detachPendant(e, i=!0) {
- const o = this.accessories.get(e);
- o && (o.dispose(),
- this.accessories.delete(e))
- }
- changeClothesComp(e, i, o, s, c) {
- return new Promise(d=>{
- if (this.resourceIdList.some(_=>_.name === i))
- return d();
- if (e.isHide || !e.isRender)
- c.concat(o).forEach(b=>{
- e.clothesList = e.clothesList.filter(j=>j.type != b);
- const k = {
- type: o,
- id: i,
- url: s,
- lod: 0
- };
- e.clothesList.push(k)
- }
- ),
- d();
- else {
- const _ = c.concat(o);
- e.avatarManager.loadDecoration(o, i, 0).then(b=>{
- if (b) {
- e.attachDecoration(b);
- const k = {
- type: o,
- id: i,
- url: s
- };
- e.clothesList.push(k),
- b.root.setEnabled(!0),
- _.forEach(j=>{
- const $ = this.resourceIdList.filter(_e=>_e.type === j);
- if ($.length > 1) {
- const _e = $.filter(et=>et.name === i);
- if (_e.length > 1)
- for (let et = 1; et < _e.length; ++et) {
- e.detachDecoration(_e[et]),
- e.clothesList = e.clothesList.filter(rt=>rt.id != _e[et].name);
- const tt = {
- type: o,
- id: i,
- url: s
- };
- e.clothesList.push(tt)
- }
- }
- $[0] && $[0].name != i && this._readyToDetach(e, o) && (e.detachDecoration($[0]),
- e.clothesList = e.clothesList.filter(_e=>_e.id != $[0].name))
- }
- )
- }
- return d()
- }
- )
- }
- }
- )
- }
- _readyToDetach(e, i) {
- 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")))
- }
- addDecoComp(e, i, o, s, c) {
- if (e.isRender) {
- const d = e.avatarManager.extraComps.get(i)
- , _ = d == null ? void 0 : d.clone(i, void 0);
- if (!d) {
- log$I.error("\u6CA1\u6709\u5BF9\u5E94\u7684\u7EC4\u4EF6");
- return
- }
- this.extras.push(_);
- const b = this.skeleton.bones.find(k=>k.name === o);
- _.position = s,
- _.rotation = c,
- _.attachToBone(b, e.rootNode.getChildMeshes()[0])
- }
- }
- showExtra(e) {
- this.extras.forEach(i=>{
- i.name.indexOf(e) > 0 && i.setEnabled(!0)
- }
- )
- }
- hideExtra(e) {
- this.extras.forEach(i=>{
- i.name.indexOf(e) > 0 && i.setEnabled(!1)
- }
- )
- }
- disposeExtra() {
- this.extras.forEach(e=>{
- e.dispose()
- }
- ),
- this.extras = []
- }
- }
- function LinearBezierCurves(a, e, i) {
- return Vector3.Lerp(e, i, 1 - a)
- }
- function QuadraticBezierCurves(a, e, i, o) {
- let s = LinearBezierCurves(a, e, i)
- , c = LinearBezierCurves(a, i, o);
- return LinearBezierCurves(a, s, c)
- }
- function CubicBezierCurves(a, e, i, o, s) {
- let c = QuadraticBezierCurves(a, e, i, o)
- , d = QuadraticBezierCurves(a, i, o, s);
- return LinearBezierCurves(a, c, d)
- }
- function CardinalMultiply(a, e, i, o, s, c) {
- var d, _, b, k;
- return d = a[0] * e + a[1] * i + a[2] * o + a[3] * s,
- _ = a[4] * e + a[5] * i + a[6] * o + a[7] * s,
- b = a[8] * e + a[9] * i + a[10] * o + a[11] * s,
- k = a[12] * e + a[13] * i + a[14] * o + a[15] * s,
- k + c * (b + c * (_ + c * d))
- }
- function CardinalCurves(a, e, i, o, s, c) {
- let d = new Array(16)
- , _ = c;
- return d[0] = -_,
- d[1] = 2 - _,
- d[2] = _ - 2,
- d[3] = _,
- d[4] = 2 * _,
- d[5] = _ - 3,
- d[8] = -_,
- d[9] = 0,
- d[12] = 0,
- d[13] = 1,
- d[6] = 3 - 2 * _,
- d[7] = -_,
- d[10] = _,
- d[11] = 0,
- d[14] = 0,
- d[15] = 0,
- 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))
- }
- function HermiteCurves(a, e, i, o, s) {
- let c = Math.pow(a, 3)
- , d = Math.pow(a, 2)
- , _ = 2 * c - 3 * d + 1
- , b = -2 * c + 3 * d
- , k = c - 2 * d + a
- , j = c - d
- , $ = e.multiplyByFloats(_, _, _)
- , _e = i.multiplyByFloats(b, b, b)
- , et = o.multiplyByFloats(k, k, k)
- , tt = s.multiplyByFloats(j, j, j);
- return $.add(_e.add(et).add(tt))
- }
- const log$H = new Logger$1("XStateMachine");
- class XStateMachine {
- constructor(e) {
- this._observer = void 0,
- this._movingObserver = void 0,
- this._scene = e
- }
- rotateTo(e, i, o, s) {
- return new Promise((c,d)=>{
- var $;
- const _ = e.avatarManager.scene;
- if (o && e.setRotation(o),
- i == o)
- return c();
- e.priority === 0 && log$H.info(`avatar ${e.id} starts to rotate from ${o} to ${i}`);
- let b = 0;
- const k = 1e3 / 25
- , j = calcDistance3DAngle(i, e.rotation) / k;
- this._movingObserver && _.onBeforeRenderObservable.remove(this._movingObserver),
- ($ = e.controller) == null || $.playAnimation(s || "Walking", !0),
- this._movingObserver = _ == null ? void 0 : _.onBeforeRenderObservable.add(()=>{
- var _e;
- if (b < 1) {
- if (!e.rootNode)
- return e.setRotation(i),
- c();
- const et = Vector3.Lerp(e.rootNode.rotation, ue4Rotation2Xverse(i), b);
- e.setRotation(xverseRotation2Ue4(et)),
- b += k / (j * 1e3)
- } else
- return _.onBeforeRenderObservable.remove(this._movingObserver),
- (_e = e.controller) == null || _e.playAnimation("Idle", !0),
- c()
- }
- )
- }
- )
- }
- _filterPathPoint(e) {
- let i = 0;
- const o = 1e-4;
- if (e.length <= 1)
- return e;
- for (; i < e.length - 1; )
- calcDistance3D(e[i], e[i + 1]) < o ? e.splice(i, 1) : i++;
- return e
- }
- moveToHermite(e, i, o, s, c, d, _) {
- return new Promise((b,k)=>{
- var ot;
- const j = e.avatarManager.scene;
- e.priority === 0 && log$H.info(`avatar ${e.id} starts to move from ${i} to ${o}`);
- let$ = 0;
- 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();
- it.x = -it.x,
- it.z = -it.z;
- const nt = 1e3 / 25;
- this._movingObserver && j.onBeforeRenderObservable.remove(this._movingObserver),
- (ot = e.controller) == null || ot.playAnimation(d, !0),
- this._movingObserver = j == null ? void 0 : j.onBeforeRenderObservable.add(()=>{
- var st;
- et = HermiteCurves($, ue4Position2Xverse(i), ue4Position2Xverse(o), rt, it),
- e.rootNode.lookAt(et);
- const at = xverseRotation2Ue4({
- x: e.rootNode.rotation.x,
- y: e.rootNode.rotation.y,
- z: e.rootNode.rotation.z
- });
- if (at && (at.roll = 0,
- at.pitch = 0,
- e.setRotation(at)),
- $ <= 1) {
- if (e.setPosition(xversePosition2Ue4(_e), _),
- !e.rootNode)
- return e.setPosition(o, _),
- b();
- $ += nt / s,
- _e = et.clone()
- } else
- return e.setPosition(o, _),
- j.onBeforeRenderObservable.remove(this._movingObserver),
- (st = e.controller) == null || st.playAnimation("Idle", !0),
- b()
- }
- )
- }
- )
- }
- moveToCardinal(e, i, o, s, c, d, _, b) {
- return new Promise((k,j)=>{
- var ot;
- const $ = e.avatarManager.scene;
- e.priority === 0 && log$H.info(`avatar ${e.id} starts to move from ${i} to ${o}`);
- let _e = 0
- , et = ue4Position2Xverse(d[0])
- , tt = ue4Position2Xverse(d[1]);
- var rt = ue4Position2Xverse(i), it;
- const nt = 1e3 / 25;
- this._movingObserver && $.onBeforeRenderObservable.remove(this._movingObserver),
- (ot = e.controller) == null || ot.playAnimation(c, !0),
- this._movingObserver = $ == null ? void 0 : $.onBeforeRenderObservable.add(()=>{
- var st;
- it = CardinalCurves(_e, ue4Position2Xverse(i), et, tt, ue4Position2Xverse(o), _),
- e.rootNode.lookAt(it);
- const at = xverseRotation2Ue4({
- x: e.rootNode.rotation.x,
- y: e.rootNode.rotation.y,
- z: e.rootNode.rotation.z
- });
- if (at && (at.roll = 0,
- at.pitch = 0,
- e.setRotation(at)),
- _e <= 1) {
- if (e.setPosition(xversePosition2Ue4(rt), b),
- !e.rootNode)
- return e.setPosition(o, b),
- k();
- _e += nt / s,
- rt = it.clone()
- } else
- return e.setPosition(o, b),
- $.onBeforeRenderObservable.remove(this._movingObserver),
- (st = e.controller) == null || st.playAnimation("Idle", !0),
- k()
- }
- )
- }
- )
- }
- moveToBezier(e, i, o, s, c) {
- return new Promise((d,_)=>{
- var tt;
- i.length < 2 && _("[Engine input Bezier control points error]");
- const b = e.avatarManager.scene;
- e.priority === 0 && log$H.info(`avatar ${e.id} starts to move in Bezier Curve, from ${i[0]} to ${i[i.length - 1]}`);
- let k = 0
- , j = new Array;
- i.forEach(rt=>{
- j.push(ue4Position2Xverse(rt))
- }
- );
- var $ = j[0], _e;
- const et = 1e3 / 25;
- this._movingObserver && b.onBeforeRenderObservable.remove(this._movingObserver),
- (tt = e.controller) == null || tt.playAnimation(s, !0),
- this._movingObserver = b == null ? void 0 : b.onBeforeRenderObservable.add(()=>{
- var rt;
- switch (i.length) {
- case 2:
- _e = LinearBezierCurves(k, j[0], j[1]);
- break;
- case 3:
- _e = QuadraticBezierCurves(k, j[0], j[1], j[2]);
- break;
- case 4:
- _e = CubicBezierCurves(k, j[0], j[1], j[2], j[3]);
- break
- }
- if (k != 0) {
- e.rootNode.lookAt(_e);
- const it = xverseRotation2Ue4({
- x: e.rootNode.rotation.x,
- y: e.rootNode.rotation.y,
- z: e.rootNode.rotation.z
- });
- it && (it.roll = 0,
- it.pitch = 0,
- e.setRotation(it))
- }
- if (k < 1) {
- if (e.setPosition(xversePosition2Ue4($), c),
- !e.rootNode)
- return e.setPosition(j[j.length - 1], c),
- d();
- k += et / o,
- $ = _e.clone()
- } else
- return b.onBeforeRenderObservable.remove(this._movingObserver),
- (rt = e.controller) == null || rt.playAnimation("Idle", !0),
- d()
- }
- )
- }
- )
- }
- moveTo(e, i, o, s, c, d, _) {
- return new Promise((b,k)=>{
- var nt;
- const j = e.avatarManager.scene;
- e.priority === 0 && log$H.info(`avatar ${e.id} starts to move from ${i} to ${o}`);
- let$ = 0;
- d ? d = d.concat(o) : d = [o],
- d = this._filterPathPoint(d);
- let _e = i
- , et = d.shift();
- if (!et)
- return k("[Engine input path error]");
- let tt = calcDistance3D(_e, et) / s;
- const rt = 1e3 / 25;
- e.rootNode.lookAt(ue4Position2Xverse(et));
- const it = xverseRotation2Ue4({
- x: e.rootNode.rotation.x,
- y: e.rootNode.rotation.y,
- z: e.rootNode.rotation.z
- });
- it && (it.roll = 0,
- it.pitch = 0,
- e.setRotation(it)),
- this._movingObserver && j.onBeforeRenderObservable.remove(this._movingObserver),
- (nt = e.controller) == null || nt.playAnimation(c, !0),
- this._movingObserver = j == null ? void 0 : j.onBeforeRenderObservable.add(()=>{
- var ot;
- if ($ < 1) {
- const at = Vector3.Lerp(ue4Position2Xverse(_e), ue4Position2Xverse(et), $);
- if (e.setPosition(xversePosition2Ue4(at), _),
- !e.rootNode)
- return e.setPosition(o, _),
- b();
- $ += rt / (tt * 1e3)
- } else if (_e = et,
- et = d.shift(),
- et) {
- tt = calcDistance3D(_e, et) / s,
- e.rootNode.lookAt(ue4Position2Xverse(et));
- const at = xverseRotation2Ue4({
- x: e.rootNode.rotation.x,
- y: e.rootNode.rotation.y,
- z: e.rootNode.rotation.z
- });
- at && (at.roll = 0,
- at.pitch = 0,
- e.setRotation(at)),
- $ = 0
- } else
- return j.onBeforeRenderObservable.remove(this._movingObserver),
- (ot = e.controller) == null || ot.playAnimation("Idle", !0),
- b()
- }
- )
- }
- )
- }
- lookAt(e, i, o) {
- return new Promise(s=>{
- var et, tt;
- const c = ue4Position2Xverse(i)
- , d = 1e-4;
- if (calcDistance3D(e.position, i) <= d)
- return s();
- const _ = new Vector3(e.rootNode.rotation.x % (Math.PI * 2),e.rootNode.rotation.y % (Math.PI * 2),e.rootNode.rotation.z % (Math.PI * 2));
- (et = e.rootNode) == null || et.lookAt(c);
- 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));
- if (e.rootNode.rotation = _,
- b.y - _.y > Math.PI && (b.y -= 2 * Math.PI),
- b.y - _.y < -Math.PI && (b.y += 2 * Math.PI),
- e.rootNode && Math.abs(_.x / _.z - b.x / b.z) <= d)
- return s();
- let k = 0;
- const j = o || 1 / 100
- , $ = (tt = e.rootNode) == null ? void 0 : tt.getScene()
- , _e = $ == null ? void 0 : $.onBeforeRenderObservable.add(()=>{
- var nt;
- const rt = (nt = e.controller) == null ? void 0 : nt.animations.find(ot=>ot.name == "Idle");
- (rt == null ? void 0 : rt.isPlaying) != !0 && (rt == null || rt.play());
- const it = Vector3.Lerp(_, b, k);
- if (k < 1) {
- const ot = xverseRotation2Ue4({
- x: it.x,
- y: it.y - Math.PI,
- z: it.z
- });
- ot && (ot.roll = 0,
- ot.pitch = 0,
- e.setRotation(ot)),
- k += j
- } else
- _e && $.onBeforeRenderObservable.remove(_e),
- s()
- }
- )
- }
- )
- }
- sendObjectTo(e, i, o, s=2, c=10, d={
- x: 0,
- y: 0,
- z: 150
- }) {
- return new Promise((_,b)=>{
- var k;
- if (!o.loaded)
- b("Gift has not inited!");
- else {
- const j = (k = e.rootNode) == null ? void 0 : k.getScene();
- let$ = 0;
- const _e = 1 / (s * 25)
- , et = _e
- , tt = c / 100
- , rt = 8 * tt * _e * _e;
- let it = .5 * rt / _e
- , nt = ue4Position2Xverse(e.position);
- const ot = ue4Position2Xverse(d)
- , at = ue4Position2Xverse(e.position)
- , st = j == null ? void 0 : j.onBeforeRenderObservable.add(()=>{
- (!i || !e.position || !i.position) && (st && j.onBeforeRenderObservable.remove(st),
- b("Invalid receiver when shoot gift!")),
- o.loaded || (st && j.onBeforeRenderObservable.remove(st),
- _());
- const ut = ue4Position2Xverse(i.position)
- , ct = new Vector3((ut.x - at.x) * _e,it,(ut.z - at.z) * _e);
- it = it - rt,
- $ < 1 ? (nt = nt.add(ct),
- o.setPositionVector(nt.add(ot)),
- $ += et) : (_(),
- st && j.onBeforeRenderObservable.remove(st))
- }
- )
- }
- }
- )
- }
- roll(e, i, o, s) {
- var c, d;
- this._observer && ((c = this._scene) == null || c.onBeforeRenderObservable.remove(this._observer)),
- i && (o = o != null ? o : 1,
- s = s != null ? s : 1,
- this._observer = (d = this._scene) == null ? void 0 : d.onBeforeRenderObservable.add(()=>{
- e.rootNode.rotation.y += o * .1 * s,
- e.rootNode.rotation.y %= Math.PI * 2
- }
- ))
- }
- disposeObsever() {
- this._movingObserver && this._scene.onBeforeRenderObservable.remove(this._movingObserver)
- }
- }
- class PoolObject {
- constructor(e, i, o, s=!0) {
- this.data = e,
- this.nextFree = i,
- this.previousFree = o,
- this.free = s
- }
- dispose() {
- this.data && this.data instanceof Mesh && this.data.dispose(!0, !0),
- this.previousFree = null,
- this.nextFree = null,
- this.data = null
- }
- }
- class Pool {
- constructor(e, i, o, s, ...c) {
- this._pool = [],
- this.objCreator = e,
- this.objReseter = i;
- for (let d = 0; d < s; d++)
- this.addNewObject(this.newPoolObject(...c));
- this.capacity = o
- }
- addNewObject(e) {
- return this._pool.push(e),
- this.release(e),
- e
- }
- release(e) {
- e.free = !0,
- e.nextFree = null,
- e.previousFree = this.lastFree,
- this.lastFree ? this.lastFree.nextFree = e : this.nextFree = e,
- this.lastFree = e,
- this.objReseter(e)
- }
- getFree(...e) {
- const i = this.nextFree ? this.nextFree : this.addNewObject(this.newPoolObject(...e));
- return i.free = !1,
- this.nextFree = i.nextFree,
- this.nextFree || (this.lastFree = null),
- i
- }
- newPoolObject(...e) {
- const i = this.objCreator(...e);
- return new PoolObject(i,this.nextFree,this.lastFree)
- }
- releaseAll() {
- this._pool.forEach(e=>this.release(e))
- }
- clean(e=0, ...i) {
- let o = this.nextFree;
- if (!o)
- return;
- let s = 0;
- for (; o; )
- s += 1,
- o = o.nextFree;
- let c = !1;
- if (s > e && this._pool.length > this.capacity && (c = !0),
- c)
- for (o = this.nextFree; o; ) {
- o.free = !1,
- this.nextFree = o.nextFree;
- const d = this._pool.indexOf(o);
- this._pool.splice(d, 1),
- this.nextFree || (this.lastFree = null),
- o == null || o.dispose(),
- o = this.nextFree
- }
- }
- }
- const texRootDir = "https://app-asset-1258211750.file.myqcloud.com/1/textures/"
- , _XBillboardManager = class {
- constructor(a) {
- this.billboardMap = new Map,
- this.userBackGroundBlob = new Array,
- this.npcBackGroundBlob = new Array,
- this._updateLoopObserver = void 0,
- this.sceneManager = a,
- this.billboardPool = new Pool(this.createBillboardAsset,this.resetBillboardAsset,0,60,this.sceneManager.Scene,!1),
- this.tickInterval = 250;
- let e = 0;
- this.tickObserver = this.sceneManager.Scene.onAfterRenderObservable.add(()=>{
- e += 1,
- e == this.tickInterval && (this.tick(),
- e = 0)
- }
- ),
- this.launchBillboardStatusLoop()
- }
- tick() {
- this.billboardPool.clean(0, this.sceneManager.Scene, !1)
- }
- createBillboardAsset(a, e=!1) {
- const i = MeshBuilder.CreatePlane("billboard-", {
- height: .001,
- width: .001,
- sideOrientation: Mesh.DOUBLESIDE
- }, a);
- i.isPickable = !0,
- i.setEnabled(!1);
- const o = new DynamicTexture("billboard-tex-",{
- width: .001 + 1,
- height: .001 + 1
- },a,e,Texture.BILINEAR_SAMPLINGMODE);
- o.hasAlpha = !0;
- const s = new StandardMaterial("billboard-mat-",a);
- return s.diffuseTexture = o,
- s.emissiveColor = new Color3(.95,.95,.95),
- s.useAlphaFromDiffuseTexture = !0,
- i.material = s,
- i.billboardMode = Mesh.BILLBOARDMODE_Y,
- i.position.y = 0,
- i
- }
- resetBillboardAsset(a) {
- const e = a.data;
- return e.setEnabled(!1),
- e.isPickable = !1,
- a
- }
- async loadBackGroundTexToIDB() {
- _XBillboardManager.userBubbleUrls.forEach(i=>{
- this.sceneManager.urlTransformer(i).then(o=>{
- this.userBackGroundBlob.push(o)
- }
- )
- }
- ),
- _XBillboardManager.npcBubbleUrls.forEach(i=>{
- this.sceneManager.urlTransformer(i).then(o=>{
- this.npcBackGroundBlob.push(o)
- }
- )
- }
- )
- }
- addBillboardToMap(a, e) {
- this.billboardMap.set(a, e)
- }
- addBillboard(a, e, i) {
- let o = this.getBillboard(a);
- return o || (o = new XBillboard(this,e,i),
- this.addBillboardToMap(a, o)),
- o
- }
- 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={
- x: 0,
- y: 0,
- z: 0
- }}) {
- const tt = this.addBillboard(e, !1, !0);
- tt.getMesh() == null && tt.init(e, $, _e);
- let rt;
- i != null && (rt = i ? _XBillboardManager.userBubbleUrls : _XBillboardManager.npcBubbleUrls),
- tt && tt.getMesh() && (tt.DEFAULT_CONFIGS = {
- id: e,
- isUser: i,
- background: o,
- font: s,
- fontsize: c,
- fontcolor: d,
- fontstyle: _,
- linesize: b,
- linelimit: k,
- scale: j,
- width: $,
- height: _e,
- position: et
- },
- tt.drawBillboard({
- imageList: o || rt
- }, {
- texts: a,
- font: s,
- fontsize: c,
- fontcolor: d,
- fontstyle: _,
- linesize: b,
- linelimit: k
- }, {
- position: et,
- scale: j
- }),
- e && tt.setId(e),
- tt.setStatus(BillboardStatus.SHOW))
- }
- getBillboard(a) {
- return this.billboardMap.get(a)
- }
- toggle(a, e) {
- var i;
- (i = this.getBillboard(a)) == null || i.setStatus(e ? BillboardStatus.SHOW : BillboardStatus.HIDE)
- }
- removeBillboard(a) {
- const e = this.getBillboard(a);
- e && (e.setStatus(BillboardStatus.DISPOSE),
- this.billboardMap.delete(a))
- }
- launchBillboardStatusLoop() {
- this._updateLoopObserver = this.sceneManager.Scene.onBeforeRenderObservable.add(()=>{
- this.billboardMap.size <= 0 || this.billboardMap.forEach(a=>{
- a.stageChanged && (a.status == BillboardStatus.SHOW ? a.show() : a.status == BillboardStatus.HIDE ? a.hide() : (a.hide(),
- a.dispose()),
- a.stageChanged = !1)
- }
- )
- }
- )
- }
- }
- ;
- let XBillboardManager = _XBillboardManager;
- XBillboardManager.alphaWidthMap = new Map;
- XBillboardManager.userBubbleUrls = [texRootDir + "bubble01.png", texRootDir + "bubble02.png", texRootDir + "bubble03.png"];
- XBillboardManager.npcBubbleUrls = [texRootDir + "bubble01_npc.png", texRootDir + "bubble02_npc.png", texRootDir + "bubble03_npc.png"];
- const log$G = new Logger$1("XAvatarBillboardComponent");
- class XAvatarBillboardComponent {
- constructor(e) {
- this._nickName = "",
- this._words = "",
- this._isNameVisible = !0,
- this._isBubbleVisible = !0,
- this._isGiftButtonsVisible = !1,
- this.withinVisualRange = !1,
- this._bubble = void 0,
- this._nameBoard = void 0,
- this._giftButtons = new Map,
- this._buttonTex = new Map,
- this._nameLinesLimit = 2,
- this._nameLengthPerLine = 16,
- this._pickBbox = null,
- this.bbox = void 0,
- this._height = .26,
- this._attachmentObservers = new Map,
- this.attachToAvatar = (i,o,s=!1,c={
- x: 0,
- y: 0,
- z: 0
- },d=!1,_)=>{
- const b = i.rootNode;
- if (this.bbox || i.getBbox(),
- o && b) {
- let k = this._attachmentObservers.get(o);
- if (k)
- if (d)
- this._scene.onBeforeRenderObservable.remove(k),
- this._attachmentObservers.delete(o);
- else
- return;
- const j = ue4Position2Xverse(c);
- s ? (o.setParent(b),
- o.position = j) : (k = this._scene.onBeforeRenderObservable.add(()=>{
- let$ = 0;
- _ ? ($ = i.rootNode.rotation.y / Math.PI * 180 + 90,
- i.rootNode.rotation.y && (o.rotation.y = i.rootNode.rotation.y)) : $ = i.avatarManager.sceneManager.cameraComponent.getCameraPose().rotation.yaw,
- $ || ($ = 0);
- const _e = new Vector3(0,this._height,0);
- 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),
- _e.y < .07 * i.scale && (_e.y = 0),
- o.position.x = b.position.x + j.x * Math.sin($ * Math.PI / 180) + j.z * Math.cos($ * Math.PI / 180),
- o.position.z = b.position.z + j.x * Math.cos($ * Math.PI / 180) - j.z * Math.sin($ * Math.PI / 180),
- o.position.y = b.position.y + this.bbox.maximum.y + j.y + _e.y
- }
- ),
- this._attachmentObservers.set(o, k))
- } else
- log$G.error("avatar or attachment not found!")
- }
- ,
- this.detachFromAvatar = (i,o,s=!1)=>{
- const c = this._attachmentObservers.get(o);
- c && this._scene.onBeforeRenderObservable.remove(c),
- i.rootNode ? (o.setEnabled(!1),
- o.parent = null,
- s && o.dispose()) : log$G.error("avatar not found!")
- }
- ,
- this.getBbox = (i,o={})=>{
- const {isConst: s=!1, changeWithAvatar: c=!1} = o;
- let {localCenter: d={
- x: 0,
- y: 0,
- z: 75
- }, width: _=1.32, height: b=1.5, depth: k=.44} = o;
- if (c) {
- const j = i.scale;
- d = {
- x: d.x * j,
- y: d.y * j,
- z: d.z * j
- },
- _ *= j,
- b *= j,
- k *= j
- }
- if (i.rootNode) {
- let j = new Vector3(0,0,0)
- , $ = new Vector3(0,0,0);
- if (s) {
- const et = ue4Position2Xverse(d);
- j = j.add(et.add(new Vector3(-_ / 2,-b / 2,-k / 2))),
- $ = $.add(et.add(new Vector3(_ / 2,b / 2,k / 2)))
- } else if (j = j.add(new Vector3(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY)),
- $ = $.add(new Vector3(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY)),
- i.isRender) {
- i.rootNode.getChildMeshes().forEach(rt=>{
- const it = rt.getBoundingInfo().boundingBox.minimum
- , nt = rt.getBoundingInfo().boundingBox.maximum;
- j.x = Math.min(j.x, it.x),
- $.x = Math.max($.x, nt.x),
- j.y = Math.min(j.y, it.y),
- $.y = Math.max($.y, nt.y),
- j.z = Math.min(j.z, it.z),
- $.z = Math.max($.z, nt.z)
- }
- );
- const et = $.x - j.x
- , tt = $.z - j.z;
- j.x -= i.scale * et / 2,
- $.x += i.scale * et / 2,
- $.y *= i.scale,
- j.z -= i.scale * tt / 2,
- $.z += i.scale * tt / 2
- } else {
- const et = i.avatarManager.getMainAvatar();
- et && et.bbComponent.bbox && (j.x = et.bbComponent.bbox.minimum.x,
- $.x = et.bbComponent.bbox.maximum.x,
- j.y = et.bbComponent.bbox.minimum.y,
- $.y = et.bbComponent.bbox.maximum.y,
- j.z = et.bbComponent.bbox.minimum.z,
- $.z = et.bbComponent.bbox.maximum.z)
- }
- const _e = i.rootNode.computeWorldMatrix(!0);
- this.bbox ? this.bbox.reConstruct(j, $, _e) : this.bbox = new BoundingBox(j,$,_e),
- this._pickBbox == null
- } else
- log$G.error("avatar not found!")
- }
- ,
- this._scene = e
- }
- get isNameVisible() {
- return this._isNameVisible
- }
- get isBubbleVisible() {
- return this._isBubbleVisible
- }
- get isGiftButtonsVisible() {
- return this._isGiftButtonsVisible
- }
- get words() {
- return this._words
- }
- get nickName() {
- return this._nickName
- }
- get giftButtons() {
- return this._giftButtons
- }
- get bubble() {
- return this._bubble
- }
- get nameBoard() {
- return this._nameBoard
- }
- setNicknameStatus(e) {
- var i;
- if (this.nameBoard && this.nameBoard.setStatus(e),
- e == BillboardStatus.DISPOSE) {
- const o = (i = this.nameBoard) == null ? void 0 : i.getMesh();
- if (o) {
- const s = this._attachmentObservers.get(o);
- s && (this._scene.onBeforeRenderObservable.remove(s),
- this._attachmentObservers.delete(o))
- }
- }
- }
- setBubbleStatus(e) {
- var i;
- if (this.bubble && this.bubble.setStatus(e),
- e == BillboardStatus.DISPOSE) {
- const o = (i = this.bubble) == null ? void 0 : i.getMesh();
- if (o) {
- const s = this._attachmentObservers.get(o);
- s && (this._scene.onBeforeRenderObservable.remove(s),
- this._attachmentObservers.delete(o))
- }
- }
- }
- setButtonsStatus(e) {
- this.giftButtons && this.giftButtons.size != 0 && this.giftButtons.forEach(i=>{
- if (i.setStatus(e),
- e == BillboardStatus.DISPOSE && i.getMesh()) {
- const o = i.getMesh();
- if (o) {
- const s = this._attachmentObservers.get(o);
- s && (this._scene.onBeforeRenderObservable.remove(s),
- this._attachmentObservers.delete(o))
- }
- }
- }
- )
- }
- setGiftButtonsVisible(e) {
- this.setButtonsStatus(e ? BillboardStatus.SHOW : BillboardStatus.DISPOSE)
- }
- dispose(e) {
- this._attachmentObservers.forEach(i=>{
- this._scene.onBeforeRenderObservable.remove(i)
- }
- ),
- this._attachmentObservers.clear(),
- this.updateBillboardStatus(e, BillboardStatus.DISPOSE),
- this._buttonTex.clear(),
- this._pickBbox && (e.avatarManager.bboxMeshPool.release(this._pickBbox),
- this._pickBbox = null)
- }
- updateBillboardStatus(e, i) {
- this.bbox || e.getBbox(),
- e.isRender ? (e.setBubbleStatus(i),
- e.setButtonsStatus(i),
- e.setNicknameStatus(i)) : (e.setBubbleStatus(BillboardStatus.DISPOSE),
- e.setButtonsStatus(BillboardStatus.DISPOSE),
- e.enableNickname ? e.setNicknameStatus(i) : e.setNicknameStatus(BillboardStatus.DISPOSE))
- }
- disposeBillBoard(e) {
- this._attachmentObservers.forEach(i=>{
- this._scene.onBeforeRenderObservable.remove(i)
- }
- ),
- this._attachmentObservers.clear(),
- this.updateBillboardStatus(e, BillboardStatus.DISPOSE),
- this._buttonTex.clear(),
- this._pickBbox && (e.avatarManager.bboxMeshPool.release(this._pickBbox),
- this._pickBbox = null)
- }
- setPickBoxScale(e) {
- this._pickBbox && this._pickBbox.data && (this._pickBbox.data.scaling = new Vector3(e,e,e))
- }
- setIsPickable(e, i) {
- e.rootNode && e.rootNode.getChildMeshes().forEach(o=>{
- o.isPickable = i
- }
- ),
- this._pickBbox && this._pickBbox.data && (this._pickBbox.data.isPickable = i)
- }
- initNameboard(e, i=1) {
- this._nameBoard == null && (this._nameBoard = e.avatarManager.sceneManager.billboardComponent.addBillboard("name-" + e.id, !1, !0)),
- this._nameBoard.init("nickname", i / 300, i / 300)
- }
- initBubble(e, i=1) {
- this._bubble == null && (this._bubble = e.avatarManager.sceneManager.billboardComponent.addBillboard("bubble-" + e.id, !1, !0)),
- e.isRender && this._bubble.init("bubble", i / 250, i / 250)
- }
- 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={
- x: 0,
- y: 0,
- z: 40
- }, scale: et, compensationZ: tt=11.2, reregistAnyway: rt=!0}) {
- (!this.bubble || this.bubble.getMesh() == null) && e.initBubble(),
- this._words = i;
- let it;
- s != null && (it = s ? XBillboardManager.userBubbleUrls : XBillboardManager.npcBubbleUrls),
- this._bubble && (this._bubble.DEFAULT_CONFIGS = {
- id: o,
- isUser: s,
- background: c || it,
- font: d,
- fontsize: _,
- fontcolor: b,
- fontstyle: k,
- linesize: j,
- linelimit: $,
- offsets: _e,
- scale: et,
- compensationZ: tt,
- reregistAnyway: rt
- },
- this._bubble.getMesh() && (e.avatarManager.enableBubble ? (this._bubble.drawBillboard({
- imageList: c || it
- }, {
- texts: this._words,
- font: d,
- fontsize: _,
- fontcolor: b,
- fontstyle: k,
- linesize: j
- }, {
- offsets: _e,
- scale: et,
- compensationZ: tt
- }),
- this.attachToAvatar(e, this._bubble.getMesh(), !1, this._bubble.offsets, rt)) : this.setBubbleStatus(BillboardStatus.DISPOSE),
- o && this._bubble.setId(o))),
- this.setButtonsStatus(BillboardStatus.DISPOSE)
- }
- silent() {
- this.setBubbleStatus(BillboardStatus.DISPOSE),
- this._words = ""
- }
- 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={
- x: 0,
- y: 0,
- z: 15
- }, scale: et, compensationZ: tt=0, reregistAnyway: rt=!1}) {
- this._nickName = i,
- (!this.nameBoard || this.nameBoard.getMesh() == null) && this.initNameboard(e),
- this._nameBoard && this._nameBoard.getMesh() && (this._nameBoard.DEFAULT_CONFIGS = {
- id: o,
- isUser: s,
- background: c,
- font: d,
- fontsize: _,
- fontcolor: b,
- fontstyle: k,
- linesize: j,
- linelimit: $,
- offsets: _e,
- scale: et,
- compensationZ: tt,
- reregistAnyway: rt
- },
- e.avatarManager.enableNickname ? (this._nameBoard.drawBillboard({}, {
- texts: this._nickName,
- font: d,
- fontsize: _,
- fontcolor: b,
- fontstyle: k,
- linesize: j,
- linelimit: $
- }, {
- offsets: _e,
- scale: et,
- compensationZ: 0
- }),
- this.attachToAvatar(e, this._nameBoard.getMesh(), !1, this._nameBoard.offsets, rt)) : this.setNicknameStatus(BillboardStatus.DISPOSE),
- o && this._nameBoard.setId(o))
- }
- generateButtons(e, i=null, o, s=85) {
- if (i && (this._buttonTex = i,
- this.clearButtons()),
- this._buttonTex.size == 0)
- return;
- let c = (this._buttonTex.size - 1) / 2;
- this._buttonTex.forEach((d,_)=>{
- let b = this._giftButtons.get(_);
- b || (b = e.avatarManager.sceneManager.billboardComponent.addBillboard("button-" + _ + e.id, !0, !1),
- b.init(_, o / 240, o / 240));
- const k = {
- x: o * c * 70,
- y: 0,
- z: o * (s - 20 * (c * c))
- };
- b.drawBillboard({
- imageList: [d]
- }, {}, {
- offsets: k,
- scale: o
- }),
- this.attachToAvatar(e, b.getMesh(), !1, b.offsets, !0),
- this._giftButtons.set(_, b),
- c -= 1
- }
- ),
- this.setBubbleStatus(BillboardStatus.DISPOSE)
- }
- clearButtons() {
- this._giftButtons.forEach(e=>{
- e.dispose()
- }
- ),
- this._giftButtons.clear()
- }
- createPickBoundingbox(e, i) {
- const o = i.extendSize.x * 2
- , s = i.extendSize.y * 2
- , c = i.extendSize.z * 2
- , d = this._scene
- , _ = Math.max(o, c)
- , b = e.avatarManager.bboxMeshPool.getFree(d, _, s, _)
- , k = b.data;
- return k && (k.position = i.centerWorld,
- k.setEnabled(!1),
- k.isPickable = !0,
- k.xtype = EMeshType.XAvatar,
- k.xid = e.id),
- b
- }
- }
- const log$F = new Logger$1("Avatar")
- , castRayOffsetY = .01
- , castRayTeleportationOffset = 10;
- class XAvatar {
- constructor({id: e, avatarType: i, priority: o, avatarManager: s, assets: c, status: d}) {
- this.id = "-1",
- this.priority = 0,
- this.isRender = !1,
- this.distLevel = 0,
- this.isInLoadingList = !1,
- this.isHide = !1,
- this.clothesList = [],
- this.isSelected = !1,
- this.pendingLod = !1,
- this._previousReceivedPosition = new Vector3(0,1e4,0),
- this.rootNode = void 0,
- this.distToCam = 1e11,
- this.enableNickname = !0,
- this.distance = 1e11,
- this.isCulling = !1,
- this.reslevel = 0,
- this.isInLoadingQueue = !1,
- this._scene = void 0,
- this._transparent = 0,
- this.hide = ()=>(this.isHide = !0,
- this._hide(),
- !this.isRender),
- this._show = ()=>{
- var _;
- this.isHide || (this.setIsPickable(!0),
- this.bbComponent._attachmentObservers.forEach((b,k)=>{
- k.setEnabled(!0)
- }
- ),
- this.priority == 0 && (this.rootNode.setEnabled(!0),
- this.isRender = !0,
- this.avatarManager._updateBillboardStatus(this, BillboardStatus.SHOW),
- this.component.accessories.forEach(b=>{
- b.rootComponent.setEnabled(!0)
- }
- ),
- (_ = this.controller) == null || _.playAnimation(this.controller.onPlay, this.controller.loop)),
- this.component.accessories.forEach(b=>{
- b.rootComponent.setEnabled(!0)
- }
- ))
- }
- ,
- this.show = ()=>(this.isHide = !1,
- this._show(),
- !!this.isRender),
- this.setAnimations = _=>{
- this.controller.animations = _
- }
- ,
- this.attachToAvatar = (_,b=!1,k={
- x: 0,
- y: 0,
- z: 0
- },j=!1,$,_e)=>this.bbComponent.attachToAvatar(this, _, b, k, j, _e),
- this.detachFromAvatar = (_,b=!1)=>this.bbComponent.detachFromAvatar(this, _, b),
- this.getBbox = (_={})=>this.bbComponent.getBbox(this, _),
- this.id = e,
- this._avatarManager = s,
- this._scene = this.avatarManager.scene,
- this.clothesList = c,
- this._avatarType = i,
- this.priority = o || 0,
- this.controller = new XAnimationController(this),
- this.component = new XAvatarComopnent,
- this.stateMachine = new XStateMachine(this._scene),
- this.bbComponent = new XAvatarBillboardComponent(this._scene),
- this.rootNode = new TransformNode(e,this._avatarManager.scene),
- this._avatarScale = d.avatarScale == null ? 1 : d.avatarScale,
- this._avatarRotation = d.avatarRotation == null ? {
- pitch: 0,
- yaw: 0,
- roll: 0
- } : d.avatarRotation,
- this._avatarPosition = d.avatarPosition == null ? {
- x: 0,
- y: 0,
- z: 0
- } : d.avatarPosition,
- this._isRayCastEnable = avatarSetting.isRayCastEnable,
- this.setPosition(this._avatarPosition, !0),
- this.setRotation(this._avatarRotation),
- this.setScale(this.scale),
- this._isRayCastEnable = avatarSetting.isRayCastEnable,
- this._scene.registerBeforeRender(()=>{
- this.tick()
- }
- )
- }
- tick() {
- this.cullingTick()
- }
- cullingTick() {
- var e;
- this.isCulling && ((e = this.rootNode) == null || e.getChildMeshes().forEach(i=>{
- this.distToCam < 50 ? i.visibility = 0 : i.visibility = this._transparent
- }
- ))
- }
- setTransParentThresh(e) {
- this._transparent = e
- }
- get isNameVisible() {
- return this.bbComponent.isNameVisible
- }
- get isBubbleVisible() {
- return this.bbComponent.isBubbleVisible
- }
- get isGiftButtonsVisible() {
- return this.bbComponent.isGiftButtonsVisible
- }
- get words() {
- return this.bbComponent.words
- }
- get nickName() {
- return this.bbComponent.nickName
- }
- get giftButtons() {
- return this.bbComponent.giftButtons
- }
- get bubble() {
- return this.bbComponent.bubble
- }
- get nameBoard() {
- return this.bbComponent.nameBoard
- }
- get avatarManager() {
- return this._avatarManager
- }
- set withinVisibleRange(e) {
- this.bbComponent.withinVisualRange = e
- }
- setNicknameStatus(e) {
- return this.bbComponent.setNicknameStatus(e)
- }
- setBubbleStatus(e) {
- return this.bbComponent.setBubbleStatus(e)
- }
- setButtonsStatus(e) {
- return this.bbComponent.setBubbleStatus(e)
- }
- setGiftButtonsVisible(e) {
- return this.bbComponent.setGiftButtonsVisible(e)
- }
- get avatarType() {
- return this._avatarType
- }
- attachBody(e) {
- return this.component.addBodyComp(this, e)
- }
- attachDecoration(e) {
- return this.component.addClothesComp(this, e)
- }
- detachDecoration(e) {
- return this.component.clearClothesComp(e)
- }
- detachDecorationAll() {
- return this.component.clearAllClothesComps()
- }
- get skeleton() {
- return this.component.skeleton
- }
- get position() {
- return this._avatarPosition
- }
- get rotation() {
- return this._avatarRotation
- }
- get scale() {
- return this._avatarScale
- }
- _hide_culling() {
- this.bbComponent.updateBillboardStatus(this, BillboardStatus.HIDE),
- this.isCulling = !0
- }
- _show_culling() {
- this.isCulling && (this.rootNode && this.rootNode.getChildMeshes().forEach(e=>{
- e.visibility = 1
- }
- ),
- this.bbComponent.updateBillboardStatus(this, BillboardStatus.SHOW),
- this.isCulling = !1)
- }
- _hide() {
- !this.isHide || (this.setIsPickable(!1),
- this.bbComponent._attachmentObservers.forEach((e,i)=>{
- i.setEnabled(!1)
- }
- ),
- this.priority == 0 ? (this.rootNode.setEnabled(!1),
- this.isRender = !1,
- this.bbComponent.updateBillboardStatus(this, BillboardStatus.HIDE),
- this.component.accessories.forEach(e=>{
- e.rootComponent.setEnabled(!1)
- }
- )) : this.isRender && (this.avatarManager.currentLODUsers[this.distLevel]--,
- this.removeAvatarFromScene()),
- this.component.accessories.forEach(e=>{
- e.rootComponent.setEnabled(!1)
- }
- ))
- }
- rotate(e, i, o) {
- return this.stateMachine.roll(this, e, i, o)
- }
- set isRayCastEnable(e) {
- this._isRayCastEnable = e
- }
- get isRayCastEnable() {
- return this._isRayCastEnable
- }
- getAvatarId() {
- return this.id
- }
- getAvaliableAnimations() {
- const e = avatarLoader.avaliableAnimation.get(this.avatarType);
- return e || []
- }
- setPosition(e, i=!1) {
- if (this._avatarPosition = e,
- this.rootNode) {
- const o = ue4Position2Xverse(this._avatarPosition);
- let s = !1;
- this.avatarManager.getMainAvatar() && (this.id != this.avatarManager.getMainAvatar().id || (Math.abs(o.y - this._previousReceivedPosition.y) > castRayOffsetY && (s = !0),
- o.subtract(this._previousReceivedPosition).length() > castRayTeleportationOffset && (s = !0))),
- this._isRayCastEnable ? s || i ? this._castRay(e).then(c=>{
- this.rootNode.position = o,
- this.rootNode.position.y -= c
- }
- ).catch(c=>{
- Promise.reject(c)
- }
- ) : (this.rootNode.position.x = o.x,
- this.rootNode.position.z = o.z) : this.rootNode.position = o,
- this._previousReceivedPosition = o.clone()
- }
- return Promise.resolve(e)
- }
- setRotation(e) {
- if (this._avatarRotation = e,
- this.rootNode) {
- const i = {
- pitch: e.pitch,
- yaw: e.yaw + 180,
- roll: e.roll
- }
- , o = ue4Rotation2Xverse(i);
- this.rootNode.rotation = o
- }
- }
- setAvatarVisible(e) {
- this.rootNode && (this.rootNode.setEnabled(e),
- this.rootNode.getChildMeshes().forEach(i=>{
- i.setEnabled(e)
- }
- ))
- }
- setScale(e) {
- this._avatarScale = e,
- this.rootNode && (this.rootNode.scaling = new Vector3(e,e,e)),
- this.bbComponent.bbox && this.getBbox()
- }
- _removeAvatarFromScene() {
- var e, i;
- this.isRender = !1,
- (e = this.controller) == null || e.detachAnimation(),
- this.component.dispose(this),
- (i = this.avatarManager.sceneManager) == null || i.lightComponent.removeShadow(this),
- this.component.accessories.forEach(o=>{
- o.rootComponent.setEnabled(!1)
- }
- )
- }
- removeAvatarFromScene() {
- this._removeAvatarFromScene(),
- this._disposeBillBoard()
- }
- _disposeBillBoard() {
- this.bbComponent.disposeBillBoard(this)
- }
- addComponent(e, i, o, s) {
- return i === "pendant" ? this.component.attachPendant(this, e) : this.component.changeClothesComp(this, e, i, o, s)
- }
- removeComponent(e, i) {
- if (e === "pendant")
- i ? this.component.detachPendant(i) : this.component.accessories.forEach((o,s)=>{
- this.component.detachPendant(s)
- }
- );
- else {
- const o = this.component.resourceIdList.find(s=>s.type == e);
- o && (this.detachDecoration(o),
- this.clothesList = this.clothesList.filter(s=>s.type != e))
- }
- }
- getComponentByType(e, i) {
- if (e === "pendant")
- if (i) {
- const o = this.component.accessories.get(i);
- return o || []
- } else
- return Array.from(this.component.accessories).map(o=>o[1]);
- else
- return this.component.resourceIdList.find(o=>o.type == e)
- }
- _castRay(e) {
- return new Promise((i,o)=>{
- var et;
- const s = ue4Position2Xverse(e)
- , c = new Vector3(0,-1,0)
- , d = 1.5 * this.scale
- , _ = 100 * d
- , b = d
- , k = new Vector3(s.x,s.y + b,+s.z)
- , j = new Ray(k,c,_)
- , $ = (et = this.avatarManager.sceneManager) == null ? void 0 : et.getGround(e);
- if (!$ || $.length <= 0)
- return log$F.warn(`\u89D2\u8272 id= ${this.id} \u627E\u4E0D\u5230\u5730\u9762\uFF0C\u5F53\u524D\u9AD8\u5EA6\u4E3A\u4E0B\u53D1\u9AD8\u5EA6`),
- i(0);
- let _e = j.intersectsMeshes($);
- if (_e.length > 0)
- return i(_e[0].distance - b);
- if (c.y = 1,
- _e = j.intersectsMeshes($),
- _e.length > 0)
- return i(-(_e[0].distance - b))
- }
- )
- }
- setPickBoxScale(e) {
- return this.bbComponent.setPickBoxScale(e)
- }
- setIsPickable(e) {
- return this.bbComponent.setIsPickable(this, e)
- }
- createPickBoundingbox(e) {
- return this.bbComponent.createPickBoundingbox(this, e)
- }
- scaleBbox(e) {
- this.bbComponent.bbox && this.bbComponent.bbox.scale(e)
- }
- rotateTo(e, i, o) {
- return this.stateMachine.rotateTo(this, e, i, o)
- }
- faceTo(e, i) {
- return this.stateMachine.lookAt(this, e, i)
- }
- removeObserver() {
- this.stateMachine.disposeObsever()
- }
- moveHermite(e, i, o, s, c, d) {
- return this.stateMachine.moveToHermite(this, e, i, o, s, c, d)
- }
- moveCardinal(e, i, o, s, c, d, _=!1) {
- return this.stateMachine.moveToCardinal(this, e, i, o, s, c, d, _)
- }
- move(e, i, o, s, c, d=!1) {
- return this.stateMachine.moveTo(this, e, i, o, s, c, d)
- }
- initNameboard(e=1) {
- return this.bbComponent.initNameboard(this, e)
- }
- initBubble(e=1) {
- return this.bbComponent.initBubble(this, e)
- }
- 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: $={
- x: 0,
- y: 0,
- z: 40
- }, scale: _e=this._avatarScale, compensationZ: et=11.2, reregistAnyway: tt=!0}) {
- return this.bbComponent.say(this, e, {
- id: i,
- isUser: o,
- background: s,
- font: c,
- fontsize: d,
- fontcolor: _,
- fontstyle: b,
- linesize: k,
- linelimit: j,
- offsets: $,
- scale: _e,
- compensationZ: et,
- reregistAnyway: tt
- })
- }
- silent() {
- return this.bbComponent.silent()
- }
- 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: $={
- x: 0,
- y: 0,
- z: 15
- }, scale: _e=this._avatarScale, compensationZ: et=0, reregistAnyway: tt=!1}) {
- return this.bbComponent.setNickName(this, e, {
- id: i,
- isUser: o,
- background: s,
- font: c,
- fontsize: d,
- fontcolor: _,
- fontstyle: b,
- linesize: k,
- linelimit: j,
- offsets: $,
- scale: _e,
- compensationZ: et,
- reregistAnyway: tt
- })
- }
- generateButtons(e=null, i=this._avatarScale, o=85) {
- return this.bbComponent.generateButtons(this, e, i, o)
- }
- clearButtons() {
- return this.bbComponent.clearButtons()
- }
- attachExtraProp(e, i, o, s) {
- return this.component.addDecoComp(this, e, i, o, s)
- }
- showExtra(e) {
- return this.component.showExtra(e)
- }
- hideExtra(e) {
- return this.component.hideExtra(e)
- }
- disposeExtra() {
- return this.component.disposeExtra()
- }
- getSkeletonPositionByName(e) {
- var i;
- if (this.skeleton) {
- const o = this.skeleton.bones.find(s=>s.name.replace("Clone of ", "") == e);
- if (o && o.getTransformNode() && ((i = o.getTransformNode()) == null ? void 0 : i.position)) {
- const s = o.getTransformNode().position;
- return xversePosition2Ue4({
- x: s.x,
- y: s.y,
- z: s.z
- })
- }
- }
- }
- shootTo(e, i, o=2, s=10, c={
- x: 0,
- y: 0,
- z: 150
- }) {
- return this.stateMachine.sendObjectTo(this, e, i, o, s, c)
- }
- }
- const log$E = new Logger$1("AvatarManager");
- var EAvatarRelationRank = (a=>(a[a.Self = 0] = "Self",
- a[a.Npc = 1] = "Npc",
- a[a.Friend = 2] = "Friend",
- a[a.Stranger = 3] = "Stranger",
- a[a.Robot = 4] = "Robot",
- a[a.Unknown = 5] = "Unknown",
- a))(EAvatarRelationRank || {});
- class XAvatarManager {
- constructor(e) {
- this.characterMap = new Map,
- this.curAnimList = [],
- this.extraComps = new Map,
- this._mainUser = void 0,
- this._sceneManager = void 0,
- this.maxBillBoardDist = 0,
- this.maxAvatarNum = 0,
- this.currentLODUsers = [],
- this._distLevels = [],
- this._maxLODUsers = [],
- this._cullingDistance = 0,
- this._delayTime = 100,
- this._queueLength = -1,
- this._queue = [],
- this._processList = [],
- this._process = void 0,
- this._updateLoopObserver = void 0,
- this._enableNickname = !0,
- this._enableBubble = !0,
- this._defaultAnims = void 0,
- this._tickDispose = 0,
- this._disposeTime = 10,
- this.avatarLoader = avatarLoader,
- this.onThingsLoading = !1,
- this.compMap = new Map,
- this._scene = e.mainScene,
- this._sceneManager = e,
- this.initAvatarMap(),
- this._initSettings(),
- this._maxDistRange = this._distLevels[this._distLevels.length - 1],
- this.bboxMeshPool = new Pool(this.createBboxAsset,this.resetBboxAsset,0,0,this._sceneManager.Scene,0,0,0),
- this._tickInterval = 250;
- let i = 0;
- this._tickObserver = this._scene.onAfterRenderObservable.add(()=>{
- i += 1,
- i == this._tickInterval && (this.tick(),
- i = 0)
- }
- )
- }
- tick() {
- this.bboxMeshPool.clean(0)
- }
- createBboxAsset(e, i, o, s) {
- return MeshBuilder.CreateBox("avatarBbox", {
- width: i,
- height: o,
- depth: s
- }, e)
- }
- resetBboxAsset(e) {
- const i = e.data;
- return i.setEnabled(!1),
- i.isPickable = !1,
- e
- }
- _initSettings() {
- this._defaultAnims = avatarSetting.defaultIdle,
- this._lodSettings = avatarSetting.lod,
- this._distLevels = avatarSetting.lod.map(e=>e.dist),
- this._maxLODUsers = avatarSetting.lod.map(e=>e.quota),
- this.currentLODUsers = new Array(this._distLevels.length).fill(0),
- this.maxAvatarNum = avatarSetting.maxAvatarNum,
- this.maxBillBoardDist = avatarSetting.maxBillBoardDist,
- this._cullingDistance = avatarSetting.cullingDistance
- }
- maxRenderNum() {
- let e = 0;
- return this._maxLODUsers.forEach(i=>{
- e += i
- }
- ),
- e
- }
- curRenderNum() {
- let e = 0;
- return this.currentLODUsers.forEach(i=>{
- e += i
- }
- ),
- e
- }
- setLoDLevels(e) {
- this._distLevels = e
- }
- set cullingDistance(e) {
- this._cullingDistance = e
- }
- get cullingDistance() {
- return this._cullingDistance
- }
- getLoDLevels() {
- return this._distLevels
- }
- setLodUserLimits(e, i) {
- this._maxLODUsers.length > e && (this._maxLODUsers[e] = i)
- }
- setLodDist(e, i) {
- this._distLevels[e] = i
- }
- setMaxDistRange(e) {
- this._maxDistRange = e,
- this._distLevels[this._distLevels.length - 1] = e
- }
- get scene() {
- return this._scene
- }
- setMainAvatar(e) {
- var i;
- this._mainUser = (i = this.characterMap.get(0)) == null ? void 0 : i.get(e)
- }
- getMainAvatar() {
- return this._mainUser
- }
- get enableNickname() {
- return this._enableNickname
- }
- get enableBubble() {
- return this._enableBubble
- }
- enableAllNickname(e) {
- this._enableNickname = e,
- this.characterMap.forEach(i=>{
- i.forEach(o=>{
- e ? o.nameBoard && o.nickName.length > 0 && o.isRender && o.setNickName(o.nickName, o.nameBoard.DEFAULT_CONFIGS) : o.setNicknameStatus(BillboardStatus.DISPOSE)
- }
- )
- }
- )
- }
- enableAllBubbles(e) {
- this._enableBubble = e,
- this.characterMap.forEach(i=>{
- i.forEach(o=>{
- e ? o.bubble && o.words.length > 0 && o.isRender && o.say(o.words, o.bubble.DEFAULT_CONFIGS) : o.setBubbleStatus(BillboardStatus.DISPOSE)
- }
- )
- }
- )
- }
- getAvatarById(e) {
- let i;
- return this.characterMap.forEach((o,s)=>{
- o.get(e) && (i = o.get(e))
- }
- ),
- i
- }
- getAvatarNums() {
- let e = 0;
- return this.characterMap.forEach((i,o)=>{
- e += i.size
- }
- ),
- e
- }
- registerAvatar(e) {
- this.characterMap.get(e.priority).set(e.id, e)
- }
- unregisterAvatar(e) {
- this.characterMap.get(e.priority).delete(e.id)
- }
- initAvatarMap() {
- this.characterMap.set(0, new Map),
- this.characterMap.set(1, new Map),
- this.characterMap.set(2, new Map),
- this.characterMap.set(3, new Map),
- this.characterMap.set(4, new Map),
- this.characterMap.set(5, new Map)
- }
- loadAvatar({id: e, avatarType: i, priority: o, avatarManager: s, assets: c, status: d}) {
- return new Promise((_,b)=>{
- if (this.getAvatarById(e))
- return b(new DuplicateAvatarIDError(`[Engine] cannot init avatar with the same id = ${e}`));
- if (this.getAvatarNums() > this.maxAvatarNum)
- return b(new ExceedMaxAvatarNumError(`[Engine] \u8D85\u51FA\u6700\u5927\u89D2\u8272\u9650\u5236 ${this.maxAvatarNum}`));
- const k = new XAvatar({
- id: e,
- avatarType: i,
- priority: o,
- avatarManager: s,
- assets: c,
- status: d
- });
- if (this.registerAvatar(k),
- o == 0)
- this.setMainAvatar(k.id),
- this.addAvatarToScene(k, 0).then(j=>(log$E.debug(`[Engine] avatar ${k.id} has been added to scene`),
- j ? (this._updateBillboardStatus(j, BillboardStatus.SHOW),
- setTimeout(()=>{
- this.launchProcessLoadingLoop()
- }
- , this._delayTime),
- _(j)) : (k.removeAvatarFromScene(),
- b(new AvatarAssetLoadingError)))).catch(j=>(k.removeAvatarFromScene(),
- b(new AvatarAssetLoadingError(j))));
- else
- return _(k)
- }
- )
- }
- deleteAvatar(e) {
- return e.isRender ? (e.removeAvatarFromScene(),
- this.currentLODUsers[e.distLevel]--) : e.bbComponent.disposeBillBoard(e),
- this._processList = this._processList.filter(i=>i.id !== e.id),
- this.unregisterAvatar(e),
- e.rootNode && (e.rootNode.dispose(),
- e.rootNode = void 0),
- e.bbComponent.bbox && e.bbComponent.bbox.dispose(),
- e.removeObserver(),
- e
- }
- _checkLODLevel(e) {
- if (e < this._distLevels[0])
- return 0;
- for (let i = 1; i < this._distLevels.length; ++i)
- if (e >= this._distLevels[i - 1] && e < this._distLevels[i])
- return i;
- return this._distLevels.length - 1
- }
- get sceneManager() {
- return this._sceneManager
- }
- launchProcessLoadingLoop() {
- this._updateAvatarStatus()
- }
- stopProcessLoadingLoop() {
- var e;
- this._updateLoopObserver && ((e = this._scene) == null || e.onBeforeRenderObservable.remove(this._updateLoopObserver)),
- this._queueLength = 0,
- this._clear(this.compMap),
- this._process && (this._process.isInLoadingList = !1,
- this._process.removeAvatarFromScene(),
- this._process = void 0),
- this._processList.forEach(i=>{
- i.isInLoadingList = !1
- }
- ),
- this._processList = []
- }
- _distToMain(e) {
- var c;
- const i = (c = this._mainUser) == null ? void 0 : c.position
- , o = e.position
- , s = this.sceneManager.cameraComponent.MainCamera.position;
- if (o && s) {
- const d = this.sceneManager.cameraComponent.MainCamera.getFrontPosition(1).subtract(s)
- , _ = e.rootNode.position.subtract(s)
- , b = new Vector3(d.x,0,d.z).normalize()
- , k = new Vector3(_.x,0,_.z).normalize();
- let j = 1;
- if (b && k) {
- const $ = b.multiply(k);
- j = Math.acos($.x + $.y + $.z) < this.sceneManager.cameraComponent.getCameraHorizonFov() * .6 ? 1 : 1e11
- }
- return calcDistance3D(i || s, o) * j
- } else
- return log$E.warn("user position or camera position is not correct!"),
- 1e11
- }
- _distToCamera(e) {
- var s;
- const i = (s = this._sceneManager) == null ? void 0 : s.cameraComponent.getCameraPose().position
- , o = e.position;
- return o && i ? calcDistance3D(i, o) : (log$E.warn("user position or camera position is not correct!"),
- 1e11)
- }
- showAll(e) {
- this.characterMap.forEach((i,o)=>{
- e && o == 0 && i.forEach((s,c)=>{
- s.show()
- }
- ),
- o != 0 && i.forEach((s,c)=>{
- s.show()
- }
- )
- }
- )
- }
- hideAll(e) {
- this.characterMap.forEach((i,o)=>{
- e && o == 0 && i.forEach((s,c)=>{
- s.hide()
- }
- ),
- o != 0 && i.forEach((s,c)=>{
- s.hide()
- }
- )
- }
- )
- }
- _assemblyAvatar(e, i) {
- var s, c;
- const o = e.get(avatarSetting.body);
- if (o && !i.attachBody(o)) {
- i.isInLoadingList = !1,
- this._clear(e);
- return
- }
- for (const d of e)
- if (d[0] != avatarSetting.body && d[0] != avatarSetting.animations && !i.attachDecoration(d[1])) {
- i.isInLoadingList = !1,
- i.removeAvatarFromScene(),
- this._clear(e);
- return
- }
- i.isRender = !0,
- (s = i.controller) == null || s.playAnimation(i.controller.onPlay, i.controller.loop),
- (c = i.controller) == null || c.onPlayObservable.addOnce(()=>{
- var d, _;
- if (!this.getAvatarById(i.id)) {
- i.isInLoadingList = !1,
- i.removeAvatarFromScene(),
- this.currentLODUsers[i.distLevel]--;
- return
- }
- if (this.getAvatarById(i.id).rootNode.getChildMeshes().length < e.size) {
- 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}`),
- i.isInLoadingList = !1,
- i.removeAvatarFromScene(),
- this.currentLODUsers[i.distLevel]--;
- return
- }
- i.setIsPickable(!0),
- i.isInLoadingList = !1,
- i.setAvatarVisible(!0),
- (_ = this._sceneManager) == null || _.lightComponent.setShadow(i),
- i.getBbox(),
- i.nameBoard && i.nickName.length > 0 && this._enableNickname && i.setNickName(i.nickName, i.nameBoard.DEFAULT_CONFIGS),
- i.component.accessories.forEach(b=>{
- b.rootComponent.setEnabled(!0)
- }
- ),
- i.bubble && i.words.length > 0 && i.say(i.words, i.bubble.DEFAULT_CONFIGS),
- log$E.debug(`[Engine] avatar ${i.id} has been added to scene, current number of users : ${this.currentLODUsers}`)
- }
- )
- }
- _disposeUnusedAssets() {
- this._tickDispose++,
- (this._tickDispose > this._disposeTime || avatarLoader.containers.size > 100) && (avatarLoader.disposeContainer(),
- this._tickDispose = 0)
- }
- _addResourcesToList(e, i) {
- return e.clothesList.forEach(o=>{
- o.lod = i,
- this._queue.push(o)
- }
- ),
- this._queue.push({
- type: avatarSetting.animations,
- id: this._defaultAnims
- }),
- this._queue.push({
- type: avatarSetting.body,
- id: e.avatarType,
- lod: i
- }),
- !0
- }
- _updateBillboardStatus(e, i) {
- e.bbComponent.updateBillboardStatus(e, i)
- }
- _processLayer(e) {
- const i = this.characterMap.get(e)
- , o = [];
- for (i == null || i.forEach(s=>{
- s.distToCam = this._distToCamera(s);
- const c = s.distToCam < this._cullingDistance;
- if (s.isRender && (!s.isHide && c ? s._hide_culling() : s._show_culling()),
- s.priority != 0) {
- s.distance = this._distToMain(s);
- let d = BillboardStatus.SHOW;
- s.distance < this._maxDistRange && (c ? d = BillboardStatus.HIDE : s._show_culling(),
- this._updateBillboardStatus(s, d)),
- s.isHide || (s.isInLoadingList ? this.currentLODUsers[s.distLevel]++ : o.push(s))
- }
- }
- ),
- o.sort((s,c)=>c.distance - s.distance); o.length > 0 && this.curRenderNum() < this.maxRenderNum(); ) {
- const s = o.pop();
- let c = this._checkLODLevel(s.distance)
- , d = !1;
- for (let _ = 0; _ < this._maxLODUsers.length; ++_)
- if (this.currentLODUsers[_] < this._maxLODUsers[_]) {
- c = _,
- d = !0;
- break
- }
- if (!d || s.distance > this._maxDistRange) {
- if (s.isRender) {
- s._removeAvatarFromScene();
- let _ = BillboardStatus.HIDE;
- s.distance < this._maxDistRange && (_ = BillboardStatus.SHOW),
- this._updateBillboardStatus(s, _)
- }
- break
- }
- c != s.distLevel ? (s.isRender && (s.pendingLod = !0),
- s.distLevel = c,
- this._processList.push(s),
- s.isInLoadingList = !0) : s.isRender || (this._processList.push(s),
- s.isInLoadingList = !0),
- this.currentLODUsers[c]++
- }
- return this.curRenderNum() >= this.maxRenderNum() && o.forEach(s=>{
- if (s.isRender) {
- s._removeAvatarFromScene();
- let c = BillboardStatus.HIDE;
- s.distance < this._maxDistRange && (c = BillboardStatus.SHOW),
- this._updateBillboardStatus(s, c)
- }
- }
- ),
- this.curRenderNum() < this.maxRenderNum()
- }
- _updateAvatar() {
- this.currentLODUsers = [0, 0, 0];
- const e = [5, 4, 3, 2, 1, 0];
- for (; e.length > 0; ) {
- const i = e.pop();
- if (!this._processLayer(i)) {
- e.forEach(s=>{
- var c;
- (c = this.characterMap.get(s)) == null || c.forEach(d=>{
- d.distance = this._distToMain(d);
- let _ = BillboardStatus.HIDE;
- d.distToCam < this._maxDistRange && (_ = BillboardStatus.SHOW,
- d.isRender && d._removeAvatarFromScene()),
- this._updateBillboardStatus(d, _)
- }
- )
- }
- );
- break
- }
- }
- }
- _updateAvatarStatus() {
- this._updateLoopObserver = this.scene.onBeforeRenderObservable.add(()=>{
- var e;
- if (!(this.getAvatarNums() <= 0)) {
- if (!this._process && this._processList.length == 0 && this._updateAvatar(),
- !this._process && this._processList.length > 0) {
- const i = this._processList.shift();
- i != this._process && !i.isCulling ? this._addResourcesToList(i, i.distLevel) ? (this._process = i,
- this._queueLength = this._queue.length) : (this._process = void 0,
- this._queue = [],
- i.isInLoadingList = !1) : i.isInLoadingList = !1
- }
- if (this.compMap.size === this._queueLength && this._process) {
- this._process.pendingLod && (this._process.pendingLod = !1,
- this._process._removeAvatarFromScene());
- const i = Date.now();
- this._assemblyAvatar(this.compMap, this._process),
- (e = this._sceneManager) == null || e.engineRunTimeStats.timeArray_addAvatarToScene.add(Date.now() - i),
- this._updateBillboardStatus(this._process, BillboardStatus.SHOW),
- this.compMap.clear(),
- this._queue = [],
- this._process.isInLoadingList = !1,
- this._process = void 0
- }
- this._disposeUnusedAssets(),
- this._loadResByList(this.compMap)
- }
- }
- )
- }
- _clear(e) {
- e.forEach((i,o)=>{
- o == avatarSetting.body && (i.root._parentContainer ? i.root._parentContainer.xReferenceCount-- : i.root.getChildMeshes().forEach(s=>{
- s.dispose()
- }
- )),
- (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())
- }
- )
- }
- _loadResByList(e) {
- let i = 0;
- const o = 5;
- if (!this._process) {
- e.clear();
- return
- }
- for (; !this.onThingsLoading && i < o && this._queue.length > 0; ) {
- const s = Date.now()
- , c = this._queue.pop();
- setTimeout(()=>{
- c ? c.type === avatarSetting.body ? (this.onThingsLoading = !0,
- this.loadBody(c.type, c.id, c.lod).then(d=>{
- d && e.set(avatarSetting.body, d),
- i += Date.now() - s,
- this.onThingsLoading = !1
- }
- ).catch(d=>{
- this._process && (this._process.isHide = !0,
- this.currentLODUsers[this._process.distLevel]--,
- this._clear(e),
- this._queue = [],
- this._process.isInLoadingList = !1,
- this._process = void 0,
- i += 100,
- this.onThingsLoading = !1),
- log$E.warn(`[Engine] body ${c.id} uri error, type ${c.type}, avatar has been hided` + d)
- }
- )) : c.type === avatarSetting.animations ? this.loadAnimation(this._process.avatarType, c.id).then(d=>{
- d && e.set(avatarSetting.animations, d),
- i += Date.now() - s,
- this.onThingsLoading = !1
- }
- ).catch(d=>{
- this._process && (this._process.isHide = !0,
- this.currentLODUsers[this._process.distLevel]--,
- this._clear(e),
- this._queue = [],
- this._process.isInLoadingList = !1,
- this._process = void 0,
- i += 100,
- this.onThingsLoading = !1),
- log$E.warn(`animation ${c.id} uri error, type ${c.type}, avatar has been hided` + d)
- }
- ) : this.loadDecoration(c.type, c.id, c.lod).then(d=>{
- d && e.set(d.type, d),
- i += Date.now() - s,
- this.onThingsLoading = !1
- }
- ).catch(d=>{
- this._process && (this._process.isHide = !0,
- this.currentLODUsers[this._process.distLevel]--,
- this._clear(e),
- this._queue = [],
- this._process.isInLoadingList = !1,
- this._process = void 0,
- i += 100,
- this.onThingsLoading = !1),
- log$E.warn(`component ${c.id} uri error, type ${c.type}, avatar has been hided` + d)
- }
- ) : i += 100
- }
- , 0)
- }
- }
- _validateContainer(e) {
- return !e.meshes || e.meshes.length <= 1 ? (log$E.warn("import container has no valid meshes"),
- !1) : !e.skeletons || e.skeletons.length == 0 ? (log$E.warn("import container has no valid skeletons"),
- !1) : !0
- }
- _getAssetContainer(e, i) {
- return new Promise((o,s)=>{
- const c = this._getSourceKey(e, i || 0)
- , d = avatarLoader.containers.get(c);
- if (d)
- return o(d);
- avatarLoader.load(this.sceneManager, e, i).then(_=>_ ? this._validateContainer(_) ? (avatarLoader.containers.set(c, _),
- 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}.`)))
- }
- )
- }
- _clipContainerRes(e) {
- e.transformNodes = [],
- e.skeletons.forEach(i=>{
- i.dispose()
- }
- ),
- e.skeletons = []
- }
- loadBody(e, i, o) {
- return avatarLoader.load(this.sceneManager, i, o).then(s=>{
- if (s) {
- const c = s.instantiateModelsToScene();
- s.xReferenceCount++;
- const d = {
- isRender: !1,
- uId: Math.random(),
- root: c.rootNodes[0],
- skeletonType: e,
- name: i,
- animations: c.animationGroups,
- skeleton: c.skeletons[0],
- lod: o
- };
- return c.rootNodes[0]._parentContainer = s,
- c.rootNodes[0].setEnabled(!1),
- d
- } else
- return Promise.reject(new ContainerLoadingFailedError("[Engine] container failed instanciates failed"))
- }
- ).catch(()=>Promise.reject(new ContainerLoadingFailedError(`[Engine] body type ${e} instanciates failed`)))
- }
- updateAnimationLists(e, i) {
- return new Promise((o,s)=>(avatarLoader.avaliableAnimation.set(i, e),
- o()))
- }
- loadAnimation(e, i) {
- return avatarLoader.loadAnimRes(this.sceneManager, i, e).then(o=>{
- if (o) {
- let s;
- const c = this.avatarLoader.animations;
- return o.animationGroups.forEach(d=>{
- d.stop(),
- d.name === i && (s = d,
- s.pContainer = o),
- c.set(getAnimationKey(d.name, e), d)
- }
- ),
- this._clipContainerRes(o),
- o.xReferenceCount++,
- s
- } else
- return Promise.reject(new ContainerLoadingFailedError("[Engine] container failed instanciates failed"))
- }
- )
- }
- loadDecoration(e, i, o) {
- return avatarLoader.load(this.sceneManager, i, o).then(s=>{
- if (s) {
- if (s.meshes.length <= 1)
- return console.error("\u3010\u5F02\u5E38\uFF0Ccontainer\u4E0D\u542Bmesh\u3011"),
- Promise.reject(`\u3010\u5F02\u5E38\uFF0Ccontainer\u4E0D\u542Bmesh\u3011 ${i}`);
- const c = s.meshes[1].clone(s.meshes[1].name, null);
- if (!c)
- return log$E.warn("[Engine] decoration does not exist!"),
- null;
- const d = {
- isRender: !1,
- uId: Math.random(),
- root: c,
- type: e,
- name: i,
- isSelected: !1,
- lod: o
- };
- if (s.xReferenceCount++,
- c._parentContainer = s,
- s.meshes.length > 1)
- for (let _ = 2; _ < s.meshes.length; _++)
- c.addChild(s.meshes[_].clone(s.meshes[_].name, null));
- return c.setEnabled(!1),
- d.isSelected = !0,
- d
- } else
- return Promise.reject(new ContainerLoadingFailedError("[Engine] container failed, instanciates failed."))
- }
- )
- }
- _getSourceKey(e, i) {
- return i && avatarSetting.lod[i] ? e + avatarSetting.lod[i].fileName.split(".")[0] : e
- }
- addAvatarToScene(e, i) {
- const o = Date.now();
- return this.loadBody(e.avatarType, e.avatarType, i).then(s=>{
- var c;
- return s ? (e.attachBody(s),
- s.animations.length > 0 ? (s.animations.forEach(d=>{
- d.stop()
- }
- ),
- e.setAnimations(s.animations),
- (c = e.controller) == null || c.playAnimation(e.controller.onPlay, !0),
- e.isRender = !0,
- e.isInLoadingList = !1,
- e.setAvatarVisible(!0),
- e) : this.loadAnimation(e.avatarType, this._defaultAnims).then(d=>{
- if (!d)
- return e.removeAvatarFromScene(),
- e.isInLoadingList = !1,
- Promise.reject(new AvatarAnimationError);
- const _ = [];
- return e.clothesList.length > 0 && e.clothesList.forEach(b=>{
- _.push(this.loadDecoration(b.type, b.id, i))
- }
- ),
- Promise.all(_).then(b=>{
- var $, _e, et, tt;
- b.forEach(rt=>{
- if (rt && !rt.isRender)
- e.attachDecoration(rt);
- else {
- e.isInLoadingList = !1,
- e.removeAvatarFromScene(),
- Promise.reject(new AvatarAssetLoadingError);
- return
- }
- }
- ),
- e.isRender = !0,
- ($ = e.controller) == null || $.playAnimation(e.controller.onPlay, e.controller.loop),
- e.setAvatarVisible(!0),
- (_e = this._sceneManager) == null || _e.lightComponent.setShadow(e);
- const k = avatarLoader.mshPath.get("meshes/ygb.glb")
- , j = avatarLoader.matPath.get(avatarResources.ygb.mesh);
- if (k && j)
- this.loadExtra(j, k).then(rt=>{
- var it;
- return e.isRender = !0,
- e.isInLoadingList = !1,
- e.distLevel = i,
- (it = this._sceneManager) == null || it.engineRunTimeStats.timeArray_addAvatarToScene.add(Date.now() - o),
- e
- }
- );
- else
- return e.isRender = !0,
- e.isInLoadingList = !1,
- e.distLevel = i,
- (et = this._sceneManager) == null || et.engineRunTimeStats.timeArray_addAvatarToScene.add(Date.now() - o),
- e;
- return e.isInLoadingList = !1,
- e.distLevel = i,
- (tt = this._sceneManager) == null || tt.engineRunTimeStats.timeArray_addAvatarToScene.add(Date.now() - o),
- e
- }
- ).catch(()=>Promise.reject(new AvatarAssetLoadingError(`[Engine] avatar ${e.id} instanciates failed.`)))
- }
- ).catch(()=>Promise.reject(new AvatarAssetLoadingError(`[Engine] avatar ${e.id} instanciates failed.`)))) : (e.isInLoadingList = !1,
- Promise.reject(new ContainerLoadingFailedError(`[Engine] avatar ${e.id} instanciates failed`)))
- }
- ).catch(()=>Promise.reject(new AvatarAssetLoadingError(`[Engine] avatar ${e.id} instanciates failed.`)))
- }
- loadExtra(e, i) {
- const o = avatarResources.ygb.name;
- return new Promise((s,c)=>{
- var d;
- (d = this.sceneManager) == null || d.urlTransformer(e).then(_=>{
- SceneLoader.LoadAssetContainerAsync("", _, this.scene, null, avatarSetting.fileType).then(b=>{
- var j;
- this.extraComps.set(o, b.meshes[0]);
- const k = new NodeMaterial(`material_${o}`,this._scene,{
- emitComments: !1
- });
- (j = this.sceneManager) == null || j.urlTransformer(i).then($=>{
- k.loadAsync($).then(()=>{
- b.meshes[2].material.dispose(!0, !0),
- k.build(!1),
- b.meshes[2].material = k,
- s(b.meshes[2])
- }
- )
- }
- )
- }
- )
- }
- )
- }
- )
- }
- getAvatarList() {
- const e = [];
- return this.characterMap.forEach((i,o)=>{
- i.forEach((s,c)=>{
- e.push(s)
- }
- )
- }
- ),
- e
- }
- _debug_avatar() {
- var i, o;
- console.error("===>currentLODUsers", this.currentLODUsers),
- console.error("===>maxLODUsers", this._maxLODUsers),
- console.error("===>Loddist", this.getLoDLevels()),
- console.error("===> main character loc", (o = (i = this._mainUser) == null ? void 0 : i.rootNode) == null ? void 0 : o.position);
- let e = 0;
- this.getAvatarList().forEach(s=>{
- s.isRender && (console.error(`avatar id : ${s.id},lod ${s.distLevel},is Hide ${s.isHide}, distance ${s.distance}, is pending ${s.isInLoadingList}`),
- e++)
- }
- ),
- console.error("========= avatar num", e),
- console.error("loop:", this._updateLoopObserver ? "on" : "false", "=> process", this._process, "===> comp", this._processList),
- console.error("===>maxLODUsers", this._maxLODUsers)
- }
- }
- const log$D = new Logger$1("XLightManager");
- class XLightManager {
- constructor(e) {
- this.sceneManager = e,
- this._scene = this.sceneManager.Scene,
- this._envTexture = null,
- this.shadowLean = .1;
- const i = new Vector3(this.shadowLean,-1,0)
- , o = 1024;
- this._shadowLight = new DirectionalLight("AvatarLight",i,this._scene),
- this._shadowLight.shadowMaxZ = 5e3,
- this._shadowLight.intensity = 0,
- this.attachLightToCamera(this._shadowLight),
- this._shadowGenerator = new ShadowGenerator(o,this._shadowLight,!0),
- this._avatarShadowMeshMap = new Map,
- this._cullingShadowObservers = new Map
- }
- set shadowLean(e) {
- e = Math.min(e, 1),
- e = Math.max(e, -1),
- this._shadowLight && (this._shadowLight.direction = new Vector3(e,-1,0))
- }
- setIBL(e) {
- return new Promise((i,o)=>{
- this.sceneManager.urlTransformer(e).then(s=>{
- var c;
- if (s == ((c = this._envTexture) == null ? void 0 : c.url))
- return i("env set success");
- this._envTexture != null && this.disposeIBL(),
- this._envTexture = CubeTexture.CreateFromPrefilteredData(s, this._scene, ".env"),
- this._scene.environmentTexture = this._envTexture,
- this._envTexture.onLoadObservable.addOnce(()=>{
- i("env set success"),
- log$D.info("env set success")
- }
- )
- }
- ).catch(()=>{
- o("env set fail")
- }
- )
- }
- )
- }
- disposeIBL() {
- this._envTexture == null ? log$D.info("env not exist") : (this._envTexture.dispose(),
- this._envTexture = null,
- this._scene.environmentTexture = null,
- log$D.info("env dispose success"))
- }
- removeShadow(e) {
- var i;
- if (this._avatarShadowMeshMap.has(e)) {
- this._avatarShadowMeshMap.delete(e),
- this._cullingShadowObservers.get(e) && (this._scene.onBeforeRenderObservable.remove(this._cullingShadowObservers.get(e)),
- this._cullingShadowObservers.delete(e));
- const o = e.rootNode;
- o && ((i = this._shadowGenerator) == null || i.removeShadowCaster(o))
- } else
- return
- }
- setShadow(e) {
- if (this._avatarShadowMeshMap.has(e))
- return;
- e.rootNode && this._avatarShadowMeshMap.set(e, e.rootNode.getChildMeshes());
- const i = 20
- , o = 10
- , s = this.cullingShadow(i, o, e);
- this._cullingShadowObservers.set(e, s)
- }
- cullingShadow(e, i, o) {
- let s = 0;
- const c = ()=>{
- var _;
- if (s == i) {
- const b = this._avatarShadowMeshMap.get(o)
- , k = (_ = o.rootNode) == null ? void 0 : _.getChildMeshes()
- , j = this._scene.activeCamera;
- b == null || b.forEach($=>{
- var _e;
- (_e = this._shadowGenerator) == null || _e.removeShadowCaster($, !1)
- }
- ),
- k == null || k.forEach($=>{
- var _e;
- (_e = this._shadowGenerator) == null || _e.addShadowCaster($, !1)
- }
- ),
- j && o.rootNode.position.subtract(j.position).length() > e && (k == null || k.forEach($=>{
- var _e;
- (_e = this._shadowGenerator) == null || _e.removeShadowCaster($, !1)
- }
- )),
- k && this._avatarShadowMeshMap.set(o, k),
- s = 0
- } else
- s += 1
- }
- ;
- return this._scene.onBeforeRenderObservable.add(c)
- }
- attachLightToCamera(e) {
- const i = e
- , o = 15
- , s = ()=>{
- const c = this._scene.activeCamera;
- if (c) {
- const d = i.direction
- , _ = new Vector3(o * d.x,o * d.y,o * d.z)
- , b = c.position;
- i.position = b.subtract(_)
- }
- }
- ;
- return i && this._scene.registerBeforeRender(s),
- s
- }
- }
- ParticleSystemSet.prototype.systems = new Array;
- const _XParticleManager = class {
- constructor(a) {
- if (this.load = (e,i,o)=>new Promise(s=>{
- ParticleSystemSet.BaseAssetsUrl = e;
- const c = new XMLHttpRequest;
- c.open("get", e + "/" + i),
- c.send(null),
- c.onload = ()=>{
- if (c.status == 200) {
- const d = JSON.parse(c.responseText);
- let _ = null;
- if (Object.keys(d).find(b=>b == "systems") == null) {
- const b = ParticleSystem.Parse(d, this._scene, e);
- _ = new ParticleSystemSet,
- _.systems.push(b)
- } else
- _ = ParticleSystemSet.Parse(d, this._scene, !1);
- s(_)
- }
- }
- }
- ),
- this.get = e=>this._particles.get(e),
- this.start = e=>{
- const i = this._particles.get(e);
- i && i.start()
- }
- ,
- this.stop = e=>{
- var o;
- const i = ((o = this._particles.get(e)) == null ? void 0 : o.systems) || [];
- for (let s = 0; s < i.length; s++)
- i[s].stop()
- }
- ,
- this.remove = e=>{
- const i = this._particles.get(e);
- i && i.dispose()
- }
- ,
- this.setParticlePosition = (e,i)=>{
- const o = this._particles.get(e);
- o && (o.emitterNode = i)
- }
- ,
- this.setParticleScalingInPlace = (e,i)=>{
- const o = this._particles.get(e);
- o == null || o.systems.forEach(s=>{
- _XParticleManager.scalingInPlace(s, i)
- }
- )
- }
- ,
- this._scene = a,
- this._particles = new Map,
- this._light = null,
- this._scene.getLightByName("fireworkLight"))
- this._light = this._scene.getLightByName("fireworkLight");
- else {
- const e = new PointLight("fireworkLight",new Vector3(0,0,0),a);
- e.intensity = 0,
- this._light = e
- }
- }
- _flashBang(a=200) {
- const e = this._scene.getLightByName("fireworkLight");
- e.intensity = 1,
- setTimeout(()=>{
- e.intensity = 0
- }
- , a)
- }
- }
- ;
- let XParticleManager = _XParticleManager;
- XParticleManager.disposeParticleSysSet = a=>{
- !a.systems || (a.systems.forEach(e=>{
- _XParticleManager.disposeParticleSystem(e)
- }
- ),
- a.dispose())
- }
- ;
- XParticleManager.disposeParticleSystem = a=>{
- a.particleSystem && (a = a.particleSystem),
- a.subEmitters && a.subEmitters.forEach(e=>{
- e instanceof Array ? e.forEach(i=>{
- _XParticleManager.disposeParticleSystem(i)
- }
- ) : _XParticleManager.disposeParticleSystem(e)
- }
- ),
- a.dispose()
- }
- ;
- XParticleManager.scalingInPlace = (a,e)=>{
- a.getClassName() === "ParticleSystem" && (a.minSize *= e,
- a.maxSize *= e,
- a.subEmitters != null && a.subEmitters.forEach(i=>{
- i instanceof SubEmitter && _XParticleManager.scalingInPlace(i.particleSystem, e),
- i instanceof ParticleSystem && _XParticleManager.scalingInPlace(i, e),
- i instanceof Array && i.forEach(o=>{
- _XParticleManager.scalingInPlace(o.particleSystem, e)
- }
- )
- }
- ))
- }
- ;
- const DefaultUrlTransformer$1 = async a=>a
- , log$C = new Logger$1("subSequence")
- , DEFAULT_FRAME_RATE = 30
- , ROOT_MESH_ANIM_PROPERTY = ["scaling", "position", "rotation"]
- , MESH_TAG = "XSubSequence";
- class XSpriteManager extends SpriteManager {
- constructor(e, i, o, s, c) {
- super(e, i, o, s, c),
- this.originalPositions = new Array,
- this.sprites.forEach(d=>{
- this.originalPositions.push(d.position)
- }
- )
- }
- static Parse(e, i, o) {
- const s = new XSpriteManager(e.name,"",e.capacity,{
- width: e.cellWidth,
- height: e.cellHeight
- },i);
- 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));
- for (const c of e.sprites) {
- const d = Sprite.Parse(c, s);
- s.originalPositions.push(d.position)
- }
- return s
- }
- }
- class XSubSequence {
- constructor(e, i, o=DefaultUrlTransformer$1) {
- this._pickable = !1,
- this.onLoadedObserverable = new Observable,
- this.onSubSequenceTransformationChangeObservable = new Observable,
- this.onIntersectionObservable = new Observable,
- this._isDisposing = !1,
- this.init = ()=>new Promise((s,c)=>{
- this.urlTransformer(this._abosoluteUrl).then(d=>{
- const _ = new XMLHttpRequest;
- _.open("get", d),
- _.send(null),
- _.onload = ()=>{
- if (_.status == 200) {
- const b = JSON.parse(_.responseText);
- this.load(b).then(()=>{
- this.onLoadedObserverable.notifyObservers(this),
- this._loaded = !0,
- s()
- }
- , ()=>{
- c(),
- log$C.error("subSequence: Load ${jsonBlob} json fail")
- }
- )
- }
- }
- ,
- _.onerror = ()=>{
- log$C.error("http: Get ${jsonBlob} json fail"),
- c()
- }
- }
- )
- }
- ),
- this.play = async(s=!0)=>new Promise(c=>{
- if (this._animGroup.isPlaying && this._animGroup.stop(),
- this._particleGroups.forEach(d=>{
- var _;
- ((_ = d.emitterNode) == null ? void 0 : _.getClassName()) == "Mesh" && d.emitterNode instanceof Mesh ? d.emitterNode.isEnabled() && d.start() : d.start()
- }
- ),
- this._animGroup.targetedAnimations.length == 0) {
- this.show();
- let d = 0;
- this._spriteGroups.forEach(_=>{
- _.sprites.forEach(b=>{
- b.toIndex > d && (d = b.toIndex)
- }
- )
- }
- ),
- this._spriteGroups.forEach(_=>{
- _.sprites.forEach(b=>{
- b.playAnimation(b.fromIndex, b.toIndex, s, b.delay, ()=>{
- b.toIndex == d && (this._isPaused = !0,
- this.hide(),
- c())
- }
- )
- }
- )
- }
- )
- } else
- this._animGroup.play(s),
- this._spriteGroups.forEach(d=>{
- d.sprites.forEach(_=>{
- _.playAnimation(_.fromIndex, _.toIndex, s, _.delay)
- }
- )
- }
- ),
- s ? this._animGroup.onAnimationGroupLoopObservable.addOnce(()=>{
- c()
- }
- ) : this._animGroup.onAnimationGroupEndObservable.addOnce(()=>{
- this._spriteGroups.forEach(d=>{
- d.sprites.forEach(_=>{
- _.isVisible = !1,
- _.isPickable = !1,
- _.stopAnimation()
- }
- )
- }
- ),
- c()
- }
- );
- this._isStarted = !0,
- this._isPaused = !1
- }
- ),
- this.stop = ()=>{
- this._animGroup.stop(),
- this._particleGroups.forEach(s=>{
- s.systems.forEach(c=>{
- c.stop()
- }
- )
- }
- ),
- this._spriteGroups.forEach(s=>{
- s.sprites.forEach(c=>{
- c.stopAnimation()
- }
- )
- }
- ),
- this._isStarted = !1
- }
- ,
- this.clone = (s="Clone")=>{
- const c = new XSubSequence(this._scene,this._abosoluteUrl);
- return c._centerNode.name = s + "_" + this._centerNode.name,
- c._animGroup.name = s + "_" + this._animGroup.name,
- this._meshGroups.forEach(d=>{
- const _ = d.clone(s + "_", c._centerNode)
- , b = _.getChildren(void 0, !1);
- if (b.forEach(k=>{
- k.setEnabled(!0)
- }
- ),
- b.push(_),
- _) {
- const k = d.getChildren(void 0, !1);
- k.push(d),
- this.animGroup.targetedAnimations.forEach(j=>{
- if (j.target instanceof Node$2) {
- const $ = k.indexOf(j.target);
- $ != -1 && c._animGroup.addTargetedAnimation(j.animation, b[$])
- }
- }
- )
- }
- }
- ),
- c._loaded = !0,
- c
- }
- ,
- this.goToFrame = s=>{
- this._animGroup.start(!0, 1, s, s)
- }
- ,
- this.pause = ()=>{
- this._isPaused = !0,
- this._animGroup.pause()
- }
- ,
- this.reset = ()=>{
- this._animGroup.reset()
- }
- ,
- this.loadTrackToAnim = s=>{
- const c = Array();
- let d = !0;
- s.keyFrame.forEach(b=>{
- if (b.frame > this._endFrame && (this._endFrame = b.frame),
- b.value instanceof Array) {
- const k = {
- frame: b.frame,
- value: new Vector3(0,0,0)
- }
- , j = new Vector3(b.value[0],b.value[1],b.value[2]);
- k.value = j,
- c.push(k)
- } else
- c.push(b),
- d = !1
- }
- ),
- s.loop == null && (s.loop = !1),
- s.index == null && (s.index = 0);
- let _ = null;
- if ("blockName"in s) {
- const b = {
- keyFrame: c,
- blockName: s.blockName,
- property: s.property,
- targetName: s.targetName,
- index: s.index,
- loop: s.loop
- };
- _ = this.transferTrackToAnim(b, d)
- } else {
- const b = {
- keyFrame: c,
- property: s.property,
- targetName: s.targetName,
- index: s.index,
- loop: s.loop
- };
- _ = this.transferTrackToAnim(b, d)
- }
- return _
- }
- ,
- this.transferTrackToAnim = (s,c)=>{
- let d = null;
- c ? (d = new Animation(s.targetName + "_" + s.property,s.property,DEFAULT_FRAME_RATE,Animation.ANIMATIONTYPE_VECTOR3,Animation.ANIMATIONLOOPMODE_CYCLE),
- d.setKeys(s.keyFrame)) : (d = new Animation(s.targetName + "_" + s.property,s.property,DEFAULT_FRAME_RATE,Animation.ANIMATIONTYPE_FLOAT,Animation.ANIMATIONLOOPMODE_CYCLE),
- d.setKeys(s.keyFrame));
- let _ = null;
- return "blockName"in s ? _ = {
- animation: d,
- blockName: s.blockName,
- targetName: s.targetName,
- nodeIndex: s.index,
- loop: s.loop
- } : _ = {
- animation: d,
- targetName: s.targetName,
- nodeIndex: s.index,
- loop: s.loop
- },
- _
- }
- ,
- i.indexOf("./") == 0 && (i = i.slice(2)),
- this._abosoluteUrl = i,
- this._name = i.split("/").slice(-1)[0].split(".")[0].split("_")[1],
- this._rootDir = i.split("/").slice(0, -1).join("/") + "/",
- this._scene = e,
- this._meshGroups = new Map,
- this._animGroup = new AnimationGroup("SubSeqAnim_",this._scene),
- this._particleGroups = new Map,
- this._materialGroups = new Map,
- this._glowGroups = new Map,
- this._highLightGroups = new Map,
- this._spriteGroups = new Map,
- this._endFrame = 0,
- this._centerNode = new TransformNode("__rootSubSeq__",e),
- this._loaded = !1,
- this._isPaused = !0,
- this._isStarted = !1,
- this._centerNode.setEnabled(!1),
- this.urlTransformer = o,
- this._centerNode.onAfterWorldMatrixUpdateObservable.add(()=>{
- this.onSubSequenceTransformationChangeObservable.notifyObservers(this)
- }
- ),
- this._animGroup.onAnimationGroupPlayObservable.add(()=>{
- this._particleGroups.forEach(s=>{
- s.systems.forEach(c=>{
- c.isStarted() || c.start()
- }
- )
- }
- ),
- this.show()
- }
- ),
- this._animGroup.onAnimationGroupLoopObservable.add(()=>{
- this._particleGroups.forEach(s=>{
- s.systems.forEach(c=>{
- c.isStarted() || c.start()
- }
- )
- }
- )
- }
- ),
- this._animGroup.onAnimationGroupEndObservable.add(()=>{
- this.hide()
- }
- )
- }
- dispose() {
- this._isDisposing = !0,
- this._spriteGroups.forEach(e=>{
- e.dispose()
- }
- ),
- this._glowGroups.forEach(e=>{
- e.dispose()
- }
- ),
- this._highLightGroups.forEach(e=>{
- e.dispose()
- }
- ),
- this._particleGroups.forEach(e=>{
- XParticleManager.disposeParticleSysSet(e)
- }
- ),
- this._animGroup.stop(),
- this._animGroup.dispose(),
- this._meshGroups.forEach(e=>{
- e.getChildren(void 0, !1).forEach(i=>{
- var o, s;
- (i.getClassName() === "AbstractMesh" || i.getClassName() === "Mesh") && ((o = i.skeleton) == null || o.dispose(),
- (s = i.material) == null || s.dispose(!0, !0)),
- i.dispose(!0, !0)
- }
- ),
- e.dispose(!1, !0)
- }
- ),
- this._centerNode.dispose(!1, !0),
- this._materialGroups.forEach(e=>{}
- ),
- this._materialGroups.clear(),
- this._spriteGroups.clear(),
- this._glowGroups.clear(),
- this._highLightGroups.clear(),
- this._meshGroups.clear(),
- this._particleGroups.clear(),
- this._loaded = !1
- }
- get animGroup() {
- return this._animGroup
- }
- get name() {
- return this._name
- }
- get path() {
- return this._abosoluteUrl
- }
- get position() {
- return xversePosition2Ue4(this.pos)
- }
- get rotation() {
- return xverseRotation2Ue4(this.rot)
- }
- get scaling() {
- return this.scal
- }
- get pos() {
- return this._centerNode.position
- }
- get rot() {
- return this._centerNode.rotation
- }
- get scal() {
- return this._centerNode.scaling
- }
- get root() {
- return this._centerNode
- }
- get loaded() {
- return this._loaded
- }
- get isPlaying() {
- return this._animGroup ? this._animGroup.isPlaying : this._isStarted && !this._isPaused
- }
- get isStarted() {
- return this._animGroup ? this._animGroup.isStarted : this._isStarted
- }
- get isPickable() {
- return this._pickable
- }
- set isPickable(e) {
- this._meshGroups.forEach(i=>{
- i.getChildMeshes().forEach(o=>{
- o.isPickable = e
- }
- )
- }
- ),
- this._spriteGroups.forEach(i=>{
- i.isPickable = e,
- i.sprites.forEach(o=>{
- o.isPickable = e
- }
- )
- }
- ),
- this._pickable = e
- }
- addAnimation(e) {
- this._animGroup.addTargetedAnimation(e, this._centerNode),
- this._spriteGroups.forEach(i=>{
- i.sprites.forEach(o=>{
- this._animGroup.addTargetedAnimation(e, o)
- }
- )
- }
- )
- }
- setStartFrame(e) {
- this._animGroup.stop(),
- this._animGroup.targetedAnimations.forEach(i=>{
- const o = i.animation.getKeys();
- o.forEach(s=>{
- e + o[0].frame > 0 ? s.frame += e : s.frame -= o[0].frame
- }
- )
- }
- )
- }
- lookAt(e) {
- ue4Position2Xverse(e) && this.root.lookAt(ue4Position2Xverse(e))
- }
- setPosition(e) {
- this.setPositionVector(ue4Position2Xverse(e))
- }
- setPositionVector(e) {
- this._centerNode.position = e,
- this._particleGroups.forEach(i=>{
- i.emitterNode == null || i.emitterNode instanceof Vector3 ? i.emitterNode = e : this._scene.getMeshByName(i.emitterNode.name) || (i.emitterNode = e)
- }
- ),
- this._spriteGroups.forEach(i=>{
- i.sprites.forEach((o,s)=>{
- o.position = e
- }
- )
- }
- )
- }
- setScaling(e) {
- this.setScalingVector(ue4Scaling2Xverse(e))
- }
- setScalingVector(e) {
- var i;
- this._centerNode.scaling = e,
- (i = this._particleGroups) == null || i.forEach(o=>{
- o.systems.forEach(s=>{
- XParticleManager.scalingInPlace(s, e.x)
- }
- )
- }
- ),
- this._spriteGroups.forEach(o=>{
- o.sprites.forEach(s=>{
- s.size *= e.x
- }
- )
- }
- )
- }
- setRotation(e) {
- this.setRotationVector(ue4Rotation2Xverse(e))
- }
- setRotationVector(e) {
- this._centerNode.rotation = e
- }
- hide() {
- this._centerNode.setEnabled(!1),
- this._particleGroups.forEach(e=>{
- e.systems.forEach(i=>{
- i.isStarted() && i.stop()
- }
- )
- }
- ),
- this._spriteGroups.forEach(e=>{
- e.sprites.forEach(i=>{
- i.isVisible = !1
- }
- )
- }
- )
- }
- show() {
- this._centerNode.setEnabled(!0),
- this._centerNode.getChildren().forEach(e=>{
- e.setEnabled(!0),
- e.getChildMeshes().forEach(i=>{
- i.setEnabled(!0)
- }
- )
- }
- ),
- this._particleGroups.forEach(e=>{
- e.systems.forEach(i=>{
- i.start()
- }
- )
- }
- ),
- this._spriteGroups.forEach(e=>{
- e.sprites.forEach(i=>{
- i.isVisible = !0
- }
- )
- }
- )
- }
- get totalFrame() {
- return this._endFrame
- }
- load(e) {
- return new Promise((i,o)=>{
- const s = e.Mesh
- , c = e.Sprite
- , d = e.Material
- , _ = e.Glow
- , b = e.HighLight
- , k = e.Particle
- , j = e.MeshTrack
- , $ = e.ParticleTrack
- , _e = e.MaterialTrack;
- this._animGroup.name += e.Type;
- const et = Date.now();
- this._centerNode.name += e.Type;
- const tt = new Array
- , rt = new Array;
- s != null && s.forEach(it=>{
- tt.push(this.loadMesh(it))
- }
- ),
- c != null && c.forEach(it=>{
- rt.push(this.loadSprite(it))
- }
- ),
- Promise.all(tt).then(()=>{
- d != null && d.forEach(it=>{
- rt.push(this.loadMaterial(it))
- }
- ),
- k != null && k.forEach(it=>{
- rt.push(this.loadParticle(it))
- }
- ),
- Promise.all(rt).then(()=>{
- if (this._isDisposing) {
- const nt = Date.now() - et;
- log$C.info(`subSequence: Load ${e.Type} takes ${nt} ms`),
- i(this);
- return
- }
- if (_ != null)
- for (const nt of _)
- this.loadGlow(nt);
- if (b != null)
- for (const nt of b)
- this.loadHighLight(nt);
- j != null && j.forEach(nt=>{
- const ot = this._meshGroups.get(nt.targetName);
- if (ot != null) {
- const at = this.loadTrackToAnim(nt);
- ROOT_MESH_ANIM_PROPERTY.indexOf(at.animation.targetProperty) == -1 ? ot.getChildMeshes().forEach(st=>{
- at.animation.targetProperty in st && this._animGroup.addTargetedAnimation(at.animation, st)
- }
- ) : this._animGroup.addTargetedAnimation(at.animation, ot)
- }
- }
- ),
- $ != null && $.forEach(nt=>{
- var ut;
- const ot = nt.index
- , at = nt.targetName
- , st = (ut = this._particleGroups.get(at)) == null ? void 0 : ut.systems[ot];
- if (st != null) {
- const ct = this.loadTrackToAnim(nt);
- this._animGroup.addTargetedAnimation(ct.animation, st)
- }
- }
- ),
- _e != null && _e.forEach(nt=>{
- const ot = this._materialGroups.get(nt.targetName);
- if (ot) {
- const at = ot[0];
- if (at != null)
- if (at.getBlockByName(nt.blockName) != null) {
- const st = this.loadTrackToAnim(nt);
- ot == null || ot.forEach(ut=>{
- this._animGroup.addTargetedAnimation(st.animation, ut.getBlockByName(nt.blockName))
- }
- )
- } else
- console.error("property " + nt.property + "is not in " + at.name)
- }
- }
- );
- const it = Date.now() - et;
- log$C.info(`subSequence: Load ${e.Type} takes ${it} ms`),
- i(this)
- }
- , ()=>{
- log$C.error(`subSequence: Load ${e.Type} fail`),
- o()
- }
- )
- }
- , ()=>{
- o()
- }
- )
- }
- )
- }
- loadMesh(e) {
- return new Promise((i,o)=>{
- const s = this._rootDir + e.uri;
- this.urlTransformer(s).then(c=>{
- if (this._isDisposing) {
- i();
- return
- }
- SceneLoader.LoadAssetContainer("", c, this._scene, d=>{
- if (this._isDisposing) {
- d.removeAllFromScene(),
- i();
- return
- }
- d.animationGroups.forEach(b=>{
- b.stop()
- }
- ),
- d.animationGroups.length != 0 && (d.animationGroups.forEach(b=>{
- b.targetedAnimations.forEach(k=>{
- this._animGroup.addTargetedAnimation(k.animation, k.target)
- }
- ),
- b.dispose()
- }
- ),
- d.animationGroups = [],
- d.animations = [],
- d.materials = []);
- const _ = new TransformNode("__root__" + e.name,this._scene);
- if (e.uri.split(".")[1] == "glb")
- d.meshes[0].parent = _;
- else if (e.uri.split(".")[1] == "obj") {
- const b = new TransformNode("__root__",this._scene);
- d.meshes.forEach(k=>{
- k.parent = b,
- k.Type = MESH_TAG
- }
- ),
- b.parent = _
- }
- _.getChildMeshes().forEach(b=>{
- e.isPickable != null ? b.isPickable = e.isPickable : b.isPickable = !1,
- b.xtype = "XSubSequence"
- }
- ),
- this._meshGroups.set(e.name, _),
- _.parent = this._centerNode,
- d.addAllToScene(),
- i()
- }
- , ()=>{}
- , ()=>{
- log$C.error("subSequence:Load effect mesh fail"),
- log$C.error(`Effect Mesh ${e.name} load error`),
- o()
- }
- , ".glb")
- }
- , ()=>{
- log$C.error("http:Get effect mesh fail"),
- log$C.error(`Effect Mesh ${e.name} load error`),
- o()
- }
- )
- }
- )
- }
- loadSprite(e) {
- return new Promise((i,o)=>{
- if (this._isDisposing) {
- i();
- return
- }
- const s = this._rootDir + e.uri;
- if (e.uri !== "") {
- e.name;
- const c = new XMLHttpRequest;
- c.open("get", s),
- c.send(null),
- c.onload = ()=>{
- if (c.status == 200) {
- const d = JSON.parse(c.responseText)
- , _ = XSpriteManager.Parse(d, this._scene, this._rootDir);
- _.sprites.forEach(b=>{
- b.stopAnimation()
- }
- ),
- this._spriteGroups.set(e.name, _),
- i()
- } else
- log$C.error("subSequence:Load effect sprite fail"),
- log$C.error(`Effect Sprite ${e.name} load error`),
- o()
- }
- }
- }
- )
- }
- loadMaterial(e) {
- return new Promise((i,o)=>{
- if (this._isDisposing) {
- i();
- return
- }
- const s = this._rootDir + e.uri;
- if (e.uri !== "") {
- const c = e.name
- , d = new NodeMaterial(`material_${c}`,this._scene,{
- emitComments: !1
- });
- d.backFaceCulling = !1,
- this.urlTransformer(s).then(_=>{
- if (this._isDisposing) {
- d.dispose(!1, !0, !1),
- i();
- return
- }
- d.loadAsync(_).then(()=>{
- if (this._isDisposing) {
- d.dispose(!0, !0, !1),
- i();
- return
- }
- d.build(!1);
- const b = new Array;
- let k = !1;
- for (let j = 0; j < e.meshName.length; j++)
- this._meshGroups.forEach($=>{
- $.getChildMeshes().forEach(_e=>{
- var et;
- if (_e.name === e.meshName[j]) {
- k = !0,
- (et = _e.material) == null || et.dispose(!0, !0);
- const tt = _e;
- if (tt.skeleton == null) {
- const rt = d;
- tt.material = rt,
- b.push(rt)
- } else if (tt.numBoneInfluencers = 4,
- tt.computeBonesUsingShaders = !0,
- j == 0) {
- const rt = d;
- tt.material = rt,
- b.push(rt)
- } else {
- const rt = d.clone(`material_${c}` + String(j), !1);
- tt.material = rt,
- b.push(rt)
- }
- }
- }
- )
- }
- );
- k ? this._materialGroups.set(e.name, b) : d.dispose(!0, !0),
- i()
- }
- , ()=>{
- log$C.error("http:Get effect Material fail"),
- log$C.error(`Effect NodeMaterial ${c} load error`),
- o()
- }
- )
- }
- )
- }
- }
- )
- }
- async loadGlow(e) {
- const i = new GlowLayer(e.name,this._scene,{
- blurKernelSize: e.blurKernelSize
- });
- i.intensity = e.intensity,
- e.meshName.forEach(o=>{
- const s = this._scene.getMeshByName(o);
- s != null && i.addIncludedOnlyMesh(s)
- }
- ),
- this._glowGroups.set(e.name, i)
- }
- loadHighLight(e) {
- const i = new HighlightLayer(e.name,this._scene);
- e.meshName.forEach(o=>{
- const s = this._scene.getMeshByName(o);
- if (s != null) {
- const c = new Color3(e.color[0],e.color[1],e.color[2]);
- i.addMesh(s, c)
- }
- }
- ),
- this._highLightGroups.set(e.name, i)
- }
- loadParticle(e) {
- return new Promise((i,o)=>{
- const s = this._rootDir + e.rootDir
- , c = new XParticleManager(this._scene);
- this.urlTransformer(s + e.uri).then(d=>{
- if (this._isDisposing) {
- i();
- return
- }
- c.load(s, e.uri, e.name).then(_=>{
- if (this._isDisposing) {
- o();
- return
- }
- this._particleGroups.set(e.name, _),
- i()
- }
- , ()=>{
- log$C.error(`SubSequence: ${e.name} particle load fail`),
- o()
- }
- )
- }
- , ()=>{
- log$C.error(`http: ${s + e.uri} load fail`),
- o()
- }
- )
- }
- )
- }
- }
- const DefaultUrlTransformer = async a=>a;
- class XSequence {
- constructor(e, i, o="test", s=DefaultUrlTransformer) {
- this.init = async()=>new Promise(c=>{
- this.urlTransformer(this._abosoluteUrl).then(d=>{
- const _ = new XMLHttpRequest;
- _.open("get", d),
- _.send(null),
- _.onload = ()=>{
- if (_.status == 200) {
- const b = JSON.parse(_.responseText);
- this.load(b).then(()=>{
- c()
- }
- )
- }
- }
- }
- )
- }
- ),
- this.getRootOfSubSeqs = ()=>{
- const c = new Array;
- return this._subSeqs.forEach(d=>{
- c.push(d.root)
- }
- ),
- c
- }
- ,
- this.play = async(c=!0)=>new Promise(d=>{
- this._animGroup.play(c),
- c ? this._animGroup.onAnimationGroupLoopObservable.addOnce(()=>{
- d()
- }
- ) : this._animGroup.onAnimationGroupEndObservable.addOnce(()=>{
- d()
- }
- )
- }
- ),
- this.goToFrame = c=>{
- this._animGroup.goToFrame(c)
- }
- ,
- this.hide = ()=>{
- this._subSeqs.forEach(c=>{
- c.hide()
- }
- )
- }
- ,
- this.show = ()=>{
- this._subSeqs.forEach(c=>{
- c.show()
- }
- )
- }
- ,
- this.pause = ()=>{
- this._animGroup.pause()
- }
- ,
- this.reset = ()=>{
- this._animGroup.reset()
- }
- ,
- this._scene = e,
- this._abosoluteUrl = i,
- this._rootDir = i.split("/").slice(0, -1).join("/") + "/",
- this._name = o,
- this._subSeqs = new Map,
- this._animGroup = new AnimationGroup("Seq_" + o,e),
- this._targetSubSeqs = new Map,
- this._animGroup.onAnimationGroupPlayObservable.add(()=>{
- this._subSeqs.forEach(c=>{
- c.show()
- }
- )
- }
- ),
- this._animGroup.onAnimationGroupEndObservable.add(()=>{
- this._subSeqs.forEach(c=>{
- c.hide()
- }
- )
- }
- ),
- this.urlTransformer = s
- }
- get animGroup() {
- return this._animGroup
- }
- serialize() {
- const e = {};
- return e.SubSequence = new Array,
- e.TimeLine = new Array,
- this._subSeqs.forEach(i=>{
- const o = {
- name: i.name,
- uri: i.path
- };
- e.SubSequence.push(o);
- const s = this._targetSubSeqs.get(i);
- s && e.TimeLine.push({
- frame: s == null ? void 0 : s.frame,
- position: s.position,
- rotation: s.rotation,
- scaling: s.scaling,
- name: i.name
- })
- }
- ),
- e
- }
- get isPlaying() {
- return this._animGroup.isPlaying
- }
- get isStarted() {
- return this._animGroup.isStarted
- }
- get loaded() {
- let e = !0;
- return this._subSeqs.forEach(i=>{
- e = e && i.loaded
- }
- ),
- e
- }
- dispose() {
- this._subSeqs.forEach(e=>{
- e.dispose()
- }
- ),
- this.animGroup.dispose()
- }
- setFrame(e, i) {
- const o = this._subSeqs.get(e);
- if (o) {
- const s = this._targetSubSeqs.get(o);
- s && (s.frame = i),
- s && this.update(o, s)
- }
- }
- get name() {
- return this._name
- }
- update(e, i) {
- if (i) {
- const o = {
- frame: i.frame,
- scaling: new Vector3(i.scaling[0],i.scaling[1],i.scaling[2]),
- position: new Vector3(i.position[0],i.position[1],i.position[2]),
- rotation: new Vector3(i.rotation[0] / 180 * Math.PI,i.rotation[1] / 180 * Math.PI,i.rotation[2] / 180 * Math.PI),
- name: i.name
- }
- , s = this._subSeqs.get(o.name);
- s && (s.setPositionVector(o.position),
- s.setRotationVector(o.rotation),
- s.setScalingVector(o.scaling),
- s.setStartFrame(o.frame),
- this._targetSubSeqs.set(s, i),
- s.onSubSequenceTransformationChangeObservable.add(()=>{
- const c = this._targetSubSeqs.get(s);
- c && (c.position = [s.pos.x, s.pos.y, s.pos.z]),
- c && (c.rotation = [s.rot.x, s.rot.y, s.rot.z]),
- c && (c.scaling = [s.scal.x, s.scal.y, s.scal.z])
- }
- ))
- }
- }
- load(e) {
- return new Promise((i,o)=>{
- const s = new Array
- , c = e.SubSequence
- , d = e.TimeLine;
- for (const _ of c) {
- _.uri.indexOf("./") == 0 && (_.uri = _.uri.slice(2));
- const b = new XSubSequence(this._scene,this._rootDir + _.uri,this.urlTransformer);
- this._subSeqs.set(_.name, b),
- s.push(b.init())
- }
- Promise.all(s).then(()=>{
- d.forEach(_=>{
- const b = this._subSeqs.get(_.name);
- b && this.update(b, _)
- }
- ),
- this._subSeqs.forEach(_=>{
- _.animGroup.targetedAnimations.forEach(b=>{
- this._animGroup.addTargetedAnimation(b.animation, b.target)
- }
- )
- }
- ),
- i()
- }
- , ()=>{
- o()
- }
- )
- }
- )
- }
- }
- const log$B = new Logger$1("XStaticMesh");
- class XStaticMesh {
- constructor({id: e, mesh: i, group: o="default", lod: s=0, xtype: c=EMeshType.XStaticMesh, skinInfo: d="default", url: _=""}) {
- this._mesh = void 0,
- this._id = "-1",
- this._isMoving = !1,
- this._isRotating = !1,
- this._isVisible = !0,
- this.setVisibility = (b,k)=>{
- Array.isArray(b) ? b.forEach(j=>{
- this.setVisibility(j, k)
- }
- ) : b.isAnInstance || (b.visibility = k)
- }
- ,
- this.setPickable = (b,k)=>{
- Array.isArray(b) ? b.forEach(j=>{
- this.setPickable(j, k)
- }
- ) : ("isPickable"in b && (b.isPickable = k),
- b.setEnabled(k))
- }
- ,
- this.hide = ()=>{
- var b;
- this._isVisible = !1,
- this.mesh && this.setVisibility(this.mesh, 0),
- this.mesh && this.setPickable(this.mesh, !1),
- (b = this.mesh) == null || b.getChildMeshes().forEach(k=>{
- this.setVisibility(k, 0),
- this.setPickable(k, !1)
- }
- )
- }
- ,
- this.show = ()=>{
- var b;
- this._isVisible = !0,
- this.mesh && this.setVisibility(this.mesh, 1),
- this.mesh && this.setPickable(this.mesh, !0),
- (b = this.mesh) == null || b.getChildMeshes().forEach(k=>{
- this.setVisibility(k, 1),
- this.setPickable(k, !0)
- }
- )
- }
- ,
- this.attachToAvatar = (b,k={
- x: 0,
- y: .5,
- z: 0
- },j={
- yaw: 0,
- pitch: 0,
- roll: 0
- },$={
- x: .35,
- y: .35,
- z: .35
- })=>{
- const _e = ue4Scaling2Xverse($)
- , et = ue4Rotation2Xverse(j)
- , tt = ue4Position2Xverse(k)
- , rt = this._mesh;
- b && rt ? (b.setParent(rt),
- b.position = tt,
- b.rotation = et,
- b.scaling = _e) : log$B.error("[Engine] avatar or attachment not found!")
- }
- ,
- this.detachFromAvatar = (b,k=!1)=>{
- this._mesh && b ? this._mesh.removeChild(b) : log$B.error("[Engine] avatar not found!")
- }
- ,
- this._id = e,
- this._mesh = i,
- this._group = o,
- this._lod = s,
- this._skinInfo = d,
- this.unallowMove(),
- this._mesh.xtype = c,
- this._mesh.xid = e,
- this._mesh.xgroup = this._group,
- this._mesh.xlod = this._lod,
- this._mesh.xskinInfo = this._skinInfo,
- this._mesh.xurl = _
- }
- get mesh() {
- return this._mesh
- }
- get position() {
- var c;
- if (!this._mesh)
- return null;
- const {x: e, y: i, z: o} = (c = this._mesh) == null ? void 0 : c.position;
- return xversePosition2Ue4({
- x: e,
- y: i,
- z: o
- })
- }
- get id() {
- return this._id
- }
- get group() {
- return this._group
- }
- get isMoving() {
- return this._isMoving
- }
- get isVisible() {
- return this._isVisible
- }
- get isRotating() {
- return this._isRotating
- }
- get skinInfo() {
- return this._skinInfo
- }
- allowMove() {
- this._mesh != null && (this._mesh.getChildMeshes().forEach(e=>{
- e.unfreezeWorldMatrix()
- }
- ),
- this._mesh.unfreezeWorldMatrix())
- }
- unallowMove() {
- this._mesh != null && (this._mesh.getChildMeshes().forEach(e=>{
- e.freezeWorldMatrix()
- }
- ),
- this._mesh.freezeWorldMatrix())
- }
- getID() {
- return this._id
- }
- setPosition(e) {
- if (this._mesh) {
- const i = ue4Position2Xverse(e);
- this._mesh.position = i
- } else
- log$B.error("[Engine] no root for positioning")
- }
- setRotation(e) {
- const i = ue4Rotation2Xverse_mesh(e);
- this._mesh ? this._mesh.rotation = i : log$B.error("[Engine] no root for rotating")
- }
- setScale(e) {
- this._mesh ? this._mesh.scaling = new Vector3(e,e,-e) : log$B.error("[Engine] no root for scaling")
- }
- disableAvatar() {
- var e;
- (e = this._mesh) == null || e.setEnabled(!1)
- }
- enableAvatar() {
- var e;
- (e = this._mesh) == null || e.setEnabled(!0)
- }
- togglePickable(e) {
- var i;
- (i = this.mesh) == null || i.getChildMeshes().forEach(o=>{
- "instances"in o && "isPickable"in o && (o.isPickable = e)
- }
- ),
- this.mesh != null && "isPickable"in this.mesh && (this.mesh.isPickable = e)
- }
- setMaterial(e) {
- var i;
- (i = this.mesh) == null || i.getChildMeshes().forEach(o=>{
- "instances"in o && "material"in o && (o.material = e)
- }
- ),
- this.mesh != null && "material"in this.mesh && (this.mesh.material = e)
- }
- dispose(e=!1, i=!1) {
- !this.mesh.isDisposed() && this.mesh.dispose(e, i)
- }
- }
- class Timeout$1 {
- constructor(e, i, o=!0) {
- this._fn = e,
- this._delay = i,
- o && this.start()
- }
- get delay() {
- return this._delay
- }
- get isSet() {
- return !!this._timeout
- }
- setDelay(e) {
- this._delay = e
- }
- start() {
- this.isSet || (this._timeout = window.setTimeout(()=>{
- const e = this._fn;
- this.clear(),
- e()
- }
- , this._delay))
- }
- clear() {
- window.clearTimeout(this._timeout),
- this._timeout = void 0
- }
- reset() {
- this.clear(),
- this.start()
- }
- }
- class Stream$1 {
- constructor(e) {
- if (this._streamPlayTimer = null,
- this.play = ()=>new Promise((i,o)=>{
- this._streamPlayTimer = new Timeout$1(()=>{
- o("Stream play timeout")
- }
- ,5e3),
- this.el && this.el.play().then(()=>{
- var s;
- i(),
- (s = this._streamPlayTimer) == null || s.clear()
- }
- ).catch(s=>{
- var c;
- o("Media Failed to autoplay"),
- (c = this._streamPlayTimer) == null || c.clear()
- }
- )
- }
- ),
- !e) {
- this.el = this.createVideoElement();
- return
- }
- this.el = e
- }
- createVideoElement() {
- const e = document.createElement("video");
- return e.muted = !0,
- e.autoplay = !1,
- e.playsInline = !0,
- e.width = 360,
- e.height = 640,
- e.setAttribute("autostart", "false"),
- e.setAttribute("controls", "controls"),
- e.setAttribute("muted", "true"),
- e.setAttribute("preload", "auto"),
- e.setAttribute("hidden", "hidden"),
- document.body.appendChild(e),
- e
- }
- }
- var tvFragment = `precision highp float;
-
- varying vec2 vUV;
- uniform float tvWidthHeightScale;
- uniform float mvWidthHeightScale;
- uniform float bforceforceKeepContent;
-
- uniform sampler2D texture_video;
- // \u7B49\u6BD4\u4F8B\u7F29\u653E\u753B\u9762\u5360\u6EE1\u5C4F\u5E55\uFF0C\u5B58\u5728\u5185\u5BB9\u7684\u4E22\u5931
- vec2 equalScalingFitTvSize(vec2 uv, float tvWidthHeightScale, float mvWidthHeightScale)
- {
- if( tvWidthHeightScale > mvWidthHeightScale )
- {
- float scale = mvWidthHeightScale/tvWidthHeightScale;
- uv.y = (uv.y - 0.5) * scale + 0.5;
- }else if( tvWidthHeightScale < mvWidthHeightScale )
- {
- float scale = tvWidthHeightScale/mvWidthHeightScale;
- uv.x = (uv.x - 0.5) * scale + 0.5;
- }
- return vec2( uv.x , uv.y);
- }
- // \u5F3A\u5236\u4FDD\u7559\u753B\u9762\u5185\u5BB9\uFF08\u5E26\u6709\u9ED1\u8FB9\uFF09
- vec2 forceKeepContent(vec2 uv, float tvWidthHeightScale, float mvWidthHeightScale)
- {
- if( tvWidthHeightScale > mvWidthHeightScale )
- {
- float scale = mvWidthHeightScale/tvWidthHeightScale;
- uv.x = (uv.x - 0.5) / scale + 0.5;
- }else if( tvWidthHeightScale < mvWidthHeightScale )
- {
- float scale = tvWidthHeightScale/mvWidthHeightScale;
- uv.y = (uv.y - 0.5) / scale + 0.5;
- }
- return vec2( uv.x , uv.y);
- }
- void main()
- {
- vec2 uv = vUV;
- vec3 rgb;
- vec3 color = vec3(0,0,0);
- // \u4E00\u65E6\u8BBE\u7F6E\u4E86mvWidthHeightScale\uFF0C\u5C31\u4F1A\u89E6\u53D1\u7B49\u6BD4\u4F8B\u7F29\u653Eor\u5F3A\u5236\u4FDD\u5185\u5BB9
- if(tvWidthHeightScale > 0.0 && mvWidthHeightScale > 0.0)
- {
- if(bforceforceKeepContent > 0.0){
- uv = forceKeepContent(uv, tvWidthHeightScale, mvWidthHeightScale);
- }else{
- uv = equalScalingFitTvSize(uv, tvWidthHeightScale, mvWidthHeightScale);
- }
- }
-
- color = texture2D(texture_video, uv).rgb;
-
- if( uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0 )
- {
- color = vec3(0,0,0);
- }
- gl_FragColor = vec4(color, 1.0);
- }
- `
- , tvVertex = `precision highp float;
-
- varying vec2 vUV;
- attribute vec2 uv;
- attribute vec3 position;
-
- uniform mat4 view;
- uniform mat4 projection;
- uniform mat4 world;
- void main()
- {
- vUV = uv;
- gl_Position = projection * view * world * vec4(position , 1.0);
- }
- `;
- const log$A = new Logger$1("XTelevision");
- var EFitMode = (a=>(a.fill = "fill",
- a.contain = "contain",
- a.cover = "cover",
- a))(EFitMode || {});
- class XTelevision {
- constructor(e, i, o, s) {
- if (this.tvMeshs = [],
- this.scene = e,
- this.meshPath = i,
- this._scenemanager = o,
- s != null) {
- const {vAng: c=0, widthHeightScale: d=-1, fitMode: _="fill"} = s;
- this.vAng = c,
- this.widthHeightScale = d,
- this.fitMode = _
- }
- }
- set tvWidthHeightscale(e) {
- this.widthHeightScale = e
- }
- get tvWidthHeightscale() {
- return this.widthHeightScale
- }
- get tvFitMode() {
- return this.fitMode
- }
- set tvFitMode(e) {
- this.fitMode = e
- }
- setPlaySpeed(e) {
- this.videoElement != null && (this.videoElement.playbackRate = e)
- }
- getMesh() {
- return this.tvMeshs
- }
- createElement(e, i=!1) {
- const s = new Stream$1().el;
- return s.loop = i,
- s.autoplay = !0,
- s.src = e,
- s
- }
- async setUrl(e) {
- const {url: i, isLive: o=!1, poster: s=null, bLoop: c=!1, bMuted: d=!0} = e || {};
- if (typeof i != "string")
- return log$A.error("[Engine] Tv setUrl Error, url must be string: ", i),
- Promise.reject(new XTvMediaUrlError("[Engine] url must be string"));
- if (this.videoElement) {
- this.videoElement.src = i,
- s != null && s.length > 0 && (this.videoElement.poster = s);
- const b = this.play();
- return "bMuted"in e && b !== void 0 && b.then(()=>{
- this.videoElement.muted = d
- }
- ),
- this.videoElement.addEventListener("loadedmetadata", k=>{
- this.videoElement.videoWidth > 0 ? this.videoMat.setFloat("mvWidthHeightScale", this.videoElement.videoWidth / this.videoElement.videoHeight) : this.videoMat.setFloat("mvWidthHeightScale", 16 / 9)
- }
- ),
- Promise.resolve(this)
- }
- const _ = this.createElement(i, c);
- return s != null && s.length > 0 && (_.poster = s),
- this.setVideo(_, o).then(()=>{
- var k;
- const b = (k = this.videoElement) == null ? void 0 : k.play();
- "bMuted"in e && b !== void 0 && b.then(()=>{
- this.videoElement.muted = d
- }
- )
- }
- ).catch(b=>{
- const k = new XTvMediaUrlError("[Engine] setUrl error! " + b);
- return log$A.error(k),
- Promise.reject(k)
- }
- )
- }
- setCurrentTime(e) {
- if (!this.videoElement) {
- log$A.warn("[Engine] The television is not been initialize succesfully");
- return
- }
- const {currentTime: i} = e;
- if (typeof i != "number") {
- log$A.warn("[Engine] video currentTime must be number");
- return
- }
- this.videoElement.currentTime = i / 1e3
- }
- getCurrentTime() {
- return this.videoElement ? this.videoElement.currentTime * 1e3 : -1
- }
- play() {
- return log$A.info("[Engine] Play television"),
- this.toggle(!0),
- this.videoElement ? this.videoElement.play() : Promise.resolve()
- }
- pause() {
- var e;
- return log$A.info("[Engine] Pause television"),
- (e = this.videoElement) == null ? void 0 : e.pause()
- }
- stop() {
- log$A.info("[Engine] Stop television"),
- this.pause(),
- setTimeout(()=>{
- this.setCurrentTime({
- currentTime: 0
- })
- }
- ),
- this.toggle(!1)
- }
- toggle(e) {
- log$A.info(`[Engine] Set Tv visibility = ${e}`);
- for (let i = 0; i < this.tvMeshs.length; ++i)
- e == !0 ? this.tvMeshs[i].show() : this.tvMeshs[i].hide()
- }
- getVideoMat() {
- return this.videoMat
- }
- changeTvFitMode() {
- this.fitMode == "contain" ? (this.widthHeightScale < 0 && (this.widthHeightScale = 2.4),
- this.videoMat.setFloat("tvWidthHeightScale", this.widthHeightScale),
- this.videoMat.setFloat("bforceforceKeepContent", 1)) : this.fitMode == "cover" ? (this.widthHeightScale < 0 && (this.widthHeightScale = this.calWidthHeightScale()),
- this.videoMat.setFloat("tvWidthHeightScale", this.widthHeightScale),
- this.videoMat.setFloat("bforceforceKeepContent", -1)) : this.videoMat.setFloat("tvWidthHeightScale", -1)
- }
- async setVideo(e, i=!1, o=!0) {
- return this.tvMeshs.length != 0 ? (log$A.warn(`[Engine] Set Video. length!=0, mesh: ${this.meshPath}, src: ${e.src}`),
- new Promise((s,c)=>{
- if (!(e instanceof HTMLVideoElement))
- return log$A.error("[Engine] Error, param of setVideo must be a HTMLVideoElement"),
- c(new XTvVideoElementError("[Engine] param of setVideo must be a HTMLVideoElement"));
- this.videoElement = e,
- o == !1 && (i == !1 || checkOS().isIOS) && e.crossOrigin !== "anonymous" && (e.crossOrigin = "anonymous",
- e.load()),
- this.videoElement.addEventListener("loadedmetadata", d=>{
- this.videoElement.videoWidth > 0 ? this.videoMat.setFloat("mvWidthHeightScale", this.videoElement.videoWidth / this.videoElement.videoHeight) : this.videoMat.setFloat("mvWidthHeightScale", 16 / 9)
- }
- ),
- this.videoTexture.updateURL(this.videoElement.src),
- s(this)
- }
- )) : (log$A.warn(`[Engine] Set Video. length==0, mesh: ${this.meshPath}, src: ${e.src}`),
- this.meshPath == "" ? (log$A.error("[Engine] Error, television meshPath is empty."),
- 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,
- o == !1 && (i == !1 || checkOS().isIOS) && e.crossOrigin !== "anonymous" && (e.crossOrigin = "anonymous",
- e.load()),
- SceneLoader.LoadAssetContainerAsync("", s, this.scene, null, ".glb").then(_=>{
- for (let k = _.materials.length - 1; k >= 0; --k)
- _.materials[k].dispose();
- const b = [];
- this.videoTexture = new VideoTexture("videoTex_" + Date.now(),e,this.scene,!1,!0,void 0,{
- autoPlay: !0,
- autoUpdateTexture: !0,
- muted: !0
- }),
- this.videoTexture.vAng = this.vAng,
- this.videoMat = new ShaderMaterial("videoMat_" + Date.now(),this.scene,{
- vertexSource: tvVertex,
- fragmentSource: tvFragment
- },{
- attributes: ["uv", "position"],
- uniforms: ["view", "projection", "worldViewProjection", "world"]
- }),
- this.videoMat.setTexture("texture_video", this.videoTexture),
- this.videoMat.setFloat("tvWidthHeightScale", -1),
- this.videoMat.setFloat("mvWidthHeightScale", 16 / 9),
- this.videoMat.setFloat("bforceforceKeepContent", -1),
- this.videoMat.backFaceCulling = !1,
- this.videoMat.sideOrientation = Mesh.FRONTSIDE,
- this.videoElement.addEventListener("loadedmetadata", k=>{
- this.videoElement.videoWidth > 0 ? this.videoMat.setFloat("mvWidthHeightScale", this.videoElement.videoWidth / this.videoElement.videoHeight) : this.videoMat.setFloat("mvWidthHeightScale", 16 / 9)
- }
- );
- for (let k = 0; k < _.meshes.length; ++k)
- _.meshes[k].visibility = 1,
- _.meshes[k].isPickable = !0,
- _.meshes[k].checkCollisions = !1,
- _.meshes[k].material = this.videoMat,
- "hasVertexAlpha"in _.meshes[k] && (_.meshes[k].hasVertexAlpha = !1),
- this.scene.addMesh(_.meshes[k]),
- b.push(new XStaticMesh({
- id: _.meshes[k].id,
- mesh: _.meshes[k],
- xtype: EMeshType.Tv
- }));
- this.changeTvFitMode(),
- this.tvMeshs = b,
- this.toggle(!0),
- c(this)
- }
- ).catch(_=>{
- log$A.error("[Engine] setVideo: create Tv by input mesh error! " + _),
- d(new XTvModelError("[Engine] setVideo: create Tv by input mesh error! " + _))
- }
- )) : d(new XTvVideoElementError("[Engine] param of setVideo must be a HTMLVideoElement")))))
- }
- async setSameVideo(e, i="") {
- return e == null || e == null ? (log$A.error("[Engine] setSameVideo: input material is null or undefined "),
- 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}`),
- new Promise((o,s)=>{
- try {
- this.videoMat = e,
- this.tvMeshs.forEach(c=>{
- c.setMaterial(e)
- }
- ),
- this.changeTvFitMode(),
- o(this)
- } catch (c) {
- log$A.error("[Engine] setSameVideo: create Tv by input mesh error! " + c),
- s(new XTvModelError("[Engine] create Tv by input mesh error! " + c))
- }
- }
- )) : (i != "" && (this.meshPath = i,
- this.widthHeightScale = -1),
- this.meshPath == "" ? (log$A.error("[Engine] Error, setSameVideo television meshPath is empty."),
- Promise.reject(new XTvVideoElementError("[Engine] Error, setSameVideo television meshPath is empty."))) : (log$A.warn(`[Engine] Set mirror video. length==0, mesh: ${this.meshPath}`),
- this._scenemanager.urlTransformer(this.meshPath).then(o=>new Promise((s,c)=>(this.videoMat = e,
- e != null && e.getActiveTextures()[0] && (this.videoElement = e == null ? void 0 : e.getActiveTextures()[0].video),
- SceneLoader.LoadAssetContainerAsync("", o, this.scene, null, ".glb").then(d=>{
- for (let b = d.materials.length - 1; b >= 0; --b)
- d.materials[b].dispose();
- const _ = [];
- for (let b = 0; b < d.meshes.length; ++b)
- d.meshes[b].visibility = 0,
- d.meshes[b].isPickable = !0,
- d.meshes[b].checkCollisions = !1,
- d.meshes[b].material = this.videoMat,
- "hasVertexAlpha"in d.meshes[b] && (d.meshes[b].hasVertexAlpha = !1),
- this.scene.addMesh(d.meshes[b]),
- _.push(new XStaticMesh({
- id: d.meshes[b].id,
- mesh: d.meshes[b],
- xtype: EMeshType.Tv
- }));
- i != "" && this.cleanTv(!1, !1),
- this.tvMeshs = _,
- this.changeTvFitMode(),
- s(this)
- }
- ).catch(d=>{
- log$A.error("[Engine] setSameVideo: create Tv by input mesh error! " + d),
- c(new XTvModelError("[Engine] create Tv by input mesh error! " + d))
- }
- ))))))
- }
- async changeTvModel(e="") {
- return e != "" && (this.meshPath = e,
- this.widthHeightScale = -1),
- this.meshPath == "" ? (log$A.error("[Engine] Error,changeTvModel television meshPath is empty."),
- 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! "),
- 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=>{
- for (let _ = c.materials.length - 1; _ >= 0; --_)
- c.materials[_].dispose();
- const d = [];
- for (let _ = 0; _ < c.meshes.length; ++_)
- c.meshes[_].visibility = 0,
- c.meshes[_].isPickable = !0,
- c.meshes[_].checkCollisions = !1,
- c.meshes[_].material = this.videoMat,
- "hasVertexAlpha"in c.meshes[_] && (c.meshes[_].hasVertexAlpha = !1),
- this.scene.addMesh(c.meshes[_]),
- d.push(new XStaticMesh({
- id: c.meshes[_].id,
- mesh: c.meshes[_],
- xtype: EMeshType.Tv
- }));
- e != "" && this.cleanTv(!1, !1),
- this.tvMeshs = d,
- this.changeTvFitMode(),
- o(this)
- }
- ).catch(c=>{
- log$A.error("[Engine] changeTvModel: create Tv by input mesh error! " + c),
- s(new XTvModelError("[Engine] changeTvModel: create Tv by input mesh error! " + c))
- }
- )))
- }
- calWidthHeightScale() {
- const e = [1e5, 1e5, 1e5]
- , i = [-1e5, -1e5, -1e5];
- for (let d = 0; d < this.tvMeshs.length; ++d)
- if (this.tvMeshs[d].mesh.name != "__root__") {
- const _ = this.tvMeshs[d].mesh.getBoundingInfo().boundingBox.vectorsWorld;
- for (let b = 0; b < _.length; ++b)
- e[0] > _[b].x && (e[0] = _[b].x),
- e[1] > _[b].y && (e[1] = _[b].y),
- e[2] > _[b].z && (e[2] = _[b].z),
- i[0] < _[b].x && (i[0] = _[b].x),
- i[1] < _[b].y && (i[1] = _[b].y),
- i[2] < _[b].z && (i[2] = _[b].z);
- break
- }
- const o = i[0] - e[0]
- , s = i[1] - e[1]
- , c = i[2] - e[2];
- return Math.sqrt(o * o + c * c) / Math.abs(s)
- }
- cleanTv(e=!1, i=!0) {
- log$A.warn("[Engine] cleanTV");
- for (let o = 0; o < this.tvMeshs.length; ++o)
- this.tvMeshs[o].dispose(e, i);
- this.tvMeshs = [],
- this.meshPath = ""
- }
- }
- class XStats {
- constructor(e) {
- this._scenemanager = e,
- this.scene = e.Scene,
- this._canvas = e.canvas,
- this.initSceneInstrument()
- }
- initSceneInstrument() {
- this.sceneInstrumentation = new SceneInstrumentation(this.scene),
- this.sceneInstrumentation.captureCameraRenderTime = !0,
- this.sceneInstrumentation.captureActiveMeshesEvaluationTime = !0,
- this.sceneInstrumentation.captureRenderTargetsRenderTime = !0,
- this.sceneInstrumentation.captureFrameTime = !0,
- this.sceneInstrumentation.captureRenderTime = !0,
- this.sceneInstrumentation.captureInterFrameTime = !0,
- this.sceneInstrumentation.captureParticlesRenderTime = !0,
- this.sceneInstrumentation.captureSpritesRenderTime = !0,
- this.sceneInstrumentation.capturePhysicsTime = !0,
- this.sceneInstrumentation.captureAnimationsTime = !0,
- this.engineInstrumentation = new EngineInstrumentation(this.scene.getEngine()),
- this.caps = this.scene.getEngine().getCaps(),
- this.engine = this.scene.getEngine(),
- this._osversion = this.osVersion()
- }
- getFrameTimeCounter() {
- return this.sceneInstrumentation.frameTimeCounter.current
- }
- getInterFrameTimeCounter() {
- return this.sceneInstrumentation.interFrameTimeCounter.current
- }
- getActiveMeshEvaluationTime() {
- return this.sceneInstrumentation.activeMeshesEvaluationTimeCounter.current
- }
- getDrawCall() {
- return this.sceneInstrumentation.drawCallsCounter.current
- }
- getDrawCallTime() {
- return this.sceneInstrumentation.renderTimeCounter.current
- }
- getAnimationTime() {
- return this.sceneInstrumentation.animationsTimeCounter.current
- }
- getActiveMesh() {
- return this.scene.getActiveMeshes().length
- }
- getActiveFaces() {
- return Math.round(this.scene.getActiveIndices() / 3)
- }
- getActiveBones() {
- return this.scene.getActiveBones()
- }
- getActiveAnimation() {
- return this.scene._activeAnimatables.length
- }
- getActiveParticles() {
- return this.scene.getActiveParticles()
- }
- getTotalMaterials() {
- return this.scene.materials.length
- }
- getTotalTextures() {
- return this.scene.textures.length
- }
- getTotalGeometries() {
- return this.scene.geometries.length
- }
- getTotalMeshes() {
- return this.scene.meshes.length
- }
- getCameraRenderTime() {
- return this.sceneInstrumentation.cameraRenderTimeCounter.current
- }
- getTotalRootNodes() {
- return this.scene.rootNodes.length
- }
- getRenderTargetRenderTime() {
- const e = this.getDrawCallTime()
- , i = this.getActiveMeshEvaluationTime()
- , o = this.getCameraRenderTime() - (i + e);
- return this.getRTT1Time() + o
- }
- getRegisterBeforeRenderTime() {
- return this.sceneInstrumentation.registerBeforeTimeCounter.current
- }
- getRegisterAfterRenderTime() {
- return this.sceneInstrumentation.registerAfterTimeCounter.current
- }
- getRTT1Time() {
- return this.sceneInstrumentation.getRTT1TimeCounter.current
- }
- getRegisterBeforeRenderObserverLength() {
- return this.scene.onBeforeRenderObservable.observers.length
- }
- getRegisterAfterRenderObserverLength() {
- return this.scene.onAfterRenderObservable.observers.length
- }
- getTotalMeshByType() {
- const e = new Map;
- return this.scene.meshes.forEach(i=>{
- e.has(i.xtype) ? e.set(i.xtype, e.get(i.xtype) + 1) : e.set(i.xtype, 1)
- }
- ),
- e
- }
- getHardwareRenderInfo() {
- return {
- maxTexturesUnits: this.caps.maxTexturesImageUnits,
- maxVertexTextureImageUnits: this.caps.maxVertexTextureImageUnits,
- maxCombinedTexturesImageUnits: this.caps.maxCombinedTexturesImageUnits,
- maxTextureSize: this.caps.maxTextureSize,
- maxSamples: this.caps.maxSamples,
- maxCubemapTextureSize: this.caps.maxCubemapTextureSize,
- maxRenderTextureSize: this.caps.maxRenderTextureSize,
- maxVertexAttribs: this.caps.maxVertexAttribs,
- maxVaryingVectors: this.caps.maxVaryingVectors,
- maxVertexUniformVectors: this.caps.maxVertexUniformVectors,
- maxFragmentUniformVectors: this.caps.maxFragmentUniformVectors,
- standardDerivatives: this.caps.standardDerivatives,
- supportTextureCompress: {
- s3tc: this.caps.s3tc !== void 0,
- s3tc_srgb: this.caps.s3tc_srgb !== void 0,
- pvrtc: this.caps.pvrtc !== void 0,
- etc1: this.caps.etc1 !== void 0,
- etc2: this.caps.etc2 !== void 0,
- astc: this.caps.astc !== void 0,
- bptc: this.caps.bptc !== void 0
- },
- textureFloat: this.caps.textureFloat,
- vertexArrayObject: this.caps.vertexArrayObject,
- textureAnisotropicFilterExtension: this.caps.textureAnisotropicFilterExtension !== void 0,
- maxAnisotropy: this.caps.maxAnisotropy,
- instancedArrays: this.caps.instancedArrays,
- uintIndices: this.caps.uintIndices,
- highPrecisionShaders: this.caps.highPrecisionShaderSupported,
- fragmentDepth: this.caps.fragmentDepthSupported,
- textureFloatLinearFiltering: this.caps.textureFloatLinearFiltering,
- renderToTextureFloat: this.caps.textureFloatRender,
- textureHalfFloat: this.caps.textureHalfFloat,
- textureHalfFloatLinearFiltering: this.caps.textureHalfFloatLinearFiltering,
- textureHalfFloatRender: this.caps.textureHalfFloatRender,
- textureLOD: this.caps.textureLOD,
- drawBuffersExtension: this.caps.drawBuffersExtension,
- depthTextureExtension: this.caps.depthTextureExtension,
- colorBufferFloat: this.caps.colorBufferFloat,
- supportTimerQuery: this.caps.timerQuery !== void 0,
- canUseTimestampForTimerQuery: this.caps.canUseTimestampForTimerQuery,
- supportOcclusionQuery: this.caps.supportOcclusionQuery,
- multiview: this.caps.multiview,
- oculusMultiview: this.caps.oculusMultiview,
- maxMSAASamples: this.caps.maxMSAASamples,
- blendMinMax: this.caps.blendMinMax,
- canUseGLInstanceID: this.caps.canUseGLInstanceID,
- canUseGLVertexID: this.caps.canUseGLVertexID,
- supportComputeShaders: this.caps.supportComputeShaders,
- supportSRGBBuffers: this.caps.supportSRGBBuffers,
- supportStencil: this.engine.isStencilEnable
- }
- }
- getSystemInfo() {
- return {
- resolution: "real: " + this.engine.getRenderWidth() + "x" + this.engine.getRenderHeight() + " cavs: " + this._canvas.clientWidth + "x" + this._canvas.clientHeight,
- hardwareScalingLevel: this.engine.getHardwareScalingLevel().toFixed(2).toString() + "_" + this._scenemanager.initEngineScaleNumber.toFixed(2).toString(),
- driver: this.engine.getGlInfo().renderer,
- vender: this.engine.getGlInfo().vendor,
- version: this.engine.getGlInfo().version,
- os: this._osversion
- }
- }
- getFps() {
- const e = this.sceneInstrumentation.frameTimeCounter.lastSecAverage
- , i = this.sceneInstrumentation.interFrameTimeCounter.lastSecAverage;
- return 1e3 / (e + i)
- }
- osVersion() {
- const e = window.navigator.userAgent;
- let i;
- return /iphone|ipad|ipod/gi.test(e) ? i = e.match(/OS (\d+)_(\d+)_?(\d+)?/) : /android/gi.test(e) && (i = e.match(/Android (\d+)/)),
- i != null && i.length > 0 ? i[0] : null
- }
- }
- class RunTimeArray {
- constructor() {
- this.circularData = []
- }
- add(e) {
- this.circularData.length > 1e3 && this.circularData.shift(),
- this.circularData.push(e)
- }
- getAvg() {
- let e = 0;
- for (let i = 0; i < this.circularData.length; i++)
- e += this.circularData[i];
- return {
- sum: e,
- avg: e / this.circularData.length || 0
- }
- }
- getMax() {
- let e = 0;
- for (let i = 0; i < this.circularData.length; i++)
- e < this.circularData[i] && (e = this.circularData[i]);
- return e || 0
- }
- clear() {
- this.circularData = []
- }
- getStat() {
- const e = this.getAvg()
- , i = {
- sum: e.sum,
- avg: e.avg,
- max: this.getMax()
- };
- return this.clear(),
- i
- }
- }
- class XEngineRunTimeStats {
- constructor() {
- this.timeArray_loadStaticMesh = new RunTimeArray,
- this.timeArray_updateStaticMesh = new RunTimeArray,
- this.timeArray_addAvatarToScene = new RunTimeArray
- }
- }
- const log$z = new Logger$1("XDecalManager");
- class XDecalManager {
- get decals() {
- return Array.from(this._decal.values())
- }
- getMesh() {
- return this._decal
- }
- constructor(e) {
- this._decal = new Map,
- this._mat = new Map,
- this._sharedMat = new Map,
- this._scenemanager = e,
- this.scene = e.Scene
- }
- async addDecal(e) {
- const {id: i, meshPath: o, skinInfo: s="default"} = e;
- return this._decal.get(i) ? (log$z.warn(`[Engine] Cannot add decal with an existing id: [${i}], meshPath: ${o}, skinInfo:${s}`),
- Promise.resolve(!0)) : (log$z.info(`[Engine] addDecal wiht id:[${i}], meshPath: ${o}, skinInfo:${s}`),
- new Promise((c,d)=>this._scenemanager.urlTransformer(o).then(_=>new Promise((b,k)=>{
- if (this._decal.get(i))
- b(!0);
- else {
- const j = new XDecal({
- id: i,
- scene: this.scene,
- meshPath: _,
- skinInfo: s
- });
- this._decal.set(i, j),
- j.loadModel().then(()=>{
- b(!0)
- }
- ).catch($=>{
- log$z.error(`[Engine] addDecal Error! id: [${i}], meshpath:${o}, skin: ${s}. ${$}`),
- k(new XDecalError(`[Engine] addDecal Error! id: [${i}], meshpath:${o}, skin: ${s}. ${$}`))
- }
- )
- }
- }
- )).then(_=>{
- _ == !0 ? c(!0) : d(!1)
- }
- ).catch(_=>{
- log$z.error(`[Engine] Add Decal error! id: [${i}], meshpath:${o}, skin:${s}. ${_}`),
- d(new XDecalError(`[Engine] addDecal error! id: [${i}], meshpath:${o}, skin:${s}. ${_}`))
- }
- )))
- }
- setDecalTexture(e) {
- const {id: i, buffer: o, isDynamic: s=!1, width: c=1100, height: d=25, slots: _=1, visibleSlots: b=1} = e
- , k = !0;
- return log$z.info(`[Engine] setDecalTexture wiht id:[${i}]`),
- new Promise((j,$)=>{
- const _e = this._decal.get(i);
- if (_e != null)
- if (this._mat.get(i) != null)
- this.changeDecalTexture({
- id: i,
- buffer: o,
- isUrl: k,
- isDynamic: s,
- width: c,
- height: d,
- slots: _,
- visibleSlots: b
- }),
- j(!0);
- else {
- const et = new XDecalMaterial(i,this.scene);
- et.setTexture(o, k, s, c, d, _, b).then(()=>{
- _e.setMat(et.getMat()),
- this._decal.set(i, _e),
- this._mat.set(i, et),
- j(!0)
- }
- ).catch(tt=>{
- log$z.error("[Engine] setDecalTexture Error! " + tt),
- $(new XDecalTextureError(`[Engine] decal set texture error! ${tt}`))
- }
- )
- }
- else
- log$z.error("[Engine] Error! decal id: [" + i + "] is not find!"),
- $(new XDecalTextureError(`[Engine] decal id: [${i}] is not find!`))
- }
- )
- }
- async shareDecal(e) {
- const {idTar: i, meshPath: o, idSrc: s, skinInfo: c="default"} = e;
- 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}`),
- new Promise((d,_)=>this._scenemanager.urlTransformer(o).then(b=>{
- const k = new XDecal({
- id: i,
- scene: this.scene,
- meshPath: b,
- skinInfo: c
- })
- , j = this._mat.get(s);
- j != null && (k.setMat(j.getMat()),
- k.sourceMatId = s,
- this._decal.set(i, k),
- this.addSharedMatCount(s)),
- d(!0)
- }
- ).catch(b=>{
- _(new XDecalError(`[Engine] decal shareDecal error! ${b}`))
- }
- ))) : (log$z.error(`[Engine] shareDecal Error. idSrc: [${s}] not exist! or idTar: [${i}] exists!`),
- Promise.reject(`[Engine] shareDecal Error. idSrc: [${s}] not exist! or idTar: [${i}] exists!`))
- }
- changeDecalModel(e) {
- const {id: i, meshPath: o} = e
- , s = this._decal.get(i);
- return new Promise((c,d)=>s != null ? (log$z.info(`[Engine] changeDecalModel id:${i}`),
- s.changeModel(o).then(()=>{
- this._decal.set(i, s),
- c(!0)
- }
- )) : (log$z.warn(`[Engine] changeDecalModel id:${i} is not exist`),
- d(`[Engine] changeDecalModel id:${i} is not exist`)))
- }
- changeDecalTexture(e) {
- const {id: i, buffer: o, isUrl: s=!1, isDynamic: c=!1, width: d=1110, height: _=25, slots: b=1, visibleSlots: k=1} = e
- , j = this._mat.get(i);
- j != null && this._decal.has(i) ? (j.changeTexture(o, s, c, d, _, b, k),
- this._mat.set(i, j)) : log$z.error(`[Engine] changeDecalTexture Error. id:${i} is not exist`)
- }
- deleteDecal(e) {
- var i, o;
- if (this._decal.has(e)) {
- const s = this._decal.get(e);
- s != null && s.cleanMesh(),
- this._sharedMat.get(e) != null ? this.minusSharedMatCount(e) : this._mat.get(e) != null ? ((i = this._mat.get(e)) == null || i.cleanTexture(),
- this._mat.delete(e)) : ((o = s.sourceMatId) == null ? void 0 : o.length) > 0 && this.minusSharedMatCount(s.sourceMatId),
- this._decal.delete(e)
- }
- }
- deleteDecalBySkinInfo(e) {
- for (const [i,o] of this._decal.entries())
- o.skinInfo == e && this.deleteDecal(i)
- }
- addSharedMatCount(e) {
- const i = this._sharedMat.get(e);
- i != null ? this._sharedMat.set(e, i + 1) : this._sharedMat.set(e, 1)
- }
- minusSharedMatCount(e) {
- var o;
- const i = this._sharedMat.get(e);
- i != null && (this._sharedMat.set(e, i - 1),
- i == 0 && (this._sharedMat.delete(e),
- (o = this._mat.get(e)) == null || o.cleanTexture(),
- this._mat.delete(e)))
- }
- toggle(e, i) {
- const o = this._decal.get(e);
- o == null || o.toggle(i)
- }
- toggleDecalBySkinInfo(e, i) {
- for (const [o,s] of this._decal.entries())
- s.skinInfo == e && s.toggle(i)
- }
- updateTexAsWords(e, i, o={}) {
- 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;
- let {x: tt=c / 2} = o;
- const rt = this._mat.get(e);
- if (rt) {
- tt == -1 && (tt = (rt.getUOffset() + j / k) % 1 * c * k);
- const nt = rt.getMat().diffuseTexture
- , ot = nt.getContext();
- s && ot.clearRect(tt - c / 2, _ - d / 2, c, d),
- ot.textAlign = "center",
- ot.textBaseline = "middle",
- nt.drawText(i, tt, _, et + " " + b + "px " + $, _e, "transparent", !0),
- nt.hasAlpha = !0,
- nt.update()
- }
- }
- async updateTexAsImg(e, i, o={}) {
- const {clearArea: s=!0, w: c=480, h: d=480, x: _=c / 2, y: b=d / 2, clearW: k=c, clearH: j=d} = o;
- return i == null || i == null || i == "" ? (log$z.error(`[Engine] updateTexAsImg Error. id: [${e}], newBuffer is Null or ""!`),
- 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)=>{
- const it = this._mat.get(e);
- if (it) {
- const ot = it.getMat().diffuseTexture;
- if (typeof i == "string") {
- const at = new Image;
- at.crossOrigin = "anonymous",
- at.src = et,
- at.onload = ()=>{
- const st = ot.getContext();
- s && st.clearRect(_ - k / 2, b - j / 2, k, j),
- st.drawImage(at, _ - c / 2, b - d / 2, c, d),
- ot.update(),
- tt(!0)
- }
- ,
- at.onerror = ()=>{
- log$z.error(`[Engine] updateTexAsImg Error.newImg load error. id: [${e}], decalMat is Null or undefined!`),
- rt(new XDecalError(`[Engine] updateTexAsImg Error. id: [${e}], decalMat is Null or undefined!`))
- }
- } else
- log$z.error(`[Engine] updateTexAsImg Error. id: [${e}], Buffer is not string!`),
- rt(new XDecalError(`[Engine] updateTexAsImg Error. id: [${e}], Buffer is not string!`))
- } else
- log$z.error(`[Engine] updateTexAsImg Error. id: [${e}], decalMat is Null or undefined!`),
- rt(new XDecalError(`[Engine] updateTexAsImg Error. id: [${e}], decalMat is Null or undefined!`))
- }
- ).then(tt=>{
- tt == !0 ? $(!0) : (log$z.error(`[Engine] updateTexAsImg Error. id: [${e}] !`),
- _e(new XDecalError(`[Engine] updateTexAsImg error! id: [${e}]`)))
- }
- ).catch(tt=>{
- log$z.error(`[Engine] updateTexAsImg Error. id: [${e}]. ${tt}`)
- }
- )))
- }
- startAnime(e, i) {
- log$z.info(`[Engine] Decal Start Anime. [${e}]`);
- const {speed: o=.001, callback: s} = i
- , c = this._mat.get(e);
- c ? (c.do_animation(o),
- s && c.uOffsetObserverable.add(s)) : (log$z.error(`[Engine] startAnime Error. id: [${e}] is not exist!`),
- new XDecalError(`[Engine] startAnime Error. id: [${e}] is not exist!`))
- }
- }
- class XDecalMaterial {
- constructor(e, i) {
- this._speed = .001,
- this._slots = 1,
- this._visibleSlots = 1,
- this._animeObserver = null,
- this.reg_mat_update = ()=>{
- const o = this._mat.diffuseTexture;
- o != null && (o.uOffset = o.uOffset + this._speed,
- o.uOffset > 1 && (o.uOffset -= 1),
- Math.round(o.uOffset % (1 / this._slots) / this._speed) == 0 && this._uOffsetObserverable.notifyObservers(this))
- }
- ,
- this.setTexture = async(o,s=!0,c=!1,d=1,_=1,b=1,k=1)=>new Promise((j,$)=>{
- this._slots = b,
- this._visibleSlots = k;
- const _e = this._tex;
- c ? (this._tex = new DynamicTexture("dyTex",{
- width: d,
- height: _
- },this.scene,!0,Texture.BILINEAR_SAMPLINGMODE),
- this._tex.name = "decal_dy_" + this._id,
- this._tex.uScale = k / b,
- this._tex.vScale = -1,
- this._tex.vOffset = 1,
- this._tex.wrapU = 1,
- this._mat.emissiveColor = new Color3(.95,.95,.95),
- this._mat.diffuseTexture = this._tex,
- this._mat.diffuseTexture.hasAlpha = !0,
- this._mat.useAlphaFromDiffuseTexture = !0,
- this._mat.backFaceCulling = !1,
- this._mat.transparencyMode = Material.MATERIAL_ALPHATEST,
- _e != null && _e.dispose(),
- j(!0)) : !c && s && typeof o == "string" ? this._tex = new Texture(o,this.scene,!0,!1,Texture.BILINEAR_SAMPLINGMODE,()=>{
- this._tex.name = "decal_" + this._id,
- this._mat.emissiveTexture = this._tex,
- this._mat.diffuseTexture = this._tex,
- this._mat.diffuseTexture.hasAlpha = !0,
- this._mat.useAlphaFromDiffuseTexture = !0,
- this._mat.transparencyMode = Material.MATERIAL_ALPHATEST,
- _e != null && _e.dispose(),
- j(!0)
- }
- ,()=>{
- log$z.error("[Engine] decal create texture error!"),
- $(new XDecalTextureError("[Engine] decal create texture error!"))
- }
- ,null,!0) : this._tex = new Texture("data:decal_" + this._id,this.scene,!0,!1,Texture.BILINEAR_SAMPLINGMODE,()=>{
- this._tex.name = "decal_" + this._id,
- this._mat.emissiveTexture = this._tex,
- this._mat.diffuseTexture = this._tex,
- this._mat.diffuseTexture.hasAlpha = !0,
- this._mat.useAlphaFromDiffuseTexture = !0,
- this._mat.transparencyMode = Material.MATERIAL_ALPHATEST,
- _e != null && _e.dispose(),
- j(!0)
- }
- ,()=>{
- log$z.error("[Engine] decal create texture error!"),
- $(new XDecalTextureError("[Engine] decal create texture error!"))
- }
- ,o,!0)
- }
- ),
- this._id = e,
- this.scene = i,
- this._mat = new StandardMaterial("decalMat_" + this._id,this.scene),
- this._isRegisterAnimation = !1,
- this._uOffsetObserverable = new Observable
- }
- get uOffsetObserverable() {
- return this._uOffsetObserverable
- }
- getMat() {
- return this._mat
- }
- set speed(e) {
- this._speed = e
- }
- getUOffset() {
- return this._tex.uOffset
- }
- do_animation(e) {
- this._speed = e,
- this._isRegisterAnimation == !1 && (this._isRegisterAnimation = !0,
- this._animeObserver = this.scene.onBeforeRenderObservable.add(()=>{
- this.reg_mat_update()
- }
- ))
- }
- changeTexture(e, i=!1, o=!1, s=1, c=1, d=1, _=1) {
- return this._mat == null || this._tex == null ? (log$z.error("[Engine] Decal Mat is null or tex is null"),
- Promise.reject(new XDecalTextureError("[Engine] Decal Mat is null or tex is null"))) : this.setTexture(e, i, o, s, c, d, _)
- }
- cleanTexture() {
- log$z.info("[Engine] Decal clean Texture"),
- this.scene.onBeforeRenderObservable.remove(this._animeObserver),
- this._uOffsetObserverable.clear(),
- this._tex.dispose(),
- this._mat.dispose()
- }
- }
- class XDecal {
- constructor(e) {
- this._low_model = [],
- this._mat = null,
- this.sourceMatId = "",
- this.loadModel = async()=>new Promise((d,_)=>{
- typeof this.meshPath == "string" ? SceneLoader.LoadAssetContainerAsync("", this.meshPath, this.scene, null, ".glb").then(b=>{
- for (let k = b.materials.length - 1; k >= 0; --k)
- b.materials[k].dispose();
- for (let k = 0; k < b.meshes.length; ++k)
- b.meshes[k].visibility = 1,
- b.meshes[k].isPickable = !0,
- b.meshes[k].checkCollisions = !1,
- "hasVertexAlpha"in b.meshes[k] && (b.meshes[k].hasVertexAlpha = !1),
- this.scene.addMesh(b.meshes[k]),
- this._low_model.push(new XStaticMesh({
- id: this._id,
- mesh: b.meshes[k],
- xtype: EMeshType.Decal,
- skinInfo: this._skinInfo
- })),
- this.toggle(!1);
- d(!0)
- }
- ).catch(b=>{
- _(new XDecalError(`[Engine] decal load model error! ${b}`))
- }
- ) : _(new XDecalError("[Engine] decal inport mesh is not string!"))
- }
- ).catch(d=>{
- new XDecalError(`[Engine] decal loadModel ${d}`)
- }
- );
- const {id: i, scene: o, meshPath: s, skinInfo: c="default"} = e;
- this._id = i,
- this.scene = o,
- this.meshPath = s,
- this._skinInfo = c
- }
- get skinInfo() {
- return this._skinInfo
- }
- getMesh() {
- return this._low_model
- }
- getMat() {
- return this._mat
- }
- get id() {
- return this._id
- }
- toggle(e) {
- for (let i = 0; i < this._low_model.length; ++i)
- e == !0 ? this._low_model[i].show() : this._low_model[i].hide()
- }
- setMat(e) {
- this._mat = e;
- for (let i = 0; i < this._low_model.length; ++i)
- this._low_model[i].mesh.material = this._mat;
- this.toggle(!0)
- }
- changeModel(e="") {
- return e != "" && (this.meshPath = e),
- this.meshPath == "" ? (log$z.error("[Engine] changeModel Error! meshPath is empty"),
- Promise.reject(new XDecalTextureError("[Engine] changeModel Error! meshPath is empty"))) : new Promise((i,o)=>SceneLoader.LoadAssetContainerAsync("", this.meshPath, this.scene, null, ".glb").then(s=>{
- for (let d = s.materials.length - 1; d >= 0; --d)
- s.materials[d].dispose();
- const c = [];
- for (let d = 0; d < s.meshes.length; ++d)
- s.meshes[d].visibility = 0,
- s.meshes[d].isPickable = !0,
- s.meshes[d].checkCollisions = !1,
- "hasVertexAlpha"in s.meshes[d] && (s.meshes[d].hasVertexAlpha = !1),
- this._mat != null && (s.meshes[d].material = this._mat),
- this.scene.addMesh(s.meshes[d]),
- c.push(new XStaticMesh({
- id: this._id,
- mesh: s.meshes[d],
- xtype: EMeshType.Decal,
- skinInfo: this._skinInfo
- }));
- e != "" && this.cleanMesh(),
- this._low_model = c,
- this._mat != null && this.toggle(!0),
- i(this)
- }
- ).catch(s=>{
- log$z.error("[Engine] Create decal error! " + s),
- o(new XDecalError("[Engine] Create decal error! " + s))
- }
- ))
- }
- cleanMesh(e=!1, i=!1) {
- log$z.info("[Engine] Decal Model clean mesh");
- for (let o = 0; o < this._low_model.length; ++o)
- this._low_model[o].dispose(e, i)
- }
- }
- const log$y = new Logger$1("XBreathPointManager");
- class XBreathPointManager {
- constructor(e) {
- this.materialMap = new Map,
- this.breathPoints = new Map,
- this._allIds = new Set,
- this._loopBPKeys = [],
- this.addBreathPoint = async i=>{
- const o = [{
- url: "https://static.xverse.cn/qqktv/texture.png"
- }];
- if (o.length <= 0) {
- log$y.warn("[Engine] BreathPoint get texture list error: textureList.length <= 0"),
- new XBreathPointError("[Engine] BreathPoint get texture list error!");
- return
- }
- const s = o[0]
- , {id: c, spriteSheet: d=s.url, spriteWidthNumber: _=20, spriteHeightNumber: b=1, position: k, rotation: j={
- pitch: -90,
- yaw: 270,
- roll: 0
- }, 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;
- if (this.breathPoints.get(c)) {
- log$y.warn("[Engine] Cannot add breathPoint with an existing id: [" + c + "]"),
- new XBreathPointError("[Engine] Cannot add breathPoint with an existing id: [" + c + "]");
- return
- }
- if (it) {
- const mt = this.castRay(new Vector3(k.x,k.y,k.z)) * scaleFromUE4toXverse;
- mt != 0 ? k.z = k.z - mt + 1 : k.z = k.z + 1
- }
- let ct;
- if (this.materialMap.get(nt)) {
- const mt = this.materialMap.get(nt);
- mt.count = mt.count + 1,
- ct = mt.mat
- } else {
- const mt = new Texture(d,this._scene,!0,!0,Texture.BILINEAR_SAMPLINGMODE,null,()=>{
- log$y.error("[Engine] Breathpoint create texture error."),
- new XBreathPointError("[Engine] Breathpoint create texture error.")
- }
- ,null,!0);
- mt.name = "TexBreathPoint_" + c,
- ct = new StandardMaterial(`MaterialBreathPoint_${c}`,this._scene),
- ct.alpha = 1,
- ct.emissiveTexture = mt,
- ct.backFaceCulling = at,
- ct.diffuseTexture = mt,
- ct.diffuseTexture.hasAlpha = !0,
- ct.useAlphaFromDiffuseTexture = !0,
- this.materialMap.set(nt, {
- mat: ct,
- count: 1,
- lastRenderTime: Date.now(),
- fps: tt,
- spriteWidthNumber: _,
- spriteHeightNumber: b,
- spriteSheet: d,
- texture: mt
- })
- }
- const lt = new Array(6);
- for (let mt = 0; mt < 6; mt++)
- lt[mt] = new Vector4(0,0,0,0);
- lt[0] = new Vector4(0,0,1 / _,1 / b),
- lt[1] = new Vector4(0,0,1 / _,1 / b);
- let ft = {};
- _e > 0 && et > 0 ? ft = {
- width: _e,
- height: et,
- depth: .01,
- faceUV: lt
- } : ft = {
- size: $,
- depth: .01,
- faceUV: lt
- };
- const ht = MeshBuilder.CreateBox(c, ft, this._scene);
- ht.material = ct;
- const pt = new XStaticMesh({
- id: c,
- mesh: ht,
- xtype: EMeshType.XBreathPoint,
- skinInfo: ut
- });
- let dt = j;
- rt && (ht.billboardMode = Mesh.BILLBOARDMODE_ALL,
- pt.allowMove(),
- dt = {
- pitch: 0,
- yaw: 270,
- roll: 0
- });
- const _t = new BreathPoint({
- type: nt,
- mesh: pt,
- id: c,
- position: k,
- rotation: dt,
- mat: ct,
- maxVisibleRegion: st,
- scene: this._scene,
- skinInfo: ut
- });
- this.breathPoints.set(c, _t),
- this._allIds.add(c),
- ot > 0 && setTimeout(()=>{
- this.clearBreathPoints(c)
- }
- , ot * 1e3)
- }
- ,
- this.reg_breathpoint_update = ()=>{
- const i = new Date().getTime();
- if (this.materialMap != null)
- for (const [o,s] of this.materialMap)
- i - s.lastRenderTime > 1e3 / s.fps && (s.lastRenderTime = i,
- Math.abs(s.mat.diffuseTexture.uOffset - (1 - 1 / s.spriteWidthNumber)) < 1e-6 ? (s.mat.diffuseTexture.uOffset = 0,
- 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)
- }
- ,
- this.reg_breathpoint_autovisible = ()=>{
- if (this._scene.getFrameId() % 2 == 0)
- if (this._loopBPKeys.length == 0)
- this._loopBPKeys = Array.from(this._allIds);
- else {
- const i = this._getMainPlayerPosition();
- for (let o = 0; o < 5 && this._loopBPKeys.length > 0; ++o) {
- const s = this._loopBPKeys.pop();
- if (s != null) {
- const c = this.getBreathPoint(s);
- if (c != null && c.maxvisibleregion >= 0 && c.mesh.visibility == 1) {
- const d = c.mesh.position;
- calcDistance3DVector(i, d) >= c.maxvisibleregion ? c == null || c.removeFromScene() : c == null || c.addToScene()
- }
- }
- }
- }
- }
- ,
- this._sceneManager = e,
- this._scene = e.Scene,
- this._scene.registerBeforeRender(this.reg_breathpoint_update),
- this._scene.registerBeforeRender(this.reg_breathpoint_autovisible)
- }
- setAllBreathPointVisibility(e) {
- for (const [i,o] of this.breathPoints.entries())
- o.toggleVisibility(e)
- }
- toggleBPVisibilityBySkinInfo(e, i) {
- for (const [o,s] of this.breathPoints.entries())
- s.skinInfo == e && s.toggleVisibility(i)
- }
- toggleBPVisibilityById(e, i) {
- const o = this.getBreathPoint(e);
- o != null && o.toggleVisibility(i)
- }
- getBreathPointBySkinInfo(e) {
- const i = [];
- for (const [o,s] of this.breathPoints.entries())
- s.skinInfo == e && i.push(s);
- return i
- }
- getAllBreathPoint() {
- return this.breathPoints
- }
- getBreathPoint(e) {
- return this.breathPoints.get(e)
- }
- delete(e) {
- const i = this.breathPoints.get(e);
- if (i != null) {
- i.dispose(),
- this._allIds.delete(e);
- const o = this.materialMap.get(i._type);
- o != null && (o.count = o.count - 1,
- o.count <= 0 && (o.count = 0,
- o.texture.dispose(),
- o.mat.dispose(!0, !0),
- this.materialMap.delete(i._type))),
- this.breathPoints.delete(e)
- }
- }
- castRay(e) {
- var _;
- e = ue4Position2Xverse({
- x: e.x,
- y: e.y,
- z: e.z
- });
- const i = new Vector3(0,-1,0)
- , o = new Ray(e,i,length)
- , s = []
- , c = (_ = this._sceneManager) == null ? void 0 : _.getGround({
- x: e.x,
- y: e.y,
- z: e.z
- });
- let d = o.intersectsMeshes(c);
- if (d.length > 0) {
- const b = d[0];
- if (b && b.pickedMesh) {
- const k = b.distance;
- i.y = 1;
- const j = o.intersectsMeshes(s);
- let$ = 1e8;
- if (j.length > 0) {
- const _e = j[0];
- return _e && _e.pickedMesh && ($ = -_e.distance),
- $ == 1e8 ? k : Math.abs($) < Math.abs(k) ? $ : k
- }
- }
- } else if (i.y = 1,
- d = o.intersectsMeshes(s),
- d.length > 0) {
- const b = d[0];
- if (b && b.pickedMesh)
- return b.distance
- }
- return 0
- }
- changePickable(e) {
- for (const [i,o] of this.breathPoints.entries())
- o.changePickable(e)
- }
- clearBreathPoints(e) {
- log$y.info(`[Engine] clearBreathPoints: ${e}`);
- for (const [i,o] of this.breathPoints.entries())
- (o._type == e || o._id == e) && this.delete(o._id)
- }
- clearBreathPointsBySkinInfo(e) {
- log$y.info(`[Engine] clearBreathPointsBySkinInfo: ${e}`);
- for (const [i,o] of this.breathPoints.entries())
- o.skinInfo == e && this.delete(o._id)
- }
- clearAllBreathPoints() {
- log$y.info("[Engine] ClearAllBreathPoints");
- for (const [e,i] of this.breathPoints.entries())
- this.delete(i._id)
- }
- _getMainPlayerPosition() {
- var o;
- const e = this._sceneManager.cameraComponent.MainCamera.position
- , i = this._sceneManager.avatarComponent.getMainAvatar();
- if (i != null && i != null) {
- const s = (o = i == null ? void 0 : i.rootNode) == null ? void 0 : o.position;
- if (s != null)
- return s
- }
- return e
- }
- changeBreathPointPose(e, i, o) {
- const s = new Vector3(e.position.x,e.position.y,e.position.z);
- if (this.breathPoints.get(o) != null) {
- log$y.info(`[Engine] changeBreathPointPose, id:${o}`);
- const c = this.breathPoints.get(o)
- , d = c.mesh.position;
- let _ = d.subtract(s);
- _ = Vector3.Normalize(_);
- const b = Vector3.Distance(d, s)
- , k = new Ray(s,_,b)
- , j = this._scene.multiPickWithRay(k);
- if (j) {
- for (let$ = 0; $ < j.length; $++)
- if (j[$].pickedMesh != null && i.mesh.name.indexOf(j[$].pickedMesh.name) >= 0) {
- const _e = j[$].pickedPoint;
- c.mesh.position = s.add(_e.subtract(s).scale(.99)),
- this.breathPoints.set(o, c)
- }
- }
- } else
- log$y.warn(`[Engine] changeBreathPointPose, id:${o} is not existing!`)
- }
- }
- class BreathPoint {
- get isInScene() {
- return this._isInScene
- }
- get skinInfo() {
- return this._skinInfo
- }
- get maxvisibleregion() {
- return this._maxVisibleRegion
- }
- getMesh() {
- return this._staticmesh
- }
- get mesh() {
- return this._staticmesh.mesh
- }
- toggleVisibility(e) {
- e == !0 ? this._staticmesh.show() : this._staticmesh.hide()
- }
- changePickable(e) {
- this._staticmesh.mesh.isPickable = e
- }
- constructor(e) {
- const {mesh: i, id: o, position: s, rotation: c, mat: d, type: _="default", maxVisibleRegion: b=-1, scene: k, skinInfo: j="default"} = e;
- this._id = o,
- i.mesh.position = ue4Position2Xverse(s),
- i.mesh.rotation = ue4Rotation2Xverse(c),
- this._staticmesh = i,
- this._mat = d,
- this._type = _,
- this._maxVisibleRegion = b,
- this._scene = k,
- this._skinInfo = j,
- this._isInScene = !0
- }
- removeFromScene() {
- this._isInScene && (this._staticmesh.mesh != null && this._scene.removeMesh(this._staticmesh.mesh),
- this._isInScene = !1)
- }
- addToScene() {
- this._isInScene == !1 && (this._staticmesh.mesh != null && this._scene.addMesh(this._staticmesh.mesh),
- this._isInScene = !0)
- }
- dispose() {
- var e;
- (e = this._staticmesh.mesh) == null || e.dispose(!1, !1)
- }
- set position(e) {
- this._staticmesh.mesh.position = ue4Position2Xverse(e)
- }
- get position() {
- return xversePosition2Ue4(this._staticmesh.mesh.position)
- }
- set rotation(e) {
- this._staticmesh.mesh.rotation = ue4Rotation2Xverse(e)
- }
- get rotation() {
- return xverseRotation2Ue4(this._staticmesh.mesh.rotation)
- }
- }
- var pureVideoFragment = `precision highp float;
- varying vec3 ModelPos;
- uniform float isYUV; // false: 0, true: 1.0
- uniform sampler2D texture_video;
- // uniform sampler2D chrominanceYTexture;
- // uniform sampler2D chrominanceUTexture;
- // uniform sampler2D chrominanceVTexture;
- uniform float haveShadowLight;
- varying vec4 vPositionFromLight;
- uniform float fireworkLight;
- varying float fireworkDistance;
- varying float fireworkCosTheta;
- uniform sampler2D shadowSampler;
- // uniform float focal;
- // uniform float captureWidth;
- // uniform float captureHeight;
- uniform vec3 focal_width_height;
- const float inv_2_PI = 0.1591549; // 1 / (2 * pi)
- const float inv_PI = 0.3183099; // 1 / ( pi)
- const vec2 invAtan = vec2(0.1591549, 0.3183099);
- float unpack(vec4 color)
- {
- 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);
- return dot(color, bit_shift);
- }
- float ShadowCalculation(vec4 vPositionFromLight, sampler2D ShadowMap)
- {
- vec3 projCoords = vPositionFromLight.xyz / vPositionFromLight.w;
- vec3 depth = 0.5 * projCoords + vec3(0.5);
- vec2 uv = depth.xy;
- if (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0)
- {
- return 1.0;
- }
- #ifndef SHADOWFULLFLOAT
- float shadow = unpack(texture2D(ShadowMap, uv));
- #else
- float shadow = texture2D(ShadowMap, uv).x;
- #endif
- if (depth.z > shadow - 1e-4)
- {
- return 0.7;
- }
- else
- {
- return 1.0;
- }
- }
- // const float f = 514.133282; //937.83246;
- // const float w = 720.0;
- // const float h = 1280.0;
- // vec2 SampleTex(vec3 pt3d, vec2 widthHeight)
- vec2 SampleTex(vec3 pt3d)
- {
- // // 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
- // 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
- // uv.x = uv.x + 0.5;
- // uv.y = uv.y + 0.5;
- // return uv;
- return focal_width_height.x / focal_width_height.yz *pt3d.xy/pt3d.z + 0.5;
- }
-
- void main()
- {
- vec3 yuv;
- vec3 rgb;
- vec2 uv;
- vec3 color = vec3(0,0,0);
- vec3 flash_color = fireworkLight * 1000.0 / fireworkDistance * fireworkCosTheta * vec3(1,0,0);
- float shadow = 1.0;
- if (haveShadowLight > 0.5)
- {
- shadow = ShadowCalculation(vPositionFromLight, shadowSampler);
- }
- // uv = SampleTex( normalize(ModelPos), vec2(captureWidth, captureHeight));
- uv = SampleTex( normalize(ModelPos) );
- if( isYUV < 0.5 )
- {
- color = texture2D(texture_video, uv).rgb;
- }else{
- const mat4 YUV2RGB = mat4
- (
- 1.1643828125, 0, 1.59602734375, -.87078515625,
- 1.1643828125, -.39176171875, -.81296875, .52959375,
- 1.1643828125, 2.017234375, 0, -1.081390625,
- 0, 0, 0, 1
- );
-
- vec4 result = vec4(
- texture2D(texture_video, vec2(uv.x, uv.y*0.666666 + 0.333333 ) ).x,
- texture2D(texture_video, vec2(uv.x * 0.5, uv.y*0.333333 ) ).x,
- texture2D(texture_video, vec2(0.5 + uv.x * 0.5, uv.y*0.333333 ) ).x,
- 1) * YUV2RGB;
- color = clamp(result.rgb, 0.0, 1.0);
- }
- if( uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0 )
- {
- color = vec3(0,0,0);
- }
- // gl_FragColor = vec4(shadow, shadow, shadow, 1.0);
- gl_FragColor = vec4(shadow * (color + flash_color) * 1.0, 1.0);
- }
- `
- , pureVideoVertex = `precision highp float;
- varying vec3 ModelPos;
- varying vec4 vPositionFromLight;
- varying float fireworkDistance;
- varying float fireworkCosTheta;
- attribute vec2 uv;
- attribute vec3 position;
- attribute vec4 world0;
- attribute vec4 world1;
- attribute vec4 world2;
- attribute vec4 world3;
- #ifdef NORMAL
- attribute vec3 normal;
- #endif
- uniform vec3 fireworkLightPosition;
- uniform mat4 view;
- uniform mat4 projection;
- uniform mat4 lightSpaceMatrix;
- uniform mat4 world;
- uniform mat4 worldViewProjection;
- float DistanceCalculation(vec3 Q, vec3 P)
- {
- 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);
- }
- float CosThetaCalculation(vec3 Q, vec3 P)
- {
- return max(0.,dot(Q, P));
- }
- void main()
- {
-
- #include<instancesVertex>
- vPositionFromLight = lightSpaceMatrix * finalWorld * vec4(position, 1.0);
-
- // fireworkDistance = DistanceCalculation(vec3(finalWorld * vec4(position, 1.0)), fireworkLightPosition);
- fireworkDistance = distance(vec3(finalWorld * vec4(position, 1.0)), fireworkLightPosition);
-
-
- fireworkCosTheta = 1.0;
- #ifdef NORMAL
- vec3 directionFirework = fireworkLightPosition.xyz - vec3(finalWorld * vec4(position, 1.0));
- directionFirework = normalize(directionFirework);
- // directionFirework = directionFirework / (directionFirework.x * directionFirework.x + directionFirework.y * directionFirework.y + directionFirework.z * directionFirework.z);
- fireworkCosTheta = CosThetaCalculation(directionFirework, normal);
- #endif
-
- ModelPos = vec3( view * finalWorld * vec4(position , 1.0));
- gl_Position = projection * view * finalWorld * vec4(position , 1.0);
- }
- `
- , panoFragment = `precision highp float;
- uniform float isYUV; // false: 0, true: 1.0
- varying vec2 TexCoords;
- varying vec3 WorldPos;
- varying vec3 vNormal;
- uniform float haveShadowLight;
- varying vec4 vPositionFromLight;
- uniform float fireworkLight;
- varying float fireworkDistance;
- varying float fireworkCosTheta;
- uniform sampler2D shadowSampler;
- uniform vec3 centre_pose;
- uniform sampler2D texture_pano;
- const float inv_2_PI = 0.1591549; // 1 / (2 * pi)
- const float inv_PI = 0.3183099; // 1 / ( pi)
- const vec2 invAtan = vec2(0.1591549, 0.3183099);
- float unpack(vec4 color)
- {
- 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);
- return dot(color, bit_shift);
- }
-
- float ShadowCalculation(vec4 vPositionFromLight, sampler2D ShadowMap)
- {
- vec3 projCoords = vPositionFromLight.xyz / vPositionFromLight.w;
- vec3 depth = 0.5 * projCoords + vec3(0.5);
- vec2 uv = depth.xy;
- if (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0)
- {
- return 1.0;
- }
- #ifndef SHADOWFULLFLOAT
- float shadow = unpack(texture2D(ShadowMap, uv));
- #else
- float shadow = texture2D(ShadowMap, uv).x;
- #endif
- if (depth.z > shadow)
- {
- return 0.7;
- }
- else
- {
- return 1.0;
- }
- }
-
- vec2 SampleSphericalMap(vec3 pt3d)
- {
- vec2 uv = vec2( atan(-pt3d.z,pt3d.x), atan( pt3d.y, sqrt(pt3d.x*pt3d.x + pt3d.z * pt3d.z)));
- uv.x = 0.5 + uv.x * inv_2_PI ; // yaw: \u6C34\u5E73\u65B9\u5411 \uFF0C0 \u5230 360 \uFF0C \u5BF9\u5E948k\u7684\u5BBD
- uv.y = 0.5 + uv.y * inv_PI ; // pitch: \u7AD6\u76F4\u65B9\u5411\uFF0C -64 \u5230 64 \uFF0C\u5BF9\u5E944k\u7684\u957F
- return vec2(uv.x,uv.y);
- }
- vec3 fitUint8Range(vec3 color)
- {
- if( color.x < 0.0 ){color.x = 0.0;}
- if( color.x > 1.0 ){color.x = 1.0;}
- if( color.y < 0.0 ){color.y = 0.0;}
- if( color.y > 1.0 ){color.y = 1.0;}
- if( color.z < 0.0 ){color.z = 0.0;}
- if( color.z > 1.0 ){color.z = 1.0;}
- return color;
- }
- void main()
- {
- // // Debug
- // vec3 vLightPosition = vec3(0,10,100);
- // // World values
- // vec3 vPositionW = vec3( WorldPos.x, WorldPos.y, WorldPos.z );
- // vec3 vNormalW = normalize( vNormal) ;
- // vec3 viewDirectionW = normalize(vPositionW);
- // // Light
- // vec3 lightVectorW = normalize(vLightPosition - vPositionW);
- // // diffuse
- // float ndl = max(0., dot(vNormalW, lightVectorW));
- // gl_FragColor = vec4( ndl, ndl, ndl, 1.);
- vec2 uv;
- vec3 color = vec3(0,0,0);
-
- vec3 flash_color = fireworkLight * 1000.0 / fireworkDistance * fireworkCosTheta * vec3(1,0,0);
- float shadow = 1.0;
- if (haveShadowLight > 0.5)
- {
- shadow = ShadowCalculation(vPositionFromLight, shadowSampler);
- }
- uv = SampleSphericalMap(normalize( WorldPos - centre_pose ));
- if( isYUV < 0.5 )
- {
- color = texture2D(texture_pano, uv).rgb;
- }else{
- const mat4 YUV2RGB = mat4
- (
- 1.1643828125, 0, 1.59602734375, -.87078515625,
- 1.1643828125, -.39176171875, -.81296875, .52959375,
- 1.1643828125, 2.017234375, 0, -1.081390625,
- 0, 0, 0, 1
- );
-
- vec4 result = vec4(
- texture2D(texture_pano, vec2(uv.x, uv.y*0.666666 + 0.333333 ) ).x,
- texture2D(texture_pano, vec2(uv.x * 0.5, uv.y*0.333333 ) ).x,
- texture2D(texture_pano, vec2(0.5 + uv.x * 0.5, uv.y*0.333333 ) ).x,
- 1) * YUV2RGB;
- color = fitUint8Range(result.rgb);
- }
- if( uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0 )
- {
- color = vec3(0,0,0);
- }
- gl_FragColor = vec4( shadow * (color + flash_color), 1.0);
- }`
- , panoVertex = `precision highp float;
- varying vec2 TexCoords;
- varying vec3 vNormal;
- varying vec3 WorldPos;
- varying vec4 vPositionFromLight;
- varying float fireworkDistance;
- varying float fireworkCosTheta;
- uniform vec3 fireworkLightPosition;
- uniform mat4 lightSpaceMatrix;
- attribute vec3 normal;
- attribute vec2 uv;
- attribute vec3 position;
- uniform mat4 view;
- uniform mat4 projection;
- uniform mat4 world;
- uniform mat4 worldViewProjection;
-
- attribute vec4 world0;
- attribute vec4 world1;
- attribute vec4 world2;
- attribute vec4 world3;
- float DistanceCalculation(vec3 Q, vec3 P)
- {
- 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);
- }
- float CosThetaCalculation(vec3 Q, vec3 P)
- {
- return max(0.,dot(Q, P));
- }
- void main()
- {
- #include<instancesVertex>
- vPositionFromLight = lightSpaceMatrix * world * vec4(position, 1.0);
- fireworkDistance = DistanceCalculation(vec3(finalWorld * vec4(position, 1.0)), fireworkLightPosition);
- fireworkCosTheta = 1.0;
- vec3 newP = vec3( finalWorld * vec4(position, 1.0) );
- WorldPos = newP;
- TexCoords = uv;
- vNormal = normal;
- gl_Position = projection * view * vec4(newP , 1.0);
- }
- `;
- class XVideoRawYUV {
- constructor(e, i) {
- this.scene = e,
- this._videoRawYUVTexture = [],
- this.videosResOriArray = i,
- this._currentVideoId = -1;
- for (let o = 0; o < i.length; ++o)
- (s=>{
- const c = RawTexture.CreateLuminanceTexture(null, i[s].width, i[s].height * 1.5, this.scene, !1, !0);
- c.name = "videoTex_" + i[s].width + "_" + i[s].height,
- this._videoRawYUVTexture.push(c)
- }
- )(o)
- }
- inRange(e) {
- return e >= 0 && e < this._videoRawYUVTexture.length
- }
- getVideoYUVTex(e) {
- return this.inRange(e) ? this._videoRawYUVTexture[e] : null
- }
- findId(e, i) {
- let o = 0;
- for (let s = 0; s < this.videosResOriArray.length; ++s)
- if (this.videosResOriArray[s].width == e && this.videosResOriArray[s].height == i) {
- o = s;
- break
- }
- return o
- }
- getCurrentVideoTexId() {
- return this._currentVideoId
- }
- setCurrentVideoTexId(e) {
- this._currentVideoId = e
- }
- }
- const log$x = new Logger$1("XMaterial");
- var EShaderMode = (a=>(a[a.default = 0] = "default",
- a[a.video = 1] = "video",
- a[a.videoAndPano = 2] = "videoAndPano",
- a))(EShaderMode || {});
- class XMaterialComponent {
- constructor(e, i) {
- this._inputYUV420 = !0,
- this._inputPanoYUV420 = !0,
- this._isUpdateYUV = !0,
- this.initMaterial = async()=>new Promise((o,s)=>{
- this._initDefaultShader(),
- this.shaderMode == 2 ? this.initDynamicData(this._panoInfo.dynamicRange, this._panoInfo.width, this._panoInfo.height).then(()=>{
- this._initPureVideoShader(),
- this._prepareRender(this.yuvInfo)
- }
- ) : this.shaderMode == 1 ? (this._initPureVideoShader(),
- this._prepareRender(this.yuvInfo)) : this.shaderMode == 0,
- o(!0)
- }
- ),
- this._initPureVideoContent = o=>{
- this._inputYUV420 ? this._videoRawYUVTexArray.getVideoYUVTex(0) != null && (this._lowModelShader.setTexture("texture_video", this._videoRawYUVTexArray.getVideoYUVTex(0)),
- this._lowModelShader.setFloat("isYUV", 1),
- Texture.WhenAllReady([this._videoRawYUVTexArray.getVideoYUVTex(0)], ()=>{
- this._changePureVideoLowModelShaderCanvasSize(o)
- }
- )) : (this._videoElement = o.videoElement,
- this._videoTexture || (this._videoTexture = new VideoTexture("InterVideoTexture",this._videoElement,this.scene,!0,!1)),
- Texture.WhenAllReady([this._videoTexture], ()=>{
- this._changePureVideoLowModelShaderCanvasSize({
- width: this._videoElement.height,
- height: this._videoElement.width,
- fov: o.fov
- })
- }
- ),
- this._lowModelShader.setTexture("texture_video", this._videoTexture),
- this._lowModelShader.setFloat("isYUV", 0))
- }
- ,
- this._changePureVideoLowModelShaderCanvasSize = o=>{
- var b;
- const s = o.fov || 50
- , c = o.width || 720
- , d = o.height || 1280
- , _ = c / (2 * Math.tan(Math.PI * s / 360));
- (b = this._lowModelShader) == null || b.setVector3("focal_width_height", new Vector3(_,c,d))
- }
- ,
- this.updateRawYUVData = (o,s,c,d=-1)=>{
- var _, b;
- if (d == -1 && (d = this.yuvInfo.fov),
- this._isUpdateYUV == !0) {
- const k = {
- width: s,
- height: c,
- fov: d
- }
- , j = this._videoRawYUVTexArray.findId(s, c)
- , $ = this._videoRawYUVTexArray.getCurrentVideoTexId();
- ($ < 0 || j != $ || d != this.yuvInfo.fov) && (this.yuvInfo.width = s,
- this.yuvInfo.height = c,
- this.yuvInfo.fov = d,
- this._videoRawYUVTexArray.setCurrentVideoTexId(j),
- this._changeVideoRes(j),
- this.changeCameraFovWithShaderUpdate(k),
- this._scenemanager.yuvInfo = k),
- (_ = this._videoRawYUVTexArray.getVideoYUVTex(j)) == null || _.update(o),
- (b = this._videoRawYUVTexArray.getVideoYUVTex(j)) == null || b.updateSamplingMode(Texture.BILINEAR_SAMPLINGMODE)
- }
- }
- ,
- this._changeVideoRes = o=>{
- this._lowModelShader.setTexture("texture_video", this._videoRawYUVTexArray.getVideoYUVTex(o))
- }
- ,
- this.initDynamicData = (o,s,c)=>new Promise((d,_)=>{
- this.setDynamicSize(o).then(b=>{
- if (b) {
- for (let k = 0; k < o; ++k)
- (j=>{
- this.initDynamicTexture(j, s, c),
- this.initDynamicShaders(j).then(()=>{
- this._updatePanoShaderInput(j)
- }
- )
- }
- )(k);
- d(!0)
- } else
- _(new XMaterialError(`[Engine] DynamicRoomSize (${o}) is too small`))
- }
- )
- }
- ).catch(d=>log$x.error(`[Engine] ${d}`)),
- this._initDefaultShader = ()=>{
- this._defaultShader == null && (this._defaultShader = new GridMaterial("GridShader",this.scene),
- this._defaultShader.gridRatio = 50,
- this._defaultShader.lineColor = new Color3(0,0,.5),
- this._defaultShader.majorUnitFrequency = 1,
- this._defaultShader.mainColor = new Color3(.6,.6,.6),
- this._defaultShader.backFaceCulling = !1)
- }
- ,
- this._initPureVideoShader = ()=>{
- if (this._lowModelShader == null) {
- const o = new ShaderMaterial("PureVideoShader",this.scene,{
- vertexSource: pureVideoVertex,
- fragmentSource: pureVideoFragment
- },{
- attributes: ["uv", "position", "world0", "world1", "world2", "world3"],
- uniforms: ["view", "projection", "worldViewProjection", "world"],
- defines: ["#define SHADOWFULLFLOAT"]
- });
- o.setTexture("shadowSampler", null),
- o.setMatrix("lightSpaceMatrix", null),
- o.setFloat("haveShadowLight", 0),
- o.setTexture("texture_video", null),
- o.setFloat("isYUV", this._inputYUV420 ? 1 : 0),
- o.setFloat("fireworkLight", 0),
- o.setVector3("fireworkLightPosition", new Vector3(0,0,0)),
- o.setVector3("focal_width_height", new Vector3(772.022491,720,1280)),
- o.backFaceCulling = !1,
- this._lowModelShader = o
- }
- }
- ,
- this.setDynamicSize = o=>new Promise((s,c)=>{
- o >= 1 && o <= 100 ? (this._dynamic_size = o,
- s(!0)) : (this._dynamic_size = 1,
- s(!1))
- }
- ),
- this._isInDynamicRange = o=>o < this._dynamic_size && o >= 0,
- this.initDynamicTexture = (o,s,c)=>{
- this._isInDynamicRange(o) && (this._dynamic_textures[o] != null && (this._dynamic_textures[o].dispose(),
- this._dynamic_textures[o] = null),
- 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),
- this._dynamic_textures[o].name = "Pano_Dynamic_" + o + "_" + Date.now())
- }
- ,
- this.initDynamicShaders = o=>(log$x.info("[Engine] Material init dynamic shader."),
- new Promise((s,c)=>{
- this._dynamic_shaders[o] != null && this._dynamic_shaders[o].dispose();
- const d = new ShaderMaterial("Pano_Shader_" + o,this.scene,{
- vertexSource: panoVertex,
- fragmentSource: panoFragment
- },{
- attributes: ["uv", "position", "world0", "world1", "world2", "world3"],
- uniforms: ["view", "projection", "worldViewProjection", "world"],
- defines: ["#define SHADOWFULLFLOAT"]
- });
- d.setTexture("texture_pano", null),
- d.setVector3("centre_pose", new Vector3(0,0,0)),
- d.setFloat("isYUV", this._inputPanoYUV420 ? 1 : 0),
- d.setTexture("shadowSampler", null),
- d.setMatrix("lightSpaceMatrix", null),
- d.setFloat("haveShadowLight", 0),
- d.setFloat("fireworkLight", 0),
- d.setVector3("fireworkLightPosition", new Vector3(0,0,0)),
- d.backFaceCulling = !1,
- this._dynamic_shaders[o] = d,
- s(!0)
- }
- )),
- this._scenemanager = e,
- this.scene = e.Scene,
- this.engine = this.scene.getEngine(),
- this.shaderMode = 1,
- this._dynamic_textures = [],
- this._dynamic_shaders = [],
- this._dynamic_babylonpose = [],
- this._videoRawYUVTexArray = new XVideoRawYUV(this.scene,i.videoResOriArray),
- this.shaderMode = i.shaderMode,
- i.yuvInfo != null && (this.yuvInfo = i.yuvInfo),
- i.panoInfo != null && this.setPanoInfo(i.panoInfo)
- }
- stopYUVUpdate() {
- this._isUpdateYUV = !1
- }
- allowYUVUpdate() {
- this._isUpdateYUV = !0
- }
- setPanoInfo(e) {
- this._panoInfo = e
- }
- _prepareRender(e) {
- e && (this._initPureVideoContent(e),
- this._updatePureVideoShaderInput())
- }
- changeCameraFovWithShaderUpdate(e) {
- this._changePureVideoLowModelShaderCanvasSize(e),
- this._scenemanager.cameraComponent.cameraFovChange(e)
- }
- getPureVideoShader() {
- return this._lowModelShader
- }
- getDefaultShader() {
- return this._defaultShader
- }
- updatePanoPartYUV(e, i, o) {
- const s = i.subarray(0, o.width * o.height)
- , c = i.subarray(o.width * o.height, o.width * o.height * 1.25)
- , d = i.subarray(o.width * o.height * 1.25)
- , _ = this._panoInfo.width
- , b = this._panoInfo.height;
- if (this._dynamic_textures[e] != null) {
- const k = this._dynamic_textures[e].getInternalTexture();
- if (k != null && k != null) {
- const j = this.engine._getTextureTarget(k);
- this.engine._bindTextureDirectly(j, k, !0),
- this.engine.updateTextureData(k, s, o.startX, b * 1.5 - o.startY - o.height, o.width, o.height),
- this.engine.updateTextureData(k, c, o.startX * .5, (b - o.startY - o.height) * .5, o.width * .5 - 1, o.height * .5 - 1),
- this.engine.updateTextureData(k, d, o.startX * .5 + _ * .5, (b - o.startY - o.height) * .5, o.width * .5, o.height * .5),
- this.engine._bindTextureDirectly(j, null)
- }
- }
- }
- changePanoImg(e, i) {
- if (log$x.info(`[Engine] changePanoImg, id=${e}, pose=${i.pose.position.x},${i.pose.position.y},${i.pose.position.z}`),
- !this._isInDynamicRange(e))
- return log$x.error(`[Engine] ${e} is bigger than dynamic size set in PanoInfo`),
- Promise.reject(new XMaterialError(`[Engine] ${e} is bigger than dynamic size set in PanoInfo`));
- const o = ue4Position2Xverse(i.pose.position);
- return o && (this._dynamic_babylonpose[e] = {
- position: o
- }),
- new Promise((s,c)=>{
- try {
- typeof i.data == "string" ? (this.setPanoYUV420(!1),
- this._dynamic_textures[e].updateURL(i.data, null, ()=>{
- this._dynamic_textures[e].updateSamplingMode(Texture.NEAREST_SAMPLINGMODE)
- }
- )) : (this.isPanoYUV420() == !1 && this.initDynamicTexture(e, this._panoInfo.width, this._panoInfo.height),
- this.setPanoYUV420(!0),
- this._dynamic_textures[e].update(i.data),
- this._dynamic_textures[e].updateSamplingMode(Texture.NEAREST_SAMPLINGMODE)),
- s(this)
- } catch (d) {
- c(new XMaterialError(`[Engine] ChangePanoImg Error! ${d}`))
- }
- }
- ).then(s=>(i.fov != null && this._scenemanager.cameraComponent.changeCameraFov(i.fov * Math.PI / 180),
- this._dynamic_shaders[e].setFloat("isYUV", this._inputPanoYUV420 ? 1 : 0),
- this._dynamic_shaders[e].setTexture("texture_pano", this._dynamic_textures[e]),
- this._dynamic_shaders[e].setVector3("centre_pose", this._dynamic_babylonpose[e].position),
- !0))
- }
- setYUV420(e) {
- this._inputYUV420 = e
- }
- isYUV420() {
- return this._inputYUV420
- }
- setPanoYUV420(e) {
- this._inputPanoYUV420 = e
- }
- isPanoYUV420() {
- return this._inputPanoYUV420
- }
- getDynamicShader(e) {
- return this._dynamic_shaders[e]
- }
- _updatePureVideoShaderInput() {
- var e, i, o, s, c, d, _, b, k, j;
- if (this.scene.getLightByName("AvatarLight") ? ((e = this._lowModelShader) == null || e.setFloat("haveShadowLight", 1),
- (s = this._lowModelShader) == null || s.setTexture("shadowSampler", (o = (i = this.scene.getLightByName("AvatarLight")) == null ? void 0 : i.getShadowGenerator()) == null ? void 0 : o.getShadowMapForRendering()),
- (_ = 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)),
- (k = this._lowModelShader) == null || k.setMatrix("lightSpaceMatrix", new Matrix),
- (j = this._lowModelShader) == null || j.setFloat("haveShadowLight", 0)),
- this.scene.getLightByName("fireworkLight"))
- this.scene.registerBeforeRender(()=>{
- var $;
- this._lowModelShader.setFloat("fireworkLight", this.scene.getLightByName("fireworkLight").getScaledIntensity()),
- this._lowModelShader.setVector3("fireworkLightPosition", ($ = this.scene.getLightByName("fireworkLight")) == null ? void 0 : $.position)
- }
- );
- else {
- const $ = new PointLight("fireworkLight",new Vector3(0,0,0),this.scene);
- $.intensity = 0
- }
- }
- _updatePanoShaderInput(e) {
- var i, o, s, c, d, _, b, k, j, $;
- if (this._isInDynamicRange(e))
- if (this.scene.getLightByName("AvatarLight") ? ((i = this._dynamic_shaders[e]) == null || i.setFloat("haveShadowLight", 1),
- (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()),
- (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)),
- (j = this._lowModelShader) == null || j.setMatrix("lightSpaceMatrix", new Matrix),
- ($ = this._lowModelShader) == null || $.setFloat("haveShadowLight", 0)),
- this.scene.getLightByName("fireworkLight"))
- this.scene.registerBeforeRender(()=>{
- var _e;
- this._dynamic_shaders[e].setFloat("fireworkLight", this.scene.getLightByName("fireworkLight").getScaledIntensity()),
- this._dynamic_shaders[e].setVector3("fireworkLightPosition", (_e = this.scene.getLightByName("fireworkLight")) == null ? void 0 : _e.position)
- }
- );
- else {
- const _e = new PointLight("fireworkLight",new Vector3(0,0,0),this.scene);
- _e.intensity = 0
- }
- }
- }
- class XCameraComponent {
- constructor(e, i, o) {
- this.maincameraRotLimitObserver = null,
- this.forceKeepVertical = !1,
- this.initCamera = s=>{
- const {maxZ: c=1e4, minZ: d=.1, angularSensibility: _=2e3} = s;
- this.mainCamera = new FreeCamera("camera_main",new Vector3(0,1e3,0),this.scene),
- this.mainCamera.mode = Camera$1.PERSPECTIVE_CAMERA,
- this.mainCamera.speed = .1,
- this.mainCamera.angularSensibility = _,
- this.mainCamera.setTarget(new Vector3(0,1010,0)),
- this.mainCamera.minZ = d,
- this.mainCamera.fov = Math.PI * this.yuvInfo.fov / 180,
- this.mainCamera.maxZ = c,
- this.mainCamera.fovMode = Camera$1.FOVMODE_HORIZONTAL_FIXED,
- this.cgCamera = new FreeCamera("camera_temp",new Vector3(0,1e3,0),this.scene),
- this.cgCamera.mode = Camera$1.PERSPECTIVE_CAMERA,
- this.cgCamera.speed = .1,
- this.cgCamera.setTarget(new Vector3(0,1010,0)),
- this.cgCamera.maxZ = c,
- this.cgCamera.minZ = d,
- this.cgCamera.fovMode = Camera$1.FOVMODE_HORIZONTAL_FIXED,
- this.cameraFovChange(this.yuvInfo)
- }
- ,
- this.cameraFovChange = s=>{
- this.yuvInfo = s;
- const c = s.width
- , d = s.height
- , _ = this.canvas.width
- , b = this.canvas.height
- , k = s.fov;
- if (this.forceKeepVertical == !0) {
- const j = c / (2 * Math.tan(Math.PI * k / 360))
- , $ = 2 * Math.atan(d / (2 * j));
- this.mainCamera.fov = $,
- this.cgCamera.fov = $,
- this.mainCamera.fovMode = Camera$1.FOVMODE_VERTICAL_FIXED,
- this.cgCamera.fovMode = Camera$1.FOVMODE_VERTICAL_FIXED
- } else if (this.mainCamera.fovMode = Camera$1.FOVMODE_HORIZONTAL_FIXED,
- this.cgCamera.fovMode = Camera$1.FOVMODE_HORIZONTAL_FIXED,
- _ / b < c / d && this.mainCamera.fov) {
- const j = b
- , $ = _
- , _e = j * c / d / (2 * Math.tan(k * Math.PI / 360))
- , et = 2 * Math.atan($ / (2 * _e));
- this.mainCamera.fov = et,
- this.cgCamera.fov = et
- } else
- this.mainCamera.fov = Math.PI * k / 180,
- this.cgCamera.fov = Math.PI * k / 180
- }
- ,
- this.setCameraPose = s=>{
- var _;
- const c = ue4Position2Xverse(s.position);
- let d = null;
- s.rotation != null && (d = ue4Rotation2Xverse(s.rotation)),
- this._cameraPose = {
- position: c
- },
- d != null && (this._cameraPose.rotation = d),
- this.scene.activeCamera === this.mainCamera && !((_ = this.mainCamera) != null && _.isDisposed()) && this._setCamPositionRotation(this.mainCamera, this._cameraPose)
- }
- ,
- this._setCamPositionRotation = (s,c)=>{
- var d, _;
- c.position && (s.position = (d = c.position) == null ? void 0 : d.clone()),
- c.rotation && (s.rotation = (_ = c.rotation) == null ? void 0 : _.clone())
- }
- ,
- this.switchCamera = s=>{
- var c;
- (c = this.scene.activeCamera) == null || c.detachControl(this.canvas),
- this.scene.activeCamera = s
- }
- ,
- this.reCalXYZRot = (s,c)=>(s = s % (2 * Math.PI),
- Math.abs(c - s) >= Math.PI && (s = s - 2 * Math.PI),
- s),
- this._moveCam = (s,c,d,_,b,k,j,$)=>{
- const _e = (st,ut,ct)=>(st.x = this.reCalXYZRot(st.x, ut.x),
- st.y = this.reCalXYZRot(st.y, ut.y),
- st.z = this.reCalXYZRot(st.z, ut.z),
- new Vector3((ut.x - st.x) * ct + st.x,(ut.y - st.y) * ct + st.y,(ut.z - st.z) * ct + st.z))
- , et = function(st, ut, ct) {
- return new Vector3((ut.x - st.x) * ct + st.x,(ut.y - st.y) * ct + st.y,(ut.z - st.z) * ct + st.z)
- }
- , tt = new Animation("myAnimation1","position",j,Animation.ANIMATIONTYPE_VECTOR3,Animation.ANIMATIONLOOPMODE_CONSTANT);
- let rt = []
- , it = c
- , nt = d;
- for (let st = 0; st < k; ++st)
- rt.push({
- frame: st,
- value: et(it, nt, st / k)
- });
- rt.push({
- frame: rt.length,
- value: et(it, nt, 1)
- }),
- tt.setKeys(rt);
- const ot = new Animation("myAnimation2","rotation",j,Animation.ANIMATIONTYPE_VECTOR3,Animation.ANIMATIONLOOPMODE_CONSTANT);
- rt = [],
- it = _,
- nt = b;
- for (let st = 0; st < k; ++st)
- rt.push({
- frame: st,
- value: _e(it, nt, st / k)
- });
- rt.push({
- frame: rt.length,
- value: _e(it, nt, 1)
- }),
- ot.setKeys(rt),
- s.animations.push(ot),
- s.animations.push(tt);
- const at = this.scene.beginAnimation(s, 0, k, !1);
- at.onAnimationEnd = ()=>{
- $(),
- at.stop(),
- at.animationStarted = !1
- }
- }
- ,
- this.scene = i,
- this.canvas = e,
- this.yuvInfo = o.yuvInfo,
- o.forceKeepVertical != null && (this.forceKeepVertical = o.forceKeepVertical),
- this.initCamera(o.cameraParam)
- }
- get MainCamera() {
- return this.mainCamera
- }
- get CgCamera() {
- return this.cgCamera
- }
- getCameraHorizonFov() {
- return this.mainCamera.fovMode == Camera$1.FOVMODE_HORIZONTAL_FIXED ? this.mainCamera.fov : Math.PI * this.yuvInfo.fov / 180
- }
- changeMainCameraRotationDamping(e=2e3) {
- this.mainCamera.angularSensibility = e
- }
- removeMainCameraRotationLimit() {
- this.maincameraRotLimitObserver != null && this.mainCamera.onAfterCheckInputsObservable.remove(this.maincameraRotLimitObserver)
- }
- setMainCameraInfo(e) {
- const {maxZ: i=1e4, minZ: o=.1, angularSensibility: s=2e3} = e;
- this.mainCamera.maxZ = i,
- this.mainCamera.minZ = o,
- this.mainCamera.angularSensibility = s
- }
- getMainCameraInfo() {
- return {
- maxZ: this.mainCamera.maxZ,
- minZ: this.mainCamera.minZ,
- angularSensibility: this.mainCamera.angularSensibility
- }
- }
- _limitAngle(e, i) {
- return Math.abs(Math.abs(i[0] - i[1]) - 360) < 1e-6 || (e = (e % 360 + 360) % 360,
- i[0] = (i[0] % 360 + 360) % 360,
- i[1] = (i[1] % 360 + 360) % 360,
- 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])),
- e
- }
- setMainCameraRotationLimit(e, i) {
- this.maincameraRotLimitObserver != null && this.removeMainCameraRotationLimit();
- const o = this.mainCamera
- , {yaw: s, pitch: c, roll: d} = e
- , {yaw: _, pitch: b, roll: k} = i;
- if (_ < 0 || b < 0 || k < 0)
- throw new Error("\u76F8\u673A\u65CB\u8F6C\u9650\u5236\u53EA\u80FD\u8BBE\u7F6E\u4E3A\u5927\u4E8E0");
- const j = [c - b, c + b]
- , $ = [s - _, s + _]
- , _e = [d - k, d + k];
- this.maincameraRotLimitObserver = o.onAfterCheckInputsObservable.add(()=>{
- let {pitch: et, yaw: tt, roll: rt} = xverseRotation2Ue4(o.rotation);
- et = this._limitAngle(et, j),
- tt = this._limitAngle(tt, $),
- rt = this._limitAngle(rt, _e),
- o.rotation = ue4Rotation2Xverse({
- pitch: et,
- yaw: tt,
- roll: rt
- })
- }
- )
- }
- setMainCameraRotationLimitByAnchor(e, i, o) {
- this.maincameraRotLimitObserver != null && this.removeMainCameraRotationLimit();
- const s = this.mainCamera
- , c = ue4Rotation2Xverse_mesh(i)
- , d = ue4Rotation2Xverse_mesh(o);
- d != null && c != null && e.mesh != null && (this.maincameraRotLimitObserver = s.onAfterCheckInputsObservable.add(()=>{
- const _ = e.mesh.rotation;
- 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)),
- 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)),
- 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))
- }
- ))
- }
- getCameraPose() {
- const e = xversePosition2Ue4({
- x: this.mainCamera.position.x,
- y: this.mainCamera.position.y,
- z: this.mainCamera.position.z
- })
- , i = xverseRotation2Ue4({
- x: this.mainCamera.rotation.x,
- y: this.mainCamera.rotation.y,
- z: this.mainCamera.rotation.z
- });
- return {
- position: e,
- rotation: i
- }
- }
- changeCameraFov(e, i) {
- this.mainCamera.fov = e,
- i != null && (this.mainCamera.fovMode = i == 0 ? Camera$1.FOVMODE_HORIZONTAL_FIXED : Camera$1.FOVMODE_VERTICAL_FIXED)
- }
- controlCameraRotation(e, i, o=.5, s=.5) {
- const c = {
- pitch: s * i * 180,
- yaw: o * e * 180,
- roll: 0
- };
- this.addRot(c)
- }
- addRot(e) {
- const i = this.mainCamera
- , o = ue4Rotation2Xverse_mesh(e);
- o != null && i.rotation.addInPlace(o)
- }
- getCameraFov() {
- return this.mainCamera.fov
- }
- allowMainCameraController() {
- this.mainCamera.attachControl(this.canvas, !0)
- }
- detachMainCameraController() {
- this.mainCamera.detachControl(this.canvas)
- }
- forceChangeSavedCameraPose(e) {
- this.saveCameraPose != null && (e.position != null && (this.saveCameraPose.position = ue4Position2Xverse(e.position)),
- e.rotation != null && (this.saveCameraPose.rotation = ue4Rotation2Xverse(e.rotation)))
- }
- changeToFirstPersonView(e) {
- this.saveCameraPose = {
- position: this.mainCamera.position.clone(),
- rotation: this.mainCamera.rotation.clone()
- },
- this.mainCamera.attachControl(this.canvas, !0),
- e.position != null && (this.mainCamera.position = ue4Position2Xverse(e.position)),
- e.rotation != null && (this.mainCamera.rotation = ue4Rotation2Xverse(e.rotation))
- }
- changeToThirdPersonView() {
- this.saveCameraPose != null && this.mainCamera != null && (this.mainCamera.position = this.saveCameraPose.position.clone(),
- this.mainCamera.rotation = this.saveCameraPose.rotation.clone(),
- this.mainCamera.detachControl(this.canvas))
- }
- switchToMainCamera() {
- this.switchCamera(this.mainCamera)
- }
- switchToCgCamera() {
- this.switchCamera(this.cgCamera)
- }
- moveMainCamera(e, i, o, s, c) {
- this._moveCam(this.mainCamera, this.mainCamera.position, e, this.mainCamera.rotation, i, o, s, c)
- }
- }
- function uuid$2() {
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, a=>{
- const e = Math.random() * 16 | 0;
- return (a === "x" ? e : e & 3 | 8).toString(16)
- }
- )
- }
- function hashCode(a) {
- let e = 0, i, o;
- if (a == null || a.length === 0)
- return e;
- for (i = 0; i < a.length; i++)
- o = a.charCodeAt(i),
- e = (e << 5) - e + o,
- e |= 0;
- return e
- }
- const log$w = new Logger$1("XStaticMeshComponent")
- , _XStaticMeshComponent = class {
- constructor(a) {
- this.reg_staticmesh_partupdate = ()=>{
- if (this._allowRegionUpdate && (this.scene.getFrameId(),
- this._meshUpdateFrame()),
- this._allowRegionForceLod) {
- this.scene.getFrameId() % 2 == 0 && this.setOneRegionLod(this._meshInfoKeys[this._currentUpdateRegionCount % this._meshInfoKeys.length].toString(), this._forceLod);
- let i = !0;
- const o = Array.from(this._currentMeshUsedLod.keys());
- if (o.length > 0) {
- for (let s = 0; s < o.length; ++s)
- this._currentMeshUsedLod.get(o[s]) != this._forceLod && (i = !1);
- i && (this._allowRegionForceLod = !1)
- }
- }
- }
- ,
- this.setMeshInfo = (e,i="")=>{
- this._abosoluteUrl != e && (this._abosoluteUrl.length > 0 && this.deleteLastRegionMesh(),
- this._partMeshSkinInfo = i,
- this._abosoluteUrl = e,
- this._rootDir = this._abosoluteUrl.slice(0, -4) + "/",
- this.parseJson(this._rootDir + "meshInfo.json").then(()=>{
- this.startMeshUpdate()
- }
- ))
- }
- ,
- this._meshUpdateFrame = ()=>{
- {
- let e = this._meshInfoKeys[this._currentUpdateRegionCount % this._meshInfoKeys.length];
- const i = !0;
- let o = 3;
- if (this._scenemanager != null && this._scenemanager.cameraComponent != null) {
- const s = this._getMainPlayerPosition();
- if (s != null) {
- if (this._cameraInRegionId >= 0) {
- const d = this.getRegionIdWhichIncludeCamera(s);
- (this._cameraInRegionId != d || this.regionIdInCamera.length == 0) && (this._cameraInRegionId = d,
- this.regionIdInCamera = this._getNeighborId(this._cameraInRegionId.toString()),
- this.regionIdInCameraConst = this.regionIdInCamera.slice());
- let _ = this.regionIdInCamera.pop();
- for (; _ != null; )
- if (this._notUsedRegionLists.indexOf(_) >= 0)
- _ = this.regionIdInCamera.pop();
- else
- break;
- _ != null && (e = _.toString())
- } else
- this._cameraInRegionId = this.getRegionIdWhichIncludeCamera(s);
- if (this._currentMeshUsedLod.size == 0 || this._notUsedRegionLists.indexOf(parseInt(e)) >= 0) {
- e = this._cameraInRegionId.toString();
- const d = this._getNeighborId(e);
- for (; d.length == 0 && (e = this.getNearestRegionIdWithCamera(s).toString()),
- this._notUsedRegionLists.indexOf(parseInt(e)) >= 0; )
- e = d.pop().toString()
- }
- const c = this._meshInfoJson[this._cameraInRegionId.toString()].lod;
- o = 3,
- 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]
- }
- }
- this.setOneRegionLod(e, o, i),
- this.updateRegionNotInLocalNeighbor(),
- this.cleanRootNodes()
- }
- }
- ,
- this.updateRegionNotInLocalNeighbor = ()=>{
- Array.from(this._currentMeshUsedLod.keys()).forEach(i=>{
- this.regionIdInCameraConst.indexOf(parseInt(i)) < 0 && this.setOneRegionLod(i, -1)
- }
- )
- }
- ,
- this.cleanRootNodes = ()=>{
- if (this.scene.getFrameId() % 3 == 0) {
- const e = [];
- this.scene.rootNodes.forEach(i=>{
- (i.getClassName() == "TransformNode" && i.getChildren().length == 0 || i.getClassName() == "Mesh" && i.name == "__root__" && i.getChildren().length == 0) && e.push(i)
- }
- ),
- e.forEach(i=>{
- i.dispose()
- }
- )
- }
- }
- ,
- this.setOneRegionLod = (e,i,o=!0)=>{
- this._currentUpdateRegionCount++;
- const s = this._calHashCode(this._rootDir)
- , c = "region_" + s + "_" + e;
- if (i < 0) {
- this._currentMeshUsedLod.has(e) && (this._currentMeshUsedLod.delete(e),
- this._currentPartGroup.delete(c),
- this.deleteMeshesByCustomProperty("group", "region_" + s + "_" + e));
- return
- }
- const d = this._rootDir + e + "_lod" + i + "_xverse.glb"
- , _ = this._currentMeshUsedLod.get(e);
- this._currentPartGroup.add(c),
- _ != null ? _ != i && (this._currentMeshUsedLod.set(e, i),
- this._scenemanager.addNewLowPolyMesh({
- url: d,
- group: "region_" + s + "_" + e,
- pick: !0,
- lod: i,
- skinInfo: this._partMeshSkinInfo
- }, [{
- group: "region_" + s + "_" + e,
- mode: 0
- }])) : (this._currentMeshUsedLod.set(e, i),
- this._scenemanager.addNewLowPolyMesh({
- url: d,
- group: "region_" + s + "_" + e,
- pick: !0,
- lod: i,
- skinInfo: this._partMeshSkinInfo
- }))
- }
- ,
- this.checkPointInView = ({x: e, y: i, z: o})=>{
- const s = ue4Position2Xverse({
- x: e,
- y: i,
- z: o
- });
- if (!s)
- return !1;
- for (let c = 0; c < 6; c++)
- if (this.scene.frustumPlanes[c].dotCoordinate(s) < 0)
- return !1;
- return !0
- }
- ,
- this.addNewLowPolyMesh = (e,i,o)=>{
- if (!e.url.endsWith("glb") && !e.url.startsWith("blob:"))
- return e.url.endsWith("zip") ? (this.setMeshInfo(e.url, e.skinInfo),
- Promise.resolve(!0)) : (log$w.error("[Engine] input model path is error! ", e.url),
- Promise.reject(new XLowpolyModelError("[Engine] input model path is error! " + e.url)));
- {
- const s = e.url;
- return new Promise((c,d)=>this._scenemanager.urlTransformer(e.url).then(_=>{
- e.url = _;
- const b = new XStaticMeshFromOneGltf(this.scene,e)
- , k = Date.now();
- return new Promise((j,$)=>{
- b.loadMesh(o, !0).then(_e=>{
- const et = Date.now();
- if (this._scenemanager.engineRunTimeStats.timeArray_loadStaticMesh.add(et - k),
- _e == !0) {
- const tt = this.getLowModelType(e);
- let rt = 0;
- if (this._lowModel_group.has(tt) && (rt = this._lowModel_group.get(tt).length),
- o != null && this._scenemanager.currentShader != null && this._scenemanager.currentShader.name != o.name && b.setMaterial(this._scenemanager.currentShader),
- this._allowRegionUpdate == !1 && tt.startsWith("region_"))
- b.dispose();
- else if (this._staticmeshes.push(b),
- this.lowmodelGroupMapAddValue(tt, b),
- i != null && i.length > 0) {
- const it = [];
- for (let nt = 0; nt < i.length; ++nt)
- it.push(i[nt].group),
- this.updateLowModelGroup(i[nt], tt, rt)
- }
- this._scenemanager.engineRunTimeStats.timeArray_updateStaticMesh.add(Date.now() - et),
- j(!0)
- } else
- $(new XLowpolyModelError("[Engine] after lowmodel error!"))
- }
- ).catch(_e=>{
- log$w.error("[Engine] load Mesh [" + s + "] error! " + _e),
- $(new XLowpolyModelError(`[Engine] load Mesh [${s}] error! ${_e}`))
- }
- )
- }
- )
- }
- ).then(_=>{
- _ == !0 ? (log$w.info(`[Engine] load Mesh [${s}] successfully.`),
- c(!0)) : d(!1)
- }
- ).catch(_=>{
- log$w.error("[Engine] addNewLowPolyMesh [" + s + "] error! " + _),
- d(new XLowpolyModelError(`[Engine] addNewLowPolyMesh [${s}] error! ${_}`))
- }
- ))
- }
- }
- ,
- this.toggleLowModelVisibility = e=>{
- const {vis: i, groupName: o="", skinInfo: s=""} = e;
- this._meshVis = i,
- this._meshVisTypeName = {
- groupName: o,
- skinInfo: s
- },
- this._doMeshVisChangeNumber = 0,
- o == _XStaticMeshComponent.ALL_MESHES || this._currentPartGroup.has(o) == !0 || this._partMeshSkinInfo == s ? i == !1 ? (this._visCheckDurationFrameNumber = 100,
- this.stopMeshUpdate()) : (this._visCheckDurationFrameNumber = 1,
- this.startMeshUpdate()) : this._visCheckDurationFrameNumber = 1
- }
- ,
- this.reg_staticmesh_visibility = ()=>{
- if (this._doMeshVisChangeNumber >= 0)
- if (this._doMeshVisChangeNumber < this._visCheckDurationFrameNumber)
- if (this._doMeshVisChangeNumber = this._doMeshVisChangeNumber + 1,
- this._meshVisTypeName.groupName == _XStaticMeshComponent.ALL_MESHES)
- this._lowModel_group.forEach((e,i)=>{
- for (let o = 0, s = e.length; o < s; ++o)
- e[o].toggleVisibility(this._meshVis)
- }
- );
- else {
- if (this._lowModel_group.has(this._meshVisTypeName.groupName))
- for (let e = 0; e < this._lowModel_group.get(this._meshVisTypeName.groupName).length; ++e)
- this._lowModel_group.get(this._meshVisTypeName.groupName)[e].toggleVisibility(this._meshVis);
- if (this._meshVisTypeName.skinInfo != "")
- for (let e = 0; e < this._staticmeshes.length; ++e)
- this._staticmeshes[e].skinInfo == this._meshVisTypeName.skinInfo && this._staticmeshes[e].toggleVisibility(this._meshVis)
- }
- else
- this._meshVis = !0,
- this._meshVisTypeName = {
- groupName: "",
- skinInfo: ""
- },
- this._doMeshVisChangeNumber = -1
- }
- ,
- this._getMeshesByCustomProperty = (e,i)=>{
- let o = [];
- return this._staticmeshes.forEach(s=>{
- s[e] != null && s[e] == i && (o = o.concat(s.meshes))
- }
- ),
- o
- }
- ,
- this._lowModel_group = new Map,
- this._staticmeshes = [],
- this._meshInfoJson = null,
- this._meshInfoKeys = [],
- this._currentUpdateRegionCount = 0,
- this._abosoluteUrl = "",
- this._partMeshSkinInfo = "",
- this._forceLod = 3,
- this._allowRegionUpdate = !1,
- this._allowRegionForceLod = !1,
- this._currentMeshUsedLod = new Map,
- this._currentPartGroup = new Set,
- this._scenemanager = a,
- this.scene = a.Scene,
- this.regionIdInCamera = [],
- this.regionIdInCameraConst = [],
- this._cameraInRegionId = -1,
- this._rootDir = "",
- this._meshVis = !0,
- this._meshVisTypeName = {
- groupName: "",
- skinInfo: ""
- },
- this._doMeshVisChangeNumber = -1,
- this._visCheckDurationFrameNumber = -1,
- this._regionLodRule = [0, 1, 3, 3, -1],
- this.initCgLowModel(),
- this._regionPartLoop()
- }
- get cameraInRegionId() {
- return this._cameraInRegionId
- }
- setRegionLodRule(a) {
- return a.length != 5 ? !1 : (a.forEach(e=>{}
- ),
- this._regionLodRule = a,
- !0)
- }
- get lowModel_group() {
- return this._lowModel_group
- }
- _regionPartLoop() {
- this.scene.registerBeforeRender(this.reg_staticmesh_partupdate),
- this.scene.registerAfterRender(this.reg_staticmesh_visibility)
- }
- _globalSearchCameraInWhichRegion(a, e) {
- let i = -1;
- for (let o = 0; o < e.length; ++o) {
- const s = this._meshInfoJson[e[o].toString()].boundingbox
- , c = s[0]
- , d = s[1];
- 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]) {
- i = parseInt(e[o].toString());
- break
- }
- }
- return i
- }
- getRegionIdByPosition(a) {
- return this.getRegionIdWhichIncludeCamera(a)
- }
- getRegionIdWhichIncludeCamera(a) {
- let e = -1;
- if (this._allowRegionUpdate == !1)
- return e;
- if (this._cameraInRegionId == -1 ? e = this._globalSearchCameraInWhichRegion(a, this._meshInfoKeys) : (e = this._globalSearchCameraInWhichRegion(a, this.regionIdInCameraConst),
- e == -1 && (e = this._globalSearchCameraInWhichRegion(a, this._meshInfoKeys))),
- e == -1) {
- let i = 1e7;
- for (let o = 0; o < this._meshInfoKeys.length; ++o) {
- const s = this._meshInfoJson[this._meshInfoKeys[o]].center
- , c = Math.abs(a.x - s[0]) + Math.abs(a.y - s[1]);
- i > c && (i = c,
- e = parseInt(this._meshInfoKeys[o]))
- }
- }
- return e
- }
- getNearestRegionIdWithCamera(a) {
- let e = 1
- , i = 1e7;
- for (let o = 0; o < this._meshInfoKeys.length; ++o) {
- if (this._notUsedRegionLists.indexOf(parseInt(this._meshInfoKeys[o])) >= 0)
- continue;
- const s = this._meshInfoJson[this._meshInfoKeys[o]].center
- , c = Math.abs(a.x - s[0]) + Math.abs(a.y - s[1]);
- i > c && (i = c,
- e = parseInt(this._meshInfoKeys[o]))
- }
- return e
- }
- _getNeighborId(a) {
- const e = this._meshInfoJson[a].lod;
- let i = [];
- const o = Object.keys(e);
- for (let s = o.length - 1; s >= 0; --s)
- i = i.concat(e[o[s]]);
- return i.push(parseInt(a)),
- i
- }
- _getMainPlayerPosition() {
- const a = this._scenemanager.cameraComponent.getCameraPose().position
- , e = this._scenemanager.avatarComponent.getMainAvatar();
- if (e != null && e != null) {
- const i = e.position;
- if (i != null)
- return i
- }
- return a
- }
- _calHashCode(a) {
- return hashCode(a) + "_" + this._partMeshSkinInfo
- }
- forceAllRegionLod(a=3) {
- a < 0 && (a = 0),
- a > 3 && (a = 3),
- this.stopMeshUpdate(),
- this._allowRegionForceLod = !0,
- this._forceLod = a
- }
- deleteLastRegionMesh() {
- if (this._rootDir != "") {
- const a = this._calHashCode(this._rootDir);
- this._currentMeshUsedLod.clear(),
- this._currentPartGroup.clear(),
- this._meshInfoJson = null,
- this._meshInfoKeys = [],
- this._currentUpdateRegionCount = 0,
- this._orijson = null,
- this._notUsedRegionLists = [],
- this._partMeshSkinInfo = "",
- this._abosoluteUrl = "",
- this.stopMeshUpdate(),
- this.deleteMeshesByCustomProperty("group", "region_" + a, !0)
- }
- }
- startMeshUpdate() {
- this._allowRegionUpdate == !1 && this._meshInfoJson != null && this._abosoluteUrl != "" && this._meshInfoKeys.length > 0 && (this._allowRegionUpdate = !0)
- }
- stopMeshUpdate() {
- this._allowRegionUpdate = !1
- }
- parseJson(a) {
- return new Promise((e,i)=>this._scenemanager.urlTransformer(a).then(o=>{
- const s = new XMLHttpRequest;
- s.open("get", o),
- s.send(null),
- s.onload = ()=>{
- if (s.status == 200) {
- const c = JSON.parse(s.responseText);
- this._orijson = c,
- this._meshInfoJson = this._orijson.usedRegion,
- this._notUsedRegionLists = this._orijson.notUsedRegion,
- this._meshInfoKeys = Object.keys(this._meshInfoJson),
- log$w.info("[Engine] parse zip mesh info successful"),
- e()
- }
- }
- ,
- s.onerror = ()=>{
- log$w.error(`[Engine] load zip mesh info json error, (provided by blob): ${o}`),
- i(new XLowpolyJsonError(`[Engine] load zip mesh info json error, (provided by blob): ${o}`))
- }
- }
- ).catch(o=>{
- log$w.error(`[Engine] load zip mesh info json error: ${o}, link:${a}`),
- i(new XLowpolyJsonError(`[Engine] load zip mesh info json error: ${o}, link: ${a}`))
- }
- ))
- }
- initCgLowModel() {
- const a = MeshBuilder.CreatePlane("CgPlane", {
- size: 400
- });
- a.position = new Vector3(0,1010,0),
- a.rotation = new Vector3(3 * Math.PI / 2,0,0),
- this._CgPlane = new XStaticMesh({
- id: "CgPlane",
- mesh: a,
- xtype: EMeshType.Cgplane
- }),
- this._CgPlane.hide()
- }
- getLowModelType(a) {
- let e = "";
- return a.group != null ? e = a.group : e = "default",
- e
- }
- lowmodelGroupMapAddValue(a, e) {
- const i = this._lowModel_group.get(a);
- i != null ? (i.push(e),
- this._lowModel_group.set(a, i)) : this._lowModel_group.set(a, [e])
- }
- updateLowModelGroup(a, e, i) {
- let o = i;
- a.group == e || (o = -1),
- 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)
- }
- toggleVisibleLowModelGroup(a, e, i=-1) {
- if (this._lowModel_group.has(e)) {
- const o = this._lowModel_group.get(e);
- let s = o.length;
- i >= 0 && s >= i && (s = i);
- for (let c = 0; c < s; ++c)
- o[c].toggleVisibility(a)
- }
- }
- deleteLowModelGroup(a, e=-1) {
- if (this._lowModel_group.has(a)) {
- const s = this._lowModel_group.get(a);
- let c = s.length;
- e >= 0 && c >= e && (c = e);
- for (let d = 0; d < c; ++d)
- s[d].dispose();
- e >= 0 ? this._lowModel_group.set(a, this._lowModel_group.get(a).slice(c)) : this._lowModel_group.delete(a)
- }
- const i = this._lowModel_group.get(a)
- , o = [];
- i != null && i.length > 0 ? this._staticmeshes.forEach(s=>{
- if (s.group != a)
- o.push(s);
- else
- for (let c = 0; c < i.length; ++c)
- s.groupUuid == i[c].groupUuid && o.push(s)
- }
- ) : this._staticmeshes.forEach(s=>{
- s.group != a && o.push(s)
- }
- ),
- this._staticmeshes = o
- }
- deleteMeshesByGroup(a) {
- this.deleteLowModelGroup(a)
- }
- deleteMeshesById(a) {
- this.deleteMeshesByCustomProperty("id", a)
- }
- deleteMeshesByLoD(a) {
- this.deleteMeshesByCustomProperty("lod", a)
- }
- deleteMeshesBySkinInfo(a) {
- this.deleteMeshesByCustomProperty("skinInfo", a)
- }
- removeMeshesFromSceneByGroup(a) {
- this.removeMeshesFromSceneByCustomProperty("group", a)
- }
- removeMeshesFromSceneById(a) {
- this.removeMeshesFromSceneByCustomProperty("id", a)
- }
- addMeshesToSceneByGroup(a) {
- this.addMeshesToSceneByCustomProperty("group", a)
- }
- addMeshesToSceneById(a) {
- this.addMeshesToSceneByCustomProperty("id", a)
- }
- removeMeshesFromSceneByCustomProperty(a, e, i=!1) {
- this._staticmeshes.forEach(o=>{
- o.isinscene && o[a] != null && (i ? o[a].indexOf(e) < 0 || o.removeFromScene() : o[a] != e || o.removeFromScene())
- }
- )
- }
- addMeshesToSceneByCustomProperty(a, e, i=!1) {
- this._staticmeshes.forEach(o=>{
- o.isinscene == !1 && o[a] != null && (i ? o[a].indexOf(e) < 0 || o.addToScene() : o[a] != e || o.addToScene())
- }
- )
- }
- deleteMeshesByCustomProperty(a, e, i=!1) {
- const o = [];
- this._staticmeshes.forEach(c=>{
- c[a] != null && (i ? c[a].indexOf(e) < 0 ? o.push(c) : c.dispose() : c[a] != e ? o.push(c) : c.dispose())
- }
- ),
- this._staticmeshes = o;
- const s = Array.from(this._lowModel_group.keys());
- for (let c = 0; c < s.length; ++c) {
- const d = s[c]
- , _ = this._lowModel_group.get(d);
- if (_ != null) {
- const b = [];
- for (let k = 0; k < _.length; ++k)
- _[k][a] != null && (i ? _[k][a].indexOf(e) < 0 && b.push(_[k]) : _[k][a] != e && b.push(_[k]));
- b.length > 0 ? this._lowModel_group.set(d, b) : this._lowModel_group.delete(d)
- }
- }
- }
- getMeshes() {
- let a = [];
- for (let e = 0; e < this._staticmeshes.length; ++e)
- a = a.concat(this._staticmeshes[e].meshes);
- return a
- }
- getCgMesh() {
- return this._CgPlane
- }
- getMeshesByGroup(a="default") {
- const e = this._lowModel_group.get(a);
- if (e != null) {
- let i = [];
- for (let o = 0; o < e.length; ++o)
- i = i.concat(e[o].meshes);
- return i
- } else
- return null
- }
- getMeshesByGroup2(a="default") {
- return this._getMeshesByCustomProperty("group", a)
- }
- }
- ;
- let XStaticMeshComponent = _XStaticMeshComponent;
- XStaticMeshComponent.ALL_MESHES = "ALL_MESHES";
- class XStaticMeshFromOneGltf {
- constructor(e, i) {
- this.loadMesh = (o,s)=>{
- const c = this._meshes.length
- , d = s ? 1 : 0
- , _ = this._url;
- return SceneLoader.LoadAssetContainerAsync("", _, this._scene, ()=>{
- this._scene.blockMaterialDirtyMechanism = !0
- }
- , ".glb").then(b=>{
- for (let k = b.materials.length - 1; k >= 0; --k)
- b.materials[k].dispose();
- this._scene.blockMaterialDirtyMechanism = !0;
- for (let k = 0; k < b.meshes.length; ++k) {
- const j = b.meshes[k];
- if ("instances"in j) {
- "visibility"in j && (j.visibility = 0),
- "isPickable"in j && (j.isPickable = this._pickable),
- o != null && (j.material = o),
- "hasVertexAlpha"in j && (j.hasVertexAlpha = !1);
- const $ = new XStaticMesh({
- id: this._groupUuid + "-" + Math.random().toString(36).substr(2, 5),
- mesh: j,
- lod: this._lod,
- group: this._group,
- url: this._url,
- xtype: EMeshType.XStaticMesh,
- skinInfo: this._skinInfo
- });
- this._meshes.push($)
- }
- this._scene.addMesh(j)
- }
- return !0
- }
- ).then(()=>{
- this._isInScene = !0;
- for (let b = c; b < this._meshes.length; ++b)
- this._meshes[b].mesh.visibility = d;
- return Promise.resolve(!0)
- }
- ).catch(b=>{
- log$w.error("[Engine] input gltf mesh uri error! " + b),
- Promise.reject(new XLowpolyModelError("[Engine] input gltf mesh uri error! " + b))
- }
- )
- }
- ,
- this._meshes = [],
- this._scene = e,
- this._url = i.url,
- i.group != null ? this._group = i.group : this._group = "default",
- i.pick != null ? this._pickable = i.pick : this._pickable = !1,
- i.id != null ? this._id = i.id : this._id = "default",
- i.lod != null ? this._lod = i.lod : this._lod = -1,
- i.skinInfo != null ? this._skinInfo = i.skinInfo : this._skinInfo = "default",
- this._groupUuid = uuid$2(),
- this._isInScene = !1
- }
- get isinscene() {
- return this._isInScene
- }
- get groupUuid() {
- return this._groupUuid
- }
- get skinInfo() {
- return this._skinInfo
- }
- get group() {
- return this._group
- }
- get meshes() {
- return this._meshes
- }
- get url() {
- return this._url
- }
- get id() {
- return this._id
- }
- get lod() {
- return this._lod
- }
- removeFromScene() {
- if (this._isInScene) {
- this._isInScene = !1;
- for (let e = 0, i = this._meshes.length; e < i; ++e)
- this._meshes[e].mesh != null && this._scene.removeMesh(this._meshes[e].mesh)
- }
- }
- addToScene() {
- if (this._isInScene == !1) {
- this._isInScene = !0;
- for (let e = 0, i = this._meshes.length; e < i; ++e)
- this._meshes[e].mesh != null && this._scene.addMesh(this._meshes[e].mesh)
- }
- }
- toggleVisibility(e) {
- const i = e ? 1 : 0;
- for (let o = 0, s = this._meshes.length; o < s; ++o)
- "visibility"in this._meshes[o].mesh && (this._meshes[o].mesh.visibility = i)
- }
- togglePickable(e) {
- for (let i = 0, o = this._meshes.length; i < o; ++i)
- "isPickable"in this._meshes[i].mesh && (this._meshes[i].mesh.isPickable = e)
- }
- setMaterial(e) {
- for (let i = 0, o = this._meshes.length; i < o; ++i)
- "material"in this._meshes[i].mesh && (this._meshes[i].mesh.material = e)
- }
- dispose() {
- for (let e = 0, i = this._meshes.length; e < i; ++e)
- this._meshes[e].mesh.dispose(!1, !1)
- }
- }
- const log$v = new Logger$1("XSceneManager");
- var ECurrentShaderMode = (a=>(a[a.default = 0] = "default",
- a[a.video = 1] = "video",
- a[a.pano = 2] = "pano",
- a))(ECurrentShaderMode || {})
- , EImageQuality = (a=>(a[a.low = 0] = "low",
- a[a.mid = 1] = "mid",
- a[a.high = 2] = "high",
- a))(EImageQuality || {});
- class XSceneManager {
- constructor(e, i, o, s, c) {
- this._forceKeepVertical = !1,
- this._renderStatusCheckCount = 0,
- this._renderStatusNotChecktCount = 0,
- this._nonlinearCanvasResize = !1,
- this._bChangeEngineSize = !0,
- this._mv = [],
- this.uploadHardwareSystemInfo = ()=>{
- const j = this.statisticComponent.getHardwareRenderInfo()
- , $ = this.statisticComponent.getSystemInfo()
- , _e = {
- driver: $.driver,
- vender: $.vender,
- webgl: $.version,
- os: $.os
- };
- log$v.warn(JSON.stringify(j)),
- log$v.warn(JSON.stringify(_e))
- }
- ,
- this.addNewLowPolyMesh = async(j,$)=>(this._currentShader == null && await this.initSceneManager(),
- this._lowpolyManager.addNewLowPolyMesh(j, $, this._currentShader)),
- this.initSceneManager = async()=>(await this._materialManager.initMaterial(),
- this.applyShader()),
- this.registerAfterRender = ()=>{
- var j;
- if (this._forceKeepVertical) {
- const $ = this.canvas.width
- , _e = this.canvas.height;
- let et = 0
- , tt = [[0, 0, 0, 0], [0, 0, 0, 0]];
- 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),
- tt = [[0, 0, $, et], [0, _e - et, $, et]]) : (et = Math.ceil(($ - this._yuvInfo.width * _e / this._yuvInfo.height) / 2),
- tt = [[0, 0, et, _e], [$ - et, 0, et, _e]]),
- et > 0) {
- this.gl.enable(this.gl.SCISSOR_TEST);
- for (let rt = 0; rt < tt.length; ++rt)
- this.gl.scissor(tt[rt][0], tt[rt][1], tt[rt][2], tt[rt][3]),
- this.gl.clearColor(0, 0, 0, 1),
- this.gl.clear(this.gl.COLOR_BUFFER_BIT);
- this.gl.disable(this.gl.SCISSOR_TEST)
- }
- }
- }
- ,
- this.resetRender = ()=>{
- 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))
- }
- ;
- const d = /iphone|ipad/gi.test(window.navigator.userAgent) || i.disableWebGL2;
- o || (o = new Engine(e,!0,{
- preserveDrawingBuffer: !0,
- stencil: !0,
- disableWebGL2Support: d
- },!0)),
- s || (s = new Scene(o)),
- this.scene = s,
- this.engine = o,
- this.canvas = e,
- this.scene.clearColor = new Color4(.7,.7,.7,1),
- this.engine.getCaps().parallelShaderCompile = void 0,
- this._initEngineScaleNumber = this.engine.getHardwareScalingLevel(),
- this.engine.enableOfflineSupport = !1,
- this.engine.doNotHandleContextLost = !0,
- this.scene.clearCachedVertexData(),
- this.scene.cleanCachedTextureBuffer(),
- this.urlTransformer = i.urlTransformer || (j=>Promise.resolve(j)),
- i.logger && Logger$1.setLogger(i.logger),
- this.gl = e.getContext("webgl2", {
- preserveDrawingBuffer: !0
- }) || e.getContext("webgl", {
- preserveDrawingBuffer: !0
- }) || e.getContext("experimental-webgl", {
- preserveDrawingBuffer: !0
- }),
- this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT, 1),
- this._currentPanoId = 0,
- i.forceKeepVertical != null && (this._forceKeepVertical = i.forceKeepVertical),
- i.panoInfo != null && (this.panoInfo = i.panoInfo),
- i.shaderMode != null && (this.shaderMode = i.shaderMode),
- i.yuvInfo != null ? this._yuvInfo = i.yuvInfo : this._yuvInfo = {
- width: i.videoResOriArray[0].width,
- height: i.videoResOriArray[0].height,
- fov: 50
- },
- i.cameraParam != null && (this.cameraParam = i.cameraParam),
- i.nonlinearCanvasResize != null && (this._nonlinearCanvasResize = i.nonlinearCanvasResize),
- this._cameraManager = new XCameraComponent(this.canvas,this.scene,{
- cameraParam: this.cameraParam,
- yuvInfo: this._yuvInfo,
- forceKeepVertical: this._forceKeepVertical
- }),
- this._lowpolyManager = new XStaticMeshComponent(this),
- this._materialManager = new XMaterialComponent(this,{
- videoResOriArray: i.videoResOriArray,
- yuvInfo: this._yuvInfo,
- panoInfo: this.panoInfo,
- shaderMode: this.shaderMode
- }),
- this._statisticManager = new XStats(this),
- this._breathPointManager = new XBreathPointManager(this),
- this._decalManager = new XDecalManager(this),
- this._avatarManager = new XAvatarManager(this),
- this._billboardManager = new XBillboardManager(this),
- this.billboardComponent.loadBackGroundTexToIDB();
- let _ = !1
- , b = !1;
- i.disableLight != null && (_ = i.disableLight),
- i.disablePostprocess != null && (b = i.disablePostprocess),
- _ || (this._lightManager = new XLightManager(this)),
- b || this.postprocessing(),
- this.initSceneManager(),
- this.engineRunTimeStats = new XEngineRunTimeStats,
- /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)),
- this.scene.registerBeforeRender(()=>{
- this._nonlinearCanvasResize && this._bChangeEngineSize && (this.setEngineSize(this._yuvInfo),
- this._bChangeEngineSize = !1)
- }
- ),
- this.scene.registerAfterRender(()=>{
- this._nonlinearCanvasResize || this.registerAfterRender()
- }
- ),
- window.addEventListener("resize", ()=>{
- this._nonlinearCanvasResize ? this._bChangeEngineSize = !0 : this.engine.resize()
- }
- ),
- XBillboardManager.alphaWidthMap = getAlphaWidthMap("Arial", this.scene),
- this.uploadHardwareSystemInfo()
- }
- get yuvInfo() {
- return this.getCurrentShaderMode() == 1 ? this._yuvInfo : {
- width: -1,
- height: -1,
- fov: -1
- }
- }
- set yuvInfo(e) {
- this.getCurrentShaderMode() == 1 && (this._yuvInfo = e,
- this._cameraManager.cameraFovChange(e))
- }
- get mainScene() {
- return this.scene
- }
- get cameraComponent() {
- return this._cameraManager
- }
- get staticmeshComponent() {
- return this._lowpolyManager
- }
- get materialComponent() {
- return this._materialManager
- }
- get statisticComponent() {
- return this._statisticManager
- }
- get avatarComponent() {
- return this._avatarManager
- }
- get lightComponent() {
- return this._lightManager
- }
- get Engine() {
- return this.engine
- }
- get Scene() {
- return this.scene
- }
- get billboardComponent() {
- return this._billboardManager
- }
- get breathPointComponent() {
- return this._breathPointManager
- }
- get skytvComponent() {
- return this._skytv
- }
- get mvComponent() {
- return this._mv
- }
- get decalComponent() {
- return this._decalManager
- }
- get currentShader() {
- return this._currentShader
- }
- get initEngineScaleNumber() {
- return this._initEngineScaleNumber
- }
- setImageQuality(e) {
- e == 0 ? (this.engine.setHardwareScalingLevel(this.adaptRatio(this._initEngineScaleNumber, 1.8)),
- log$v.info("[Engine] change image quality to low")) : e == 1 ? (this.engine.setHardwareScalingLevel(this.adaptRatio(this._initEngineScaleNumber, 1.5)),
- log$v.info("[Engine] change image quality to mid")) : e == 2 && (this.engine.setHardwareScalingLevel(this.adaptRatio(this._initEngineScaleNumber, 1)),
- log$v.info("[Engine] change image quality to high"))
- }
- adaptRatio(e, i) {
- const o = Math.max(this.canvas.clientWidth, this.canvas.clientHeight);
- for (; o / (e * i) < 1e3; )
- if (i = i - .1,
- i < 1.1) {
- i = 1;
- break
- }
- const s = Math.min(this.canvas.clientWidth, this.canvas.clientHeight);
- for (; s / (e * i) > 1e3; )
- if (i = i + .1,
- i >= 2) {
- i = 2;
- break
- }
- return e * i
- }
- setNonlinearCanvasResize(e) {
- this._nonlinearCanvasResize = e,
- this._bChangeEngineSize = e,
- e || this.engine.resize()
- }
- changeCameraFovWithShaderUpdate(e) {
- this.materialComponent.changeCameraFovWithShaderUpdate(e)
- }
- setBackgroundColor(e) {
- this.scene.clearColor = new Color4(e.r,e.g,e.b,e.a)
- }
- setBackgroundImg(e) {
- return this._backgroundImg != null && this._backgroundImg.url == e ? Promise.resolve(!0) : new Promise((i,o)=>{
- this.urlTransformer(e).then(s=>{
- this._backgroundImg == null ? this._backgroundImg = {
- layer: new Layer("tex_background_" + Date.now(),s,this.Scene,!0),
- url: e
- } : this._backgroundImg.url != e && this._backgroundImg.layer != null && this._backgroundImg.layer.texture != null && (this._backgroundImg.layer.texture.updateURL(s),
- this._backgroundImg.layer.name = "tex_background_" + Date.now(),
- this._backgroundImg.url = e),
- i(!0)
- }
- ).catch(s=>{
- log$v.error(`[Engine] set background image Error: ${s}`),
- o(`[Engine] set background image Error: ${s}`)
- }
- )
- }
- )
- }
- cleanTheWholeScene() {
- const e = this.scene.getFrameId();
- this.scene.onBeforeRenderObservable.clear(),
- this.scene.onAfterRenderObservable.clear(),
- this.scene.clearCachedVertexData(),
- this.scene.cleanCachedTextureBuffer(),
- this.scene.registerBeforeRender(()=>{
- this.scene.getFrameId() - e > 5 && this.scene.dispose()
- }
- )
- }
- getAreaAvatar(e, i) {
- const o = [];
- return this._avatarManager.getAvatarList().forEach(s=>{
- const c = e
- , d = s.position;
- d && c && calcDistance3D(c, d) < i && o.push(s.id)
- }
- ),
- o
- }
- setEngineSize(e) {
- const i = e.width
- , o = e.height
- , s = this.canvas.width;
- this.canvas.height,
- this.engine.setSize(Math.round(s), Math.round(s * (o / i)))
- }
- getCurrentShaderMode() {
- return this._currentShader === this._materialManager.getDefaultShader() ? 0 : this._currentShader === this._materialManager.getPureVideoShader() ? 1 : 2
- }
- addSkyTV(e, i) {
- return this._skytv = new XTelevision(this.scene,e,this,i),
- this._skytv
- }
- addMv(e, i) {
- this._mv.push(new XTelevision(this.scene,e,this,i))
- }
- addMeshInfo(e) {
- this._lowpolyManager.setMeshInfo(e)
- }
- applyShader() {
- return new Promise((e,i)=>{
- this.shaderMode == EShaderMode.videoAndPano || this.shaderMode == EShaderMode.video ? this.changeVideoShaderForLowModel() : this.shaderMode == EShaderMode.default && this.changeDefaultShaderForLowModel(),
- e(!0)
- }
- )
- }
- changeHardwareScaling(e) {
- e < 1 ? e = 1 : e > 2.5 && (e = 2.5),
- this._bChangeEngineSize = !0,
- this.engine.setHardwareScalingLevel(this._initEngineScaleNumber * e)
- }
- getCurrentUsedPanoId() {
- return this._currentPanoId
- }
- render() {
- try {
- this.scene.render()
- } catch (e) {
- throw log$v.error(`[Engine] Render Error: ${e}`),
- e
- }
- }
- isReadyToRender(e) {
- const {checkMesh: i=!0, checkEffect: o=!1, checkPostProgress: s=!1, checkParticle: c=!1, checkAnimation: d=!1, materialNameWhiteLists: _=[]} = e;
- if (this.scene._isDisposed)
- return log$v.error("[Engine] this.scene._isDisposed== false "),
- !1;
- let b;
- const k = this.scene.getEngine();
- if (o && !k.areAllEffectsReady())
- return log$v.error("[Engine] engine.areAllEffectsReady == false"),
- !1;
- if (d && this.scene._pendingData.length > 0)
- return log$v.error("[Engine] scene._pendingData.length > 0 && animation error"),
- !1;
- if (i) {
- for (b = 0; b < this.scene.meshes.length; b++) {
- const j = this.scene.meshes[b];
- if (!j.isEnabled() || !j.subMeshes || j.subMeshes.length === 0 || j != null && j.material != null && !(j.material.name.startsWith("Pure") || j.material.name.startsWith("Pano")))
- continue;
- if (!j.isReady(!0))
- 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}`),
- !1;
- const $ = j.hasThinInstances || j.getClassName() === "InstancedMesh" || j.getClassName() === "InstancedLinesMesh" || k.getCaps().instancedArrays && j.instances.length > 0;
- for (const _e of this.scene._isReadyForMeshStage)
- if (!_e.action(j, $))
- 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}`),
- !1
- }
- for (b = 0; b < this.scene.geometries.length; b++)
- if (this.scene.geometries[b].delayLoadState === 2)
- return log$v.error("[Engine] geometry.delayLoadState === 2"),
- !1
- }
- if (s) {
- if (this.scene.activeCameras && this.scene.activeCameras.length > 0) {
- for (const j of this.scene.activeCameras)
- if (!j.isReady(!0))
- return log$v.error("[Engine] camera not ready === false, ", j.name),
- !1
- } else if (this.scene.activeCamera && !this.scene.activeCamera.isReady(!0))
- return log$v.error("[Engine] activeCamera ready === false, ", this.scene.activeCamera.name),
- !1
- }
- if (c) {
- for (const j of this.scene.particleSystems)
- if (!j.isReady())
- return log$v.error("[Engine] particleSystem ready === false, ", j.name),
- !1
- }
- return !0
- }
- changePanoShaderForLowModel(e) {
- return log$v.info(`[Engine] changePanoShaderForLowModel: ${e}`),
- this._materialManager.allowYUVUpdate(),
- new Promise((i,o)=>{
- this._materialManager._isInDynamicRange(e) == !1 && o(!1),
- this._currentPanoId = e,
- this._currentShader = this._materialManager.getDynamicShader(e),
- this.changeShaderForLowModel().then(()=>{
- i(!0)
- }
- )
- }
- )
- }
- changeVideoShaderForLowModel() {
- return log$v.info("[Engine] changeVideoShaderForLowModel"),
- this._currentShader = this._materialManager.getPureVideoShader(),
- this._materialManager.allowYUVUpdate(),
- this.changeShaderForLowModel()
- }
- changeDefaultShaderForLowModel() {
- return log$v.info("[Engine] changeDefaultShaderForLowModel"),
- this._currentShader = this._materialManager.getDefaultShader(),
- this._materialManager.stopYUVUpdate(),
- this.changeShaderForLowModel()
- }
- changeShaderForLowModel() {
- return new Promise((e,i)=>{
- this._lowpolyManager.getMeshes().forEach(o=>{
- o.setMaterial(this._currentShader)
- }
- ),
- this._lowpolyManager.getCgMesh().mesh.material = this._currentShader,
- e(!0)
- }
- )
- }
- setIBL(e) {
- this._lightManager.setIBL(e)
- }
- postprocessing() {
- const e = new DefaultRenderingPipeline("default",!0,this.scene);
- e.imageProcessingEnabled = !1,
- e.bloomEnabled = !0,
- e.bloomThreshold = 1,
- e.bloomWeight = 1,
- e.bloomKernel = 64,
- e.bloomScale = .1
- }
- getGround(e) {
- const i = this._lowpolyManager.getMeshes()
- , o = [];
- return i.forEach(s=>{
- s.mesh.name.indexOf("SM_Stage") >= 0 && o.push(s.mesh)
- }
- ),
- this.Scene.meshes.forEach(s=>{
- s.name.split("_")[0] === "ground" && o.push(s)
- }
- ),
- o
- }
- }
- new Logger$1("XVolume");
- class WorldStore {
- static get DefaultWorld() {
- return this.Instances.length === 0 ? null : this.Instances[this.Instances.length - 1]
- }
- }
- WorldStore.Instances = new Array;
- class XLevel extends XObject {
- constructor() {
- var e;
- super(),
- this._OwningWorld = null,
- (e = XWorld.GetDefaultWorld()) == null || e.Levels.push(this),
- this.Actors = new Array,
- this.Components = new Array
- }
- get OwningWorld() {
- return this._OwningWorld
- }
- set OWningWorld(e) {
- this._OwningWorld = e
- }
- dispose() {
- var i;
- const e = XWorld.GetDefaultWorld().Levels.indexOf(this);
- (i = XWorld.GetDefaultWorld()) == null || i.Levels.splice(e, 1)
- }
- }
- class XWorld extends XObject {
- constructor() {
- super(),
- XWorld.Instances.push(this),
- this._persistentLevel = null,
- this.Levels = new Array,
- this.Components = new Array
- }
- static GetDefaultWorld() {
- return WorldStore.DefaultWorld
- }
- static get Instances() {
- return WorldStore.Instances
- }
- get persistentLevel() {
- return this._persistentLevel == null && (this._persistentLevel = new XLevel),
- this._persistentLevel
- }
- set persistentLevel(e) {
- this._persistentLevel = e
- }
- dispose() {
- const e = XWorld.Instances.indexOf(this);
- XWorld.Instances.splice(e, 1),
- this.Levels = [],
- this.Components = [],
- this._persistentLevel = null
- }
- }
- class XActorComponent extends XObject {
- constructor() {
- super(),
- this._ownerPrivate = null,
- this._worldPrivate = XWorld.GetDefaultWorld(),
- this._tickEnabled = !0
- }
- Tick() {}
- ReceiveTick() {
- this.tickEnabled && this.Tick()
- }
- get tickEnabled() {
- return this._tickEnabled
- }
- set tickEnabled(e) {
- this._tickEnabled = e
- }
- get owner() {
- return this._ownerPrivate
- }
- set owner(e) {
- e && (this._ownerPrivate = e,
- this._outer = e == null ? void 0 : e.outer)
- }
- set outer(e) {
- this._outer = e
- }
- get outer() {
- return this.owner && (this._outer = this.owner.outer),
- this._outer
- }
- RegisterComponentWithWorld(e) {}
- }
- var __defProp$2 = Object.defineProperty
- , __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor
- , __decorateClass$2 = (a,e,i,o)=>{
- for (var s = o > 1 ? void 0 : o ? __getOwnPropDesc$2(e, i) : e, c = a.length - 1, d; c >= 0; c--)
- (d = a[c]) && (s = (o ? d(e, i, s) : d(s)) || s);
- return o && s && __defProp$2(e, i, s),
- s
- }
- ;
- AssetContainer.prototype.clone = function(a, e=!0, i, o=!0) {
- const s = new AssetContainer(this.scene);
- a || (a = "");
- const c = $=>a + "_CloneOf_" + $
- , d = {}
- , _ = {}
- , b = []
- , k = [];
- i || (i = {
- doNotInstantiate: !0
- });
- const j = ($,_e)=>{
- if (d[$.uniqueId] = _e.uniqueId,
- _[_e.uniqueId] = _e,
- c && (_e.name = c($.name)),
- _e instanceof Mesh) {
- const et = _e;
- if (s.meshes.push(_e),
- _e.geometry && s.geometries.push(_e.geometry),
- et.morphTargetManager) {
- const tt = $.morphTargetManager;
- et.morphTargetManager = tt.clone(),
- s.morphTargetManagers.push(et.morphTargetManager);
- for (let rt = 0; rt < tt.numTargets; rt++) {
- const it = tt.getTarget(rt)
- , nt = et.morphTargetManager.getTarget(rt);
- d[it.uniqueId] = nt.uniqueId,
- _[nt.uniqueId] = nt
- }
- }
- } else
- _e instanceof TransformNode && s.transformNodes.push(_e)
- }
- ;
- return this.transformNodes.forEach($=>{
- if (!$.parent) {
- const _e = $.instantiateHierarchy(null, i, (et,tt)=>{
- j(et, tt)
- }
- );
- _e && s.rootNodes.push(_e)
- }
- }
- ),
- this.meshes.forEach($=>{
- if (!$.parent) {
- const _e = $.instantiateHierarchy(null, i, (et,tt)=>{
- if (j(et, tt),
- tt.material) {
- const rt = tt;
- if (rt.material)
- if (e) {
- const it = et.material;
- if (k.indexOf(it) === -1) {
- let nt = it.clone(c ? c(it.name) : "Clone of " + it.name);
- if (s.materials.push(nt),
- k.push(it),
- d[it.uniqueId] = nt.uniqueId,
- _[nt.uniqueId] = nt,
- it.getClassName() === "MultiMaterial") {
- const ot = it;
- for (const at of ot.subMaterials)
- !at || (nt = at.clone(c ? c(at.name) : "Clone of " + at.name),
- k.push(at),
- d[at.uniqueId] = nt.uniqueId,
- _[nt.uniqueId] = nt);
- ot.subMaterials = ot.subMaterials.map(at=>at && _[d[at.uniqueId]]),
- s.multiMaterials.push(ot)
- }
- }
- rt.getClassName() !== "InstancedMesh" && (rt.material = _[d[it.uniqueId]])
- } else
- rt.material.getClassName() === "MultiMaterial" ? (this.scene.multiMaterials.indexOf(rt.material) === -1 && this.scene.addMultiMaterial(rt.material),
- s.multiMaterials.indexOf(rt.material) === -1 && s.multiMaterials.push(rt.material)) : (this.scene.materials.indexOf(rt.material) === -1 && this.scene.addMaterial(rt.material),
- s.materials.indexOf(rt.material) === -1 && s.materials.push(rt.material))
- }
- }
- );
- _e && s.rootNodes.push(_e)
- }
- }
- ),
- this.skeletons.forEach($=>{
- const _e = $.clone(c ? c($.name) : "Clone of " + $.name);
- $.overrideMesh && (_e.overrideMesh = _[d[$.overrideMesh.uniqueId]]);
- for (const et of this.meshes)
- if (et.skeleton === $ && !et.isAnInstance) {
- const tt = _[d[et.uniqueId]];
- if (tt.isAnInstance || (tt.skeleton = _e,
- b.indexOf(_e) !== -1))
- continue;
- b.push(_e);
- for (const rt of _e.bones)
- rt._linkedTransformNode && (rt._linkedTransformNode = _[d[rt._linkedTransformNode.uniqueId]])
- }
- s.skeletons.push(_e)
- }
- ),
- this.animationGroups.forEach($=>{
- const _e = $.clone($.name, et=>_[d[et.uniqueId]] || et, o);
- s.animationGroups.push(_e)
- }
- ),
- this.textures.forEach($=>{
- const _e = $.clone();
- _e && s.textures.push(_e)
- }
- ),
- this.cameras.forEach($=>{
- s.cameras.push($.clone(c($.name)))
- }
- ),
- this.lights.forEach($=>{
- const _e = $.clone(c($.name));
- _e && s.lights.push(_e)
- }
- ),
- s
- }
- ;
- AssetContainer.prototype.GetName = function() {
- return this._name || (this._name = ""),
- this._name
- }
- ;
- AssetContainer.prototype.SetName = function(a) {
- this._name = a
- }
- ;
- AssetContainer.prototype.GetRootNode = function() {
- return this._rootNode || (this._rootNode = this.meshes[0]),
- this._rootNode
- }
- ;
- AssetContainer.prototype.CreateRootNodeByName = function(a) {
- const e = new Mesh("assetContainerRootMesh_" + a,this.scene);
- return this.meshes.forEach(i=>{
- i.parent || e.addChild(i)
- }
- ),
- this.meshes.unshift(e),
- e
- }
- ;
- AssetContainer.prototype.GetMeshesWithoutParent = function() {
- const a = new Array;
- return this.meshes.forEach(e=>{
- e.parent || a.push(e)
- }
- ),
- a
- }
- ;
- AssetContainer.prototype.GetOwner = function() {
- return this._owner
- }
- ;
- AssetContainer.prototype.SetOwner = function(a) {
- this._owner || (this._owner = new XObject),
- this._owner = a
- }
- ;
- AssetContainer.prototype.toJSON = function() {
- const a = this.GetOwner()
- , e = a == null ? void 0 : a.outer;
- return e ? e.SaveAsset(this) : ""
- }
- ;
- AssetContainer.prototype.getClassName = function() {
- return "AssetContainer"
- }
- ;
- new Logger$1("XSceneComponent");
- class XSceneComponent extends XActorComponent {
- constructor() {
- super(),
- this._billboardMode = 0,
- this._castShadow = !0,
- this.getBbox = (i={})=>{
- const {isConst: o=!1, changeWithAvatar: s=!1} = i;
- let {localCenter: c={
- x: 0,
- y: 0,
- z: 75
- }, width: d=1.32, height: _=1.5, depth: b=.44} = i;
- if (s) {
- const k = this.scaling;
- c = {
- x: c.x * k.x,
- y: c.y * k.y,
- z: c.z * k.z
- },
- d *= k.x,
- _ *= k.y,
- b *= k.z
- }
- if (this.rootNode) {
- let k = new Vector3(0,0,0)
- , j = new Vector3(0,0,0);
- if (o) {
- const _e = ue4Position2Xverse(c);
- k = k.add(_e.add(new Vector3(-d / 2,-_ / 2,-b / 2))),
- j = j.add(_e.add(new Vector3(d / 2,_ / 2,b / 2)))
- } else {
- k = k.add(new Vector3(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY)),
- j = j.add(new Vector3(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY)),
- this.rootNode.getChildMeshes().forEach(tt=>{
- const rt = tt.getBoundingInfo().boundingBox.minimum
- , it = tt.getBoundingInfo().boundingBox.maximum;
- k.x = Math.min(k.x, rt.x),
- j.x = Math.max(j.x, it.x),
- k.y = Math.min(k.y, rt.y),
- j.y = Math.max(j.y, it.y),
- k.z = Math.min(k.z, rt.z),
- j.z = Math.max(j.z, it.z)
- }
- );
- const _e = j.x - k.x
- , et = j.z - k.z;
- k.x -= this.scaling.x * _e / 2,
- j.x += this.scaling.x * _e / 2,
- j.y *= this.scaling.y,
- k.z -= this.scaling.z * et / 2,
- j.z += this.scaling.z * et / 2
- }
- const $ = this.rootNode.computeWorldMatrix(!0);
- this.bbox ? this.bbox.reConstruct(k, j, $) : this.bbox = new BoundingBox(k,j,$)
- }
- }
- ;
- const e = EngineStore.LastCreatedScene;
- this._bbox = null,
- this._attachChildren = new Array,
- this._attachParent = null,
- this._asset = new AssetContainer(e),
- this._rootNode = this._asset.GetRootNode()
- }
- getClassName() {
- return "XSceneComponent"
- }
- set asset(e) {
- !e || (this._asset = e,
- this._asset.SetOwner(this),
- this._rootNode = this._asset.GetRootNode())
- }
- get asset() {
- return this._asset
- }
- set castShadow(e) {
- !this._rootNode || (this._rootNode.getChildMeshes().forEach(i=>{}
- ),
- this._castShadow = e)
- }
- get castShadow() {
- return this._castShadow
- }
- set position(e) {
- if (!this.rootNode || !e)
- return;
- const i = ue4Position2Xverse(e);
- i && (this.rootNode.position = i)
- }
- get position() {
- return this.rootNode ? xversePosition2Ue4(this.rootNode.position) : {
- x: 0,
- y: 0,
- z: 0
- }
- }
- set rotation(e) {
- if (!this.rootNode || !e)
- return;
- const i = ue4Rotation2Xverse(e);
- i && (this.rootNode.rotation = i)
- }
- get rotation() {
- return this.rootNode ? xverseRotation2Ue4(this.rootNode.rotation) : {
- pitch: 0,
- yaw: 0,
- roll: 0
- }
- }
- set scaling(e) {
- if (!this.rootNode || !e)
- return;
- const i = ue4Scaling2Xverse(e);
- i && (this.rootNode.scaling = i)
- }
- get scaling() {
- if (!this.rootNode)
- return {
- x: 0,
- y: 0,
- z: 0
- };
- const e = this.rootNode.scaling;
- return {
- x: e.x,
- y: -e.z,
- z: e.y
- }
- }
- setEnabled(e) {
- !this.rootNode || (this.rootNode.setEnabled(e),
- this._attachChildren.forEach(i=>{
- i.setEnabled(e)
- }
- ))
- }
- isEnabled() {
- return this.rootNode ? this.rootNode.isEnabled : null
- }
- get billboardMode() {
- return this._billboardMode
- }
- set bllboardMode(e) {
- this._billboardMode !== e && (!this.rootNode || this._rootNode.getChildMeshes().forEach(i=>{
- i.billboardMode = e
- }
- ))
- }
- set name(e) {
- !this.rootNode || (this.rootNode.name = e)
- }
- get name() {
- return this.rootNode ? this.rootNode.name : ""
- }
- get bbox() {
- return this._bbox
- }
- set bbox(e) {
- this._bbox = e
- }
- get rootNode() {
- return this._rootNode
- }
- postLoad() {
- var e;
- this._asset && (this.asset = this._asset,
- this._rootNode = (e = this._asset) == null ? void 0 : e.GetRootNode())
- }
- dispose() {
- var e, i;
- (e = this._asset) == null || e.dispose(),
- (i = this._bbox) == null || i.dispose(),
- this._attachChildren = [],
- this._attachParent = null
- }
- DetachFromComponent(e) {
- !this.rootNode || (this.rootNode.parent = null,
- e._attachChildren.splice(e._attachChildren.indexOf(this), 1),
- this._attachParent = null)
- }
- AttachToComponent(e, i={
- x: 0,
- y: 0,
- z: 0
- }) {
- if (!this.asset || !this.rootNode)
- return;
- const o = this.rootNode;
- this.asset.scene;
- const s = ue4Position2Xverse(i);
- o.setParent(e.rootNode),
- o.position = s,
- e._attachChildren.push(this),
- this._attachParent = e
- }
- }
- __decorateClass$2([xProperty("xAsset")], XSceneComponent.prototype, "_asset", 2);
- RegisterXObjectClass("XSceneComponent", XSceneComponent);
- var __defProp$1 = Object.defineProperty
- , __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor
- , __decorateClass$1 = (a,e,i,o)=>{
- for (var s = o > 1 ? void 0 : o ? __getOwnPropDesc$1(e, i) : e, c = a.length - 1, d; c >= 0; c--)
- (d = a[c]) && (s = (o ? d(e, i, s) : d(s)) || s);
- return o && s && __defProp$1(e, i, s),
- s
- }
- ;
- new Logger$1("XActor");
- class XActor extends XObject {
- constructor() {
- super();
- const e = EngineStore.LastCreatedScene;
- this._children = new Array,
- this._ownedComponent = new Set,
- this._rootComponent = new XSceneComponent,
- this._rootComponent.owner = this,
- this._tickInterval = 1;
- let i = 0;
- this._tickObserver = e.onAfterRenderObservable.add(()=>{
- i += 1,
- i == this._tickInterval && (this._tick(),
- i = 0)
- }
- )
- }
- set outer(e) {
- this._outer = e,
- this._ownedComponent.forEach(i=>{
- i.outer = e
- }
- )
- }
- get outer() {
- return this._outer
- }
- get rootComponent() {
- return this._rootComponent
- }
- getClassName() {
- return "XActor"
- }
- _tick() {
- this._ownedComponent.forEach(e=>{
- e.ReceiveTick()
- }
- )
- }
- get tickInterval() {
- return this._tickInterval
- }
- set tickInterval(e) {
- this._tickInterval = e
- }
- AttachToActor(e) {
- e._children.push(this),
- this._rootComponent.AttachToComponent(e.rootComponent)
- }
- postLoad() {
- this._ownedComponent.add(this._rootComponent)
- }
- dispose() {
- this._children = [],
- this._ownedComponent.clear(),
- this._rootComponent.dispose(),
- this._tickObserver.unregisterOnNextCall = !0
- }
- }
- __decorateClass$1([xProperty("rootComponent")], XActor.prototype, "_rootComponent", 2);
- RegisterXObjectClass("XActor", XActor);
- var __defProp = Object.defineProperty
- , __getOwnPropDesc = Object.getOwnPropertyDescriptor
- , __decorateClass = (a,e,i,o)=>{
- for (var s = o > 1 ? void 0 : o ? __getOwnPropDesc(e, i) : e, c = a.length - 1, d; c >= 0; c--)
- (d = a[c]) && (s = (o ? d(e, i, s) : d(s)) || s);
- return o && s && __defProp(e, i, s),
- s
- }
- ;
- class XAccessory extends XActor {
- constructor() {
- super()
- }
- getClassName() {
- return "XAccessory"
- }
- set attachType(e) {
- this._attachType = e
- }
- get attachType() {
- return this._attachType
- }
- set attachBoneId(e) {
- this._attachBoneId = e
- }
- get attachBoneId() {
- return this._attachBoneId
- }
- set attachPointOffset(e) {
- this._attachPointOffset = e
- }
- get attachPointOffset() {
- return this._attachPointOffset
- }
- set attachPointRotation(e) {
- this._attachPointRotation = e
- }
- get attachPointScale() {
- return this._attachPointScale
- }
- set pointId(e) {
- this._pointId = e
- }
- get pointId() {
- return this._pointId
- }
- set attachPointOffsetVector3(e) {
- this._attachPointOffset = xversePosition2Ue4(e)
- }
- set attachPointScaleVector3(e) {
- this._attachPointScale = {
- x: e.x,
- y: -e.z,
- z: e.y
- }
- }
- set attachPointRotationVector3(e) {
- this._attachPointRotation = xverseRotation2Ue4_mesh(e)
- }
- setLocalRTS(e) {
- if (e) {
- const i = ue4Scaling2Xverse(this._attachPointScale);
- i && (e.scaling = i);
- const o = ue4Position2Xverse(this._attachPointOffset);
- o && (e.position = o);
- const s = ue4Rotation2Xverse_mesh(this._attachPointRotation);
- s && (e.rotation = s)
- }
- }
- setParentTo(e) {
- this.rootComponent && this.rootComponent.rootNode && (this.rootComponent.rootNode.parent = e,
- this.setLocalRTS(this.rootComponent.rootNode))
- }
- detachFrom(e=!0) {
- e ? this.dispose() : this.rootComponent && this.rootComponent.rootNode && (this.rootComponent.rootNode.parent = null,
- this.rootComponent.rootNode.detachFromBone(!1))
- }
- attachTo(e) {
- switch (this._attachType) {
- case 0:
- this.rootComponent && this.rootComponent.rootNode && e.component.body && (this.rootComponent.rootNode.parent = e.component.body.root,
- this.setLocalRTS(this.rootComponent.rootNode));
- break;
- case 1:
- {
- const i = e.skeleton.bones.find(o=>o.name === this._attachBoneId);
- i && this.rootComponent && this.rootComponent.rootNode && e.component.body && (this.rootComponent.rootNode.attachToBone(i, e.component.body.root),
- this.setLocalRTS(this.rootComponent.rootNode));
- break
- }
- }
- }
- async play() {
- this.rootComponent.asset && this.rootComponent.asset.animationGroups && this.rootComponent.asset.animationGroups.length > 0 && (this.rootComponent.asset.animationGroups[0].play(),
- this.rootComponent.asset.animationGroups[0].onAnimationGroupEndObservable.addOnce(()=>Promise.resolve(null)))
- }
- stop() {
- this.rootComponent.asset && this.rootComponent.asset.animationGroups && this.rootComponent.asset.animationGroups.length > 0 && this.rootComponent.asset.animationGroups[0].stop()
- }
- }
- __decorateClass([xProperty("_pointId")], XAccessory.prototype, "_pointId", 2);
- __decorateClass([xProperty("_attachBoneId")], XAccessory.prototype, "_attachBoneId", 2);
- __decorateClass([xProperty("_attachType")], XAccessory.prototype, "_attachType", 2);
- __decorateClass([xProperty("_attachPointOffset")], XAccessory.prototype, "_attachPointOffset", 2);
- __decorateClass([xProperty("_attachPointRotation")], XAccessory.prototype, "_attachPointRotation", 2);
- __decorateClass([xProperty("_attachPointScale")], XAccessory.prototype, "_attachPointScale", 2);
- RegisterXObjectClass("XAccessory", XAccessory);
- const log$u = new Logger$1("ScreenShot");
- function CreateScreenshot(a, e, i, o, s="image/png", c=!1) {
- const {height: d, width: _} = _getScreenshotSize(a, e, i);
- if (log$u.info("[Engine]CreateScreenshot!"),
- !(d && _)) {
- log$u.error("[Engine]CreateScreenshot Invalid 'size' parameter !");
- return
- }
- Tools._ScreenshotCanvas || (Tools._ScreenshotCanvas = document.createElement("canvas")),
- Tools._ScreenshotCanvas.width = _,
- Tools._ScreenshotCanvas.height = d;
- const b = Tools._ScreenshotCanvas.getContext("2d")
- , k = a.getRenderWidth() / a.getRenderHeight();
- let j = _
- , $ = j / k;
- $ > d && ($ = d,
- j = $ * k);
- const _e = Math.max(0, _ - j) / 2
- , et = Math.max(0, d - $) / 2;
- e.getScene().onAfterRenderObservable.addOnce(function() {
- const rt = a.getRenderingCanvas();
- b && rt ? b.drawImage(rt, _e, et, j, $) : log$u.error("[Engine]CreateScreenshot Invalid renderContext and renderingCanvas!"),
- c ? (Tools.EncodeScreenshotCanvasData(void 0, s),
- o && o("")) : Tools.EncodeScreenshotCanvasData(o, s)
- })
- }
- function CreateScreenshotAsync(a, e, i, o="image/png") {
- return new Promise((s,c)=>{
- CreateScreenshot(a, e, i, d=>{
- typeof d != "undefined" ? s(d) : c(new Error("Data is undefined"))
- }
- , o)
- }
- )
- }
- function CreateScreenshotUsingRenderTarget(a, e, i, o, s="image/png", c=1, d=!1, _, b=!1, k=!1) {
- const {height: j, width: $} = _getScreenshotSize(a, e, i)
- , _e = {
- width: $,
- height: j
- };
- if (!(j && $)) {
- log$u.error("Invalid 'size' parameter !");
- return
- }
- const et = e.getScene();
- let tt = null;
- const rt = et.activeCameras;
- et.activeCameras = null,
- et.activeCamera !== e && (tt = et.activeCamera,
- et.activeCamera = e),
- et.render();
- 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);
- it.renderList = null,
- it.samples = c,
- it.renderSprites = b,
- et.onAfterRenderTargetsRenderObservable.addOnce(function() {
- it.readPixels(void 0, void 0, void 0, !1).then(ot=>{
- Tools.DumpData($, j, ot, o, s, _, !0),
- it.dispose()
- }
- )
- });
- const nt = ()=>{
- et.incrementRenderId(),
- et.resetCachedMaterial(),
- it.render(!0),
- et.incrementRenderId(),
- et.resetCachedMaterial(),
- tt && (et.activeCamera = tt),
- et.activeCameras = rt,
- e.getProjectionMatrix(!0),
- et.render()
- }
- ;
- if (d) {
- const ot = new FxaaPostProcess("antialiasing",1,et.activeCamera);
- it.addPostProcess(ot),
- ot.getEffect().isReady() ? nt() : ot.getEffect().onCompiled = ()=>{
- nt()
- }
- } else
- nt()
- }
- function CreateScreenshotUsingRenderTargetAsync(a, e, i, o="image/png", s=1, c=!1, d, _=!1) {
- return new Promise((b,k)=>{
- CreateScreenshotUsingRenderTarget(a, e, i, j=>{
- typeof j != "undefined" ? b(j) : k(new Error("Data is undefined"))
- }
- , o, s, c, d, _)
- }
- )
- }
- function _getScreenshotSize(a, e, i) {
- let o = 0
- , s = 0;
- if (typeof i == "object") {
- const c = i.precision ? Math.abs(i.precision) : 1;
- i.width && i.height ? (o = i.height * c,
- s = i.width * c) : i.width && !i.height ? (s = i.width * c,
- o = Math.round(s / a.getAspectRatio(e))) : i.height && !i.width ? (o = i.height * c,
- s = Math.round(o * a.getAspectRatio(e))) : (s = Math.round(a.getRenderWidth() * c),
- o = Math.round(s / a.getAspectRatio(e)))
- } else
- isNaN(i) || (o = i,
- s = i);
- return s && (s = Math.floor(s)),
- o && (o = Math.floor(o)),
- {
- height: o | 0,
- width: s | 0
- }
- }
- const initSideEffects = ()=>{
- Tools.CreateScreenshot = CreateScreenshot,
- Tools.CreateScreenshotAsync = CreateScreenshotAsync,
- Tools.CreateScreenshotUsingRenderTarget = CreateScreenshotUsingRenderTarget,
- Tools.CreateScreenshotUsingRenderTargetAsync = CreateScreenshotUsingRenderTargetAsync
- }
- ;
- initSideEffects();
- const VERSION$1 = "1.0.92";
- ParticleSystem.prototype.isReady = function() {
- if (!this.emitter || this._imageProcessingConfiguration && !this._imageProcessingConfiguration.isReady())
- return !1;
- if (this.blendMode !== ParticleSystem.BLENDMODE_MULTIPLYADD) {
- if (!this._getWrapper(this.blendMode).effect.isReady())
- return !1
- } else if (!this._getWrapper(ParticleSystem.BLENDMODE_MULTIPLY).effect.isReady() || !this._getWrapper(ParticleSystem.BLENDMODE_ADD).effect.isReady())
- return !1;
- return !0
- }
- ;
- const animationMap = new Map;
- animationMap.set("Falling", new AnimationRange("Falling1",0,15));
- animationMap.set("Click", new AnimationRange("Click",16,39));
- animationMap.set("Disappear", new AnimationRange("Disappear",40,47));
- class XRain extends XSubSequence {
- constructor(e, i, o) {
- super(e, i, o),
- this.onLoadedObserverable.addOnce(()=>{
- this._particleGroups.forEach(s=>{
- const c = s.systems[0];
- c.getClassName() == "ParticleSystem" && (c.startPositionFunction = function(d, _) {
- const k = 2 * Math.random() * Math.PI
- , j = Math.random() * 15 * Math.sin(k)
- , $ = this.minEmitBox.y
- , _e = Math.random() * 15 * Math.cos(k);
- Vector3.TransformCoordinatesFromFloatsToRef(j, $, _e, d, _)
- }
- )
- }
- )
- }
- )
- }
- }
- const log$t = new Logger$1("Billboard");
- var BillboardStatus = (a=>(a[a.SHOW = 1] = "SHOW",
- a[a.HIDE = 0] = "HIDE",
- a[a.DISPOSE = -1] = "DISPOSE",
- a))(BillboardStatus || {});
- class XBillboard {
- constructor(e, i=!1, o=!1) {
- this._mesh = null,
- this._texture = null,
- this._scalingFactor = 1,
- this.offsets = null,
- this._background = null,
- this.poolobj = null,
- this._initMeshScale = new Vector3(1,1,1),
- this._status = -1,
- this._stageChanged = !1,
- this.DEFAULT_CONFIGS = {},
- this._billboardManager = e,
- this._pickable = i,
- this._usePool = o
- }
- set scalingFactor(e) {
- this._scalingFactor = e
- }
- set background(e) {
- this._background = e
- }
- get size() {
- return -1
- }
- setStatus(e) {
- e != this._status && (this._stageChanged = !0,
- this._status = e)
- }
- get status() {
- return this._status
- }
- get stageChanged() {
- return this._stageChanged
- }
- set stageChanged(e) {
- this._stageChanged = e
- }
- init(e="", i=.001, o=.001, s=!1) {
- const c = this._billboardManager.sceneManager.Scene;
- if (this._usePool) {
- const d = this._billboardManager.billboardPool.getFree(c, i, o, s);
- this._mesh = d.data,
- this._mesh.isPickable = this._pickable,
- this._mesh.xid = e,
- this._mesh.xtype = EMeshType.XBillboard,
- this._texture = this._mesh.material.diffuseTexture,
- this.poolobj = d
- } else
- this._mesh = this._billboardManager.createBillboardAsset(c, s);
- this._mesh.isPickable = this._pickable,
- this._initMeshScale.x = i * 1e3,
- this._initMeshScale.y = o * 1e3,
- this._mesh.xid = e,
- this._mesh.xtype = EMeshType.XBillboard,
- this._texture = this._mesh.material.diffuseTexture,
- this.setStatus(1),
- this._stageChanged = !0
- }
- dispose() {
- this._usePool ? this.poolobj && (this._billboardManager.billboardPool.release(this.poolobj),
- this._mesh = null,
- this._texture = null,
- this.poolobj = null) : this._mesh && (this._mesh.dispose(!0, !0),
- this._mesh = null,
- this._texture = null),
- this._background = null
- }
- getMesh() {
- return this._mesh
- }
- updateImage(e) {
- return new Promise(i=>{
- if (this._texture == null) {
- log$t.error("[Engine]Billboard texture not found");
- return
- }
- const o = this._mesh
- , s = this._texture
- , c = this._scalingFactor
- , d = this._initMeshScale.x
- , _ = this._initMeshScale.y
- , b = this._texture.getContext()
- , k = this._texture.getSize();
- b.clearRect(0, 0, k.width, k.height);
- const j = new Image;
- j.crossOrigin = "anonymous",
- j.src = e,
- j.onload = ()=>{
- const $ = j.width * c
- , _e = j.height * c;
- o.scaling.x = $ * d,
- o.scaling.y = _e * _,
- s.scaleTo($, _e),
- b.drawImage(j, 0, 0, $, _e),
- s.hasAlpha = !0,
- s.update(),
- i()
- }
- }
- )
- }
- show() {
- this._mesh && (this._mesh.setEnabled(!0),
- this._mesh.isPickable = this._pickable)
- }
- hide() {
- this._mesh && (this._mesh.setEnabled(!1),
- this._mesh.isPickable = !1)
- }
- setId(e) {
- this._mesh && (this._mesh.xid = e)
- }
- setPosition(e) {
- if (e && this._mesh) {
- const i = ue4Position2Xverse(e);
- this._mesh.position = i
- }
- }
- updateText(e, i, o=!0, s=[], c=30, d="monospace", _="black", b="bold", k) {
- if (this._texture == null) {
- log$t.error("[Engine]Billboard texture not found");
- return
- }
- const j = this._texture
- , $ = this._mesh
- , _e = this._scalingFactor
- , et = this._initMeshScale.x
- , tt = this._initMeshScale.y;
- if (e != "") {
- const rt = this._texture.getContext()
- , it = this._texture.getSize();
- rt.clearRect(0, 0, it.width, it.height);
- const nt = new Image;
- if (o) {
- i != null ? i ? this._background = this._billboardManager.userBackGroundBlob : this._background = this._billboardManager.npcBackGroundBlob : this._background || (this._background = this._billboardManager.userBackGroundBlob);
- let ot = e
- , at = k && k < s.length - 1 ? k : s.length - 1;
- if (this._background) {
- if (at > this._background.length) {
- for (let st = 0; st < at - this._background.length; st++)
- s.pop();
- at = s.length - 1,
- ot = e.slice(0, s[at] - 1) + String.fromCharCode(8230)
- }
- nt.crossOrigin = "anonymous",
- nt.src = this._background[at - 1],
- nt.onload = function() {
- const st = nt.width * _e
- , ut = nt.height * _e;
- $.scaling.x = st * et,
- $.scaling.y = ut * tt,
- j.scaleTo(st, ut),
- rt.textAlign = "center",
- rt.textBaseline = "middle",
- rt.drawImage(nt, 0, 0, st, ut);
- for (let ct = 0; ct < at; ct++)
- 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);
- j.hasAlpha = !0
- }
- }
- } else {
- const ot = k && k < s.length - 1 ? k : s.length - 1
- , at = 480 * _e
- , st = 60 * _e * ot;
- this._mesh.scaling = new Vector3(at * et,st * tt,1),
- j.scaleTo(at, st);
- const ut = j.getContext();
- ut.textAlign = "center",
- ut.textBaseline = "middle";
- for (let ct = 0; ct < ot; ct++)
- setTimeout(()=>{
- 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),
- 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)
- }
- , 0);
- j.hasAlpha = !0
- }
- } else
- this.clearText()
- }
- drawBillboard(e, i, o) {
- var it;
- const {imageList: s} = e
- , {texts: c, font: d="monospace", fontsize: _=40, fontcolor: b="#ffffff", fontstyle: k="", linesize: j=20, linelimit: $} = i
- , {position: _e, offsets: et, scale: tt, compensationZ: rt=0} = o;
- if (this.scalingFactor = tt || 1,
- et && (this.offsets = {
- x: et.x * this._scalingFactor,
- y: et.y * this._scalingFactor,
- z: et.z * this._scalingFactor
- }),
- this.offsets || (this.offsets = {
- x: 0,
- y: 0,
- z: 0
- }),
- this.setPosition(_e),
- s && !c)
- (it = this._billboardManager.sceneManager) == null || it.urlTransformer(s[0]).then(nt=>{
- this.updateImage(nt)
- }
- );
- else if (c && !s) {
- const [nt,ot] = getStringBoundaries(c, j, XBillboardManager.alphaWidthMap);
- this.offsets.z += this._scalingFactor * rt * (ot.length - 1),
- this.updateText(nt, void 0, !1, ot, _, d, b, k, $)
- } else if (c && s) {
- this.background = s;
- const [nt,ot] = getStringBoundaries(c, j, XBillboardManager.alphaWidthMap);
- this.offsets.z += this._scalingFactor * rt * (ot.length - 1),
- this.updateText(nt, void 0, !0, ot, _, d, b, k, $)
- }
- this.setStatus(1)
- }
- clearText() {
- if (this._texture != null) {
- const e = this._texture.getContext()
- , i = this._texture.getSize();
- e.clearRect(0, 0, i.width, i.height),
- this._texture.update()
- }
- }
- }
- var AvatarGroup = (a=>(a.Npc = "npc",
- a.User = "user",
- a))(AvatarGroup || {})
- , ChangeComponentsMode = (a=>(a[a.Preview = 0] = "Preview",
- a[a.Confirm = 1] = "Confirm",
- a[a.Cancel = 2] = "Cancel",
- a))(ChangeComponentsMode || {})
- , MotionType = (a=>(a.Walk = "walk",
- a.Run = "run",
- a.Fly = "fly",
- a))(MotionType || {});
- class XverseError extends Error {
- constructor(i, o) {
- super(o);
- Tt(this, "code");
- this.code = i
- }
- toJSON() {
- return {
- code: this.code,
- message: this.message
- }
- }
- toString() {
- if (Object(this) !== this)
- throw new TypeError;
- let o = this.name;
- o = o === void 0 ? "Error" : String(o);
- let s = this.message;
- s = s === void 0 ? "" : String(s);
- const c = this.code;
- return s = c === void 0 ? s : c + "," + s,
- o === "" ? s : s === "" ? o : o + ": " + s
- }
- }
- class ParamError extends XverseError {
- constructor(e) {
- super(1001, e || "\u53C2\u6570\u9519\u8BEF")
- }
- }
- class InternalError extends XverseError {
- constructor(e) {
- super(1002, e || "\u5185\u90E8\u9519\u8BEF")
- }
- }
- class TimeoutError extends XverseError {
- constructor(e) {
- super(1003, e || "\u8D85\u65F6")
- }
- }
- class AuthenticationError extends XverseError {
- constructor(e) {
- super(1004, e || "\u9274\u6743\u5931\u8D25")
- }
- }
- class TokenExpiredError extends XverseError {
- constructor(e) {
- super(1005, e || "Token \u5DF2\u8FC7\u671F")
- }
- }
- class UnsupportedError extends XverseError {
- constructor(e) {
- super(1006, e || "\u624B\u673A\u7CFB\u7EDF\u4E0D\u652F\u6301XVerse")
- }
- }
- class InitNetworkTimeoutError extends XverseError {
- constructor(e) {
- super(1007, e || "\u7F51\u7EDC\u521D\u59CB\u5316\u8D85\u65F6")
- }
- }
- class InitDecoderTimeoutError extends XverseError {
- constructor(e) {
- super(1008, e || "Decoder \u521D\u59CB\u5316\u8D85\u65F6")
- }
- }
- class InitConfigTimeoutError extends XverseError {
- constructor(e) {
- super(1009, e || "\u914D\u7F6E\u521D\u59CB\u5316\u8D85\u65F6")
- }
- }
- class InitEngineTimeoutError extends XverseError {
- constructor(e) {
- super(1010, e || "\u5F15\u64CE\u521D\u59CB\u5316\u8D85\u65F6")
- }
- }
- class InitEngineError extends XverseError {
- constructor(e) {
- super(1011, e || "\u5F15\u64CE\u521D\u59CB\u5316\u9519\u8BEF")
- }
- }
- class ActionBlockedError extends XverseError {
- constructor(e) {
- super(1012, e || "\u52A8\u4F5C\u88AB\u5C4F\u853D")
- }
- }
- class PreloadCanceledError extends XverseError {
- constructor(e) {
- super(1013, e || "\u9884\u52A0\u8F7D\u88AB\u53D6\u6D88")
- }
- }
- class FrequencyLimitError extends XverseError {
- constructor(e) {
- super(1014, e || "\u9891\u7387\u9650\u5236")
- }
- }
- class UsersUpperLimitError extends XverseError {
- constructor(e) {
- super(2e3, e || "\u76F4\u64AD\u95F4\u4EBA\u6570\u5DF2\u6EE1")
- }
- }
- class RoomsUpperLimitError extends XverseError {
- constructor(e) {
- super(2001, e || "\u623F\u95F4\u5230\u8FBE\u4E0A\u9650")
- }
- }
- class ServerParamError extends XverseError {
- constructor(e) {
- super(2002, e || "\u670D\u52A1\u5668\u53C2\u6570\u9519\u8BEF")
- }
- }
- class LackOfTokenError extends XverseError {
- constructor(e) {
- super(2003, e || "\u7F3A\u5C11 Token")
- }
- }
- class LoginFailedError extends XverseError {
- constructor(e) {
- super(2004, e || "\u8FDB\u5165\u623F\u95F4\u5931\u8D25")
- }
- }
- class VerifyServiceDownError extends XverseError {
- constructor(e) {
- super(2005, e || "\u9274\u6743\u670D\u52A1\u5F02\u5E38")
- }
- }
- class CreateSessionFailedError extends XverseError {
- constructor(e) {
- super(2006, e || "\u521B\u5EFA session \u5931\u8D25")
- }
- }
- class RtcConnectionError extends XverseError {
- constructor(e) {
- super(2008, e || "RTC\u5EFA\u8054\u5931\u8D25")
- }
- }
- class DoActionFailedError extends XverseError {
- constructor(e) {
- super(2009, e || "\u52A8\u4F5C\u6267\u884C\u5931\u8D25")
- }
- }
- class StateSyncFailedError extends XverseError {
- constructor(e) {
- super(2010, e || "\u72B6\u6001\u540C\u6B65\u5931\u8D25")
- }
- }
- class BroadcastFailedError extends XverseError {
- constructor(e) {
- super(2011, e || "\u5E7F\u64AD\u63A5\u53E3\u63A5\u53E3\u5F02\u5E38")
- }
- }
- class DataAbnormalError extends XverseError {
- constructor(e) {
- super(2012, e || "\u6570\u636E\u5F02\u5E38")
- }
- }
- class GetOnVehicleError extends XverseError {
- constructor(e) {
- super(2015, e || "\u4E0A\u8F7D\u5177\u5931\u8D25\u9700\u8981\u9884\u7EA6")
- }
- }
- class RepeatLoginError extends XverseError {
- constructor(e) {
- super(2017, e || "\u5F02\u5730\u767B\u5F55")
- }
- }
- class RoomDoseNotExistError extends XverseError {
- constructor(e) {
- super(2018, e || "\u6307\u5B9A\u623F\u95F4\u4E0D\u5B58\u5728")
- }
- }
- class TicketExpireError extends XverseError {
- constructor(e) {
- super(2019, e || "\u7968\u636E\u8FC7\u671F")
- }
- }
- class ServerRateLimitError extends XverseError {
- constructor(e) {
- super(2020, e || "\u670D\u52A1\u7AEF\u9891\u7387\u9650\u5236")
- }
- }
- class DoActionBlockedError extends XverseError {
- constructor(e) {
- super(2333, e || "\u52A8\u4F5C\u88AB\u5C4F\u853D")
- }
- }
- class UnReachableError extends XverseError {
- constructor(e) {
- super(2335, e || "\u533A\u57DF\u4E0D\u53EF\u5230\u8FBE")
- }
- }
- class ActionMaybeDelayError extends XverseError {
- constructor(e) {
- super(2334, e || "\u52A8\u4F5C\u53EF\u80FD\u5EF6\u8FDF\u6267\u884C")
- }
- }
- class ActionResponseTimeoutError extends XverseError {
- constructor(e) {
- super(2999, e || "action\u56DE\u5305\u8D85\u65F6")
- }
- }
- var Codes$1 = (a=>(a[a.Success = 0] = "Success",
- a[a.Param = 1001] = "Param",
- a[a.Internal = 1002] = "Internal",
- a[a.Timeout = 1003] = "Timeout",
- a[a.Authentication = 1004] = "Authentication",
- a[a.TokenExpired = 1005] = "TokenExpired",
- a[a.Unsupported = 1006] = "Unsupported",
- a[a.InitNetworkTimeout = 1007] = "InitNetworkTimeout",
- a[a.InitDecoderTimeout = 1008] = "InitDecoderTimeout",
- a[a.InitConfigTimeout = 1009] = "InitConfigTimeout",
- a[a.InitEngineTimeout = 1010] = "InitEngineTimeout",
- a[a.InitEngine = 1011] = "InitEngine",
- a[a.ActionBlocked = 1012] = "ActionBlocked",
- a[a.PreloadCanceled = 1013] = "PreloadCanceled",
- a[a.FrequencyLimit = 1014] = "FrequencyLimit",
- a[a.UsersUpperLimit = 2e3] = "UsersUpperLimit",
- a[a.RoomsUpperLimit = 2001] = "RoomsUpperLimit",
- a[a.ServerParam = 2002] = "ServerParam",
- a[a.LackOfToken = 2003] = "LackOfToken",
- a[a.LoginFailed = 2004] = "LoginFailed",
- a[a.VerifyServiceDown = 2005] = "VerifyServiceDown",
- a[a.CreateSessionFailed = 2006] = "CreateSessionFailed",
- a[a.RtcConnection = 2008] = "RtcConnection",
- a[a.DoActionFailed = 2009] = "DoActionFailed",
- a[a.StateSyncFailed = 2010] = "StateSyncFailed",
- a[a.BroadcastFailed = 2011] = "BroadcastFailed",
- a[a.DataAbnormal = 2012] = "DataAbnormal",
- a[a.GetOnVehicle = 2015] = "GetOnVehicle",
- a[a.RepeatLogin = 2017] = "RepeatLogin",
- a[a.RoomDoseNotExist = 2018] = "RoomDoseNotExist",
- a[a.TicketExpire = 2019] = "TicketExpire",
- a[a.ServerRateLimit = 2020] = "ServerRateLimit",
- a[a.DoActionBlocked = 2333] = "DoActionBlocked",
- a[a.UnReachable = 2335] = "UnReachable",
- a[a.ActionMaybeDelay = 2334] = "ActionMaybeDelay",
- a[a.ActionResponseTimeout = 2999] = "ActionResponseTimeout",
- a))(Codes$1 || {});
- const CodeErrorMap = {
- 1001: ParamError,
- 1002: InternalError,
- 1003: TimeoutError,
- 1004: AuthenticationError,
- 1005: TokenExpiredError,
- 1006: UnsupportedError,
- 1007: InitNetworkTimeoutError,
- 1008: InitDecoderTimeoutError,
- 1009: InitConfigTimeoutError,
- 1010: InitEngineTimeoutError,
- 1011: InitEngineError,
- 1012: ActionBlockedError,
- 1013: PreloadCanceledError,
- 1014: FrequencyLimitError,
- 2e3: UsersUpperLimitError,
- 2001: RoomsUpperLimitError,
- 2002: ServerParamError,
- 2003: LackOfTokenError,
- 2004: LoginFailedError,
- 2005: VerifyServiceDownError,
- 2006: CreateSessionFailedError,
- 2008: RtcConnectionError,
- 2009: DoActionFailedError,
- 2010: StateSyncFailedError,
- 2011: BroadcastFailedError,
- 2012: DataAbnormalError,
- 2015: GetOnVehicleError,
- 2017: RepeatLoginError,
- 2018: RoomDoseNotExistError,
- 2019: TicketExpireError,
- 2020: ServerRateLimitError,
- 2333: DoActionBlockedError,
- 2335: UnReachableError,
- 2334: ActionMaybeDelayError,
- 2999: ActionResponseTimeoutError
- };
- class EventEmitter {
- constructor() {
- Tt(this, "topics", {});
- Tt(this, "on", (e,i,o)=>this.register(!1, e, i, o));
- Tt(this, "once", (e,i,o)=>this.register(!0, e, i, o));
- Tt(this, "register", (e,i,o,s)=>{
- this.topics[i] || (this.topics[i] = {
- once: e,
- listeners: [],
- excuted: !1
- });
- const c = {
- order: s || 0,
- listener: o,
- once: e
- };
- return this.topics[i].listeners.push(c),
- this.topics[i].listeners.sort((d,_)=>d.order - _.order),
- {
- unsub: ()=>{
- this.off(i, o)
- }
- }
- }
- );
- Tt(this, "off", (e,i)=>{
- const o = this.topics[e];
- if (!o)
- return;
- const s = o.listeners.findIndex(c=>c.listener === i);
- this.topics[e].listeners.splice(s, 1),
- this.topics[e].listeners.length === 0 && delete this.topics[e]
- }
- );
- Tt(this, "removeAllListener", ()=>{
- this.topics = {}
- }
- );
- Tt(this, "emit", (e,i)=>{
- !this.topics[e] || !this.topics[e].listeners || this.topics[e].listeners.length < 1 || this.topics[e].excuted || (this.topics[e].listeners.forEach(o=>{
- try {
- o.listener(i !== void 0 ? i : {})
- } catch (s) {
- console.error(s)
- }
- }
- ),
- this.topics[e] && this.topics[e].once && (this.topics[e].excuted = !0))
- }
- )
- }
- }
- const safeDecodeURIComponent = a=>{
- let e = "";
- try {
- e = decodeURIComponent(a)
- } catch {
- e = a
- }
- return e
- }
- , safelyJsonParse = a=>{
- let e = {};
- try {
- e = JSON.parse(a)
- } catch {}
- return e
- }
- , getRandomItem = a=>a.length === 0 ? null : a[Math.floor(Math.random() * a.length)]
- , ENV = "production";
- function getFormattedDate(a) {
- const e = a.getMonth() + 1
- , i = a.getDate()
- , o = a.getHours()
- , s = a.getMinutes()
- , c = a.getSeconds()
- , d = a.getMilliseconds()
- , _ = (e < 10 ? "0" : "") + e
- , b = (i < 10 ? "0" : "") + i
- , k = (o < 10 ? "0" : "") + o
- , j = (s < 10 ? "0" : "") + s
- , $ = (c < 10 ? "0" : "") + c;
- return a.getFullYear() + "-" + _ + "-" + b + " " + k + ":" + j + ":" + $ + "." + d
- }
- const SERVER_URLS = {
- DEV: "wss://sit-eks.xverse.cn/ws",
- PROD: "wss://eks.xverse.cn/ws"
- }
- , REPORT_URL = {
- DEV: "https://xa.xverse.cn:6680/collect",
- PROD: "https://xa.xverse.cn/collect"
- }
- , MAX_RECONNECT_COUNT = 3
- , DEFAULT_JOINROOM_TIMEOUT = 15e3
- , DEFAULT_MAIN_CAMERA_FOV = 50
- , DEFAULT_AVATAR_SCALE = 1
- , REPORT_NUM_PER_REQUEST = 20
- , DEFAULT_OPEN_TIMEOUT_MS = 6e3
- , WS_CLOSE_NORMAL = 1e3
- , WS_CLOSE_RECONNECT = 3008
- , PING_INTERVAL_MS = 1e3
- , TEXTURE_URL = "https://static.xverse.cn/qqktv/texture.png"
- , REPORT_MODULE_TYPE = "xverse-js"
- , authenticationErrorCodes = [3001, 3002, 3003, 3005]
- , RTT_MAX_VALUE = 200
- , HB_MAX_VALUE = 500
- , DURATION = 5
- , lr = class extends EventEmitter {
- constructor() {
- super();
- Tt(this, "_header", {});
- Tt(this, "_body", {});
- Tt(this, "_queue", []);
- Tt(this, "_disabled", !1);
- Tt(this, "_interval", null);
- Tt(this, "_reportUrl");
- Tt(this, "isDocumentLoaded", ()=>document.readyState === "complete");
- this._header.logModuleId = REPORT_MODULE_TYPE,
- this._header.url = location.href,
- this._header.enviroment = ENV,
- this._header.networkType = window.navigator.connection ? window.navigator.connection.type : "unknown",
- this._interval = window.setInterval(()=>{
- this._flushReport()
- }
- , 10 * 1e3)
- }
- static appendExtraMetrics(i) {
- this.VALID_METRICS.push(...i)
- }
- disable() {
- this._disabled = !0,
- this._interval && window.clearInterval(this._interval)
- }
- updateHeader(i) {
- Object.assign(this._header, i)
- }
- updateBody(i) {
- Object.assign(this._body, i)
- }
- updateReportUrl(i) {
- this._reportUrl = i
- }
- report(i, o, s) {
- if (i === "measurement" && (Array.isArray(o) || (o = [o]),
- o.forEach(b=>{
- var k;
- (k = b.metric) != null && k.endsWith("Action") || lr.VALID_METRICS.includes(b.metric) || console.warn("invalid upload metric", b.metric)
- }
- )),
- this._disabled)
- return;
- s || (s = {});
- const {immediate: c, sampleRate: d} = s;
- if (d && d > Math.random())
- return;
- this.updateBody({
- logTime: getFormattedDate(new Date),
- logTimestamp: Date.now()
- });
- const _ = b=>{
- const k = $t(Zt($t({}, this._body), {
- type: i
- }), b);
- this._queue.push(k),
- i === "measurement" && this.emit("report", b)
- }
- ;
- Array.isArray(o) ? o.forEach(b=>_(b)) : _(o),
- (c || this._queue.length >= REPORT_NUM_PER_REQUEST) && this._flushReport()
- }
- _flushReport() {
- if (this._disabled || !this._queue.length || !this.isDocumentLoaded())
- return;
- const i = {
- header: this._header,
- body: this._queue.splice(0, REPORT_NUM_PER_REQUEST)
- };
- this._post(i)
- }
- _post(i) {
- const o = this._reportUrl || REPORT_URL.DEV;
- return new Promise((s,c)=>{
- const d = new XMLHttpRequest;
- d.open("POST", o),
- d.setRequestHeader("Content-Type", "application/json");
- try {
- d.send(JSON.stringify(i))
- } catch (_) {
- console.error(_)
- }
- d.addEventListener("readystatechange", ()=>{
- if (d.readyState == 4)
- return d.status == 200 ? s(d) : c("Unable to send log")
- }
- )
- }
- )
- }
- }
- ;
- let Reporter = lr;
- 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"]);
- const reporter = new Reporter;
- var LoggerLevels = (a=>(a[a.Debug = 1] = "Debug",
- a[a.Info = 2] = "Info",
- a[a.Warn = 3] = "Warn",
- a[a.Error = 4] = "Error",
- a[a.Off = 5] = "Off",
- a))(LoggerLevels || {});
- const ur = class {
- constructor(e) {
- Tt(this, "module", "log");
- Tt(this, "level", 1);
- this.module = e
- }
- static setLevel(e) {
- this.level = e
- }
- setLevel(e) {
- this.level = e
- }
- atleast(e) {
- return e >= this.level && e >= ur.level
- }
- print(e, i, ...o) {
- if (this.atleast(i)) {
- const s = e == "debug" ? "info" : e
- , c = this.prefix(e);
- console[s].call(null, c, ...o)
- }
- if (e !== "debug" && e !== "info") {
- const s = o.map(c=>{
- if (c instanceof Object)
- try {
- return JSON.stringify(c)
- } catch {
- return c
- }
- else
- return c
- }
- ).join(",");
- reporter.report("log", {
- message: s,
- level: e,
- module: this.module
- })
- }
- }
- debug(...e) {
- return this.print("debug", 1, ...e)
- }
- info(...e) {
- return this.print("info", 2, ...e)
- }
- infoAndReportLog(e, ...i) {
- const {reportOptions: o} = e;
- delete e.reportOptions,
- reporter.report("log", e, o),
- i.length || (i = [e.message]),
- this.debug(...i)
- }
- infoAndReportMeasurement(e, ...i) {
- var s;
- const {reportOptions: o} = e;
- if (e.startTime) {
- const c = Date.now();
- e.value === void 0 && (e.endTime = c),
- e.value === void 0 && (e.value = c - e.startTime)
- }
- if (e.error ? e.code = ((s = e.error) == null ? void 0 : s.code) || Codes$1.Internal : e.code = Codes$1.Success,
- reporter.report("measurement", e, o),
- i.length || (i = [e]),
- e.level === 4 || e.error) {
- this.error(...i);
- return
- }
- this.warn(...i)
- }
- warn(...e) {
- return this.print("warn", 3, ...e)
- }
- error(...e) {
- return this.print("error", 4, ...e)
- }
- prefix(e) {
- return `[${this.module}][${e}] ${getFormattedDate(new Date)}:`
- }
- }
- ;
- let Logger = ur;
- Tt(Logger, "level", 4);
- function getDistance(a, e) {
- const {x: i, y: o, z: s} = a
- , {x: c, y: d, z: _} = e;
- return Math.sqrt(Math.abs(i - c) ** 2 + Math.abs(o - d) ** 2 + Math.abs(s - _) ** 2)
- }
- function uuid$1() {
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, a=>{
- const e = Math.random() * 16 | 0;
- return (a === "x" ? e : e & 3 | 8).toString(16)
- }
- )
- }
- function getErrorByCode(a) {
- if (a === Codes$1.Success)
- return InternalError;
- const e = CodeErrorMap[a];
- return e || console.warn("unkown code", a),
- e || InternalError
- }
- const log$s = new Logger("events");
- class EventsManager extends EventEmitter {
- constructor() {
- super(...arguments);
- Tt(this, "events", new Map);
- Tt(this, "specialEvents", new Map)
- }
- remove(i, o, s, c) {
- if (this.specialEvents.has(i) && !c && o === Codes$1.Success)
- return;
- this.events.get(i) && (this.emit(i, {
- code: o,
- data: s
- }),
- this.events.delete(i),
- this.specialEvents.delete(i))
- }
- async track(i, o) {
- const s = i.traceId
- , {sampleRate: c=1, noReport: d=!1, special: _} = o || {}
- , b = Actions[i.event] + "Action"
- , k = i.tag;
- this.events.set(s, !0),
- _ && this.specialEvents.set(s, !0);
- const j = Date.now();
- let$ = null;
- return new Promise((_e,et)=>{
- if (d)
- return this.off(s),
- this.events.delete(s),
- _e(void 0);
- this.on(s, ({code: rt, data: it, msg: nt})=>{
- if (rt === Codes$1.Success)
- _e(it),
- this.off(s),
- Math.random() < c && log$s.infoAndReportMeasurement({
- metric: b,
- tag: k,
- extra: i.extra,
- startTime: j,
- traceId: s
- });
- else {
- if (rt === Codes$1.ActionMaybeDelay)
- return;
- if (rt === Codes$1.DoActionBlocked && i.event === Actions.Rotation) {
- log$s.debug(b + " response code: " + rt);
- return
- }
- const ot = getErrorByCode(rt)
- , at = new ot(nt);
- this.off(s),
- et(at),
- this.emit("actionResponseError", {
- error: at,
- event: i,
- tag: k
- }),
- log$s.infoAndReportMeasurement({
- metric: b,
- tag: k,
- extra: i.extra,
- error: at,
- startTime: j,
- traceId: s
- })
- }
- }
- );
- const tt = i.timeout || 2e3;
- $ = window.setTimeout(()=>{
- if ($ && clearTimeout($),
- !this.events.get(s))
- return;
- const rt = new ActionResponseTimeoutError(`${b} timeout in ${tt}ms`);
- this.emit("actionResponseTimeout", {
- error: rt,
- event: i,
- tag: k
- }),
- et(rt),
- this.events.delete(s),
- this.off(s),
- log$s.infoAndReportMeasurement({
- metric: b,
- tag: k,
- extra: i.extra,
- error: rt,
- startTime: j,
- traceId: s
- })
- }
- , tt)
- }
- )
- }
- emitTraceIdToDecoder(i, o) {
- if (i === Actions.Rotation || i === Actions.Clicking || i === Actions.GetOnVehicle || i === Actions.GetOffVehicle || i === Actions.Joystick) {
- const s = {
- [Actions.Rotation]: "Rotation",
- [Actions.GetOnVehicle]: "GetOnVehicle",
- [Actions.GetOffVehicle]: "GetOffVehicle",
- [Actions.Clicking]: "MoveTo",
- [Actions.Joystick]: "Joystick"
- };
- this.emit("traceId", {
- traceId: o,
- timestamp: Date.now(),
- event: s[i]
- })
- }
- }
- }
- const eventsManager = new EventsManager;
- var Actions = (a=>(a[a.Clicking = 1] = "Clicking",
- a[a.PlayCG = 6] = "PlayCG",
- a[a.Back = 7] = "Back",
- a[a.ChangeRoom = 8] = "ChangeRoom",
- a[a.ChangeSkin = 13] = "ChangeSkin",
- a[a.Joystick = 15] = "Joystick",
- a[a.Transfer = 18] = "Transfer",
- a[a.GetOnVehicle = 22] = "GetOnVehicle",
- a[a.GetOffVehicle = 23] = "GetOffVehicle",
- a[a.StopMoving = 34] = "StopMoving",
- a[a.UnaryActionLine = 1e3] = "UnaryActionLine",
- a[a.Init = 1001] = "Init",
- a[a.Exit = 1002] = "Exit",
- a[a.SetIFrameInfo = 1003] = "SetIFrameInfo",
- a[a.GetNeighborPoints = 1004] = "GetNeighborPoints",
- a[a.ReserveSeat = 1005] = "ReserveSeat",
- a[a.GetReserveStatus = 1006] = "GetReserveStatus",
- a[a.ChangeNickname = 1007] = "ChangeNickname",
- a[a.ChangeBitRateInfo = 1008] = "ChangeBitRateInfo",
- a[a.Echo = 1009] = "Echo",
- a[a.SetPlayerState = 1010] = "SetPlayerState",
- a[a.TurnTo = 1011] = "TurnTo",
- a[a.TurnToFace = 1012] = "TurnToFace",
- a[a.RotateTo = 1013] = "RotateTo",
- a[a.Rotation = 1014] = "Rotation",
- a[a.CameraTurnTo = 1015] = "CameraTurnTo",
- a[a.ConfirmEvent = 1016] = "ConfirmEvent",
- a[a.Broadcast = 1017] = "Broadcast",
- a[a.NotifyActionLine = 2e4] = "NotifyActionLine",
- a[a.AudienceChangeToVisitor = 1020] = "AudienceChangeToVisitor",
- a[a.VisitorChangeToAudience = 1021] = "VisitorChangeToAudience",
- a[a.RemoveVisitor = 1022] = "RemoveVisitor",
- a[a.GetUserWithAvatar = 1023] = "GetUserWithAvatar",
- a[a.GetNewUserState = 1024] = "GetNewUserState",
- a[a.SetSyncPolicy = 1025] = "SetSyncPolicy",
- a))(Actions || {})
- , RemoveVisitorType = (a=>(a[a.RVT_ChangeToObserver = 1] = "RVT_ChangeToObserver",
- a[a.RVT_MoveOutOfTheRoom = 2] = "RVT_MoveOutOfTheRoom",
- a))(RemoveVisitorType || {})
- , NewUserStateType = (a=>(a[a.NUST_Undefined = 0] = "NUST_Undefined",
- a[a.NUST_Myself = 1] = "NUST_Myself",
- a[a.NUST_FollowingList = 2] = "NUST_FollowingList",
- a))(NewUserStateType || {})
- , CoreBroadcastType = (a=>(a.PlayAnimation = "PlayAnimation",
- a))(CoreBroadcastType || {})
- , MessageHandleType = (a=>(a[a.MHT_Undefined = 0] = "MHT_Undefined",
- a[a.MHT_RoomMulticast = 1] = "MHT_RoomMulticast",
- a[a.MHT_FollowListMulticast = 2] = "MHT_FollowListMulticast",
- a[a.MHT_CustomTargetSync = 3] = "MHT_CustomTargetSync",
- a))(MessageHandleType || {});
- new Logger("xverse-broadcast");
- const cr = class {
- constructor(e, i) {
- this.room = e,
- cr.handlers.push(i)
- }
- broadcast(e) {
- const {data: i, msgType: o=MessageHandleType.MHT_FollowListMulticast, targetUserIds: s, sampleRate: c=1} = e;
- return this.room.actionsHandler.broadcast({
- data: i,
- msgType: o,
- targetUserIds: s,
- sampleRate: c
- })
- }
- }
- ;
- let Broadcast = cr;
- Tt(Broadcast, "handlers", []);
- const log$r = new Logger("actions-handler")
- , QueueActions = [Actions.Transfer, Actions.ChangeSkin, Actions.GetOnVehicle, Actions.GetOffVehicle];
- class ActionsHandler {
- constructor(e) {
- Tt(this, "room");
- Tt(this, "currentActiveAction");
- Tt(this, "blockedActions", []);
- Tt(this, "avatarComponentsSync", e=>{
- const i = {
- action_type: Actions.SetPlayerState,
- set_player_state_action: {
- player_state: {
- avatar_components: JSON.stringify(e)
- }
- }
- };
- this.sendData({
- data: i
- })
- }
- );
- this.room = e
- }
- addBlockedActions(e) {
- this.blockedActions.push(...e)
- }
- removeBlockedActions(e) {
- if (!e) {
- this.blockedActions = [];
- return
- }
- const i = this.blockedActions.indexOf(e);
- this.blockedActions.splice(i, 1)
- }
- async sendData(e) {
- await this.beforeSend(e);
- const i = uuid$1();
- if (this.room.networkController.sendRtcData(Zt($t({}, e.data), {
- trace_id: i,
- user_id: this.room.options.userId
- })),
- eventsManager.emitTraceIdToDecoder(e.data.action_type, i),
- this.blockedActions.includes(e.data.action_type))
- return new Promise(()=>{}
- );
- if (e.track === !1)
- return Promise.resolve(null);
- const {sampleRate: o=1, timeout: s=2e3, tag: c, data: d, special: _} = e;
- return eventsManager.track({
- timeout: s,
- traceId: i,
- event: d.action_type,
- tag: c,
- extra: d
- }, {
- special: _,
- sampleRate: o,
- noReport: this.room.viewMode === "serverless" || this.room.options.viewMode === "serverless"
- }).finally(()=>{
- QueueActions.includes(e.data.action_type) && (this.currentActiveAction = void 0)
- }
- )
- }
- async beforeSend(e) {
- var c;
- const i = (c = this.room._userAvatar) == null ? void 0 : c.isMoving
- , o = e.data.action_type;
- if (QueueActions.includes(o)) {
- if (this.currentActiveAction)
- return log$r.error(`${Actions[this.currentActiveAction]} still pending, reject ${Actions[o]}`),
- Promise.reject(new FrequencyLimitError(`${Actions[o]} action request frequency limit`));
- this.currentActiveAction = o
- }
- if (i && QueueActions.includes(e.data.action_type))
- try {
- await this.stopMoving()
- } catch (d) {
- this.currentActiveAction = void 0,
- log$r.error("before action stopMoving failed", d)
- }
- }
- async moveTo(e) {
- const {point: i, extra: o="", motionType: s} = e
- , c = {
- action_type: Actions.Clicking,
- clicking_action: {
- clicking_point: i,
- clicking_type: ClickType.IgnoreView,
- extra: encodeURIComponent(o),
- attitude: s
- },
- clicking_state: this.room._currentClickingState
- };
- return this.sendData({
- data: c
- })
- }
- transfer(e) {
- const {renderType: i, player: o, camera: s, areaName: c, attitude: d, pathName: _, person: b, noMedia: k, timeout: j, tag: $, special: _e} = e
- , et = {
- data: {
- action_type: Actions.Transfer,
- transfer_action: {
- render_type: i,
- player: o,
- camera: s,
- areaName: c,
- attitude: d,
- pathName: _,
- person: {
- type: b
- },
- noMedia: k,
- tiles: [0, 1, 2, 4]
- }
- },
- special: _e,
- timeout: j || 4e3,
- tag: $
- };
- return this.sendData(et).then(tt=>(typeof b != "undefined" && this.room.updateCurrentNetworkOptions({
- person: b,
- rotationRenderType: i
- }),
- tt))
- }
- changeRotationRenderType(e) {
- const {renderType: i, player: o, camera: s, areaName: c, attitude: d, pathName: _} = e;
- return this.transfer({
- renderType: i,
- player: o,
- camera: s,
- areaName: c,
- attitude: d,
- pathName: _,
- tag: "changeToRotationVideo"
- })
- }
- requestPanorama(e, i, o) {
- const {camera: s, player: c, areaName: d, attitude: _, pathName: b, tag: k} = e;
- return this.transfer({
- renderType: RenderType.ClientRotationPano,
- player: c,
- camera: s,
- person: Person.First,
- areaName: d,
- attitude: _,
- pathName: b,
- noMedia: i,
- timeout: o,
- tag: k || "requestPanorama",
- special: !i
- })
- }
- setMotionType(e) {
- return this.transfer({
- attitude: e,
- tag: "setMotionType"
- })
- }
- setNickName(e) {
- const i = {
- action_type: Actions.ChangeNickname,
- change_nickname_action: {
- nickname: e
- }
- };
- return this.sendData({
- data: i
- })
- }
- getReserveSeat({routeId: e, name: i}) {
- const o = {
- action_type: Actions.ReserveSeat,
- reserve_seat_action: {
- route_id: e,
- name: i
- }
- };
- return this.sendData({
- data: o
- })
- }
- getReserveStatus({routeId: e, name: i, need_detail: o}) {
- const s = {
- action_type: Actions.GetReserveStatus,
- get_reserve_status_action: {
- route_id: e,
- name: i,
- need_detail: o
- }
- };
- return this.sendData({
- data: s,
- timeout: 2e3
- }).then(c=>c.reserveDetail)
- }
- stopMoving() {
- const e = {
- action_type: Actions.StopMoving,
- stop_move_action: {}
- };
- return this.sendData({
- data: e
- })
- }
- getOnVehicle({routeId: e, name: i, camera: o}) {
- const s = {
- action_type: Actions.GetOnVehicle,
- get_on_vehicle_action: {
- route_id: e,
- name: i,
- camera: o
- }
- };
- return this.sendData({
- data: s
- })
- }
- getOffVehicle({renderType: e, player: i, camera: o}) {
- const s = {
- action_type: Actions.GetOffVehicle,
- get_off_vehicle_action: {
- render_type: e,
- player: i,
- camera: o
- }
- };
- return this.sendData({
- data: s
- })
- }
- confirmEvent(e) {
- const i = {
- action_type: Actions.ConfirmEvent,
- confirm_event_action: {
- id: e
- }
- };
- return this.sendData({
- data: i,
- track: !1
- })
- }
- echo(e) {
- const i = {
- action_type: Actions.Echo,
- echo_msg: {
- echoMsg: e
- }
- };
- return this.sendData({
- data: i,
- track: !1
- })
- }
- async changeSkin(e) {
- const i = e.special === void 0 ? e.renderType === RenderType.ClientRotationPano : e.special
- , {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
- , it = this.room.skinList.filter(ot=>ot.id === o)[0];
- if (!it) {
- const ot = `skin ${o} is invalid`;
- return log$r.error(ot),
- Promise.reject(new ParamError(ot))
- }
- const nt = {
- action_type: Actions.ChangeSkin,
- change_skin_action: {
- skinID: o,
- mode: s === ChangeMode.Preview ? ChangeMode.Preview : ChangeMode.Confirm,
- skin_data_version: o + it.versionId,
- landing_type: c,
- landing_point: d,
- landing_camera: _,
- render_wrapper: {
- render_type: b
- },
- areaName: k,
- attitude: j,
- noMedia: et,
- person: _e,
- pathName: $,
- roomTypeId: rt
- }
- };
- return this.sendData({
- data: nt,
- timeout: tt || 6e3,
- special: i
- }).then(async ot=>(b === RenderType.ClientRotationPano && ot && await this.room.panorama.handleReceivePanorama(ot),
- this.handleChangeSkin(e))).catch(ot=>et ? this.handleChangeSkin(e) : Promise.reject(ot))
- }
- handleChangeSkin(e) {
- const {skinId: i, mode: o, renderType: s, areaName: c, attitude: d, pathName: _} = e;
- return this.room.sceneManager.staticmeshComponent.getCgMesh().show(),
- this.room.sceneManager.cameraComponent.switchToCgCamera(),
- this.room.engineProxy._updateSkinAssets(i).then(()=>{
- this.room.sceneManager.staticmeshComponent.getCgMesh().hide(),
- this.room.sceneManager.cameraComponent.switchToMainCamera(),
- this.room.pathManager.currentArea = c,
- log$r.info("changeSkin _updateSkinAssets susccss"),
- this.room.updateCurrentNetworkOptions({
- pathName: _,
- attitude: d,
- areaName: c
- }),
- this.room.skinChangedHook(),
- this.room.emit("skinChanged", {
- skin: {
- id: i
- },
- mode: o
- }),
- s === RenderType.ClientRotationPano && this.room.sceneManager.cameraComponent.allowMainCameraController()
- }
- )
- }
- rotate({pitch: e, yaw: i}) {
- var s;
- if (this.room.isPano || ((s = this.room._userAvatar) == null ? void 0 : s._isChangingComponentsMode))
- return;
- const o = {
- action_type: Actions.Rotation,
- rotation_action: {
- vertical_move: e,
- horizontal_move: -i
- }
- };
- this.sendData({
- data: o,
- track: !1
- })
- }
- turnTo(e) {
- const {point: i, timeout: o=2e3, offset: s=8} = e || {}
- , c = {
- action_type: Actions.TurnTo,
- turn_to_action: {
- turn_to_point: i,
- offset: s
- }
- };
- return this.sendData({
- data: c,
- timeout: o
- })
- }
- rotateTo(e) {
- const {point: i, offset: o=0, speed: s=3} = e || {}
- , c = {
- action_type: Actions.RotateTo,
- rotate_to_action: {
- rotate_to_point: i,
- offset: o,
- speed: s
- }
- };
- return this.sendData({
- data: c
- })
- }
- broadcast(e) {
- const {data: i, msgType: o=MessageHandleType.MHT_FollowListMulticast, targetUserIds: s, sampleRate: c=1} = e;
- if (o === MessageHandleType.MHT_CustomTargetSync && !Array.isArray(s))
- return Promise.reject(new ParamError(`param targetUserIds is required when msgType is ${MessageHandleType[o]}`));
- const d = {
- action_type: Actions.Broadcast,
- broadcast_action: {
- data: JSON.stringify(i),
- user_id: this.room.options.userId,
- msgType: o
- }
- };
- return Array.isArray(s) && o === MessageHandleType.MHT_CustomTargetSync && (d.broadcast_action.target_user_ids = s),
- this.room.actionsHandler.sendData({
- data: d,
- tag: i.broadcastType,
- sampleRate: c
- })
- }
- getNeighborPoints(e) {
- const {point: i, containSelf: o=!1, searchRange: s=500} = e
- , c = {
- action_type: Actions.GetNeighborPoints,
- get_neighbor_points_action: {
- point: i,
- level: 1,
- containSelf: o,
- searchRange: s
- }
- };
- return this.sendData({
- data: c
- }).then(d=>d.nps)
- }
- playCG(e) {
- const i = {
- action_type: Actions.PlayCG,
- play_cg_action: {
- cg_name: e
- }
- };
- return this.sendData({
- data: i
- })
- }
- audienceToVisitor(e) {
- const {avatarId: i, avatarComponents: o, player: s, camera: c} = e
- , d = {
- action_type: Actions.AudienceChangeToVisitor,
- audienceChangeToVisitorAction: {
- avatarID: i,
- avatarComponents: o,
- player: s,
- camera: c
- }
- };
- return log$r.debug("send data: audience to visitor"),
- this.sendData({
- data: d
- })
- }
- visitorToAudience(e) {
- const {renderType: i, player: o, camera: s, areaName: c, attitude: d, pathName: _, person: b, noMedia: k} = e
- , j = {
- action_type: Actions.VisitorChangeToAudience,
- visitorChangeToAudienceAction: {
- transferAction: {
- render_type: i,
- player: o,
- camera: s,
- areaName: c,
- attitude: d,
- pathName: _,
- person: {
- type: b
- },
- noMedia: k,
- tiles: [0, 1, 2, 4]
- }
- }
- };
- return log$r.debug("send data: visitor to audience"),
- this.sendData({
- data: j
- })
- }
- removeVisitor(e) {
- const {removeType: i, userIDList: o, extraInfo: s=""} = e
- , c = {
- action_type: Actions.RemoveVisitor,
- removeVisitorAction: {
- removeVisitorEvent: i,
- userIDList: o.map(d=>String(d)),
- extraInfo: encodeURIComponent(s)
- }
- };
- return log$r.debug("send data: remove visitor"),
- this.sendData({
- data: c
- })
- }
- getUserWithAvatar(e, i) {
- const o = {
- action_type: Actions.GetUserWithAvatar,
- getUserWithAvatarAction: {
- userType: e,
- roomID: i
- }
- };
- return log$r.debug("send data: get user with avatar"),
- this.sendData({
- data: o,
- sampleRate: 0
- }).then(s=>(Math.random() < .1 && log$r.infoAndReportMeasurement({
- metric: "getUserWithAvatar",
- startTime: Date.now(),
- extra: {
- visitors: s.userWithAvatarList,
- avatars: this.room.avatars.filter(c=>c.withModel).map(c=>({
- isHost: c.isHost,
- userID: c.userId
- }))
- }
- }),
- s.userWithAvatarList))
- }
- getNewUserState(e) {
- const i = {
- action_type: Actions.GetNewUserState,
- getNewUserStateAction: {
- userType: e
- }
- };
- return this.sendData({
- data: i,
- sampleRate: 0
- }).then(o=>o)
- }
- setSyncPolicy({syncPolicy: e}) {
- const i = {
- action_type: Actions.SetSyncPolicy,
- setSyncPolicyAction: {
- syncPolicy: e
- }
- };
- return this.sendData({
- data: i
- })
- }
- joystick(e) {
- const {degree: i, level: o=1} = e
- , s = uuid$1();
- let c = -i + 90 + 360;
- c >= 360 && (c -= 360);
- const d = {
- action_type: Actions.Joystick,
- dir_action: {
- move_angle: c,
- speed_level: o
- },
- trace_id: s,
- user_id: this.room.options.userId,
- packet_id: s
- };
- return this.sendData({
- data: d,
- track: !1
- })
- }
- }
- const log$q = new Logger("db");
- class BaseTable {
- constructor(e, i) {
- Tt(this, "db");
- Tt(this, "isCreatingTable", !1);
- Tt(this, "hasCleared", !1);
- this.dbName = e,
- this.dbVersion = i
- }
- async clearDataBase(e) {
- return this.hasCleared || (e && (this.hasCleared = !0),
- !window.indexedDB.databases) ? Promise.resolve() : new Promise((i,o)=>{
- const s = window.indexedDB.deleteDatabase(this.dbName);
- s.onsuccess = ()=>{
- i()
- }
- ,
- s.onerror = o
- }
- )
- }
- tableName() {
- throw new Error("Derived class have to override 'tableName', and set a proper table name!")
- }
- keyPath() {
- throw new Error("Derived class have to override 'keyPath', and set a proper index name!")
- }
- index() {
- throw new Error("Derived class have to override 'index', and set a proper index name!")
- }
- async checkAndOpenDatabase() {
- return this.db ? Promise.resolve(this.db) : new Promise((e,i)=>{
- const s = setTimeout(()=>{
- log$q.warn("wait db to open for", 200),
- this.db ? e(this.db) : e(this.checkAndOpenDatabase()),
- clearTimeout(s)
- }
- , 200);
- this.openDatabase(this.dbName, this.dbVersion || 1, ()=>{
- this.db && !this.isCreatingTable && e(this.db),
- log$q.warn(`successCallback called, this.db: ${!!this.db}, this.isCreatingStore: ${this.isCreatingTable}`),
- clearTimeout(s)
- }
- , ()=>{
- i(new Error("Failed to open database!")),
- clearTimeout(s)
- }
- , ()=>{
- this.db && e(this.db),
- clearTimeout(s),
- log$q.warn(`successCallback called, this.db: ${!!this.db}, this.isCreatingStore: ${this.isCreatingTable}`)
- }
- )
- }
- )
- }
- openDatabase(e, i, o, s, c) {
- if (this.isCreatingTable)
- return;
- this.isCreatingTable = !0,
- log$q.warn({
- database: e,
- version: i
- });
- const d = window.indexedDB.open(e, i)
- , _ = this.tableName();
- d.onsuccess = b=>{
- this.db = d.result,
- log$q.warn(`IndexedDb ${e} is opened.`),
- this.db.objectStoreNames.contains(_) && (this.isCreatingTable = !1),
- o && o(b)
- }
- ,
- d.onerror = b=>{
- var k;
- log$q.error("Failed to open database", (k = b == null ? void 0 : b.srcElement) == null ? void 0 : k.error),
- this.isCreatingTable = !1,
- s && s(b),
- this.clearDataBase(!0)
- }
- ,
- d.onupgradeneeded = b=>{
- const k = b.target.result
- , j = this.index();
- log$q.warn(`Creating table ${_}.`);
- let$ = k.objectStoreNames.contains(_);
- if ($)
- $ = k.transaction([_], "readwrite").objectStore(_);
- else {
- const _e = this.keyPath();
- $ = k.createObjectStore(_, {
- keyPath: _e
- })
- }
- j.map(_e=>{
- $.createIndex(_e, _e, {
- unique: !1
- })
- }
- ),
- this.isCreatingTable = !1,
- log$q.warn(`Table ${_} opened`),
- c && c(b)
- }
- }
- async add(e) {
- const i = this.tableName()
- , c = (await this.checkAndOpenDatabase()).transaction([i], "readwrite").objectStore(i).add(e);
- return new Promise(function(d, _) {
- c.onsuccess = b=>{
- d(b)
- }
- ,
- c.onerror = b=>{
- var k;
- log$q.error((k = b.srcElement) == null ? void 0 : k.error),
- _(b)
- }
- }
- )
- }
- async put(e) {
- const i = this.tableName()
- , c = (await this.checkAndOpenDatabase()).transaction([i], "readwrite").objectStore(i).put(e);
- return new Promise(function(d, _) {
- c.onsuccess = b=>{
- d(b)
- }
- ,
- c.onerror = b=>{
- var k;
- log$q.error("db put error", (k = b.srcElement) == null ? void 0 : k.error),
- _(b)
- }
- }
- )
- }
- delete(e, i, o) {
- const s = this.tableName();
- this.checkAndOpenDatabase().then(c=>{
- const _ = c.transaction([s], "readwrite").objectStore(s).delete(e);
- _.onsuccess = i,
- _.onerror = o
- }
- )
- }
- update() {
- this.checkAndOpenDatabase().then(e=>{}
- )
- }
- async getAllKeys() {
- const e = this.tableName()
- , i = await this.checkAndOpenDatabase();
- return new Promise((o,s)=>{
- const d = i.transaction([e], "readonly").objectStore(e).getAllKeys();
- d.onsuccess = _=>{
- o(_.target.result)
- }
- ,
- d.onerror = _=>{
- log$q.error("db getAllKeys error", _),
- s(_)
- }
- }
- )
- }
- async query(e, i) {
- const o = this.tableName()
- , s = await this.checkAndOpenDatabase();
- return new Promise((c,d)=>{
- const k = s.transaction([o], "readonly").objectStore(o).index(e).get(i);
- k.onsuccess = function(j) {
- var _e;
- const $ = (_e = j == null ? void 0 : j.target) == null ? void 0 : _e.result;
- c && c($)
- }
- ,
- k.onerror = j=>{
- log$q.error("db query error", j),
- d(j)
- }
- }
- )
- }
- async sleep(e) {
- return new Promise(i=>{
- setTimeout(()=>{
- i("")
- }
- , e)
- }
- )
- }
- }
- class ModelTable extends BaseTable {
- constructor() {
- super("XverseDatabase", 1)
- }
- tableName() {
- return "models"
- }
- index() {
- return ["url"]
- }
- keyPath() {
- return "url"
- }
- }
- const modelTable = new ModelTable;
- var axios$2 = {
- exports: {}
- }
- , bind$2 = function(e, i) {
- return function() {
- for (var s = new Array(arguments.length), c = 0; c < s.length; c++)
- s[c] = arguments[c];
- return e.apply(i, s)
- }
- }
- , bind$1 = bind$2
- , toString = Object.prototype.toString;
- function isArray$1(a) {
- return toString.call(a) === "[object Array]"
- }
- function isUndefined(a) {
- return typeof a == "undefined"
- }
- function isBuffer(a) {
- return a !== null && !isUndefined(a) && a.constructor !== null && !isUndefined(a.constructor) && typeof a.constructor.isBuffer == "function" && a.constructor.isBuffer(a)
- }
- function isArrayBuffer(a) {
- return toString.call(a) === "[object ArrayBuffer]"
- }
- function isFormData(a) {
- return typeof FormData != "undefined" && a instanceof FormData
- }
- function isArrayBufferView(a) {
- var e;
- return typeof ArrayBuffer != "undefined" && ArrayBuffer.isView ? e = ArrayBuffer.isView(a) : e = a && a.buffer && a.buffer instanceof ArrayBuffer,
- e
- }
- function isString(a) {
- return typeof a == "string"
- }
- function isNumber(a) {
- return typeof a == "number"
- }
- function isObject(a) {
- return a !== null && typeof a == "object"
- }
- function isPlainObject(a) {
- if (toString.call(a) !== "[object Object]")
- return !1;
- var e = Object.getPrototypeOf(a);
- return e === null || e === Object.prototype
- }
- function isDate(a) {
- return toString.call(a) === "[object Date]"
- }
- function isFile(a) {
- return toString.call(a) === "[object File]"
- }
- function isBlob(a) {
- return toString.call(a) === "[object Blob]"
- }
- function isFunction$1(a) {
- return toString.call(a) === "[object Function]"
- }
- function isStream(a) {
- return isObject(a) && isFunction$1(a.pipe)
- }
- function isURLSearchParams(a) {
- return typeof URLSearchParams != "undefined" && a instanceof URLSearchParams
- }
- function trim(a) {
- return a.trim ? a.trim() : a.replace(/^\s+|\s+$/g, "")
- }
- function isStandardBrowserEnv() {
- return typeof navigator != "undefined" && (navigator.product === "ReactNative" || navigator.product === "NativeScript" || navigator.product === "NS") ? !1 : typeof window != "undefined" && typeof document != "undefined"
- }
- function forEach(a, e) {
- if (!(a === null || typeof a == "undefined"))
- if (typeof a != "object" && (a = [a]),
- isArray$1(a))
- for (var i = 0, o = a.length; i < o; i++)
- e.call(null, a[i], i, a);
- else
- for (var s in a)
- Object.prototype.hasOwnProperty.call(a, s) && e.call(null, a[s], s, a)
- }
- function merge() {
- var a = {};
- function e(s, c) {
- 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
- }
- for (var i = 0, o = arguments.length; i < o; i++)
- forEach(arguments[i], e);
- return a
- }
- function extend$2(a, e, i) {
- return forEach(e, function(s, c) {
- i && typeof s == "function" ? a[c] = bind$1(s, i) : a[c] = s
- }),
- a
- }
- function stripBOM(a) {
- return a.charCodeAt(0) === 65279 && (a = a.slice(1)),
- a
- }
- var utils$d = {
- isArray: isArray$1,
- isArrayBuffer,
- isBuffer,
- isFormData,
- isArrayBufferView,
- isString,
- isNumber,
- isObject,
- isPlainObject,
- isUndefined,
- isDate,
- isFile,
- isBlob,
- isFunction: isFunction$1,
- isStream,
- isURLSearchParams,
- isStandardBrowserEnv,
- forEach,
- merge,
- extend: extend$2,
- trim,
- stripBOM
- }
- , utils$c = utils$d;
- function encode(a) {
- return encodeURIComponent(a).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]")
- }
- var buildURL$2 = function(e, i, o) {
- if (!i)
- return e;
- var s;
- if (o)
- s = o(i);
- else if (utils$c.isURLSearchParams(i))
- s = i.toString();
- else {
- var c = [];
- utils$c.forEach(i, function(b, k) {
- b === null || typeof b == "undefined" || (utils$c.isArray(b) ? k = k + "[]" : b = [b],
- utils$c.forEach(b, function($) {
- utils$c.isDate($) ? $ = $.toISOString() : utils$c.isObject($) && ($ = JSON.stringify($)),
- c.push(encode(k) + "=" + encode($))
- }))
- }),
- s = c.join("&")
- }
- if (s) {
- var d = e.indexOf("#");
- d !== -1 && (e = e.slice(0, d)),
- e += (e.indexOf("?") === -1 ? "?" : "&") + s
- }
- return e
- }
- , utils$b = utils$d;
- function InterceptorManager$1() {
- this.handlers = []
- }
- InterceptorManager$1.prototype.use = function(e, i, o) {
- return this.handlers.push({
- fulfilled: e,
- rejected: i,
- synchronous: o ? o.synchronous : !1,
- runWhen: o ? o.runWhen : null
- }),
- this.handlers.length - 1
- }
- ;
- InterceptorManager$1.prototype.eject = function(e) {
- this.handlers[e] && (this.handlers[e] = null)
- }
- ;
- InterceptorManager$1.prototype.forEach = function(e) {
- utils$b.forEach(this.handlers, function(o) {
- o !== null && e(o)
- })
- }
- ;
- var InterceptorManager_1 = InterceptorManager$1
- , utils$a = utils$d
- , normalizeHeaderName$1 = function(e, i) {
- utils$a.forEach(e, function(s, c) {
- c !== i && c.toUpperCase() === i.toUpperCase() && (e[i] = s,
- delete e[c])
- })
- }
- , enhanceError$2 = function(e, i, o, s, c) {
- return e.config = i,
- o && (e.code = o),
- e.request = s,
- e.response = c,
- e.isAxiosError = !0,
- e.toJSON = function() {
- return {
- message: this.message,
- name: this.name,
- description: this.description,
- number: this.number,
- fileName: this.fileName,
- lineNumber: this.lineNumber,
- columnNumber: this.columnNumber,
- stack: this.stack,
- config: this.config,
- code: this.code,
- status: this.response && this.response.status ? this.response.status : null
- }
- }
- ,
- e
- }
- , enhanceError$1 = enhanceError$2
- , createError$2 = function(e, i, o, s, c) {
- var d = new Error(e);
- return enhanceError$1(d, i, o, s, c)
- }
- , createError$1 = createError$2
- , settle$1 = function(e, i, o) {
- var s = o.config.validateStatus;
- !o.status || !s || s(o.status) ? e(o) : i(createError$1("Request failed with status code " + o.status, o.config, null, o.request, o))
- }
- , utils$9 = utils$d
- , cookies$1 = utils$9.isStandardBrowserEnv() ? function() {
- return {
- write: function(i, o, s, c, d, _) {
- var b = [];
- b.push(i + "=" + encodeURIComponent(o)),
- utils$9.isNumber(s) && b.push("expires=" + new Date(s).toGMTString()),
- utils$9.isString(c) && b.push("path=" + c),
- utils$9.isString(d) && b.push("domain=" + d),
- _ === !0 && b.push("secure"),
- document.cookie = b.join("; ")
- },
- read: function(i) {
- var o = document.cookie.match(new RegExp("(^|;\\s*)(" + i + ")=([^;]*)"));
- return o ? decodeURIComponent(o[3]) : null
- },
- remove: function(i) {
- this.write(i, "", Date.now() - 864e5)
- }
- }
- }() : function() {
- return {
- write: function() {},
- read: function() {
- return null
- },
- remove: function() {}
- }
- }()
- , isAbsoluteURL$1 = function(e) {
- return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)
- }
- , combineURLs$1 = function(e, i) {
- return i ? e.replace(/\/+$/, "") + "/" + i.replace(/^\/+/, "") : e
- }
- , isAbsoluteURL = isAbsoluteURL$1
- , combineURLs = combineURLs$1
- , buildFullPath$1 = function(e, i) {
- return e && !isAbsoluteURL(i) ? combineURLs(e, i) : i
- }
- , utils$8 = utils$d
- , 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"]
- , parseHeaders$1 = function(e) {
- var i = {}, o, s, c;
- return e && utils$8.forEach(e.split(`
- `), function(_) {
- if (c = _.indexOf(":"),
- o = utils$8.trim(_.substr(0, c)).toLowerCase(),
- s = utils$8.trim(_.substr(c + 1)),
- o) {
- if (i[o] && ignoreDuplicateOf.indexOf(o) >= 0)
- return;
- o === "set-cookie" ? i[o] = (i[o] ? i[o] : []).concat([s]) : i[o] = i[o] ? i[o] + ", " + s : s
- }
- }),
- i
- }
- , utils$7 = utils$d
- , isURLSameOrigin$1 = utils$7.isStandardBrowserEnv() ? function() {
- var e = /(msie|trident)/i.test(navigator.userAgent), i = document.createElement("a"), o;
- function s(c) {
- var d = c;
- return e && (i.setAttribute("href", d),
- d = i.href),
- i.setAttribute("href", d),
- {
- href: i.href,
- protocol: i.protocol ? i.protocol.replace(/:$/, "") : "",
- host: i.host,
- search: i.search ? i.search.replace(/^\?/, "") : "",
- hash: i.hash ? i.hash.replace(/^#/, "") : "",
- hostname: i.hostname,
- port: i.port,
- pathname: i.pathname.charAt(0) === "/" ? i.pathname : "/" + i.pathname
- }
- }
- return o = s(window.location.href),
- function(d) {
- var _ = utils$7.isString(d) ? s(d) : d;
- return _.protocol === o.protocol && _.host === o.host
- }
- }() : function() {
- return function() {
- return !0
- }
- }();
- function Cancel$3(a) {
- this.message = a
- }
- Cancel$3.prototype.toString = function() {
- return "Cancel" + (this.message ? ": " + this.message : "")
- }
- ;
- Cancel$3.prototype.__CANCEL__ = !0;
- var Cancel_1 = Cancel$3
- , utils$6 = utils$d
- , settle = settle$1
- , cookies = cookies$1
- , buildURL$1 = buildURL$2
- , buildFullPath = buildFullPath$1
- , parseHeaders = parseHeaders$1
- , isURLSameOrigin = isURLSameOrigin$1
- , createError = createError$2
- , defaults$4 = defaults_1
- , Cancel$2 = Cancel_1
- , xhr = function(e) {
- return new Promise(function(o, s) {
- var c = e.data, d = e.headers, _ = e.responseType, b;
- function k() {
- e.cancelToken && e.cancelToken.unsubscribe(b),
- e.signal && e.signal.removeEventListener("abort", b)
- }
- utils$6.isFormData(c) && delete d["Content-Type"];
- var j = new XMLHttpRequest;
- if (e.auth) {
- var $ = e.auth.username || ""
- , _e = e.auth.password ? unescape(encodeURIComponent(e.auth.password)) : "";
- d.Authorization = "Basic " + btoa($ + ":" + _e)
- }
- var et = buildFullPath(e.baseURL, e.url);
- j.open(e.method.toUpperCase(), buildURL$1(et, e.params, e.paramsSerializer), !0),
- j.timeout = e.timeout;
- function tt() {
- if (!!j) {
- var it = "getAllResponseHeaders"in j ? parseHeaders(j.getAllResponseHeaders()) : null
- , nt = !_ || _ === "text" || _ === "json" ? j.responseText : j.response
- , ot = {
- data: nt,
- status: j.status,
- statusText: j.statusText,
- headers: it,
- config: e,
- request: j
- };
- settle(function(st) {
- o(st),
- k()
- }, function(st) {
- s(st),
- k()
- }, ot),
- j = null
- }
- }
- if ("onloadend"in j ? j.onloadend = tt : j.onreadystatechange = function() {
- !j || j.readyState !== 4 || j.status === 0 && !(j.responseURL && j.responseURL.indexOf("file:") === 0) || setTimeout(tt)
- }
- ,
- j.onabort = function() {
- !j || (s(createError("Request aborted", e, "ECONNABORTED", j)),
- j = null)
- }
- ,
- j.onerror = function() {
- s(createError("Network Error", e, null, j)),
- j = null
- }
- ,
- j.ontimeout = function() {
- var nt = e.timeout ? "timeout of " + e.timeout + "ms exceeded" : "timeout exceeded"
- , ot = e.transitional || defaults$4.transitional;
- e.timeoutErrorMessage && (nt = e.timeoutErrorMessage),
- s(createError(nt, e, ot.clarifyTimeoutError ? "ETIMEDOUT" : "ECONNABORTED", j)),
- j = null
- }
- ,
- utils$6.isStandardBrowserEnv()) {
- var rt = (e.withCredentials || isURLSameOrigin(et)) && e.xsrfCookieName ? cookies.read(e.xsrfCookieName) : void 0;
- rt && (d[e.xsrfHeaderName] = rt)
- }
- "setRequestHeader"in j && utils$6.forEach(d, function(nt, ot) {
- typeof c == "undefined" && ot.toLowerCase() === "content-type" ? delete d[ot] : j.setRequestHeader(ot, nt)
- }),
- utils$6.isUndefined(e.withCredentials) || (j.withCredentials = !!e.withCredentials),
- _ && _ !== "json" && (j.responseType = e.responseType),
- typeof e.onDownloadProgress == "function" && j.addEventListener("progress", e.onDownloadProgress),
- typeof e.onUploadProgress == "function" && j.upload && j.upload.addEventListener("progress", e.onUploadProgress),
- (e.cancelToken || e.signal) && (b = function(it) {
- !j || (s(!it || it && it.type ? new Cancel$2("canceled") : it),
- j.abort(),
- j = null)
- }
- ,
- e.cancelToken && e.cancelToken.subscribe(b),
- e.signal && (e.signal.aborted ? b() : e.signal.addEventListener("abort", b))),
- c || (c = null),
- j.send(c)
- }
- )
- }
- , utils$5 = utils$d
- , normalizeHeaderName = normalizeHeaderName$1
- , enhanceError = enhanceError$2
- , DEFAULT_CONTENT_TYPE = {
- "Content-Type": "application/x-www-form-urlencoded"
- };
- function setContentTypeIfUnset(a, e) {
- !utils$5.isUndefined(a) && utils$5.isUndefined(a["Content-Type"]) && (a["Content-Type"] = e)
- }
- function getDefaultAdapter() {
- var a;
- return (typeof XMLHttpRequest != "undefined" || typeof process != "undefined" && Object.prototype.toString.call(process) === "[object process]") && (a = xhr),
- a
- }
- function stringifySafely(a, e, i) {
- if (utils$5.isString(a))
- try {
- return (e || JSON.parse)(a),
- utils$5.trim(a)
- } catch (o) {
- if (o.name !== "SyntaxError")
- throw o
- }
- return (i || JSON.stringify)(a)
- }
- var defaults$3 = {
- transitional: {
- silentJSONParsing: !0,
- forcedJSONParsing: !0,
- clarifyTimeoutError: !1
- },
- adapter: getDefaultAdapter(),
- transformRequest: [function(e, i) {
- return normalizeHeaderName(i, "Accept"),
- normalizeHeaderName(i, "Content-Type"),
- 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"),
- e.toString()) : utils$5.isObject(e) || i && i["Content-Type"] === "application/json" ? (setContentTypeIfUnset(i, "application/json"),
- stringifySafely(e)) : e
- }
- ],
- transformResponse: [function(e) {
- var i = this.transitional || defaults$3.transitional
- , o = i && i.silentJSONParsing
- , s = i && i.forcedJSONParsing
- , c = !o && this.responseType === "json";
- if (c || s && utils$5.isString(e) && e.length)
- try {
- return JSON.parse(e)
- } catch (d) {
- if (c)
- throw d.name === "SyntaxError" ? enhanceError(d, this, "E_JSON_PARSE") : d
- }
- return e
- }
- ],
- timeout: 0,
- xsrfCookieName: "XSRF-TOKEN",
- xsrfHeaderName: "X-XSRF-TOKEN",
- maxContentLength: -1,
- maxBodyLength: -1,
- validateStatus: function(e) {
- return e >= 200 && e < 300
- },
- headers: {
- common: {
- Accept: "application/json, text/plain, */*"
- }
- }
- };
- utils$5.forEach(["delete", "get", "head"], function(e) {
- defaults$3.headers[e] = {}
- });
- utils$5.forEach(["post", "put", "patch"], function(e) {
- defaults$3.headers[e] = utils$5.merge(DEFAULT_CONTENT_TYPE)
- });
- var defaults_1 = defaults$3
- , utils$4 = utils$d
- , defaults$2 = defaults_1
- , transformData$1 = function(e, i, o) {
- var s = this || defaults$2;
- return utils$4.forEach(o, function(d) {
- e = d.call(s, e, i)
- }),
- e
- }
- , isCancel$1 = function(e) {
- return !!(e && e.__CANCEL__)
- }
- , utils$3 = utils$d
- , transformData = transformData$1
- , isCancel = isCancel$1
- , defaults$1 = defaults_1
- , Cancel$1 = Cancel_1;
- function throwIfCancellationRequested(a) {
- if (a.cancelToken && a.cancelToken.throwIfRequested(),
- a.signal && a.signal.aborted)
- throw new Cancel$1("canceled")
- }
- var dispatchRequest$1 = function(e) {
- throwIfCancellationRequested(e),
- e.headers = e.headers || {},
- e.data = transformData.call(e, e.data, e.headers, e.transformRequest),
- e.headers = utils$3.merge(e.headers.common || {}, e.headers[e.method] || {}, e.headers),
- utils$3.forEach(["delete", "get", "head", "post", "put", "patch", "common"], function(s) {
- delete e.headers[s]
- });
- var i = e.adapter || defaults$1.adapter;
- return i(e).then(function(s) {
- return throwIfCancellationRequested(e),
- s.data = transformData.call(e, s.data, s.headers, e.transformResponse),
- s
- }, function(s) {
- return isCancel(s) || (throwIfCancellationRequested(e),
- s && s.response && (s.response.data = transformData.call(e, s.response.data, s.response.headers, e.transformResponse))),
- Promise.reject(s)
- })
- }
- , utils$2 = utils$d
- , mergeConfig$2 = function(e, i) {
- i = i || {};
- var o = {};
- function s(j, $) {
- return utils$2.isPlainObject(j) && utils$2.isPlainObject($) ? utils$2.merge(j, $) : utils$2.isPlainObject($) ? utils$2.merge({}, $) : utils$2.isArray($) ? $.slice() : $
- }
- function c(j) {
- if (utils$2.isUndefined(i[j])) {
- if (!utils$2.isUndefined(e[j]))
- return s(void 0, e[j])
- } else
- return s(e[j], i[j])
- }
- function d(j) {
- if (!utils$2.isUndefined(i[j]))
- return s(void 0, i[j])
- }
- function _(j) {
- if (utils$2.isUndefined(i[j])) {
- if (!utils$2.isUndefined(e[j]))
- return s(void 0, e[j])
- } else
- return s(void 0, i[j])
- }
- function b(j) {
- if (j in i)
- return s(e[j], i[j]);
- if (j in e)
- return s(void 0, e[j])
- }
- var k = {
- url: d,
- method: d,
- data: d,
- baseURL: _,
- transformRequest: _,
- transformResponse: _,
- paramsSerializer: _,
- timeout: _,
- timeoutMessage: _,
- withCredentials: _,
- adapter: _,
- responseType: _,
- xsrfCookieName: _,
- xsrfHeaderName: _,
- onUploadProgress: _,
- onDownloadProgress: _,
- decompress: _,
- maxContentLength: _,
- maxBodyLength: _,
- transport: _,
- httpAgent: _,
- httpsAgent: _,
- cancelToken: _,
- socketPath: _,
- responseEncoding: _,
- validateStatus: b
- };
- return utils$2.forEach(Object.keys(e).concat(Object.keys(i)), function($) {
- var _e = k[$] || c
- , et = _e($);
- utils$2.isUndefined(et) && _e !== b || (o[$] = et)
- }),
- o
- }
- , data = {
- version: "0.24.0"
- }
- , VERSION = data.version
- , validators$1 = {};
- ["object", "boolean", "number", "function", "string", "symbol"].forEach(function(a, e) {
- validators$1[a] = function(o) {
- return typeof o === a || "a" + (e < 1 ? "n " : " ") + a
- }
- });
- var deprecatedWarnings = {};
- validators$1.transitional = function(e, i, o) {
- function s(c, d) {
- return "[Axios v" + VERSION + "] Transitional option '" + c + "'" + d + (o ? ". " + o : "")
- }
- return function(c, d, _) {
- if (e === !1)
- throw new Error(s(d, " has been removed" + (i ? " in " + i : "")));
- return i && !deprecatedWarnings[d] && (deprecatedWarnings[d] = !0,
- console.warn(s(d, " has been deprecated since v" + i + " and will be removed in the near future"))),
- e ? e(c, d, _) : !0
- }
- }
- ;
- function assertOptions(a, e, i) {
- if (typeof a != "object")
- throw new TypeError("options must be an object");
- for (var o = Object.keys(a), s = o.length; s-- > 0; ) {
- var c = o[s]
- , d = e[c];
- if (d) {
- var _ = a[c]
- , b = _ === void 0 || d(_, c, a);
- if (b !== !0)
- throw new TypeError("option " + c + " must be " + b);
- continue
- }
- if (i !== !0)
- throw Error("Unknown option " + c)
- }
- }
- var validator$1 = {
- assertOptions,
- validators: validators$1
- }
- , utils$1 = utils$d
- , buildURL = buildURL$2
- , InterceptorManager = InterceptorManager_1
- , dispatchRequest = dispatchRequest$1
- , mergeConfig$1 = mergeConfig$2
- , validator = validator$1
- , validators = validator.validators;
- function Axios$1(a) {
- this.defaults = a,
- this.interceptors = {
- request: new InterceptorManager,
- response: new InterceptorManager
- }
- }
- Axios$1.prototype.request = function(e) {
- typeof e == "string" ? (e = arguments[1] || {},
- e.url = arguments[0]) : e = e || {},
- e = mergeConfig$1(this.defaults, e),
- e.method ? e.method = e.method.toLowerCase() : this.defaults.method ? e.method = this.defaults.method.toLowerCase() : e.method = "get";
- var i = e.transitional;
- i !== void 0 && validator.assertOptions(i, {
- silentJSONParsing: validators.transitional(validators.boolean),
- forcedJSONParsing: validators.transitional(validators.boolean),
- clarifyTimeoutError: validators.transitional(validators.boolean)
- }, !1);
- var o = []
- , s = !0;
- this.interceptors.request.forEach(function(_e) {
- typeof _e.runWhen == "function" && _e.runWhen(e) === !1 || (s = s && _e.synchronous,
- o.unshift(_e.fulfilled, _e.rejected))
- });
- var c = [];
- this.interceptors.response.forEach(function(_e) {
- c.push(_e.fulfilled, _e.rejected)
- });
- var d;
- if (!s) {
- var _ = [dispatchRequest, void 0];
- for (Array.prototype.unshift.apply(_, o),
- _ = _.concat(c),
- d = Promise.resolve(e); _.length; )
- d = d.then(_.shift(), _.shift());
- return d
- }
- for (var b = e; o.length; ) {
- var k = o.shift()
- , j = o.shift();
- try {
- b = k(b)
- } catch ($) {
- j($);
- break
- }
- }
- try {
- d = dispatchRequest(b)
- } catch ($) {
- return Promise.reject($)
- }
- for (; c.length; )
- d = d.then(c.shift(), c.shift());
- return d
- }
- ;
- Axios$1.prototype.getUri = function(e) {
- return e = mergeConfig$1(this.defaults, e),
- buildURL(e.url, e.params, e.paramsSerializer).replace(/^\?/, "")
- }
- ;
- utils$1.forEach(["delete", "get", "head", "options"], function(e) {
- Axios$1.prototype[e] = function(i, o) {
- return this.request(mergeConfig$1(o || {}, {
- method: e,
- url: i,
- data: (o || {}).data
- }))
- }
- });
- utils$1.forEach(["post", "put", "patch"], function(e) {
- Axios$1.prototype[e] = function(i, o, s) {
- return this.request(mergeConfig$1(s || {}, {
- method: e,
- url: i,
- data: o
- }))
- }
- });
- var Axios_1 = Axios$1
- , Cancel = Cancel_1;
- function CancelToken(a) {
- if (typeof a != "function")
- throw new TypeError("executor must be a function.");
- var e;
- this.promise = new Promise(function(s) {
- e = s
- }
- );
- var i = this;
- this.promise.then(function(o) {
- if (!!i._listeners) {
- var s, c = i._listeners.length;
- for (s = 0; s < c; s++)
- i._listeners[s](o);
- i._listeners = null
- }
- }),
- this.promise.then = function(o) {
- var s, c = new Promise(function(d) {
- i.subscribe(d),
- s = d
- }
- ).then(o);
- return c.cancel = function() {
- i.unsubscribe(s)
- }
- ,
- c
- }
- ,
- a(function(s) {
- i.reason || (i.reason = new Cancel(s),
- e(i.reason))
- })
- }
- CancelToken.prototype.throwIfRequested = function() {
- if (this.reason)
- throw this.reason
- }
- ;
- CancelToken.prototype.subscribe = function(e) {
- if (this.reason) {
- e(this.reason);
- return
- }
- this._listeners ? this._listeners.push(e) : this._listeners = [e]
- }
- ;
- CancelToken.prototype.unsubscribe = function(e) {
- if (!!this._listeners) {
- var i = this._listeners.indexOf(e);
- i !== -1 && this._listeners.splice(i, 1)
- }
- }
- ;
- CancelToken.source = function() {
- var e, i = new CancelToken(function(s) {
- e = s
- }
- );
- return {
- token: i,
- cancel: e
- }
- }
- ;
- var CancelToken_1 = CancelToken
- , spread = function(e) {
- return function(o) {
- return e.apply(null, o)
- }
- }
- , isAxiosError = function(e) {
- return typeof e == "object" && e.isAxiosError === !0
- }
- , utils = utils$d
- , bind = bind$2
- , Axios = Axios_1
- , mergeConfig = mergeConfig$2
- , defaults = defaults_1;
- function createInstance(a) {
- var e = new Axios(a)
- , i = bind(Axios.prototype.request, e);
- return utils.extend(i, Axios.prototype, e),
- utils.extend(i, e),
- i.create = function(s) {
- return createInstance(mergeConfig(a, s))
- }
- ,
- i
- }
- var axios$1 = createInstance(defaults);
- axios$1.Axios = Axios;
- axios$1.Cancel = Cancel_1;
- axios$1.CancelToken = CancelToken_1;
- axios$1.isCancel = isCancel$1;
- axios$1.VERSION = data.version;
- axios$1.all = function(e) {
- return Promise.all(e)
- }
- ;
- axios$1.spread = spread;
- axios$1.isAxiosError = isAxiosError;
- axios$2.exports = axios$1;
- axios$2.exports.default = axios$1;
- var axios = axios$2.exports;
- const isFunction = a=>typeof a == "function";
- class AxiosCanceler {
- constructor() {
- Tt(this, "pendingMap", new Map)
- }
- addPending(e) {
- return new axios.CancelToken(i=>{
- this.pendingMap.has(e) || this.pendingMap.set(e, i)
- }
- )
- }
- removeAllPending() {
- this.pendingMap.forEach(e=>{
- e && isFunction(e) && e()
- }
- ),
- this.pendingMap.clear()
- }
- removePending(e) {
- if (this.pendingMap.has(e)) {
- const i = this.pendingMap.get(e);
- i && i(e),
- this.pendingMap.delete(e)
- }
- }
- removeCancelToken(e) {
- this.pendingMap.has(e) && this.pendingMap.delete(e)
- }
- reset() {
- this.pendingMap = new Map
- }
- }
- const log$p = new Logger("http");
- class Http$1 {
- constructor() {
- Tt(this, "instatnce");
- Tt(this, "canceler");
- Tt(this, "requestParams", e=>$t({}, e.params));
- Tt(this, "requestConstant", ()=>({
- x_nounce: this.randomString(),
- x_timestamp: new Date().getTime(),
- x_os: "web"
- }));
- this.instatnce = axios.create(),
- this.canceler = new AxiosCanceler
- }
- get(e) {
- return this.request(Zt($t({}, e), {
- method: "GET"
- }))
- }
- post(e) {
- return this.request(Zt($t({}, e), {
- method: "POST"
- }))
- }
- request(e) {
- const {url: i, timeout: o=1e4, method: s, key: c, beforeRequest: d, responseType: _, data: b} = e;
- let {retry: k=0} = e;
- const j = this.transformUrlHook(i)
- , $ = this.canceler.addPending(i);
- d && isFunction(d) && d(e);
- const _e = this.requestParams(e);
- let et = {
- url: j,
- method: s,
- timeout: o,
- cancelToken: $,
- responseType: _,
- params: _e
- };
- s === "POST" && (et = $t({
- data: b
- }, et));
- const tt = Date.now()
- , rt = ()=>this.instatnce.request(et).then(it=>(c && log$p.infoAndReportMeasurement({
- metric: "http",
- startTime: tt,
- extra: i,
- group: "http",
- tag: c
- }),
- this.canceler.removeCancelToken(i),
- it)).catch(it=>{
- const nt = axios.isCancel(it);
- return k > 0 && !nt ? (k--,
- log$p.warn(`request ${i} retry, left retry count`, k),
- rt()) : (log$p.infoAndReportMeasurement({
- metric: "http",
- startTime: tt,
- error: it,
- extra: {
- url: i,
- isCanceled: nt
- },
- tag: c,
- group: "http"
- }),
- this.canceler.removeCancelToken(i),
- Promise.reject(it))
- }
- );
- return rt()
- }
- transformUrlHook(e) {
- return e
- }
- randomString() {
- let e = "";
- const i = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
- , o = i.length;
- for (let s = 0; s < 8; s++)
- e += i.charAt(Math.floor(Math.random() * o));
- return e
- }
- }
- const http$1 = new Http$1
- , log$o = new Logger("AssetsStorage");
- class AssetsStorage {
- static async readOrRequest(e, i) {
- let o = null;
- try {
- o = await modelTable.query("url", e)
- } catch (c) {
- return log$o.debug(c),
- log$o.warn("cache query error", e),
- Promise.resolve(e)
- }
- let s = o && o.model;
- return s || (s = await this.requestAndPut({
- url: e,
- responseType: "blob",
- retry: 2
- })),
- typeof s == "string" && (s = this.dataURItoBlob(s)),
- i && i.returnBlob ? s : URL.createObjectURL(s)
- }
- static async requestAndPut(e) {
- try {
- const i = await http$1.get(e);
- return await modelTable.put({
- url: e.url,
- model: i.data
- }),
- i.data
- } catch {
- return Promise.reject(new InternalError("request and put error"))
- }
- }
- }
- Tt(AssetsStorage, "dataURItoBlob", e=>{
- let i;
- e.split(",")[0].indexOf("base64") >= 0 ? i = atob(e.split(",")[1]) : i = unescape(e.split(",")[1]);
- const o = e.split(",")[0].split(":")[1].split(";")[0]
- , s = new Uint8Array(i.length);
- for (let d = 0; d < i.length; d++)
- s[d] = i.charCodeAt(d);
- return new Blob([s],{
- type: o
- })
- }
- );
- const fr = class {
- static _GetStorage() {
- try {
- return localStorage.setItem("test", ""),
- localStorage.removeItem("test"),
- localStorage
- } catch {
- const e = {};
- return {
- getItem: i=>{
- const o = e[i];
- return o === void 0 ? null : o
- }
- ,
- setItem: (i,o)=>{
- e[i] = o
- }
- }
- }
- }
- static ReadString(e, i) {
- const o = this._Storage.getItem(e);
- return o !== null ? o : i
- }
- static WriteString(e, i) {
- this._Storage.setItem(e, i)
- }
- static ReadBoolean(e, i) {
- const o = this._Storage.getItem(e);
- return o !== null ? o === "true" : i
- }
- static WriteBoolean(e, i) {
- this._Storage.setItem(e, i ? "true" : "false")
- }
- static ReadNumber(e, i) {
- const o = this._Storage.getItem(e);
- return o !== null ? parseFloat(o) : i
- }
- static WriteNumber(e, i) {
- this._Storage.setItem(e, i.toString())
- }
- }
- ;
- let DataStorage = fr;
- Tt(DataStorage, "_Storage", fr._GetStorage());
- const urlMap = new Map
- , urlTransformer = async(a,e=!1)=>typeof a != "string" ? (console.warn("url transformer error", a),
- a) : a.startsWith("blob:") ? a : e ? AssetsStorage.readOrRequest(a, {
- returnBlob: !0
- }) : urlMap.has(a) ? urlMap.get(a) : AssetsStorage.readOrRequest(a).then(i=>(urlMap.set(a, i),
- i));
- var workerSourceCode = `onmessage = function (event) {
- const data = event.data
- if (!data) return
- if (data.type === 'start') {
- const startTime = Date.now()
- const request = new XMLHttpRequest()
- request.open('GET', data.url)
- try {
- request.send()
- } catch (error) {
- console.error(error)
- }
- request.addEventListener('readystatechange', () => {
- if (request.readyState == 4) {
- if (request.status == 200) {
- postMessage(Date.now() - startTime)
- }
- }
- })
- }
- }
- `;
- const log$n = new Logger("detect");
- let worker = null;
- function checkNetworkQuality(a) {
- if (!a)
- return;
- const e = Date.now();
- if (pingOthers("https://www.baidu.com", function(i, o) {
- log$n.infoAndReportMeasurement({
- metric: "baiduRtt",
- group: "http",
- value: o,
- startTime: e
- })
- }),
- !worker) {
- const i = new Blob([workerSourceCode],{
- type: "application/javascript"
- });
- worker = new Worker(URL.createObjectURL(i)),
- worker.onmessage = function(o) {
- log$n.infoAndReportMeasurement({
- metric: "workerRtt",
- group: "http",
- startTime: e,
- value: o.data
- })
- }
- }
- }
- function pingOthers(a, e) {
- let i = !1;
- const o = new Image;
- o.onload = c,
- o.onerror = d;
- const s = Date.now();
- function c(b) {
- i = !0,
- _()
- }
- function d(b) {}
- function _() {
- const b = Date.now() - s;
- if (typeof e == "function")
- return i ? e(null, b) : (console.error("error loading resource"),
- e("error", b))
- }
- o.src = a + "/favicon.ico?" + +new Date
- }
- const log$m = new Logger("heartbeat");
- class Heartbeat {
- constructor(e) {
- Tt(this, "_interval", null);
- Tt(this, "ping", ()=>{
- const e = Date.now().toString();
- this.handler.ping(e)
- }
- );
- this.handler = e
- }
- start() {
- this.stop(),
- log$m.debug(`Setting ping interval to ${PING_INTERVAL_MS}ms`),
- this._interval = window.setInterval(this.ping, PING_INTERVAL_MS)
- }
- stop() {
- log$m.debug("stop heartbeat"),
- this._interval && window.clearInterval(this._interval)
- }
- pong(e, i) {
- !e || typeof e == "string" && this.handler.pong(Date.now() - Number(e), i)
- }
- }
- class NetworkMonitor {
- constructor(e) {
- Tt(this, "_listener");
- this._listener = e
- }
- get isOnline() {
- const e = window.navigator;
- return typeof e.onLine == "boolean" ? e.onLine : !0
- }
- start() {
- window.addEventListener("online", this._listener),
- window.addEventListener("offline", this._listener)
- }
- stop() {
- window.removeEventListener("online", this._listener),
- window.removeEventListener("offline", this._listener)
- }
- }
- function VisibilityChangeHandler() {
- this.subscribers = [],
- this.bindFunc = void 0,
- this.id = 1,
- this.addListener()
- }
- VisibilityChangeHandler.prototype = {
- subscribe(a) {
- if (!a)
- return;
- const e = ++this.id
- , i = {
- id: e,
- handler: a
- };
- return this.subscribers.push(i),
- ()=>{
- this.subscribers = this.subscribers.filter(s=>s.id == e)
- }
- },
- destroy() {
- !this.bindFunc || (document.hidden !== void 0 ? document.removeEventListener("visibilitychange", this.bindFunc, !1) : document.webkitHidden && document.removeEventListener("webkitvisibilitychange", this.bindFunc, !1))
- },
- broadcast(a) {
- this.subscribers.forEach(e=>e.handler(a))
- },
- addListener() {
- document.hidden !== void 0 ? (this.bindFunc = ()=>this.broadcast(document.hidden),
- document.addEventListener("visibilitychange", this.bindFunc, !1)) : document.webkitHidden && (this.bindFunc = ()=>this.broadcast(document.webkitHidden),
- document.addEventListener("webkitvisibilitychange", this.bindFunc, !1))
- }
- };
- const WASM_Version = "h264"
- , DECODER_VERSION = "v0.9.3"
- , WASM_URLS = {
- h264: "https://static.xverse.cn/wasm/v17/lib_ff264dec.js",
- xv265: "https://static.xverse.cn/wasm/codec-release/h265-dec-sw-wasm/v-0-9-1/libxv265dec.js",
- h265: ""
- }
- , STUCK_STAGE_GOOD = 45
- , STUCK_STAGE_WELL = 85
- , STUCK_STAGE_FAIR = 125
- , STUCK_STAGE_BAD = 165
- , DECODER_PASSIVE_JITTER = 0;
- function add(a, e) {
- return e == -1 && (e = 0),
- a + e
- }
- function count_valid(a, e) {
- let i = 0;
- return e != -1 && (i = 1),
- a + i
- }
- function count_less(a, e) {
- function i(o, s) {
- let c = 0;
- return s != -1 && s < e && (c = 1),
- o + c
- }
- return a.reduce(i, 0)
- }
- function count_sd(a, e) {
- function i(o, s) {
- let c = 0;
- return s == -1 ? c = 0 : c = (s - e) * (s - e),
- o + c
- }
- return Math.sqrt(a.reduce(i, 0) / a.reduce(count_valid, 0)) || 0
- }
- function max(a, e) {
- return Math.max(a, e)
- }
- class CircularArray {
- constructor(e, i, o) {
- this.sum = 0,
- this.incomingSum = 0,
- this.count = 0,
- this.incomingCount = 0,
- this.max = 0,
- this.incomingMax = 0,
- this.goodLess = 0,
- this.wellLess = 0,
- this.fairLess = 0,
- this.badLess = 0,
- this.countLess = !1,
- this.lessThreshes = [],
- this.incomingData = [],
- this.circularData = Array(e).fill(-1),
- this.circularPtr = 0,
- this.circularLength = e,
- i && (this.countLess = !0,
- this.lessThreshes = o)
- }
- add(e) {
- e < 0 || (this.circularData[this.circularPtr] != -1 ? (this.sum -= this.circularData[this.circularPtr],
- Math.abs(this.circularData[this.circularPtr] - this.max) < .01 && (this.circularData[this.circularPtr] = -1,
- this.max = this.computeMax(this.circularData))) : this.count += 1,
- this.sum += e,
- this.incomingSum += e,
- this.incomingCount += 1,
- this.max < e && (this.max = e),
- this.incomingMax < e && (this.incomingMax = e),
- this.circularData[this.circularPtr] = e,
- this.circularPtr = (this.circularPtr + 1) % this.circularLength,
- this.incomingData.push(e),
- this.incomingData.length > this.circularLength && (this.clearIncoming(),
- this.incomingCount = 0,
- this.incomingSum = 0))
- }
- computeAvg(e) {
- return e.reduce(add, 0) / e.reduce(count_valid, 0) || 0
- }
- computeMax(e) {
- return e.reduce(max, 0) || 0
- }
- computeThreshPercent(e) {
- if (this.countLess) {
- const i = count_less(e, this.lessThreshes[0]) || 0
- , o = count_less(e, this.lessThreshes[1]) || 0
- , s = count_less(e, this.lessThreshes[2]) || 0
- , c = count_less(e, this.lessThreshes[3]) || 0
- , d = e.reduce(count_valid, 0);
- return [i, o, s, c, d]
- } else
- return [0, 0, 0, 0, 0]
- }
- getAvg() {
- return this.sum / this.count || 0 || 0
- }
- getMax(e=!0) {
- return this.max || 0
- }
- getStandardDeviation() {
- return count_sd(this.circularData, this.getAvg())
- }
- getThreshPercent() {
- return this.computeThreshPercent(this.circularData)
- }
- getIncomingMax() {
- return this.computeMax(this.incomingData) || 0
- }
- getIncomingAvg() {
- return this.computeAvg(this.incomingData) || 0
- }
- getIncomingStandardDeviation() {
- return count_sd(this.incomingData, this.getIncomingAvg())
- }
- getIncomingThreshPercent() {
- return this.computeThreshPercent(this.incomingData)
- }
- clearFastComputeItem() {
- this.sum = 0,
- this.incomingSum = 0,
- this.count = 0,
- this.incomingCount = 0,
- this.max = 0,
- this.incomingMax = 0,
- this.goodLess = 0,
- this.wellLess = 0,
- this.fairLess = 0,
- this.badLess = 0
- }
- clearIncoming() {
- for (; this.incomingData.length > 0; )
- this.incomingData.pop()
- }
- clear() {
- this.circularData.fill(-1),
- this.circularPtr = 0,
- this.clearFastComputeItem(),
- this.clearIncoming()
- }
- }
- class SecondArray {
- constructor() {
- this.circularData = []
- }
- add(e) {
- this.circularData.push(e)
- }
- getAvg() {
- let e = 0;
- for (let i = 0; i < this.circularData.length; i++)
- e += this.circularData[i];
- return {
- sum: e,
- avg: e / this.circularData.length || 0
- }
- }
- getMax() {
- let e = 0;
- for (let i = 0; i < this.circularData.length; i++)
- e < this.circularData[i] && (e = this.circularData[i]);
- return e || 0
- }
- clear() {
- this.circularData = []
- }
- getStat() {
- const e = this.getAvg()
- , i = {
- sum: e.sum,
- avg: e.avg,
- max: this.getMax()
- };
- return this.clear(),
- i
- }
- }
- var decoder = `/* eslint-disable no-inner-declarations */
- /* eslint-disable default-case */
- /* eslint-disable no-restricted-globals */
- // import { arrayBuffer } from "stream/consumers"
- // import { addSyntheticLeadingComment, textChangeRangeIsUnchanged } from "typescript"
- /* eslint-disable no-undef */
- const CACHE_BUF_LENGTH = 16
- const YUV_BUF_LENGTH = 16
- if ('function' === typeof importScripts) {
- const startTime = Date.now()
- // self.importScripts('https://static.xverse.cn/wasm/zx_test_exclusive/v2/libxv265dec.js')
- // printConsole.log('Decoder update time is 2021/10/14 12:13 ')
- const YUVArray = []
- const mediaArray = []
- let IframesReceived = 0
- let IframesDecoded = 0
- let lastReceivePts = 0
- let lastProcessPts = 0
- let framesReturned = 0
- let send_out_buffer = 0
- let lastPoc = 0
- let cachedFirstFrame = undefined
- let cachedPanoramaFirstFrame = undefined
- const printConsole = {
- log: (msg) => self.postMessage({ t: MessageEvent.ConsoleLog, printMsg: msg }),
- error: (msg, code) => self.postMessage({ t: MessageEvent.ConsoleError, printMsg: msg, code: code }),
- }
- const MessageEvent = {
- DecodeMessage: 0,
- UpdateStats: 1,
- WASMReady: 2,
- CacheFrame: 3,
- RecordVideo: 4,
- OnlyEmitSignal: 5,
- WASMReadyCost: 6,
- PanoramaMessage: 7,
- RequestIFrame: 8,
- ConsoleLog: 9,
- ConsoleError: 10,
- }
- let lastReceiveContentPts = 0
- let saveMediaBytes = 0 // Just for test use
- const IFrameCacheBuffer = {}
- for (var i = 0; i < CACHE_BUF_LENGTH; ++i) {
- mediaArray.push({
- pts: -1,
- receive_ts: 0,
- decode_ts: 0,
- yuv_ts: 0,
- render_ts: 0,
- media: null,
- meta: null,
- isIDR: false,
- })
- }
- let downloadBlob = (data, fileName, mimeType) => {
- const blob = new Blob([data], {
- type: mimeType,
- })
- const url = URL.createObjectURL(blob)
- self.postMessage({ t: MessageEvent.RecordVideo, fileObj: blob, link: url })
- //downloadURL(url, fileName)
- setTimeout(function () {
- return URL.revokeObjectURL(url)
- }, 3000)
- }
- function Decoder() {
- this.expected_frameCnt = 1
- this.inited = false
- this.wasminited = false
- this.cacheMap = new Map()
- this.receivedMedia = 0
- this.receivedFrame = 0
- this.receivedYUV = 0
- this.receivedEmit = 0
- this.lastReceivedEmit = 0
- this.mediaBytesReceived = 0
- this.metaBytesReceived = 0
- this.prevSeq = 0
- this.packetsLost = 0
- this.packetsDrop = 0
- this.dtpf = 0
- this.dtmf = 0
- this.getFrameInterval = 10
- this.jumpI = false
- this.startEmit = false
- this.JankTimes = 0
- this.bigJankTimes = 0
- this.mediaCacheBuffer = new Uint8Array(1024 * 1024 * 10) // 10MB for video recording
- this.errorCacheBuffer = new Uint8Array(1024 * 1024 * 10) // 10MB for error stream recording
- this.mediaCacheSize = 0
- this.errorCacheSize = 0
- this.startRecord = false
- this.saveRecord = false
- this.requestingIFrame = false
- this.decoderId = 0 // 0 for 720p, 1 for 480p.
- this.DecodablePts = 0
- this.BlockedFrames = []
- this.decodeTimeCircular = Array(120).fill(-1)
- this.dtcPtr = 0
- this.readPtr = 1
- this.writePtr = 1
- this.cntBufInc = 0
- this.prevBufNum = 0
- this.MAX_TRY_TO_DEC_BUFNUM = 3
- this.skipFrameUntilI = true
- this.enable_logging = false
- this.framesReceivedBetweenTimerInterval = 0
- this.maxFramesReceivedBetweenTimerInterval = 0
- this.isFirstFrame = 1
- this.consumerPrevPts = -1
- this.consumerCurrPts = -1
- this.consumerWaitingIDR = false
- this.lastObj = null
- this.bufferIFrame = 0
- this.passiveJitterLength = 0
- }
- //refactor:
- Decoder.prototype.isBufEmpty = function () {
- return this.readPtr == this.writePtr
- }
- Decoder.prototype.isBufFull = function () {
- return (this.writePtr + 1) % CACHE_BUF_LENGTH == this.readPtr
- }
- Decoder.prototype.getNumOfPktToBeDec = function () {
- return (this.writePtr + CACHE_BUF_LENGTH - this.readPtr) % CACHE_BUF_LENGTH
- }
- Decoder.prototype.getNumOfEmptySlot = function () {
- return CACHE_BUF_LENGTH - this.getNumOfPktToBeDec() - 1
- }
- Decoder.prototype.aheadof = function (a, b) {
- return (a - b + 65536) % 65536 > 65536 / 2
- }
- Decoder.prototype.distance = function (a, b) {
- var res
- if (this.aheadof(a, b)) {
- res = this.seqDiff(b, a, 65536)
- } else {
- res = this.seqDiff(a, b, 65536)
- }
- return res
- }
- Decoder.prototype.isSeqJump = function (a, b) {
- return this.distance(a, b) >= CACHE_BUF_LENGTH - 1
- }
- Decoder.prototype.seqDiff = function (a, b, mod) {
- return (a + mod - b) % mod
- }
- //notice: n could be nagative
- Decoder.prototype.seqAdd = function (seq, n, mod) {
- return (seq + mod + n) % mod
- }
- //end refactor
- Decoder.prototype.resetDecoder = function () {
- this.isFirstFrame = 1
- this.expected_frameCnt = 1
- this.receivedMedia = 0
- this.receivedYUV = 0
- this.receivedEmit = 0
- this.lastReceivedEmit = 0
- this.mediaBytesReceived = 0
- this.metaBytesReceived = 0
- this.prevSeq = 0
- this.packetsLost = 0
- this.packetsDrop = 0
- this.dtpf = 0
- this.dtmf = 0
- this.JankTimes = 0
- this.bigJankTimes = 0
- this.getFrameInterval = 10
- this.jumpI = false
- IframesReceived = 0
- IframesDecoded = 0
- lastReceivePts = 0
- lastProcessPts = 0
- lastReceiveContentPts = 0
- this.requestingIFrame = false
- this.DecodablePts = 0
- this.BlockedFrames = []
- this.decodeTimeCircular.fill(-1)
- this.dtcPtr = 0
- for (var i = 0; i < CACHE_BUF_LENGTH; ++i) {
- mediaArray[i].media = null
- mediaArray[i].meta = null
- mediaArray[i] = {
- pts: -1,
- receive_ts: 0,
- decode_ts: 0,
- yuv_ts: 0,
- render_ts: 0,
- media: null,
- meta: null,
- isIDR: false,
- }
- }
- //refactor:
- this.readPtr = this.writePtr = 1
- this.cntBufInc = 0
- this.prevBufNum = 0
- this.MAX_TRY_TO_DEC_BUFNUM = 3
- this.skipFrameUntilI = true
- this.consumerPrevPts = -1
- this.consumerCurrPts = -1
- this.consumerWaitingIDR = false
- this.lastObj = null
- this.bufferIFrame = 0
- //end refactor
- }
- //refactor:
- Decoder.prototype.changeLogSwitch = function (status) {
- this.enable_logging = status
- }
- const MAX_LOG_NUM = 128
- logBufQueue = []
- Decoder.prototype.dumpLogBuf = function () {
- while (logBufQueue.length > 0) {
- console.log(logBufQueue.shift())
- }
- }
- Decoder.prototype.dumpJitterBufInfo = function (label, pts = -1) {
- // if (!this.enable_logging) {
- // return
- // }
- logInfo =
- 'WritePtr: ' +
- this.writePtr +
- ', ReadPtr: ' +
- this.readPtr +
- '\\n' +
- ', Producer Prev/Curr: ' +
- this.prevSeq +
- '/' +
- pts +
- '\\n' +
- ', Consumer Prev/Curr: ' +
- this.consumerPrevPts +
- '/' +
- this.consumerCurrPts +
- '\\n' +
- 'awaitingBuf: ' +
- this.getNumOfPktToBeDec() +
- ', emptySlotNum: ' +
- this.getNumOfEmptySlot() +
- ', skipFrameUntilI: ' +
- this.skipFrameUntilI +
- '\\n' +
- ' framesReceivedBetweenTimerInterval: ' +
- this.framesReceivedBetweenTimerInterval +
- ', maxFramesReceivedBetweenTimerInterval: ' +
- this.maxFramesReceivedBetweenTimerInterval +
- '\\n' +
- ' label: ' +
- label +
- '\\n'
- if (pts != -1) {
- logInfo += ' this.notEnoughSlots(' + pts + '): ' + this.notEnoughSlots(pts) + '\\n'
- }
- if (this.enable_logging) {
- console.log(logInfo)
- } else {
- logBufQueue.push(logInfo)
- if (logBufQueue.length > MAX_LOG_NUM) {
- logBufQueue.shift()
- }
- }
- }
- Decoder.prototype.resetBufItem = function (index) {
- mediaArray[index].media = null
- mediaArray[index].meta = null
- if (mediaArray[index].isIDR == true) {
- this.bufferIFrame -= 1
- }
- mediaArray[index] = {
- pts: -1,
- receive_ts: 0,
- decode_ts: 0,
- yuv_ts: 0,
- render_ts: 0,
- media: null,
- meta: null,
- isIDR: false,
- }
- this.readPtr = this.seqAdd(this.readPtr, 1, CACHE_BUF_LENGTH)
- }
- Decoder.prototype.checkPktOrderInConsumer = function (index) {
- if (this.consumerPrevPts == -1) {
- if (!this.isSlotEmpty(index)) {
- this.consumerPrevPts = mediaArray[index].pts
- }
- return true
- }
- if (this.isSlotEmpty(index)) {
- //lost
- // debugger
- // console.log("[xmedia] return on SLOT EMPTY, prev: %s", prev)
- this.consumerWaitingIDR = true
- this.consumerPrevPts = this.seqAdd(this.consumerPrevPts, 1, 65536)
- return true
- }
- if (!this.slotHasMedia(index)) {
- // pure meta
- // debugger
- // console.log("[xmedia] return on meta, prev: %s, cur: %s", this., mediaArray[index].pts)
- this.consumerPrevPts = mediaArray[index].pts
- return true
- }
- this.consumerCurrPts = mediaArray[index].pts
- if (this.consumerWaitingIDR || this.seqDiff(this.consumerCurrPts, this.consumerPrevPts, 65536) != 1) {
- // if (!mediaArray[index].isIDR && mediaArray[index].media.byteLength!=0) {
- if (this.isPFrame(mediaArray[index].isIDR, mediaArray[index].media.byteLength)) {
- console.error('[INFO][XMEDIA] optimize to further reduce clutter chance. copy console log to developer')
- this.dumpLogBuf()
- this.dumpJitterBufInfo('go away.')
- // debugger
- this.consumerPrevPts = -1
- // this.resetDecoder()
- return false
- }
- }
- // console.log("[xmedia] return finally, prev: %s, cur: %s", prev, cur)
- this.consumerPrevPts = this.consumerCurrPts
- this.consumerWaitingIDR = false
- return true
- }
- Decoder.prototype.slotHasMedia = function (index) {
- return mediaArray[index].media != null && mediaArray[index].media.byteLength != 0
- }
- Decoder.prototype.slotHasContent = function (index) {
- return mediaArray[index].media != null && mediaArray[index].meta != null && mediaArray[index].pts != -1
- }
- Decoder.prototype.procBufItem = function (index) {
- this.dumpJitterBufInfo('Entering Decoder.prototype.procBufItem')
- // console.log('[][Core][WASM], pts: %s, isIDR: %s, length: %s', mediaArray[index].pts, mediaArray[index].isIDR, mediaArray[index].media.length)
- // var loginfo = 'pts: %s, isIDR: %s, length: %s', mediaArray[index].pts, mediaArray[index].isIDR, mediaArray[index].media.length
- needToSkip = this.skipFrameUntilI && !mediaArray[index].isIDR
- var loginfo =
- 'pts: ' +
- mediaArray[index].pts +
- ', isidr: ' +
- mediaArray[index].isIDR +
- ', slotHasMedia: ' +
- this.slotHasMedia(index) +
- ', slotHasMeta: ' +
- (mediaArray[index].meta != null) +
- ', needToSkip: ' +
- needToSkip
- if (this.slotHasContent(index) && !needToSkip) {
- // console.log("[xmedia] %s ------------ 001", mediaArray[index].pts)
- let objData = {
- media: mediaArray[index].media,
- frameCnt: mediaArray[index].pts,
- meta: mediaArray[index].meta,
- metadata: mediaArray[index].metadata,
- isIDR: mediaArray[index].isIDR,
- }
- // -------------------
- if (this.checkPktOrderInConsumer(index)) {
- // console.log("[xmedia] %s ------------ 002", mediaArray[index].pts)
- this.decodeFrame(objData)
- }
- if (mediaArray[index].isIDR) {
- // console.log("[xmedia] %s ------------ 003", mediaArray[index].pts)
- // console.log("mediaArray[index].isIDR: this.skipFrameUntilI = false")
- this.skipFrameUntilI = false
- }
- } else {
- // console.log("[xmedia] %s ------------ 004", mediaArray[index].pts)
- if (this.slotHasMedia(index)) {
- // console.log("[xmedia] %s ------------ 005", mediaArray[index].pts)
- //need to skip, waiting I Frame
- //dropCache++
- this.dropPkt += 1
- // MARKER META1META2
- // self.postMessage({ t: MessageEvent.OnlyEmitSignal, meta_only: true, meta: mediaArray[index].meta, metadata: mediaArray[index].metadata })
- } else {
- // console.log("[xmedia] %s ------------ 006", mediaArray[index].pts)
- // no media
- if (mediaArray[index].meta != null) {
- this.checkPktOrderInConsumer(index)
- // console.log("[xmedia] %s ------------ 007", mediaArray[index].pts)
- // Still frame
- // console.log('[send signal]', mediaArray[index].pts)
- self.postMessage({
- t: MessageEvent.OnlyEmitSignal,
- meta_only: true,
- meta: mediaArray[index].meta,
- metadata: mediaArray[index].metadata,
- })
- } else {
- // console.log("[xmedia] %s ------------ 008", mediaArray[index].pts)
- // Lost_rcv++
- // console.log("lost_rcv++: this.skipFrameUntilI = true")
- // console.info('[xmedia] FFFFF This code should not be executed!!!!')
- console.info('[xmedia] null pkt sneaked into profBufItem without harm')
- this.skipFrameUntilI = true
- }
- }
- }
- this.dumpJitterBufInfo('Leaving Decoder.prototype.procBufItem, ' + loginfo)
- this.lastObj = mediaArray[index]
- this.resetBufItem(index)
- }
- Decoder.prototype.flushBuffer = function (untilIDR) {
- this.dumpJitterBufInfo('Entering Decoder.prototype.flushBuffer')
- this.skipFrameUntilI = true
- var breakWhenIDR = false
- while (this.getNumOfPktToBeDec() > 0) {
- index = this.readPtr
- if (this.slotHasMedia(index)) {
- // dropMedia until IDR // \u6765\u4E0D\u53CA\u89E3\u7801\u4E22\u5E27
- this.packetsDrop += 1
- if (untilIDR) {
- if (mediaArray[index].isIDR == true) {
- breakWhenIDR = true
- break
- }
- }
- } else if (mediaArray[index].meta != null) {
- self.postMessage({
- t: MessageEvent.OnlyEmitSignal,
- meta_only: true,
- meta: mediaArray[index].meta,
- metadata: mediaArray[index].metadata,
- })
- }
- this.resetBufItem(index)
- }
- if (!breakWhenIDR) {
- this.isFirstFrame = true
- }
- this.dumpJitterBufInfo('Leaving Decoder.prototype.flushBuffer')
- return this.isFirstFrame
- }
- // var cnt = 0
- Decoder.prototype.getFrameToDecode = function () {
- this.dumpJitterBufInfo('Entering Decoder.prototype.getFrameToDecode')
- if (this.getNumOfPktToBeDec() == 0) {
- return false
- }
- //bufNum awaiting increase counter
- // while (this.getNumOfPktToBeDec() > CACHE_BUF_LENGTH / 2) {
- // needToCheck = true
- // if (this.cntBufInc > this.MAX_TRY_TO_DEC_BUFNUM) {
- // console.log('ringbuffer is deteriorating, flush until IDR')
- // var untilIDR = true
- // this.flushBuffer(untilIDR)
- // this.cntBufInc = 0
- // break
- // }
- // this.procBufItem(this.readPtr)
- // }
- // if (this.getNumOfPktToBeDec() == 0) {
- // return false
- // }
- let IFrmInBuffer = 0
- let frmInBuffer = 0
- for (var i = 0; i < CACHE_BUF_LENGTH; ++i) {
- if (mediaArray[i].isIDR) {
- IFrmInBuffer += 1
- }
- if (this.slotHasMedia(i)) {
- frmInBuffer += 1
- }
- }
- if (!this.slotHasContent(this.readPtr) && IFrmInBuffer == 0) {
- if (frmInBuffer > 0) {
- // There is P frame in buffer but cannot be decoded.
- // Due to ordered data channel, this is packet loss.
- // So request for I frame here.
- printConsole.log('detect packet lost. Request for I frame.')
- self.postMessage({ t: MessageEvent.RequestIFrame })
- }
- return false
- }
- this.procBufItem(this.readPtr)
- // if (this.getNumOfPktToBeDec() > this.prevBufNum) {
- // this.cntBufInc++
- // } else {
- // if (this.cntBufInc > 2) {
- // // aimd
- // this.cntBufInc / 2
- // }
- // }
- // this.prevBufNum = this.getNumOfPktToBeDec()
- this.dumpJitterBufInfo('Leaving Decoder.prototype.getFrameToDecode')
- return true
- }
- //refactor end:
- var cacheBuffer
- var resultBuffer
- Decoder.prototype.startDecoding = function () {
- function iterative_getFrameToDecode() {
- self.decoder.framesReceivedBetweenTimerInterval = 0
- self.decoder.dumpJitterBufInfo('Entering Decoder.prototype.iterative_getFrameToDecode')
- var start_ts = Date.now()
- let hasDecodeFrame = self.decoder.getFrameToDecode()
- var end_ts = Date.now()
- // refactor
- let expect_interval =
- 1000 / (30 + Math.max(self.decoder.getNumOfPktToBeDec() - self.decoder.passiveJitterLength, 0))
- //let expect_interval = 1000 / (Decoder.prototype.getNumOfPktToBeDec() + 30)
- if (hasDecodeFrame) {
- let usedTime = end_ts - start_ts
- self.decoder.getFrameInterval = expect_interval - Math.max(usedTime, self.decoder.dtpf)
- if (self.decoder.getFrameInterval < 1) {
- self.decoder.getFrameInterval = 0
- }
- } else {
- self.decoder.getFrameInterval = 5
- }
- // let usedTime = end_ts - start_ts
- // FPS = 30
- // if (usedTime * FPS < 1000) {
- // self.decoder.getFrameInterval = 1000 / (FPS + Decoder.prototype.getNumOfPktToBeDec())
- // } else {
- // self.decoder.getFrameInterval = 1 //ms
- // }
- // if (Decoder.prototype.getNumOfPktToBeDec() == 0) {
- // //Hinse: have to get buf to send asap.
- // self.decoder.getFrameInterval = 5 //ms
- // }
- setTimeout(iterative_getFrameToDecode, self.decoder.getFrameInterval)
- self.decoder.dumpJitterBufInfo('Leaving Decoder.prototype.iterative_getFrameToDecode')
- // refactor end
- }
- function postStats() {
- function add(accumulator, a) {
- if (a == -1) {
- a = 0
- }
- return accumulator + a
- }
- function count_valid(accumulator, a) {
- let non_zero = 0
- if (a != -1) {
- non_zero = 1
- }
- return accumulator + non_zero
- }
- function max(maxer, a) {
- return Math.max(maxer, a)
- }
- const dtpf =
- self.decoder.decodeTimeCircular.reduce(add, 0) / self.decoder.decodeTimeCircular.reduce(count_valid, 0) || 0
- const dtmf = self.decoder.decodeTimeCircular.reduce(max, 0)
- let objData = {
- t: MessageEvent.UpdateStats,
- mediaBytesReceived: self.decoder.mediaBytesReceived,
- metaBytesReceived: self.decoder.metaBytesReceived,
- packetsLost: self.decoder.packetsLost, // \u7F51\u7EDC\u4E22\u5E27
- packetsDrop: self.decoder.packetsDrop, // \u6765\u4E0D\u53CA\u89E3\u7801\u4E22\u5E27
- framesReceived: self.decoder.receivedMedia,
- framesDecoded: self.decoder.receivedYUV,
- framesRendered: self.decoder.receivedEmit,
- framesReturned: framesReturned,
- // framesAwait: leastReceivePts - lastProcessPts,
- framesAwait: self.decoder.getNumOfPktToBeDec(), // \u7B49\u5F85\u89E3\u7801\u7684\u5E27
- decodeTimePerFrame: dtpf,
- decodeTimeMaxFrame: dtmf,
- sendOutBuffer: send_out_buffer,
- JankTimes: self.decoder.JankTimes,
- bigJankTimes: self.decoder.bigJankTimes,
- receivedIframe: self.decoder.IframesReceived,
- decodedIframe: self.decoder.IframesDecoded,
- }
- self.postMessage(objData)
- self.decoder.dtmf = 0
- }
- setTimeout(iterative_getFrameToDecode, this.getFrameInterval)
- setInterval(postStats, 1000)
- }
- Decoder.prototype.initAll = function (config) {
- if (typeof wasmSource != 'undefined') {
- if (wasmSource == 0) {
- // Load from indexedDB
- // console.log('Load WASM from indexedDB')
- printConsole.log('Load WASM from indexedDB')
- wasmSource = undefined
- } else if (wasmSource == 1) {
- // Load by fetch
- // console.log('Load WASM by fetch')
- printConsole.log('Load WASM by fetch')
- wasmSource = undefined
- } else {
- printConsole.log('WASM not ready now, wait for 200 ms.')
- }
- } else {
- printConsole.log('wasm variable is not defined. Probably libffmpeg.js file is not loaded properly.')
- }
- if (typeof wasmTable === 'undefined') {
- setTimeout(self.decoder.initAll, 200, config)
- return 0
- }
- cacheBuffer = Module._malloc(1024 * 1024)
- resultBuffer = Module._malloc(64)
- self.postMessage({
- t: MessageEvent.WASMReadyCost,
- type: 'report',
- data: {
- metric: 'wasmDownloadCost',
- value: Date.now() - startTime,
- group: 'costs',
- },
- })
- // WASM already initialized. Now we open decoder.
- const LOG_LEVEL_WASM = 2
- const DECODER_H264 = 0
- const decoder_type = DECODER_H264
- for (var j = 0; j < YUV_BUF_LENGTH; ++j) {
- YUVArray.push({ status: 0, buffer: new Uint8Array((config.width * config.height * 3) / 2) })
- }
- printConsole.log('Going to open decoder ' + String(Date.now()))
- var ret0 = Module._openDecoder(0, decoder_type, LOG_LEVEL_WASM)
- if (ret0 == 0) {
- self.decoder.startDecoding()
- self.postMessage({ t: MessageEvent.WASMReady, wasm_ready: true, updateStats: false })
- } else {
- printConsole.error('openDecoder failed with error ' + String(ret0), '5001')
- return 1
- }
- return 0
- }
- Decoder.prototype.cacheFrame = function (data) {
- if (data.position != undefined) {
- var media = data.data.subarray(data.metaLen, data.metaLen + data.mediaLen)
- if (IFrameCacheBuffer[JSON.stringify(data.position)] == undefined) {
- for (var key in IFrameCacheBuffer) delete IFrameCacheBuffer[key] // Clear Frame Cache
- IFrameCacheBuffer[JSON.stringify(data.position)] = {}
- }
- IFrameCacheBuffer[JSON.stringify(data.position)][data.cachedKey] = media
- self.postMessage({
- t: MessageEvent.CacheFrame,
- cacheFrame: true,
- cachedKey: data.cachedKey,
- metadata: data.metadata,
- })
- }
- }
- Decoder.prototype.updateMediaMetaStats = function (data) {
- this.metaBytesReceived += data.metaLen
- this.mediaBytesReceived += data.mediaLen
- if (data.mediaLen != 0) {
- this.receivedMedia++
- }
- }
- Decoder.prototype.isIFrame = function (isIDR, mediaLen) {
- // return data.isIDR && media.byteLength !=0
- return isIDR && mediaLen != 0
- }
- Decoder.prototype.isPFrame = function (isIDR, mediaLen) {
- // return !data.isIDR && media.byteLength !=0
- return !isIDR && mediaLen != 0
- }
- Decoder.prototype.isPureMeta = function (metaLen, mediaLen) {
- // return media.byteLength == 0 && meta.byteLength !=0
- return mediaLen == 0 && metaLen != 0
- }
- Decoder.prototype.isInvalidPkt = function (isIDR, mediaLen, metaLen) {
- return !this.isIFrame(isIDR, mediaLen) && !this.isPFrame(isIDR, mediaLen) && !this.isPureMeta(metaLen, mediaLen)
- }
- Decoder.prototype.isSlotEmpty = function (index) {
- return !this.slotHasMedia(index) && mediaArray[index].meta == null
- }
- Decoder.prototype.handleNewPktOnFlush = function (isIDR, mediaLen) {
- var dropPkt = false
- // console.log("[xmedia] 000-1 isFirstFrame %s", this.isFirstFrame)
- if (this.isFirstFrame) {
- // let IDR/meta pass
- // console.log("[xmedia] 000-2 isIDR: %s, mediaLen: %s", isIDR, mediaLen)
- // console.log("[xmedia] 000-3 this.isPFrame(isIDR, mediaLen): %s", this.isPFrame(isIDR, mediaLen))
- if (this.isPFrame(isIDR, mediaLen)) {
- // console.log("[xmedia] 001: isPFrame TRUE")
- this.packetsDrop += 1
- // MARKER META1META2
- dropPkt = true
- }
- if (this.isIFrame(isIDR, mediaLen)) {
- // console.log("[xmedia] 002: isIFrame TRUE")
- this.isFirstFrame = false
- }
- }
- // console.log("[xmedia] 003: dropPkt: %s", dropPkt)
- return dropPkt
- }
- Decoder.prototype.notEnoughSlots = function (pts) {
- return this.isBufFull() || this.seqDiff(pts, this.prevSeq, CACHE_BUF_LENGTH) > this.getNumOfEmptySlot()
- }
- Decoder.prototype.receiveFrame = function (data) {
- var key = data.cachedKey
- var pts = data.frameCnt
- var meta = data.data.subarray(0, data.metaLen)
- var media
- if (data.cached) {
- media = IFrameCacheBuffer[JSON.stringify(data.position)][key]
- } else if (data.cacheRequest) {
- media = data.data.subarray(data.metaLen, data.metaLen + data.mediaLen)
- self.decoder.cacheFrame(data)
- } else {
- media = data.data.subarray(data.metaLen, data.metaLen + data.mediaLen)
- }
- this.updateMediaMetaStats(data)
- if (this.isFirstFrame) {
- // console.log('[xmedia] isFirstFrame = true. pts:%s', pts)
- if (this.isPFrame(data.isIDR, media.byteLength)) {
- // MARKER META1META2
- this.packetsDrop += 1
- return
- }
- this.prevSeq = this.seqDiff(pts, 1, 65536)
- this.readPtr = this.writePtr = pts % CACHE_BUF_LENGTH
- if (data.isIDR) {
- this.isFirstFrame = false
- }
- }
- if (pts !== this.seqAdd(this.prevSeq, 1, 65536) && pts !== this.prevSeq) {
- this.packetsLost += 1
- }
- const index = pts % CACHE_BUF_LENGTH
- if (this.startRecord) {
- this.mediaCacheBuffer.set(media, this.mediaCacheSize)
- this.mediaCacheSize += media.byteLength
- }
- if (this.saveRecord) {
- downloadBlob(this.mediaCacheBuffer.subarray(0, this.mediaCacheSize), 'test.264', 'application/octet-stream')
- this.mediaCacheSize = 0
- this.saveRecord = false
- this.startRecord = false
- }
- //refactor:
- // Step 1, big jump detected. we cannot handle it, flush all.
- var untilIDR, pktDrop
- if (this.isSeqJump(this.prevSeq, pts)) {
- // console.log('[resetdecoder] Fatal: decoder seq jump from ' + this.prevSeq + ' to ' + pts)
- untilIDR = false
- this.flushBuffer(untilIDR)
- pktDrop = this.handleNewPktOnFlush(data.isIDR, media.byteLength)
- if (pktDrop) return
- }
- this.dumpJitterBufInfo('Entering Decoder.prototype.receiveFrame', pts)
- // console.log("--->> this.notEnoughSlots(pts): %s", this.notEnoughSlots(pts))
- // Step 2,
- if (this.aheadof(pts, this.prevSeq)) {
- // pts before prevSeq
- // pkts in wrong order
- if (this.packetsLost > 0) {
- this.packetsLost -= 1
- // this.packetdisorder +=1
- }
- // console.log("[xmedia] disorder frame received. preSeq: %s, pts: %s", this.prevSeq, pts)
- if (this.seqDiff(this.prevSeq, pts, 65536) < this.getNumOfPktToBeDec()) {
- // slot for pts is not handled yet. just put it back:
- // console.log('put disorder frame to enc_queue, pkt:%s, prevPts: %s, numOfPktToBeDec: %s', pts, this.prevSeq, this.getNumOfPktToBeDec())
- } else {
- //dropDisorder++
- console.error(
- 'drop disorder pkt:%s, prevPts: %s, numOfPktToBeDec: %s',
- pts,
- this.prevSeq,
- this.getNumOfPktToBeDec(),
- )
- this.packetsDrop += 1
- // ---------------------
- // Note:
- //
- // Three principles for meta data:
- // step 1 step 2
- // 1. backend -----> frontend (decoder.js) -----> frontend (worker.js), meta pkts must be kept in order in the whole pipeline
- // 2. if media presents and needs to be dropped, the meta companion needs to be dropped together.
- // 3. if media is absent (media.bytelength == 0), send meta anyway
- // ---------------------
- // According to rule 1, drop meta at this point is reasonable.
- return
- }
- } else {
- // pts after prevSeq
- // make sure the ringbuffer has empty slot for new pkt
- if (this.notEnoughSlots(pts)) {
- this.dumpJitterBufInfo('Fatal: decoder buf is full', pts)
- //dropIncoming
- untilIDR = true
- this.flushBuffer(untilIDR)
- if (this.notEnoughSlots(pts)) {
- untilIDR = false
- this.flushBuffer(untilIDR)
- }
- pktDrop = this.handleNewPktOnFlush(data.isIDR, media.byteLength)
- if (pktDrop) return
- }
- }
- mediaArray[index] = {
- pts: pts,
- receive_ts: Date.now(),
- decode_ts: 0,
- yuv_ts: 0,
- render_ts: 0,
- media: media,
- meta: meta,
- metadata: data.metadata,
- isIDR: data.isIDR,
- }
- if (data.isIDR == true) {
- this.bufferIFrame += 1
- }
- this.framesReceivedBetweenTimerInterval += 1
- if (this.framesReceivedBetweenTimerInterval > this.maxFramesReceivedBetweenTimerInterval) {
- this.maxFramesReceivedBetweenTimerInterval = this.framesReceivedBetweenTimerInterval
- }
- if (!this.aheadof(pts, this.prevSeq)) {
- // writePtr += (cur - prev)
- this.writePtr = this.seqAdd(this.writePtr, this.seqDiff(pts, this.prevSeq, CACHE_BUF_LENGTH), CACHE_BUF_LENGTH)
- if (this.seqAdd(index, 1, CACHE_BUF_LENGTH) != this.writePtr) {
- this.dumpJitterBufInfo('dec worker internal info: index (' + index + ') != write_ptr (' + this.writePtr + ')')
- // debugger
- }
- this.prevSeq = pts
- }
- this.dumpJitterBufInfo('Leaving Decoder.prototype.receiveFrame')
- //refactor end
- }
- Decoder.prototype.startEmiter = function () {
- self.decoder.startEmit = true
- if (cachedFirstFrame != undefined) {
- self.postMessage(cachedFirstFrame, [cachedFirstFrame.data.buffer])
- send_out_buffer += 1
- this.receivedEmit++
- cachedFirstFrame = undefined
- }
- if (cachedPanoramaFirstFrame != undefined) {
- self.postMessage(cachedPanoramaFirstFrame)
- send_out_buffer += 1
- this.receivedEmit++
- cachedPanoramaFirstFrame = undefined
- }
- }
- Decoder.prototype.decodePanorama = function (data) {
- console.log('upload pano data')
- var content = data.data.data
- var content_size = data.data.mediaLen
- // var cacheBuffer = Module._malloc(content_size)
- // var resultBuffer = Module._malloc(64)
- Module.HEAPU8.set(content, cacheBuffer)
- let ret = 0
- try {
- ret = Module._decodeData(0, 0, cacheBuffer, content_size, resultBuffer)
- // currently only need to use flushDecoder for pano mode.
- ret = Module._flushDecoder(0, 0, resultBuffer)
- // // console.log('[][Core][WASM] return value %s',ret)
- // if(ret!=0){
- // // console.log('[][Core][WASM],-abcdefg-----> ', ret)
- // var ret_close = Module._closeDecoder(0)
- // // eslint-disable-next-line no-empty
- // if (ret_close === 0) {
- // // console.log('[][Core][WASM] decoder closed for restart')
- // } else {
- // printConsole.error('close decoder failed after decode pano.')
- // return 1
- // }
- // var ret0 = Module._openDecoder(0, 0, 2)
- // // console.log('[][Core][WASM] decoder restart success')
- // // var ret1 = Module._openDecoder(1, decoder_type, LOG_LEVEL_WASM)
- // if (ret0 === 0) {
- // ret = Module._decodeData(0, 0, cacheBuffer, content_size, resultBuffer)
- // } else {
- // printConsole.error('openDecoder failed with error ' + String(ret0) , '5001')
- // return 1
- // }
- // }
- } catch (e) {
- console.log('catch error ', e)
- printConsole.error(e.message, '5002')
- }
- // let ret = Module._decodeData(0, 0, cacheBuffer, content_size, resultBuffer)
- var width = Module.getValue(resultBuffer, 'i32')
- var height = Module.getValue(resultBuffer + 4, 'i32')
- var stride_y = Module.getValue(resultBuffer + 20, 'i32')
- var stride_u = Module.getValue(resultBuffer + 24, 'i32')
- var stride_v = Module.getValue(resultBuffer + 28, 'i32')
- var addr_y = Module.getValue(resultBuffer + 8, 'i32')
- var addr_u = Module.getValue(resultBuffer + 12, 'i32')
- var addr_v = Module.getValue(resultBuffer + 16, 'i32')
- var poc = Module.getValue(resultBuffer + 32, 'i32')
- if (ret != 0) {
- printConsole.log(
- 'Decode Data error for panorama, ret value is ' + String(ret) + ', frame content size: ' + String(content_size),
- )
- return
- }
- var yuv_data = new Uint8Array((width * height * 3) / 2)
- let pos = 0
- for (let i = 0; i < height; i++) {
- let src = addr_y + i * stride_y
- let tmp = HEAPU8.subarray(src, src + width)
- tmp = new Uint8Array(tmp)
- yuv_data.set(tmp, pos)
- pos += tmp.length
- }
- for (let i = 0; i < height / 2; i++) {
- let src = addr_u + i * stride_u
- let tmp = HEAPU8.subarray(src, src + width / 2)
- tmp = new Uint8Array(tmp)
- yuv_data.set(tmp, pos)
- pos += tmp.length
- let src2 = addr_v + i * stride_v
- let tmp2 = HEAPU8.subarray(src2, src2 + width / 2)
- tmp2 = new Uint8Array(tmp2)
- yuv_data.set(tmp2, pos)
- pos += tmp2.length
- }
- const objData = {
- t: MessageEvent.PanoramaMessage,
- tileId: data.data.tileId,
- // uuid: data.data.uuid,
- data: yuv_data,
- metadata: data.data.metadata,
- // x: data.data.x,
- // y: data.data.y,
- // z: data.data.z,
- }
- //TODO: remove debug
- if (this.startEmit) {
- self.postMessage(objData)
- } else {
- cachedPanoramaFirstFrame = objData
- }
- // console.log('upload pano data with dataLength:', len(yuv_data))
- var ret_close = Module._closeDecoder(0)
- // eslint-disable-next-line no-empty
- if (ret_close === 0) {
- // console.log('[][Core][WASM] decoder closed for restart')
- } else {
- printConsole.error('close decoder failed after decode pano.')
- return 1
- }
- var ret0 = Module._openDecoder(0, 0, 2)
- // var ret1 = Module._openDecoder(1, decoder_type, LOG_LEVEL_WASM)
- if (ret0 === 0) {
- // console.log('[][Core][WASM] decoder restart success')
- self.decoder.startDecoding()
- self.postMessage({ t: MessageEvent.WASMReady, wasm_ready: true, updateStats: false })
- } else {
- printConsole.error('openDecoder failed with error ' + String(ret0), '5001')
- return 1
- }
- }
- Decoder.prototype.decodeFrame = function (data) {
- var content = data.media
- if (typeof content == 'undefined') {
- printConsole.error('null content in decoder', '5999')
- return
- }
- var content_size = content.byteLength
- // var cacheBuffer = Module._malloc(content_size)
- // var resultBuffer = Module._malloc(64)
- Module.HEAPU8.set(content, cacheBuffer)
- const index = data.frameCnt % CACHE_BUF_LENGTH
- mediaArray[index].decode_ts = Date.now()
- var objData
- if (content_size != 0) {
- // var date = Date.now()
- // var curDate = Date.now()
- // while (curDate - date < 100) {
- // curDate = Date.now()
- // }
- // TODO: Enable/Disable it by config
- if (data.isIDR) {
- this.errorCacheSize = 0
- }
- // Guarantee that stream start from I frame
- if (this.errorCacheSize != 0 || data.isIDR) {
- this.errorCacheBuffer.set(content, this.mediaCacheSize)
- this.errorCacheSize += content.byteLength
- }
- let start_ts = Date.now()
- let ret = 0
- try {
- ret = Module._decodeData(0, data.frameCnt, cacheBuffer, content_size, resultBuffer)
- // if(ret==8){
- // // console.log('[][Core][WASM],-abcdefg-----> ', ret)
- // var ret_close = Module._closeDecoder(0)
- // // eslint-disable-next-line no-empty
- // if (ret_close === 0) {
- // // console.log('[][Core][WASM] decoder closed for restart')
- // } else {
- // printConsole.error('close decoder failed after decode pano.')
- // return 1
- // }
- // var ret0 = Module._openDecoder(0, 0, 2)
- // // console.log('[][Core][WASM] decoder restart success')
- // // var ret1 = Module._openDecoder(1, decoder_type, LOG_LEVEL_WASM)
- // if (ret0 === 0) {
- // ret = Module._decodeData(0, data.frameCnt, cacheBuffer, content_size, resultBuffer)
- // } else {
- // printConsole.error('openDecoder failed with error ' + String(ret0) , '5001')
- // return 1
- // }
- // }
- } catch (e) {
- console.log('catch error ', e)
- if (this.errorCacheSize > 0) {
- downloadBlob(this.errorCacheBuffer.subarray(0, this.errorCacheSize), 'error.264', 'application/octet-stream')
- this.errorCacheSize = 0
- }
- printConsole.error(e.message, '5002')
- }
- var width = Module.getValue(resultBuffer, 'i32')
- var height = Module.getValue(resultBuffer + 4, 'i32')
- var stride_y = Module.getValue(resultBuffer + 20, 'i32')
- var stride_u = Module.getValue(resultBuffer + 24, 'i32')
- var stride_v = Module.getValue(resultBuffer + 28, 'i32')
- var addr_y = Module.getValue(resultBuffer + 8, 'i32')
- var addr_u = Module.getValue(resultBuffer + 12, 'i32')
- var addr_v = Module.getValue(resultBuffer + 16, 'i32')
- var poc = Module.getValue(resultBuffer + 32, 'i32')
- var pts = data.frameCnt
- if (ret != 0) {
- printConsole.log(
- 'Decode Data error for video stream, ret value is ' +
- String(ret) +
- ', frame content size: ' +
- String(content_size),
- )
- if (this.errorCacheSize > 0) {
- downloadBlob(this.errorCacheBuffer.subarray(0, this.errorCacheSize), 'error.264', 'application/octet-stream')
- this.errorCacheSize = 0
- }
- printConsole.log('current poc is ' + String(poc) + ', last poc is ' + String(lastPoc))
- return
- }
- lastPoc = poc
- this.receivedYUV++
- let end_ts = Date.now()
- fdt = end_ts - start_ts
- if (fdt + self.decoder.getFrameInterval > 84) {
- this.JankTimes++
- }
- if (fdt + self.decoder.getFrameInterval > 125) {
- this.bigJankTimes++
- }
- self.decoder.dtpf = self.decoder.dtpf * 0.9 + fdt * 0.1
- // if (fdt > self.decoder.dtmf) {
- // self.decoder.dtmf = fdt
- // }
- self.decoder.decodeTimeCircular[self.decoder.dtcPtr] = fdt
- self.decoder.dtcPtr = (self.decoder.dtcPtr + 1) % self.decoder.decodeTimeCircular.length
- if (YUVArray.length <= 0) {
- // printConsole.error('No buffer to save YUV after decoding, pts is ' + String(pts), '5002')
- return
- }
- var first_available_buffer = YUVArray.shift()
- var yuv_data = first_available_buffer.buffer
- let pos = 0
- for (let i = 0; i < height; i++) {
- let src = addr_y + i * stride_y
- let tmp = HEAPU8.subarray(src, src + width)
- tmp = new Uint8Array(tmp)
- yuv_data.set(tmp, pos)
- pos += tmp.length
- }
- for (let i = 0; i < height / 2; i++) {
- let src = addr_u + i * stride_u
- let tmp = HEAPU8.subarray(src, src + width / 2)
- tmp = new Uint8Array(tmp)
- yuv_data.set(tmp, pos)
- pos += tmp.length
- let src2 = addr_v + i * stride_v
- let tmp2 = HEAPU8.subarray(src2, src2 + width / 2)
- tmp2 = new Uint8Array(tmp2)
- yuv_data.set(tmp2, pos)
- pos += tmp2.length
- }
- objData = {
- t: MessageEvent.DecodeMessage,
- data: yuv_data,
- width: width,
- height: height,
- pts: data.frameCnt,
- yuv_ts: Date.now(),
- meta: data.meta,
- metadata: data.metadata,
- }
- } else {
- objData = {
- t: MessageEvent.DecodeMessage,
- data: null,
- width: 0,
- height: 0,
- pts: data.frameCnt,
- yuv_ts: Date.now(),
- meta: data.meta,
- metadata: data.metadata,
- }
- }
- if (this.startEmit) {
- if (objData.data != null) {
- objData.postTs = Date.now()
- self.postMessage(objData, [objData.data.buffer])
- send_out_buffer += 1
- this.receivedEmit++
- } else {
- objData.postTs = Date.now()
- self.postMessage(objData)
- this.receivedEmit++
- }
- } else {
- if (objData.data != null) {
- cachedFirstFrame = objData
- }
- }
- // if (cacheBuffer != null) {
- // Module._free(cacheBuffer)
- // cacheBuffer = null
- // }
- // if (resultBuffer != null) {
- // Module._free(resultBuffer)
- // resultBuffer = null
- // }
- return
- }
- Decoder.prototype.receiveBuffer = function (data) {
- framesReturned++
- send_out_buffer -= 1
- YUVArray.push({ status: 0, buffer: data.buffer })
- }
- Decoder.prototype.setPassiveJitter = function (len) {
- this.passiveJitterLength = len
- }
- Decoder.prototype.uninitDecoder = function () {
- printConsole.log('Going to uninit decoder.')
- }
- Decoder.prototype.StartRecord = function () {
- printConsole.log('Start Record')
- this.startRecord = true
- }
- Decoder.prototype.SaveRecord = function () {
- printConsole.log('Save Record')
- this.saveRecord = true
- }
- Decoder.prototype.ReceivePanorama = function (data) {
- self.decoder.resetDecoder()
- self.decoder.decodePanorama(data)
- }
- Decoder.prototype.LoadWASM = function (url) {
- printConsole.log('Load WASM from ' + String(url))
- try {
- self.importScripts(url)
- } catch (e) {
- console.log('catch error ', e)
- printConsole.error(e.message, '5003')
- }
- }
- // self.incoming_pkt_queue = new array()
- function getRandomInt(max) {
- return Math.floor(Math.random() * max)
- }
- // console.log(getRandomInt(30));
- self.decoder = new Decoder()
- netArray = []
- var gTmpIdx = 0
- var gLossCnt = 0
- self.onmessage = function (evt) {
- switch (evt.data.t) {
- case 1: // Init Message
- self.decoder.initAll(evt.data.config)
- break
- case 0: // Decode Message
- // console.log('[][Core][WASM],------> ', evt.data)
- gTmpIdx += 1
- randLen = 16
- // randLen = getRandomInt(30)
- // eslint-disable-next-line no-constant-condition
- if (gTmpIdx > 100 && false) {
- var test_jitter_buffer = true
- if (test_jitter_buffer == true) {
- if (netArray.length % 5 == 4) {
- // netArray.insert(netArray.length -1, evt.data)
- netArray.splice(netArray.length - 1, 0, evt.data)
- } else {
- netArray.push(evt.data)
- }
- if (netArray.length > randLen) {
- // 1. jitter
- while (netArray.length > 0) {
- // console.log("[xmedia] array len: %s", netArray.length)
- gLossCnt += 1
- var pkt = netArray.shift()
- // lose pkt
- var dropInterval = 50
- var dropContinousPkts = 3
- if (gLossCnt % dropInterval < dropContinousPkts) {
- if (gLossCnt == dropInterval + dropContinousPkts - 1) {
- gLossCnt = 0
- }
- } else {
- self.decoder.receiveFrame(pkt)
- }
- }
- // // 2. disorder
- // if (incoming_pkt_queue.length % 3) {
- // in[0]
- // in[2]
- // in[1]
- // }
- }
- } else {
- self.decoder.receiveFrame(evt.data)
- }
- } else {
- self.decoder.receiveFrame(evt.data)
- }
- break
- case 2: // Receive used buffer
- self.decoder.receiveBuffer(evt.data)
- break
- case 3: // Unint Message
- self.decoder.uninitDecoder()
- break
- case 4: // Reset status
- self.decoder.resetDecoder()
- break
- case 5: // Start emit
- self.decoder.startEmiter()
- break
- case 6: // Start Record
- self.decoder.StartRecord()
- break
- case 7: // Save Record
- self.decoder.SaveRecord()
- break
- case 8: // Panorama Decode Message
- self.decoder.ReceivePanorama(evt.data)
- break
- case 9: // Select WASM Version
- self.decoder.setPassiveJitter(evt.data.jitterLength)
- self.decoder.LoadWASM(evt.data.url)
- break
- case 100: // change decoder worker status
- self.decoder.changeLogSwitch(evt.data.status)
- break
- }
- }
- }
- `;
- const panorama_width = 4096
- , panorama_height = 2048
- , tile_width = 512
- , tile_height = 256;
- function ToRadius(a) {
- return a / 180 * Math.PI
- }
- function ToAngle(a) {
- return a / Math.PI * 180
- }
- function getAngleInView(a, e) {
- const i = {}
- , o = e.x - a.width * .5
- , s = a.height * .5 - e.y
- , c = -1 * ToRadius(a.angle.pitch)
- , d = ToRadius(a.angle.yaw)
- , _ = a.width / 2 / Math.tan(ToRadius(a.horz_fov / 2))
- , b = Math.sin(c)
- , k = Math.cos(c);
- for (i.yaw = Math.atan2(o, _ * k + s * b),
- i.pitch = Math.atan2((s - _ * Math.tan(c)) * Math.cos(i.yaw), _ + s * Math.tan(c)),
- i.pitch = ToAngle(i.pitch),
- i.yaw = ToAngle(d + i.yaw); i.yaw > 359.9; )
- i.yaw -= 360;
- for (; i.yaw < 0; )
- i.yaw += 360;
- return i
- }
- function getRectangleInView(a) {
- const e = {}
- , i = Array(9)
- , o = a.height
- , s = a.width;
- for (let d = 0, _ = 0; _ <= o; _ += o / 2)
- for (let b = 0; b <= s; b += s / 2,
- d++) {
- const k = {};
- k.x = b,
- k.y = _;
- let j = {};
- j = a,
- j.angle.pitch >= 90 && (j.angle.pitch = 89.999),
- j.angle.pitch <= -90 && (j.angle.pitch = -89.999),
- j.angle.yaw = 0,
- i[d] = getAngleInView(a, k),
- i[d].pitch < -90 ? i[d].pitch = 90 : i[d].pitch > 90 && (i[d].pitch = -90)
- }
- let c = i[0].yaw > i[3].yaw ? 3 : 0;
- return i[c].yaw > i[6].yaw && (c = 6),
- i[c].yaw > i[c + 2].yaw && (i[c + 2].yaw += 360),
- i[c + 2].yaw > i[c].yaw + 180 ? (e.x = 0,
- e.width = panorama_width) : (e.x = (i[c].yaw / 360 - .5) * panorama_width,
- e.width = (i[c + 2].yaw / 360 - .5) * panorama_width - e.x),
- e.y = (.5 - i[i[0].pitch > i[1].pitch ? 0 : 1].pitch / 180) * panorama_height,
- e.height = (.5 - i[i[6].pitch > i[7].pitch ? 7 : 6].pitch / 180) * panorama_height - e.y,
- e
- }
- function MaskSetToOne(a, e) {
- const i = a / 8
- , o = a % 8;
- e.setUint8(i, e.getUint8(i) | 1 << 7 - o)
- }
- function IsAll0(a) {
- return a.getUint32(0) == 0 && a.getUint32(4) == 0
- }
- function getMaskFromTiles(a, e) {
- const i = new DataView(e);
- a.forEach(function(o, s) {
- MaskSetToOne(o, i)
- })
- }
- function operateForDataView(a, e, i, o) {
- i.setUint32(0, o(a.getUint32(0), e.getUint32(0))),
- i.setUint32(4, o(a.getUint32(4), e.getUint32(4)))
- }
- function getTilesInView(a, e) {
- const i = getRectangleInView(a)
- , o = Math.floor(i.x / tile_width)
- , s = Math.floor((i.x + i.width - 1) / tile_width)
- , c = Math.floor(i.y / tile_height)
- , d = Math.floor((i.y + i.height - 1) / tile_height);
- console.log({
- left: o,
- right: s,
- top: c,
- bottom: d
- });
- const b = []
- , k = panorama_height / tile_height;
- for (let j = o; j <= s; j++)
- for (let$ = c; $ <= d; $++)
- b.push(j * k + $);
- return console.log(b),
- getMaskFromTiles(b, e),
- b
- }
- var md5$1 = {
- exports: {}
- };
- (function(module) {
- (function() {
- var ERROR = "input is invalid type"
- , WINDOW = typeof window == "object"
- , root = WINDOW ? window : {};
- root.JS_MD5_NO_WINDOW && (WINDOW = !1);
- var WEB_WORKER = !WINDOW && typeof self == "object"
- , NODE_JS = !root.JS_MD5_NO_NODE_JS && typeof process == "object" && process.versions && process.versions.node;
- NODE_JS ? root = commonjsGlobal : WEB_WORKER && (root = self);
- 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;
- if (ARRAY_BUFFER) {
- var buffer = new ArrayBuffer(68);
- buffer8 = new Uint8Array(buffer),
- blocks = new Uint32Array(buffer)
- }
- (root.JS_MD5_NO_NODE_JS || !Array.isArray) && (Array.isArray = function(a) {
- return Object.prototype.toString.call(a) === "[object Array]"
- }
- ),
- ARRAY_BUFFER && (root.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView) && (ArrayBuffer.isView = function(a) {
- return typeof a == "object" && a.buffer && a.buffer.constructor === ArrayBuffer
- }
- );
- var createOutputMethod = function(a) {
- return function(e, i) {
- return new Md5(!0).update(e, i)[a]()
- }
- }
- , createMethod = function() {
- var a = createOutputMethod("hex");
- NODE_JS && (a = nodeWrap(a)),
- a.getCtx = a.create = function() {
- return new Md5
- }
- ,
- a.update = function(o) {
- return a.create().update(o)
- }
- ;
- for (var e = 0; e < OUTPUT_TYPES.length; ++e) {
- var i = OUTPUT_TYPES[e];
- a[i] = createOutputMethod(i)
- }
- return a
- }
- , nodeWrap = function(method) {
- var crypto = eval("require('crypto')")
- , Buffer = eval("require('buffer').Buffer")
- , nodeMethod = function(a) {
- if (typeof a == "string")
- return crypto.createHash("md5").update(a, "utf8").digest("hex");
- if (a == null)
- throw ERROR;
- return a.constructor === ArrayBuffer && (a = new Uint8Array(a)),
- Array.isArray(a) || ArrayBuffer.isView(a) || a.constructor === Buffer ? crypto.createHash("md5").update(new Buffer(a)).digest("hex") : method(a)
- };
- return nodeMethod
- };
- function Md5(a) {
- if (a)
- 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,
- this.blocks = blocks,
- this.buffer8 = buffer8;
- else if (ARRAY_BUFFER) {
- var e = new ArrayBuffer(68);
- this.buffer8 = new Uint8Array(e),
- this.blocks = new Uint32Array(e)
- } else
- this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
- this.h0 = this.h1 = this.h2 = this.h3 = this.start = this.bytes = this.hBytes = 0,
- this.finalized = this.hashed = !1,
- this.first = !0
- }
- Md5.prototype.update = function(a, e) {
- if (!this.finalized) {
- for (var i, o = 0, s, c = a.length, d = this.blocks, _ = this.buffer8; o < c; ) {
- if (this.hashed && (this.hashed = !1,
- d[0] = d[16],
- 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),
- ARRAY_BUFFER)
- for (s = this.start; o < c && s < 64; ++o)
- i = a.charCodeAt(o),
- e || i < 128 ? _[s++] = i : i < 2048 ? (_[s++] = 192 | i >> 6,
- _[s++] = 128 | i & 63) : i < 55296 || i >= 57344 ? (_[s++] = 224 | i >> 12,
- _[s++] = 128 | i >> 6 & 63,
- _[s++] = 128 | i & 63) : (i = 65536 + ((i & 1023) << 10 | a.charCodeAt(++o) & 1023),
- _[s++] = 240 | i >> 18,
- _[s++] = 128 | i >> 12 & 63,
- _[s++] = 128 | i >> 6 & 63,
- _[s++] = 128 | i & 63);
- else
- for (s = this.start; o < c && s < 64; ++o)
- i = a.charCodeAt(o),
- e || i < 128 ? d[s >> 2] |= i << SHIFT[s++ & 3] : i < 2048 ? (d[s >> 2] |= (192 | i >> 6) << SHIFT[s++ & 3],
- d[s >> 2] |= (128 | i & 63) << SHIFT[s++ & 3]) : i < 55296 || i >= 57344 ? (d[s >> 2] |= (224 | i >> 12) << SHIFT[s++ & 3],
- d[s >> 2] |= (128 | i >> 6 & 63) << SHIFT[s++ & 3],
- d[s >> 2] |= (128 | i & 63) << SHIFT[s++ & 3]) : (i = 65536 + ((i & 1023) << 10 | a.charCodeAt(++o) & 1023),
- d[s >> 2] |= (240 | i >> 18) << SHIFT[s++ & 3],
- d[s >> 2] |= (128 | i >> 12 & 63) << SHIFT[s++ & 3],
- d[s >> 2] |= (128 | i >> 6 & 63) << SHIFT[s++ & 3],
- d[s >> 2] |= (128 | i & 63) << SHIFT[s++ & 3]);
- this.lastByteIndex = s,
- this.bytes += s - this.start,
- s >= 64 ? (this.start = s - 64,
- this.hash(),
- this.hashed = !0) : this.start = s
- }
- return this.bytes > 4294967295 && (this.hBytes += this.bytes / 4294967296 << 0,
- this.bytes = this.bytes % 4294967296),
- this
- }
- }
- ,
- Md5.prototype.finalize = function() {
- if (!this.finalized) {
- this.finalized = !0;
- var a = this.blocks
- , e = this.lastByteIndex;
- a[e >> 2] |= EXTRA[e & 3],
- e >= 56 && (this.hashed || this.hash(),
- a[0] = a[16],
- 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),
- a[14] = this.bytes << 3,
- a[15] = this.hBytes << 3 | this.bytes >>> 29,
- this.hash()
- }
- }
- ,
- Md5.prototype.hash = function() {
- var a, e, i, o, s, c, d = this.blocks;
- this.first ? (a = d[0] - 680876937,
- a = (a << 7 | a >>> 25) - 271733879 << 0,
- o = (-1732584194 ^ a & 2004318071) + d[1] - 117830708,
- o = (o << 12 | o >>> 20) + a << 0,
- i = (-271733879 ^ o & (a ^ -271733879)) + d[2] - 1126478375,
- i = (i << 17 | i >>> 15) + o << 0,
- e = (a ^ i & (o ^ a)) + d[3] - 1316259209,
- e = (e << 22 | e >>> 10) + i << 0) : (a = this.h0,
- e = this.h1,
- i = this.h2,
- o = this.h3,
- a += (o ^ e & (i ^ o)) + d[0] - 680876936,
- a = (a << 7 | a >>> 25) + e << 0,
- o += (i ^ a & (e ^ i)) + d[1] - 389564586,
- o = (o << 12 | o >>> 20) + a << 0,
- i += (e ^ o & (a ^ e)) + d[2] + 606105819,
- i = (i << 17 | i >>> 15) + o << 0,
- e += (a ^ i & (o ^ a)) + d[3] - 1044525330,
- e = (e << 22 | e >>> 10) + i << 0),
- a += (o ^ e & (i ^ o)) + d[4] - 176418897,
- a = (a << 7 | a >>> 25) + e << 0,
- o += (i ^ a & (e ^ i)) + d[5] + 1200080426,
- o = (o << 12 | o >>> 20) + a << 0,
- i += (e ^ o & (a ^ e)) + d[6] - 1473231341,
- i = (i << 17 | i >>> 15) + o << 0,
- e += (a ^ i & (o ^ a)) + d[7] - 45705983,
- e = (e << 22 | e >>> 10) + i << 0,
- a += (o ^ e & (i ^ o)) + d[8] + 1770035416,
- a = (a << 7 | a >>> 25) + e << 0,
- o += (i ^ a & (e ^ i)) + d[9] - 1958414417,
- o = (o << 12 | o >>> 20) + a << 0,
- i += (e ^ o & (a ^ e)) + d[10] - 42063,
- i = (i << 17 | i >>> 15) + o << 0,
- e += (a ^ i & (o ^ a)) + d[11] - 1990404162,
- e = (e << 22 | e >>> 10) + i << 0,
- a += (o ^ e & (i ^ o)) + d[12] + 1804603682,
- a = (a << 7 | a >>> 25) + e << 0,
- o += (i ^ a & (e ^ i)) + d[13] - 40341101,
- o = (o << 12 | o >>> 20) + a << 0,
- i += (e ^ o & (a ^ e)) + d[14] - 1502002290,
- i = (i << 17 | i >>> 15) + o << 0,
- e += (a ^ i & (o ^ a)) + d[15] + 1236535329,
- e = (e << 22 | e >>> 10) + i << 0,
- a += (i ^ o & (e ^ i)) + d[1] - 165796510,
- a = (a << 5 | a >>> 27) + e << 0,
- o += (e ^ i & (a ^ e)) + d[6] - 1069501632,
- o = (o << 9 | o >>> 23) + a << 0,
- i += (a ^ e & (o ^ a)) + d[11] + 643717713,
- i = (i << 14 | i >>> 18) + o << 0,
- e += (o ^ a & (i ^ o)) + d[0] - 373897302,
- e = (e << 20 | e >>> 12) + i << 0,
- a += (i ^ o & (e ^ i)) + d[5] - 701558691,
- a = (a << 5 | a >>> 27) + e << 0,
- o += (e ^ i & (a ^ e)) + d[10] + 38016083,
- o = (o << 9 | o >>> 23) + a << 0,
- i += (a ^ e & (o ^ a)) + d[15] - 660478335,
- i = (i << 14 | i >>> 18) + o << 0,
- e += (o ^ a & (i ^ o)) + d[4] - 405537848,
- e = (e << 20 | e >>> 12) + i << 0,
- a += (i ^ o & (e ^ i)) + d[9] + 568446438,
- a = (a << 5 | a >>> 27) + e << 0,
- o += (e ^ i & (a ^ e)) + d[14] - 1019803690,
- o = (o << 9 | o >>> 23) + a << 0,
- i += (a ^ e & (o ^ a)) + d[3] - 187363961,
- i = (i << 14 | i >>> 18) + o << 0,
- e += (o ^ a & (i ^ o)) + d[8] + 1163531501,
- e = (e << 20 | e >>> 12) + i << 0,
- a += (i ^ o & (e ^ i)) + d[13] - 1444681467,
- a = (a << 5 | a >>> 27) + e << 0,
- o += (e ^ i & (a ^ e)) + d[2] - 51403784,
- o = (o << 9 | o >>> 23) + a << 0,
- i += (a ^ e & (o ^ a)) + d[7] + 1735328473,
- i = (i << 14 | i >>> 18) + o << 0,
- e += (o ^ a & (i ^ o)) + d[12] - 1926607734,
- e = (e << 20 | e >>> 12) + i << 0,
- s = e ^ i,
- a += (s ^ o) + d[5] - 378558,
- a = (a << 4 | a >>> 28) + e << 0,
- o += (s ^ a) + d[8] - 2022574463,
- o = (o << 11 | o >>> 21) + a << 0,
- c = o ^ a,
- i += (c ^ e) + d[11] + 1839030562,
- i = (i << 16 | i >>> 16) + o << 0,
- e += (c ^ i) + d[14] - 35309556,
- e = (e << 23 | e >>> 9) + i << 0,
- s = e ^ i,
- a += (s ^ o) + d[1] - 1530992060,
- a = (a << 4 | a >>> 28) + e << 0,
- o += (s ^ a) + d[4] + 1272893353,
- o = (o << 11 | o >>> 21) + a << 0,
- c = o ^ a,
- i += (c ^ e) + d[7] - 155497632,
- i = (i << 16 | i >>> 16) + o << 0,
- e += (c ^ i) + d[10] - 1094730640,
- e = (e << 23 | e >>> 9) + i << 0,
- s = e ^ i,
- a += (s ^ o) + d[13] + 681279174,
- a = (a << 4 | a >>> 28) + e << 0,
- o += (s ^ a) + d[0] - 358537222,
- o = (o << 11 | o >>> 21) + a << 0,
- c = o ^ a,
- i += (c ^ e) + d[3] - 722521979,
- i = (i << 16 | i >>> 16) + o << 0,
- e += (c ^ i) + d[6] + 76029189,
- e = (e << 23 | e >>> 9) + i << 0,
- s = e ^ i,
- a += (s ^ o) + d[9] - 640364487,
- a = (a << 4 | a >>> 28) + e << 0,
- o += (s ^ a) + d[12] - 421815835,
- o = (o << 11 | o >>> 21) + a << 0,
- c = o ^ a,
- i += (c ^ e) + d[15] + 530742520,
- i = (i << 16 | i >>> 16) + o << 0,
- e += (c ^ i) + d[2] - 995338651,
- e = (e << 23 | e >>> 9) + i << 0,
- a += (i ^ (e | ~o)) + d[0] - 198630844,
- a = (a << 6 | a >>> 26) + e << 0,
- o += (e ^ (a | ~i)) + d[7] + 1126891415,
- o = (o << 10 | o >>> 22) + a << 0,
- i += (a ^ (o | ~e)) + d[14] - 1416354905,
- i = (i << 15 | i >>> 17) + o << 0,
- e += (o ^ (i | ~a)) + d[5] - 57434055,
- e = (e << 21 | e >>> 11) + i << 0,
- a += (i ^ (e | ~o)) + d[12] + 1700485571,
- a = (a << 6 | a >>> 26) + e << 0,
- o += (e ^ (a | ~i)) + d[3] - 1894986606,
- o = (o << 10 | o >>> 22) + a << 0,
- i += (a ^ (o | ~e)) + d[10] - 1051523,
- i = (i << 15 | i >>> 17) + o << 0,
- e += (o ^ (i | ~a)) + d[1] - 2054922799,
- e = (e << 21 | e >>> 11) + i << 0,
- a += (i ^ (e | ~o)) + d[8] + 1873313359,
- a = (a << 6 | a >>> 26) + e << 0,
- o += (e ^ (a | ~i)) + d[15] - 30611744,
- o = (o << 10 | o >>> 22) + a << 0,
- i += (a ^ (o | ~e)) + d[6] - 1560198380,
- i = (i << 15 | i >>> 17) + o << 0,
- e += (o ^ (i | ~a)) + d[13] + 1309151649,
- e = (e << 21 | e >>> 11) + i << 0,
- a += (i ^ (e | ~o)) + d[4] - 145523070,
- a = (a << 6 | a >>> 26) + e << 0,
- o += (e ^ (a | ~i)) + d[11] - 1120210379,
- o = (o << 10 | o >>> 22) + a << 0,
- i += (a ^ (o | ~e)) + d[2] + 718787259,
- i = (i << 15 | i >>> 17) + o << 0,
- e += (o ^ (i | ~a)) + d[9] - 343485551,
- e = (e << 21 | e >>> 11) + i << 0,
- this.first ? (this.h0 = a + 1732584193 << 0,
- this.h1 = e - 271733879 << 0,
- this.h2 = i - 1732584194 << 0,
- this.h3 = o + 271733878 << 0,
- this.first = !1) : (this.h0 = this.h0 + a << 0,
- this.h1 = this.h1 + e << 0,
- this.h2 = this.h2 + i << 0,
- this.h3 = this.h3 + o << 0)
- }
- ,
- Md5.prototype.hex = function() {
- this.finalize();
- var a = this.h0
- , e = this.h1
- , i = this.h2
- , o = this.h3;
- 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]
- }
- ,
- Md5.prototype.toString = Md5.prototype.hex,
- Md5.prototype.digest = function(a) {
- if (a === "hex")
- return this.hex();
- this.finalize();
- var e = this.h0
- , i = this.h1
- , o = this.h2
- , s = this.h3
- , 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];
- return c
- }
- ,
- Md5.prototype.array = Md5.prototype.digest,
- Md5.prototype.arrayBuffer = function() {
- this.finalize();
- var a = new ArrayBuffer(16)
- , e = new Uint32Array(a);
- return e[0] = this.h0,
- e[1] = this.h1,
- e[2] = this.h2,
- e[3] = this.h3,
- a
- }
- ,
- Md5.prototype.buffer = Md5.prototype.arrayBuffer,
- Md5.prototype.base64 = function() {
- for (var a, e, i, o = "", s = this.array(), c = 0; c < 15; )
- a = s[c++],
- e = s[c++],
- i = s[c++],
- 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];
- return a = s[c],
- o += BASE64_ENCODE_CHAR[a >>> 2] + BASE64_ENCODE_CHAR[a << 4 & 63] + "==",
- o
- }
- ;
- var exports = createMethod();
- COMMON_JS ? module.exports = exports : root.md5 = exports
- }
- )()
- }
- )(md5$1);
- var crypto = {
- exports: {}
- };
- (function(a) {
- var e = e || function(i, o) {
- var s = {}
- , c = s.lib = {}
- , d = function() {}
- , _ = c.Base = {
- extend: function(rt) {
- d.prototype = this;
- var it = new d;
- return rt && it.mixIn(rt),
- it.hasOwnProperty("init") || (it.init = function() {
- it.$super.init.apply(this, arguments)
- }
- ),
- it.init.prototype = it,
- it.$super = this,
- it
- },
- create: function() {
- var rt = this.extend();
- return rt.init.apply(rt, arguments),
- rt
- },
- init: function() {},
- mixIn: function(rt) {
- for (var it in rt)
- rt.hasOwnProperty(it) && (this[it] = rt[it]);
- rt.hasOwnProperty("toString") && (this.toString = rt.toString)
- },
- clone: function() {
- return this.init.prototype.extend(this)
- }
- }
- , b = c.WordArray = _.extend({
- init: function(rt, it) {
- rt = this.words = rt || [],
- this.sigBytes = it != o ? it : 4 * rt.length
- },
- toString: function(rt) {
- return (rt || j).stringify(this)
- },
- concat: function(rt) {
- var it = this.words
- , nt = rt.words
- , ot = this.sigBytes;
- if (rt = rt.sigBytes,
- this.clamp(),
- ot % 4)
- for (var at = 0; at < rt; at++)
- it[ot + at >>> 2] |= (nt[at >>> 2] >>> 24 - 8 * (at % 4) & 255) << 24 - 8 * ((ot + at) % 4);
- else if (65535 < nt.length)
- for (at = 0; at < rt; at += 4)
- it[ot + at >>> 2] = nt[at >>> 2];
- else
- it.push.apply(it, nt);
- return this.sigBytes += rt,
- this
- },
- clamp: function() {
- var rt = this.words
- , it = this.sigBytes;
- rt[it >>> 2] &= 4294967295 << 32 - 8 * (it % 4),
- rt.length = i.ceil(it / 4)
- },
- clone: function() {
- var rt = _.clone.call(this);
- return rt.words = this.words.slice(0),
- rt
- },
- random: function(rt) {
- for (var it = [], nt = 0; nt < rt; nt += 4)
- it.push(4294967296 * i.random() | 0);
- return new b.init(it,rt)
- }
- })
- , k = s.enc = {}
- , j = k.Hex = {
- stringify: function(rt) {
- var it = rt.words;
- rt = rt.sigBytes;
- for (var nt = [], ot = 0; ot < rt; ot++) {
- var at = it[ot >>> 2] >>> 24 - 8 * (ot % 4) & 255;
- nt.push((at >>> 4).toString(16)),
- nt.push((at & 15).toString(16))
- }
- return nt.join("")
- },
- parse: function(rt) {
- for (var it = rt.length, nt = [], ot = 0; ot < it; ot += 2)
- nt[ot >>> 3] |= parseInt(rt.substr(ot, 2), 16) << 24 - 4 * (ot % 8);
- return new b.init(nt,it / 2)
- }
- }
- , $ = k.Latin1 = {
- stringify: function(rt) {
- var it = rt.words;
- rt = rt.sigBytes;
- for (var nt = [], ot = 0; ot < rt; ot++)
- nt.push(String.fromCharCode(it[ot >>> 2] >>> 24 - 8 * (ot % 4) & 255));
- return nt.join("")
- },
- parse: function(rt) {
- for (var it = rt.length, nt = [], ot = 0; ot < it; ot++)
- nt[ot >>> 2] |= (rt.charCodeAt(ot) & 255) << 24 - 8 * (ot % 4);
- return new b.init(nt,it)
- }
- }
- , _e = k.Utf8 = {
- stringify: function(rt) {
- try {
- return decodeURIComponent(escape($.stringify(rt)))
- } catch {
- throw Error("Malformed UTF-8 data")
- }
- },
- parse: function(rt) {
- return $.parse(unescape(encodeURIComponent(rt)))
- }
- }
- , et = c.BufferedBlockAlgorithm = _.extend({
- reset: function() {
- this._data = new b.init,
- this._nDataBytes = 0
- },
- _append: function(rt) {
- typeof rt == "string" && (rt = _e.parse(rt)),
- this._data.concat(rt),
- this._nDataBytes += rt.sigBytes
- },
- _process: function(rt) {
- var it = this._data
- , nt = it.words
- , ot = it.sigBytes
- , at = this.blockSize
- , st = ot / (4 * at)
- , st = rt ? i.ceil(st) : i.max((st | 0) - this._minBufferSize, 0);
- if (rt = st * at,
- ot = i.min(4 * rt, ot),
- rt) {
- for (var ut = 0; ut < rt; ut += at)
- this._doProcessBlock(nt, ut);
- ut = nt.splice(0, rt),
- it.sigBytes -= ot
- }
- return new b.init(ut,ot)
- },
- clone: function() {
- var rt = _.clone.call(this);
- return rt._data = this._data.clone(),
- rt
- },
- _minBufferSize: 0
- });
- c.Hasher = et.extend({
- cfg: _.extend(),
- init: function(rt) {
- this.cfg = this.cfg.extend(rt),
- this.reset()
- },
- reset: function() {
- et.reset.call(this),
- this._doReset()
- },
- update: function(rt) {
- return this._append(rt),
- this._process(),
- this
- },
- finalize: function(rt) {
- return rt && this._append(rt),
- this._doFinalize()
- },
- blockSize: 16,
- _createHelper: function(rt) {
- return function(it, nt) {
- return new rt.init(nt).finalize(it)
- }
- },
- _createHmacHelper: function(rt) {
- return function(it, nt) {
- return new tt.HMAC.init(rt,nt).finalize(it)
- }
- }
- });
- var tt = s.algo = {};
- return s
- }(Math);
- (function() {
- var i = e
- , d = i.lib
- , o = d.WordArray
- , s = d.Hasher
- , c = []
- , d = i.algo.SHA1 = s.extend({
- _doReset: function() {
- this._hash = new o.init([1732584193, 4023233417, 2562383102, 271733878, 3285377520])
- },
- _doProcessBlock: function(_, b) {
- 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++) {
- if (16 > rt)
- c[rt] = _[b + rt] | 0;
- else {
- var it = c[rt - 3] ^ c[rt - 8] ^ c[rt - 14] ^ c[rt - 16];
- c[rt] = it << 1 | it >>> 31
- }
- it = (j << 5 | j >>> 27) + tt + c[rt],
- 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),
- tt = et,
- et = _e,
- _e = $ << 30 | $ >>> 2,
- $ = j,
- j = it
- }
- k[0] = k[0] + j | 0,
- k[1] = k[1] + $ | 0,
- k[2] = k[2] + _e | 0,
- k[3] = k[3] + et | 0,
- k[4] = k[4] + tt | 0
- },
- _doFinalize: function() {
- var _ = this._data
- , b = _.words
- , k = 8 * this._nDataBytes
- , j = 8 * _.sigBytes;
- return b[j >>> 5] |= 128 << 24 - j % 32,
- b[(j + 64 >>> 9 << 4) + 14] = Math.floor(k / 4294967296),
- b[(j + 64 >>> 9 << 4) + 15] = k,
- _.sigBytes = 4 * b.length,
- this._process(),
- this._hash
- },
- clone: function() {
- var _ = s.clone.call(this);
- return _._hash = this._hash.clone(),
- _
- }
- });
- i.SHA1 = s._createHelper(d),
- i.HmacSHA1 = s._createHmacHelper(d)
- }
- )(),
- function() {
- var i = e
- , o = i.enc.Utf8;
- i.algo.HMAC = i.lib.Base.extend({
- init: function(s, c) {
- s = this._hasher = new s.init,
- typeof c == "string" && (c = o.parse(c));
- var d = s.blockSize
- , _ = 4 * d;
- c.sigBytes > _ && (c = s.finalize(c)),
- c.clamp();
- for (var b = this._oKey = c.clone(), k = this._iKey = c.clone(), j = b.words, $ = k.words, _e = 0; _e < d; _e++)
- j[_e] ^= 1549556828,
- $[_e] ^= 909522486;
- b.sigBytes = k.sigBytes = _,
- this.reset()
- },
- reset: function() {
- var s = this._hasher;
- s.reset(),
- s.update(this._iKey)
- },
- update: function(s) {
- return this._hasher.update(s),
- this
- },
- finalize: function(s) {
- var c = this._hasher;
- return s = c.finalize(s),
- c.reset(),
- c.finalize(this._oKey.clone().concat(s))
- }
- })
- }(),
- function() {
- var i = e
- , o = i.lib
- , s = o.WordArray
- , c = i.enc;
- c.Base64 = {
- stringify: function(d) {
- var _ = d.words
- , b = d.sigBytes
- , k = this._map;
- d.clamp();
- for (var j = [], $ = 0; $ < b; $ += 3)
- 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++)
- j.push(k.charAt(rt >>> 6 * (3 - it) & 63));
- var nt = k.charAt(64);
- if (nt)
- for (; j.length % 4; )
- j.push(nt);
- return j.join("")
- },
- parse: function(d) {
- var _ = d.length
- , b = this._map
- , k = b.charAt(64);
- if (k) {
- var j = d.indexOf(k);
- j != -1 && (_ = j)
- }
- for (var $ = [], _e = 0, et = 0; et < _; et++)
- if (et % 4) {
- var tt = b.indexOf(d.charAt(et - 1)) << et % 4 * 2
- , rt = b.indexOf(d.charAt(et)) >>> 6 - et % 4 * 2;
- $[_e >>> 2] |= (tt | rt) << 24 - _e % 4 * 8,
- _e++
- }
- return s.create($, _e)
- },
- _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
- }
- }(),
- a.exports = e
- }
- )(crypto);
- var domParser = {}
- , sax = {}
- , 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]/
- , nameChar = new RegExp("[\\-\\.0-9" + nameStartChar.source.slice(1, -1) + "\\u00B7\\u0300-\\u036F\\u203F-\\u2040]")
- , tagNamePattern = new RegExp("^" + nameStartChar.source + nameChar.source + "*(?::" + nameStartChar.source + nameChar.source + "*)?$")
- , S_TAG = 0
- , S_ATTR = 1
- , S_ATTR_SPACE = 2
- , S_EQ = 3
- , S_ATTR_NOQUOT_VALUE = 4
- , S_ATTR_END = 5
- , S_TAG_SPACE = 6
- , S_TAG_CLOSE = 7;
- function XMLReader$1() {}
- XMLReader$1.prototype = {
- parse: function(a, e, i) {
- var o = this.domBuilder;
- o.startDocument(),
- _copy(e, e = {}),
- parse(a, e, i, o, this.errorHandler),
- o.endDocument()
- }
- };
- function parse(a, e, i, o, s) {
- function c(Et) {
- if (Et > 65535) {
- Et -= 65536;
- var At = 55296 + (Et >> 10)
- , gt = 56320 + (Et & 1023);
- return String.fromCharCode(At, gt)
- } else
- return String.fromCharCode(Et)
- }
- function d(Et) {
- var At = Et.slice(1, -1);
- return At in i ? i[At] : At.charAt(0) === "#" ? c(parseInt(At.substr(1).replace("x", "0x"))) : (s.error("entity not found:" + Et),
- Et)
- }
- function _(Et) {
- if (Et > rt) {
- var At = a.substring(rt, Et).replace(/&#?\w+;/g, d);
- _e && b(rt),
- o.characters(At, 0, Et - rt),
- rt = Et
- }
- }
- function b(Et, At) {
- for (; Et >= j && (At = $.exec(a)); )
- k = At.index,
- j = k + At[0].length,
- _e.lineNumber++;
- _e.columnNumber = Et - k + 1
- }
- for (var k = 0, j = 0, $ = /.*(?:\r\n?|\n)|.*$/g, _e = o.locator, et = [{
- currentNSMap: e
- }], tt = {}, rt = 0; ; ) {
- try {
- var it = a.indexOf("<", rt);
- if (it < 0) {
- if (!a.substr(rt).match(/^\s*$/)) {
- var nt = o.doc
- , ot = nt.createTextNode(a.substr(rt));
- nt.appendChild(ot),
- o.currentElement = ot
- }
- return
- }
- switch (it > rt && _(it),
- a.charAt(it + 1)) {
- case "/":
- var dt = a.indexOf(">", it + 3)
- , at = a.substring(it + 2, dt)
- , st = et.pop();
- dt < 0 ? (at = a.substring(it + 2).replace(/[\s<].*/, ""),
- s.error("end tag name: " + at + " is not complete:" + st.tagName),
- dt = it + 1 + at.length) : at.match(/\s</) && (at = at.replace(/[\s<].*/, ""),
- s.error("end tag name: " + at + " maybe not complete"),
- dt = it + 1 + at.length);
- var ut = st.localNSMap
- , ct = st.tagName == at
- , lt = ct || st.tagName && st.tagName.toLowerCase() == at.toLowerCase();
- if (lt) {
- if (o.endElement(st.uri, st.localName, at),
- ut)
- for (var ft in ut)
- o.endPrefixMapping(ft);
- ct || s.fatalError("end tag name: " + at + " is not match the current start tagName:" + st.tagName)
- } else
- et.push(st);
- dt++;
- break;
- case "?":
- _e && b(it),
- dt = parseInstruction(a, it, o);
- break;
- case "!":
- _e && b(it),
- dt = parseDCC(a, it, o, s);
- break;
- default:
- _e && b(it);
- var ht = new ElementAttributes
- , pt = et[et.length - 1].currentNSMap
- , dt = parseElementStartPart(a, it, ht, pt, d, s)
- , _t = ht.length;
- if (!ht.closed && fixSelfClosed(a, dt, ht.tagName, tt) && (ht.closed = !0,
- i.nbsp || s.warning("unclosed xml attribute")),
- _e && _t) {
- for (var mt = copyLocator(_e, {}), vt = 0; vt < _t; vt++) {
- var yt = ht[vt];
- b(yt.offset),
- yt.locator = copyLocator(_e, {})
- }
- o.locator = mt,
- appendElement$1(ht, o, pt) && et.push(ht),
- o.locator = _e
- } else
- appendElement$1(ht, o, pt) && et.push(ht);
- ht.uri === "http://www.w3.org/1999/xhtml" && !ht.closed ? dt = parseHtmlSpecialContent(a, dt, ht.tagName, d, o) : dt++
- }
- } catch (Et) {
- s.error("element parse error: " + Et),
- dt = -1
- }
- dt > rt ? rt = dt : _(Math.max(it, rt) + 1)
- }
- }
- function copyLocator(a, e) {
- return e.lineNumber = a.lineNumber,
- e.columnNumber = a.columnNumber,
- e
- }
- function parseElementStartPart(a, e, i, o, s, c) {
- for (var d, _, b = ++e, k = S_TAG; ; ) {
- var j = a.charAt(b);
- switch (j) {
- case "=":
- if (k === S_ATTR)
- d = a.slice(e, b),
- k = S_EQ;
- else if (k === S_ATTR_SPACE)
- k = S_EQ;
- else
- throw new Error("attribute equal must after attrName");
- break;
- case "'":
- case '"':
- if (k === S_EQ || k === S_ATTR)
- if (k === S_ATTR && (c.warning('attribute value must after "="'),
- d = a.slice(e, b)),
- e = b + 1,
- b = a.indexOf(j, e),
- b > 0)
- _ = a.slice(e, b).replace(/&#?\w+;/g, s),
- i.add(d, _, e - 1),
- k = S_ATTR_END;
- else
- throw new Error("attribute value no end '" + j + "' match");
- else if (k == S_ATTR_NOQUOT_VALUE)
- _ = a.slice(e, b).replace(/&#?\w+;/g, s),
- i.add(d, _, e),
- c.warning('attribute "' + d + '" missed start quot(' + j + ")!!"),
- e = b + 1,
- k = S_ATTR_END;
- else
- throw new Error('attribute value must after "="');
- break;
- case "/":
- switch (k) {
- case S_TAG:
- i.setTagName(a.slice(e, b));
- case S_ATTR_END:
- case S_TAG_SPACE:
- case S_TAG_CLOSE:
- k = S_TAG_CLOSE,
- i.closed = !0;
- case S_ATTR_NOQUOT_VALUE:
- case S_ATTR:
- case S_ATTR_SPACE:
- break;
- default:
- throw new Error("attribute invalid close char('/')")
- }
- break;
- case "":
- return c.error("unexpected end of input"),
- k == S_TAG && i.setTagName(a.slice(e, b)),
- b;
- case ">":
- switch (k) {
- case S_TAG:
- i.setTagName(a.slice(e, b));
- case S_ATTR_END:
- case S_TAG_SPACE:
- case S_TAG_CLOSE:
- break;
- case S_ATTR_NOQUOT_VALUE:
- case S_ATTR:
- _ = a.slice(e, b),
- _.slice(-1) === "/" && (i.closed = !0,
- _ = _.slice(0, -1));
- case S_ATTR_SPACE:
- k === S_ATTR_SPACE && (_ = d),
- k == S_ATTR_NOQUOT_VALUE ? (c.warning('attribute "' + _ + '" missed quot(")!!'),
- 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!!'),
- i.add(_, _, e));
- break;
- case S_EQ:
- throw new Error("attribute value missed!!")
- }
- return b;
- case "\x80":
- j = " ";
- default:
- if (j <= " ")
- switch (k) {
- case S_TAG:
- i.setTagName(a.slice(e, b)),
- k = S_TAG_SPACE;
- break;
- case S_ATTR:
- d = a.slice(e, b),
- k = S_ATTR_SPACE;
- break;
- case S_ATTR_NOQUOT_VALUE:
- var _ = a.slice(e, b).replace(/&#?\w+;/g, s);
- c.warning('attribute "' + _ + '" missed quot(")!!'),
- i.add(d, _, e);
- case S_ATTR_END:
- k = S_TAG_SPACE;
- break
- }
- else
- switch (k) {
- case S_ATTR_SPACE:
- i.tagName,
- (o[""] !== "http://www.w3.org/1999/xhtml" || !d.match(/^(?:disabled|checked|selected)$/i)) && c.warning('attribute "' + d + '" missed value!! "' + d + '" instead2!!'),
- i.add(d, d, e),
- e = b,
- k = S_ATTR;
- break;
- case S_ATTR_END:
- c.warning('attribute space is required"' + d + '"!!');
- case S_TAG_SPACE:
- k = S_ATTR,
- e = b;
- break;
- case S_EQ:
- k = S_ATTR_NOQUOT_VALUE,
- e = b;
- break;
- case S_TAG_CLOSE:
- throw new Error("elements closed character '/' and '>' must be connected to")
- }
- }
- b++
- }
- }
- function appendElement$1(a, e, i) {
- for (var o = a.tagName, s = null, $ = a.length; $--; ) {
- var c = a[$]
- , d = c.qName
- , _ = c.value
- , _e = d.indexOf(":");
- if (_e > 0)
- var b = c.prefix = d.slice(0, _e)
- , k = d.slice(_e + 1)
- , j = b === "xmlns" && k;
- else
- k = d,
- b = null,
- j = d === "xmlns" && "";
- c.localName = k,
- j !== !1 && (s == null && (s = {},
- _copy(i, i = {})),
- i[j] = s[j] = _,
- c.uri = "http://www.w3.org/2000/xmlns/",
- e.startPrefixMapping(j, _))
- }
- for (var $ = a.length; $--; ) {
- c = a[$];
- var b = c.prefix;
- b && (b === "xml" && (c.uri = "http://www.w3.org/XML/1998/namespace"),
- b !== "xmlns" && (c.uri = i[b || ""]))
- }
- var _e = o.indexOf(":");
- _e > 0 ? (b = a.prefix = o.slice(0, _e),
- k = a.localName = o.slice(_e + 1)) : (b = null,
- k = a.localName = o);
- var et = a.uri = i[b || ""];
- if (e.startElement(et, k, o, a),
- a.closed) {
- if (e.endElement(et, k, o),
- s)
- for (b in s)
- e.endPrefixMapping(b)
- } else
- return a.currentNSMap = i,
- a.localNSMap = s,
- !0
- }
- function parseHtmlSpecialContent(a, e, i, o, s) {
- if (/^(?:script|textarea)$/i.test(i)) {
- var c = a.indexOf("</" + i + ">", e)
- , d = a.substring(e + 1, c);
- if (/[&<]/.test(d))
- return /^script$/i.test(i) ? (s.characters(d, 0, d.length),
- c) : (d = d.replace(/&#?\w+;/g, o),
- s.characters(d, 0, d.length),
- c)
- }
- return e + 1
- }
- function fixSelfClosed(a, e, i, o) {
- var s = o[i];
- return s == null && (s = a.lastIndexOf("</" + i + ">"),
- s < e && (s = a.lastIndexOf("</" + i)),
- o[i] = s),
- s < e
- }
- function _copy(a, e) {
- for (var i in a)
- e[i] = a[i]
- }
- function parseDCC(a, e, i, o) {
- var s = a.charAt(e + 2);
- switch (s) {
- case "-":
- if (a.charAt(e + 3) === "-") {
- var c = a.indexOf("-->", e + 4);
- return c > e ? (i.comment(a, e + 4, c - e - 4),
- c + 3) : (o.error("Unclosed comment"),
- -1)
- } else
- return -1;
- default:
- if (a.substr(e + 3, 6) == "CDATA[") {
- var c = a.indexOf("]]>", e + 9);
- return i.startCDATA(),
- i.characters(a, e + 9, c - e - 9),
- i.endCDATA(),
- c + 3
- }
- var d = split(a, e)
- , _ = d.length;
- if (_ > 1 && /!doctype/i.test(d[0][0])) {
- var b = d[1][0]
- , k = _ > 3 && /^public$/i.test(d[2][0]) && d[3][0]
- , j = _ > 4 && d[4][0]
- , $ = d[_ - 1];
- return i.startDTD(b, k && k.replace(/^(['"])(.*?)\1$/, "$2"), j && j.replace(/^(['"])(.*?)\1$/, "$2")),
- i.endDTD(),
- $.index + $[0].length
- }
- }
- return -1
- }
- function parseInstruction(a, e, i) {
- var o = a.indexOf("?>", e);
- if (o) {
- var s = a.substring(e, o).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);
- return s ? (s[0].length,
- i.processingInstruction(s[1], s[2]),
- o + 2) : -1
- }
- return -1
- }
- function ElementAttributes(a) {}
- ElementAttributes.prototype = {
- setTagName: function(a) {
- if (!tagNamePattern.test(a))
- throw new Error("invalid tagName:" + a);
- this.tagName = a
- },
- add: function(a, e, i) {
- if (!tagNamePattern.test(a))
- throw new Error("invalid attribute:" + a);
- this[this.length++] = {
- qName: a,
- value: e,
- offset: i
- }
- },
- length: 0,
- getLocalName: function(a) {
- return this[a].localName
- },
- getLocator: function(a) {
- return this[a].locator
- },
- getQName: function(a) {
- return this[a].qName
- },
- getURI: function(a) {
- return this[a].uri
- },
- getValue: function(a) {
- return this[a].value
- }
- };
- function _set_proto_(a, e) {
- return a.__proto__ = e,
- a
- }
- _set_proto_({}, _set_proto_.prototype)instanceof _set_proto_ || (_set_proto_ = function(a, e) {
- function i() {}
- i.prototype = e,
- i = new i;
- for (e in a)
- i[e] = a[e];
- return i
- }
- );
- function split(a, e) {
- var i, o = [], s = /'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;
- for (s.lastIndex = e,
- s.exec(a); i = s.exec(a); )
- if (o.push(i),
- i[1])
- return o
- }
- sax.XMLReader = XMLReader$1;
- var dom = {};
- function copy(a, e) {
- for (var i in a)
- e[i] = a[i]
- }
- function _extends(a, e) {
- var i = a.prototype;
- if (Object.create) {
- var o = Object.create(e.prototype);
- i.__proto__ = o
- }
- if (!(i instanceof e)) {
- let c = function() {};
- var s = c;
- c.prototype = e.prototype,
- c = new c,
- copy(i, c),
- a.prototype = i = c
- }
- i.constructor != a && (typeof a != "function" && console.error("unknow Class:" + a),
- i.constructor = a)
- }
- var htmlns = "http://www.w3.org/1999/xhtml"
- , NodeType = {}
- , ELEMENT_NODE = NodeType.ELEMENT_NODE = 1
- , ATTRIBUTE_NODE = NodeType.ATTRIBUTE_NODE = 2
- , TEXT_NODE = NodeType.TEXT_NODE = 3
- , CDATA_SECTION_NODE = NodeType.CDATA_SECTION_NODE = 4
- , ENTITY_REFERENCE_NODE = NodeType.ENTITY_REFERENCE_NODE = 5
- , ENTITY_NODE = NodeType.ENTITY_NODE = 6
- , PROCESSING_INSTRUCTION_NODE = NodeType.PROCESSING_INSTRUCTION_NODE = 7
- , COMMENT_NODE = NodeType.COMMENT_NODE = 8
- , DOCUMENT_NODE = NodeType.DOCUMENT_NODE = 9
- , DOCUMENT_TYPE_NODE = NodeType.DOCUMENT_TYPE_NODE = 10
- , DOCUMENT_FRAGMENT_NODE = NodeType.DOCUMENT_FRAGMENT_NODE = 11
- , NOTATION_NODE = NodeType.NOTATION_NODE = 12
- , ExceptionCode = {}
- , ExceptionMessage = {};
- ExceptionCode.INDEX_SIZE_ERR = (ExceptionMessage[1] = "Index size error",
- 1);
- ExceptionCode.DOMSTRING_SIZE_ERR = (ExceptionMessage[2] = "DOMString size error",
- 2);
- var HIERARCHY_REQUEST_ERR = ExceptionCode.HIERARCHY_REQUEST_ERR = (ExceptionMessage[3] = "Hierarchy request error",
- 3);
- ExceptionCode.WRONG_DOCUMENT_ERR = (ExceptionMessage[4] = "Wrong document",
- 4);
- ExceptionCode.INVALID_CHARACTER_ERR = (ExceptionMessage[5] = "Invalid character",
- 5);
- ExceptionCode.NO_DATA_ALLOWED_ERR = (ExceptionMessage[6] = "No data allowed",
- 6);
- ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = (ExceptionMessage[7] = "No modification allowed",
- 7);
- var NOT_FOUND_ERR = ExceptionCode.NOT_FOUND_ERR = (ExceptionMessage[8] = "Not found",
- 8);
- ExceptionCode.NOT_SUPPORTED_ERR = (ExceptionMessage[9] = "Not supported",
- 9);
- var INUSE_ATTRIBUTE_ERR = ExceptionCode.INUSE_ATTRIBUTE_ERR = (ExceptionMessage[10] = "Attribute in use",
- 10);
- ExceptionCode.INVALID_STATE_ERR = (ExceptionMessage[11] = "Invalid state",
- 11);
- ExceptionCode.SYNTAX_ERR = (ExceptionMessage[12] = "Syntax error",
- 12);
- ExceptionCode.INVALID_MODIFICATION_ERR = (ExceptionMessage[13] = "Invalid modification",
- 13);
- ExceptionCode.NAMESPACE_ERR = (ExceptionMessage[14] = "Invalid namespace",
- 14);
- ExceptionCode.INVALID_ACCESS_ERR = (ExceptionMessage[15] = "Invalid access",
- 15);
- function DOMException$1(a, e) {
- if (e instanceof Error)
- var i = e;
- else
- i = this,
- Error.call(this, ExceptionMessage[a]),
- this.message = ExceptionMessage[a],
- Error.captureStackTrace && Error.captureStackTrace(this, DOMException$1);
- return i.code = a,
- e && (this.message = this.message + ": " + e),
- i
- }
- DOMException$1.prototype = Error.prototype;
- copy(ExceptionCode, DOMException$1);
- function NodeList() {}
- NodeList.prototype = {
- length: 0,
- item: function(a) {
- return this[a] || null
- },
- toString: function(a, e) {
- for (var i = [], o = 0; o < this.length; o++)
- serializeToString(this[o], i, a, e);
- return i.join("")
- }
- };
- function LiveNodeList(a, e) {
- this._node = a,
- this._refresh = e,
- _updateLiveList(this)
- }
- function _updateLiveList(a) {
- var e = a._node._inc || a._node.ownerDocument._inc;
- if (a._inc != e) {
- var i = a._refresh(a._node);
- __set__(a, "length", i.length),
- copy(i, a),
- a._inc = e
- }
- }
- LiveNodeList.prototype.item = function(a) {
- return _updateLiveList(this),
- this[a]
- }
- ;
- _extends(LiveNodeList, NodeList);
- function NamedNodeMap() {}
- function _findNodeIndex(a, e) {
- for (var i = a.length; i--; )
- if (a[i] === e)
- return i
- }
- function _addNamedNode(a, e, i, o) {
- if (o ? e[_findNodeIndex(e, o)] = i : e[e.length++] = i,
- a) {
- i.ownerElement = a;
- var s = a.ownerDocument;
- s && (o && _onRemoveAttribute(s, a, o),
- _onAddAttribute(s, a, i))
- }
- }
- function _removeNamedNode(a, e, i) {
- var o = _findNodeIndex(e, i);
- if (o >= 0) {
- for (var s = e.length - 1; o < s; )
- e[o] = e[++o];
- if (e.length = s,
- a) {
- var c = a.ownerDocument;
- c && (_onRemoveAttribute(c, a, i),
- i.ownerElement = null)
- }
- } else
- throw DOMException$1(NOT_FOUND_ERR, new Error(a.tagName + "@" + i))
- }
- NamedNodeMap.prototype = {
- length: 0,
- item: NodeList.prototype.item,
- getNamedItem: function(a) {
- for (var e = this.length; e--; ) {
- var i = this[e];
- if (i.nodeName == a)
- return i
- }
- },
- setNamedItem: function(a) {
- var e = a.ownerElement;
- if (e && e != this._ownerElement)
- throw new DOMException$1(INUSE_ATTRIBUTE_ERR);
- var i = this.getNamedItem(a.nodeName);
- return _addNamedNode(this._ownerElement, this, a, i),
- i
- },
- setNamedItemNS: function(a) {
- var e = a.ownerElement, i;
- if (e && e != this._ownerElement)
- throw new DOMException$1(INUSE_ATTRIBUTE_ERR);
- return i = this.getNamedItemNS(a.namespaceURI, a.localName),
- _addNamedNode(this._ownerElement, this, a, i),
- i
- },
- removeNamedItem: function(a) {
- var e = this.getNamedItem(a);
- return _removeNamedNode(this._ownerElement, this, e),
- e
- },
- removeNamedItemNS: function(a, e) {
- var i = this.getNamedItemNS(a, e);
- return _removeNamedNode(this._ownerElement, this, i),
- i
- },
- getNamedItemNS: function(a, e) {
- for (var i = this.length; i--; ) {
- var o = this[i];
- if (o.localName == e && o.namespaceURI == a)
- return o
- }
- return null
- }
- };
- function DOMImplementation$1(a) {
- if (this._features = {},
- a)
- for (var e in a)
- this._features = a[e]
- }
- DOMImplementation$1.prototype = {
- hasFeature: function(a, e) {
- var i = this._features[a.toLowerCase()];
- return !!(i && (!e || e in i))
- },
- createDocument: function(a, e, i) {
- var o = new Document;
- if (o.implementation = this,
- o.childNodes = new NodeList,
- o.doctype = i,
- i && o.appendChild(i),
- e) {
- var s = o.createElementNS(a, e);
- o.appendChild(s)
- }
- return o
- },
- createDocumentType: function(a, e, i) {
- var o = new DocumentType;
- return o.name = a,
- o.nodeName = a,
- o.publicId = e,
- o.systemId = i,
- o
- }
- };
- function Node$1() {}
- Node$1.prototype = {
- firstChild: null,
- lastChild: null,
- previousSibling: null,
- nextSibling: null,
- attributes: null,
- parentNode: null,
- childNodes: null,
- ownerDocument: null,
- nodeValue: null,
- namespaceURI: null,
- prefix: null,
- localName: null,
- insertBefore: function(a, e) {
- return _insertBefore(this, a, e)
- },
- replaceChild: function(a, e) {
- this.insertBefore(a, e),
- e && this.removeChild(e)
- },
- removeChild: function(a) {
- return _removeChild(this, a)
- },
- appendChild: function(a) {
- return this.insertBefore(a, null)
- },
- hasChildNodes: function() {
- return this.firstChild != null
- },
- cloneNode: function(a) {
- return cloneNode(this.ownerDocument || this, this, a)
- },
- normalize: function() {
- for (var a = this.firstChild; a; ) {
- var e = a.nextSibling;
- e && e.nodeType == TEXT_NODE && a.nodeType == TEXT_NODE ? (this.removeChild(e),
- a.appendData(e.data)) : (a.normalize(),
- a = e)
- }
- },
- isSupported: function(a, e) {
- return this.ownerDocument.implementation.hasFeature(a, e)
- },
- hasAttributes: function() {
- return this.attributes.length > 0
- },
- lookupPrefix: function(a) {
- for (var e = this; e; ) {
- var i = e._nsMap;
- if (i) {
- for (var o in i)
- if (i[o] == a)
- return o
- }
- e = e.nodeType == ATTRIBUTE_NODE ? e.ownerDocument : e.parentNode
- }
- return null
- },
- lookupNamespaceURI: function(a) {
- for (var e = this; e; ) {
- var i = e._nsMap;
- if (i && a in i)
- return i[a];
- e = e.nodeType == ATTRIBUTE_NODE ? e.ownerDocument : e.parentNode
- }
- return null
- },
- isDefaultNamespace: function(a) {
- var e = this.lookupPrefix(a);
- return e == null
- }
- };
- function _xmlEncoder(a) {
- return a == "<" && "<" || a == ">" && ">" || a == "&" && "&" || a == '"' && """ || "&#" + a.charCodeAt() + ";"
- }
- copy(NodeType, Node$1);
- copy(NodeType, Node$1.prototype);
- function _visitNode(a, e) {
- if (e(a))
- return !0;
- if (a = a.firstChild)
- do
- if (_visitNode(a, e))
- return !0;
- while (a = a.nextSibling)
- }
- function Document() {}
- function _onAddAttribute(a, e, i) {
- a && a._inc++;
- var o = i.namespaceURI;
- o == "http://www.w3.org/2000/xmlns/" && (e._nsMap[i.prefix ? i.localName : ""] = i.value)
- }
- function _onRemoveAttribute(a, e, i, o) {
- a && a._inc++;
- var s = i.namespaceURI;
- s == "http://www.w3.org/2000/xmlns/" && delete e._nsMap[i.prefix ? i.localName : ""]
- }
- function _onUpdateChild(a, e, i) {
- if (a && a._inc) {
- a._inc++;
- var o = e.childNodes;
- if (i)
- o[o.length++] = i;
- else {
- for (var s = e.firstChild, c = 0; s; )
- o[c++] = s,
- s = s.nextSibling;
- o.length = c
- }
- }
- }
- function _removeChild(a, e) {
- var i = e.previousSibling
- , o = e.nextSibling;
- return i ? i.nextSibling = o : a.firstChild = o,
- o ? o.previousSibling = i : a.lastChild = i,
- _onUpdateChild(a.ownerDocument, a),
- e
- }
- function _insertBefore(a, e, i) {
- var o = e.parentNode;
- if (o && o.removeChild(e),
- e.nodeType === DOCUMENT_FRAGMENT_NODE) {
- var s = e.firstChild;
- if (s == null)
- return e;
- var c = e.lastChild
- } else
- s = c = e;
- var d = i ? i.previousSibling : a.lastChild;
- s.previousSibling = d,
- c.nextSibling = i,
- d ? d.nextSibling = s : a.firstChild = s,
- i == null ? a.lastChild = c : i.previousSibling = c;
- do
- s.parentNode = a;
- while (s !== c && (s = s.nextSibling));
- return _onUpdateChild(a.ownerDocument || a, a),
- e.nodeType == DOCUMENT_FRAGMENT_NODE && (e.firstChild = e.lastChild = null),
- e
- }
- function _appendSingleChild(a, e) {
- var i = e.parentNode;
- if (i) {
- var o = a.lastChild;
- i.removeChild(e);
- var o = a.lastChild
- }
- var o = a.lastChild;
- return e.parentNode = a,
- e.previousSibling = o,
- e.nextSibling = null,
- o ? o.nextSibling = e : a.firstChild = e,
- a.lastChild = e,
- _onUpdateChild(a.ownerDocument, a, e),
- e
- }
- Document.prototype = {
- nodeName: "#document",
- nodeType: DOCUMENT_NODE,
- doctype: null,
- documentElement: null,
- _inc: 1,
- insertBefore: function(a, e) {
- if (a.nodeType == DOCUMENT_FRAGMENT_NODE) {
- for (var i = a.firstChild; i; ) {
- var o = i.nextSibling;
- this.insertBefore(i, e),
- i = o
- }
- return a
- }
- return this.documentElement == null && a.nodeType == ELEMENT_NODE && (this.documentElement = a),
- _insertBefore(this, a, e),
- a.ownerDocument = this,
- a
- },
- removeChild: function(a) {
- return this.documentElement == a && (this.documentElement = null),
- _removeChild(this, a)
- },
- importNode: function(a, e) {
- return importNode(this, a, e)
- },
- getElementById: function(a) {
- var e = null;
- return _visitNode(this.documentElement, function(i) {
- if (i.nodeType == ELEMENT_NODE && i.getAttribute("id") == a)
- return e = i,
- !0
- }),
- e
- },
- createElement: function(a) {
- var e = new Element;
- e.ownerDocument = this,
- e.nodeName = a,
- e.tagName = a,
- e.childNodes = new NodeList;
- var i = e.attributes = new NamedNodeMap;
- return i._ownerElement = e,
- e
- },
- createDocumentFragment: function() {
- var a = new DocumentFragment;
- return a.ownerDocument = this,
- a.childNodes = new NodeList,
- a
- },
- createTextNode: function(a) {
- var e = new Text;
- return e.ownerDocument = this,
- e.appendData(a),
- e
- },
- createComment: function(a) {
- var e = new Comment;
- return e.ownerDocument = this,
- e.appendData(a),
- e
- },
- createCDATASection: function(a) {
- var e = new CDATASection;
- return e.ownerDocument = this,
- e.appendData(a),
- e
- },
- createProcessingInstruction: function(a, e) {
- var i = new ProcessingInstruction;
- return i.ownerDocument = this,
- i.tagName = i.target = a,
- i.nodeValue = i.data = e,
- i
- },
- createAttribute: function(a) {
- var e = new Attr;
- return e.ownerDocument = this,
- e.name = a,
- e.nodeName = a,
- e.localName = a,
- e.specified = !0,
- e
- },
- createEntityReference: function(a) {
- var e = new EntityReference;
- return e.ownerDocument = this,
- e.nodeName = a,
- e
- },
- createElementNS: function(a, e) {
- var i = new Element
- , o = e.split(":")
- , s = i.attributes = new NamedNodeMap;
- return i.childNodes = new NodeList,
- i.ownerDocument = this,
- i.nodeName = e,
- i.tagName = e,
- i.namespaceURI = a,
- o.length == 2 ? (i.prefix = o[0],
- i.localName = o[1]) : i.localName = e,
- s._ownerElement = i,
- i
- },
- createAttributeNS: function(a, e) {
- var i = new Attr
- , o = e.split(":");
- return i.ownerDocument = this,
- i.nodeName = e,
- i.name = e,
- i.namespaceURI = a,
- i.specified = !0,
- o.length == 2 ? (i.prefix = o[0],
- i.localName = o[1]) : i.localName = e,
- i
- }
- };
- _extends(Document, Node$1);
- function Element() {
- this._nsMap = {}
- }
- Element.prototype = {
- nodeType: ELEMENT_NODE,
- hasAttribute: function(a) {
- return this.getAttributeNode(a) != null
- },
- getAttribute: function(a) {
- var e = this.getAttributeNode(a);
- return e && e.value || ""
- },
- getAttributeNode: function(a) {
- return this.attributes.getNamedItem(a)
- },
- setAttribute: function(a, e) {
- var i = this.ownerDocument.createAttribute(a);
- i.value = i.nodeValue = "" + e,
- this.setAttributeNode(i)
- },
- removeAttribute: function(a) {
- var e = this.getAttributeNode(a);
- e && this.removeAttributeNode(e)
- },
- appendChild: function(a) {
- return a.nodeType === DOCUMENT_FRAGMENT_NODE ? this.insertBefore(a, null) : _appendSingleChild(this, a)
- },
- setAttributeNode: function(a) {
- return this.attributes.setNamedItem(a)
- },
- setAttributeNodeNS: function(a) {
- return this.attributes.setNamedItemNS(a)
- },
- removeAttributeNode: function(a) {
- return this.attributes.removeNamedItem(a.nodeName)
- },
- removeAttributeNS: function(a, e) {
- var i = this.getAttributeNodeNS(a, e);
- i && this.removeAttributeNode(i)
- },
- hasAttributeNS: function(a, e) {
- return this.getAttributeNodeNS(a, e) != null
- },
- getAttributeNS: function(a, e) {
- var i = this.getAttributeNodeNS(a, e);
- return i && i.value || ""
- },
- setAttributeNS: function(a, e, i) {
- var o = this.ownerDocument.createAttributeNS(a, e);
- o.value = o.nodeValue = "" + i,
- this.setAttributeNode(o)
- },
- getAttributeNodeNS: function(a, e) {
- return this.attributes.getNamedItemNS(a, e)
- },
- getElementsByTagName: function(a) {
- return new LiveNodeList(this,function(e) {
- var i = [];
- return _visitNode(e, function(o) {
- o !== e && o.nodeType == ELEMENT_NODE && (a === "*" || o.tagName == a) && i.push(o)
- }),
- i
- }
- )
- },
- getElementsByTagNameNS: function(a, e) {
- return new LiveNodeList(this,function(i) {
- var o = [];
- return _visitNode(i, function(s) {
- s !== i && s.nodeType === ELEMENT_NODE && (a === "*" || s.namespaceURI === a) && (e === "*" || s.localName == e) && o.push(s)
- }),
- o
- }
- )
- }
- };
- Document.prototype.getElementsByTagName = Element.prototype.getElementsByTagName;
- Document.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS;
- _extends(Element, Node$1);
- function Attr() {}
- Attr.prototype.nodeType = ATTRIBUTE_NODE;
- _extends(Attr, Node$1);
- function CharacterData() {}
- CharacterData.prototype = {
- data: "",
- substringData: function(a, e) {
- return this.data.substring(a, a + e)
- },
- appendData: function(a) {
- a = this.data + a,
- this.nodeValue = this.data = a,
- this.length = a.length
- },
- insertData: function(a, e) {
- this.replaceData(a, 0, e)
- },
- appendChild: function(a) {
- throw new Error(ExceptionMessage[HIERARCHY_REQUEST_ERR])
- },
- deleteData: function(a, e) {
- this.replaceData(a, e, "")
- },
- replaceData: function(a, e, i) {
- var o = this.data.substring(0, a)
- , s = this.data.substring(a + e);
- i = o + i + s,
- this.nodeValue = this.data = i,
- this.length = i.length
- }
- };
- _extends(CharacterData, Node$1);
- function Text() {}
- Text.prototype = {
- nodeName: "#text",
- nodeType: TEXT_NODE,
- splitText: function(a) {
- var e = this.data
- , i = e.substring(a);
- e = e.substring(0, a),
- this.data = this.nodeValue = e,
- this.length = e.length;
- var o = this.ownerDocument.createTextNode(i);
- return this.parentNode && this.parentNode.insertBefore(o, this.nextSibling),
- o
- }
- };
- _extends(Text, CharacterData);
- function Comment() {}
- Comment.prototype = {
- nodeName: "#comment",
- nodeType: COMMENT_NODE
- };
- _extends(Comment, CharacterData);
- function CDATASection() {}
- CDATASection.prototype = {
- nodeName: "#cdata-section",
- nodeType: CDATA_SECTION_NODE
- };
- _extends(CDATASection, CharacterData);
- function DocumentType() {}
- DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;
- _extends(DocumentType, Node$1);
- function Notation() {}
- Notation.prototype.nodeType = NOTATION_NODE;
- _extends(Notation, Node$1);
- function Entity() {}
- Entity.prototype.nodeType = ENTITY_NODE;
- _extends(Entity, Node$1);
- function EntityReference() {}
- EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;
- _extends(EntityReference, Node$1);
- function DocumentFragment() {}
- DocumentFragment.prototype.nodeName = "#document-fragment";
- DocumentFragment.prototype.nodeType = DOCUMENT_FRAGMENT_NODE;
- _extends(DocumentFragment, Node$1);
- function ProcessingInstruction() {}
- ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;
- _extends(ProcessingInstruction, Node$1);
- function XMLSerializer$1() {}
- XMLSerializer$1.prototype.serializeToString = function(a, e, i) {
- return nodeSerializeToString.call(a, e, i)
- }
- ;
- Node$1.prototype.toString = nodeSerializeToString;
- function nodeSerializeToString(a, e) {
- var i = []
- , o = this.nodeType == 9 ? this.documentElement : this
- , s = o.prefix
- , c = o.namespaceURI;
- if (c && s == null) {
- var s = o.lookupPrefix(c);
- if (s == null)
- var d = [{
- namespace: c,
- prefix: null
- }]
- }
- return serializeToString(this, i, a, e, d),
- i.join("")
- }
- function needNamespaceDefine(a, e, i) {
- var o = a.prefix || ""
- , s = a.namespaceURI;
- if (!o && !s || o === "xml" && s === "http://www.w3.org/XML/1998/namespace" || s == "http://www.w3.org/2000/xmlns/")
- return !1;
- for (var c = i.length; c--; ) {
- var d = i[c];
- if (d.prefix == o)
- return d.namespace != s
- }
- return !0
- }
- function serializeToString(a, e, i, o, s) {
- if (o)
- if (a = o(a),
- a) {
- if (typeof a == "string") {
- e.push(a);
- return
- }
- } else
- return;
- switch (a.nodeType) {
- case ELEMENT_NODE:
- s || (s = []),
- s.length;
- var c = a.attributes
- , d = c.length
- , et = a.firstChild
- , _ = a.tagName;
- i = htmlns === a.namespaceURI || i,
- e.push("<", _);
- for (var b = 0; b < d; b++) {
- var k = c.item(b);
- k.prefix == "xmlns" ? s.push({
- prefix: k.localName,
- namespace: k.value
- }) : k.nodeName == "xmlns" && s.push({
- prefix: "",
- namespace: k.value
- })
- }
- for (var b = 0; b < d; b++) {
- var k = c.item(b);
- if (needNamespaceDefine(k, i, s)) {
- var j = k.prefix || ""
- , $ = k.namespaceURI
- , _e = j ? " xmlns:" + j : " xmlns";
- e.push(_e, '="', $, '"'),
- s.push({
- prefix: j,
- namespace: $
- })
- }
- serializeToString(k, e, i, o, s)
- }
- if (needNamespaceDefine(a, i, s)) {
- var j = a.prefix || ""
- , $ = a.namespaceURI
- , _e = j ? " xmlns:" + j : " xmlns";
- e.push(_e, '="', $, '"'),
- s.push({
- prefix: j,
- namespace: $
- })
- }
- if (et || i && !/^(?:meta|link|img|br|hr|input)$/i.test(_)) {
- if (e.push(">"),
- i && /^script$/i.test(_))
- for (; et; )
- et.data ? e.push(et.data) : serializeToString(et, e, i, o, s),
- et = et.nextSibling;
- else
- for (; et; )
- serializeToString(et, e, i, o, s),
- et = et.nextSibling;
- e.push("</", _, ">")
- } else
- e.push("/>");
- return;
- case DOCUMENT_NODE:
- case DOCUMENT_FRAGMENT_NODE:
- for (var et = a.firstChild; et; )
- serializeToString(et, e, i, o, s),
- et = et.nextSibling;
- return;
- case ATTRIBUTE_NODE:
- return e.push(" ", a.name, '="', a.value.replace(/[<&"]/g, _xmlEncoder), '"');
- case TEXT_NODE:
- return e.push(a.data.replace(/[<&]/g, _xmlEncoder));
- case CDATA_SECTION_NODE:
- return e.push("<![CDATA[", a.data, "]]>");
- case COMMENT_NODE:
- return e.push("<!--", a.data, "-->");
- case DOCUMENT_TYPE_NODE:
- var tt = a.publicId
- , rt = a.systemId;
- if (e.push("<!DOCTYPE ", a.name),
- tt)
- e.push(' PUBLIC "', tt),
- rt && rt != "." && e.push('" "', rt),
- e.push('">');
- else if (rt && rt != ".")
- e.push(' SYSTEM "', rt, '">');
- else {
- var it = a.internalSubset;
- it && e.push(" [", it, "]"),
- e.push(">")
- }
- return;
- case PROCESSING_INSTRUCTION_NODE:
- return e.push("<?", a.target, " ", a.data, "?>");
- case ENTITY_REFERENCE_NODE:
- return e.push("&", a.nodeName, ";");
- default:
- e.push("??", a.nodeName)
- }
- }
- function importNode(a, e, i) {
- var o;
- switch (e.nodeType) {
- case ELEMENT_NODE:
- o = e.cloneNode(!1),
- o.ownerDocument = a;
- case DOCUMENT_FRAGMENT_NODE:
- break;
- case ATTRIBUTE_NODE:
- i = !0;
- break
- }
- if (o || (o = e.cloneNode(!1)),
- o.ownerDocument = a,
- o.parentNode = null,
- i)
- for (var s = e.firstChild; s; )
- o.appendChild(importNode(a, s, i)),
- s = s.nextSibling;
- return o
- }
- function cloneNode(a, e, i) {
- var o = new e.constructor;
- for (var s in e) {
- var c = e[s];
- typeof c != "object" && c != o[s] && (o[s] = c)
- }
- switch (e.childNodes && (o.childNodes = new NodeList),
- o.ownerDocument = a,
- o.nodeType) {
- case ELEMENT_NODE:
- var d = e.attributes
- , _ = o.attributes = new NamedNodeMap
- , b = d.length;
- _._ownerElement = o;
- for (var k = 0; k < b; k++)
- o.setAttributeNode(cloneNode(a, d.item(k), !0));
- break;
- case ATTRIBUTE_NODE:
- i = !0
- }
- if (i)
- for (var j = e.firstChild; j; )
- o.appendChild(cloneNode(a, j, i)),
- j = j.nextSibling;
- return o
- }
- function __set__(a, e, i) {
- a[e] = i
- }
- try {
- if (Object.defineProperty) {
- let a = function(e) {
- switch (e.nodeType) {
- case ELEMENT_NODE:
- case DOCUMENT_FRAGMENT_NODE:
- var i = [];
- for (e = e.firstChild; e; )
- e.nodeType !== 7 && e.nodeType !== 8 && i.push(a(e)),
- e = e.nextSibling;
- return i.join("");
- default:
- return e.nodeValue
- }
- };
- var getTextContent = a;
- Object.defineProperty(LiveNodeList.prototype, "length", {
- get: function() {
- return _updateLiveList(this),
- this.$$length
- }
- }),
- Object.defineProperty(Node$1.prototype, "textContent", {
- get: function() {
- return a(this)
- },
- set: function(e) {
- switch (this.nodeType) {
- case ELEMENT_NODE:
- case DOCUMENT_FRAGMENT_NODE:
- for (; this.firstChild; )
- this.removeChild(this.firstChild);
- (e || String(e)) && this.appendChild(this.ownerDocument.createTextNode(e));
- break;
- default:
- this.data = e,
- this.value = e,
- this.nodeValue = e
- }
- }
- }),
- __set__ = function(e, i, o) {
- e["$$" + i] = o
- }
- }
- } catch (a) {}
- dom.DOMImplementation = DOMImplementation$1;
- dom.XMLSerializer = XMLSerializer$1;
- function DOMParser$1(a) {
- this.options = a || {
- locator: {}
- }
- }
- DOMParser$1.prototype.parseFromString = function(a, e) {
- var i = this.options
- , o = new XMLReader
- , s = i.domBuilder || new DOMHandler
- , c = i.errorHandler
- , d = i.locator
- , _ = i.xmlns || {}
- , b = {
- lt: "<",
- gt: ">",
- amp: "&",
- quot: '"',
- apos: "'"
- };
- return d && s.setDocumentLocator(d),
- o.errorHandler = buildErrorHandler(c, s, d),
- o.domBuilder = i.domBuilder || s,
- /\/x?html?$/.test(e) && (b.nbsp = "\xA0",
- b.copy = "\xA9",
- _[""] = "http://www.w3.org/1999/xhtml"),
- _.xml = _.xml || "http://www.w3.org/XML/1998/namespace",
- a ? o.parse(a, _, b) : o.errorHandler.error("invalid doc source"),
- s.doc
- }
- ;
- function buildErrorHandler(a, e, i) {
- if (!a) {
- if (e instanceof DOMHandler)
- return e;
- a = e
- }
- var o = {}
- , s = a instanceof Function;
- i = i || {};
- function c(d) {
- var _ = a[d];
- !_ && s && (_ = a.length == 2 ? function(b) {
- a(d, b)
- }
- : a),
- o[d] = _ && function(b) {
- _("[xmldom " + d + "] " + b + _locator(i))
- }
- || function() {}
- }
- return c("warning"),
- c("error"),
- c("fatalError"),
- o
- }
- function DOMHandler() {
- this.cdata = !1
- }
- function position(a, e) {
- e.lineNumber = a.lineNumber,
- e.columnNumber = a.columnNumber
- }
- DOMHandler.prototype = {
- startDocument: function() {
- this.doc = new DOMImplementation().createDocument(null, null, null),
- this.locator && (this.doc.documentURI = this.locator.systemId)
- },
- startElement: function(a, e, i, o) {
- var s = this.doc
- , c = s.createElementNS(a, i || e)
- , d = o.length;
- appendElement(this, c),
- this.currentElement = c,
- this.locator && position(this.locator, c);
- for (var _ = 0; _ < d; _++) {
- var a = o.getURI(_)
- , b = o.getValue(_)
- , i = o.getQName(_)
- , k = s.createAttributeNS(a, i);
- this.locator && position(o.getLocator(_), k),
- k.value = k.nodeValue = b,
- c.setAttributeNode(k)
- }
- },
- endElement: function(a, e, i) {
- var o = this.currentElement;
- o.tagName,
- this.currentElement = o.parentNode
- },
- startPrefixMapping: function(a, e) {},
- endPrefixMapping: function(a) {},
- processingInstruction: function(a, e) {
- var i = this.doc.createProcessingInstruction(a, e);
- this.locator && position(this.locator, i),
- appendElement(this, i)
- },
- ignorableWhitespace: function(a, e, i) {},
- characters: function(a, e, i) {
- if (a = _toString.apply(this, arguments),
- a) {
- if (this.cdata)
- var o = this.doc.createCDATASection(a);
- else
- var o = this.doc.createTextNode(a);
- this.currentElement ? this.currentElement.appendChild(o) : /^\s*$/.test(a) && this.doc.appendChild(o),
- this.locator && position(this.locator, o)
- }
- },
- skippedEntity: function(a) {},
- endDocument: function() {
- this.doc.normalize()
- },
- setDocumentLocator: function(a) {
- (this.locator = a) && (a.lineNumber = 0)
- },
- comment: function(a, e, i) {
- a = _toString.apply(this, arguments);
- var o = this.doc.createComment(a);
- this.locator && position(this.locator, o),
- appendElement(this, o)
- },
- startCDATA: function() {
- this.cdata = !0
- },
- endCDATA: function() {
- this.cdata = !1
- },
- startDTD: function(a, e, i) {
- var o = this.doc.implementation;
- if (o && o.createDocumentType) {
- var s = o.createDocumentType(a, e, i);
- this.locator && position(this.locator, s),
- appendElement(this, s)
- }
- },
- warning: function(a) {
- console.warn("[xmldom warning] " + a, _locator(this.locator))
- },
- error: function(a) {
- console.error("[xmldom error] " + a, _locator(this.locator))
- },
- fatalError: function(a) {
- throw console.error("[xmldom fatalError] " + a, _locator(this.locator)),
- a
- }
- };
- function _locator(a) {
- if (a)
- return `
- @` + (a.systemId || "") + "#[line:" + a.lineNumber + ",col:" + a.columnNumber + "]"
- }
- function _toString(a, e, i) {
- return typeof a == "string" ? a.substr(e, i) : a.length >= e + i || e ? new java.lang.String(a,e,i) + "" : a
- }
- "endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g, function(a) {
- DOMHandler.prototype[a] = function() {
- return null
- }
- });
- function appendElement(a, e) {
- a.currentElement ? a.currentElement.appendChild(e) : a.doc.appendChild(e)
- }
- var XMLReader = sax.XMLReader
- , DOMImplementation = domParser.DOMImplementation = dom.DOMImplementation;
- domParser.XMLSerializer = dom.XMLSerializer;
- domParser.DOMParser = DOMParser$1;
- var DOMParser = domParser.DOMParser
- , xmlToJSON = function() {
- this.version = "1.3.5";
- var a = {
- mergeCDATA: !0,
- normalize: !0,
- stripElemPrefix: !0
- }
- , e = new RegExp(/(?!xmlns)^.*:/);
- return this.grokType = function(i) {
- return /^\s*$/.test(i) ? null : /^(?:true|false)$/i.test(i) ? i.toLowerCase() === "true" : isFinite(i) ? parseFloat(i) : i
- }
- ,
- this.parseString = function(i, o) {
- if (i) {
- var s = this.stringToXML(i);
- return s.getElementsByTagName("parsererror").length ? null : this.parseXML(s, o)
- } else
- return null
- }
- ,
- this.parseXML = function(i, o) {
- for (var s in o)
- a[s] = o[s];
- var c = {}
- , d = 0
- , _ = ""
- , b = i.childNodes.length;
- if (b)
- for (var k, j, $, _e = 0; _e < i.childNodes.length; _e++)
- k = i.childNodes.item(_e),
- k.nodeType === 4 ? a.mergeCDATA && (_ += k.nodeValue) : k.nodeType === 3 ? _ += k.nodeValue : k.nodeType === 1 && (d === 0 && (c = {}),
- a.stripElemPrefix ? j = k.nodeName.replace(e, "") : j = k.nodeName,
- $ = xmlToJSON.parseXML(k),
- c.hasOwnProperty(j) ? (c[j].constructor !== Array && (c[j] = [c[j]]),
- c[j].push($)) : (c[j] = $,
- d++));
- return Object.keys(c).length || (c = _ || ""),
- c
- }
- ,
- this.xmlToString = function(i) {
- try {
- var o = i.xml ? i.xml : new XMLSerializer().serializeToString(i);
- return o
- } catch {
- return null
- }
- }
- ,
- this.stringToXML = function(i) {
- try {
- var o = null;
- if (window.DOMParser) {
- var s = new DOMParser;
- return o = s.parseFromString(i, "text/xml"),
- o
- } else
- return o = new ActiveXObject("Microsoft.XMLDOM"),
- o.async = !1,
- o.loadXML(i),
- o
- } catch {
- return null
- }
- }
- ,
- this
- }
- .call({})
- , xml2json$1 = function(a) {
- return xmlToJSON.parseString(a)
- }
- , xml2json_1 = xml2json$1
- , 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"
- , element_non_start_char = "-.0-9\xB7\u0300-\u036F\u203F\u2040"
- , element_replace = new RegExp("^([^" + element_start_char + "])|^((x|X)(m|M)(l|L))|([^" + element_start_char + element_non_start_char + "])","g")
- , not_safe_in_xml = /[^\x09\x0A\x0D\x20-\xFF\x85\xA0-\uD7FF\uE000-\uFDCF\uFDE0-\uFFFD]/gm
- , objKeys = function(a) {
- var e = [];
- if (a instanceof Object)
- for (var i in a)
- a.hasOwnProperty(i) && e.push(i);
- return e
- }
- , process_to_xml = function(a, e) {
- var i = function(o, s, c, d, _) {
- var b = e.indent !== void 0 ? e.indent : " "
- , k = e.prettyPrint ? `
- ` + new Array(d).join(b) : "";
- e.removeIllegalNameCharacters && (o = o.replace(element_replace, "_"));
- var j = [k, "<", o, c || ""];
- return s && s.length > 0 ? (j.push(">"),
- j.push(s),
- _ && j.push(k),
- j.push("</"),
- j.push(o),
- j.push(">")) : j.push("/>"),
- j.join("")
- };
- return function o(s, c, d) {
- var _ = typeof s;
- switch ((Array.isArray ? Array.isArray(s) : s instanceof Array) ? _ = "array" : s instanceof Date && (_ = "date"),
- _) {
- case "array":
- var b = [];
- return s.map(function(_e) {
- b.push(o(_e, 1, d + 1))
- }),
- e.prettyPrint && b.push(`
- `),
- b.join("");
- case "date":
- return s.toJSON ? s.toJSON() : s + "";
- case "object":
- var k = [];
- for (var j in s)
- if (s.hasOwnProperty(j))
- if (s[j]instanceof Array)
- for (var $ = 0; $ < s[j].length; $++)
- s[j].hasOwnProperty($) && k.push(i(j, o(s[j][$], 0, d + 1), null, d + 1, objKeys(s[j][$]).length));
- else
- k.push(i(j, o(s[j], 0, d + 1), null, d + 1));
- return e.prettyPrint && k.length > 0 && k.push(`
- `),
- k.join("");
- case "function":
- return s();
- default:
- return e.escape ? esc(s) : "" + s
- }
- }(a, 0, 0)
- }
- , xml_header = function(a) {
- var e = ['<?xml version="1.0" encoding="UTF-8"'];
- return a && e.push(' standalone="yes"'),
- e.push("?>"),
- e.join("")
- };
- function esc(a) {
- return ("" + a).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/'/g, "'").replace(/"/g, """).replace(not_safe_in_xml, "")
- }
- var json2xml$1 = function(a, e) {
- if (e || (e = {
- xmlHeader: {
- standalone: !0
- },
- prettyPrint: !0,
- indent: " ",
- escape: !0
- }),
- typeof a == "string")
- try {
- a = JSON.parse(a.toString())
- } catch {
- return !1
- }
- var i = ""
- , o = "";
- e && (typeof e == "object" ? (e.xmlHeader && (i = xml_header(!!e.xmlHeader.standalone)),
- typeof e.docType != "undefined" && (o = "<!DOCTYPE " + e.docType + ">")) : i = xml_header()),
- e = e || {};
- var s = [i, e.prettyPrint && o ? `
- ` : "", o, process_to_xml(a, e)];
- return s.join("").replace(/\n{2,}/g, `
- `).replace(/\s+$/g, "")
- }
- , md5 = md5$1.exports
- , CryptoJS = crypto.exports
- , xml2json = xml2json_1
- , json2xml = json2xml$1;
- function camSafeUrlEncode(a) {
- return encodeURIComponent(a).replace(/!/g, "%21").replace(/'/g, "%27").replace(/\(/g, "%28").replace(/\)/g, "%29").replace(/\*/g, "%2A")
- }
- function getObjectKeys(a, e) {
- var i = [];
- for (var o in a)
- a.hasOwnProperty(o) && i.push(e ? camSafeUrlEncode(o).toLowerCase() : o);
- return i.sort(function(s, c) {
- return s = s.toLowerCase(),
- c = c.toLowerCase(),
- s === c ? 0 : s > c ? 1 : -1
- })
- }
- var obj2str = function(a, e) {
- var i, o, s, c = [], d = getObjectKeys(a);
- for (i = 0; i < d.length; i++)
- o = d[i],
- s = a[o] === void 0 || a[o] === null ? "" : "" + a[o],
- o = e ? camSafeUrlEncode(o).toLowerCase() : camSafeUrlEncode(o),
- s = camSafeUrlEncode(s) || "",
- c.push(o + "=" + s);
- return c.join("&")
- }
- , 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"]
- , getSignHeaderObj = function(a) {
- var e = {};
- for (var i in a) {
- var o = i.toLowerCase();
- (o.indexOf("x-cos-") > -1 || signHeaders.indexOf(o) > -1) && (e[i] = a[i])
- }
- return e
- }
- , getAuth$1 = function(a) {
- a = a || {};
- 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;
- a.UseRawKey ? b = a.Pathname || a.pathname || "/" + _ : (b = a.Pathname || a.pathname || _,
- b.indexOf("/") !== 0 && (b = "/" + b));
- var k = a.ForceSignHost !== !1;
- if (!d.Host && !d.host && a.Bucket && a.Region && k && (d.Host = a.Bucket + ".cos." + a.Region + ".myqcloud.com"),
- !e)
- throw new Error("missing param SecretId");
- if (!i)
- throw new Error("missing param SecretKey");
- var j = Math.round(getSkewTime(a.SystemClockOffset) / 1e3) - 1
- , $ = j
- , _e = a.Expires || a.expires;
- _e === void 0 ? $ += 900 : $ += _e * 1 || 0;
- var et = "sha1"
- , tt = e
- , rt = o || j + ";" + $
- , it = o || j + ";" + $
- , nt = getObjectKeys(d, !0).join(";").toLowerCase()
- , ot = getObjectKeys(c, !0).join(";").toLowerCase()
- , at = CryptoJS.HmacSHA1(it, i).toString()
- , st = [s, b, util$5.obj2str(c, !0), util$5.obj2str(d, !0), ""].join(`
- `)
- , ut = ["sha1", rt, CryptoJS.SHA1(st).toString(), ""].join(`
- `)
- , ct = CryptoJS.HmacSHA1(ut, at).toString()
- , 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("&");
- return lt
- }
- , readIntBE = function(a, e, i) {
- var o = e / 8
- , s = a.slice(i, i + o);
- return new Uint8Array(s).reverse(),
- new {
- 8: Uint8Array,
- 16: Uint16Array,
- 32: Uint32Array
- }[e](s)[0]
- }
- , buf2str = function(a, e, i, o) {
- var s = a.slice(e, i)
- , c = "";
- return new Uint8Array(s).forEach(function(d) {
- c += String.fromCharCode(d)
- }),
- o && (c = decodeURIComponent(escape(c))),
- c
- }
- , parseSelectPayload = function(a) {
- for (var e = {}, i = buf2str(a), o = {
- records: []
- }; a.byteLength; ) {
- var s = readIntBE(a, 32, 0), c = readIntBE(a, 32, 4), d = s - c - 16, _ = 0, b;
- for (a = a.slice(12); _ < c; ) {
- var k = readIntBE(a, 8, _)
- , j = buf2str(a, _ + 1, _ + 1 + k)
- , $ = readIntBE(a, 16, _ + k + 2)
- , _e = buf2str(a, _ + k + 4, _ + k + 4 + $);
- e[j] = _e,
- _ += k + 4 + $
- }
- if (e[":event-type"] === "Records")
- b = buf2str(a, _, _ + d, !0),
- o.records.push(b);
- else if (e[":event-type"] === "Stats")
- b = buf2str(a, _, _ + d, !0),
- o.stats = util$5.xml2json(b).Stats;
- else if (e[":event-type"] === "error") {
- var et = e[":error-code"]
- , tt = e[":error-message"]
- , rt = new Error(tt);
- rt.message = tt,
- rt.name = rt.code = et,
- o.error = rt
- } else
- ["Progress", "Continuation", "End"].includes(e[":event-type"]);
- a = a.slice(_ + d + 4)
- }
- return {
- payload: o.records.join(""),
- body: i
- }
- }
- , getSourceParams = function(a) {
- var e = this.options.CopySourceParser;
- if (e)
- return e(a);
- var i = a.match(/^([^.]+-\d+)\.cos(v6|-cdc)?\.([^.]+)\.myqcloud\.com\/(.+)$/);
- return i ? {
- Bucket: i[1],
- Region: i[3],
- Key: i[4]
- } : null
- }
- , noop = function() {}
- , clearKey = function(a) {
- var e = {};
- for (var i in a)
- a.hasOwnProperty(i) && a[i] !== void 0 && a[i] !== null && (e[i] = a[i]);
- return e
- }
- , readAsBinaryString = function(a, e) {
- var i, o = new FileReader;
- FileReader.prototype.readAsBinaryString ? (i = FileReader.prototype.readAsBinaryString,
- o.onload = function() {
- e(this.result)
- }
- ) : FileReader.prototype.readAsArrayBuffer ? i = function(s) {
- var c = ""
- , d = new FileReader;
- d.onload = function(_) {
- for (var b = new Uint8Array(d.result), k = b.byteLength, j = 0; j < k; j++)
- c += String.fromCharCode(b[j]);
- e(c)
- }
- ,
- d.readAsArrayBuffer(s)
- }
- : console.error("FileReader not support readAsBinaryString"),
- i.call(o, a)
- }
- , fileSliceNeedCopy = function() {
- var a = function(i, o) {
- i = i.split("."),
- o = o.split(".");
- for (var s = 0; s < o.length; s++)
- if (i[s] !== o[s])
- return parseInt(i[s]) > parseInt(o[s]) ? 1 : -1;
- return 0
- }
- , e = function(i) {
- if (!i)
- return !1;
- var o = (i.match(/Chrome\/([.\d]+)/) || [])[1]
- , s = (i.match(/QBCore\/([.\d]+)/) || [])[1]
- , c = (i.match(/QQBrowser\/([.\d]+)/) || [])[1]
- , 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;
- return d
- };
- return e(typeof navigator != "undefined" && navigator.userAgent)
- }()
- , fileSlice = function(a, e, i, o, s) {
- var c;
- if (a.slice ? c = a.slice(e, i) : a.mozSlice ? c = a.mozSlice(e, i) : a.webkitSlice && (c = a.webkitSlice(e, i)),
- o && fileSliceNeedCopy) {
- var d = new FileReader;
- d.onload = function(_) {
- c = null,
- s(new Blob([d.result]))
- }
- ,
- d.readAsArrayBuffer(c)
- } else
- s(c)
- }
- , getBodyMd5 = function(a, e, i, o) {
- i = i || noop,
- a ? typeof e == "string" ? i(util$5.md5(e, !0)) : Blob && e instanceof Blob ? util$5.getFileMd5(e, function(s, c) {
- i(c)
- }, o) : i() : i()
- }
- , md5ChunkSize = 1024 * 1024
- , getFileMd5 = function(a, e, i) {
- var o = a.size
- , s = 0
- , c = md5.getCtx()
- , d = function(_) {
- if (_ >= o) {
- var b = c.digest("hex");
- e(null, b);
- return
- }
- var k = Math.min(o, _ + md5ChunkSize);
- util$5.fileSlice(a, _, k, !1, function(j) {
- readAsBinaryString(j, function($) {
- j = null,
- c = c.update($, !0),
- s += $.length,
- $ = null,
- i && i({
- loaded: s,
- total: o,
- percent: Math.round(s / o * 1e4) / 1e4
- }),
- d(_ + md5ChunkSize)
- })
- })
- };
- d(0)
- };
- function clone(a) {
- return map$1(a, function(e) {
- return typeof e == "object" && e !== null ? clone(e) : e
- })
- }
- function attr(a, e, i) {
- return a && e in a ? a[e] : i
- }
- function extend$1(a, e) {
- return each(e, function(i, o) {
- a[o] = e[o]
- }),
- a
- }
- function isArray(a) {
- return a instanceof Array
- }
- function isInArray(a, e) {
- for (var i = !1, o = 0; o < a.length; o++)
- if (e === a[o]) {
- i = !0;
- break
- }
- return i
- }
- function makeArray(a) {
- return isArray(a) ? a : [a]
- }
- function each(a, e) {
- for (var i in a)
- a.hasOwnProperty(i) && e(a[i], i)
- }
- function map$1(a, e) {
- var i = isArray(a) ? [] : {};
- for (var o in a)
- a.hasOwnProperty(o) && (i[o] = e(a[o], o));
- return i
- }
- function filter(a, e) {
- var i = isArray(a)
- , o = i ? [] : {};
- for (var s in a)
- a.hasOwnProperty(s) && e(a[s], s) && (i ? o.push(a[s]) : o[s] = a[s]);
- return o
- }
- var binaryBase64 = function(a) {
- var e, i, o, s = "";
- for (e = 0,
- i = a.length / 2; e < i; e++)
- o = parseInt(a[e * 2] + a[e * 2 + 1], 16),
- s += String.fromCharCode(o);
- return btoa(s)
- }
- , uuid = function() {
- var a = function() {
- return ((1 + Math.random()) * 65536 | 0).toString(16).substring(1)
- };
- return a() + a() + "-" + a() + "-" + a() + "-" + a() + "-" + a() + a() + a()
- }
- , hasMissingParams = function(a, e) {
- var i = e.Bucket
- , o = e.Region
- , s = e.Key
- , c = this.options.Domain
- , d = !c || c.indexOf("{Bucket}") > -1
- , _ = !c || c.indexOf("{Region}") > -1;
- if (a.indexOf("Bucket") > -1 || a === "deleteMultipleObject" || a === "multipartList" || a === "listObjectVersions") {
- if (d && !i)
- return "Bucket";
- if (_ && !o)
- return "Region"
- } else if (a.indexOf("Object") > -1 || a.indexOf("multipart") > -1 || a === "sliceUploadFile" || a === "abortUploadTask") {
- if (d && !i)
- return "Bucket";
- if (_ && !o)
- return "Region";
- if (!s)
- return "Key"
- }
- return !1
- }
- , formatParams = function(a, e) {
- if (e = extend$1({}, e),
- a !== "getAuth" && a !== "getV4Auth" && a !== "getObjectUrl") {
- var i = e.Headers || {};
- if (e && typeof e == "object") {
- (function() {
- for (var s in e)
- e.hasOwnProperty(s) && s.indexOf("x-cos-") > -1 && (i[s] = e[s])
- }
- )();
- var o = {
- "x-cos-mfa": "MFA",
- "Content-MD5": "ContentMD5",
- "Content-Length": "ContentLength",
- "Content-Type": "ContentType",
- Expect: "Expect",
- Expires: "Expires",
- "Cache-Control": "CacheControl",
- "Content-Disposition": "ContentDisposition",
- "Content-Encoding": "ContentEncoding",
- Range: "Range",
- "If-Modified-Since": "IfModifiedSince",
- "If-Unmodified-Since": "IfUnmodifiedSince",
- "If-Match": "IfMatch",
- "If-None-Match": "IfNoneMatch",
- "x-cos-copy-source": "CopySource",
- "x-cos-copy-source-Range": "CopySourceRange",
- "x-cos-metadata-directive": "MetadataDirective",
- "x-cos-copy-source-If-Modified-Since": "CopySourceIfModifiedSince",
- "x-cos-copy-source-If-Unmodified-Since": "CopySourceIfUnmodifiedSince",
- "x-cos-copy-source-If-Match": "CopySourceIfMatch",
- "x-cos-copy-source-If-None-Match": "CopySourceIfNoneMatch",
- "x-cos-acl": "ACL",
- "x-cos-grant-read": "GrantRead",
- "x-cos-grant-write": "GrantWrite",
- "x-cos-grant-full-control": "GrantFullControl",
- "x-cos-grant-read-acp": "GrantReadAcp",
- "x-cos-grant-write-acp": "GrantWriteAcp",
- "x-cos-storage-class": "StorageClass",
- "x-cos-traffic-limit": "TrafficLimit",
- "x-cos-mime-limit": "MimeLimit",
- "x-cos-server-side-encryption-customer-algorithm": "SSECustomerAlgorithm",
- "x-cos-server-side-encryption-customer-key": "SSECustomerKey",
- "x-cos-server-side-encryption-customer-key-MD5": "SSECustomerKeyMD5",
- "x-cos-server-side-encryption": "ServerSideEncryption",
- "x-cos-server-side-encryption-cos-kms-key-id": "SSEKMSKeyId",
- "x-cos-server-side-encryption-context": "SSEContext"
- };
- util$5.each(o, function(s, c) {
- e[s] !== void 0 && (i[c] = e[s])
- }),
- e.Headers = clearKey(i)
- }
- }
- return e
- }
- , apiWrapper = function(a, e) {
- return function(i, o) {
- var s = this;
- typeof i == "function" && (o = i,
- i = {}),
- i = formatParams(a, i);
- var c = function($) {
- return $ && $.headers && ($.headers["x-cos-request-id"] && ($.RequestId = $.headers["x-cos-request-id"]),
- $.headers["x-ci-request-id"] && ($.RequestId = $.headers["x-ci-request-id"]),
- $.headers["x-cos-version-id"] && ($.VersionId = $.headers["x-cos-version-id"]),
- $.headers["x-cos-delete-marker"] && ($.DeleteMarker = $.headers["x-cos-delete-marker"])),
- $
- }
- , d = function($, _e) {
- o && o(c($), c(_e))
- }
- , _ = function() {
- if (a !== "getService" && a !== "abortUploadTask") {
- var $ = hasMissingParams.call(s, a, i);
- if ($)
- return "missing param " + $;
- if (i.Region) {
- if (s.options.CompatibilityMode) {
- if (!/^([a-z\d-.]+)$/.test(i.Region))
- return "Region format error."
- } else {
- if (i.Region.indexOf("cos.") > -1)
- return 'param Region should not be start with "cos."';
- if (!/^([a-z\d-]+)$/.test(i.Region))
- return "Region format error."
- }
- !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")
- }
- if (i.Bucket) {
- if (!/^([a-z\d-]+)-(\d+)$/.test(i.Bucket))
- if (i.AppId)
- i.Bucket = i.Bucket + "-" + i.AppId;
- else if (s.options.AppId)
- i.Bucket = i.Bucket + "-" + s.options.AppId;
- else
- return 'Bucket should format as "test-1250000000".';
- i.AppId && (console.warn('warning: AppId has been deprecated, Please put it at the end of parameter Bucket(E.g Bucket:"test-1250000000" ).'),
- delete i.AppId)
- }
- !s.options.UseRawKey && i.Key && i.Key.substr(0, 1) === "/" && (i.Key = i.Key.substr(1))
- }
- }
- , b = _()
- , k = a === "getAuth" || a === "getObjectUrl";
- if (window.Promise && !k && !o)
- return new Promise(function($, _e) {
- if (o = function(et, tt) {
- et ? _e(et) : $(tt)
- }
- ,
- b)
- return d(util$5.error(new Error(b)));
- e.call(s, i, d)
- }
- );
- if (b)
- return d(util$5.error(new Error(b)));
- var j = e.call(s, i, d);
- if (k)
- return j
- }
- }
- , throttleOnProgress = function(a, e) {
- var i = this, o = 0, s = 0, c = Date.now(), d, _;
- function b() {
- if (_ = 0,
- e && typeof e == "function") {
- d = Date.now();
- var k = Math.max(0, Math.round((s - o) / ((d - c) / 1e3) * 100) / 100) || 0, j;
- s === 0 && a === 0 ? j = 1 : j = Math.floor(s / a * 100) / 100 || 0,
- c = d,
- o = s;
- try {
- e({
- loaded: s,
- total: a,
- speed: k,
- percent: j
- })
- } catch {}
- }
- }
- return function(k, j) {
- if (k && (s = k.loaded,
- a = k.total),
- j)
- clearTimeout(_),
- b();
- else {
- if (_)
- return;
- _ = setTimeout(b, i.options.ProgressInterval)
- }
- }
- }
- , getFileSize = function(a, e, i) {
- var o;
- if (typeof e.Body == "string" ? e.Body = new Blob([e.Body],{
- type: "text/plain"
- }) : e.Body instanceof ArrayBuffer && (e.Body = new Blob([e.Body])),
- e.Body && (e.Body instanceof Blob || e.Body.toString() === "[object File]" || e.Body.toString() === "[object Blob]"))
- o = e.Body.size;
- else {
- i(util$5.error(new Error("params body format error, Only allow File|Blob|String.")));
- return
- }
- e.ContentLength = o,
- i(null, o)
- }
- , getSkewTime = function(a) {
- return Date.now() + (a || 0)
- }
- , error = function(a, e) {
- var i = a;
- return a.message = a.message || null,
- typeof e == "string" ? (a.error = e,
- a.message = e) : typeof e == "object" && e !== null && (extend$1(a, e),
- (e.code || e.name) && (a.code = e.code || e.name),
- e.message && (a.message = e.message),
- e.stack && (a.stack = e.stack)),
- typeof Object.defineProperty == "function" && (Object.defineProperty(a, "name", {
- writable: !0,
- enumerable: !1
- }),
- Object.defineProperty(a, "message", {
- enumerable: !0
- })),
- a.name = e && e.name || a.name || a.code || "Error",
- a.code || (a.code = a.name),
- a.error || (a.error = clone(i)),
- a
- }
- , isNode = function() {
- return typeof window != "object" && typeof process == "object" && typeof commonjsRequire == "function"
- }
- , isCIHost = function(a) {
- return /^https?:\/\/([^/]+\.)?ci\.[^/]+/.test(a)
- }
- , util$5 = {
- noop,
- formatParams,
- apiWrapper,
- xml2json,
- json2xml,
- md5,
- clearKey,
- fileSlice,
- getBodyMd5,
- getFileMd5,
- binaryBase64,
- extend: extend$1,
- isArray,
- isInArray,
- makeArray,
- each,
- map: map$1,
- filter,
- clone,
- attr,
- uuid,
- camSafeUrlEncode,
- throttleOnProgress,
- getFileSize,
- getSkewTime,
- error,
- obj2str,
- getAuth: getAuth$1,
- parseSelectPayload,
- getSourceParams,
- isBrowser: !0,
- isNode,
- isCIHost
- }
- , util_1 = util$5
- , event$1 = {}
- , initEvent = function(a) {
- var e = {}
- , i = function(o) {
- return !e[o] && (e[o] = []),
- e[o]
- };
- a.on = function(o, s) {
- o === "task-list-update" && console.warn('warning: Event "' + o + '" has been deprecated. Please use "list-update" instead.'),
- i(o).push(s)
- }
- ,
- a.off = function(o, s) {
- for (var c = i(o), d = c.length - 1; d >= 0; d--)
- s === c[d] && c.splice(d, 1)
- }
- ,
- a.emit = function(o, s) {
- for (var c = i(o).map(function(_) {
- return _
- }), d = 0; d < c.length; d++)
- c[d](s)
- }
- }
- , EventProxy$1 = function() {
- initEvent(this)
- };
- event$1.init = initEvent;
- event$1.EventProxy = EventProxy$1;
- var task$1 = {}, util$4 = util_1, cacheKey = "cos_sdk_upload_cache", expires = 30 * 24 * 3600, cache, timer, getCache = function() {
- try {
- var a = JSON.parse(localStorage.getItem(cacheKey))
- } catch {}
- a || (a = []),
- cache = a
- }, setCache = function() {
- try {
- localStorage.setItem(cacheKey, JSON.stringify(cache))
- } catch {}
- }, init = function() {
- if (!cache) {
- getCache.call(this);
- for (var a = !1, e = Math.round(Date.now() / 1e3), i = cache.length - 1; i >= 0; i--) {
- var o = cache[i][2];
- (!o || o + expires < e) && (cache.splice(i, 1),
- a = !0)
- }
- a && setCache()
- }
- }, save = function() {
- timer || (timer = setTimeout(function() {
- setCache(),
- timer = null
- }, 400))
- }, mod = {
- using: {},
- setUsing: function(a) {
- mod.using[a] = !0
- },
- removeUsing: function(a) {
- delete mod.using[a]
- },
- getFileId: function(a, e, i, o) {
- return a.name && a.size && a.lastModifiedDate && e ? util$4.md5([a.name, a.size, a.lastModifiedDate, e, i, o].join("::")) : null
- },
- getUploadIdList: function(a) {
- if (!a)
- return null;
- init.call(this);
- for (var e = [], i = 0; i < cache.length; i++)
- cache[i][0] === a && e.push(cache[i][1]);
- return e.length ? e : null
- },
- saveUploadId: function(a, e, i) {
- if (init.call(this),
- !!a) {
- for (var o = cache.length - 1; o >= 0; o--) {
- var s = cache[o];
- s[0] === a && s[1] === e && cache.splice(o, 1)
- }
- cache.unshift([a, e, Math.round(Date.now() / 1e3)]),
- cache.length > i && cache.splice(i),
- save()
- }
- },
- removeUploadId: function(a) {
- init.call(this),
- delete mod.using[a];
- for (var e = cache.length - 1; e >= 0; e--)
- cache[e][1] === a && cache.splice(e, 1);
- save()
- }
- }, session$2 = mod, session$1 = session$2, util$3 = util_1, originApiMap = {}, transferToTaskMethod = function(a, e) {
- originApiMap[e] = a[e],
- a[e] = function(i, o) {
- i.SkipTask ? originApiMap[e].call(this, i, o) : this._addTask(e, i, o)
- }
- }, initTask = function(a) {
- var e = []
- , i = {}
- , o = 0
- , s = 0
- , c = function($) {
- var _e = {
- id: $.id,
- Bucket: $.Bucket,
- Region: $.Region,
- Key: $.Key,
- FilePath: $.FilePath,
- state: $.state,
- loaded: $.loaded,
- size: $.size,
- speed: $.speed,
- percent: $.percent,
- hashPercent: $.hashPercent,
- error: $.error
- };
- return $.FilePath && (_e.FilePath = $.FilePath),
- $._custom && (_e._custom = $._custom),
- _e
- }
- , d = function() {
- var $, _e = function() {
- $ = 0,
- a.emit("task-list-update", {
- list: util$3.map(e, c)
- }),
- a.emit("list-update", {
- list: util$3.map(e, c)
- })
- };
- return function() {
- $ || ($ = setTimeout(_e))
- }
- }()
- , _ = function() {
- if (!(e.length <= a.options.UploadQueueSize)) {
- for (var $ = 0; $ < s && $ < e.length && e.length > a.options.UploadQueueSize; ) {
- var _e = e[$].state === "waiting" || e[$].state === "checking" || e[$].state === "uploading";
- !e[$] || !_e ? (i[e[$].id] && delete i[e[$].id],
- e.splice($, 1),
- s--) : $++
- }
- d()
- }
- }
- , b = function() {
- if (!(o >= a.options.FileParallelLimit)) {
- for (; e[s] && e[s].state !== "waiting"; )
- s++;
- if (!(s >= e.length)) {
- var $ = e[s];
- s++,
- o++,
- $.state = "checking",
- $.params.onTaskStart && $.params.onTaskStart(c($)),
- !$.params.UploadData && ($.params.UploadData = {});
- var _e = util$3.formatParams($.api, $.params);
- originApiMap[$.api].call(a, _e, function(et, tt) {
- !a._isRunningTask($.id) || (($.state === "checking" || $.state === "uploading") && ($.state = et ? "error" : "success",
- et && ($.error = et),
- o--,
- d(),
- b(),
- $.callback && $.callback(et, tt),
- $.state === "success" && ($.params && (delete $.params.UploadData,
- delete $.params.Body,
- delete $.params),
- delete $.callback)),
- _())
- }),
- d(),
- setTimeout(b)
- }
- }
- }
- , k = function($, _e) {
- var et = i[$];
- if (!!et) {
- var tt = et && et.state === "waiting"
- , rt = et && (et.state === "checking" || et.state === "uploading");
- if (_e === "canceled" && et.state !== "canceled" || _e === "paused" && tt || _e === "paused" && rt) {
- if (_e === "paused" && et.params.Body && typeof et.params.Body.pipe == "function") {
- console.error("stream not support pause");
- return
- }
- et.state = _e,
- a.emit("inner-kill-task", {
- TaskId: $,
- toState: _e
- });
- try {
- var it = et && et.params && et.params.UploadData.UploadId
- } catch {}
- _e === "canceled" && it && session$1.removeUsing(it),
- d(),
- rt && (o--,
- b()),
- _e === "canceled" && (et.params && (delete et.params.UploadData,
- delete et.params.Body,
- delete et.params),
- delete et.callback)
- }
- _()
- }
- };
- a._addTasks = function($) {
- util$3.each($, function(_e) {
- a._addTask(_e.api, _e.params, _e.callback, !0)
- }),
- d()
- }
- ;
- var j = !0;
- a._addTask = function($, _e, et, tt) {
- _e = util$3.formatParams($, _e);
- var rt = util$3.uuid();
- _e.TaskId = rt,
- _e.onTaskReady && _e.onTaskReady(rt),
- _e.TaskReady && (_e.TaskReady(rt),
- j && console.warn('warning: Param "TaskReady" has been deprecated. Please use "onTaskReady" instead.'),
- j = !1);
- var it = {
- params: _e,
- callback: et,
- api: $,
- index: e.length,
- id: rt,
- Bucket: _e.Bucket,
- Region: _e.Region,
- Key: _e.Key,
- FilePath: _e.FilePath || "",
- state: "waiting",
- loaded: 0,
- size: 0,
- speed: 0,
- percent: 0,
- hashPercent: 0,
- error: null,
- _custom: _e._custom
- }
- , nt = _e.onHashProgress;
- _e.onHashProgress = function(at) {
- !a._isRunningTask(it.id) || (it.hashPercent = at.percent,
- nt && nt(at),
- d())
- }
- ;
- var ot = _e.onProgress;
- return _e.onProgress = function(at) {
- !a._isRunningTask(it.id) || (it.state === "checking" && (it.state = "uploading"),
- it.loaded = at.loaded,
- it.speed = at.speed,
- it.percent = at.percent,
- ot && ot(at),
- d())
- }
- ,
- util$3.getFileSize($, _e, function(at, st) {
- if (at)
- return et(util$3.error(at));
- i[rt] = it,
- e.push(it),
- it.size = st,
- !tt && d(),
- b(),
- _()
- }),
- rt
- }
- ,
- a._isRunningTask = function($) {
- var _e = i[$];
- return !!(_e && (_e.state === "checking" || _e.state === "uploading"))
- }
- ,
- a.getTaskList = function() {
- return util$3.map(e, c)
- }
- ,
- a.cancelTask = function($) {
- k($, "canceled")
- }
- ,
- a.pauseTask = function($) {
- k($, "paused")
- }
- ,
- a.restartTask = function($) {
- var _e = i[$];
- _e && (_e.state === "paused" || _e.state === "error") && (_e.state = "waiting",
- d(),
- s = Math.min(s, _e.index),
- b())
- }
- ,
- a.isUploadRunning = function() {
- return o || s < e.length
- }
- };
- task$1.transferToTaskMethod = transferToTaskMethod;
- task$1.init = initTask;
- var base$1 = {}
- , stringifyPrimitive = function(a) {
- switch (typeof a) {
- case "string":
- return a;
- case "boolean":
- return a ? "true" : "false";
- case "number":
- return isFinite(a) ? a : "";
- default:
- return ""
- }
- }
- , queryStringify = function(a, e, i, o) {
- return e = e || "&",
- i = i || "=",
- a === null && (a = void 0),
- typeof a == "object" ? Object.keys(a).map(function(s) {
- var c = encodeURIComponent(stringifyPrimitive(s)) + i;
- return Array.isArray(a[s]) ? a[s].map(function(d) {
- return c + encodeURIComponent(stringifyPrimitive(d))
- }).join(e) : c + encodeURIComponent(stringifyPrimitive(a[s]))
- }).filter(Boolean).join(e) : o ? encodeURIComponent(stringifyPrimitive(o)) + i + encodeURIComponent(stringifyPrimitive(a)) : ""
- }
- , xhrRes = function(a, e, i) {
- var o = {};
- return e.getAllResponseHeaders().trim().split(`
- `).forEach(function(s) {
- if (s) {
- var c = s.indexOf(":")
- , d = s.substr(0, c).trim().toLowerCase()
- , _ = s.substr(c + 1).trim();
- o[d] = _
- }
- }),
- {
- error: a,
- statusCode: e.status,
- statusMessage: e.statusText,
- headers: o,
- body: i
- }
- }
- , xhrBody = function(a, e) {
- return !e && e === "text" ? a.responseText : a.response
- }
- , request$1 = function(a, e) {
- var i = (a.method || "GET").toUpperCase()
- , o = a.url;
- if (a.qs) {
- var s = queryStringify(a.qs);
- s && (o += (o.indexOf("?") === -1 ? "?" : "&") + s)
- }
- var c = new XMLHttpRequest;
- if (c.open(i, o, !0),
- c.responseType = a.dataType || "text",
- a.xhrFields)
- for (var d in a.xhrFields)
- c[d] = a.xhrFields[d];
- var _ = a.headers;
- if (_)
- for (var b in _)
- _.hasOwnProperty(b) && b.toLowerCase() !== "content-length" && b.toLowerCase() !== "user-agent" && b.toLowerCase() !== "origin" && b.toLowerCase() !== "host" && c.setRequestHeader(b, _[b]);
- return a.onProgress && c.upload && (c.upload.onprogress = a.onProgress),
- a.onDownloadProgress && (c.onprogress = a.onDownloadProgress),
- a.timeout && (c.timeout = a.timeout),
- c.ontimeout = function(k) {
- var j = new Error("timeout");
- e(xhrRes(j, c))
- }
- ,
- c.onload = function() {
- e(xhrRes(null, c, xhrBody(c, a.dataType)))
- }
- ,
- c.onerror = function(k) {
- var j = xhrBody(c, a.dataType);
- if (j)
- e(xhrRes(null, c, j));
- else {
- var $ = c.statusText;
- !$ && c.status === 0 && ($ = new Error("CORS blocked or network error")),
- e(xhrRes($, c, j))
- }
- }
- ,
- c.send(a.body || ""),
- c
- }
- , request_1 = request$1
- , REQUEST = request_1
- , util$2 = util_1;
- function getService(a, e) {
- typeof a == "function" && (e = a,
- a = {});
- var i = this.options.Protocol || (util$2.isBrowser && location.protocol === "http:" ? "http:" : "https:")
- , o = this.options.ServiceDomain
- , s = a.AppId || this.options.appId
- , c = a.Region;
- o ? (o = o.replace(/\{\{AppId\}\}/ig, s || "").replace(/\{\{Region\}\}/ig, c || "").replace(/\{\{.*?\}\}/ig, ""),
- /^[a-zA-Z]+:\/\//.test(o) || (o = i + "//" + o),
- o.slice(-1) === "/" && (o = o.slice(0, -1))) : c ? o = i + "//cos." + c + ".myqcloud.com" : o = i + "//service.cos.myqcloud.com";
- var d = ""
- , _ = c ? "cos." + c + ".myqcloud.com" : "service.cos.myqcloud.com"
- , b = o.replace(/^https?:\/\/([^/]+)(\/.*)?$/, "$1");
- _ === b && (d = _),
- submitRequest.call(this, {
- Action: "name/cos:GetService",
- url: o,
- method: "GET",
- headers: a.Headers,
- SignHost: d
- }, function(k, j) {
- if (k)
- return e(k);
- var $ = j && j.ListAllMyBucketsResult && j.ListAllMyBucketsResult.Buckets && j.ListAllMyBucketsResult.Buckets.Bucket || [];
- $ = util$2.isArray($) ? $ : [$];
- var _e = j && j.ListAllMyBucketsResult && j.ListAllMyBucketsResult.Owner || {};
- e(null, {
- Buckets: $,
- Owner: _e,
- statusCode: j.statusCode,
- headers: j.headers
- })
- })
- }
- function putBucket(a, e) {
- var i = this
- , o = "";
- if (a.BucketAZConfig) {
- var s = {
- BucketAZConfig: a.BucketAZConfig
- };
- o = util$2.json2xml({
- CreateBucketConfiguration: s
- })
- }
- submitRequest.call(this, {
- Action: "name/cos:PutBucket",
- method: "PUT",
- Bucket: a.Bucket,
- Region: a.Region,
- headers: a.Headers,
- body: o
- }, function(c, d) {
- if (c)
- return e(c);
- var _ = getUrl({
- protocol: i.options.Protocol,
- domain: i.options.Domain,
- bucket: a.Bucket,
- region: a.Region,
- isLocation: !0
- });
- e(null, {
- Location: _,
- statusCode: d.statusCode,
- headers: d.headers
- })
- })
- }
- function headBucket(a, e) {
- submitRequest.call(this, {
- Action: "name/cos:HeadBucket",
- Bucket: a.Bucket,
- Region: a.Region,
- headers: a.Headers,
- method: "HEAD"
- }, e)
- }
- function getBucket(a, e) {
- var i = {};
- i.prefix = a.Prefix || "",
- i.delimiter = a.Delimiter,
- i.marker = a.Marker,
- i["max-keys"] = a.MaxKeys,
- i["encoding-type"] = a.EncodingType,
- submitRequest.call(this, {
- Action: "name/cos:GetBucket",
- ResourceKey: i.prefix,
- method: "GET",
- Bucket: a.Bucket,
- Region: a.Region,
- headers: a.Headers,
- qs: i
- }, function(o, s) {
- if (o)
- return e(o);
- var c = s.ListBucketResult || {}
- , d = c.Contents || []
- , _ = c.CommonPrefixes || [];
- d = util$2.isArray(d) ? d : [d],
- _ = util$2.isArray(_) ? _ : [_];
- var b = util$2.clone(c);
- util$2.extend(b, {
- Contents: d,
- CommonPrefixes: _,
- statusCode: s.statusCode,
- headers: s.headers
- }),
- e(null, b)
- })
- }
- function deleteBucket(a, e) {
- submitRequest.call(this, {
- Action: "name/cos:DeleteBucket",
- Bucket: a.Bucket,
- Region: a.Region,
- headers: a.Headers,
- method: "DELETE"
- }, function(i, o) {
- if (i && i.statusCode === 204)
- return e(null, {
- statusCode: i.statusCode
- });
- if (i)
- return e(i);
- e(null, {
- statusCode: o.statusCode,
- headers: o.headers
- })
- })
- }
- function putBucketAcl(a, e) {
- var i = a.Headers
- , o = "";
- if (a.AccessControlPolicy) {
- var s = util$2.clone(a.AccessControlPolicy || {})
- , c = s.Grants || s.Grant;
- c = util$2.isArray(c) ? c : [c],
- delete s.Grant,
- delete s.Grants,
- s.AccessControlList = {
- Grant: c
- },
- o = util$2.json2xml({
- AccessControlPolicy: s
- }),
- i["Content-Type"] = "application/xml",
- i["Content-MD5"] = util$2.binaryBase64(util$2.md5(o))
- }
- util$2.each(i, function(d, _) {
- _.indexOf("x-cos-grant-") === 0 && (i[_] = uniqGrant(i[_]))
- }),
- submitRequest.call(this, {
- Action: "name/cos:PutBucketACL",
- method: "PUT",
- Bucket: a.Bucket,
- Region: a.Region,
- headers: i,
- action: "acl",
- body: o
- }, function(d, _) {
- if (d)
- return e(d);
- e(null, {
- statusCode: _.statusCode,
- headers: _.headers
- })
- })
- }
- function getBucketAcl(a, e) {
- submitRequest.call(this, {
- Action: "name/cos:GetBucketACL",
- method: "GET",
- Bucket: a.Bucket,
- Region: a.Region,
- headers: a.Headers,
- action: "acl"
- }, function(i, o) {
- if (i)
- return e(i);
- var s = o.AccessControlPolicy || {}
- , c = s.Owner || {}
- , d = s.AccessControlList.Grant || [];
- d = util$2.isArray(d) ? d : [d];
- var _ = decodeAcl(s);
- o.headers && o.headers["x-cos-acl"] && (_.ACL = o.headers["x-cos-acl"]),
- _ = util$2.extend(_, {
- Owner: c,
- Grants: d,
- statusCode: o.statusCode,
- headers: o.headers
- }),
- e(null, _)
- })
- }
- function putBucketCors(a, e) {
- var i = a.CORSConfiguration || {}
- , o = i.CORSRules || a.CORSRules || [];
- o = util$2.clone(util$2.isArray(o) ? o : [o]),
- util$2.each(o, function(d) {
- util$2.each(["AllowedOrigin", "AllowedHeader", "AllowedMethod", "ExposeHeader"], function(_) {
- var b = _ + "s"
- , k = d[b] || d[_] || [];
- delete d[b],
- d[_] = util$2.isArray(k) ? k : [k]
- })
- });
- var s = util$2.json2xml({
- CORSConfiguration: {
- CORSRule: o
- }
- })
- , c = a.Headers;
- c["Content-Type"] = "application/xml",
- c["Content-MD5"] = util$2.binaryBase64(util$2.md5(s)),
- submitRequest.call(this, {
- Action: "name/cos:PutBucketCORS",
- method: "PUT",
- Bucket: a.Bucket,
- Region: a.Region,
- body: s,
- action: "cors",
- headers: c
- }, function(d, _) {
- if (d)
- return e(d);
- e(null, {
- statusCode: _.statusCode,
- headers: _.headers
- })
- })
- }
- function getBucketCors(a, e) {
- submitRequest.call(this, {
- Action: "name/cos:GetBucketCORS",
- method: "GET",
- Bucket: a.Bucket,
- Region: a.Region,
- headers: a.Headers,
- action: "cors"
- }, function(i, o) {
- if (i) {
- if (i.statusCode === 404 && i.error && i.error.Code === "NoSuchCORSConfiguration") {
- var s = {
- CORSRules: [],
- statusCode: i.statusCode
- };
- i.headers && (s.headers = i.headers),
- e(null, s)
- } else
- e(i);
- return
- }
- var c = o.CORSConfiguration || {}
- , d = c.CORSRules || c.CORSRule || [];
- d = util$2.clone(util$2.isArray(d) ? d : [d]),
- util$2.each(d, function(_) {
- util$2.each(["AllowedOrigin", "AllowedHeader", "AllowedMethod", "ExposeHeader"], function(b) {
- var k = b + "s"
- , j = _[k] || _[b] || [];
- delete _[b],
- _[k] = util$2.isArray(j) ? j : [j]
- })
- }),
- e(null, {
- CORSRules: d,
- statusCode: o.statusCode,
- headers: o.headers
- })
- })
- }
- function deleteBucketCors(a, e) {
- submitRequest.call(this, {
- Action: "name/cos:DeleteBucketCORS",
- method: "DELETE",
- Bucket: a.Bucket,
- Region: a.Region,
- headers: a.Headers,
- action: "cors"
- }, function(i, o) {
- if (i && i.statusCode === 204)
- return e(null, {
- statusCode: i.statusCode
- });
- if (i)
- return e(i);
- e(null, {
- statusCode: o.statusCode || i.statusCode,
- headers: o.headers
- })
- })
- }
- function getBucketLocation(a, e) {
- submitRequest.call(this, {
- Action: "name/cos:GetBucketLocation",
- method: "GET",
- Bucket: a.Bucket,
- Region: a.Region,
- headers: a.Headers,
- action: "location"
- }, e)
- }
- function putBucketPolicy(a, e) {
- var i = a.Policy;
- try {
- typeof i == "string" && (i = JSON.parse(i))
- } catch {}
- if (!i || typeof i == "string")
- return e(util$2.error(new Error("Policy format error")));
- var o = JSON.stringify(i);
- i.version || (i.version = "2.0");
- var s = a.Headers;
- s["Content-Type"] = "application/json",
- s["Content-MD5"] = util$2.binaryBase64(util$2.md5(o)),
- submitRequest.call(this, {
- Action: "name/cos:PutBucketPolicy",
- method: "PUT",
- Bucket: a.Bucket,
- Region: a.Region,
- action: "policy",
- body: o,
- headers: s
- }, function(c, d) {
- if (c && c.statusCode === 204)
- return e(null, {
- statusCode: c.statusCode
- });
- if (c)
- return e(c);
- e(null, {
- statusCode: d.statusCode,
- headers: d.headers
- })
- })
- }
- function getBucketPolicy(a, e) {
- submitRequest.call(this, {
- Action: "name/cos:GetBucketPolicy",
- method: "GET",
- Bucket: a.Bucket,
- Region: a.Region,
- headers: a.Headers,
- action: "policy",
- rawBody: !0
- }, function(i, o) {
- if (i)
- return i.statusCode && i.statusCode === 403 ? e(util$2.error(i, {
- ErrorStatus: "Access Denied"
- })) : i.statusCode && i.statusCode === 405 ? e(util$2.error(i, {
- ErrorStatus: "Method Not Allowed"
- })) : i.statusCode && i.statusCode === 404 ? e(util$2.error(i, {
- ErrorStatus: "Policy Not Found"
- })) : e(i);
- var s = {};
- try {
- s = JSON.parse(o.body)
- } catch {}
- e(null, {
- Policy: s,
- statusCode: o.statusCode,
- headers: o.headers
- })
- })
- }
- function deleteBucketPolicy(a, e) {
- submitRequest.call(this, {
- Action: "name/cos:DeleteBucketPolicy",
- method: "DELETE",
- Bucket: a.Bucket,
- Region: a.Region,
- headers: a.Headers,
- action: "policy"
- }, function(i, o) {
- if (i && i.statusCode === 204)
- return e(null, {
- statusCode: i.statusCode
- });
- if (i)
- return e(i);
- e(null, {
- statusCode: o.statusCode || i.statusCode,
- headers: o.headers
- })
- })
- }
- function putBucketTagging(a, e) {
- var i = a.Tagging || {}
- , o = i.TagSet || i.Tags || a.Tags || [];
- o = util$2.clone(util$2.isArray(o) ? o : [o]);
- var s = util$2.json2xml({
- Tagging: {
- TagSet: {
- Tag: o
- }
- }
- })
- , c = a.Headers;
- c["Content-Type"] = "application/xml",
- c["Content-MD5"] = util$2.binaryBase64(util$2.md5(s)),
- submitRequest.call(this, {
- Action: "name/cos:PutBucketTagging",
- method: "PUT",
- Bucket: a.Bucket,
- Region: a.Region,
- body: s,
- action: "tagging",
- headers: c
- }, function(d, _) {
- if (d && d.statusCode === 204)
- return e(null, {
- statusCode: d.statusCode
- });
- if (d)
- return e(d);
- e(null, {
- statusCode: _.statusCode,
- headers: _.headers
- })
- })
- }
- function getBucketTagging(a, e) {
- submitRequest.call(this, {
- Action: "name/cos:GetBucketTagging",
- method: "GET",
- Bucket: a.Bucket,
- Region: a.Region,
- headers: a.Headers,
- action: "tagging"
- }, function(i, o) {
- if (i) {
- if (i.statusCode === 404 && i.error && (i.error === "Not Found" || i.error.Code === "NoSuchTagSet")) {
- var s = {
- Tags: [],
- statusCode: i.statusCode
- };
- i.headers && (s.headers = i.headers),
- e(null, s)
- } else
- e(i);
- return
- }
- var c = [];
- try {
- c = o.Tagging.TagSet.Tag || []
- } catch {}
- c = util$2.clone(util$2.isArray(c) ? c : [c]),
- e(null, {
- Tags: c,
- statusCode: o.statusCode,
- headers: o.headers
- })
- })
- }
- function deleteBucketTagging(a, e) {
- submitRequest.call(this, {
- Action: "name/cos:DeleteBucketTagging",
- method: "DELETE",
- Bucket: a.Bucket,
- Region: a.Region,
- headers: a.Headers,
- action: "tagging"
- }, function(i, o) {
- if (i && i.statusCode === 204)
- return e(null, {
- statusCode: i.statusCode
- });
- if (i)
- return e(i);
- e(null, {
- statusCode: o.statusCode,
- headers: o.headers
- })
- })
- }
- function putBucketLifecycle(a, e) {
- var i = a.LifecycleConfiguration || {}
- , o = i.Rules || a.Rules || [];
- o = util$2.clone(o);
- var s = util$2.json2xml({
- LifecycleConfiguration: {
- Rule: o
- }
- })
- , c = a.Headers;
- c["Content-Type"] = "application/xml",
- c["Content-MD5"] = util$2.binaryBase64(util$2.md5(s)),
- submitRequest.call(this, {
- Action: "name/cos:PutBucketLifecycle",
- method: "PUT",
- Bucket: a.Bucket,
- Region: a.Region,
- body: s,
- action: "lifecycle",
- headers: c
- }, function(d, _) {
- if (d && d.statusCode === 204)
- return e(null, {
- statusCode: d.statusCode
- });
- if (d)
- return e(d);
- e(null, {
- statusCode: _.statusCode,
- headers: _.headers
- })
- })
- }
- function getBucketLifecycle(a, e) {
- submitRequest.call(this, {
- Action: "name/cos:GetBucketLifecycle",
- method: "GET",
- Bucket: a.Bucket,
- Region: a.Region,
- headers: a.Headers,
- action: "lifecycle"
- }, function(i, o) {
- if (i) {
- if (i.statusCode === 404 && i.error && i.error.Code === "NoSuchLifecycleConfiguration") {
- var s = {
- Rules: [],
- statusCode: i.statusCode
- };
- i.headers && (s.headers = i.headers),
- e(null, s)
- } else
- e(i);
- return
- }
- var c = [];
- try {
- c = o.LifecycleConfiguration.Rule || []
- } catch {}
- c = util$2.clone(util$2.isArray(c) ? c : [c]),
- e(null, {
- Rules: c,
- statusCode: o.statusCode,
- headers: o.headers
- })
- })
- }
- function deleteBucketLifecycle(a, e) {
- submitRequest.call(this, {
- Action: "name/cos:DeleteBucketLifecycle",
- method: "DELETE",
- Bucket: a.Bucket,
- Region: a.Region,
- headers: a.Headers,
- action: "lifecycle"
- }, function(i, o) {
- if (i && i.statusCode === 204)
- return e(null, {
- statusCode: i.statusCode
- });
- if (i)
- return e(i);
- e(null, {
- statusCode: o.statusCode,
- headers: o.headers
- })
- })
- }
- function putBucketVersioning(a, e) {
- if (!a.VersioningConfiguration) {
- e(util$2.error(new Error("missing param VersioningConfiguration")));
- return
- }
- var i = a.VersioningConfiguration || {}
- , o = util$2.json2xml({
- VersioningConfiguration: i
- })
- , s = a.Headers;
- s["Content-Type"] = "application/xml",
- s["Content-MD5"] = util$2.binaryBase64(util$2.md5(o)),
- submitRequest.call(this, {
- Action: "name/cos:PutBucketVersioning",
- method: "PUT",
- Bucket: a.Bucket,
- Region: a.Region,
- body: o,
- action: "versioning",
- headers: s
- }, function(c, d) {
- if (c && c.statusCode === 204)
- return e(null, {
- statusCode: c.statusCode
- });
- if (c)
- return e(c);
- e(null, {
- statusCode: d.statusCode,
- headers: d.headers
- })
- })
- }
- function getBucketVersioning(a, e) {
- submitRequest.call(this, {
- Action: "name/cos:GetBucketVersioning",
- method: "GET",
- Bucket: a.Bucket,
- Region: a.Region,
- headers: a.Headers,
- action: "versioning"
- }, function(i, o) {
- i || !o.VersioningConfiguration && (o.VersioningConfiguration = {}),
- e(i, o)
- })
- }
- function putBucketReplication(a, e) {
- var i = util$2.clone(a.ReplicationConfiguration)
- , o = util$2.json2xml({
- ReplicationConfiguration: i
- });
- o = o.replace(/<(\/?)Rules>/ig, "<$1Rule>"),
- o = o.replace(/<(\/?)Tags>/ig, "<$1Tag>");
- var s = a.Headers;
- s["Content-Type"] = "application/xml",
- s["Content-MD5"] = util$2.binaryBase64(util$2.md5(o)),
- submitRequest.call(this, {
- Action: "name/cos:PutBucketReplication",
- method: "PUT",
- Bucket: a.Bucket,
- Region: a.Region,
- body: o,
- action: "replication",
- headers: s
- }, function(c, d) {
- if (c && c.statusCode === 204)
- return e(null, {
- statusCode: c.statusCode
- });
- if (c)
- return e(c);
- e(null, {
- statusCode: d.statusCode,
- headers: d.headers
- })
- })
- }
- function getBucketReplication(a, e) {
- submitRequest.call(this, {
- Action: "name/cos:GetBucketReplication",
- method: "GET",
- Bucket: a.Bucket,
- Region: a.Region,
- headers: a.Headers,
- action: "replication"
- }, function(i, o) {
- if (i) {
- if (i.statusCode === 404 && i.error && (i.error === "Not Found" || i.error.Code === "ReplicationConfigurationnotFoundError")) {
- var s = {
- ReplicationConfiguration: {
- Rules: []
- },
- statusCode: i.statusCode
- };
- i.headers && (s.headers = i.headers),
- e(null, s)
- } else
- e(i);
- return
- }
- !o.ReplicationConfiguration && (o.ReplicationConfiguration = {}),
- o.ReplicationConfiguration.Rule && (o.ReplicationConfiguration.Rules = util$2.makeArray(o.ReplicationConfiguration.Rule),
- delete o.ReplicationConfiguration.Rule),
- e(i, o)
- })
- }
- function deleteBucketReplication(a, e) {
- submitRequest.call(this, {
- Action: "name/cos:DeleteBucketReplication",
- method: "DELETE",
- Bucket: a.Bucket,
- Region: a.Region,
- headers: a.Headers,
- action: "replication"
- }, function(i, o) {
- if (i && i.statusCode === 204)
- return e(null, {
- statusCode: i.statusCode
- });
- if (i)
- return e(i);
- e(null, {
- statusCode: o.statusCode,
- headers: o.headers
- })
- })
- }
- function putBucketWebsite(a, e) {
- if (!a.WebsiteConfiguration) {
- e(util$2.error(new Error("missing param WebsiteConfiguration")));
- return
- }
- var i = util$2.clone(a.WebsiteConfiguration || {})
- , o = i.RoutingRules || i.RoutingRule || [];
- o = util$2.isArray(o) ? o : [o],
- delete i.RoutingRule,
- delete i.RoutingRules,
- o.length && (i.RoutingRules = {
- RoutingRule: o
- });
- var s = util$2.json2xml({
- WebsiteConfiguration: i
- })
- , c = a.Headers;
- c["Content-Type"] = "application/xml",
- c["Content-MD5"] = util$2.binaryBase64(util$2.md5(s)),
- submitRequest.call(this, {
- Action: "name/cos:PutBucketWebsite",
- method: "PUT",
- Bucket: a.Bucket,
- Region: a.Region,
- body: s,
- action: "website",
- headers: c
- }, function(d, _) {
- if (d && d.statusCode === 204)
- return e(null, {
- statusCode: d.statusCode
- });
- if (d)
- return e(d);
- e(null, {
- statusCode: _.statusCode,
- headers: _.headers
- })
- })
- }
- function getBucketWebsite(a, e) {
- submitRequest.call(this, {
- Action: "name/cos:GetBucketWebsite",
- method: "GET",
- Bucket: a.Bucket,
- Region: a.Region,
- Key: a.Key,
- headers: a.Headers,
- action: "website"
- }, function(i, o) {
- if (i) {
- if (i.statusCode === 404 && i.error.Code === "NoSuchWebsiteConfiguration") {
- var s = {
- WebsiteConfiguration: {},
- statusCode: i.statusCode
- };
- i.headers && (s.headers = i.headers),
- e(null, s)
- } else
- e(i);
- return
- }
- var c = o.WebsiteConfiguration || {};
- if (c.RoutingRules) {
- var d = util$2.clone(c.RoutingRules.RoutingRule || []);
- d = util$2.makeArray(d),
- c.RoutingRules = d
- }
- e(null, {
- WebsiteConfiguration: c,
- statusCode: o.statusCode,
- headers: o.headers
- })
- })
- }
- function deleteBucketWebsite(a, e) {
- submitRequest.call(this, {
- Action: "name/cos:DeleteBucketWebsite",
- method: "DELETE",
- Bucket: a.Bucket,
- Region: a.Region,
- headers: a.Headers,
- action: "website"
- }, function(i, o) {
- if (i && i.statusCode === 204)
- return e(null, {
- statusCode: i.statusCode
- });
- if (i)
- return e(i);
- e(null, {
- statusCode: o.statusCode,
- headers: o.headers
- })
- })
- }
- function putBucketReferer(a, e) {
- if (!a.RefererConfiguration) {
- e(util$2.error(new Error("missing param RefererConfiguration")));
- return
- }
- var i = util$2.clone(a.RefererConfiguration || {})
- , o = i.DomainList || {}
- , s = o.Domains || o.Domain || [];
- s = util$2.isArray(s) ? s : [s],
- s.length && (i.DomainList = {
- Domain: s
- });
- var c = util$2.json2xml({
- RefererConfiguration: i
- })
- , d = a.Headers;
- d["Content-Type"] = "application/xml",
- d["Content-MD5"] = util$2.binaryBase64(util$2.md5(c)),
- submitRequest.call(this, {
- Action: "name/cos:PutBucketReferer",
- method: "PUT",
- Bucket: a.Bucket,
- Region: a.Region,
- body: c,
- action: "referer",
- headers: d
- }, function(_, b) {
- if (_ && _.statusCode === 204)
- return e(null, {
- statusCode: _.statusCode
- });
- if (_)
- return e(_);
- e(null, {
- statusCode: b.statusCode,
- headers: b.headers
- })
- })
- }
- function getBucketReferer(a, e) {
- submitRequest.call(this, {
- Action: "name/cos:GetBucketReferer",
- method: "GET",
- Bucket: a.Bucket,
- Region: a.Region,
- Key: a.Key,
- headers: a.Headers,
- action: "referer"
- }, function(i, o) {
- if (i) {
- if (i.statusCode === 404 && i.error.Code === "NoSuchRefererConfiguration") {
- var s = {
- WebsiteConfiguration: {},
- statusCode: i.statusCode
- };
- i.headers && (s.headers = i.headers),
- e(null, s)
- } else
- e(i);
- return
- }
- var c = o.RefererConfiguration || {};
- if (c.DomainList) {
- var d = util$2.makeArray(c.DomainList.Domain || []);
- c.DomainList = {
- Domains: d
- }
- }
- e(null, {
- RefererConfiguration: c,
- statusCode: o.statusCode,
- headers: o.headers
- })
- })
- }
- function putBucketDomain(a, e) {
- var i = a.DomainConfiguration || {}
- , o = i.DomainRule || a.DomainRule || [];
- o = util$2.clone(o);
- var s = util$2.json2xml({
- DomainConfiguration: {
- DomainRule: o
- }
- })
- , c = a.Headers;
- c["Content-Type"] = "application/xml",
- c["Content-MD5"] = util$2.binaryBase64(util$2.md5(s)),
- submitRequest.call(this, {
- Action: "name/cos:PutBucketDomain",
- method: "PUT",
- Bucket: a.Bucket,
- Region: a.Region,
- body: s,
- action: "domain",
- headers: c
- }, function(d, _) {
- if (d && d.statusCode === 204)
- return e(null, {
- statusCode: d.statusCode
- });
- if (d)
- return e(d);
- e(null, {
- statusCode: _.statusCode,
- headers: _.headers
- })
- })
- }
- function getBucketDomain(a, e) {
- submitRequest.call(this, {
- Action: "name/cos:GetBucketDomain",
- method: "GET",
- Bucket: a.Bucket,
- Region: a.Region,
- headers: a.Headers,
- action: "domain"
- }, function(i, o) {
- if (i)
- return e(i);
- var s = [];
- try {
- s = o.DomainConfiguration.DomainRule || []
- } catch {}
- s = util$2.clone(util$2.isArray(s) ? s : [s]),
- e(null, {
- DomainRule: s,
- statusCode: o.statusCode,
- headers: o.headers
- })
- })
- }
- function deleteBucketDomain(a, e) {
- submitRequest.call(this, {
- Action: "name/cos:DeleteBucketDomain",
- method: "DELETE",
- Bucket: a.Bucket,
- Region: a.Region,
- headers: a.Headers,
- action: "domain"
- }, function(i, o) {
- if (i && i.statusCode === 204)
- return e(null, {
- statusCode: i.statusCode
- });
- if (i)
- return e(i);
- e(null, {
- statusCode: o.statusCode,
- headers: o.headers
- })
- })
- }
- function putBucketOrigin(a, e) {
- var i = a.OriginConfiguration || {}
- , o = i.OriginRule || a.OriginRule || [];
- o = util$2.clone(o);
- var s = util$2.json2xml({
- OriginConfiguration: {
- OriginRule: o
- }
- })
- , c = a.Headers;
- c["Content-Type"] = "application/xml",
- c["Content-MD5"] = util$2.binaryBase64(util$2.md5(s)),
- submitRequest.call(this, {
- Action: "name/cos:PutBucketOrigin",
- method: "PUT",
- Bucket: a.Bucket,
- Region: a.Region,
- body: s,
- action: "origin",
- headers: c
- }, function(d, _) {
- if (d && d.statusCode === 204)
- return e(null, {
- statusCode: d.statusCode
- });
- if (d)
- return e(d);
- e(null, {
- statusCode: _.statusCode,
- headers: _.headers
- })
- })
- }
- function getBucketOrigin(a, e) {
- submitRequest.call(this, {
- Action: "name/cos:GetBucketOrigin",
- method: "GET",
- Bucket: a.Bucket,
- Region: a.Region,
- headers: a.Headers,
- action: "origin"
- }, function(i, o) {
- if (i)
- return e(i);
- var s = [];
- try {
- s = o.OriginConfiguration.OriginRule || []
- } catch {}
- s = util$2.clone(util$2.isArray(s) ? s : [s]),
- e(null, {
- OriginRule: s,
- statusCode: o.statusCode,
- headers: o.headers
- })
- })
- }
- function deleteBucketOrigin(a, e) {
- submitRequest.call(this, {
- Action: "name/cos:DeleteBucketOrigin",
- method: "DELETE",
- Bucket: a.Bucket,
- Region: a.Region,
- headers: a.Headers,
- action: "origin"
- }, function(i, o) {
- if (i && i.statusCode === 204)
- return e(null, {
- statusCode: i.statusCode
- });
- if (i)
- return e(i);
- e(null, {
- statusCode: o.statusCode,
- headers: o.headers
- })
- })
- }
- function putBucketLogging(a, e) {
- var i = util$2.json2xml({
- BucketLoggingStatus: a.BucketLoggingStatus || ""
- })
- , o = a.Headers;
- o["Content-Type"] = "application/xml",
- o["Content-MD5"] = util$2.binaryBase64(util$2.md5(i)),
- submitRequest.call(this, {
- Action: "name/cos:PutBucketLogging",
- method: "PUT",
- Bucket: a.Bucket,
- Region: a.Region,
- body: i,
- action: "logging",
- headers: o
- }, function(s, c) {
- if (s && s.statusCode === 204)
- return e(null, {
- statusCode: s.statusCode
- });
- if (s)
- return e(s);
- e(null, {
- statusCode: c.statusCode,
- headers: c.headers
- })
- })
- }
- function getBucketLogging(a, e) {
- submitRequest.call(this, {
- Action: "name/cos:GetBucketLogging",
- method: "GET",
- Bucket: a.Bucket,
- Region: a.Region,
- headers: a.Headers,
- action: "logging"
- }, function(i, o) {
- if (i)
- return e(i);
- e(null, {
- BucketLoggingStatus: o.BucketLoggingStatus,
- statusCode: o.statusCode,
- headers: o.headers
- })
- })
- }
- function putBucketInventory(a, e) {
- var i = util$2.clone(a.InventoryConfiguration);
- if (i.OptionalFields) {
- var o = i.OptionalFields || [];
- i.OptionalFields = {
- Field: o
- }
- }
- if (i.Destination && i.Destination.COSBucketDestination && i.Destination.COSBucketDestination.Encryption) {
- var s = i.Destination.COSBucketDestination.Encryption;
- Object.keys(s).indexOf("SSECOS") > -1 && (s["SSE-COS"] = s.SSECOS,
- delete s.SSECOS)
- }
- var c = util$2.json2xml({
- InventoryConfiguration: i
- })
- , d = a.Headers;
- d["Content-Type"] = "application/xml",
- d["Content-MD5"] = util$2.binaryBase64(util$2.md5(c)),
- submitRequest.call(this, {
- Action: "name/cos:PutBucketInventory",
- method: "PUT",
- Bucket: a.Bucket,
- Region: a.Region,
- body: c,
- action: "inventory",
- qs: {
- id: a.Id
- },
- headers: d
- }, function(_, b) {
- if (_ && _.statusCode === 204)
- return e(null, {
- statusCode: _.statusCode
- });
- if (_)
- return e(_);
- e(null, {
- statusCode: b.statusCode,
- headers: b.headers
- })
- })
- }
- function getBucketInventory(a, e) {
- submitRequest.call(this, {
- Action: "name/cos:GetBucketInventory",
- method: "GET",
- Bucket: a.Bucket,
- Region: a.Region,
- headers: a.Headers,
- action: "inventory",
- qs: {
- id: a.Id
- }
- }, function(i, o) {
- if (i)
- return e(i);
- var s = o.InventoryConfiguration;
- if (s && s.OptionalFields && s.OptionalFields.Field) {
- var c = s.OptionalFields.Field;
- util$2.isArray(c) || (c = [c]),
- s.OptionalFields = c
- }
- if (s.Destination && s.Destination.COSBucketDestination && s.Destination.COSBucketDestination.Encryption) {
- var d = s.Destination.COSBucketDestination.Encryption;
- Object.keys(d).indexOf("SSE-COS") > -1 && (d.SSECOS = d["SSE-COS"],
- delete d["SSE-COS"])
- }
- e(null, {
- InventoryConfiguration: s,
- statusCode: o.statusCode,
- headers: o.headers
- })
- })
- }
- function listBucketInventory(a, e) {
- submitRequest.call(this, {
- Action: "name/cos:ListBucketInventory",
- method: "GET",
- Bucket: a.Bucket,
- Region: a.Region,
- headers: a.Headers,
- action: "inventory",
- qs: {
- "continuation-token": a.ContinuationToken
- }
- }, function(i, o) {
- if (i)
- return e(i);
- var s = o.ListInventoryConfigurationResult
- , c = s.InventoryConfiguration || [];
- c = util$2.isArray(c) ? c : [c],
- delete s.InventoryConfiguration,
- util$2.each(c, function(d) {
- if (d && d.OptionalFields && d.OptionalFields.Field) {
- var _ = d.OptionalFields.Field;
- util$2.isArray(_) || (_ = [_]),
- d.OptionalFields = _
- }
- if (d.Destination && d.Destination.COSBucketDestination && d.Destination.COSBucketDestination.Encryption) {
- var b = d.Destination.COSBucketDestination.Encryption;
- Object.keys(b).indexOf("SSE-COS") > -1 && (b.SSECOS = b["SSE-COS"],
- delete b["SSE-COS"])
- }
- }),
- s.InventoryConfigurations = c,
- util$2.extend(s, {
- statusCode: o.statusCode,
- headers: o.headers
- }),
- e(null, s)
- })
- }
- function deleteBucketInventory(a, e) {
- submitRequest.call(this, {
- Action: "name/cos:DeleteBucketInventory",
- method: "DELETE",
- Bucket: a.Bucket,
- Region: a.Region,
- headers: a.Headers,
- action: "inventory",
- qs: {
- id: a.Id
- }
- }, function(i, o) {
- if (i && i.statusCode === 204)
- return e(null, {
- statusCode: i.statusCode
- });
- if (i)
- return e(i);
- e(null, {
- statusCode: o.statusCode,
- headers: o.headers
- })
- })
- }
- function putBucketAccelerate(a, e) {
- if (!a.AccelerateConfiguration) {
- e(util$2.error(new Error("missing param AccelerateConfiguration")));
- return
- }
- var i = {
- AccelerateConfiguration: a.AccelerateConfiguration || {}
- }
- , o = util$2.json2xml(i)
- , s = {};
- s["Content-Type"] = "application/xml",
- s["Content-MD5"] = util$2.binaryBase64(util$2.md5(o)),
- submitRequest.call(this, {
- Action: "name/cos:PutBucketAccelerate",
- method: "PUT",
- Bucket: a.Bucket,
- Region: a.Region,
- body: o,
- action: "accelerate",
- headers: s
- }, function(c, d) {
- if (c)
- return e(c);
- e(null, {
- statusCode: d.statusCode,
- headers: d.headers
- })
- })
- }
- function getBucketAccelerate(a, e) {
- submitRequest.call(this, {
- Action: "name/cos:GetBucketAccelerate",
- method: "GET",
- Bucket: a.Bucket,
- Region: a.Region,
- action: "accelerate"
- }, function(i, o) {
- i || !o.AccelerateConfiguration && (o.AccelerateConfiguration = {}),
- e(i, o)
- })
- }
- function putBucketEncryption(a, e) {
- var i = a.ServerSideEncryptionConfiguration || {}
- , o = i.Rule || i.Rules || []
- , s = util$2.json2xml({
- ServerSideEncryptionConfiguration: {
- Rule: o
- }
- })
- , c = a.Headers;
- c["Content-Type"] = "application/xml",
- c["Content-MD5"] = util$2.binaryBase64(util$2.md5(s)),
- submitRequest.call(this, {
- Action: "name/cos:PutBucketEncryption",
- method: "PUT",
- Bucket: a.Bucket,
- Region: a.Region,
- body: s,
- action: "encryption",
- headers: c
- }, function(d, _) {
- if (d && d.statusCode === 204)
- return e(null, {
- statusCode: d.statusCode
- });
- if (d)
- return e(d);
- e(null, {
- statusCode: _.statusCode,
- headers: _.headers
- })
- })
- }
- function getBucketEncryption(a, e) {
- submitRequest.call(this, {
- Action: "name/cos:GetBucketEncryption",
- method: "GET",
- Bucket: a.Bucket,
- Region: a.Region,
- headers: a.Headers,
- action: "encryption"
- }, function(i, o) {
- if (i) {
- if (i.statusCode === 404 && i.code === "NoSuchEncryptionConfiguration") {
- var s = {
- EncryptionConfiguration: {
- Rules: []
- },
- statusCode: i.statusCode
- };
- i.headers && (s.headers = i.headers),
- e(null, s)
- } else
- e(i);
- return
- }
- var c = util$2.makeArray(o.EncryptionConfiguration && o.EncryptionConfiguration.Rule || []);
- o.EncryptionConfiguration = {
- Rules: c
- },
- e(i, o)
- })
- }
- function deleteBucketEncryption(a, e) {
- submitRequest.call(this, {
- Action: "name/cos:DeleteBucketReplication",
- method: "DELETE",
- Bucket: a.Bucket,
- Region: a.Region,
- headers: a.Headers,
- action: "encryption"
- }, function(i, o) {
- if (i && i.statusCode === 204)
- return e(null, {
- statusCode: i.statusCode
- });
- if (i)
- return e(i);
- e(null, {
- statusCode: o.statusCode,
- headers: o.headers
- })
- })
- }
- function headObject(a, e) {
- submitRequest.call(this, {
- Action: "name/cos:HeadObject",
- method: "HEAD",
- Bucket: a.Bucket,
- Region: a.Region,
- Key: a.Key,
- VersionId: a.VersionId,
- headers: a.Headers
- }, function(i, o) {
- if (i) {
- var s = i.statusCode;
- return a.Headers["If-Modified-Since"] && s && s === 304 ? e(null, {
- NotModified: !0,
- statusCode: s
- }) : e(i)
- }
- o.ETag = util$2.attr(o.headers, "etag", ""),
- e(null, o)
- })
- }
- function listObjectVersions(a, e) {
- var i = {};
- i.prefix = a.Prefix || "",
- i.delimiter = a.Delimiter,
- i["key-marker"] = a.KeyMarker,
- i["version-id-marker"] = a.VersionIdMarker,
- i["max-keys"] = a.MaxKeys,
- i["encoding-type"] = a.EncodingType,
- submitRequest.call(this, {
- Action: "name/cos:GetBucketObjectVersions",
- ResourceKey: i.prefix,
- method: "GET",
- Bucket: a.Bucket,
- Region: a.Region,
- headers: a.Headers,
- qs: i,
- action: "versions"
- }, function(o, s) {
- if (o)
- return e(o);
- var c = s.ListVersionsResult || {}
- , d = c.DeleteMarker || [];
- d = util$2.isArray(d) ? d : [d];
- var _ = c.Version || [];
- _ = util$2.isArray(_) ? _ : [_];
- var b = util$2.clone(c);
- delete b.DeleteMarker,
- delete b.Version,
- util$2.extend(b, {
- DeleteMarkers: d,
- Versions: _,
- statusCode: s.statusCode,
- headers: s.headers
- }),
- e(null, b)
- })
- }
- function getObject(a, e) {
- var i = a.Query || {}
- , o = a.QueryString || ""
- , s = util$2.throttleOnProgress.call(this, 0, a.onProgress);
- i["response-content-type"] = a.ResponseContentType,
- i["response-content-language"] = a.ResponseContentLanguage,
- i["response-expires"] = a.ResponseExpires,
- i["response-cache-control"] = a.ResponseCacheControl,
- i["response-content-disposition"] = a.ResponseContentDisposition,
- i["response-content-encoding"] = a.ResponseContentEncoding,
- submitRequest.call(this, {
- Action: "name/cos:GetObject",
- method: "GET",
- Bucket: a.Bucket,
- Region: a.Region,
- Key: a.Key,
- VersionId: a.VersionId,
- DataType: a.DataType,
- headers: a.Headers,
- qs: i,
- qsStr: o,
- rawBody: !0,
- onDownloadProgress: s
- }, function(c, d) {
- if (s(null, !0),
- c) {
- var _ = c.statusCode;
- return a.Headers["If-Modified-Since"] && _ && _ === 304 ? e(null, {
- NotModified: !0
- }) : e(c)
- }
- e(null, {
- Body: d.body,
- ETag: util$2.attr(d.headers, "etag", ""),
- statusCode: d.statusCode,
- headers: d.headers
- })
- })
- }
- function putObject(a, e) {
- var i = this
- , o = a.ContentLength
- , s = util$2.throttleOnProgress.call(i, o, a.onProgress)
- , c = a.Headers;
- !c["Cache-Control"] && !c["cache-control"] && (c["Cache-Control"] = ""),
- !c["Content-Type"] && !c["content-type"] && (c["Content-Type"] = a.Body && a.Body.type || "");
- var d = a.UploadAddMetaMd5 || i.options.UploadAddMetaMd5 || i.options.UploadCheckContentMd5;
- util$2.getBodyMd5(d, a.Body, function(_) {
- _ && (i.options.UploadCheckContentMd5 && (c["Content-MD5"] = util$2.binaryBase64(_)),
- (a.UploadAddMetaMd5 || i.options.UploadAddMetaMd5) && (c["x-cos-meta-md5"] = _)),
- a.ContentLength !== void 0 && (c["Content-Length"] = a.ContentLength),
- s(null, !0),
- submitRequest.call(i, {
- Action: "name/cos:PutObject",
- TaskId: a.TaskId,
- method: "PUT",
- Bucket: a.Bucket,
- Region: a.Region,
- Key: a.Key,
- headers: a.Headers,
- qs: a.Query,
- body: a.Body,
- onProgress: s
- }, function(b, k) {
- if (b)
- return s(null, !0),
- e(b);
- s({
- loaded: o,
- total: o
- }, !0);
- var j = getUrl({
- ForcePathStyle: i.options.ForcePathStyle,
- protocol: i.options.Protocol,
- domain: i.options.Domain,
- bucket: a.Bucket,
- region: i.options.UseAccelerate ? "accelerate" : a.Region,
- object: a.Key
- });
- j = j.substr(j.indexOf("://") + 3),
- k.Location = j,
- k.ETag = util$2.attr(k.headers, "etag", ""),
- e(null, k)
- })
- }, a.onHashProgress)
- }
- function deleteObject(a, e) {
- submitRequest.call(this, {
- Action: "name/cos:DeleteObject",
- method: "DELETE",
- Bucket: a.Bucket,
- Region: a.Region,
- Key: a.Key,
- headers: a.Headers,
- VersionId: a.VersionId,
- action: a.Recursive ? "recursive" : ""
- }, function(i, o) {
- if (i) {
- var s = i.statusCode;
- return s && s === 404 ? e(null, {
- BucketNotFound: !0,
- statusCode: s
- }) : e(i)
- }
- e(null, {
- statusCode: o.statusCode,
- headers: o.headers
- })
- })
- }
- function getObjectAcl(a, e) {
- submitRequest.call(this, {
- Action: "name/cos:GetObjectACL",
- method: "GET",
- Bucket: a.Bucket,
- Region: a.Region,
- Key: a.Key,
- headers: a.Headers,
- action: "acl"
- }, function(i, o) {
- if (i)
- return e(i);
- var s = o.AccessControlPolicy || {}
- , c = s.Owner || {}
- , d = s.AccessControlList && s.AccessControlList.Grant || [];
- d = util$2.isArray(d) ? d : [d];
- var _ = decodeAcl(s);
- delete _.GrantWrite,
- o.headers && o.headers["x-cos-acl"] && (_.ACL = o.headers["x-cos-acl"]),
- _ = util$2.extend(_, {
- Owner: c,
- Grants: d,
- statusCode: o.statusCode,
- headers: o.headers
- }),
- e(null, _)
- })
- }
- function putObjectAcl(a, e) {
- var i = a.Headers
- , o = "";
- if (a.AccessControlPolicy) {
- var s = util$2.clone(a.AccessControlPolicy || {})
- , c = s.Grants || s.Grant;
- c = util$2.isArray(c) ? c : [c],
- delete s.Grant,
- delete s.Grants,
- s.AccessControlList = {
- Grant: c
- },
- o = util$2.json2xml({
- AccessControlPolicy: s
- }),
- i["Content-Type"] = "application/xml",
- i["Content-MD5"] = util$2.binaryBase64(util$2.md5(o))
- }
- util$2.each(i, function(d, _) {
- _.indexOf("x-cos-grant-") === 0 && (i[_] = uniqGrant(i[_]))
- }),
- submitRequest.call(this, {
- Action: "name/cos:PutObjectACL",
- method: "PUT",
- Bucket: a.Bucket,
- Region: a.Region,
- Key: a.Key,
- action: "acl",
- headers: i,
- body: o
- }, function(d, _) {
- if (d)
- return e(d);
- e(null, {
- statusCode: _.statusCode,
- headers: _.headers
- })
- })
- }
- function optionsObject(a, e) {
- var i = a.Headers;
- i.Origin = a.Origin,
- i["Access-Control-Request-Method"] = a.AccessControlRequestMethod,
- i["Access-Control-Request-Headers"] = a.AccessControlRequestHeaders,
- submitRequest.call(this, {
- Action: "name/cos:OptionsObject",
- method: "OPTIONS",
- Bucket: a.Bucket,
- Region: a.Region,
- Key: a.Key,
- headers: i
- }, function(o, s) {
- if (o)
- return o.statusCode && o.statusCode === 403 ? e(null, {
- OptionsForbidden: !0,
- statusCode: o.statusCode
- }) : e(o);
- var c = s.headers || {};
- e(null, {
- AccessControlAllowOrigin: c["access-control-allow-origin"],
- AccessControlAllowMethods: c["access-control-allow-methods"],
- AccessControlAllowHeaders: c["access-control-allow-headers"],
- AccessControlExposeHeaders: c["access-control-expose-headers"],
- AccessControlMaxAge: c["access-control-max-age"],
- statusCode: s.statusCode,
- headers: s.headers
- })
- })
- }
- function putObjectCopy(a, e) {
- var i = this
- , o = a.Headers;
- !o["Cache-Control"] && !o["cache-control"] && (o["Cache-Control"] = "");
- var s = a.CopySource || ""
- , c = util$2.getSourceParams.call(this, s);
- if (!c) {
- e(util$2.error(new Error("CopySource format error")));
- return
- }
- var d = c[1]
- , _ = c[3]
- , b = decodeURIComponent(c[4]);
- submitRequest.call(this, {
- Scope: [{
- action: "name/cos:GetObject",
- bucket: d,
- region: _,
- prefix: b
- }, {
- action: "name/cos:PutObject",
- bucket: a.Bucket,
- region: a.Region,
- prefix: a.Key
- }],
- method: "PUT",
- Bucket: a.Bucket,
- Region: a.Region,
- Key: a.Key,
- VersionId: a.VersionId,
- headers: a.Headers
- }, function(k, j) {
- if (k)
- return e(k);
- var $ = util$2.clone(j.CopyObjectResult || {})
- , _e = getUrl({
- ForcePathStyle: i.options.ForcePathStyle,
- protocol: i.options.Protocol,
- domain: i.options.Domain,
- bucket: a.Bucket,
- region: a.Region,
- object: a.Key,
- isLocation: !0
- });
- util$2.extend($, {
- Location: _e,
- statusCode: j.statusCode,
- headers: j.headers
- }),
- e(null, $)
- })
- }
- function uploadPartCopy(a, e) {
- var i = a.CopySource || ""
- , o = util$2.getSourceParams.call(this, i);
- if (!o) {
- e(util$2.error(new Error("CopySource format error")));
- return
- }
- var s = o[1]
- , c = o[3]
- , d = decodeURIComponent(o[4]);
- submitRequest.call(this, {
- Scope: [{
- action: "name/cos:GetObject",
- bucket: s,
- region: c,
- prefix: d
- }, {
- action: "name/cos:PutObject",
- bucket: a.Bucket,
- region: a.Region,
- prefix: a.Key
- }],
- method: "PUT",
- Bucket: a.Bucket,
- Region: a.Region,
- Key: a.Key,
- VersionId: a.VersionId,
- qs: {
- partNumber: a.PartNumber,
- uploadId: a.UploadId
- },
- headers: a.Headers
- }, function(_, b) {
- if (_)
- return e(_);
- var k = util$2.clone(b.CopyPartResult || {});
- util$2.extend(k, {
- statusCode: b.statusCode,
- headers: b.headers
- }),
- e(null, k)
- })
- }
- function deleteMultipleObject(a, e) {
- var i = a.Objects || []
- , o = a.Quiet;
- i = util$2.isArray(i) ? i : [i];
- var s = util$2.json2xml({
- Delete: {
- Object: i,
- Quiet: o || !1
- }
- })
- , c = a.Headers;
- c["Content-Type"] = "application/xml",
- c["Content-MD5"] = util$2.binaryBase64(util$2.md5(s));
- var d = util$2.map(i, function(_) {
- return {
- action: "name/cos:DeleteObject",
- bucket: a.Bucket,
- region: a.Region,
- prefix: _.Key
- }
- });
- submitRequest.call(this, {
- Scope: d,
- method: "POST",
- Bucket: a.Bucket,
- Region: a.Region,
- body: s,
- action: "delete",
- headers: c
- }, function(_, b) {
- if (_)
- return e(_);
- var k = b.DeleteResult || {}
- , j = k.Deleted || []
- , $ = k.Error || [];
- j = util$2.isArray(j) ? j : [j],
- $ = util$2.isArray($) ? $ : [$];
- var _e = util$2.clone(k);
- util$2.extend(_e, {
- Error: $,
- Deleted: j,
- statusCode: b.statusCode,
- headers: b.headers
- }),
- e(null, _e)
- })
- }
- function restoreObject(a, e) {
- var i = a.Headers;
- if (!a.RestoreRequest) {
- e(util$2.error(new Error("missing param RestoreRequest")));
- return
- }
- var o = a.RestoreRequest || {}
- , s = util$2.json2xml({
- RestoreRequest: o
- });
- i["Content-Type"] = "application/xml",
- i["Content-MD5"] = util$2.binaryBase64(util$2.md5(s)),
- submitRequest.call(this, {
- Action: "name/cos:RestoreObject",
- method: "POST",
- Bucket: a.Bucket,
- Region: a.Region,
- Key: a.Key,
- VersionId: a.VersionId,
- body: s,
- action: "restore",
- headers: i
- }, e)
- }
- function putObjectTagging(a, e) {
- var i = a.Tagging || {}
- , o = i.TagSet || i.Tags || a.Tags || [];
- o = util$2.clone(util$2.isArray(o) ? o : [o]);
- var s = util$2.json2xml({
- Tagging: {
- TagSet: {
- Tag: o
- }
- }
- })
- , c = a.Headers;
- c["Content-Type"] = "application/xml",
- c["Content-MD5"] = util$2.binaryBase64(util$2.md5(s)),
- submitRequest.call(this, {
- Action: "name/cos:PutObjectTagging",
- method: "PUT",
- Bucket: a.Bucket,
- Key: a.Key,
- Region: a.Region,
- body: s,
- action: "tagging",
- headers: c,
- VersionId: a.VersionId
- }, function(d, _) {
- if (d && d.statusCode === 204)
- return e(null, {
- statusCode: d.statusCode
- });
- if (d)
- return e(d);
- e(null, {
- statusCode: _.statusCode,
- headers: _.headers
- })
- })
- }
- function getObjectTagging(a, e) {
- submitRequest.call(this, {
- Action: "name/cos:GetObjectTagging",
- method: "GET",
- Key: a.Key,
- Bucket: a.Bucket,
- Region: a.Region,
- headers: a.Headers,
- action: "tagging",
- VersionId: a.VersionId
- }, function(i, o) {
- if (i) {
- if (i.statusCode === 404 && i.error && (i.error === "Not Found" || i.error.Code === "NoSuchTagSet")) {
- var s = {
- Tags: [],
- statusCode: i.statusCode
- };
- i.headers && (s.headers = i.headers),
- e(null, s)
- } else
- e(i);
- return
- }
- var c = [];
- try {
- c = o.Tagging.TagSet.Tag || []
- } catch {}
- c = util$2.clone(util$2.isArray(c) ? c : [c]),
- e(null, {
- Tags: c,
- statusCode: o.statusCode,
- headers: o.headers
- })
- })
- }
- function deleteObjectTagging(a, e) {
- submitRequest.call(this, {
- Action: "name/cos:DeleteObjectTagging",
- method: "DELETE",
- Bucket: a.Bucket,
- Region: a.Region,
- Key: a.Key,
- headers: a.Headers,
- action: "tagging",
- VersionId: a.VersionId
- }, function(i, o) {
- if (i && i.statusCode === 204)
- return e(null, {
- statusCode: i.statusCode
- });
- if (i)
- return e(i);
- e(null, {
- statusCode: o.statusCode,
- headers: o.headers
- })
- })
- }
- function selectObjectContent(a, e) {
- var i = a.SelectType;
- if (!i)
- return e(util$2.error(new Error("missing param SelectType")));
- var o = a.SelectRequest || {}
- , s = util$2.json2xml({
- SelectRequest: o
- })
- , c = a.Headers;
- c["Content-Type"] = "application/xml",
- c["Content-MD5"] = util$2.binaryBase64(util$2.md5(s)),
- submitRequest.call(this, {
- Action: "name/cos:GetObject",
- method: "POST",
- Bucket: a.Bucket,
- Region: a.Region,
- Key: a.Key,
- headers: a.Headers,
- action: "select",
- qs: {
- "select-type": a.SelectType
- },
- VersionId: a.VersionId,
- body: s,
- DataType: "arraybuffer",
- rawBody: !0
- }, function(d, _) {
- if (d && d.statusCode === 204)
- return e(null, {
- statusCode: d.statusCode
- });
- if (d)
- return e(d);
- var b = util$2.parseSelectPayload(_.body);
- e(null, {
- statusCode: _.statusCode,
- headers: _.headers,
- Body: b.body,
- Payload: b.payload
- })
- })
- }
- function multipartInit(a, e) {
- var i = this
- , o = a.Headers;
- !o["Cache-Control"] && !o["cache-control"] && (o["Cache-Control"] = ""),
- !o["Content-Type"] && !o["content-type"] && (o["Content-Type"] = a.Body && a.Body.type || ""),
- util$2.getBodyMd5(a.Body && (a.UploadAddMetaMd5 || i.options.UploadAddMetaMd5), a.Body, function(s) {
- s && (a.Headers["x-cos-meta-md5"] = s),
- submitRequest.call(i, {
- Action: "name/cos:InitiateMultipartUpload",
- method: "POST",
- Bucket: a.Bucket,
- Region: a.Region,
- Key: a.Key,
- action: "uploads",
- headers: a.Headers,
- qs: a.Query
- }, function(c, d) {
- if (c)
- return e(c);
- if (d = util$2.clone(d || {}),
- d && d.InitiateMultipartUploadResult)
- return e(null, util$2.extend(d.InitiateMultipartUploadResult, {
- statusCode: d.statusCode,
- headers: d.headers
- }));
- e(null, d)
- })
- }, a.onHashProgress)
- }
- function multipartUpload(a, e) {
- var i = this;
- util$2.getFileSize("multipartUpload", a, function() {
- util$2.getBodyMd5(i.options.UploadCheckContentMd5, a.Body, function(o) {
- o && (a.Headers["Content-MD5"] = util$2.binaryBase64(o)),
- submitRequest.call(i, {
- Action: "name/cos:UploadPart",
- TaskId: a.TaskId,
- method: "PUT",
- Bucket: a.Bucket,
- Region: a.Region,
- Key: a.Key,
- qs: {
- partNumber: a.PartNumber,
- uploadId: a.UploadId
- },
- headers: a.Headers,
- onProgress: a.onProgress,
- body: a.Body || null
- }, function(s, c) {
- if (s)
- return e(s);
- e(null, {
- ETag: util$2.attr(c.headers, "etag", ""),
- statusCode: c.statusCode,
- headers: c.headers
- })
- })
- })
- })
- }
- function multipartComplete(a, e) {
- for (var i = this, o = a.UploadId, s = a.Parts, c = 0, d = s.length; c < d; c++)
- s[c].ETag && s[c].ETag.indexOf('"') === 0 || (s[c].ETag = '"' + s[c].ETag + '"');
- var _ = util$2.json2xml({
- CompleteMultipartUpload: {
- Part: s
- }
- });
- _ = _.replace(/\n\s*/g, "");
- var b = a.Headers;
- b["Content-Type"] = "application/xml",
- b["Content-MD5"] = util$2.binaryBase64(util$2.md5(_)),
- submitRequest.call(this, {
- Action: "name/cos:CompleteMultipartUpload",
- method: "POST",
- Bucket: a.Bucket,
- Region: a.Region,
- Key: a.Key,
- qs: {
- uploadId: o
- },
- body: _,
- headers: b
- }, function(k, j) {
- if (k)
- return e(k);
- var $ = getUrl({
- ForcePathStyle: i.options.ForcePathStyle,
- protocol: i.options.Protocol,
- domain: i.options.Domain,
- bucket: a.Bucket,
- region: a.Region,
- object: a.Key,
- isLocation: !0
- })
- , _e = j.CompleteMultipartUploadResult || {};
- _e.ProcessResults && _e && _e.ProcessResults && (_e.UploadResult = {
- OriginalInfo: {
- Key: _e.Key,
- Location: $,
- ETag: _e.ETag,
- ImageInfo: _e.ImageInfo
- },
- ProcessResults: _e.ProcessResults
- },
- delete _e.ImageInfo,
- delete _e.ProcessResults);
- var et = util$2.extend(_e, {
- Location: $,
- statusCode: j.statusCode,
- headers: j.headers
- });
- e(null, et)
- })
- }
- function multipartList(a, e) {
- var i = {};
- i.delimiter = a.Delimiter,
- i["encoding-type"] = a.EncodingType,
- i.prefix = a.Prefix || "",
- i["max-uploads"] = a.MaxUploads,
- i["key-marker"] = a.KeyMarker,
- i["upload-id-marker"] = a.UploadIdMarker,
- i = util$2.clearKey(i),
- submitRequest.call(this, {
- Action: "name/cos:ListMultipartUploads",
- ResourceKey: i.prefix,
- method: "GET",
- Bucket: a.Bucket,
- Region: a.Region,
- headers: a.Headers,
- qs: i,
- action: "uploads"
- }, function(o, s) {
- if (o)
- return e(o);
- if (s && s.ListMultipartUploadsResult) {
- var c = s.ListMultipartUploadsResult.Upload || [];
- c = util$2.isArray(c) ? c : [c],
- s.ListMultipartUploadsResult.Upload = c
- }
- var d = util$2.clone(s.ListMultipartUploadsResult || {});
- util$2.extend(d, {
- statusCode: s.statusCode,
- headers: s.headers
- }),
- e(null, d)
- })
- }
- function multipartListPart(a, e) {
- var i = {};
- i.uploadId = a.UploadId,
- i["encoding-type"] = a.EncodingType,
- i["max-parts"] = a.MaxParts,
- i["part-number-marker"] = a.PartNumberMarker,
- submitRequest.call(this, {
- Action: "name/cos:ListParts",
- method: "GET",
- Bucket: a.Bucket,
- Region: a.Region,
- Key: a.Key,
- headers: a.Headers,
- qs: i
- }, function(o, s) {
- if (o)
- return e(o);
- var c = s.ListPartsResult || {}
- , d = c.Part || [];
- d = util$2.isArray(d) ? d : [d],
- c.Part = d;
- var _ = util$2.clone(c);
- util$2.extend(_, {
- statusCode: s.statusCode,
- headers: s.headers
- }),
- e(null, _)
- })
- }
- function multipartAbort(a, e) {
- var i = {};
- i.uploadId = a.UploadId,
- submitRequest.call(this, {
- Action: "name/cos:AbortMultipartUpload",
- method: "DELETE",
- Bucket: a.Bucket,
- Region: a.Region,
- Key: a.Key,
- headers: a.Headers,
- qs: i
- }, function(o, s) {
- if (o)
- return e(o);
- e(null, {
- statusCode: s.statusCode,
- headers: s.headers
- })
- })
- }
- function request(a, e) {
- submitRequest.call(this, {
- method: a.Method,
- Bucket: a.Bucket,
- Region: a.Region,
- Key: a.Key,
- action: a.Action,
- headers: a.Headers,
- qs: a.Query,
- body: a.Body,
- Url: a.Url,
- rawBody: a.RawBody,
- DataType: a.DataType
- }, function(i, o) {
- if (i)
- return e(i);
- o && o.body && (o.Body = o.body,
- delete o.body),
- e(i, o)
- })
- }
- function appendObject(a, e) {
- var i = a.Headers;
- !i["Cache-Control"] && !i["cache-control"] && (i["Cache-Control"] = ""),
- !i["Content-Type"] && !i["content-type"] && (i["Content-Type"] = a.Body && a.Body.type || ""),
- submitRequest.call(this, {
- Action: "name/cos:AppendObject",
- method: "POST",
- Bucket: a.Bucket,
- Region: a.Region,
- action: "append",
- Key: a.Key,
- body: a.Body,
- qs: {
- position: a.Position
- },
- headers: a.Headers
- }, function(o, s) {
- if (o)
- return e(o);
- e(null, s)
- })
- }
- function getAuth(a) {
- var e = this;
- return util$2.getAuth({
- SecretId: a.SecretId || this.options.SecretId || "",
- SecretKey: a.SecretKey || this.options.SecretKey || "",
- Bucket: a.Bucket,
- Region: a.Region,
- Method: a.Method,
- Key: a.Key,
- Query: a.Query,
- Headers: a.Headers,
- Expires: a.Expires,
- UseRawKey: e.options.UseRawKey,
- SystemClockOffset: e.options.SystemClockOffset
- })
- }
- function getObjectUrl(a, e) {
- var i = this
- , o = a.UseAccelerate === void 0 ? i.options.UseAccelerate : a.UseAccelerate
- , s = getUrl({
- ForcePathStyle: i.options.ForcePathStyle,
- protocol: a.Protocol || i.options.Protocol,
- domain: a.Domain || i.options.Domain,
- bucket: a.Bucket,
- region: o ? "accelerate" : a.Region,
- object: a.Key
- })
- , c = "";
- a.Query && (c += util$2.obj2str(a.Query)),
- a.QueryString && (c += (c ? "&" : "") + a.QueryString);
- var d = s;
- if (a.Sign !== void 0 && !a.Sign)
- return c && (d += "?" + c),
- e(null, {
- Url: d
- }),
- d;
- var _ = getSignHost.call(this, {
- Bucket: a.Bucket,
- Region: a.Region,
- UseAccelerate: a.UseAccelerate,
- Url: s
- })
- , b = getAuthorizationAsync.call(this, {
- Action: (a.Method || "").toUpperCase() === "PUT" ? "name/cos:PutObject" : "name/cos:GetObject",
- Bucket: a.Bucket || "",
- Region: a.Region || "",
- Method: a.Method || "get",
- Key: a.Key,
- Expires: a.Expires,
- Headers: a.Headers,
- Query: a.Query,
- SignHost: _,
- ForceSignHost: a.ForceSignHost === !1 ? !1 : i.options.ForceSignHost
- }, function(k, j) {
- if (!!e) {
- if (k) {
- e(k);
- return
- }
- var $ = function(et) {
- var tt = et.match(/q-url-param-list.*?(?=&)/g)[0]
- , rt = "q-url-param-list=" + encodeURIComponent(tt.replace(/q-url-param-list=/, "")).toLowerCase()
- , it = new RegExp(tt,"g")
- , nt = et.replace(it, rt);
- return nt
- }
- , _e = s;
- _e += "?" + (j.Authorization.indexOf("q-signature") > -1 ? $(j.Authorization) : "sign=" + encodeURIComponent(j.Authorization)),
- j.SecurityToken && (_e += "&x-cos-security-token=" + j.SecurityToken),
- j.ClientIP && (_e += "&clientIP=" + j.ClientIP),
- j.ClientUA && (_e += "&clientUA=" + j.ClientUA),
- j.Token && (_e += "&token=" + j.Token),
- c && (_e += "&" + c),
- setTimeout(function() {
- e(null, {
- Url: _e
- })
- })
- }
- });
- return b ? (d += "?" + b.Authorization + (b.SecurityToken ? "&x-cos-security-token=" + b.SecurityToken : ""),
- c && (d += "&" + c)) : c && (d += "?" + c),
- d
- }
- function decodeAcl(a) {
- var e = {
- GrantFullControl: [],
- GrantWrite: [],
- GrantRead: [],
- GrantReadAcp: [],
- GrantWriteAcp: [],
- ACL: ""
- }
- , i = {
- FULL_CONTROL: "GrantFullControl",
- WRITE: "GrantWrite",
- READ: "GrantRead",
- READ_ACP: "GrantReadAcp",
- WRITE_ACP: "GrantWriteAcp"
- }
- , o = a && a.AccessControlList || {}
- , s = o.Grant;
- s && (s = util$2.isArray(s) ? s : [s]);
- var c = {
- READ: 0,
- WRITE: 0,
- FULL_CONTROL: 0
- };
- return s && s.length && util$2.each(s, function(d) {
- 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 + '"')
- }),
- c.FULL_CONTROL || c.WRITE && c.READ ? e.ACL = "public-read-write" : c.READ ? e.ACL = "public-read" : e.ACL = "private",
- util$2.each(i, function(d) {
- e[d] = uniqGrant(e[d].join(","))
- }),
- e
- }
- function uniqGrant(a) {
- var e = a.split(","), i = {}, o, s;
- for (o = 0; o < e.length; )
- s = e[o].trim(),
- i[s] ? e.splice(o, 1) : (i[s] = !0,
- e[o] = s,
- o++);
- return e.join(",")
- }
- function getUrl(a) {
- var e = a.region || ""
- , i = a.bucket || ""
- , o = i.substr(0, i.lastIndexOf("-"))
- , s = i.substr(i.lastIndexOf("-") + 1)
- , c = a.domain
- , d = a.object;
- typeof c == "function" && (c = c({
- Bucket: i,
- Region: e
- }));
- var _ = a.protocol || (util$2.isBrowser && location.protocol === "http:" ? "http:" : "https:");
- 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",
- a.ForcePathStyle || (c = "{Bucket}." + c)),
- c = c.replace(/\{\{AppId\}\}/ig, s).replace(/\{\{Bucket\}\}/ig, o).replace(/\{\{Region\}\}/ig, e).replace(/\{\{.*?\}\}/ig, ""),
- c = c.replace(/\{AppId\}/ig, s).replace(/\{BucketName\}/ig, o).replace(/\{Bucket\}/ig, i).replace(/\{Region\}/ig, e).replace(/\{.*?\}/ig, ""),
- /^[a-zA-Z]+:\/\//.test(c) || (c = _ + "//" + c),
- c.slice(-1) === "/" && (c = c.slice(0, -1));
- var b = c;
- return a.ForcePathStyle && (b += "/" + i),
- b += "/",
- d && (b += util$2.camSafeUrlEncode(d).replace(/%2F/g, "/")),
- a.isLocation && (b = b.replace(/^https?:\/\//, "")),
- b
- }
- var getSignHost = function(a) {
- if (!a.Bucket || !a.Region)
- return "";
- var e = a.UseAccelerate === void 0 ? this.options.UseAccelerate : a.UseAccelerate
- , i = a.Url || getUrl({
- ForcePathStyle: this.options.ForcePathStyle,
- protocol: this.options.Protocol,
- domain: this.options.Domain,
- bucket: a.Bucket,
- region: e ? "accelerate" : a.Region
- })
- , o = i.replace(/^https?:\/\/([^/]+)(\/.*)?$/, "$1")
- , s = new RegExp("^([a-z\\d-]+-\\d+\\.)?(cos|cosv6|ci|pic)\\.([a-z\\d-]+)\\.myqcloud\\.com$");
- return s.test(o) ? o : ""
- };
- function getAuthorizationAsync(a, e) {
- var i = util$2.clone(a.Headers)
- , o = "";
- util$2.each(i, function(at, st) {
- (at === "" || ["content-type", "cache-control", "expires"].indexOf(st.toLowerCase()) > -1) && delete i[st],
- st.toLowerCase() === "host" && (o = at)
- });
- var s = a.ForceSignHost !== !1;
- !o && a.SignHost && s && (i.Host = a.SignHost);
- var c = !1
- , d = function(at, st) {
- c || (c = !0,
- st && st.XCosSecurityToken && !st.SecurityToken && (st = util$2.clone(st),
- st.SecurityToken = st.XCosSecurityToken,
- delete st.XCosSecurityToken),
- e && e(at, st))
- }
- , _ = this
- , b = a.Bucket || ""
- , k = a.Region || ""
- , j = a.Key || "";
- _.options.ForcePathStyle && b && (j = b + "/" + j);
- var $ = "/" + j
- , _e = {}
- , et = a.Scope;
- if (!et) {
- var tt = a.Action || ""
- , rt = a.ResourceKey || a.Key || "";
- et = a.Scope || [{
- action: tt,
- bucket: b,
- region: k,
- prefix: rt
- }]
- }
- var it = util$2.md5(JSON.stringify(et));
- _._StsCache = _._StsCache || [],
- function() {
- var at, st;
- for (at = _._StsCache.length - 1; at >= 0; at--) {
- st = _._StsCache[at];
- var ut = Math.round(util$2.getSkewTime(_.options.SystemClockOffset) / 1e3) + 30;
- if (st.StartTime && ut < st.StartTime || ut >= st.ExpiredTime) {
- _._StsCache.splice(at, 1);
- continue
- }
- if (!st.ScopeLimit || st.ScopeLimit && st.ScopeKey === it) {
- _e = st;
- break
- }
- }
- }();
- var nt = function() {
- var at = _e.StartTime && _e.ExpiredTime ? _e.StartTime + ";" + _e.ExpiredTime : ""
- , st = util$2.getAuth({
- SecretId: _e.TmpSecretId,
- SecretKey: _e.TmpSecretKey,
- Method: a.Method,
- Pathname: $,
- Query: a.Query,
- Headers: i,
- Expires: a.Expires,
- UseRawKey: _.options.UseRawKey,
- SystemClockOffset: _.options.SystemClockOffset,
- KeyTime: at,
- ForceSignHost: _.options.ForceSignHost
- })
- , ut = {
- Authorization: st,
- SecurityToken: _e.SecurityToken || _e.XCosSecurityToken || "",
- Token: _e.Token || "",
- ClientIP: _e.ClientIP || "",
- ClientUA: _e.ClientUA || ""
- };
- d(null, ut)
- }
- , ot = function(at) {
- if (at.Authorization) {
- var st = !1
- , ut = at.Authorization;
- if (ut)
- if (ut.indexOf(" ") > -1)
- st = !1;
- 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)
- st = !0;
- else
- try {
- ut = atob(ut),
- ut.indexOf("a=") > -1 && ut.indexOf("k=") > -1 && ut.indexOf("t=") > -1 && ut.indexOf("r=") > -1 && ut.indexOf("b=") > -1 && (st = !0)
- } catch {}
- if (!st)
- return util$2.error(new Error("getAuthorization callback params format error"))
- } else {
- if (!at.TmpSecretId)
- return util$2.error(new Error('getAuthorization callback params missing "TmpSecretId"'));
- if (!at.TmpSecretKey)
- return util$2.error(new Error('getAuthorization callback params missing "TmpSecretKey"'));
- if (!at.SecurityToken && !at.XCosSecurityToken)
- return util$2.error(new Error('getAuthorization callback params missing "SecurityToken"'));
- if (!at.ExpiredTime)
- return util$2.error(new Error('getAuthorization callback params missing "ExpiredTime"'));
- if (at.ExpiredTime && at.ExpiredTime.toString().length !== 10)
- return util$2.error(new Error('getAuthorization callback params "ExpiredTime" should be 10 digits'));
- if (at.StartTime && at.StartTime.toString().length !== 10)
- return util$2.error(new Error('getAuthorization callback params "StartTime" should be 10 StartTime'))
- }
- return !1
- };
- if (_e.ExpiredTime && _e.ExpiredTime - util$2.getSkewTime(_.options.SystemClockOffset) / 1e3 > 60)
- nt();
- else if (_.options.getAuthorization)
- _.options.getAuthorization.call(_, {
- Bucket: b,
- Region: k,
- Method: a.Method,
- Key: j,
- Pathname: $,
- Query: a.Query,
- Headers: i,
- Scope: et,
- SystemClockOffset: _.options.SystemClockOffset,
- ForceSignHost: _.options.ForceSignHost
- }, function(at) {
- typeof at == "string" && (at = {
- Authorization: at
- });
- var st = ot(at);
- if (st)
- return d(st);
- at.Authorization ? d(null, at) : (_e = at || {},
- _e.Scope = et,
- _e.ScopeKey = it,
- _._StsCache.push(_e),
- nt())
- });
- else if (_.options.getSTS)
- _.options.getSTS.call(_, {
- Bucket: b,
- Region: k
- }, function(at) {
- _e = at || {},
- _e.Scope = et,
- _e.ScopeKey = it,
- _e.TmpSecretId || (_e.TmpSecretId = _e.SecretId),
- _e.TmpSecretKey || (_e.TmpSecretKey = _e.SecretKey);
- var st = ot(_e);
- if (st)
- return d(st);
- _._StsCache.push(_e),
- nt()
- });
- else
- return function() {
- var at = util$2.getAuth({
- SecretId: a.SecretId || _.options.SecretId,
- SecretKey: a.SecretKey || _.options.SecretKey,
- Method: a.Method,
- Pathname: $,
- Query: a.Query,
- Headers: i,
- Expires: a.Expires,
- UseRawKey: _.options.UseRawKey,
- SystemClockOffset: _.options.SystemClockOffset,
- ForceSignHost: _.options.ForceSignHost
- })
- , st = {
- Authorization: at,
- SecurityToken: _.options.SecurityToken || _.options.XCosSecurityToken
- };
- return d(null, st),
- st
- }();
- return ""
- }
- function allowRetry(a) {
- var e = !1
- , i = !1
- , o = a.headers && (a.headers.date || a.headers.Date) || a.error && a.error.ServerTime;
- try {
- var s = a.error.Code
- , c = a.error.Message;
- (s === "RequestTimeTooSkewed" || s === "AccessDenied" && c === "Request has expired") && (i = !0)
- } catch {}
- if (a)
- if (i && o) {
- var d = Date.parse(o);
- this.options.CorrectClockSkew && Math.abs(util$2.getSkewTime(this.options.SystemClockOffset) - d) >= 3e4 && (console.error("error: Local time is too skewed."),
- this.options.SystemClockOffset = d - Date.now(),
- e = !0)
- } else
- Math.floor(a.statusCode / 100) === 5 && (e = !0);
- return e
- }
- function submitRequest(a, e) {
- var i = this;
- !a.headers && (a.headers = {}),
- !a.qs && (a.qs = {}),
- a.VersionId && (a.qs.versionId = a.VersionId),
- a.qs = util$2.clearKey(a.qs),
- a.headers && (a.headers = util$2.clearKey(a.headers)),
- a.qs && (a.qs = util$2.clearKey(a.qs));
- var o = util$2.clone(a.qs);
- a.action && (o[a.action] = "");
- var s = a.url || a.Url
- , c = a.SignHost || getSignHost.call(this, {
- Bucket: a.Bucket,
- Region: a.Region,
- Url: s
- })
- , d = function(_) {
- var b = i.options.SystemClockOffset;
- getAuthorizationAsync.call(i, {
- Bucket: a.Bucket || "",
- Region: a.Region || "",
- Method: a.method,
- Key: a.Key,
- Query: o,
- Headers: a.headers,
- SignHost: c,
- Action: a.Action,
- ResourceKey: a.ResourceKey,
- Scope: a.Scope,
- ForceSignHost: i.options.ForceSignHost
- }, function(k, j) {
- if (k) {
- e(k);
- return
- }
- a.AuthData = j,
- _submitRequest.call(i, a, function($, _e) {
- $ && _ < 2 && (b !== i.options.SystemClockOffset || allowRetry.call(i, $)) ? (a.headers && (delete a.headers.Authorization,
- delete a.headers.token,
- delete a.headers.clientIP,
- delete a.headers.clientUA,
- a.headers["x-cos-security-token"] && delete a.headers["x-cos-security-token"],
- a.headers["x-ci-security-token"] && delete a.headers["x-ci-security-token"]),
- d(_ + 1)) : e($, _e)
- })
- })
- };
- d(1)
- }
- function _submitRequest(a, e) {
- var i = this
- , o = a.TaskId;
- if (!(o && !i._isRunningTask(o))) {
- var s = a.Bucket
- , c = a.Region
- , d = a.Key
- , _ = a.method || "GET"
- , b = a.Url || a.url
- , k = a.body
- , j = a.rawBody;
- i.options.UseAccelerate && (c = "accelerate"),
- b = b || getUrl({
- ForcePathStyle: i.options.ForcePathStyle,
- protocol: i.options.Protocol,
- domain: i.options.Domain,
- bucket: s,
- region: c,
- object: d
- }),
- a.action && (b = b + "?" + a.action),
- a.qsStr && (b.indexOf("?") > -1 ? b = b + "&" + a.qsStr : b = b + "?" + a.qsStr);
- var $ = {
- method: _,
- url: b,
- headers: a.headers,
- qs: a.qs,
- body: k
- }
- , _e = "x-cos-security-token";
- if (util$2.isCIHost(b) && (_e = "x-ci-security-token"),
- $.headers.Authorization = a.AuthData.Authorization,
- a.AuthData.Token && ($.headers.token = a.AuthData.Token),
- a.AuthData.ClientIP && ($.headers.clientIP = a.AuthData.ClientIP),
- a.AuthData.ClientUA && ($.headers.clientUA = a.AuthData.ClientUA),
- a.AuthData.SecurityToken && ($.headers[_e] = a.AuthData.SecurityToken),
- $.headers && ($.headers = util$2.clearKey($.headers)),
- $ = util$2.clearKey($),
- a.onProgress && typeof a.onProgress == "function") {
- var et = k && (k.size || k.length) || 0;
- $.onProgress = function(it) {
- if (!(o && !i._isRunningTask(o))) {
- var nt = it ? it.loaded : 0;
- a.onProgress({
- loaded: nt,
- total: et
- })
- }
- }
- }
- a.onDownloadProgress && ($.onDownloadProgress = a.onDownloadProgress),
- a.DataType && ($.dataType = a.DataType),
- this.options.Timeout && ($.timeout = this.options.Timeout),
- i.options.ForcePathStyle && ($.pathStyle = i.options.ForcePathStyle),
- i.emit("before-send", $);
- var tt = (i.options.Request || REQUEST)($, function(it) {
- if (it.error !== "abort") {
- var nt = {
- options: $,
- error: at,
- statusCode: ot && ot.statusCode || 0,
- headers: ot && ot.headers || {},
- body: st
- };
- i.emit("after-receive", nt),
- at = nt.error,
- st = nt.body,
- ot = {
- statusCode: nt.statusCode,
- headers: nt.headers
- },
- i.emit("after-receive", it);
- var ot = {
- statusCode: it.statusCode,
- statusMessage: it.statusMessage,
- headers: it.headers
- }, at = it.error, st = it.body, ut, ct = function(dt, _t) {
- if (o && i.off("inner-kill-task", rt),
- !ut) {
- ut = !0;
- var mt = {};
- ot && ot.statusCode && (mt.statusCode = ot.statusCode),
- ot && ot.headers && (mt.headers = ot.headers),
- dt ? (dt = util$2.extend(dt || {}, mt),
- e(dt, null)) : (_t = util$2.extend(_t || {}, mt),
- e(null, _t)),
- tt = null
- }
- };
- if (at)
- return ct(util$2.error(at));
- var lt = ot.statusCode
- , ft = Math.floor(lt / 100) === 2;
- if (j && ft)
- return ct(null, {
- body: st
- });
- var ht;
- try {
- ht = st && st.indexOf("<") > -1 && st.indexOf(">") > -1 && util$2.xml2json(st) || {}
- } catch {
- ht = {}
- }
- var pt = ht && ht.Error;
- ft ? ct(null, ht) : pt ? ct(util$2.error(new Error(pt.Message), {
- code: pt.Code,
- error: pt
- })) : lt ? ct(util$2.error(new Error(ot.statusMessage), {
- code: "" + lt
- })) : lt && ct(util$2.error(new Error("statusCode error")))
- }
- })
- , rt = function(it) {
- it.TaskId === o && (tt && tt.abort && tt.abort(),
- i.off("inner-kill-task", rt))
- };
- o && i.on("inner-kill-task", rt)
- }
- }
- var API_MAP$1 = {
- getService,
- putBucket,
- headBucket,
- getBucket,
- deleteBucket,
- putBucketAcl,
- getBucketAcl,
- putBucketCors,
- getBucketCors,
- deleteBucketCors,
- getBucketLocation,
- getBucketPolicy,
- putBucketPolicy,
- deleteBucketPolicy,
- putBucketTagging,
- getBucketTagging,
- deleteBucketTagging,
- putBucketLifecycle,
- getBucketLifecycle,
- deleteBucketLifecycle,
- putBucketVersioning,
- getBucketVersioning,
- putBucketReplication,
- getBucketReplication,
- deleteBucketReplication,
- putBucketWebsite,
- getBucketWebsite,
- deleteBucketWebsite,
- putBucketReferer,
- getBucketReferer,
- putBucketDomain,
- getBucketDomain,
- deleteBucketDomain,
- putBucketOrigin,
- getBucketOrigin,
- deleteBucketOrigin,
- putBucketLogging,
- getBucketLogging,
- putBucketInventory,
- getBucketInventory,
- listBucketInventory,
- deleteBucketInventory,
- putBucketAccelerate,
- getBucketAccelerate,
- putBucketEncryption,
- getBucketEncryption,
- deleteBucketEncryption,
- getObject,
- headObject,
- listObjectVersions,
- putObject,
- deleteObject,
- getObjectAcl,
- putObjectAcl,
- optionsObject,
- putObjectCopy,
- deleteMultipleObject,
- restoreObject,
- putObjectTagging,
- getObjectTagging,
- deleteObjectTagging,
- selectObjectContent,
- appendObject,
- uploadPartCopy,
- multipartInit,
- multipartUpload,
- multipartComplete,
- multipartList,
- multipartListPart,
- multipartAbort,
- request,
- getObjectUrl,
- getAuth
- };
- function warnOldApi(a, e, i) {
- util$2.each(["Cors", "Acl"], function(o) {
- if (a.slice(-o.length) === o) {
- var s = a.slice(0, -o.length) + o.toUpperCase()
- , c = util$2.apiWrapper(a, e)
- , d = !1;
- i[s] = function() {
- !d && console.warn("warning: cos." + s + " has been deprecated. Please Use cos." + a + " instead."),
- d = !0,
- c.apply(this, arguments)
- }
- }
- })
- }
- base$1.init = function(a, e) {
- e.transferToTaskMethod(API_MAP$1, "putObject"),
- util$2.each(API_MAP$1, function(i, o) {
- a.prototype[o] = util$2.apiWrapper(o, i),
- warnOldApi(o, i, a.prototype)
- })
- }
- ;
- var advance$1 = {}
- , eachLimit = function(a, e, i, o) {
- if (o = o || function() {}
- ,
- !a.length || e <= 0)
- return o();
- var s = 0
- , c = 0
- , d = 0;
- (function _() {
- if (s >= a.length)
- return o();
- for (; d < e && c < a.length; )
- c += 1,
- d += 1,
- i(a[c - 1], function(b) {
- b ? (o(b),
- o = function() {}
- ) : (s += 1,
- d -= 1,
- s >= a.length ? o() : _())
- })
- }
- )()
- }
- , retry = function(a, e, i) {
- var o = function(s) {
- e(function(c, d) {
- c && s < a ? o(s + 1) : i(c, d)
- })
- };
- a < 1 ? i() : o(1)
- }
- , async = {
- eachLimit,
- retry
- }
- , async_1 = async
- , session = session$2
- , Async = async_1
- , EventProxy = event$1.EventProxy
- , util$1 = util_1;
- function sliceUploadFile(a, e) {
- 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;
- o.on("error", function(it) {
- if (!!i._isRunningTask(s))
- return it.UploadId = a.UploadData.UploadId || "",
- e(it)
- }),
- o.on("upload_complete", function(it) {
- var nt = util$1.extend({
- UploadId: a.UploadData.UploadId || ""
- }, it);
- e(null, nt)
- }),
- o.on("upload_slice_complete", function(it) {
- var nt = {};
- util$1.each(a.Headers, function(ot, at) {
- var st = at.toLowerCase();
- (st.indexOf("x-cos-meta-") === 0 || st === "pic-operations") && (nt[at] = ot)
- }),
- uploadSliceComplete.call(i, {
- Bucket: c,
- Region: d,
- Key: _,
- UploadId: it.UploadId,
- SliceList: it.SliceList,
- Headers: nt
- }, function(ot, at) {
- if (!!i._isRunningTask(s)) {
- if (session.removeUsing(it.UploadId),
- ot)
- return tt(null, !0),
- o.emit("error", ot);
- session.removeUploadId.call(i, it.UploadId),
- tt({
- loaded: et,
- total: et
- }, !0),
- o.emit("upload_complete", at)
- }
- })
- }),
- o.on("get_upload_data_finish", function(it) {
- var nt = session.getFileId(b, a.ChunkSize, c, _);
- nt && session.saveUploadId.call(i, nt, it.UploadId, i.options.UploadIdCacheLimit),
- session.setUsing(it.UploadId),
- tt(null, !0),
- uploadSliceList.call(i, {
- TaskId: s,
- Bucket: c,
- Region: d,
- Key: _,
- Body: b,
- FileSize: et,
- SliceSize: k,
- AsyncLimit: j,
- ServerSideEncryption: _e,
- UploadData: it,
- Headers: a.Headers,
- onProgress: tt
- }, function(ot, at) {
- if (!!i._isRunningTask(s)) {
- if (ot)
- return tt(null, !0),
- o.emit("error", ot);
- o.emit("upload_slice_complete", at)
- }
- })
- }),
- o.on("get_file_size_finish", function() {
- if (tt = util$1.throttleOnProgress.call(i, et, a.onProgress),
- a.UploadData.UploadId)
- o.emit("get_upload_data_finish", a.UploadData);
- else {
- var it = util$1.extend({
- TaskId: s,
- Bucket: c,
- Region: d,
- Key: _,
- Headers: a.Headers,
- StorageClass: $,
- Body: b,
- FileSize: et,
- SliceSize: k,
- onHashProgress: rt
- }, a);
- getUploadIdAndPartList.call(i, it, function(nt, ot) {
- if (!!i._isRunningTask(s)) {
- if (nt)
- return o.emit("error", nt);
- a.UploadData.UploadId = ot.UploadId,
- a.UploadData.PartList = ot.PartList,
- o.emit("get_upload_data_finish", a.UploadData)
- }
- })
- }
- }),
- et = a.ContentLength,
- delete a.ContentLength,
- !a.Headers && (a.Headers = {}),
- util$1.each(a.Headers, function(it, nt) {
- nt.toLowerCase() === "content-length" && delete a.Headers[nt]
- }),
- function() {
- 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,
- !(et / nt <= i.options.MaxPartNumber)); ot++)
- ;
- a.ChunkSize = a.SliceSize = k = Math.max(k, nt)
- }(),
- et === 0 ? (a.Body = "",
- a.ContentLength = 0,
- a.SkipTask = !0,
- i.putObject(a, e)) : o.emit("get_file_size_finish")
- }
- function getUploadIdAndPartList(a, e) {
- var i = a.TaskId
- , o = a.Bucket
- , s = a.Region
- , c = a.Key
- , d = a.StorageClass
- , _ = this
- , b = {}
- , k = a.FileSize
- , j = a.SliceSize
- , $ = Math.ceil(k / j)
- , _e = 0
- , et = util$1.throttleOnProgress.call(_, k, a.onHashProgress)
- , tt = function(nt, ot) {
- var at = j * (nt - 1)
- , st = Math.min(at + j, k)
- , ut = st - at;
- b[nt] ? ot(null, {
- PartNumber: nt,
- ETag: b[nt],
- Size: ut
- }) : util$1.fileSlice(a.Body, at, st, !1, function(ct) {
- util$1.getFileMd5(ct, function(lt, ft) {
- if (lt)
- return ot(util$1.error(lt));
- var ht = '"' + ft + '"';
- b[nt] = ht,
- _e += ut,
- et({
- loaded: _e,
- total: k
- }),
- ot(null, {
- PartNumber: nt,
- ETag: ht,
- Size: ut
- })
- })
- })
- }
- , rt = function(nt, ot) {
- var at = nt.length;
- if (at === 0)
- return ot(null, !0);
- if (at > $)
- return ot(null, !1);
- if (at > 1) {
- var st = Math.max(nt[0].Size, nt[1].Size);
- if (st !== j)
- return ot(null, !1)
- }
- var ut = function(ct) {
- if (ct < at) {
- var lt = nt[ct];
- tt(lt.PartNumber, function(ft, ht) {
- ht && ht.ETag === lt.ETag && ht.Size === lt.Size ? ut(ct + 1) : ot(null, !1)
- })
- } else
- ot(null, !0)
- };
- ut(0)
- }
- , it = new EventProxy;
- it.on("error", function(nt) {
- if (!!_._isRunningTask(i))
- return e(nt)
- }),
- it.on("upload_id_available", function(nt) {
- var ot = {}
- , at = [];
- util$1.each(nt.PartList, function(ct) {
- ot[ct.PartNumber] = ct
- });
- for (var st = 1; st <= $; st++) {
- var ut = ot[st];
- ut ? (ut.PartNumber = st,
- ut.Uploaded = !0) : ut = {
- PartNumber: st,
- ETag: null,
- Uploaded: !1
- },
- at.push(ut)
- }
- nt.PartList = at,
- e(null, nt)
- }),
- it.on("no_available_upload_id", function() {
- if (!!_._isRunningTask(i)) {
- var nt = util$1.extend({
- Bucket: o,
- Region: s,
- Key: c,
- Query: util$1.clone(a.Query),
- StorageClass: d,
- Body: a.Body
- }, a)
- , ot = util$1.clone(a.Headers);
- delete ot["x-cos-mime-limit"],
- nt.Headers = ot,
- _.multipartInit(nt, function(at, st) {
- if (!!_._isRunningTask(i)) {
- if (at)
- return it.emit("error", at);
- var ut = st.UploadId;
- if (!ut)
- return e(util$1.error(new Error("no such upload id")));
- it.emit("upload_id_available", {
- UploadId: ut,
- PartList: []
- })
- }
- })
- }
- }),
- it.on("has_and_check_upload_id", function(nt) {
- nt = nt.reverse(),
- Async.eachLimit(nt, 1, function(ot, at) {
- if (!!_._isRunningTask(i)) {
- if (session.using[ot]) {
- at();
- return
- }
- wholeMultipartListPart.call(_, {
- Bucket: o,
- Region: s,
- Key: c,
- UploadId: ot
- }, function(st, ut) {
- if (!!_._isRunningTask(i)) {
- if (st)
- return session.removeUsing(ot),
- it.emit("error", st);
- var ct = ut.PartList;
- ct.forEach(function(lt) {
- lt.PartNumber *= 1,
- lt.Size *= 1,
- lt.ETag = lt.ETag || ""
- }),
- rt(ct, function(lt, ft) {
- if (!!_._isRunningTask(i)) {
- if (lt)
- return it.emit("error", lt);
- ft ? at({
- UploadId: ot,
- PartList: ct
- }) : at()
- }
- })
- }
- })
- }
- }, function(ot) {
- !_._isRunningTask(i) || (et(null, !0),
- ot && ot.UploadId ? it.emit("upload_id_available", ot) : it.emit("no_available_upload_id"))
- })
- }),
- it.on("seek_local_avail_upload_id", function(nt) {
- var ot = session.getFileId(a.Body, a.ChunkSize, o, c)
- , at = session.getUploadIdList.call(_, ot);
- if (!ot || !at) {
- it.emit("has_and_check_upload_id", nt);
- return
- }
- var st = function(ut) {
- if (ut >= at.length) {
- it.emit("has_and_check_upload_id", nt);
- return
- }
- var ct = at[ut];
- if (!util$1.isInArray(nt, ct)) {
- session.removeUploadId.call(_, ct),
- st(ut + 1);
- return
- }
- if (session.using[ct]) {
- st(ut + 1);
- return
- }
- wholeMultipartListPart.call(_, {
- Bucket: o,
- Region: s,
- Key: c,
- UploadId: ct
- }, function(lt, ft) {
- !_._isRunningTask(i) || (lt ? (session.removeUploadId.call(_, ct),
- st(ut + 1)) : it.emit("upload_id_available", {
- UploadId: ct,
- PartList: ft.PartList
- }))
- })
- };
- st(0)
- }),
- it.on("get_remote_upload_id_list", function() {
- wholeMultipartList.call(_, {
- Bucket: o,
- Region: s,
- Key: c
- }, function(nt, ot) {
- if (!!_._isRunningTask(i)) {
- if (nt)
- return it.emit("error", nt);
- var at = util$1.filter(ot.UploadList, function(ct) {
- return ct.Key === c && (!d || ct.StorageClass.toUpperCase() === d.toUpperCase())
- }).reverse().map(function(ct) {
- return ct.UploadId || ct.UploadID
- });
- if (at.length)
- it.emit("seek_local_avail_upload_id", at);
- else {
- var st = session.getFileId(a.Body, a.ChunkSize, o, c), ut;
- st && (ut = session.getUploadIdList.call(_, st)) && util$1.each(ut, function(ct) {
- session.removeUploadId.call(_, ct)
- }),
- it.emit("no_available_upload_id")
- }
- }
- })
- }),
- it.emit("get_remote_upload_id_list")
- }
- function wholeMultipartList(a, e) {
- var i = this
- , o = []
- , s = {
- Bucket: a.Bucket,
- Region: a.Region,
- Prefix: a.Key
- }
- , c = function() {
- i.multipartList(s, function(d, _) {
- if (d)
- return e(d);
- o.push.apply(o, _.Upload || []),
- _.IsTruncated === "true" ? (s.KeyMarker = _.NextKeyMarker,
- s.UploadIdMarker = _.NextUploadIdMarker,
- c()) : e(null, {
- UploadList: o
- })
- })
- };
- c()
- }
- function wholeMultipartListPart(a, e) {
- var i = this
- , o = []
- , s = {
- Bucket: a.Bucket,
- Region: a.Region,
- Key: a.Key,
- UploadId: a.UploadId
- }
- , c = function() {
- i.multipartListPart(s, function(d, _) {
- if (d)
- return e(d);
- o.push.apply(o, _.Part || []),
- _.IsTruncated === "true" ? (s.PartNumberMarker = _.NextPartNumberMarker,
- c()) : e(null, {
- PartList: o
- })
- })
- };
- c()
- }
- function uploadSliceList(a, e) {
- var i = this
- , o = a.TaskId
- , s = a.Bucket
- , c = a.Region
- , d = a.Key
- , _ = a.UploadData
- , b = a.FileSize
- , k = a.SliceSize
- , j = Math.min(a.AsyncLimit || i.options.ChunkParallelLimit || 1, 256)
- , $ = a.Body
- , _e = Math.ceil(b / k)
- , et = 0
- , tt = a.ServerSideEncryption
- , rt = a.Headers
- , it = util$1.filter(_.PartList, function(ot) {
- return ot.Uploaded && (et += ot.PartNumber >= _e && b % k || k),
- !ot.Uploaded
- })
- , nt = a.onProgress;
- Async.eachLimit(it, j, function(ot, at) {
- if (!!i._isRunningTask(o)) {
- var st = ot.PartNumber
- , ut = Math.min(b, ot.PartNumber * k) - (ot.PartNumber - 1) * k
- , ct = 0;
- uploadSliceItem.call(i, {
- TaskId: o,
- Bucket: s,
- Region: c,
- Key: d,
- SliceSize: k,
- FileSize: b,
- PartNumber: st,
- ServerSideEncryption: tt,
- Body: $,
- UploadData: _,
- Headers: rt,
- onProgress: function(lt) {
- et += lt.loaded - ct,
- ct = lt.loaded,
- nt({
- loaded: et,
- total: b
- })
- }
- }, function(lt, ft) {
- !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 )'),
- lt ? et -= ct : (et += ut - ct,
- ot.ETag = ft.ETag),
- nt({
- loaded: et,
- total: b
- }),
- at(lt || null, ft))
- })
- }
- }, function(ot) {
- if (!!i._isRunningTask(o)) {
- if (ot)
- return e(ot);
- e(null, {
- UploadId: _.UploadId,
- SliceList: _.PartList
- })
- }
- })
- }
- function uploadSliceItem(a, e) {
- var i = this
- , o = a.TaskId
- , s = a.Bucket
- , c = a.Region
- , d = a.Key
- , _ = a.FileSize
- , b = a.Body
- , k = a.PartNumber * 1
- , j = a.SliceSize
- , $ = a.ServerSideEncryption
- , _e = a.UploadData
- , et = a.Headers || {}
- , tt = i.options.ChunkRetryTimes + 1
- , rt = j * (k - 1)
- , it = j
- , nt = rt + j;
- nt > _ && (nt = _,
- it = nt - rt);
- var ot = ["x-cos-traffic-limit", "x-cos-mime-limit"]
- , at = {};
- util$1.each(et, function(ut, ct) {
- ot.indexOf(ct) > -1 && (at[ct] = ut)
- });
- var st = _e.PartList[k - 1];
- Async.retry(tt, function(ut) {
- !i._isRunningTask(o) || util$1.fileSlice(b, rt, nt, !0, function(ct) {
- i.multipartUpload({
- TaskId: o,
- Bucket: s,
- Region: c,
- Key: d,
- ContentLength: it,
- PartNumber: k,
- UploadId: _e.UploadId,
- ServerSideEncryption: $,
- Body: ct,
- Headers: at,
- onProgress: a.onProgress
- }, function(lt, ft) {
- if (!!i._isRunningTask(o))
- return lt ? ut(lt) : (st.Uploaded = !0,
- ut(null, ft))
- })
- })
- }, function(ut, ct) {
- if (!!i._isRunningTask(o))
- return e(ut, ct)
- })
- }
- function uploadSliceComplete(a, e) {
- var i = a.Bucket
- , o = a.Region
- , s = a.Key
- , c = a.UploadId
- , d = a.SliceList
- , _ = this
- , b = this.options.ChunkRetryTimes + 1
- , k = a.Headers
- , j = d.map(function($) {
- return {
- PartNumber: $.PartNumber,
- ETag: $.ETag
- }
- });
- Async.retry(b, function($) {
- _.multipartComplete({
- Bucket: i,
- Region: o,
- Key: s,
- UploadId: c,
- Parts: j,
- Headers: k
- }, $)
- }, function($, _e) {
- e($, _e)
- })
- }
- function abortUploadTask(a, e) {
- var i = a.Bucket
- , o = a.Region
- , s = a.Key
- , c = a.UploadId
- , d = a.Level || "task"
- , _ = a.AsyncLimit
- , b = this
- , k = new EventProxy;
- if (k.on("error", function(j) {
- return e(j)
- }),
- k.on("get_abort_array", function(j) {
- abortUploadTaskArray.call(b, {
- Bucket: i,
- Region: o,
- Key: s,
- Headers: a.Headers,
- AsyncLimit: _,
- AbortArray: j
- }, e)
- }),
- d === "bucket")
- wholeMultipartList.call(b, {
- Bucket: i,
- Region: o
- }, function(j, $) {
- if (j)
- return e(j);
- k.emit("get_abort_array", $.UploadList || [])
- });
- else if (d === "file") {
- if (!s)
- return e(util$1.error(new Error("abort_upload_task_no_key")));
- wholeMultipartList.call(b, {
- Bucket: i,
- Region: o,
- Key: s
- }, function(j, $) {
- if (j)
- return e(j);
- k.emit("get_abort_array", $.UploadList || [])
- })
- } else if (d === "task") {
- if (!c)
- return e(util$1.error(new Error("abort_upload_task_no_id")));
- if (!s)
- return e(util$1.error(new Error("abort_upload_task_no_key")));
- k.emit("get_abort_array", [{
- Key: s,
- UploadId: c
- }])
- } else
- return e(util$1.error(new Error("abort_unknown_level")))
- }
- function abortUploadTaskArray(a, e) {
- var i = a.Bucket
- , o = a.Region
- , s = a.Key
- , c = a.AbortArray
- , d = a.AsyncLimit || 1
- , _ = this
- , b = 0
- , k = new Array(c.length);
- Async.eachLimit(c, d, function(j, $) {
- var _e = b;
- if (s && s !== j.Key) {
- k[_e] = {
- error: {
- KeyNotMatch: !0
- }
- },
- $(null);
- return
- }
- var et = j.UploadId || j.UploadID;
- _.multipartAbort({
- Bucket: i,
- Region: o,
- Key: j.Key,
- Headers: a.Headers,
- UploadId: et
- }, function(tt) {
- var rt = {
- Bucket: i,
- Region: o,
- Key: j.Key,
- UploadId: et
- };
- k[_e] = {
- error: tt,
- task: rt
- },
- $(null)
- }),
- b++
- }, function(j) {
- if (j)
- return e(j);
- for (var $ = [], _e = [], et = 0, tt = k.length; et < tt; et++) {
- var rt = k[et];
- rt.task && (rt.error ? _e.push(rt.task) : $.push(rt.task))
- }
- return e(null, {
- successList: $,
- errorList: _e
- })
- })
- }
- function uploadFile(a, e) {
- var i = this
- , o = a.SliceSize === void 0 ? i.options.SliceSize : a.SliceSize
- , s = []
- , c = a.Body
- , d = c.size || c.length || 0
- , _ = {
- TaskId: ""
- };
- util$1.each(a, function(et, tt) {
- typeof et != "object" && typeof et != "function" && (_[tt] = et)
- });
- var b = a.onTaskReady
- , k = function(et) {
- _.TaskId = et,
- b && b(et)
- };
- a.onTaskReady = k;
- var j = a.onFileFinish
- , $ = function(et, tt) {
- j && j(et, tt, _),
- e && e(et, tt)
- }
- , _e = d > o ? "sliceUploadFile" : "putObject";
- s.push({
- api: _e,
- params: a,
- callback: $
- }),
- i._addTasks(s)
- }
- function uploadFiles(a, e) {
- var i = this
- , o = a.SliceSize === void 0 ? i.options.SliceSize : a.SliceSize
- , s = 0
- , c = 0
- , d = util$1.throttleOnProgress.call(i, c, a.onProgress)
- , _ = a.files.length
- , b = a.onFileFinish
- , k = Array(_)
- , j = function(_e, et, tt) {
- d(null, !0),
- b && b(_e, et, tt),
- k[tt.Index] = {
- options: tt,
- error: _e,
- data: et
- },
- --_ <= 0 && e && e(null, {
- files: k
- })
- }
- , $ = [];
- util$1.each(a.files, function(_e, et) {
- (function() {
- var tt = _e.Body
- , rt = tt.size || tt.length || 0
- , it = {
- Index: et,
- TaskId: ""
- };
- s += rt,
- util$1.each(_e, function(ht, pt) {
- typeof ht != "object" && typeof ht != "function" && (it[pt] = ht)
- });
- var nt = _e.onTaskReady
- , ot = function(ht) {
- it.TaskId = ht,
- nt && nt(ht)
- };
- _e.onTaskReady = ot;
- var at = 0
- , st = _e.onProgress
- , ut = function(ht) {
- c = c - at + ht.loaded,
- at = ht.loaded,
- st && st(ht),
- d({
- loaded: c,
- total: s
- })
- };
- _e.onProgress = ut;
- var ct = _e.onFileFinish
- , lt = function(ht, pt) {
- ct && ct(ht, pt),
- j && j(ht, pt, it)
- }
- , ft = rt > o ? "sliceUploadFile" : "putObject";
- $.push({
- api: ft,
- params: _e,
- callback: lt
- })
- }
- )()
- }),
- i._addTasks($)
- }
- function sliceCopyFile(a, e) {
- var i = new EventProxy
- , o = this
- , s = a.Bucket
- , c = a.Region
- , d = a.Key
- , _ = a.CopySource
- , b = util$1.getSourceParams.call(this, _);
- if (!b) {
- e(util$1.error(new Error("CopySource format error")));
- return
- }
- var k = b.Bucket
- , j = b.Region
- , $ = decodeURIComponent(b.Key)
- , _e = a.CopySliceSize === void 0 ? o.options.CopySliceSize : a.CopySliceSize;
- _e = Math.max(0, _e);
- var et = a.CopyChunkSize || this.options.CopyChunkSize, tt = this.options.CopyChunkParallelLimit, rt = 0, it, nt;
- i.on("copy_slice_complete", function(ot) {
- var at = {};
- util$1.each(a.Headers, function(ut, ct) {
- ct.toLowerCase().indexOf("x-cos-meta-") === 0 && (at[ct] = ut)
- });
- var st = util$1.map(ot.PartList, function(ut) {
- return {
- PartNumber: ut.PartNumber,
- ETag: ut.ETag
- }
- });
- o.multipartComplete({
- Bucket: s,
- Region: c,
- Key: d,
- UploadId: ot.UploadId,
- Parts: st
- }, function(ut, ct) {
- if (ut)
- return nt(null, !0),
- e(ut);
- nt({
- loaded: it,
- total: it
- }, !0),
- e(null, ct)
- })
- }),
- i.on("get_copy_data_finish", function(ot) {
- Async.eachLimit(ot.PartList, tt, function(at, st) {
- var ut = at.PartNumber
- , ct = at.CopySourceRange
- , lt = at.end - at.start;
- copySliceItem.call(o, {
- Bucket: s,
- Region: c,
- Key: d,
- CopySource: _,
- UploadId: ot.UploadId,
- PartNumber: ut,
- CopySourceRange: ct
- }, function(ft, ht) {
- if (ft)
- return st(ft);
- rt += lt,
- nt({
- loaded: rt,
- total: it
- }),
- at.ETag = ht.ETag,
- st(ft || null, ht)
- })
- }, function(at) {
- if (at)
- return nt(null, !0),
- e(at);
- i.emit("copy_slice_complete", ot)
- })
- }),
- i.on("get_file_size_finish", function(ot) {
- (function() {
- 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,
- !(it / ct <= o.options.MaxPartNumber)); lt++)
- ;
- a.ChunkSize = et = Math.max(et, ct);
- for (var ft = Math.ceil(it / et), ht = [], pt = 1; pt <= ft; pt++) {
- var dt = (pt - 1) * et
- , _t = pt * et < it ? pt * et - 1 : it - 1
- , mt = {
- PartNumber: pt,
- start: dt,
- end: _t,
- CopySourceRange: "bytes=" + dt + "-" + _t
- };
- ht.push(mt)
- }
- a.PartList = ht
- }
- )();
- var at;
- if (a.Headers["x-cos-metadata-directive"] === "Replaced" ? at = a.Headers : at = ot,
- at["x-cos-storage-class"] = a.Headers["x-cos-storage-class"] || ot["x-cos-storage-class"],
- at = util$1.clearKey(at),
- ot["x-cos-storage-class"] === "ARCHIVE" || ot["x-cos-storage-class"] === "DEEP_ARCHIVE") {
- var st = ot["x-cos-restore"];
- if (!st || st === 'ongoing-request="true"') {
- e(util$1.error(new Error("Unrestored archive object is not allowed to be copied")));
- return
- }
- }
- delete at["x-cos-copy-source"],
- delete at["x-cos-metadata-directive"],
- delete at["x-cos-copy-source-If-Modified-Since"],
- delete at["x-cos-copy-source-If-Unmodified-Since"],
- delete at["x-cos-copy-source-If-Match"],
- delete at["x-cos-copy-source-If-None-Match"],
- o.multipartInit({
- Bucket: s,
- Region: c,
- Key: d,
- Headers: at
- }, function(ut, ct) {
- if (ut)
- return e(ut);
- a.UploadId = ct.UploadId,
- i.emit("get_copy_data_finish", a)
- })
- }),
- o.headObject({
- Bucket: k,
- Region: j,
- Key: $
- }, function(ot, at) {
- if (ot) {
- ot.statusCode && ot.statusCode === 404 ? e(util$1.error(ot, {
- ErrorStatus: $ + " Not Exist"
- })) : e(ot);
- return
- }
- if (it = a.FileSize = at.headers["content-length"],
- it === void 0 || !it) {
- 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')));
- return
- }
- if (nt = util$1.throttleOnProgress.call(o, it, a.onProgress),
- it <= _e)
- a.Headers["x-cos-metadata-directive"] || (a.Headers["x-cos-metadata-directive"] = "Copy"),
- o.putObjectCopy(a, function(ct, lt) {
- if (ct)
- return nt(null, !0),
- e(ct);
- nt({
- loaded: it,
- total: it
- }, !0),
- e(ct, lt)
- });
- else {
- var st = at.headers
- , ut = {
- "Cache-Control": st["cache-control"],
- "Content-Disposition": st["content-disposition"],
- "Content-Encoding": st["content-encoding"],
- "Content-Type": st["content-type"],
- Expires: st.expires,
- "x-cos-storage-class": st["x-cos-storage-class"]
- };
- util$1.each(st, function(ct, lt) {
- var ft = "x-cos-meta-";
- lt.indexOf(ft) === 0 && lt.length > ft.length && (ut[lt] = ct)
- }),
- i.emit("get_file_size_finish", ut)
- }
- })
- }
- function copySliceItem(a, e) {
- var i = a.TaskId
- , o = a.Bucket
- , s = a.Region
- , c = a.Key
- , d = a.CopySource
- , _ = a.UploadId
- , b = a.PartNumber * 1
- , k = a.CopySourceRange
- , j = this.options.ChunkRetryTimes + 1
- , $ = this;
- Async.retry(j, function(_e) {
- $.uploadPartCopy({
- TaskId: i,
- Bucket: o,
- Region: s,
- Key: c,
- CopySource: d,
- UploadId: _,
- PartNumber: b,
- CopySourceRange: k
- }, function(et, tt) {
- _e(et || null, tt)
- })
- }, function(_e, et) {
- return e(_e, et)
- })
- }
- var API_MAP = {
- sliceUploadFile,
- abortUploadTask,
- uploadFile,
- uploadFiles,
- sliceCopyFile
- };
- advance$1.init = function(a, e) {
- e.transferToTaskMethod(API_MAP, "sliceUploadFile"),
- util$1.each(API_MAP, function(i, o) {
- a.prototype[o] = util$1.apiWrapper(o, i)
- })
- }
- ;
- var util = util_1
- , event = event$1
- , task = task$1
- , base = base$1
- , advance = advance$1
- , defaultOptions = {
- AppId: "",
- SecretId: "",
- SecretKey: "",
- SecurityToken: "",
- ChunkRetryTimes: 2,
- FileParallelLimit: 3,
- ChunkParallelLimit: 3,
- ChunkSize: 1024 * 1024,
- SliceSize: 1024 * 1024,
- CopyChunkParallelLimit: 20,
- CopyChunkSize: 1024 * 1024 * 10,
- CopySliceSize: 1024 * 1024 * 10,
- MaxPartNumber: 1e4,
- ProgressInterval: 1e3,
- Domain: "",
- ServiceDomain: "",
- Protocol: "",
- CompatibilityMode: !1,
- ForcePathStyle: !1,
- UseRawKey: !1,
- Timeout: 0,
- CorrectClockSkew: !0,
- SystemClockOffset: 0,
- UploadCheckContentMd5: !1,
- UploadQueueSize: 1e4,
- UploadAddMetaMd5: !1,
- UploadIdCacheLimit: 50,
- UseAccelerate: !1,
- ForceSignHost: !0
- }
- , COS$1 = function(a) {
- this.options = util.extend(util.clone(defaultOptions), a || {}),
- this.options.FileParallelLimit = Math.max(1, this.options.FileParallelLimit),
- this.options.ChunkParallelLimit = Math.max(1, this.options.ChunkParallelLimit),
- this.options.ChunkRetryTimes = Math.max(0, this.options.ChunkRetryTimes),
- this.options.ChunkSize = Math.max(1024 * 1024, this.options.ChunkSize),
- this.options.CopyChunkParallelLimit = Math.max(1, this.options.CopyChunkParallelLimit),
- this.options.CopyChunkSize = Math.max(1024 * 1024, this.options.CopyChunkSize),
- this.options.CopySliceSize = Math.max(0, this.options.CopySliceSize),
- this.options.MaxPartNumber = Math.max(1024, Math.min(1e4, this.options.MaxPartNumber)),
- this.options.Timeout = Math.max(0, this.options.Timeout),
- this.options.AppId && console.warn('warning: AppId has been deprecated, Please put it at the end of parameter Bucket(E.g: "test-1250000000").'),
- this.options.SecretId && this.options.SecretId.indexOf(" ") > -1 && (console.error("error: SecretId\u683C\u5F0F\u9519\u8BEF\uFF0C\u8BF7\u68C0\u67E5"),
- console.error("error: SecretId format is incorrect. Please check")),
- this.options.SecretKey && this.options.SecretKey.indexOf(" ") > -1 && (console.error("error: SecretKey\u683C\u5F0F\u9519\u8BEF\uFF0C\u8BF7\u68C0\u67E5"),
- console.error("error: SecretKey format is incorrect. Please check")),
- 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"),
- 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")),
- event.init(this),
- task.init(this)
- };
- base.init(COS$1, task);
- advance.init(COS$1, task);
- COS$1.util = {
- md5: util.md5,
- xml2json: util.xml2json,
- json2xml: util.json2xml
- };
- COS$1.getAuthorization = util.getAuth;
- COS$1.version = "1.3.6";
- var cos = COS$1
- , COS = cos
- , cosJsSdkV5 = COS;
- const SERVER_URL = "https://cos-auth.xversepro.com/sts"
- , COS_BUCKET = "xvbs-1258211750"
- , COS_REGION = "ap-guangzhou";
- var myCos = new cosJsSdkV5({
- getAuthorization: function(a, e) {
- var i = SERVER_URL
- , o = new XMLHttpRequest;
- o.open("GET", i, !0),
- o.onload = function(s) {
- try {
- var c = JSON.parse(s.target.responseText)
- , d = c.credentials
- } catch (_) {
- console.error(_)
- }
- if (!c || !d)
- return console.error(`credentials invalid:
- ` + JSON.stringify(c, null, 2));
- e({
- TmpSecretId: d.tmpSecretId,
- TmpSecretKey: d.tmpSecretKey,
- SecurityToken: d.sessionToken,
- StartTime: c.startTime,
- ExpiredTime: c.expiredTime
- })
- }
- ,
- o.send()
- }
- });
- function uploadStream(a, e) {
- myCos.putObject({
- Bucket: COS_BUCKET,
- Region: COS_REGION,
- Key: a,
- StorageClass: "STANDARD",
- Body: e,
- onProgress: function(i) {
- console.log(JSON.stringify(i))
- }
- }, function(i, o) {
- console.log(i || o)
- })
- }
- const defaultLogger = {
- info: console.log,
- debug: console.log,
- error: console.error,
- infoAndReportMeasurement: (...a)=>{}
- };
- let log$l = defaultLogger
- , USER_ID = "987412365"
- , PAGE_SESSION = "aaabbbccc"
- , SERVER_SESSION = "cccbbbaaa";
- const COS_PREFIX = "error-bitstreams-auto-uploaded-from-application/"
- , FRAME_COMPOSE_LENGTH = 5;
- class Workers {
- constructor(e, i) {
- this.rtcp = e,
- this.cacheSize = 0,
- this.cacheBuffer = new Uint8Array(262144),
- this.cacheFrameCnt = 0,
- this.startReceiveTime = 0,
- this.cacheFrameComposes = new Array(0),
- this.cacheSizes = new Array(5).fill(0),
- this.cacheFrameCnts = new Array(5).fill(-1),
- this.cacheStartReceiveTimes = new Array(5).fill(0),
- this.cacheBuffers = [new Uint8Array(262144), new Uint8Array(262144), new Uint8Array(262144), new Uint8Array(262144), new Uint8Array(262144)],
- this.panoCacheSize = 0,
- this.panoCacheBuffer = new Uint8Array(2097152),
- this.cachePanoTileID = 0,
- this.receivedMedia = 0,
- this.receivedMedia_worker = 0,
- this.receivedYUV = 0,
- this.receivedEmit = 0,
- this.returnFrames = 0,
- this.lastReturnFrames = 0,
- this.lastReceivedEmit = 0,
- this.mediaBytesReceived = 0,
- this.metaBytesReceived = 0,
- this.noWasmBytesReceived = 0,
- this.rtcBytesReceived = 0,
- this.rtcMessageReceived = 0,
- this.packetsDrop = 0,
- this.framesAwait = 0,
- this.sendOutBuffer = 0,
- this.decodeTimePerFrame = 0,
- this.decodeTimeMaxFrame = 0,
- this.lastRenderTs = 0,
- this.JankTimes = 0,
- this.bigJankTimes = 0,
- this.DecodeJankTimes = 0,
- this.bigDecodeJankTimes = 0,
- this.saveframe = !1,
- this.SaveMediaStream = !1,
- this.packetsLost = 0,
- this.showAllReceivedMetadata = !1,
- this.firstMediaArraval = 0,
- this.firstMediaReceived = !1,
- this.firstYUVDecoded = 0,
- this.firstRender = 0,
- this.firstYUVReceived = !1,
- this.reconnectSignal = !1,
- this.serverFrameSlow = 0,
- this.serverFrameFast = 0,
- this.clientFrameSlow = 0,
- this.clientFrameFast = 0,
- this.lastServerTS = 0,
- this.lastClientTS = 0,
- this.lastSeq = 0,
- this.lastIsPureMeta = !1,
- this.lastHBPacketTs = 0,
- this.HBPacketInterval = 0,
- this.lastHBPacketSrvSentTs = 0,
- this.HBPacketIntervalSrvSent = 0,
- this.cachedLength = 2,
- this.cachedStreams = new Array(this.cachedLength),
- this.cachedMetas = new Array(this.cachedLength),
- this.cachedPtss = new Array(this.cachedLength),
- this.cachedRender = Array(this.cachedLength).fill(!1),
- this.cachedResolution = new Array(this.cachedLength),
- this.getPtr = 0,
- this.setPtr = 0,
- this.receiveIframes = 0,
- this.decodeIframes = 0,
- this.prevSenderTs = -1,
- this.serverSendTimeArray = new CircularArray(120,!1,[]),
- this.inPanoMode = !1,
- this.PanoStatus = {
- x: 0,
- y: 0,
- z: 0,
- tiles: []
- },
- this.DynamicPanoTest = !1,
- this.PanoMask = new ArrayBuffer(8),
- this.PanoView = new DataView(this.PanoMask),
- this.userId_test = "",
- this.PendingMasks = [],
- this.traceIdMap = new Map,
- this.responseTimeArray = [],
- this.processTimeArray = [],
- this.displayTimeArray = [],
- this.overallTimeArray = [],
- this.responseMiss = 0,
- this.processMiss = 0,
- this.displayMiss = 0,
- this.joyStickTraceIdMap = new Map,
- this.joyStickResponseTimeArray = [],
- this.joyStickProcessTimeArray = [],
- this.joyStickDisplayTimeArray = [],
- this.joyStickOverallTimeArray = [],
- this.joyStickResponseMiss = 0,
- this.joyStickProcessMiss = 0,
- this.joyStickDisplayMiss = 0,
- this.updateYUVCircular = new CircularArray(120,!1,[]),
- this.updateDropFrame = 0,
- this.metaParseAraay = [],
- this.responseMoveMiss = 0,
- this.processMoveMiss = 0,
- this.displayMoveMiss = 0,
- this.MovingTraceId = "",
- this.PendingMovingTraceId = "",
- this.inMovingMode = !1,
- this.StartMovingTs = 0,
- this.PendingStartMovingTs = 0,
- this.moveEvent = "",
- this.MoveToFrameCnt = 0,
- this.lastIsMoving = 0,
- this.MoveResponseDelay = 0,
- this.MoveProcessDelay = 0,
- this.MoveDisplayDelay = 0,
- this.lastMoveResponseTime = 0,
- this.lastMoveProcessTime = 0,
- this.lastMoveDisplayTime = 0,
- this.moveResponseCircular = new CircularArray(120,!0,[STUCK_STAGE_GOOD, STUCK_STAGE_WELL, STUCK_STAGE_FAIR, STUCK_STAGE_BAD]),
- this.moveProcessCircular = new CircularArray(120,!0,[STUCK_STAGE_GOOD, STUCK_STAGE_WELL, STUCK_STAGE_FAIR, STUCK_STAGE_BAD]),
- this.moveDisplayCircular = new CircularArray(120,!0,[STUCK_STAGE_GOOD, STUCK_STAGE_WELL, STUCK_STAGE_FAIR, STUCK_STAGE_BAD]),
- this.moveStartPts = -1,
- this.frameServerCircular = new CircularArray(120,!1,[]),
- this.srvMetaIntervalCircular = new CircularArray(120,!1,[]),
- this.srvMediaIntervalCircular = new CircularArray(120,!1,[]),
- this.srvHBMetaIntervalCircular = new CircularArray(120,!1,[]),
- this.srvHBMetaIntervalSrvSentCircular = new CircularArray(120,!1,[]),
- this.frameClientCircular = new CircularArray(120,!1,[]),
- this.unmarshalStreamExecutionArray = new SecondArray,
- this.receiveYUVExecutionArray = new SecondArray,
- this.postMessageWaitArray = new SecondArray,
- this.firstUpdateYUV = !0,
- this.functionMap = new Map,
- this.WASM_VERSION = "WASM-1.1",
- this.frameHistory = [],
- this.getVersion = function() {
- return DECODER_VERSION
- }
- ,
- this.downloadBlob = (o,s,c)=>{
- const d = new Blob([o],{
- type: c
- })
- , _ = window.URL.createObjectURL(d);
- this.downloadURL(_, s),
- setTimeout(function() {
- return window.URL.revokeObjectURL(_)
- }, 1e3)
- }
- ,
- this.downloadURL = function(o, s) {
- const c = document.createElement("a");
- c.href = o,
- c.download = s,
- document.body.appendChild(c),
- c.style.display = "none",
- c.click(),
- c.remove()
- }
- ,
- this.Stringify = function(o) {
- let s = "";
- for (let d = 0; d < o.length / 8192; d++)
- s += String.fromCharCode.apply(null, o.slice(d * 8192, (d + 1) * 8192));
- return s
- }
- ,
- this._rtcp = e
- }
- registerLogger(e) {
- log$l = e
- }
- registerFunction(e, i) {
- this.functionMap.set(e, i)
- }
- hasFrmCntInCache(e) {
- let i = -1;
- for (let o = 0; o < this.cacheFrameComposes.length; o++)
- this.cacheFrameComposes[o].frameCnt == e && (i = o);
- return i
- }
- requestPanoramaTest(e, i, o, s, c) {
- const d = c
- , _ = {
- action_type: 16,
- change_rotation_render_type_action: {
- render_type: 5,
- player: {
- position: {
- x: 0,
- y: 0,
- z: 0
- },
- angle: {
- yaw: 0,
- pitch: 0,
- roll: 0
- }
- },
- camera: {
- position: {
- x: e,
- y: i,
- z: o
- },
- angle: {
- yaw: 0,
- pitch: 0,
- roll: 0
- }
- },
- client_pano_titles_bitmap: s
- },
- trace_id: d,
- user_id: this.userId_test,
- packet_id: d
- };
- log$l.debug("send data: ", _),
- this._rtcp.sendData(_)
- }
- onRotateInPanoMode(e) {
- const i = e.traceId
- , o = {};
- o.width = 1280,
- o.height = 720,
- o.horz_fov = 92,
- o.angle = {
- yaw: 100,
- pitch: 30
- };
- const s = new ArrayBuffer(8)
- , c = new DataView(s);
- getTilesInView(o, s);
- const d = s.slice(0);
- this.PendingMasks.unshift({
- buffer: d,
- angle: o.angle
- }),
- MaskSetToOne(18, this.PanoView),
- operateForDataView(c, this.PanoView, c, (_,b)=>_ ^ _ & b),
- 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)
- }
- processMetaWithTraceId(e) {
- for (const i of e.traceIds) {
- if (this.traceIdMap.has(i)) {
- const o = this.traceIdMap.get(i);
- o != null && (o.receiveTime = Date.now(),
- o.status = 1)
- }
- if (this.joyStickTraceIdMap.has(i)) {
- const o = this.joyStickTraceIdMap.get(i);
- o != null && (o.receiveTime = Date.now(),
- o.status = 1)
- }
- if (i == this.PendingMovingTraceId) {
- this.inMovingMode = !0,
- this.MovingTraceId = this.PendingMovingTraceId,
- this.StartMovingTs = this.PendingStartMovingTs,
- this.PendingMovingTraceId = "",
- this.PendingStartMovingTs = 0,
- log$l.info("MoveTo TraceId match", this.StartMovingTs, Date.now());
- const o = Date.now();
- this.lastMoveResponseTime = o,
- this.lastMoveProcessTime = o,
- this.lastMoveDisplayTime = o,
- this.frameServerCircular.clear(),
- this.frameClientCircular.clear()
- }
- }
- }
- onTraceId(e, i=this) {
- const o = e.traceId
- , s = e.timestamp
- , c = e.event;
- if (c === "Rotation") {
- const d = {
- traceId: o,
- pts: 0,
- startTime: s,
- receiveTime: 0,
- readyTime: 0,
- displayTime: 0,
- status: 0
- };
- this.traceIdMap.set(o, d);
- const _ = setTimeout(()=>{
- if (_ && clearTimeout(_),
- this.traceIdMap.has(o)) {
- const b = this.traceIdMap.get(o);
- switch (b == null ? void 0 : b.status) {
- case 0:
- {
- this.responseMiss += 1;
- break
- }
- case 1:
- {
- this.processMiss += 1;
- const k = b.receiveTime - b.startTime;
- this.responseTimeArray.push(k);
- break
- }
- case 2:
- {
- this.displayMiss += 1;
- const k = b.receiveTime - b.startTime
- , j = b.readyTime - b.receiveTime;
- this.responseTimeArray.push(k),
- this.processTimeArray.push(j);
- break
- }
- case 3:
- log$l.debug("status is 3")
- }
- }
- }
- , 1e3)
- } else if (c === "Joystick") {
- const d = {
- traceId: o,
- pts: 0,
- startTime: s,
- receiveTime: 0,
- readyTime: 0,
- displayTime: 0,
- status: 0
- };
- this.joyStickTraceIdMap.set(o, d);
- const _ = setTimeout(()=>{
- if (_ && clearTimeout(_),
- this.joyStickTraceIdMap.has(o)) {
- const b = this.joyStickTraceIdMap.get(o);
- switch (b == null ? void 0 : b.status) {
- case 0:
- {
- this.joyStickResponseMiss += 1;
- break
- }
- case 1:
- {
- this.joyStickProcessMiss += 1;
- const k = b.receiveTime - b.startTime;
- this.joyStickResponseTimeArray.push(k);
- break
- }
- case 2:
- {
- this.joyStickDisplayMiss += 1;
- const k = b.receiveTime - b.startTime
- , j = b.readyTime - b.receiveTime;
- this.joyStickResponseTimeArray.push(k),
- this.joyStickProcessTimeArray.push(j);
- break
- }
- case 3:
- log$l.debug("status is 3")
- }
- }
- }
- , 1e3)
- } else
- c === "MoveTo" ? (log$l.info("receive moveto traceId ", o, " at timestamp", s),
- this.PendingMovingTraceId = o,
- this.PendingStartMovingTs = s,
- this.moveEvent = c,
- this.frameServerCircular.clear()) : c === "GetOnAirship" || c === "GetOnVehicle" ? (log$l.info("receive airship traceId ", o, " at timestamp ", s),
- this.PendingMovingTraceId = o,
- this.PendingStartMovingTs = s,
- this.moveEvent = c,
- this.frameServerCircular.clear()) : (c === "GetOffAirship" || c === "GetOffVehicle") && this.clearMoveArray()
- }
- executeFunction(e, i) {
- if (this.functionMap.has(e)) {
- const o = this.functionMap.get(e);
- o != null && o(i)
- }
- }
- UpdateStats(e) {
- var i;
- (i = this._rtcp.connection) == null || i.getStats(null).then(o=>{
- o.forEach(s=>{
- s.type == "data-channel" && (this.rtcMessageReceived = s.messagesReceived - s.messagesSent,
- this.rtcBytesReceived = s.bytesReceived)
- }
- )
- }
- ),
- this.receivedMedia_worker = e.data.framesReceived,
- this.receivedYUV = e.data.framesDecoded,
- this.receivedEmit = e.data.framesRendered,
- this.mediaBytesReceived = e.data.mediaBytesReceived,
- this.metaBytesReceived = e.data.metaBytesReceived,
- this.packetsLost = e.data.packetsLost,
- this.packetsDrop = e.data.packetsDrop,
- this.framesAwait = e.data.framesAwait,
- this.decodeTimePerFrame = e.data.decodeTimePerFrame,
- this.decodeTimeMaxFrame = e.data.decodeTimeMaxFrame,
- this.returnFrames = e.data.framesReturned,
- this.sendOutBuffer = e.data.sendOutBuffer,
- this.DecodeJankTimes = e.data.JankTimes,
- this.bigDecodeJankTimes = e.data.bigJankTimes,
- this.receiveIframes = e.data.receivedIframe,
- this.decodeIframes = e.data.decodedIframe
- }
- ReceiveDecodeMessage(e) {
- var b;
- const i = Date.now()
- , o = i - e.data.postTs;
- if (this.postMessageWaitArray.add(o),
- !this.firstYUVReceived) {
- this.firstYUVDecoded = e.data.yuv_ts;
- const k = this.firstYUVDecoded - this.rtcp.network.room._startTime;
- log$l.infoAndReportMeasurement({
- metric: "firstYUVDecodedAt",
- value: k,
- group: "joinRoom"
- }),
- this.firstRender = Date.now();
- const j = this.firstYUVDecoded - this.rtcp.network.room._startTime;
- log$l.infoAndReportMeasurement({
- metric: "firstRenderAt",
- value: j,
- group: "joinRoom"
- }),
- this.firstYUVReceived = !0,
- this.lastRenderTs = Date.now()
- }
- !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", {
- stream: this.cachedStreams[this.setPtr],
- width: this.cachedResolution[this.setPtr].width,
- height: this.cachedResolution[this.setPtr].height,
- pts: this.cachedPtss[this.setPtr]
- }),
- this.executeFunction("signal", {
- signal: this.cachedMetas[this.setPtr],
- pts: this.cachedPtss[this.setPtr],
- alreadyUpdateYUV: !0
- })) : this.updateDropFrame += 1,
- this.decoderWorker.postMessage({
- t: 2,
- frameCnt: this.cachedPtss[this.setPtr],
- buffer: this.cachedStreams[this.setPtr]
- }, [this.cachedStreams[this.setPtr].buffer])),
- this.getPtr = (this.getPtr + 1) % this.cachedLength);
- const s = e.data.metadata;
- if ((b = s == null ? void 0 : s.traceIds) != null && b.length)
- for (const k of s.traceIds) {
- if (this.traceIdMap.has(k)) {
- const j = this.traceIdMap.get(k);
- j != null && (j.readyTime = Date.now(),
- j.status = 2)
- }
- if (this.joyStickTraceIdMap.has(k)) {
- const j = this.joyStickTraceIdMap.get(k);
- j != null && (j.readyTime = Date.now(),
- j.status = 2)
- }
- }
- if (e.data.pts == this.moveStartPts && (this.MoveProcessDelay = Date.now() - this.StartMovingTs),
- this.userId_test = this.rtcp.network.room.userId,
- this.inMovingMode) {
- const k = Date.now()
- , j = k - this.lastMoveProcessTime;
- this.moveProcessCircular.add(j),
- this.lastMoveProcessTime = k
- }
- const c = this.setPtr;
- this.cachedStreams[c] = e.data.data,
- this.cachedMetas[c] = e.data.metadata,
- this.cachedPtss[c] = e.data.pts,
- this.cachedRender[c] = !1,
- this.cachedResolution[c] = {
- width: e.data.width,
- height: e.data.height
- },
- this.setPtr = (this.setPtr + 1) % this.cachedLength;
- const _ = Date.now() - i;
- this.receiveYUVExecutionArray.add(_)
- }
- SendCacheFrameInfo(e) {
- var $, _e, et, tt, rt, it, nt;
- const i = e.data.cachedKey
- , o = e.data.metadata
- , s = i
- , c = o
- , 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
- , _ = this.rtcp.network.room.skinId
- , 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
- , k = {
- MsgType: 1,
- FrameCacheMsg: {
- FrameIndex: s,
- RoomTypeId: d,
- SkinID: _,
- Position: b
- }
- };
- let j = "";
- try {
- j = JSON.stringify(k)
- } catch (ot) {
- log$l.error(ot);
- return
- }
- }
- ReceivePanoramaDecodeMessage(e) {
- log$l.info("Receive Panorama Image in Workers.ts"),
- MaskSetToOne(e.data.tileId, this.PanoView);
- let i = 0, o;
- const s = this.PendingMasks.length;
- for (i = 0; i < s; i++) {
- const c = this.PendingMasks[i].buffer
- , d = new DataView(c)
- , _ = new ArrayBuffer(8)
- , b = new DataView(_);
- if (operateForDataView(this.PanoView, d, b, (k,j)=>j ^ k & j),
- IsAll0(b)) {
- o = this.PendingMasks[i].angle;
- break
- }
- }
- for (let c = i; c < s; c++)
- this.PendingMasks.pop();
- this.executeFunction("panorama", {
- data: e.data.data,
- metadata: e.data.metadata,
- tileId: e.data.tileId,
- finished: !0,
- matchAngle: o
- })
- }
- enable_decoder_queue_logging() {
- this.decoderWorker.postMessage({
- t: 100,
- status: !0
- })
- }
- disable_decoder_queue_logging() {
- this.decoderWorker.postMessage({
- t: 100,
- status: !1
- })
- }
- async init(e={
- width: 1280,
- height: 720,
- userID: "testUserId",
- pageSession: "pagesession1",
- serverSession: "serversession1"
- }) {
- for (let o = 0; o < FRAME_COMPOSE_LENGTH; o++) {
- const s = {
- buffer: new Uint8Array(262144),
- size: 0,
- startReceiveTime: 0,
- serverTime: 0,
- frameCnt: -1
- };
- this.cacheFrameComposes.push(s)
- }
- USER_ID = e.userID,
- PAGE_SESSION = e.pageSession,
- SERVER_SESSION = e.serverSession;
- const i = new Blob([decoder],{
- type: "application/javascript"
- });
- return this.decoderWorker = new Worker(URL.createObjectURL(i)),
- this.decoderWorker.postMessage({
- t: 9,
- url: WASM_URLS[WASM_Version],
- jitterLength: DECODER_PASSIVE_JITTER
- }),
- this.decoderWorker.postMessage({
- t: 1,
- config: e
- }),
- new Promise(o=>{
- this.decoderWorker.onmessage = s=>{
- switch (s.data.t) {
- case 0:
- this.ReceiveDecodeMessage(s);
- break;
- case 1:
- this.UpdateStats(s);
- break;
- case 2:
- o();
- break;
- case 3:
- this.SendCacheFrameInfo(s);
- break;
- case 4:
- {
- const c = new Date().toISOString()
- , d = USER_ID + "-" + PAGE_SESSION + "-" + SERVER_SESSION + "-" + c + ".264";
- uploadStream(COS_PREFIX + d, s.data.fileObj);
- break
- }
- case 5:
- this.executeFunction("signal", {
- signal: s.data.metadata,
- pts: -1,
- alreadyUpdateYUV: !1
- });
- break;
- case 6:
- log$l.infoAndReportMeasurement(s.data.data),
- log$l.debug("WASM Ready Cost");
- break;
- case 7:
- this.ReceivePanoramaDecodeMessage(s);
- break;
- case 8:
- {
- const c = {
- MstType: 0
- };
- let d = "";
- try {
- d = JSON.stringify(c)
- } catch (b) {
- log$l.error(b);
- return
- }
- const _ = "wasm:" + d;
- this._rtcp.sendStringData(_);
- break
- }
- case 9:
- {
- log$l.info(s.data.printMsg);
- break
- }
- case 10:
- {
- log$l.error(s.data.printMsg),
- this.executeFunction("error", {
- code: s.data.code,
- message: s.data.printMsg
- });
- break
- }
- default:
- log$l.error("Receive unknown message event from decoder"),
- log$l.debug(s.data);
- break
- }
- }
- }
- )
- }
- setPageSession(e) {
- PAGE_SESSION = e
- }
- UpdateYUV() {
- var i, o;
- const e = this.getPtr;
- if (this.cachedMetas[e] != null && !this.cachedRender[e]) {
- const s = Date.now();
- if (this.firstUpdateYUV) {
- const $ = ((i = this.cachedStreams[e]) == null ? void 0 : i.byteLength) || 0;
- log$l.infoAndReportMeasurement({
- metric: "firstUpdateStreamLength",
- value: $,
- group: "joinRoom"
- }),
- this.firstUpdateYUV = !1
- }
- this.cachedStreams[e] != null && this.executeFunction("stream", {
- stream: this.cachedStreams[e],
- width: this.cachedResolution[e].width,
- height: this.cachedResolution[e].height,
- pts: this.cachedPtss[e]
- });
- const c = Date.now();
- this.cachedStreams[e] != null && this.decoderWorker.postMessage({
- t: 2,
- frameCnt: this.cachedPtss[e],
- buffer: this.cachedStreams[e]
- }, [this.cachedStreams[e].buffer]);
- const d = Date.now()
- , _ = c - s
- , b = d - c;
- (_ > 33 || b > 10) && log$l.debug("[wwwarning] updateYUV takes ", _, " ms, postMessage takes ", b, " ms for index ", this.cachedPtss[e]),
- c - this.lastRenderTs > 84 && this.JankTimes++,
- c - this.lastRenderTs > 125 && this.bigJankTimes++,
- this.lastRenderTs = c;
- const k = c - s;
- this.updateYUVCircular.add(k);
- const j = this.cachedMetas[e];
- if ((o = j == null ? void 0 : j.traceIds) != null && o.length)
- for (const $ of j.traceIds) {
- if (this.traceIdMap.has($)) {
- const _e = this.traceIdMap.get($);
- if (_e != null) {
- _e.displayTime = Date.now(),
- _e.status = 3;
- const et = _e.receiveTime - _e.startTime
- , tt = _e.readyTime - _e.receiveTime
- , rt = _e.displayTime - _e.readyTime
- , it = _e.displayTime - _e.startTime;
- this.responseTimeArray.push(et),
- this.processTimeArray.push(tt),
- this.displayTimeArray.push(rt),
- this.overallTimeArray.push(it),
- this.traceIdMap.delete($)
- }
- }
- if (this.joyStickTraceIdMap.has($)) {
- const _e = this.joyStickTraceIdMap.get($);
- if (_e != null) {
- _e.displayTime = Date.now(),
- _e.status = 3;
- const et = _e.receiveTime - _e.startTime
- , tt = _e.readyTime - _e.receiveTime
- , rt = _e.displayTime - _e.readyTime
- , it = _e.displayTime - _e.startTime;
- this.joyStickResponseTimeArray.push(et),
- this.joyStickProcessTimeArray.push(tt),
- this.joyStickDisplayTimeArray.push(rt),
- this.joyStickOverallTimeArray.push(it),
- this.joyStickTraceIdMap.delete($)
- }
- }
- }
- if (this.cachedPtss[e] == this.moveStartPts && (this.MoveDisplayDelay = Date.now() - this.StartMovingTs),
- this.inMovingMode) {
- const $ = Date.now()
- , _e = $ - this.lastMoveDisplayTime;
- this.moveDisplayCircular.add(_e),
- this.lastMoveDisplayTime = $
- }
- this.executeFunction("signal", {
- signal: this.cachedMetas[e],
- pts: this.cachedPtss[e],
- alreadyUpdateYUV: !0
- }),
- this.cachedRender[e] = !0,
- this.getPtr = (this.getPtr + 1) % this.cachedLength
- }
- }
- unmarshalPano(e) {
- const i = new DataView(e)
- , o = i.getUint32(0);
- if (o == 1723558763)
- return !0;
- if (o != 2296221069)
- return !1;
- console.log("Receive Pano Message"),
- i.getUint16(4);
- const s = i.getUint16(6)
- , c = i.getUint32(8)
- , d = i.getUint32(12)
- , _ = i.getUint32(16)
- , b = i.getUint32(20)
- , k = e.byteLength - s;
- if (k == d) {
- const j = new Uint8Array(e).subarray(s).slice(0, _)
- , _e = {
- data: new Uint8Array(e).subarray(s).slice(_, d),
- mediaLen: d - _,
- metadata: j,
- metaLen: _,
- tileId: c
- };
- this.decoderWorker.postMessage({
- t: 8,
- data: _e
- })
- } else {
- const j = new Uint8Array(e,s,k);
- if (this.cachePanoTileID == c) {
- if (this.panoCacheBuffer.set(j, b),
- this.panoCacheSize += k,
- this.panoCacheSize === d) {
- const $ = new Uint8Array(this.panoCacheBuffer).slice(0, _)
- , et = {
- data: new Uint8Array(this.panoCacheBuffer).slice(_, d),
- mediaLen: d - _,
- metadata: $,
- metaLen: _,
- tileId: c
- };
- this.decoderWorker.postMessage({
- t: 8,
- data: et
- }),
- this.panoCacheSize = 0
- }
- } else
- this.panoCacheBuffer.set(j, b),
- this.panoCacheSize = k,
- this.cachePanoTileID = c
- }
- return !0
- }
- clearMoveArray() {
- this.MovingTraceId = "",
- this.inMovingMode = !1,
- this.StartMovingTs = 0,
- this.MoveToFrameCnt = 0,
- this.MoveResponseDelay = 0,
- this.MoveProcessDelay = 0,
- this.MoveDisplayDelay = 0,
- this.moveStartPts = -1,
- this.moveResponseCircular.clear(),
- this.moveProcessCircular.clear(),
- this.moveDisplayCircular.clear(),
- this.moveEvent = ""
- }
- getIsMoving(e) {
- let i;
- if (typeof e.newUserStates != "undefined")
- for (let o = 0; o < e.newUserStates.length; o++) {
- const s = e.newUserStates[o];
- if (s.userId == this.rtcp.network.room.userId) {
- i = s.renderInfo.isMoving;
- break
- }
- }
- return i
- }
- isHeartBeatPacket(e, i) {
- return new DataView(e).getUint32(0) == 2009889916
- }
- resetSendTimeDiff() {
- this.prevSenderTs = 0,
- this.serverSendTimeArray.clear()
- }
- calcSendTimeDiff(e) {
- if (this.prevSenderTs == -1) {
- this.prevSenderTs = e;
- return
- }
- const i = e - this.prevSenderTs;
- this.serverSendTimeArray.add(i),
- this.prevSenderTs = e
- }
- unmarshalStream(e) {
- var lt, ft, ht, pt, dt, _t, mt, vt, yt, Et;
- const i = Date.now()
- , o = new DataView(e);
- if (o.getUint32(0) != 1437227610)
- return !1;
- o.getUint16(4);
- const c = o.getUint16(6)
- , d = o.getUint16(8)
- , _ = d
- , b = o.getUint16(10);
- let k = !1;
- b == 1 && (k = !0);
- const j = o.getUint32(12)
- , $ = o.getUint32(16)
- , _e = o.getUint32(20)
- , et = o.getUint16(24)
- , tt = o.getUint16(26)
- , rt = o.getUint32(28)
- , it = o.getUint32(c - 4)
- , nt = j + $
- , ot = e.byteLength - c
- , at = new Uint8Array(e,c,ot);
- this.calcSendTimeDiff(_e);
- let st;
- if (this.inPanoMode && ($ > 0 || et))
- return log$l.error("Stream Protocal Violation: receive illegal stream in Pano mode"),
- !0;
- if (ot === nt) {
- this.receivedMedia++;
- const At = new Uint8Array(e).subarray(c);
- _e - this.lastServerTS > 60 ? this.serverFrameSlow++ : _e - this.lastServerTS < 16 && this.serverFrameFast++;
- const gt = Date.now();
- gt - this.lastClientTS > 60 ? this.clientFrameSlow++ : gt - this.lastClientTS < 16 && this.clientFrameFast++;
- const St = $ === 0
- , xt = _e - this.lastServerTS;
- this.lastServerTS != 0 && ((d + 65536 - this.lastSeq) % 65536 === 1 && this.lastIsPureMeta == St && (St ? this.srvMetaIntervalCircular.add(xt) : this.srvMediaIntervalCircular.add(xt)),
- this.frameServerCircular.add(xt),
- this.frameClientCircular.add(gt - this.lastClientTS)),
- this.lastSeq = d,
- this.lastIsPureMeta = St,
- this.lastServerTS = _e,
- this.lastClientTS = gt;
- const bt = At.subarray(0, j)
- , Rt = Date.now()
- , Mt = JSON.parse(this.Stringify(bt))
- , Pt = Date.now();
- this.showAllReceivedMetadata && console.log(_e, gt, Mt),
- this.metaParseAraay.push(Pt - Rt),
- (lt = Mt.traceIds) != null && lt.length && this.processMetaWithTraceId(Mt),
- $ != 0 && this.moveStartPts == -1 && this.inMovingMode && (this.moveStartPts = d),
- this.moveStartPts == d && (this.MoveResponseDelay = Date.now() - this.StartMovingTs,
- console.log("move response delay: ", d, this.moveStartPts, this.MoveResponseDelay));
- const It = this.getIsMoving(Mt);
- if (this.inMovingMode && It == 0 && this.lastIsMoving == 1 && this.clearMoveArray(),
- typeof It != "undefined" && (this.lastIsMoving = It),
- this.inMovingMode) {
- const Ct = Date.now()
- , Ot = Ct - this.lastMoveResponseTime;
- this.moveResponseCircular.add(Ot),
- this.lastMoveResponseTime = Ct
- }
- (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);
- const Dt = {
- t: 0,
- data: At,
- mediaLen: $,
- metaLen: j,
- metadata: Mt,
- frameCnt: _,
- server_ts: _e,
- isIDR: k,
- cacheRequest: tt,
- cached: et,
- cachedKey: rt,
- position: st
- };
- if (this.inPanoMode)
- return this.executeFunction("signal", {
- signal: Mt,
- pts: -1,
- alreadyUpdateYUV: !0
- }),
- !0;
- if (this.decoderWorker.postMessage(Dt, [At.buffer]),
- !this.firstMediaReceived) {
- this.firstMediaArraval = Date.now();
- const Ct = this.firstMediaArraval - this.rtcp.network.room._startTime;
- log$l.infoAndReportMeasurement({
- metric: "firstMediaArravalAt",
- value: Ct,
- group: "joinRoom"
- }),
- this.firstMediaReceived = !0
- }
- } else {
- const At = this.hasFrmCntInCache(_);
- if (At != -1)
- if (this.cacheFrameComposes[At].buffer.set(at, it),
- this.cacheFrameComposes[At].size += ot,
- this.cacheFrameComposes[At].size === nt) {
- const gt = new Uint8Array(this.cacheFrameComposes[At].buffer).slice(0, nt);
- this.cacheFrameComposes[At].frameCnt = -1,
- this.cacheFrameComposes[At].size = 0,
- this.cacheFrameComposes[At].startReceiveTime = 0,
- this.cacheFrameComposes[At].serverTime = 0,
- this.receivedMedia++,
- _e - this.lastServerTS > 60 ? this.serverFrameSlow++ : _e - this.lastServerTS < 16 && this.serverFrameFast++;
- const St = Date.now();
- St - this.lastClientTS > 60 ? this.clientFrameSlow++ : St - this.lastClientTS < 16 && this.clientFrameFast++,
- this.lastServerTS != 0 && (this.frameServerCircular.add(_e - this.lastServerTS),
- this.frameClientCircular.add(St - this.lastClientTS)),
- this.lastServerTS = _e,
- this.lastClientTS = St;
- const xt = gt.subarray(0, j)
- , bt = Date.now()
- , Rt = JSON.parse(this.Stringify(xt))
- , Mt = Date.now();
- this.showAllReceivedMetadata && console.log(_e, St, Rt),
- this.metaParseAraay.push(Mt - bt),
- (_t = Rt.traceIds) != null && _t.length && this.processMetaWithTraceId(Rt),
- $ != 0 && this.moveStartPts == -1 && this.inMovingMode && (this.moveStartPts = d),
- this.moveStartPts == d && (this.MoveResponseDelay = Date.now() - this.StartMovingTs);
- const Pt = this.getIsMoving(Rt);
- if (this.inMovingMode && Pt == 0 && this.lastIsMoving == 1 && this.clearMoveArray(),
- typeof Pt != "undefined" && (this.lastIsMoving = Pt),
- this.inMovingMode) {
- const Dt = Date.now()
- , Ct = Dt - this.lastMoveResponseTime;
- this.moveResponseCircular.add(Ct),
- this.lastMoveResponseTime = Dt
- }
- (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);
- const It = {
- t: 0,
- data: gt,
- mediaLen: $,
- metaLen: j,
- metadata: Rt,
- frameCnt: _,
- server_ts: _e,
- isIDR: k,
- cacheRequest: tt,
- cached: et,
- cachedKey: rt,
- position: st
- };
- if (this.inPanoMode)
- return this.executeFunction("signal", {
- signal: Rt,
- pts: -1,
- alreadyUpdateYUV: !0
- }),
- !0;
- if (this.decoderWorker.postMessage(It, [gt.buffer]),
- !this.firstMediaReceived) {
- this.firstMediaArraval = Date.now();
- const Dt = this.firstMediaArraval - this.rtcp.network.room._startTime;
- log$l.infoAndReportMeasurement({
- metric: "firstMediaArravalAt",
- value: Dt,
- group: "joinRoom"
- }),
- this.firstMediaReceived = !0
- }
- } else
- this.cacheFrameComposes[At].size > nt && log$l.debug("I frame exceed, cache size is ", this.cacheSize, ", total size is ", nt);
- else if (At == -1) {
- let gt = this.hasFrmCntInCache(-1);
- if (gt == -1) {
- let St = Date.now() + 1e18
- , xt = -1;
- for (let bt = 0; bt < this.cacheFrameComposes.length; bt++)
- this.cacheFrameComposes[bt].serverTime < St && (St = this.cacheFrameComposes[bt].serverTime,
- xt = bt);
- gt = xt
- }
- this.cacheFrameComposes[gt].buffer.set(at, it),
- this.cacheFrameComposes[gt].size = ot,
- this.cacheFrameComposes[gt].frameCnt = _,
- this.cacheFrameComposes[gt].startReceiveTime = Date.now(),
- this.cacheFrameComposes[gt].serverTime = _e
- }
- }
- const ct = Date.now() - i;
- return this.unmarshalStreamExecutionArray.add(ct),
- !0
- }
- reset() {
- log$l.debug("Worker reset is called"),
- this.cacheFrameCnt = 0,
- this.receivedMedia = 0,
- this.reconnectSignal = !0,
- this.decoderWorker.postMessage({
- t: 4
- })
- }
- dataHandleOff(e) {
- log$l.debug("hhh")
- }
- dataHandle(e) {
- this.saveframe && (this.decoderWorker.postMessage({
- t: 6
- }),
- this.saveframe = !1),
- this.SaveMediaStream && (this.decoderWorker.postMessage({
- t: 7
- }),
- this.SaveMediaStream = !1);
- const i = new Uint8Array(e);
- if (i.length >= 4 && this.isHeartBeatPacket(i.buffer, i.length) == !0)
- return;
- if (i.length > 36 && this.unmarshalStream(i.buffer) == !0) {
- this.reconnectSignal && (this.executeFunction("reconnectedFrame", {}),
- this.reconnectSignal = !1);
- return
- }
- if (i.length > 20 && this.unmarshalPano(i.buffer) == !0)
- return;
- this.noWasmBytesReceived += e.byteLength;
- const o = JSON.parse(this.Stringify(i));
- this.executeFunction("signal", {
- signal: o,
- pts: -1,
- alreadyUpdateYUV: !0
- })
- }
- changePanoMode(e) {
- this.inPanoMode = e
- }
- uploadDataToServer() {
- this.DynamicPanoTest == !0 && (this.onRotateInPanoMode({
- traceId: "b2e1a296-6438-4371-8a31-687beb724ebe"
- }),
- this.DynamicPanoTest = !1);
- function e(ar, rr) {
- return rr == -1 && (rr = 0),
- ar + rr
- }
- function i(ar, rr) {
- return Math.max(ar, rr)
- }
- const o = this.responseTimeArray.reduce(e, 0) / this.responseTimeArray.length || 0
- , s = this.processTimeArray.reduce(e, 0) / this.processTimeArray.length || 0
- , c = this.displayTimeArray.reduce(e, 0) / this.displayTimeArray.length || 0
- , d = this.overallTimeArray.reduce(e, 0) / this.overallTimeArray.length || 0
- , _ = this.overallTimeArray.length;
- this.responseTimeArray = [],
- this.processTimeArray = [],
- this.displayTimeArray = [],
- this.overallTimeArray = [];
- const b = this.joyStickResponseTimeArray.reduce(e, 0) / this.joyStickResponseTimeArray.length || 0
- , k = this.joyStickProcessTimeArray.reduce(e, 0) / this.joyStickProcessTimeArray.length || 0
- , j = this.joyStickDisplayTimeArray.reduce(e, 0) / this.joyStickDisplayTimeArray.length || 0
- , $ = this.joyStickOverallTimeArray.reduce(e, 0) / this.joyStickOverallTimeArray.length || 0
- , _e = this.joyStickResponseTimeArray.reduce(i, 0)
- , et = this.joyStickProcessTimeArray.reduce(i, 0)
- , tt = this.joyStickDisplayTimeArray.reduce(i, 0)
- , rt = this.joyStickOverallTimeArray.reduce(i, 0);
- this.joyStickResponseTimeArray = [],
- this.joyStickProcessTimeArray = [],
- this.joyStickDisplayTimeArray = [],
- this.joyStickOverallTimeArray = [];
- const it = this.moveResponseCircular.getThreshPercent()
- , nt = it[0]
- , ot = it[1]
- , at = it[2]
- , st = it[3]
- , ut = it[4]
- , ct = ut - st
- , lt = 1 - ot / ut || 0
- , ft = [nt, ot - nt, at - ot, st - at, ct]
- , ht = this.moveProcessCircular.getThreshPercent()
- , pt = ht[0]
- , dt = ht[1]
- , _t = ht[2]
- , mt = ht[3]
- , vt = ht[4]
- , yt = vt - mt
- , Et = 1 - dt / vt || 0
- , At = [pt, dt - pt, _t - dt, mt - _t, yt]
- , gt = this.moveDisplayCircular.getThreshPercent()
- , St = gt[0]
- , xt = gt[1]
- , bt = gt[2]
- , Rt = gt[3]
- , Mt = gt[4]
- , Pt = Mt - Rt
- , It = 1 - xt / Mt || 0
- , Dt = [St, xt - St, bt - xt, Rt - bt, Pt]
- , Ct = St
- , Ot = xt - St
- , wt = bt - xt
- , Nt = Rt - bt
- , Ft = Pt
- , Vt = this.moveResponseCircular.getAvg()
- , Lt = this.moveProcessCircular.getAvg()
- , kt = this.moveDisplayCircular.getAvg()
- , Bt = this.moveResponseCircular.getMax()
- , Ut = this.moveProcessCircular.getMax()
- , Gt = this.moveDisplayCircular.getMax()
- , Ht = this.moveResponseCircular.getStandardDeviation()
- , zt = this.moveProcessCircular.getStandardDeviation()
- , Wt = this.moveDisplayCircular.getStandardDeviation();
- this.moveResponseCircular.getIncomingAvg(),
- this.moveProcessCircular.getIncomingAvg(),
- this.moveDisplayCircular.getIncomingAvg(),
- this.moveResponseCircular.getIncomingMax(),
- this.moveProcessCircular.getIncomingMax(),
- this.moveDisplayCircular.getIncomingMax(),
- this.moveResponseCircular.clearIncoming(),
- this.moveProcessCircular.clearIncoming(),
- this.moveDisplayCircular.clearIncoming();
- const Kt = this.frameServerCircular.getAvg()
- , Qt = this.frameServerCircular.getMax();
- this.frameClientCircular.getAvg(),
- this.frameClientCircular.getMax();
- const qt = this.metaParseAraay.reduce(e, 0) / this.metaParseAraay.length || 0
- , Yt = this.metaParseAraay.reduce(i, 0);
- this.metaParseAraay = [];
- const Jt = this.unmarshalStreamExecutionArray.getStat()
- , jt = this.receiveYUVExecutionArray.getStat()
- , Xt = this.postMessageWaitArray.getStat().max
- , nr = {
- mediaBytesReceived: this.mediaBytesReceived,
- metaBytesReceived: this.metaBytesReceived,
- packetsLost: this.packetsLost,
- timestamp: Date.now(),
- frameHeight: 1280,
- frameWidth: 720,
- framesReceived: this.receivedMedia,
- framesReceivedWorker: this.receivedMedia_worker,
- framesDecoded: this.receivedYUV,
- framesEmited: this.receivedEmit,
- decodeTimePerFrame: this.decodeTimePerFrame,
- decodeTimeMaxFrame: this.decodeTimeMaxFrame,
- packetsDrop: this.packetsDrop,
- framesAwait: this.framesAwait,
- firstMediaArraval: this.firstMediaArraval,
- firstYUVDecoded: this.firstYUVDecoded,
- firstRender: this.firstRender,
- returnFrames: this.returnFrames,
- sendOutBuffer: this.sendOutBuffer,
- maxGraphicTime: this.updateYUVCircular.getMax(),
- averageGraphicTime: this.updateYUVCircular.getAvg(),
- jankTimes: this.JankTimes,
- bigJankTimes: this.bigJankTimes,
- decodeJankTimes: this.DecodeJankTimes,
- bigDecodeJankTimes: this.bigDecodeJankTimes,
- serverFrameSlow: this.serverFrameSlow,
- serverFrameFast: this.serverFrameFast,
- clientFrameSlow: this.clientFrameSlow,
- clientFrameFast: this.clientFrameFast,
- rtcMessageReceived: this.rtcMessageReceived,
- rtcBytesReceived: this.rtcBytesReceived - this.noWasmBytesReceived,
- noWasmBytesReceived: this.noWasmBytesReceived,
- receiveIframes: this.receiveIframes,
- decodeIframes: this.decodeIframes,
- avgResponseTime: o,
- avgProcessTime: s,
- avgDisplayTime: c,
- avgOverallTime: d,
- overallTimeCount: _,
- responseMiss: this.responseMiss,
- processMiss: this.processMiss,
- displayMiss: this.displayMiss,
- updateDropFrame: this.updateDropFrame,
- moveEvent: this.moveEvent,
- avgResponseMoveDiff: this.moveEvent == "MoveTo" ? Vt : 0,
- avgProcessMoveDiff: this.moveEvent == "MoveTo" ? Lt : 0,
- avgDisplayMoveDiff: this.moveEvent == "MoveTo" ? kt : 0,
- maxResponseMoveDiff: this.moveEvent == "MoveTo" ? Bt : 0,
- maxProcessMoveDiff: this.moveEvent == "MoveTo" ? Ut : 0,
- maxDisplayMoveDiff: this.moveEvent == "MoveTo" ? Gt : 0,
- moveResponseJank: this.moveEvent == "MoveTo" ? lt : 0,
- moveProcessJank: this.moveEvent == "MoveTo" ? Et : 0,
- moveDisplayJank: this.moveEvent == "MoveTo" ? It : 0,
- moveResponseCounts: this.moveEvent == "MoveTo" ? ft.toString() : "0,0,0,0,0",
- moveProcessCounts: this.moveEvent == "MoveTo" ? At.toString() : "0,0,0,0,0",
- moveDisplayCounts: this.moveEvent == "MoveTo" ? Dt.toString() : "0,0,0,0,0",
- MoveDisplayCountGood: this.moveEvent == "MoveTo" ? Ct.toString() : "0",
- MoveDisplayCountWell: this.moveEvent == "MoveTo" ? Ot.toString() : "0",
- MoveDisplayCountFair: this.moveEvent == "MoveTo" ? wt.toString() : "0",
- MoveDisplayCountBad: this.moveEvent == "MoveTo" ? Nt.toString() : "0",
- MoveDisplayCountRest: this.moveEvent == "MoveTo" ? Ft.toString() : "0",
- moveResponseDelay: this.moveEvent == "MoveTo" ? this.MoveResponseDelay : 0,
- moveProcessDelay: this.moveEvent == "MoveTo" ? this.MoveProcessDelay : 0,
- moveDisplayDelay: this.moveEvent == "MoveTo" ? this.MoveDisplayDelay : 0,
- sdMoveResponseLongTime: Ht,
- sdMoveProcessLongTime: zt,
- sdMoveDisplayLongTime: Wt,
- avgResponseFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? Vt : 0,
- avgProcessFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? Lt : 0,
- avgDisplayFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? kt : 0,
- maxResponseFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? Bt : 0,
- maxProcessFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? Ut : 0,
- maxDisplayFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? Gt : 0,
- flyResponseJank: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? lt : 0,
- flyProcessJank: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? Et : 0,
- flyDisplayJank: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? It : 0,
- flyResponseCounts: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? ft.toString() : "0,0,0,0,0",
- flyProcessCounts: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? At.toString() : "0,0,0,0,0",
- flyDisplayCounts: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? Dt.toString() : "0,0,0,0,0",
- flyResponseDelay: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? this.MoveResponseDelay : 0,
- flyProcessDelay: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? this.MoveProcessDelay : 0,
- flyDisplayDelay: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? this.MoveDisplayDelay : 0,
- avgMetaParseTime: qt,
- maxMetaParseTime: Yt,
- avgServerDiff: Kt,
- maxServerDiff: Qt,
- unmarshalStreamStat: Jt,
- receiveYUVStat: jt,
- maxPostMsgDiff: Xt,
- streamType: WASM_Version,
- avgJoyStickResponseTime: b,
- avgJoyStickProcessTime: k,
- avgJoyStickDisplayTime: j,
- avgJoyStickOverallTime: $,
- maxJoyStickResponseTime: _e,
- maxJoyStickProcessTime: et,
- maxJoyStickDisplayTime: tt,
- maxJoyStickOverallTime: rt
- };
- return this.lastReturnFrames = this.returnFrames,
- this.lastReceivedEmit = this.receivedEmit,
- nr
- }
- }
- const log$k = new Logger("rtcp");
- class Rtcp extends EventEmitter {
- constructor(i) {
- super();
- Tt(this, "connection", null);
- Tt(this, "inputChannel", null);
- Tt(this, "mediaStream");
- Tt(this, "socket");
- Tt(this, "connected", !1);
- Tt(this, "candidates", []);
- Tt(this, "isAnswered", !1);
- Tt(this, "isFlushing", !1);
- Tt(this, "inputReady", !1);
- Tt(this, "workers");
- Tt(this, "actived", !0);
- Tt(this, "heartbeat");
- Tt(this, "onIcecandidate", i=>{
- if (i.candidate != null) {
- const o = JSON.stringify(i.candidate);
- log$k.debug(`Got ice candidate: ${o}`),
- this.network.socket.send({
- id: "ice_candidate",
- data: btoa(o)
- })
- }
- }
- );
- Tt(this, "onIcecandidateerror", i=>{
- log$k.error("onicecandidateerror", i.errorCode, i.errorText, i)
- }
- );
- Tt(this, "onIceStateChange", i=>{
- switch (i.target.iceGatheringState) {
- case "gathering":
- log$k.info("ice gathering");
- break;
- case "complete":
- log$k.info("Ice gathering completed")
- }
- }
- );
- Tt(this, "onIceConnectionStateChange", ()=>{
- if (!!this.connection)
- switch (log$k.info(`iceConnectionState: ${this.connection.iceConnectionState}`),
- this.connection.iceConnectionState) {
- case "connected":
- {
- this.connected = !0;
- break
- }
- case "disconnected":
- {
- this.connected = !1,
- this.emit("rtcDisconnected");
- break
- }
- case "failed":
- {
- this.emit("rtcDisconnected"),
- this.connected = !1;
- break
- }
- }
- }
- );
- Tt(this, "setRemoteDescription", async(i,o)=>{
- var _, b, k;
- if (!this.connection)
- return;
- const s = JSON.parse(atob(i))
- , c = new RTCSessionDescription(s);
- await this.connection.setRemoteDescription(c);
- const d = await this.connection.createAnswer();
- if (d.sdp = (_ = d.sdp) == null ? void 0 : _.replace(/(a=fmtp:111 .*)/g, "$1;stereo=1;sprop-stereo=1"),
- ((k = (b = d.sdp) == null ? void 0 : b.match(/a=mid:1/g)) == null ? void 0 : k.length) == 2) {
- const j = d.sdp.lastIndexOf("a=mid:1");
- d.sdp = d.sdp.slice(0, j) + "a=mid:2" + d.sdp.slice(j + 7)
- }
- try {
- await this.connection.setLocalDescription(d)
- } catch (j) {
- log$k.error("error", j)
- }
- this.isAnswered = !0,
- this.network.rtcp.flushCandidate(),
- this.network.socket.send({
- id: "answer",
- data: btoa(JSON.stringify(d))
- }),
- o.srcObject = this.mediaStream
- }
- );
- Tt(this, "flushCandidate", ()=>{
- this.isFlushing || !this.isAnswered || (this.isFlushing = !0,
- this.candidates.forEach(i=>{
- const o = atob(i)
- , s = JSON.parse(o);
- if (/172\./.test(s.candidate))
- return;
- const c = new RTCIceCandidate(s);
- this.connection && this.connection.addIceCandidate(c).then(()=>{}
- , d=>{
- log$k.info("add candidate failed", d)
- }
- )
- }
- ),
- this.isFlushing = !1)
- }
- );
- Tt(this, "input", i=>{
- var o;
- !this.actived || !this.inputChannel || this.inputChannel.readyState === "open" && ((o = this.inputChannel) == null || o.send(i))
- }
- );
- this.network = i,
- this.workers = new Workers(this,new Logger("decode")),
- this.workers.registerLogger(new Logger("decode")),
- this.workers.registerFunction("data", o=>{
- this.emit("data", o)
- }
- ),
- this.heartbeat = new Heartbeat({
- ping: o=>{
- i.room.actionsHandler.echo(o)
- }
- ,
- pong(o, s) {
- var c;
- s && o > 500 && log$k.warn(`high hb value ${o}, traceId:` + s),
- (c = i.room.stats) == null || c.assign({
- hb: o
- })
- }
- })
- }
- start() {
- this.connection = new RTCPeerConnection;
- const i = Date.now();
- this.connection.ondatachannel = o=>{
- log$k.info(`ondatachannel: ${o.channel.label}`),
- this.inputChannel = o.channel,
- this.inputChannel.onopen = ()=>{
- var s;
- log$k.info("The input channel has opened, id:", (s = this.inputChannel) == null ? void 0 : s.id),
- this.inputReady = !0,
- this.emit("rtcConnected"),
- this.network.room.currentNetworkOptions.reconnect || (log$k.infoAndReportMeasurement({
- metric: "datachannelOpenedAt",
- startTime: this.network.room._startTime,
- group: "joinRoom"
- }),
- log$k.infoAndReportMeasurement({
- metric: "datachannelOpenedCost",
- startTime: i,
- group: "joinRoom"
- }))
- }
- ,
- this.inputChannel.onclose = ()=>{
- var s;
- return log$k.info("The input channel has closed, id:", (s = this.inputChannel) == null ? void 0 : s.id)
- }
- ,
- this.inputChannel.onmessage = s=>{
- this.workers.dataHandle(s.data)
- }
- }
- ,
- this.connection.oniceconnectionstatechange = this.onIceConnectionStateChange,
- this.connection.onicegatheringstatechange = this.onIceStateChange,
- this.connection.onicecandidate = this.onIcecandidate,
- this.connection.onicecandidateerror = this.onIcecandidateerror,
- this.network.socket.send({
- id: "init_webrtc",
- data: JSON.stringify({
- is_mobile: !0
- })
- })
- }
- addCandidate(i) {
- i === "" ? this.network.rtcp.flushCandidate() : this.candidates.push(i)
- }
- disconnect() {
- var i, o, s;
- this.heartbeat.stop(),
- log$k.info("ready to close datachannel, id", (i = this.inputChannel) == null ? void 0 : i.id),
- (o = this.inputChannel) == null || o.close(),
- (s = this.connection) == null || s.close(),
- this.connection = null,
- this.inputChannel = null
- }
- sendStringData(i) {
- this.input(i)
- }
- sendData(i) {
- let o = "";
- try {
- o = JSON.stringify(i)
- } catch (s) {
- log$k.error(s);
- return
- }
- this.input(o)
- }
- }
- class Timeout {
- constructor(e, i, o=!0) {
- Tt(this, "_fn");
- Tt(this, "_delay");
- Tt(this, "_timeout");
- this._fn = e,
- this._delay = i,
- o && this.start()
- }
- get delay() {
- return this._delay
- }
- get isSet() {
- return !!this._timeout
- }
- setDelay(e) {
- this._delay = e
- }
- start() {
- this.isSet || (this._timeout = window.setTimeout(()=>{
- const e = this._fn;
- this.clear(),
- e()
- }
- , this._delay))
- }
- clear() {
- window.clearTimeout(this._timeout),
- this._timeout = void 0
- }
- reset() {
- this.clear(),
- this.start()
- }
- }
- const log$j = new Logger("ws");
- class Socket extends EventEmitter {
- constructor(i) {
- super();
- Tt(this, "_ws");
- Tt(this, "_openTimer");
- Tt(this, "connected", !1);
- Tt(this, "_hasTimeout", !1);
- Tt(this, "heartbeat");
- Tt(this, "latency", (i,o)=>this.send({
- id: "checkLatency",
- data: JSON.stringify(i),
- packet_id: o
- }));
- Tt(this, "send", i=>{
- if (this.wsNoReady())
- return;
- const o = JSON.stringify(i);
- i.id !== "heartbeat" && log$j.info("send ws frame", o),
- this._ws.send(o)
- }
- );
- Tt(this, "startGame", ()=>{
- 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;
- pt.removeWhenDisconnected = dt;
- const _t = {
- id: "start",
- room_id: i,
- user_id: o,
- trace_id: uuid$1(),
- data: JSON.stringify({
- avatar_components: JSON.stringify(_),
- avatar_id: s,
- skin_id: c,
- is_host: d ? d == "host" : !0,
- skin_data_version: c !== void 0 && b !== void 0 ? c + b : void 0,
- rotation_render_type: k,
- is_all_sync: j,
- nick_name: encodeURIComponent($ || ""),
- app_id: et,
- camera: tt,
- player: rt,
- person: ut,
- firends: JSON.stringify(it),
- sync_by_event: nt,
- area_name: ot,
- path_name: st,
- attitude: at,
- room_type_id: ct,
- syncToOthers: lt,
- hasAvatar: ft,
- avatarSize: _e,
- prioritySync: ht,
- extra: JSON.stringify(pt)
- })
- };
- this.send(_t);
- const mt = JSON.parse(_t.data);
- delete mt.token,
- log$j.infoAndReportMeasurement({
- metric: "startGame",
- extra: mt,
- startTime: Date.now()
- })
- }
- );
- this.network = i,
- this.heartbeat = new Heartbeat({
- ping: o=>{
- var s;
- if (!this.connected) {
- this.heartbeat.stop(),
- (s = i.room.stats) == null || s.assign({
- rtt: 0
- });
- return
- }
- this.send({
- id: "heartbeat",
- data: o
- })
- }
- ,
- pong(o) {
- var s;
- (s = i.room.stats) == null || s.assign({
- rtt: o
- })
- }
- })
- }
- get connection() {
- return this._ws
- }
- start() {
- this._hasTimeout = !1;
- const i = this.getAddress();
- log$j.info(`connecting to ${i}`);
- const o = Date.now();
- this._ws = new WebSocket(i),
- this._openTimer = new Timeout(()=>{
- const s = `Failed to open websocket in ${DEFAULT_OPEN_TIMEOUT_MS} ms`;
- this._hasTimeout = !0,
- this.emit("socketClosed", new InitNetworkTimeoutError(s))
- }
- ,DEFAULT_OPEN_TIMEOUT_MS),
- this._ws.onopen = ()=>{
- var s;
- (s = this._openTimer) == null || s.clear(),
- this.connected = !0,
- this.heartbeat.start(),
- this.network.room.currentNetworkOptions.reconnect || (log$j.infoAndReportMeasurement({
- metric: "wsOpenedAt",
- group: "joinRoom",
- startTime: this.network.room._startTime
- }),
- log$j.infoAndReportMeasurement({
- metric: "wsOpenedCost",
- group: "joinRoom",
- startTime: o
- }))
- }
- ,
- this.handleWSEvent()
- }
- getAddress() {
- const {wsServerUrl: i, reconnect: o, sessionId: s, token: c, roomId: d, userId: _, pageSession: b} = this.network.room.currentNetworkOptions
- , k = this.network.room.skinId;
- let j = i;
- o && (j = j + `?reconnect=true&lastSessionID=${s}`);
- const $ = `userId=${_}&roomId=${d}&pageSession=${b}` + (this.network.room.isHost ? `&skinId=${k}` : "") + (c ? `&token=${c}` : "");
- return j = j.indexOf("?") > -1 ? j + "&" + $ : j + "?" + $,
- j
- }
- handleWSEvent() {
- const i = this._ws;
- i.addEventListener("error", o=>{
- this.connected = !1,
- log$j.error("webscoket error", o),
- this.emit("socketClosed", new InternalError("connect to address error: " + this.network.room.currentNetworkOptions.wsServerUrl))
- }
- ),
- i.addEventListener("close", o=>{
- this.connected = !1,
- this._onClose(o)
- }
- ),
- i.addEventListener("message", o=>{
- if (!o || this._hasTimeout || !this.connected)
- return;
- let s = null;
- try {
- s = JSON.parse(o.data)
- } catch (d) {
- log$j.error(d);
- return
- }
- if (!s)
- return;
- const c = s.id;
- if (!!c)
- switch (c !== "heartbeat" && log$j.info(`receive ws frame: ${o.data}`),
- c) {
- case "fail":
- break;
- case "init":
- try {
- const d = s.data.slice(-37, -1);
- reporter.updateBody({
- serverSession: d
- })
- } catch (d) {
- console.error(d)
- }
- this.network.rtcp.start();
- break;
- case "heartbeat":
- this.heartbeat.pong(s.data);
- break;
- case "offer":
- this.network.rtcp.setRemoteDescription(s.data, this.network.stream.el);
- break;
- case "ice_candidate":
- this.network.rtcp.addCandidate(s.data);
- break;
- case "start":
- this.emit("gameRoomAvailable", s);
- break;
- case "error":
- try {
- const {Code: d, Msg: _} = JSON.parse(s.data);
- if (d) {
- if (d == 3003)
- return this.emit("socketClosed", new TokenExpiredError);
- if (authenticationErrorCodes.indexOf(d) > -1)
- return this.emit("socketClosed", new AuthenticationError("\u9274\u6743\u9519\u8BEF:" + _));
- {
- const b = getErrorByCode(d);
- this.emit("socketClosed", new b(_))
- }
- }
- } catch (d) {
- const _ = new InternalError("JSON.parse websocket data error: " + s.data);
- log$j.error(d, _),
- this.emit("socketClosed", _)
- }
- break;
- case "checkLatency":
- {
- const d = s.packet_id
- , _ = s.data.split(",");
- this.onLatencyCheck({
- packetId: d,
- addresses: _
- });
- break
- }
- default:
- log$j.warn("unkown ws message type", c, s)
- }
- }
- )
- }
- onLatencyCheck(i) {
- const o = [...new Set(i.addresses || [])];
- Promise.all(o.map(s=>({
- [s]: 9999
- }))).then(s=>{
- const c = Object.assign({}, ...s);
- this.latency(c, i.packetId)
- }
- )
- }
- wsNoReady() {
- return this._ws.readyState == WebSocket.CLOSED || this._ws.readyState == WebSocket.CLOSING || this._ws.readyState == WebSocket.CONNECTING
- }
- prepareReconnect() {
- this._close({
- code: WS_CLOSE_RECONNECT,
- reason: "reconnect"
- })
- }
- _onClose({code: i, reason: o}) {
- this._openTimer && this._openTimer.clear(),
- log$j.warn(`ws closed: ${i} ` + o),
- [WS_CLOSE_RECONNECT, WS_CLOSE_NORMAL].includes(i) || this.emit("socketClosed", new InternalError("Websocket error"))
- }
- _close({code: i, reason: o}) {
- var s;
- (s = this._ws) == null || s.close(i, o)
- }
- quit() {
- this._close({
- code: WS_CLOSE_NORMAL,
- reason: "quit"
- })
- }
- }
- const log$i = new Logger("stream");
- class Stream {
- constructor(e) {
- Tt(this, "el");
- Tt(this, "_streamPlayTimer", null);
- Tt(this, "play", ()=>new Promise((e,i)=>{
- this._streamPlayTimer = new Timeout(()=>{
- i(new InternalError("Stream play timeout"))
- }
- ,5e3),
- this.el && this.el.play().then(()=>{
- var o;
- e(),
- log$i.info("Media can autoplay"),
- (o = this._streamPlayTimer) == null || o.clear()
- }
- ).catch(o=>{
- var s;
- log$i.error("Media Failed to autoplay"),
- log$i.error(o),
- i(new InternalError("Media Failed to autoplay")),
- (s = this._streamPlayTimer) == null || s.clear()
- }
- )
- }
- ));
- if (!e) {
- this.el = this.createVideoElement();
- return
- }
- this.el = e
- }
- createVideoElement() {
- const e = document.createElement("video");
- return e.muted = !0,
- e.autoplay = !1,
- e.playsInline = !0,
- e.setAttribute("autostart", "false"),
- e.setAttribute("controls", "controls"),
- e.setAttribute("muted", "true"),
- e.setAttribute("preload", "auto"),
- e.setAttribute("hidden", "hidden"),
- document.body.appendChild(e),
- e
- }
- }
- const log$h = new Logger("NetworkController")
- , hr = class extends EventEmitter {
- constructor(i) {
- super();
- Tt(this, "socket");
- Tt(this, "rtcp");
- Tt(this, "stream");
- Tt(this, "_state", "connecting");
- Tt(this, "_networkMonitor");
- Tt(this, "reconnectCount", 0);
- Tt(this, "startGame", ()=>new Promise((i,o)=>{
- if (!this.rtcp.connected)
- return o(new InternalError("Game cannot load. Please refresh"));
- if (!this.rtcp.inputReady)
- return o(new InternalError("Game is not ready yet. Please wait"));
- this.socket.on("gameRoomAvailable", s=>{
- this.setState("connected"),
- i(s),
- this.rtcp.heartbeat.start()
- }
- ),
- this.socket.on("socketClosed", s=>{
- o(s)
- }
- ),
- this.socket.startGame()
- }
- ));
- this.room = i,
- this.socket = new Socket(this),
- this.rtcp = new Rtcp(this),
- this.stream = new Stream,
- this._networkMonitor = new NetworkMonitor(()=>{
- log$h.info("network changed, online:", this._networkMonitor.isOnline),
- this._state === "disconnected" && this._networkMonitor.isOnline && (log$h.info("network back to online, try to reconnect"),
- this.reconnect())
- }
- ),
- checkNetworkQuality(this.room.currentNetworkOptions.wsServerUrl),
- this._networkMonitor.start(),
- new VisibilityChangeHandler().subscribe(s=>{
- var c, d;
- s ? ((d = this.room.stats) == null || d.disable(),
- this.room.pageHideHandler(),
- log$h.infoAndReportMeasurement({
- metric: "pageHide",
- startTime: Date.now()
- })) : ((c = this.room.stats) == null || c.enable(),
- this.room.pageShowHandler(),
- log$h.infoAndReportMeasurement({
- metric: "pageShow",
- startTime: Date.now(),
- extra: {
- state: this._state
- }
- }),
- this._state === "disconnected" && this.reconnect())
- }
- )
- }
- setState(i) {
- this._state !== i && (this._state === "closed" && !hr.ALLOW_RECONNECT_AFTER_QUIT || (log$h.info("Set network state to ", i),
- this._state = i))
- }
- async connectAndStart(i) {
- return this.connect(i).then(this.startGame)
- }
- async connect(i=!1) {
- return this.room.updateCurrentNetworkOptions({
- reconnect: i
- }),
- new Promise((o,s)=>{
- this.rtcp.on("rtcConnected", ()=>{
- this.setState("connected"),
- o()
- }
- ),
- this.rtcp.on("rtcDisconnected", ()=>{
- log$h.info("rtc disconnected"),
- this._state === "connecting" ? (this.setState("disconnected"),
- s(new InternalError("rtc connect failed"))) : (this.setState("disconnected"),
- log$h.info("rtc disconnected, start to reconnect"),
- this.reconnect())
- }
- ),
- this.socket.on("socketQuit", ()=>{
- log$h.info("socket quit success"),
- this.setState("closed")
- }
- ),
- this.socket.on("socketClosed", c=>{
- this._state === "connecting" && (this.setState("disconnected"),
- s(c)),
- s(c)
- }
- ),
- this.socket.start()
- }
- )
- }
- reconnect() {
- const i = Date.now();
- if (this.reconnectCount++,
- this.reconnectCount > MAX_RECONNECT_COUNT) {
- log$h.error("reconnect failed, reached max reconnect count", MAX_RECONNECT_COUNT),
- this.reconnectCount = 0,
- this.emit("stateChanged", {
- state: "disconnected"
- });
- return
- }
- return log$h.info("start reconnect, count:", this.reconnectCount),
- this._reconnect().then(()=>{
- log$h.infoAndReportMeasurement({
- startTime: i,
- metric: "reconnect"
- })
- }
- ).catch(o=>{
- if (log$h.infoAndReportMeasurement({
- startTime: i,
- metric: "reconnect",
- error: o
- }),
- (o == null ? void 0 : o.code) === Codes$1.RepeatLogin) {
- this.room.handleRepetLogin();
- return
- }
- const s = 1e3;
- log$h.info("reconnect failed, wait " + s + " ms for next reconnect"),
- setTimeout(()=>{
- this.reconnect()
- }
- , s)
- }
- )
- }
- _reconnect() {
- return this._state === "closed" ? (log$h.warn("connection closed already"),
- Promise.reject()) : this._state === "connecting" ? (log$h.warn("connection is already in connecting state"),
- Promise.reject()) : this._state !== "disconnected" ? Promise.reject() : (this.prepareReconnect(),
- this._state = "connecting",
- this.emit("stateChanged", {
- state: "reconnecting",
- count: this.reconnectCount
- }),
- this.socket.off("gameRoomAvailable"),
- this.socket.off("socketClosed"),
- this.rtcp.off("rtcDisconnected"),
- this.rtcp.off("rtcConnected"),
- this.connectAndStart(!0).then(({session_id: i})=>{
- this.room.updateCurrentNetworkOptions({
- sessionId: i
- }),
- reporter.updateBody({
- serverSession: i
- }),
- log$h.info("reconnect success"),
- this.setState("connected"),
- this.reconnectCount = 0,
- this.emit("stateChanged", {
- state: "reconnected"
- })
- }
- ))
- }
- prepareReconnect() {
- this.rtcp.disconnect(),
- this.socket.prepareReconnect(),
- this.prepareReconnectOptions()
- }
- prepareReconnectOptions() {
- const {camera: i, player: o} = this.room.currentClickingState || {};
- i && o && this.room.updateCurrentNetworkOptions({
- camera: i,
- player: o
- })
- }
- sendRtcData(i) {
- this.rtcp.sendData(i)
- }
- sendSocketData(i) {
- log$h.debug("ws send ->", i),
- this.socket.send(i)
- }
- quit() {
- const i = uuid$1()
- , o = {
- action_type: Actions.Exit,
- trace_id: i,
- exit_action: {},
- user_id: this.room.options.userId,
- packet_id: i
- };
- this.setState("closed"),
- this.socket.quit(),
- this.sendRtcData(o)
- }
- }
- ;
- let NetworkController = hr;
- Tt(NetworkController, "ALLOW_RECONNECT_AFTER_QUIT", !0);
- let DecodeFunctionTimeList = []
- , SDKFunctionTimeList = []
- , EngineFunctionTimeList = []
- , OtherFunctionTimeList = []
- , HeavyFunctionList = [];
- function getSum(a) {
- let e = 0;
- for (let i = 0; i < a.length; i++)
- e += a[i];
- return e || 0
- }
- function getMax(a) {
- let e = 0;
- for (let i = 0; i < a.length; i++)
- e < a[i] && (e = a[i]);
- return e
- }
- function getFuncStat() {
- const a = {
- sum: getSum(DecodeFunctionTimeList),
- max: getMax(DecodeFunctionTimeList)
- }
- , e = {
- sum: getSum(SDKFunctionTimeList),
- max: getMax(SDKFunctionTimeList)
- }
- , i = {
- sum: getSum(EngineFunctionTimeList),
- max: getMax(EngineFunctionTimeList)
- }
- , o = {
- sum: getSum(OtherFunctionTimeList),
- max: getMax(OtherFunctionTimeList)
- }
- , s = HeavyFunctionList;
- return DecodeFunctionTimeList = [],
- SDKFunctionTimeList = [],
- EngineFunctionTimeList = [],
- OtherFunctionTimeList = [],
- HeavyFunctionList = [],
- {
- function: s,
- decode: a,
- sdk: e,
- engine: i,
- other: o
- }
- }
- const SAMPLES_LENGTH = 10
- , log$g = new Logger("stats")
- , numberFormat = new Intl.NumberFormat(window.navigator.language,{
- maximumFractionDigits: 0
- });
- class Stats extends EventEmitter {
- constructor(i) {
- super();
- Tt(this, "_netInterval", null);
- Tt(this, "_disabled", !1);
- Tt(this, "_aggregatedStats", {});
- Tt(this, "isNetworkGood", !0);
- Tt(this, "_displayElements", {});
- Tt(this, "showStatus", {
- default: !1,
- extra: !1
- });
- Tt(this, "_extraStats", {});
- Tt(this, "_networkSamples", []);
- Tt(this, "externalStats");
- Tt(this, "constructedTime");
- Tt(this, "_interval");
- this.room = i,
- this.constructedTime = Date.now(),
- this._interval = window.setInterval(()=>{
- if (this._disabled || !i.joined)
- return;
- this.onStats(i.networkController.rtcp.workers.uploadDataToServer());
- const o = i.signal.getSignalStat()
- , s = i.sceneManager.engineRunTimeStats
- , c = s.timeArray_addAvatarToScene.getStat()
- , d = s.timeArray_loadStaticMesh.getStat()
- , _ = s.timeArray_updateStaticMesh.getStat();
- this._aggregatedStats.engineCPUSum = c.sum + d.sum + _.sum,
- this._aggregatedStats.engineCPUMax = Math.max(c.max, d.max, _.max),
- this._aggregatedStats.sdkSignalPartial = o.partialMax.toString(),
- this._aggregatedStats.sdkCPUAvg = o.sdkAvg,
- this._aggregatedStats.sdkCPUMax = o.sdkMax,
- this._aggregatedStats.sdkBlobSum = o.blobSum,
- this._aggregatedStats.sdkBlobMax = o.blobMax;
- const k = getFuncStat().function;
- let j = "<br />";
- for (let$ = 0; $ < k.length; $++)
- j += k[$].name + ": " + k[$].time.toFixed(0) + "<br />";
- this._aggregatedStats.heavyFunc = j
- }
- , 1e3),
- this._netInterval = window.setInterval(()=>{
- this.checkNetworkQuality()
- }
- , DURATION * 1e3)
- }
- get isShow() {
- return this.showStatus.default || this.showStatus.extra
- }
- isStatsShow(i="default") {
- return this.showStatus[i]
- }
- assign(i) {
- Object.assign(this._extraStats, i),
- ((i == null ? void 0 : i.hb) || (i == null ? void 0 : i.rtt)) && this.startStatsNetSamples()
- }
- appendExternalStats(i) {
- const o = {};
- if (!i || typeof i != "object") {
- console.warn("appendExternalStats should be plain object");
- return
- }
- Object.keys(i).forEach(s=>{
- Object.prototype.hasOwnProperty.call(this._aggregatedStats, s) ? console.warn(`${s} is duplicate with internal stats`) : o[s] = i[s]
- }
- ),
- !(Object.keys(o).length > 10) && (this.externalStats = o)
- }
- getRtt() {
- const i = this._extraStats.rtt;
- return typeof i != "number" ? 0 : i > 999 ? 999 : i
- }
- enable() {
- this._disabled = !1
- }
- disable() {
- this._disabled = !0
- }
- disableNet() {
- this._netInterval && window.clearInterval(this._netInterval)
- }
- show(i="default") {
- this.showStatus[i] = !0,
- this._render(i)
- }
- hide(i="default") {
- this.showStatus[i] = !1;
- const o = this._displayElements[i];
- o && document.body.removeChild(o),
- this._displayElements[i] = null
- }
- checkNetworkQuality() {
- if (this._networkSamples.length < SAMPLES_LENGTH || this.room.networkController._state !== "connected")
- return;
- const o = this._networkSamples.map($=>this.isNetDelay($, "rtt"))
- , s = this._networkSamples.map($=>this.isNetDelay($, "hb"))
- , c = o.reduce(($,_e)=>$ + _e, 0)
- , d = s.reduce(($,_e)=>$ + _e, 0)
- , _ = Math.floor(c / this._networkSamples.length) * 100
- , b = Math.floor(d / this._networkSamples.length) * 100
- , k = 70;
- let j = !0;
- (_ >= k || b >= k) && (j = !1),
- this.isNetworkGood = j,
- this.emit("networkQuality", {
- good: j
- }),
- j || this.emit("weakNetwork"),
- this.isNetworkGood !== j && log$g.infoAndReportMeasurement({
- metric: "networkQualityChange",
- startTime: Date.now(),
- extra: {
- msg: this._networkSamples,
- netDelayRTTValues: c,
- netDelayHBValues: d,
- isNetworkGood: j
- }
- })
- }
- startStatsNetSamples() {
- const {rtt: i, hb: o} = this._extraStats;
- if (i || o) {
- const s = {
- rtt: i,
- hb: o,
- time: Date.now()
- };
- this._networkSamples.unshift(s),
- this._networkSamples.splice(SAMPLES_LENGTH)
- }
- }
- isNetDelay(i, o) {
- return o === "rtt" ? i.rtt > RTT_MAX_VALUE ? 1 : 0 : o === "hb" && i.hb > HB_MAX_VALUE ? 1 : 0
- }
- _render(i) {
- 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;
- if (!this._aggregatedStats)
- return;
- const o = []
- , s = Date.now() - this.constructedTime
- , c = Math.floor(s / 1e3 % 60)
- , d = Math.floor(s / (1e3 * 60) % 60)
- , _ = Math.floor(s / (1e3 * 60 * 60) % 24)
- , b = _ < 10 ? "0" + _.toString() : _.toString()
- , k = d < 10 ? "0" + d : d
- , j = c < 10 ? "0" + c : c;
- if (o.push({
- key: new Date(Math.floor(this._aggregatedStats.timestamp || 0)).toLocaleString("en-GB"),
- value: b + ":" + k + ":" + j
- }),
- o.push({
- key: "rtt: " + this._extraStats.rtt + " hb: " + this._extraStats.hb,
- value: "FPS: " + this._extraStats.fps + " avatar: " + (($ = this.room._userAvatar) == null ? void 0 : $.state)
- }),
- o.push({
- key: "SDK: " + Xverse$1.SUB_PACKAGE_VERSION,
- value: "ENGINE:" + VERSION$1 + " uid:" + this._extraStats.userId
- }),
- o.push({
- key: "\u540C\u6B65/\u6709\u6548/\u663E\u793A\u73A9\u5BB6",
- value: `${this._extraStats.syncUserNum || 0}/${this._extraStats.userNum || 0}/${this._extraStats.renderedUserNum || 0}`
- }),
- o.push({
- key: "media/meta bitrate(kbps)",
- value: numberFormat.format(this._aggregatedStats.mediaBitrate || 0) + "/" + numberFormat.format(this._aggregatedStats.metaBitrate || 0)
- }),
- o.push({
- key: ":----------------Decoding---------------",
- value: ""
- }),
- o.push({
- key: "-max/avg decodeTime(ms)",
- value: numberFormat.format(this._aggregatedStats.decodeTimeMaxFrame || 0) + "/" + numberFormat.format(this._aggregatedStats.decodeTimePerFrame || 0)
- }),
- o.push({
- key: "-frmAwait/Lost/Drop",
- 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
- }),
- o.push({
- key: ":----------------FrameLoop-------------",
- value: ""
- }),
- o.push({
- key: "interval(max/avg/>40)",
- 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
- }),
- o.push({
- key: "systemStuck",
- value: this._extraStats.systemStuckCnt
- }),
- o.push({
- key: "--update",
- value: (this._aggregatedStats.maxGraphicTime.toFixed(1) || 0) + "/" + (((tt = this._aggregatedStats.averageGraphicTime) == null ? void 0 : tt.toFixed(0)) || 0)
- }),
- o.push({
- key: "--timeout",
- value: (((rt = this._extraStats.maxTimeoutTime) == null ? void 0 : rt.toFixed(1)) || 0) + "/" + ((it = this._extraStats.avgTimeoutTime) == null ? void 0 : it.toFixed(0)) || 0
- }),
- o.push({
- key: "--render",
- value: (((nt = this._extraStats.maxRenderFrameTime) == null ? void 0 : nt.toFixed(1)) || 0) + "/" + (((ot = this._extraStats.renderFrameTime) == null ? void 0 : ot.toFixed(0)) || 0)
- }),
- o.push({
- key: "---anim/regBR/clip(avg ms)",
- value: (this._extraStats.animationTime.toFixed(2) || 0) + " / " + (this._extraStats.registerBeforeRenderTime.toFixed(2) || 0) + " / " + (this._extraStats.meshSelectTime.toFixed(2) || 0)
- }),
- o.push({
- key: "---anim/regBR/clip(max ms)",
- value: (this._extraStats.maxAnimationTime.toFixed(2) || 0) + " / " + (this._extraStats.maxRegisterBeforeRenderTime.toFixed(2) || 0) + " / " + (this._extraStats.maxMeshSelectTime.toFixed(2) || 0)
- }),
- o.push({
- key: "---rTR/drC/regAF(avg ms)",
- value: (this._extraStats.renderTargetRenderTime.toFixed(2) || 0) + " / " + (this._extraStats.drawcallTime.toFixed(2) || 0) + " / " + (this._extraStats.registerAfterRenderTime.toFixed(2) || 0)
- }),
- o.push({
- key: "---rTR/drC/regAF(max ms)",
- value: (this._extraStats.maxRenderTargetRenderTime.toFixed(2) || 0) + " / " + (this._extraStats.maxDrawcallTime.toFixed(2) || 0) + " / " + (this._extraStats.maxRegisterAfterRenderTime.toFixed(2) || 0)
- }),
- o.push({
- key: "--tri/drC/pati/bones/anim(Num)",
- 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)
- }),
- o.push({
- key: "--rootN/mesh/geo/tex/mat(Num)",
- 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)
- }),
- o.push({
- key: "--registerBF/AF(Num)",
- value: (this._extraStats.registerBeforeCount.toFixed(0) || 0) + " / " + (this._extraStats.registerAfterCount.toFixed(0) || 0)
- }),
- o.push({
- key: ":----------------JoyStick----------------------",
- value: ""
- }),
- o.push({
- key: "Total(avg/max)",
- value: (((at = this._aggregatedStats.avgJoyStickOverallTime) == null ? void 0 : at.toFixed(2)) || 0) + "/" + (((st = this._aggregatedStats.maxJoyStickOverallTime) == null ? void 0 : st.toFixed(2)) || 0)
- }),
- o.push({
- key: "--Rsp(avg/max)",
- value: (((ut = this._aggregatedStats.avgJoyStickResponseTime) == null ? void 0 : ut.toFixed(1)) || 0) + "/" + this._aggregatedStats.maxJoyStickResponseTime
- }),
- o.push({
- key: "--Proc(avg/max)",
- value: (((ct = this._aggregatedStats.avgJoyStickProcessTime) == null ? void 0 : ct.toFixed(1)) || 0) + "/" + this._aggregatedStats.maxJoyStickProcessTime
- }),
- o.push({
- key: "--Show(avg/max)",
- value: (((lt = this._aggregatedStats.avgJoyStickDisplayTime) == null ? void 0 : lt.toFixed(1)) || 0) + "/" + this._aggregatedStats.maxJoyStickDisplayTime
- }),
- o.push({
- key: ":----------------Rotation-------------------",
- value: ""
- }),
- o.push({
- key: "Total(ms/miss)",
- value: (((ft = this._aggregatedStats.avgOverallTime) == null ? void 0 : ft.toFixed(2)) || 0) + "/" + (this._aggregatedStats.responseMissPs + this._aggregatedStats.processMissPs + this._aggregatedStats.displayMissPs)
- }),
- o.push({
- key: "--rotateRsp",
- value: (((ht = this._aggregatedStats.avgResponseTime) == null ? void 0 : ht.toFixed(1)) || 0) + "/" + this._aggregatedStats.responseMissPs
- }),
- o.push({
- key: "--rotateProc",
- value: (((pt = this._aggregatedStats.avgProcessTime) == null ? void 0 : pt.toFixed(1)) || 0) + "/" + this._aggregatedStats.processMissPs
- }),
- o.push({
- key: "--rotateShow",
- value: (((dt = this._aggregatedStats.avgDisplayTime) == null ? void 0 : dt.toFixed(1)) || 0) + "/" + this._aggregatedStats.displayMissPs
- }),
- ((_t = this.room._userAvatar) == null ? void 0 : _t.state) == "moving",
- o.push({
- key: ":----------------Move----------------------",
- value: ""
- }),
- o.push({
- key: "-startDelay",
- 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)
- }),
- (((mt = this.room._userAvatar) == null ? void 0 : mt.state) == "moving" || this._aggregatedStats.moveEvent == "GetOnAirship" || this._aggregatedStats.moveEvent == "GetOnVehicle") && o.push({
- key: "-srvInterFrm(max/avg)",
- value: (this._aggregatedStats.maxServerDiff || 0) + "/" + (this._aggregatedStats.avgServerDiff.toFixed(1) || 0)
- }),
- o.push({
- key: "-interFrameDelay",
- value: "(max/avg/jank)"
- }),
- o.push({
- key: "--toDisplay",
- 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)
- }),
- o.push({
- key: "--received",
- 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)
- }),
- o.push({
- key: "--decoded",
- 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)
- }),
- o.push({
- key: ":----------------DevInfo-----------------",
- value: ""
- }),
- o.push({
- key: "sd",
- value: (this._aggregatedStats.sdMoveResponseLongTime.toFixed(1) || 0) + "/" + (this._aggregatedStats.sdMoveProcessLongTime.toFixed(1) || 0) + "/" + (this._aggregatedStats.sdMoveDisplayLongTime.toFixed(1) || 0)
- }),
- o.push({
- key: "----hardwareInfo",
- value: this._extraStats.hardwareInfo
- }),
- i === "default")
- this.createAndRender(o, i);
- else {
- const Ot = [];
- Ot.push({
- key: "rtt: " + this._extraStats.rtt + " hb: " + this._extraStats.hb,
- value: ""
- }),
- Ot.push({
- key: ":----------------PerFrame-------------",
- value: ""
- }),
- Ot.push({
- key: "render(max/avg)",
- value: (((xt = this._extraStats.maxRenderFrameTime) == null ? void 0 : xt.toFixed(1)) || 0) + "/" + (((bt = this._extraStats.renderFrameTime) == null ? void 0 : bt.toFixed(2)) || 0)
- }),
- Ot.push({
- key: "update(max/avg)",
- value: (this._aggregatedStats.maxGraphicTime.toFixed(1) || 0) + "/" + (((Rt = this._aggregatedStats.averageGraphicTime) == null ? void 0 : Rt.toFixed(2)) || 0)
- }),
- Ot.push({
- key: "receive(max/avg)",
- value: this._aggregatedStats.decodeCPUMax + "/" + ((Mt = this._aggregatedStats.decodeCPUAvg) == null ? void 0 : Mt.toFixed(2))
- }),
- Ot.push({
- key: "handleSignal(max/avg)",
- value: this._aggregatedStats.sdkCPUMax + "/" + ((Pt = this._aggregatedStats.sdkCPUAvg) == null ? void 0 : Pt.toFixed(2))
- }),
- Ot.push({
- key: ":----------------LowFrequent-------------",
- value: ""
- }),
- Ot.push({
- key: "engine(max/sum)",
- value: this._aggregatedStats.engineCPUMax + "/" + this._aggregatedStats.engineCPUSum
- }),
- Ot.push({
- key: "blob(max/sum)",
- value: this._aggregatedStats.sdkBlobMax + "/" + this._aggregatedStats.sdkBlobSum
- }),
- ((It = this.room._userAvatar) == null ? void 0 : It.state) == "moving",
- Ot.push({
- key: ":----------------Move----------------------",
- value: ""
- }),
- (((Dt = this.room._userAvatar) == null ? void 0 : Dt.state) == "moving" || this._aggregatedStats.moveEvent == "GetOnAirship" || this._aggregatedStats.moveEvent == "GetOnVehicle") && Ot.push({
- key: "-srvInterFrm(max/avg)",
- value: (this._aggregatedStats.maxServerDiff || 0) + "/" + (this._aggregatedStats.avgServerDiff.toFixed(1) || 0)
- }),
- Ot.push({
- key: "-interFrameDelay",
- value: "(max/avg)"
- }),
- Ot.push({
- key: "--received",
- 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)
- }),
- Ot.push({
- key: "postMsg",
- value: this._aggregatedStats.postMsgMaxTime || 0
- }),
- Ot.push({
- key: "timeoutGap",
- value: ((Ct = this._extraStats.maxTimeoutGap) == null ? void 0 : Ct.toFixed(1)) || 0
- }),
- Ot.push({
- key: ":----------------DevInfo-------------",
- value: ""
- }),
- Ot.push({
- key: "handleSignalPartial",
- value: this._aggregatedStats.sdkSignalPartial || ""
- }),
- Ot.push({
- key: "heavyFunc",
- value: this._aggregatedStats.heavyFunc || ""
- }),
- this.createAndRender(Ot, i)
- }
- }
- createAndRender(i, o="default") {
- if (!this._displayElements[o]) {
- const c = document.createElement("div");
- this._displayElements[o] = c,
- c.style.position = "absolute",
- c.style.top = "10px",
- c.style.left = "120px",
- c.style.width = "200px",
- c.style.backgroundColor = "rgba(0,0,0,.5)",
- c.style.color = "white",
- c.style.textAlign = "left",
- c.style.fontSize = "8px",
- c.style.lineHeight = "10px",
- document.body.appendChild(c)
- }
- let s = "";
- for (const c of i)
- s += `<div><span>${c.key}</span>: <span>${c.value}</span> </div>`;
- this._displayElements[o].innerHTML = s
- }
- onStats(i) {
- var _;
- if (!i)
- return;
- const o = {}
- , s = this;
- s._aggregatedStats || (s._aggregatedStats = {}),
- o.timestamp = i.timestamp,
- o.mediaBytesReceived = i.mediaBytesReceived,
- o.metaBytesReceived = i.metaBytesReceived,
- o.packetsLost = i.packetsLost,
- o.frameHeight = i.frameHeight,
- o.frameWidth = i.frameWidth,
- o.framesReceivedUI = i.framesReceived,
- o.framesReceived = i.framesReceivedWorker,
- o.framesDecoded = i.framesDecoded,
- o.framesEmited = i.framesEmited,
- o.decodeTimePerFrame = i.decodeTimePerFrame,
- o.decodeTimeMaxFrame = i.decodeTimeMaxFrame,
- o.packetsDrop = i.packetsDrop,
- o.framesAwait = i.framesAwait,
- o.updateDropFrame = i.updateDropFrame,
- o.firstMediaArraval = i.firstMediaArraval,
- o.firstYUVDecoded = i.firstYUVDecoded,
- o.firstRender = i.firstRender,
- o.returnFrames = i.returnFrames,
- o.sendOutBuffer = i.sendOutBuffer,
- o.averageGraphicTime = i.averageGraphicTime,
- o.maxGraphicTime = i.maxGraphicTime,
- o.jankTimes = i.jankTimes,
- o.bigJankTimes = i.bigJankTimes,
- o.decodeJankTimes = i.decodeJankTimes,
- o.bigDecodeJankTimes = i.bigDecodeJankTimes,
- o.serverFrameFast = i.serverFrameFast,
- o.serverFrameSlow = i.serverFrameSlow,
- o.clientFrameFast = i.clientFrameFast,
- o.clientFrameSlow = i.clientFrameSlow,
- o.rtcMessageReceived = i.rtcMessageReceived,
- o.rtcBytesReceived = i.rtcBytesReceived,
- o.receiveIframes = i.receiveIframes,
- o.decodeIframes = i.decodeIframes,
- o.avgResponseTime = i.avgResponseTime,
- o.avgProcessTime = i.avgProcessTime,
- o.avgDisplayTime = i.avgDisplayTime,
- o.avgOverallTime = i.avgOverallTime,
- o.overallTimeCount = i.overallTimeCount,
- o.responseMiss = i.responseMiss,
- o.processMiss = i.processMiss,
- o.displayMiss = i.displayMiss,
- o.avgResponseMoveDiff = i.avgResponseMoveDiff,
- o.avgProcessMoveDiff = i.avgProcessMoveDiff,
- o.avgDisplayMoveDiff = i.avgDisplayMoveDiff,
- o.maxResponseMoveDiff = i.maxResponseMoveDiff,
- o.maxProcessMoveDiff = i.maxProcessMoveDiff,
- o.maxDisplayMoveDiff = i.maxDisplayMoveDiff,
- o.moveResponseDelay = i.moveResponseDelay,
- o.moveProcessDelay = i.moveProcessDelay,
- o.moveDisplayDelay = i.moveDisplayDelay,
- o.moveResponseJank = i.moveResponseJank,
- o.moveProcessJank = i.moveProcessJank,
- o.moveDisplayJank = i.moveDisplayJank,
- o.avgMetaParseTime = i.avgMetaParseTime,
- o.maxMetaParseTime = i.maxMetaParseTime,
- o.moveResponseCounts = i.moveResponseCounts,
- o.moveProcessCounts = i.moveProcessCounts,
- o.moveDisplayCounts = i.moveDisplayCounts,
- o.MoveDisplayCountGood = i.MoveDisplayCountGood,
- o.MoveDisplayCountWell = i.MoveDisplayCountWell,
- o.MoveDisplayCountFair = i.MoveDisplayCountFair,
- o.MoveDisplayCountBad = i.MoveDisplayCountBad,
- o.MoveDisplayCountRest = i.MoveDisplayCountRest,
- o.avgServerDiff = i.avgServerDiff,
- o.maxServerDiff = i.maxServerDiff,
- o.avgResponseFlyDiff = i.avgResponseFlyDiff,
- o.avgProcessFlyDiff = i.avgProcessFlyDiff,
- o.avgDisplayFlyDiff = i.avgDisplayFlyDiff,
- o.maxResponseFlyDiff = i.maxResponseFlyDiff,
- o.maxProcessFlyDiff = i.maxProcessFlyDiff,
- o.maxDisplayFlyDiff = i.maxDisplayFlyDiff,
- o.flyResponseCounts = i.flyResponseCounts,
- o.flyProcessCounts = i.flyProcessCounts,
- o.flyDisplayCounts = i.flyDisplayCounts,
- o.flyResponseJank = i.flyResponseJank,
- o.flyProcessJank = i.flyProcessJank,
- o.flyDisplayJank = i.flyDisplayJank,
- o.flyResponseDelay = i.flyResponseDelay,
- o.flyProcessDelay = i.flyProcessDelay,
- o.flyDisplayDelay = i.flyDisplayDelay,
- o.moveEvent = i.moveEvent,
- o.sdMoveResponseLongTime = i.sdMoveResponseLongTime,
- o.sdMoveProcessLongTime = i.sdMoveProcessLongTime,
- o.sdMoveDisplayLongTime = i.sdMoveDisplayLongTime,
- o.avgJoyStickResponseTime = i.avgJoyStickResponseTime,
- o.avgJoyStickProcessTime = i.avgJoyStickProcessTime,
- o.avgJoyStickDisplayTime = i.avgJoyStickDisplayTime,
- o.avgJoyStickOverallTime = i.avgJoyStickOverallTime,
- o.maxJoyStickResponseTime = i.maxJoyStickResponseTime,
- o.maxJoyStickProcessTime = i.maxJoyStickProcessTime,
- o.maxJoyStickDisplayTime = i.maxJoyStickDisplayTime,
- o.maxJoyStickOverallTime = i.maxJoyStickOverallTime;
- const c = i.unmarshalStreamStat
- , d = i.receiveYUVStat;
- o.decodeCPUMax = Math.max(c.max, d.max),
- o.decodeCPUAvg = c.avg + d.avg,
- o.postMsgMaxTime = i.maxPostMsgDiff,
- s._aggregatedStats && s._aggregatedStats.timestamp && (o.mediaBitrate = 8 * (o.mediaBytesReceived - s._aggregatedStats.mediaBytesReceived) / 1e3,
- o.mediaBitrate = Math.round(o.mediaBitrate || 0),
- o.metaBitrate = 8 * (o.metaBytesReceived - s._aggregatedStats.metaBytesReceived) / 1e3,
- o.metaBitrate = Math.round(o.metaBitrate || 0),
- o.rtcMessagePs = o.rtcMessageReceived - s._aggregatedStats.rtcMessageReceived,
- o.rtcBitrate = 8 * (o.rtcBytesReceived - s._aggregatedStats.rtcBytesReceived) / 1e3,
- o.rtcBitrate = Math.round(o.rtcBitrate || 0),
- o.framesEmitedPs = o.framesEmited - s._aggregatedStats.framesEmited,
- o.framesEmitedPs = Math.round(o.framesEmitedPs || 0),
- o.framesReceivedPs = o.framesReceived - s._aggregatedStats.framesReceived,
- o.framesReceivedPs = Math.round(o.framesReceivedPs || 0),
- o.framesDecodedPs = o.framesDecoded - s._aggregatedStats.framesDecoded,
- o.framesDecodedPs = Math.round(o.framesDecodedPs || 0),
- o.returnFramesPs = o.returnFrames - s._aggregatedStats.returnFrames,
- o.returnFramesPs = Math.round(o.returnFramesPs || 0),
- o.responseMissPs = o.responseMiss - s._aggregatedStats.responseMiss,
- o.processMissPs = o.processMiss - s._aggregatedStats.processMiss,
- o.displayMissPs = o.displayMiss - s._aggregatedStats.displayMiss,
- o.returnFrames = i.returnFrames),
- this.showStatus.default ? this._render("default") : this.showStatus.extra && this._render("extra"),
- o.registerBeforeRenderTime = this._extraStats.registerBeforeRenderTime,
- o.registerAfterRenderTime = this._extraStats.registerAfterRenderTime,
- o.renderTargetRenderTime = this._extraStats.renderTargetRenderTime,
- o.renderFrameTime = this._extraStats.renderFrameTime,
- o.maxRenderFrameTime = this._extraStats.maxRenderFrameTime,
- o.interFrameTime = this._extraStats.interFrameTime,
- o.animationTime = this._extraStats.animationTime,
- o.meshSelectTime = this._extraStats.meshSelectTime,
- o.drawcall = this._extraStats.drawcall,
- o.drawcallTime = this._extraStats.drawcallTime,
- o.triangle = this._extraStats.triangle,
- o.registerAfterCount = this._extraStats.registerAfterCount,
- o.registerBeforeCount = this._extraStats.registerBeforeCount,
- o.fps = this._extraStats.fps,
- o.rtt = this._extraStats.rtt,
- o.hb = this._extraStats.hb,
- o.avgFrameTime = this._extraStats.avgFrameTime,
- o.avgTimeoutTime = this._extraStats.avgTimeoutTime,
- o.engineSloppyCnt = this._extraStats.engineSloppyCnt,
- o.systemStuckCnt = this._extraStats.systemStuckCnt,
- o.avatarState = (_ = this.room._userAvatar) == null ? void 0 : _.state,
- o.maxFrameTime = this._extraStats.maxFrameTime,
- o.maxTimeoutTime = this._extraStats.maxTimeoutTime,
- o.activeParticles = this._extraStats.activeParticles,
- o.activeBones = this._extraStats.activeBones,
- o.activeAnimation = this._extraStats.activeAnimation,
- o.totalRootNodes = this._extraStats.totalRootNodes,
- o.totalGeometries = this._extraStats.totalGeometries,
- o.totalMeshes = this._extraStats.totalMeshes,
- o.totalTextures = this._extraStats.totalTextures,
- o.totalMaterials = this._extraStats.totalMaterials,
- o.hardwareInfo = this._extraStats.hardwareInfo,
- o.maxInterFrameTime = this._extraStats.maxInterFrameTime,
- o.maxDrawcallTime = this._extraStats.maxDrawcallTime,
- o.maxMeshSelectTime = this._extraStats.maxMeshSelectTime,
- o.maxAnimationTime = this._extraStats.maxAnimationTime,
- o.maxRegisterBeforeRenderTime = this._extraStats.maxRegisterBeforeRenderTime,
- o.maxRegisterAfterRenderTime = this._extraStats.maxRegisterAfterRenderTime,
- o.maxRenderTargetRenderTime = this._extraStats.maxRenderTargetRenderTime,
- this.externalStats && Object.keys(this.externalStats || {}).forEach(b=>{
- o[b] = this.externalStats[b]
- }
- ),
- s._aggregatedStats = o,
- this.emit("stats", {
- stats: o
- })
- }
- }
- const isWebAssemblySupported = ()=>{
- try {
- if (typeof WebAssembly == "object" && typeof WebAssembly.instantiate == "function") {
- const a = new WebAssembly.Module(Uint8Array.of(0, 97, 115, 109, 1, 0, 0, 0));
- if (a instanceof WebAssembly.Module)
- return new WebAssembly.Instance(a)instanceof WebAssembly.Instance
- }
- } catch {}
- return console.log("wasm is not supported"),
- !1
- }
- ;
- function isSupported() {
- return typeof RTCPeerConnection == "function" && isWebAssemblySupported()
- }
- const log$f = new Logger("xverse")
- , er = class {
- constructor(e) {
- Tt(this, "debug", !1);
- Tt(this, "pageSession");
- Tt(this, "preload");
- Tt(this, "appId");
- Tt(this, "releaseId");
- e || (e = {});
- const {onLog: i, env: o, appId: s, releaseId: c, subPackageVersion: d} = e;
- er.NO_CACHE = !1,
- er.env = o || "PROD",
- er.SUB_PACKAGE_VERSION = d,
- this.debug && Logger.setLevel(LoggerLevels.Debug);
- const _ = this.pageSession = uuid$1();
- if (reporter.updateHeader({
- pageSession: _
- }),
- reporter.updateReportUrl(REPORT_URL[er.env]),
- d && reporter.updateBody({
- sdkVersion: d,
- appId: s
- }),
- log$f.infoAndReportMeasurement({
- metric: "sdkInit",
- startTime: Date.now(),
- extra: {
- version: d,
- enviroment: o,
- pageSession: _,
- engineVersion: VERSION$1
- }
- }),
- log$f.debug("debug mode:", this.debug),
- reporter.on("report", b=>{
- i && i(b)
- }
- ),
- s) {
- this.appId = s,
- this.releaseId = c;
- const b = ModelManager.getInstance(s, c);
- this.preload = new Preload(b)
- }
- }
- get isSupported() {
- return isSupported()
- }
- disableLogUpload() {
- reporter.disable(),
- log$f.debug("log upload has been disabled")
- }
- async getSkinList() {
- return []
- }
- async getAvatarList() {
- return []
- }
- async getGiftList() {
- return [{
- id: "hack "
- }]
- }
- }
- ;
- let Xverse$1 = er;
- Tt(Xverse$1, "NO_CACHE"),
- Tt(Xverse$1, "USE_TME_CDN"),
- Tt(Xverse$1, "env"),
- Tt(Xverse$1, "SUB_PACKAGE_VERSION");
- const objectParseFloat = a=>{
- const e = {};
- return a && Object.keys(a).forEach(i=>{
- e[i] = parseFloat(a[i])
- }
- ),
- e
- }
- , log$e = new Logger("model-manager")
- , tr = class {
- constructor(e, i) {
- Tt(this, "avatarModelList", []);
- Tt(this, "skinList", []);
- Tt(this, "applicationConfig");
- Tt(this, "config");
- Tt(this, "appId");
- Tt(this, "releaseId");
- this.appId = e,
- this.releaseId = i
- }
- static getInstance(e, i) {
- return tr.instance || (tr.instance = new tr(e,i)),
- tr.instance
- }
- static findModels(e, i, o) {
- return e.filter(c=>c.typeName === i && c.className === o)
- }
- static findModel(e, i, o) {
- const s = e.filter(c=>c.typeName === i && c.className === o)[0];
- return s || null
- }
- async findSkinConfig(e) {
- let i = null;
- if (i = (this.skinList = await this.getSkinsList()).find(s=>s.id === e),
- i)
- return i;
- {
- const s = `skin is invalid: skinId: ${e}`;
- return Promise.reject(new ParamError(s))
- }
- }
- async findRoute(e, i) {
- const s = (await this.findSkinConfig(e)).routeList.find(c=>c.pathName === i);
- if (!s) {
- const c = `find path failed: skinId: ${e}, pathName: ${i}`;
- return Promise.reject(new ParamError(c))
- }
- return log$e.debug("find route success", s),
- s
- }
- async findAssetList(e) {
- const o = (await this.findSkinConfig(e)).assetList;
- if (!o) {
- const s = `find path failed: skinId: ${e}`;
- return Promise.reject(new ParamError(s))
- }
- return log$e.debug("find route success", o),
- o
- }
- async findAsset(e, i, o="id") {
- const s = await this.findSkinConfig(e);
- if (Array.isArray(i))
- return i.map(d=>s.models.find(_=>_[o] === d)).filter(Boolean);
- const c = s.models.find(d=>d[o] === i);
- if (!c) {
- const d = `find asset failed: skinId: ${e}, keyValue: ${i}`;
- return Promise.reject(new ParamError(d))
- }
- return log$e.debug("find asset success", c),
- c
- }
- async findPoint(e, i) {
- const s = (await this.findSkinConfig(e)).pointList.find(c=>c.id === i);
- if (!s) {
- const c = `find point failed: skinId: ${e}, id: ${i}`;
- return Promise.reject(new ParamError(c))
- }
- return log$e.debug("find point success", s),
- s
- }
- async requestConfig() {
- if (this.config)
- return this.config;
- let e = `https://static.xverse.cn/console/config/${this.appId}/config.json`;
- this.releaseId && (e = `https://static.xverse.cn/console/config/${this.appId}/${this.releaseId}/config.json`);
- const i = Xverse$1.USE_TME_CDN ? "https://static.xverse.cn/tmeland/config/tme_config.json" : e;
- try {
- const o = await http$1.get({
- url: `${i}?t=${Date.now()}`,
- key: "config",
- timeout: 6e3,
- retry: 2
- })
- , {config: s, preload: c} = o.data.data || {};
- if (!s)
- throw new Error("config data parse error" + o.data);
- return this.config = {
- config: s,
- preload: c
- },
- log$e.debug("get config success", this.config),
- this.config
- } catch (o) {
- return Promise.reject(o)
- }
- }
- async getApplicationConfig() {
- if (this.applicationConfig)
- return this.applicationConfig;
- try {
- const e = await this.requestConfig();
- return this.applicationConfig = e.config,
- this.applicationConfig
- } catch (e) {
- return Promise.reject(e)
- }
- }
- async getAvatarModelList() {
- if (this.avatarModelList.length)
- return this.avatarModelList;
- try {
- const {avatars: e} = await this.getApplicationConfig();
- return this.avatarModelList = e.map(i=>({
- name: i.name,
- id: i.id,
- modelUrl: i.url,
- gender: i.gender,
- components: i.components
- })),
- this.avatarModelList
- } catch (e) {
- return log$e.error(e),
- Promise.reject(new InitConfigTimeoutError(e || "getAvatarModelList error"))
- }
- }
- async getSkinsList() {
- if (this.skinList.length)
- return this.skinList;
- try {
- const {skins: e} = await this.getApplicationConfig();
- return this.skinList = e.map(i=>{
- var o;
- return {
- name: i.name,
- dataVersion: i.id + i.versionId,
- id: i.id,
- fov: parseInt(i.fov || 90),
- models: i.assetList.map(s=>{
- const {assetId: c, url: d, thumbnailUrl: _, typeName: b, className: k} = s;
- return {
- id: c,
- modelUrl: d,
- name: s.name,
- thumbnailUrl: _,
- typeName: b,
- className: k === "\u4F4E\u6A21" ? "\u7C97\u6A21" : k
- }
- }
- ),
- routeList: (o = i.routeList) == null ? void 0 : o.map(s=>{
- const {areaName: c, attitude: d, id: _, pathName: b, step: k, birthPointList: j} = s;
- return {
- areaName: c,
- attitude: d,
- id: _,
- pathName: b,
- step: k,
- birthPointList: j.map($=>({
- camera: $.camera && {
- position: objectParseFloat($.camera.position),
- angle: objectParseFloat($.camera.rotation)
- },
- player: $.player && {
- position: objectParseFloat($.player.position),
- angle: objectParseFloat($.player.rotation)
- }
- }))
- }
- }
- ),
- pointList: i.pointList.map(s=>Zt($t({}, s), {
- position: objectParseFloat(s.position),
- rotation: objectParseFloat(s.rotation)
- })),
- versionId: i.versionId,
- isEnable: i.isEnable,
- assetList: i.assetList,
- visibleRules: i.visibleRules,
- animationList: i.animationList,
- resolution: i.resolution
- }
- }
- ),
- this.skinList
- } catch (e) {
- return log$e.error(e),
- Promise.reject(new InitConfigTimeoutError(e || "getSkinsList error"))
- }
- }
- async getBreathPointTextrueList() {
- return [{
- url: TEXTURE_URL
- }]
- }
- async findEffectList(e) {
- const o = (await this.findSkinConfig(e)).assetList.filter(s=>s.typeName === "EFFECTS");
- if (!o) {
- const s = `find effect failed: skinId: ${e}`;
- return Promise.reject(new ParamError(s))
- }
- return log$e.debug("find asset success", o),
- o
- }
- }
- ;
- let ModelManager = tr;
- Tt(ModelManager, "instance");
- var AssetTypeName = (a=>(a.Config = "CONFIG",
- a.Model = "MODEL",
- a.Vedio = "VEDIO",
- a.Media = "MEDIA",
- a.Effects = "EFFECTS",
- a.Gift = "GIFT",
- a.Textures = "TEXTURES",
- a))(AssetTypeName || {})
- , AssetClassName = (a=>(a.Effects = "\u7279\u6548",
- a.Tv = "TV",
- a.Lpm = "\u7C97\u6A21",
- a.Reward = "\u571F\u8C6A\u699C",
- a.Env = "\u73AF\u5883\u5149",
- a.Gbq = "\u544A\u767D\u5899",
- a.BreathPoint = "\u547C\u5438\u70B9",
- a.Gifts = "\u9001\u793C",
- a.Panorama = "\u5168\u666F\u56FE",
- a.GiftBubble = "\u9001\u793C\u6C14\u6CE1",
- a.SayBubble = "\u804A\u5929\u6C14\u6CE1",
- a))(AssetClassName || {});
- function mapLimit(a, e, i) {
- return new Promise((o,s)=>{
- const c = a.length;
- let d = e - 1
- , _ = 0;
- const b = k=>{
- k.forEach(j=>{
- i(j).then(()=>{
- if (_++,
- _ === c) {
- o();
- return
- }
- d++;
- const $ = a[d];
- $ && b([$])
- }
- , $=>{
- s($)
- }
- )
- }
- )
- }
- ;
- b(a.slice(0, e))
- }
- )
- }
- const log$d = new Logger("preload");
- class Preload {
- constructor(e) {
- Tt(this, "config");
- Tt(this, "allKeys", []);
- Tt(this, "oldResourcesDeleted", !1);
- Tt(this, "requests", {
- simple: {
- stopped: !0,
- requests: {}
- },
- observer: {
- stopped: !0,
- requests: {}
- },
- full: {
- stopped: !0,
- requests: {}
- }
- });
- this.modelManager = e,
- this.init(e.appId)
- }
- init(e) {
- reporter.updateBody({
- appId: e
- })
- }
- static getTimeoutBySize(e) {
- return e ? e < 500 * 1e3 ? 30 * 1e3 : e < 1e3 * 1e3 ? 60 * 1e3 : 100 * 1e3 : 100 * 1e3
- }
- async getConfig(e) {
- if (this.config)
- return this.config;
- const {preload: i} = await this.modelManager.requestConfig();
- return i ? (this.config = i,
- Promise.resolve(i)) : Promise.reject("no preload config")
- }
- async getAllKeys() {
- if (this.allKeys.length)
- return this.allKeys;
- try {
- const e = await modelTable.getAllKeys()._timeout(3e3, new TimeoutError("db getAllKeys timeout"));
- return this.allKeys = e,
- e
- } catch {
- const i = "preload getAllKeys error";
- return log$d.error(i),
- Promise.reject(i)
- }
- }
- stop(e) {
- e === "serverless" && (e = "observer"),
- this.requests[e].stopped = !0;
- const i = this.requests[e].requests;
- Object.keys(i).forEach(o=>{
- http$1.canceler.removePending(o),
- delete i[o]
- }
- )
- }
- clearPreload(e) {
- this.requests[e].stopped = !1,
- this.allKeys = []
- }
- async start(e, i, o) {
- let s = Date.now()
- , c = 0;
- try {
- if (e === "serverless" && (e = "observer"),
- !this.requests[e])
- return Promise.reject(new ParamError("invalid stage name: " + e));
- this.clearPreload(e);
- const d = await this.getConfig(e);
- let _ = [];
- const b = d.assetUrls.map(et=>et.url);
- try {
- _ = await this.getAllKeys(),
- await this.deleteOldResources(b, _)
- } catch {
- log$d.error("getAllKeys error, deleting db"),
- await modelTable.clearDataBase()
- }
- const {baseUrls: k, assetUrls: j} = d;
- let$;
- switch (e) {
- case "simple":
- $ = k;
- break;
- case "observer":
- $ = j;
- break;
- case "full":
- $ = j;
- break;
- default:
- $ = j
- }
- let _e = $.filter(et=>!_.includes(et.url));
- o && isFunction(o) && (_e = _e.filter(o)),
- c = _e.length,
- log$d.debug("keysNeedToPreload", _e),
- log$d.warn("preloadStart", _e.length),
- _e.length || i && i($.length, $.length),
- s = Date.now(),
- await this._preload(e, _e, i),
- log$d.infoAndReportMeasurement({
- tag: e,
- startTime: s,
- metric: "assetsPreload",
- extra: {
- total: c
- }
- });
- return
- } catch (d) {
- let _ = d;
- return (this.requests[e].stopped || axios.isCancel(d)) && (_ = new PreloadCanceledError),
- log$d.infoAndReportMeasurement({
- tag: e,
- startTime: s,
- metric: "assetsPreload",
- extra: {
- total: c
- },
- error: _,
- reportOptions: {
- immediate: !0
- }
- }),
- Promise.reject(_)
- }
- }
- async deleteOldResources(e, i) {
- if (!this.oldResourcesDeleted)
- this.oldResourcesDeleted = !0;
- else
- return Promise.resolve();
- const o = i.filter(c=>!e.includes(c));
- log$d.debug("keysNeedToDelete", o),
- log$d.warn("keysNeedToDelete", o.length);
- const s = Promise.all(o.map(c=>modelTable.delete(c)));
- try {
- await s
- } catch (c) {
- log$d.error("deleteOldResources error", c)
- }
- }
- async _preload(e, i, o) {
- const s = i.length;
- if (!s)
- return Promise.resolve();
- let c = 0;
- const d = window.setInterval(()=>{
- o && o(c, s),
- c >= s && window.clearInterval(d)
- }
- , 1e3);
- return mapLimit(i, 10, async _=>{
- const {size: b, url: k} = _;
- return this.requests[e].stopped ? Promise.reject(new PreloadCanceledError) : AssetsStorage.requestAndPut({
- url: k,
- timeout: Preload.getTimeoutBySize(b),
- responseType: "blob",
- retry: 2,
- beforeRequest: ()=>{
- this.requests[e].requests[k] = !0
- }
- }).then(()=>{
- c++,
- delete this.requests[e].requests[k]
- }
- , j=>(delete this.requests[e].requests[k],
- window.clearInterval(d),
- Promise.reject(j)))
- }
- )
- }
- }
- let sceneManager;
- function getSceneManager(a, e) {
- return sceneManager || (sceneManager = new XSceneManager(a,e)),
- sceneManager
- }
- const log$c = new Logger("tv");
- class TV extends XTelevision {
- constructor(i, o, s, c) {
- super(s.scene, o, s.sceneManager, c);
- Tt(this, "decal");
- Tt(this, "id");
- Tt(this, "imageUrl");
- Tt(this, "mode", "video");
- Tt(this, "room");
- Tt(this, "_isStoped", !1);
- Tt(this, "setVideo", (i,o=!1,s=!0)=>(log$c.warn("setVideo", {
- isLive: o,
- fixElement: s,
- src: i.src
- }),
- super.setVideo(i, o, s).then(()=>(this._isStoped = !1,
- log$c.warn("setVideo Success", {
- isLive: o,
- fixElement: s,
- src: i.src
- }),
- this))));
- this.id = i,
- this.room = s,
- this.decal = new XDecalManager(s.sceneManager)
- }
- get isStoped() {
- return this._isStoped
- }
- get objectFit() {
- return this.tvFitMode
- }
- set objectFit(i) {
- this.objectFit !== i && (this.tvFitMode = i,
- this.getVideoMat() && this.changeTvFitMode())
- }
- show() {
- this.mode === "video" ? this.toggle(!0) : this.mode === "poster" && this.showPoster()
- }
- hide() {
- this.mode === "video" ? this.toggle(!1) : this.mode === "poster" && this.hidePoster()
- }
- showVideo() {
- this.mode = "video",
- this.toggle(!0)
- }
- hideVideo() {
- this.toggle(!1)
- }
- showPoster() {
- const i = this.imageUrl;
- if (!i)
- return Promise.reject("set poster url before show it");
- if (!this.decal)
- return Promise.reject("decal was not found");
- const o = this.id;
- return this.decal.addDecal({
- id: o,
- meshPath: this.meshPath
- }).then(()=>{
- var s;
- this.mode = "poster",
- (s = this.decal) == null || s.setDecalTexture({
- id: o,
- buffer: i
- }).then(()=>{
- var c;
- (c = this.decal) == null || c.toggle(o, !0)
- }
- )
- }
- )
- }
- setPoster(i) {
- return this.imageUrl = i,
- this.showPoster()
- }
- hidePoster() {
- return this.decal ? this.decal.toggle(this.id, !1) : Promise.reject("decal was not found")
- }
- async setUrl(i) {
- const o = Date.now()
- , {url: s, loop: c=!1, muted: d} = i || {};
- if (log$c.warn("setUrl", {
- url: s,
- loop: c,
- muted: d
- }),
- !s)
- return log$c.error("tv url is required"),
- Promise.reject("tv url is required");
- await super.setUrl({
- url: s,
- bLoop: c,
- bMuted: d
- });
- const _ = this.videoElement;
- if (!_)
- return Promise.reject(new InternalError("video element is not found"));
- _.crossOrigin = "anonymous",
- _.playsInline = !0,
- _.load(),
- this.mode = "video",
- this._isStoped = !1;
- try {
- await new Promise(b=>{
- _.oncanplay = ()=>{
- log$c.warn(`setUrl success, video oncanplay within ${(Date.now() - o) / 1e3}s`, {
- url: s,
- loop: c,
- muted: d
- }),
- this.room.afterSetUrlHook(),
- _.play(),
- b(this)
- }
- }
- )._timeout(15e3, new InternalError("video oncanplay timeout in 15s"))
- } catch (b) {
- return log$c.error(b),
- Promise.reject(b)
- }
- return this
- }
- stop() {
- return log$c.warn("tv stop success"),
- this._isStoped = !0,
- this.room.afterTvStopedHook(),
- super.stop()
- }
- play() {
- return this._isStoped = !1,
- this.room.afterTvPlayedHook(),
- super.play().then(()=>{
- log$c.warn("tv play success"),
- !this.videoElement && log$c.error("tv play fake success, videoElement is not found")
- }
- ).catch(i=>(log$c.error("tv play error", i),
- Promise.reject(i)))
- }
- mirrorFrom(i) {
- const o = i.getVideoMat();
- return this.setSameVideo(o).then(()=>{
- this.toggle(!0)
- }
- )
- }
- clean() {
- var i;
- this.cleanTv(!1, !0),
- (i = this.decal) == null || i.deleteDecal(this.id)
- }
- }
- const log$b = new Logger("xverse-bus")
- , ir = class {
- constructor(e) {
- Tt(this, "_tvs", []);
- Tt(this, "isRenderFirstFrame", !1);
- Tt(this, "_idleTime", 0);
- Tt(this, "renderTimer");
- Tt(this, "lightManager");
- Tt(this, "_checkSceneNotReadyCount", 0);
- Tt(this, "_checkSceneDurationFrameNum", 0);
- Tt(this, "_checkSceneFrameCount", 0);
- Tt(this, "timeoutCircularArray", new CircularArray(120,!1,[]));
- Tt(this, "frameCircularArray", new CircularArray(120,!1,[]));
- Tt(this, "interFrameCircularArray", new CircularArray(120,!1,[]));
- Tt(this, "drawCallCntCircularArray", new CircularArray(120,!1,[]));
- Tt(this, "activeFacesCircularArray", new CircularArray(120,!1,[]));
- Tt(this, "renderTimeCircularArray", new CircularArray(120,!1,[]));
- Tt(this, "drawCallTimeCircularArray", new CircularArray(120,!1,[]));
- Tt(this, "animationCircularArray", new CircularArray(120,!1,[]));
- Tt(this, "meshSelectCircularArray", new CircularArray(120,!1,[]));
- Tt(this, "renderTargetCircularArray", new CircularArray(120,!1,[]));
- Tt(this, "regBeforeRenderCircularArray", new CircularArray(120,!1,[]));
- Tt(this, "regAfterRenderCircularArray", new CircularArray(120,!1,[]));
- Tt(this, "renderCnt", 0);
- Tt(this, "renderErrorCount", 0);
- Tt(this, "engineSloppyCnt", 0);
- Tt(this, "systemStuckCnt", 0);
- Tt(this, "timeoutSecondArray", new SecondArray);
- Tt(this, "frameRenderNumber", 0);
- Tt(this, "_setFPS", (e,i=25)=>{
- log$b.info("Set fps to", i);
- const o = i > 60 ? 60 : i < 24 ? 24 : i;
- e.Engine.stopRenderLoop();
- const s = 1e3 / o;
- let c = Date.now()
- , d = Date.now()
- , _ = s
- , b = 1;
- const k = ()=>{
- var st;
- const j = Date.now()
- , $ = j - c
- , _e = j - d;
- d = j,
- this.frameCircularArray.add(_e),
- $ - _ > s && (this.systemStuckCnt += 1),
- this.timeoutSecondArray.add($ - _);
- const et = $ / _;
- b = .9 * b + .1 * et;
- const tt = Date.now();
- let rt = 0
- , it = 0;
- if (this.room.isUpdatedRawYUVData || this.room.isPano) {
- if (this.isRenderFirstFrame = !0,
- this._checkSceneDurationFrameNum > 0)
- this._checkSceneFrameCount++,
- this.room.sceneManager.isReadyToRender({}) && this._checkSceneDurationFrameNum--,
- this._checkSceneFrameCount > ir._CHECK_DURATION && (this._checkSceneDurationFrameNum = ir._CHECK_DURATION,
- this._checkSceneFrameCount = 0,
- this._checkSceneNotReadyCount++,
- (this._checkSceneNotReadyCount == 1 || this._checkSceneNotReadyCount % 100 == 0) && log$b.error(`[SDK] Scene not ready, skip render. loop: ${this._checkSceneNotReadyCount}`),
- this._checkSceneNotReadyCount > 10 && (log$b.error("[SDK] Scene not ready, reload later"),
- this.room.proxyEvents("renderError", {
- error: new Error("[SDK] Scene not ready, skip render and reload.")
- })),
- this.room.stats.assign({
- renderErrorCount: this._checkSceneNotReadyCount
- }),
- log$b.infoAndReportMeasurement({
- value: 0,
- startTime: Date.now(),
- metric: "renderError",
- error: new Error("[SDK] Scene not ready, skip render and reload."),
- reportOptions: {
- sampleRate: .1
- }
- }));
- else
- try {
- this.room.allowRender && e.render()
- } catch (ut) {
- this.renderErrorCount++,
- this.renderErrorCount > 10 && this.room.proxyEvents("renderError", {
- error: ut
- }),
- this.room.stats.assign({
- renderErrorCount: this.renderErrorCount
- }),
- log$b.infoAndReportMeasurement({
- value: 0,
- startTime: Date.now(),
- metric: "renderError",
- error: ut,
- reportOptions: {
- sampleRate: .1
- }
- })
- }
- rt = Date.now() - tt,
- this.frameRenderNumber < 1e3 && this.frameRenderNumber++,
- this.room.networkController.rtcp.workers.UpdateYUV(),
- it = Date.now() - tt - rt
- }
- this.isRenderFirstFrame || this.room.networkController.rtcp.workers.UpdateYUV();
- const ot = Date.now() - tt;
- c = j + ot,
- _ = Math.min(Math.max((s - ot) / b, 5), 200),
- ot > s && (_ = 10,
- this.engineSloppyCnt += 1),
- this._idleTime = _;
- const at = _;
- if (_ > 150 && console.log("lastGap is ", _, ", ratio is ", b, ", usedTimeMs is ", ot, ", cpuRenderTime is ", rt, ", cpuUpdateYUVTime is ", it),
- this.timeoutCircularArray.add(at),
- this.renderCnt % 25 == 0) {
- const ut = this.frameCircularArray.getAvg()
- , ct = this.timeoutCircularArray.getAvg()
- , lt = this.frameCircularArray.getMax()
- , ft = this.timeoutCircularArray.getMax();
- (st = this.room.stats) == null || st.assign({
- avgFrameTime: ut,
- avgTimeoutTime: ct,
- maxFrameTime: lt,
- maxTimeoutTime: ft,
- systemStuckCnt: this.systemStuckCnt
- })
- }
- this.renderTimer = window.setTimeout(k, _)
- }
- ;
- this.renderTimer = window.setTimeout(k, s / b)
- }
- );
- Tt(this, "updateStats", ()=>{
- var i;
- const e = this.timeoutSecondArray.getStat();
- (i = this.room.stats) == null || i.assign({
- renderFrameTime: this.renderTimeCircularArray.getAvg(),
- maxRenderFrameTime: this.renderTimeCircularArray.getMax(),
- interFrameTime: this.interFrameCircularArray.getAvg(),
- animationTime: this.animationCircularArray.getAvg(),
- meshSelectTime: this.meshSelectCircularArray.getAvg(),
- drawcallTime: this.drawCallTimeCircularArray.getAvg(),
- idleTime: this._idleTime,
- registerBeforeRenderTime: this.regBeforeRenderCircularArray.getAvg(),
- registerAfterRenderTime: this.regAfterRenderCircularArray.getAvg(),
- renderTargetRenderTime: this.renderTargetCircularArray.getAvg(),
- fps: (1e3 / (this.renderTimeCircularArray.getAvg() + this.interFrameCircularArray.getAvg())).toFixed(2),
- drawcall: this.drawCallCntCircularArray.getAvg(),
- engineSloppyCnt: this.engineSloppyCnt,
- maxInterFrameTime: this.interFrameCircularArray.getMax(),
- maxDrawcallTime: this.drawCallTimeCircularArray.getMax(),
- maxMeshSelectTime: this.meshSelectCircularArray.getMax(),
- maxAnimationTime: this.animationCircularArray.getMax(),
- maxRegisterBeforeRenderTime: this.regBeforeRenderCircularArray.getMax(),
- maxRegisterAfterRenderTime: this.regAfterRenderCircularArray.getMax(),
- maxRenderTargetRenderTime: this.renderTargetCircularArray.getMax(),
- avgFrameTime: this.frameCircularArray.getAvg(),
- avgTimeoutTime: this.timeoutCircularArray.getAvg(),
- maxFrameTime: this.frameCircularArray.getMax(),
- maxTimeoutTime: this.timeoutCircularArray.getMax(),
- maxTimeoutGap: e.max
- })
- }
- );
- this.room = e
- }
- async initEngine(e) {
- var d, _;
- await this.updateBillboard(),
- log$b.info("engine version:", VERSION$1);
- const i = new Logger("engine");
- i.setLevel(LoggerLevels.Warn);
- const o = {
- videoResOriArray: [{
- width: 720,
- height: 1280
- }, {
- width: 1280,
- height: 720
- }, {
- width: 480,
- height: 654
- }, {
- width: 654,
- height: 480
- }, {
- width: 1920,
- height: 1080
- }, {
- width: 1080,
- height: 1920
- }, {
- width: 414,
- height: 896
- }],
- forceKeepVertical: this.room.options.objectFit !== "cover",
- panoInfo: {
- dynamicRange: 1,
- width: 4096,
- height: 2048
- },
- shaderMode: EShaderMode.videoAndPano,
- yuvInfo: {
- width: 1280,
- height: 720,
- fov: e.fov || DEFAULT_MAIN_CAMERA_FOV
- },
- cameraParam: {
- maxZ: 1e4
- },
- urlTransformer,
- logger: i,
- disableWebGL2: this.room.options.disableWebGL2 || !1
- }
- , s = (_ = (d = this.room) == null ? void 0 : d.skin) == null ? void 0 : _.resolution;
- s && (o.videoResOriArray.some(k=>k.width === s.width && k.height === s.height) || o.videoResOriArray.push(s));
- const c = this.room.sceneManager = getSceneManager(this.room.canvas, o);
- this.room.setPictureQualityLevel(this.room.options.pictureQualityLevel || "high"),
- this.room.sceneManager.staticmeshComponent.setRegionLodRule([2, 2, -1, -1, -1]),
- this.room.scene = c.Scene,
- this.room.breathPointManager = c.breathPointComponent,
- this.lightManager = c.lightComponent,
- this.registerStats(),
- await this.setEnv(e),
- await this.room.avatarManager.init(),
- await this._updateSkinAssets(e.id),
- this._setFPS(c)
- }
- pause() {
- clearTimeout(this.renderTimer),
- log$b.info("Invoke room.pause to pause render");
- const e = {
- roomId: this.room.id,
- effects: [],
- lowPolyModels: [],
- breathPointsConfig: [],
- skinId: this.room.skinId
- };
- return this.loadAssets(e, this.room.skinId)
- }
- async resume() {
- this._setFPS(this.room.sceneManager),
- this.room.sceneManager.cameraComponent.cameraFovChange(this.room.sceneManager.yuvInfo),
- log$b.info("Invoke room.resume to render");
- const e = this._createAssetList(this.room.skin);
- await this.loadAssets(e, "")
- }
- async setEnv(e) {
- var o;
- this.lightManager || (this.lightManager = this.room.sceneManager.lightComponent),
- e = e || this.room.skin;
- const i = ModelManager.findModel(e.models, AssetTypeName.Config, AssetClassName.Env);
- return i ? (o = this.lightManager) == null ? void 0 : o.setIBL(i.modelUrl) : (log$b.error("env file not found"),
- Promise.resolve())
- }
- async _parseModelsAndLoad(e, i, o) {
- log$b.info("Invoke _parseModelsAndLoad start", i);
- const s = ["airship", "balloon", "default", "ground_feiting", "ground_reqiqiu"]
- , c = new Map;
- o == null && (o = "xxxx");
- let d = !0;
- for (let k = 0; k < e.length; ++k) {
- d = !0;
- for (let j = 0; j < s.length; ++j)
- if (e[k].modelUrl.toLowerCase().indexOf(s[j]) >= 0) {
- const $ = c.get(s[j]);
- $ ? ($.push(e[k]),
- c.set(s[j], $)) : c.set(s[j], [e[k]]),
- d = !1;
- break
- }
- if (d) {
- const j = c.get("default");
- j ? (j.push(e[k]),
- c.set("default", j)) : c.set("default", [e[k]])
- }
- }
- let _ = c.get(i) || [];
- if (this.room.viewMode === "simple" && (_ = _.filter(k=>!k.modelUrl.endsWith("zip"))),
- !_)
- return Promise.reject(`no invalid scene model with group name: ${i}`);
- const b = [];
- for (let k = 0; k < _.length; ++k) {
- const j = _[k];
- if (j.modelUrl.toLowerCase().endsWith("zip"))
- j.modelUrl.toLowerCase().endsWith("zip") && b.push(this.room.sceneManager.addNewLowPolyMesh({
- url: j.modelUrl,
- skinInfo: o
- }));
- else {
- const $ = i;
- b.push(this.room.sceneManager.addNewLowPolyMesh({
- url: j.modelUrl,
- group: $,
- pick: !0,
- skinInfo: o
- }))
- }
- }
- return Promise.all(b)
- }
- async _deleteAssetsLowpolyModel(e) {
- this.room.sceneManager.staticmeshComponent.deleteMeshesBySkinInfo(e),
- this.room.sceneManager.breathPointComponent.clearBreathPointsBySkinInfo(e),
- this.room.sceneManager.decalComponent.deleteDecalBySkinInfo(e);
- const i = [];
- this.room.sceneManager.Scene.meshes.forEach(o=>{
- o.xskinInfo == e && i.push(o)
- }
- ),
- i.forEach(o=>{
- o.dispose(!1, !1)
- }
- )
- }
- async loadLandAssets() {
- const e = this._createAssetList(this.room.skin);
- return this.loadAssets(e, this.room.skinId).catch(()=>this.loadAssets(e, this.room.skinId))
- }
- async loadAssets(e, i="", o=8e3) {
- const s = Date.now();
- return this._loadAssets(e, i)._timeout(o, new InitEngineTimeoutError(`loadAssets timeout(${o}ms)`)).then(c=>(log$b.infoAndReportMeasurement({
- tag: "loadAssets",
- startTime: s,
- metric: "loadAssets"
- }),
- c)).catch(c=>(log$b.infoAndReportMeasurement({
- tag: "loadAssets",
- startTime: s,
- metric: "loadAssets",
- error: c
- }),
- Promise.reject(c)))
- }
- async _loadAssets(e, i="") {
- try {
- const o = [];
- o.push(this._loadAssetsLowpolyModel(e, i)),
- await Promise.all(o),
- this._checkSceneDurationFrameNum = ir._CHECK_DURATION,
- this._checkSceneNotReadyCount = 0,
- this._checkSceneFrameCount = 0,
- this.updateAnimationList()
- } catch (o) {
- return Promise.reject(o)
- }
- }
- updateAnimationList() {
- if (this.room.avatarManager && this.room.avatarManager.xAvatarManager) {
- const e = this.room.skin.animationList;
- if (!e)
- return;
- e.forEach(i=>{
- this.room.avatarManager.xAvatarManager.updateAnimationLists(i.animations, i.avatarId)
- }
- )
- }
- }
- async _loadAssetsLowpolyModel(e, i="") {
- const o = []
- , s = []
- , c = [];
- e.lowPolyModels.forEach($=>{
- $.group === "TV" ? s.push({
- id: "",
- name: "",
- thumbnailUrl: "",
- typeName: AssetTypeName.Model,
- className: AssetClassName.Tv,
- modelUrl: $.url
- }) : $.group === "\u544A\u767D\u5899" ? c.push({
- id: "",
- name: "",
- thumbnailUrl: "",
- typeName: AssetTypeName.Model,
- className: AssetClassName.Lpm,
- modelUrl: $.url
- }) : o.push({
- id: "",
- name: "",
- thumbnailUrl: "",
- typeName: AssetTypeName.Model,
- className: AssetClassName.Lpm,
- modelUrl: $.url
- })
- }
- ),
- i != "" && i != null && this._deleteAssetsLowpolyModel(i);
- const d = e.skinId;
- log$b.info("====> from ", i, " to ", d),
- this._tvs.forEach($=>$.clean()),
- this._tvs = [],
- Array.isArray(s) && s.forEach(($,_e)=>{
- this._tvs.push(new TV("squareTv" + _e,$.modelUrl,this.room,{
- fitMode: EFitMode.cover
- }))
- }
- ),
- e.breathPointsConfig.forEach(async$=>{
- let _e;
- try {
- _e = await urlTransformer($.imageUrl)
- } catch (et) {
- _e = $.imageUrl,
- log$b.error("urlTransformer error", et)
- }
- this.room.breathPointManager.addBreathPoint({
- id: $.id,
- position: $.position,
- spriteSheet: _e,
- rotation: $.rotation || {
- pitch: 0,
- yaw: 270,
- roll: 0
- },
- billboardMode: !0,
- type: $.type || "no_type",
- spriteWidthNumber: $.spriteWidthNum || 1,
- spriteHeightNumber: $.spriteHeightNum || 1,
- maxVisibleRegion: $.maxVisibleRegion || 150,
- width: $.width,
- height: $.height,
- skinInfo: $.skinId
- })
- }
- ),
- c.forEach($=>{
- this.room.sceneManager.decalComponent.addDecal({
- id: $.id || "gbq",
- meshPath: $.modelUrl,
- skinInfo: d
- })
- }
- );
- const b = this.room.sceneManager.staticmeshComponent.lowModel_group
- , k = Array.from(b.keys()).filter($=>!$.startsWith("region_"))
- , j = ["airship", "balloon", "ground_feiting", "ground_reqiqiu", "default"];
- return new Promise(($,_e)=>{
- Promise.all(j.map(et=>this._parseModelsAndLoad(o, et, d))).then(()=>{
- let et = !1;
- o.forEach(it=>{
- it.modelUrl.endsWith("zip") && (et = !0)
- }
- ),
- et == !1 && this.room.sceneManager.staticmeshComponent.deleteLastRegionMesh(),
- this.room.sceneManager.staticmeshComponent.lowModel_group;
- const tt = Array.from(b.keys()).filter(it=>!it.startsWith("region_"))
- , rt = k.filter(it=>tt.indexOf(it) < 0);
- rt.length > 0 && rt.forEach(it=>{
- this.room.sceneManager.staticmeshComponent.deleteMeshesByGroup(it)
- }
- ),
- $(!0)
- }
- ).catch(et=>{
- _e(et)
- }
- )
- }
- )
- }
- async _updateSkinAssets(e) {
- const i = this.room.currentState.skinId
- , o = await this.room.getSkin(e)
- , s = this._createAssetList(o);
- try {
- await this.loadAssets(s, i),
- this.room.updateCurrentState({
- versionId: o.versionId,
- skinId: o.id,
- skin: o
- })
- } catch {
- await this.loadAssets(s, i),
- this.room.updateCurrentState({
- versionId: o.versionId,
- skinId: o.id,
- skin: o
- })
- }
- const c = this.room.sceneManager.yuvInfo;
- this.room.sceneManager.changeCameraFovWithShaderUpdate(Zt($t({}, c), {
- fov: o.fov
- })),
- this.room.afterLoadAssetsHook(),
- await this.setEnv(o)
- }
- _createAssetList(e) {
- const i = []
- , o = []
- , s = [];
- let c = e.models;
- const d = this.room.modelManager.config.preload;
- return this.room.viewMode === "simple" ? d && (c = d.baseUrls.map(b=>(b.modelUrl = b.url,
- b))) : this.room.viewMode,
- ModelManager.findModels(c, AssetTypeName.Effects, AssetClassName.Effects).forEach(b=>{
- i.push({
- url: b.modelUrl,
- group: b.className,
- name: b.name
- })
- }
- ),
- ModelManager.findModels(c, AssetTypeName.Model, AssetClassName.Lpm).forEach(b=>{
- o.push({
- url: b.modelUrl,
- group: b.className
- })
- }
- ),
- ModelManager.findModels(c, AssetTypeName.Model, AssetClassName.Gbq).forEach(b=>{
- o.push({
- url: b.modelUrl,
- group: b.className
- })
- }
- ),
- ModelManager.findModels(c, AssetTypeName.Model, AssetClassName.Tv).forEach(b=>{
- o.push({
- url: b.modelUrl,
- group: b.className
- })
- }
- ),
- [].forEach(b=>{
- b.skinId == e.id && s.push(b)
- }
- ),
- {
- roomId: this.room.id,
- effects: i,
- lowPolyModels: o,
- breathPointsConfig: s,
- skinId: e.id
- }
- }
- registerStats() {
- const e = this.room.sceneManager;
- this.room.scene.registerAfterRender(()=>{
- var _t;
- const i = e.statisticComponent.getInterFrameTimeCounter()
- , o = e.statisticComponent.getDrawCall()
- , s = e.statisticComponent.getActiveFaces()
- , c = e.statisticComponent.getFrameTimeCounter()
- , d = e.statisticComponent.getDrawCallTime()
- , _ = e.statisticComponent.getAnimationTime()
- , b = e.statisticComponent.getActiveMeshEvaluationTime()
- , k = e.statisticComponent.getRenderTargetRenderTime()
- , j = e.statisticComponent.getRegisterBeforeRenderTime()
- , $ = e.statisticComponent.getRegisterAfterRenderTime()
- , _e = e.statisticComponent.getActiveParticles()
- , et = e.statisticComponent.getActiveBones()
- , tt = e.Scene._activeAnimatables.length
- , rt = e.statisticComponent.getTotalRootNodes()
- , it = e.Scene.geometries.length
- , nt = e.Scene.onBeforeRenderObservable.observers.length
- , ot = e.Scene.onAfterRenderObservable.observers.length
- , at = e.statisticComponent.getTotalMeshes()
- , st = e.statisticComponent.getTotalTextures()
- , ut = e.statisticComponent.getTotalMaterials()
- , ct = e.statisticComponent.getSystemInfo()
- , lt = ct.resolution
- , ft = ct.driver;
- ct.vender;
- const ht = ct.version
- , pt = ct.hardwareScalingLevel
- , dt = lt + "_" + ft + "_" + ht + "_" + pt;
- this.interFrameCircularArray.add(i),
- this.renderTimeCircularArray.add(c),
- this.animationCircularArray.add(_),
- this.meshSelectCircularArray.add(b),
- this.drawCallTimeCircularArray.add(d),
- this.regAfterRenderCircularArray.add($),
- this.regBeforeRenderCircularArray.add(j),
- this.renderTargetCircularArray.add(k),
- this.drawCallCntCircularArray.add(o),
- this.renderCnt += 1,
- this.renderCnt % 25 == 0 && ((_t = this.room.stats) == null || _t.assign({
- renderFrameTime: this.renderTimeCircularArray.getAvg(),
- maxRenderFrameTime: this.renderTimeCircularArray.getMax(),
- interFrameTime: this.interFrameCircularArray.getAvg(),
- animationTime: this.animationCircularArray.getAvg(),
- meshSelectTime: this.meshSelectCircularArray.getAvg(),
- drawcallTime: this.drawCallTimeCircularArray.getAvg(),
- idleTime: this._idleTime,
- registerBeforeRenderTime: this.regBeforeRenderCircularArray.getAvg(),
- registerAfterRenderTime: this.regAfterRenderCircularArray.getAvg(),
- renderTargetRenderTime: this.renderTargetCircularArray.getAvg(),
- fps: (1e3 / (this.renderTimeCircularArray.getAvg() + this.interFrameCircularArray.getAvg())).toFixed(2),
- drawcall: this.drawCallCntCircularArray.getAvg(),
- triangle: s.toString(),
- engineSloppyCnt: this.engineSloppyCnt,
- maxInterFrameTime: this.interFrameCircularArray.getMax(),
- maxDrawcallTime: this.drawCallTimeCircularArray.getMax(),
- maxMeshSelectTime: this.meshSelectCircularArray.getMax(),
- maxAnimationTime: this.animationCircularArray.getMax(),
- maxRegisterBeforeRenderTime: this.regBeforeRenderCircularArray.getMax(),
- maxRegisterAfterRenderTime: this.regAfterRenderCircularArray.getMax(),
- maxRenderTargetRenderTime: this.renderTargetCircularArray.getMax(),
- activeParticles: _e,
- activeBones: et,
- activeAnimation: tt,
- totalMeshes: at,
- totalRootNodes: rt,
- totalGeometries: it,
- totalTextures: st,
- totalMaterials: ut,
- registerBeforeCount: nt,
- registerAfterCount: ot,
- hardwareInfo: dt
- }))
- }
- )
- }
- async updateBillboard() {
- const {options: {skinId: e}} = this.room
- , o = (await this.room.modelManager.findAssetList(e)).filter(d=>d.typeName === AssetTypeName.Textures && d.className === AssetClassName.SayBubble)
- , s = ["bubble01", "bubble02", "bubble03"]
- , c = ["bubble01_npc", "bubble02_npc", "bubble03_npc"];
- if (o.length) {
- const d = o.filter(b=>s.includes(b.name)).map(b=>b.url)
- , _ = o.filter(b=>c.includes(b.name)).map(b=>b.url);
- d.length && (XBillboardManager.userBubbleUrls = d),
- _.length && (XBillboardManager.npcBubbleUrls = _)
- }
- }
- }
- ;
- let EngineProxy = ir;
- Tt(EngineProxy, "_CHECK_DURATION", 2);
- var CameraStates = (a=>(a[a.Normal = 0] = "Normal",
- a[a.ItemView = 1] = "ItemView",
- a[a.CGView = 2] = "CGView",
- a[a.PathView = 3] = "PathView",
- a))(CameraStates || {})
- , Direction = (a=>(a.Left = "left",
- a.Right = "right",
- a))(Direction || {});
- const calNormVector = (a,e)=>{
- let i = 0;
- for (let s = 0; s < 3; ++s)
- i = i + (e[s] - a[s]) * (e[s] - a[s]);
- return i = Math.sqrt(i),
- [(e[0] - a[0]) / i, (e[1] - a[1]) / i, (e[2] - a[2]) / i]
- }
- , vectorCrossMulti = (a,e)=>{
- const i = a[0]
- , o = a[2]
- , s = e[0]
- , c = e[2];
- return i * c - o * s
- }
- , log$a = new Logger("camera");
- class Camera extends EventEmitter {
- constructor(i) {
- super();
- Tt(this, "initialFov", 0);
- Tt(this, "_state", CameraStates.Normal);
- Tt(this, "_person", Person.Third);
- Tt(this, "_room");
- Tt(this, "_cameraFollowing", !0);
- Tt(this, "checkPointOnLeftOrRight", i=>{
- const o = ue4Position2Xverse(i);
- if (!o || this.checkPointInView(i))
- return;
- const d = this._room.scene.activeCamera;
- if (!d)
- return;
- const _ = [d.target.x, d.target.y, d.target.z]
- , b = [d.position.x, d.position.y, d.position.z]
- , {x: k, y: j, z: $} = o
- , _e = calNormVector(b, _)
- , et = calNormVector(b, [k, j, $]);
- return vectorCrossMulti(_e, et) < 0 ? Direction.Right : Direction.Left
- }
- );
- Tt(this, "checkPointInView", ({x: i, y: o, z: s})=>{
- const c = ue4Position2Xverse({
- x: i,
- y: o,
- z: s
- });
- if (!c)
- return !1;
- for (let d = 0; d < 6; d++)
- if (this._room.scene.frustumPlanes[d].dotCoordinate(c) < 0)
- return !1;
- return !0
- }
- );
- this._room = i
- }
- get person() {
- return this._person
- }
- get state() {
- return this._state
- }
- get pose() {
- return this._room.currentClickingState.camera
- }
- set cameraFollowing(i) {
- log$a.info("cameraFollowing setter", i),
- this.setCameraFollowing({
- isFollowHost: i
- })
- }
- get cameraFollowing() {
- return this._cameraFollowing
- }
- setCameraFollowing({isFollowHost: i}) {}
- handleRenderInfo(i) {
- const {cameraStateType: o} = i.renderInfo
- , s = this._room.sceneManager;
- if (o !== this._state && (this._state = o,
- log$a.debug("camera._state changed to", CameraStates[o]),
- o === CameraStates.CGView ? (s.cameraComponent.switchToCgCamera(),
- s.staticmeshComponent.getCgMesh().show()) : (s.cameraComponent.switchToMainCamera(),
- s.staticmeshComponent.getCgMesh().hide()),
- this.emit("stateChanged", {
- state: o
- })),
- this._room.isHost)
- return;
- const {isFollowHost: c} = i.playerState;
- !!c !== this._cameraFollowing && (this._cameraFollowing = !!c,
- this.emit("cameraFollowingChanged", {
- cameraFollowing: !!c
- }))
- }
- setCameraState({state: i}) {
- if (this._state === i) {
- log$a.warn(`You are already in ${CameraStates[i]} camera state`);
- return
- }
- i === CameraStates.Normal || this._state === CameraStates.ItemView && log$a.warn("CloseUp camera state can only be triggerd by room internally")
- }
- turnToFace({extra: i="", offset: o=0}) {
- const s = {
- action_type: Actions.TurnToFace,
- turn_to_face_action: {
- offset: o
- }
- };
- return this.emit("viewChanged", {
- extra: i
- }),
- this._room.actionsHandler.sendData({
- data: s
- })
- }
- isInDefaultView() {
- if (!this._room.isHost) {
- log$a.warn("It is recommended to call the function on the host side");
- return
- }
- if (!this._room._currentClickingState)
- return log$a.error("CurrentState should not be empty"),
- !1;
- const {camera: i, player: o} = this._room._currentClickingState;
- return Math.abs(o.angle.yaw - 180 - i.angle.yaw) % 360 <= 4
- }
- async screenShot({name: i, autoSave: o=!1}) {
- const s = this._room.scene.getEngine()
- , c = this._room.scene.activeCamera;
- try {
- this._room.sceneManager.setImageQuality(EImageQuality.high);
- const d = await CreateScreenshotAsync(s, c, {
- precision: 1
- });
- return this._room.sceneManager.setImageQuality(EImageQuality.low),
- o === !0 && downloadFileByBase64(d, i),
- Promise.resolve(d)
- } catch (d) {
- return this._room.sceneManager.setImageQuality(EImageQuality.low),
- Promise.reject(d)
- }
- }
- changeToFirstPerson(i, o, s) {
- const {camera: c, player: d, attitude: _, areaName: b, pathName: k} = i;
- return this._room.actionsHandler.requestPanorama({
- camera: c,
- player: d,
- attitude: _,
- areaName: b,
- pathName: k
- }, o, s).then(()=>{
- this._room.networkController.rtcp.workers.changePanoMode(!0);
- const {position: j, angle: $} = d || {};
- this._room.sceneManager.cameraComponent.changeToFirstPersonView({
- position: j,
- rotation: $
- })
- }
- )
- }
- setPerson(i, o={
- camera: this._room._currentClickingState.camera,
- player: this._room._currentClickingState.player
- }) {
- const s = Date.now();
- return this._setPerson(i, o).then(c=>(log$a.infoAndReportMeasurement({
- tag: Person[i],
- startTime: s,
- metric: "setPerson"
- }),
- c)).catch(c=>(log$a.infoAndReportMeasurement({
- tag: Person[i],
- startTime: s,
- metric: "setPerson",
- error: c
- }),
- Promise.reject(c)))
- }
- _setPerson(i, o={
- camera: this._room._currentClickingState.camera,
- player: this._room._currentClickingState.player
- }) {
- 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({
- camera: o.camera,
- player: o.player,
- tag: "setPerson"
- }).then(()=>{
- var d, _;
- this._person = i,
- (d = this._room._userAvatar) == null || d.hide();
- const {position: s, angle: c} = ((_ = this._room.currentClickingState) == null ? void 0 : _.camera) || {};
- !s || !c || this._room.sceneManager.cameraComponent.changeToFirstPersonView({
- position: s,
- rotation: c
- })
- }
- ) : this._room.panorama.exit({
- camera: o.camera,
- player: o.player
- }).then(()=>{
- var s, c;
- this._person = i,
- (s = this._room._userAvatar) != null && s.xAvatar && ((c = this._room._userAvatar) == null || c.xAvatar.show())
- }
- )
- }
- setCameraPose(i) {
- this._room.sceneManager.cameraComponent.setCameraPose({
- position: i.position,
- rotation: i.angle
- })
- }
- async setMainCameraRotationLimit(i) {
- if (!this._room.panorama.actived)
- return Promise.reject(new Error("panorama not actived when setMainCameraRotationLimit"));
- const {limitAxis: o, limitRotation: s} = i;
- await this._room.sceneManager.cameraComponent.setMainCameraRotationLimit(o, s)
- }
- removeMainCameraRotationLimit() {
- this._room.sceneManager.cameraComponent.removeMainCameraRotationLimit()
- }
- }
- var IEffectType = (a=>(a.Sequence = "sequence",
- a.SubSequence = "subSequence",
- a))(IEffectType || {});
- const log$9 = new Logger("effectManager");
- class XverseEffect extends EventEmitter {
- constructor({id: i, jsonPath: o, type: s, room: c, scale: d=1}) {
- super();
- Tt(this, "_id");
- Tt(this, "type");
- Tt(this, "effect");
- Tt(this, "_room");
- Tt(this, "_isLoading", !0);
- Tt(this, "_failed", !1);
- Tt(this, "_scale", 1);
- this._room = c,
- this._id = i,
- this.type = s,
- this._scale = d,
- 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)
- }
- get failed() {
- return this._failed
- }
- get position() {
- if (this.type !== IEffectType.Sequence)
- return this.effect.position
- }
- get rotation() {
- if (this.type !== IEffectType.Sequence)
- return this.effect.rotation
- }
- get isLoading() {
- return this._isLoading
- }
- get id() {
- return this._id
- }
- get name() {
- return this.effect.name
- }
- get isPlaying() {
- var i;
- return !!((i = this.effect) != null && i.isPlaying)
- }
- async init() {
- try {
- await this.effect.init()._timeout(1e4, new TimeoutError("effect init timeout(10s)")),
- this._isLoading = !1,
- this._failed = !1
- } catch (i) {
- throw this._isLoading = !1,
- this._failed = !0,
- log$9.error(`effect: ${this.id} init error`, i),
- i
- }
- }
- play(i=!1) {
- return new Promise((o,s)=>{
- this.effect.play(i),
- o()
- }
- )
- }
- hide() {
- return this.effect.hide()
- }
- show() {
- return this.effect.show()
- }
- setRotation(i) {
- var o;
- return this.type === IEffectType.Sequence ? Promise.reject("setRotation failed, sequence unSuported") : (o = this.effect) == null ? void 0 : o.setRotation(i)
- }
- setPosition(i) {
- var o;
- return this.type === IEffectType.Sequence ? Promise.reject("setPosition failed, sequence unSuported") : (o = this.effect) == null ? void 0 : o.setPosition(i)
- }
- setScaling(i) {
- var o;
- return this.type === IEffectType.Sequence ? Promise.reject("setScaling failed, sequence unSuported") : (this._scale = i,
- (o = this.effect) == null ? void 0 : o.setScaling({
- x: i,
- y: -i,
- z: i
- }))
- }
- dispose() {
- this.effect.dispose()
- }
- }
- const log$8 = new Logger("xverse-effect-manager")
- , dr = class extends EventEmitter {
- constructor(i) {
- super();
- Tt(this, "effects", new Map);
- Tt(this, "room");
- this.room = i
- }
- async addEffect(i) {
- var d;
- const {jsonPath: o, id: s, type: c=IEffectType.SubSequence} = i;
- try {
- this.effects.get(s) && ((d = this.effects.get(s)) == null || d.dispose());
- const _ = new dr.subEffect({
- id: s,
- jsonPath: o,
- type: c,
- room: this.room
- });
- return this.effects.set(s, _),
- await _.init(),
- _
- } catch (_) {
- return this.effects.delete(s),
- log$8.error(_),
- Promise.reject(_)
- }
- }
- clearEffects() {
- this.effects.forEach(i=>{
- i.dispose(),
- this.effects.delete(i.id)
- }
- )
- }
- removeEffect(i) {
- const o = this.effects.get(i);
- o == null || o.dispose(),
- o && this.effects.delete(o.id)
- }
- }
- ;
- let XverseEffectManager = dr;
- Tt(XverseEffectManager, "subEffect", XverseEffect);
- Scene.DoubleClickDelay = 500;
- class StaticMeshEvent extends EventEmitter {
- constructor(i) {
- super();
- Tt(this, "scene");
- Tt(this, "_staringPointerTime", -1);
- Tt(this, "_pickedMeshID", "0");
- Tt(this, "_pointerDownTime", -1);
- Tt(this, "_currentPickPoint");
- Tt(this, "_longPressDelay", 500);
- Tt(this, "_pointerTapDelay", 200);
- Tt(this, "_pickedMeshType");
- Tt(this, "registerEvent", ()=>{
- this.scene.onPrePointerObservable.add(this.onDown, PointerEventTypes.POINTERDOWN),
- this.scene.onPrePointerObservable.add(this.onUp, PointerEventTypes.POINTERUP),
- this.scene.onPrePointerObservable.add(this.onDoubleTap, PointerEventTypes.POINTERDOUBLETAP),
- this.scene.onDispose = ()=>{
- this.scene.onPrePointerObservable.removeCallback(this.onUp),
- this.scene.onPrePointerObservable.removeCallback(this.onDown),
- this.scene.onPrePointerObservable.removeCallback(this.onDoubleTap)
- }
- }
- );
- Tt(this, "onUp", ()=>{
- if (Date.now() - this._pointerDownTime < this._pointerTapDelay && !this.scene._inputManager._isPointerSwiping()) {
- this.scene._inputManager._totalPointersPressed = 0;
- const i = this._currentPickPoint;
- i != null && this.emit("pointTap", i)
- }
- }
- );
- Tt(this, "onDown", ()=>{
- const i = this.onPointerTap(o=>o.isPickable);
- this._currentPickPoint = i,
- this._pointerDownTime = Date.now()
- }
- );
- Tt(this, "onDoubleTap", ()=>{
- const i = this.onPointerTap(void 0);
- i != null && this.emit("pointDoubleTap", i)
- }
- );
- this.manager = i,
- this.scene = i.Scene,
- this.registerEvent(),
- this._currentPickPoint = null,
- this._pickedMeshType = null
- }
- onPointerTap(i, o=!1) {
- var c, d;
- let s = new PickingInfo;
- if (o) {
- const _ = this.scene.multiPick(this.scene.pointerX, this.scene.pointerY, i, void 0, void 0);
- _ && _.length > 1 ? s = _[1] : _ && (s = _[0])
- } else
- s = this.scene.pick(this.scene.pointerX, this.scene.pointerY, i, !1, null);
- if (s.hit) {
- const _ = (c = s == null ? void 0 : s.pickedPoint) == null ? void 0 : c.asArray();
- if (_) {
- const [b,k,j] = _
- , $ = xversePosition2Ue4({
- x: b,
- y: k,
- z: j
- });
- return {
- name: (d = s.pickedMesh) == null ? void 0 : d.name,
- type: s.pickedMesh.xtype,
- id: s.pickedMesh.xid,
- point: $
- }
- }
- }
- return null
- }
- }
- class RotationEvent {
- constructor(e) {
- Tt(this, "touchStartX");
- Tt(this, "touchStartY");
- Tt(this, "handelResize");
- Tt(this, "_room");
- Tt(this, "_canvas");
- Tt(this, "handleTouchStart", e=>{
- const i = e.touches[0];
- this.touchStartX = i.pageX,
- this.touchStartY = i.pageY,
- this._room.emit("touchStart", {
- event: e
- })
- }
- );
- Tt(this, "handleMouseDown", e=>{
- this.touchStartX = e.pageX,
- this.touchStartY = e.pageY
- }
- );
- Tt(this, "handleMouseMove", e=>{
- if (!this.touchStartX || !this.touchStartY)
- return;
- const i = e.pageX
- , o = e.pageY
- , s = i - this.touchStartX
- , c = o - this.touchStartY
- , d = this._room.options.canvas.offsetHeight
- , _ = this._room.options.canvas.offsetWidth;
- let b = 2 * c / d
- , k = 2 * s / _;
- b > 1 && (b = 1),
- k > 1 && (k = 1),
- this._room.actionsHandler.rotate({
- pitch: b,
- yaw: k
- }),
- this.touchStartX = i,
- this.touchStartY = o
- }
- );
- Tt(this, "handleMouseUp", e=>{
- this.touchStartX = void 0,
- this.touchStartY = void 0,
- this._room.emit("mouseUp", {
- event: e
- })
- }
- );
- Tt(this, "handleTouchMove", e=>{
- if (!this.touchStartX || !this.touchStartY)
- return;
- const i = e.touches[0]
- , o = i.pageX
- , s = i.pageY
- , c = o - this.touchStartX
- , d = s - this.touchStartY
- , _ = this._room.options.canvas.offsetHeight
- , b = this._room.options.canvas.offsetWidth;
- let k = 2 * d / _
- , j = 2 * c / b;
- k > 1 && (k = 1),
- j > 1 && (j = 1),
- this._room.actionsHandler.rotate({
- pitch: k,
- yaw: j
- }),
- this.touchStartX = o,
- this.touchStartY = s,
- this._room.emit("touchMove", {
- pitch: k,
- yaw: j,
- event: e
- })
- }
- );
- Tt(this, "handleTouchEnd", e=>{
- this._room.emit("touchEnd", {
- event: e
- })
- }
- );
- this._room = e,
- this._canvas = e.canvas,
- this.handelResize = this.reiszeChange()
- }
- init() {
- this._canvas.addEventListener("touchstart", this.handleTouchStart),
- this._canvas.addEventListener("touchmove", this.handleTouchMove),
- this._canvas.addEventListener("touchend", this.handleTouchEnd),
- this._room.scene.preventDefaultOnPointerDown = !1,
- this._room.scene.preventDefaultOnPointerUp = !1,
- this._canvas.addEventListener("mousedown", this.handleMouseDown),
- this._canvas.addEventListener("mousemove", this.handleMouseMove),
- this._canvas.addEventListener("mouseup", this.handleMouseUp)
- }
- clear() {
- this._canvas.removeEventListener("touchstart", this.handleTouchStart),
- this._canvas.removeEventListener("touchmove", this.handleTouchMove),
- this._canvas.removeEventListener("touchend", this.handleTouchEnd),
- this._canvas.removeEventListener("mousedown", this.handleMouseDown),
- this._canvas.removeEventListener("mousemove", this.handleMouseMove),
- this._canvas.removeEventListener("mouseup", this.handleMouseUp)
- }
- reiszeChange() {
- window.addEventListener("resize", ()=>{}
- )
- }
- }
- const log$7 = new Logger("eventsController");
- class EventsController {
- constructor(e) {
- Tt(this, "staticmeshEvent");
- Tt(this, "rotationEvent");
- Tt(this, "resize", ()=>{
- this.room.panorama.actived || this.room.sceneManager.cameraComponent.cameraFovChange(this.room.sceneManager.yuvInfo)
- }
- );
- Tt(this, "clickEvent", e=>{
- const {point: i, name: o, type: s, id: c} = e;
- log$7.debug("pointEvent", e),
- this.room.proxyEvents("pointTap", {
- point: i,
- meshName: o,
- type: s,
- id: c
- }),
- this.room.proxyEvents("_coreClick", e)
- }
- );
- Tt(this, "longPressEvent", e=>{
- this.room.proxyEvents("_corePress", e)
- }
- );
- Tt(this, "handleActionResponseTimeout", ({error: e, event: i})=>{
- this.room.proxyEvents("actionResponseTimeout", {
- error: e,
- event: i
- })
- }
- );
- Tt(this, "handleNetworkStateChange", e=>{
- const {state: i, count: o} = e;
- i == "reconnecting" ? this.room.proxyEvents("reconnecting", {
- count: o || 1
- }) : i === "reconnected" ? (this.room.networkController.rtcp.workers.reset(),
- this.room.proxyEvents("reconnected"),
- this.room.afterReconnected()) : i === "disconnected" && this.room.proxyEvents("disconnected")
- }
- );
- this.room = e,
- this.staticmeshEvent = new StaticMeshEvent(this.room.sceneManager),
- this.rotationEvent = new RotationEvent(e)
- }
- bindEvents() {
- window.addEventListener("orientationchange"in window ? "orientationchange" : "resize", this.resize),
- this.staticmeshEvent.on("pointTap", this.clickEvent),
- this.staticmeshEvent.on("longPress", this.longPressEvent),
- this.rotationEvent.init(),
- eventsManager.on("actionResponseTimeout", this.handleActionResponseTimeout),
- this.room.networkController.on("stateChanged", this.handleNetworkStateChange)
- }
- clearEvents() {
- window.removeEventListener("orientationchange"in window ? "orientationchange" : "resize", this.resize),
- this.staticmeshEvent.off("pointTap", this.clickEvent),
- this.staticmeshEvent.off("longPress", this.longPressEvent),
- eventsManager.off("actionResponseTimeout", this.handleActionResponseTimeout),
- this.room.networkController.off("stateChanged", this.handleNetworkStateChange),
- this.rotationEvent.clear()
- }
- }
- const log$6 = new Logger("panorama");
- class Panorama {
- constructor(e) {
- Tt(this, "_actived", !1);
- Tt(this, "isLoading", !1);
- Tt(this, "handleReceivePanorama", async e=>{
- const i = e.camera;
- log$6.warn("handle panorama", i);
- const o = {
- data: e.data,
- pose: {
- position: i.position,
- rotation: i == null ? void 0 : i.angle
- }
- }
- , s = this.room.sceneManager;
- if (this.room.networkController.rtcp.workers.changePanoMode(!0),
- await s.materialComponent.changePanoImg(0, o),
- !!e.finished)
- if (await s.changePanoShaderForLowModel(0),
- this.room.isPano = !0,
- this._actived = !0,
- i)
- this.room.sceneManager.cameraComponent.changeToFirstPersonView({
- position: i.position,
- rotation: i.angle
- });
- else {
- const {skinId: c, pathName: d} = this.room.currentState;
- if (!c || !d)
- return;
- const _ = await this.room.modelManager.findRoute(c, d)
- , {camera: b} = getRandomItem(_.birthPointList) || {};
- b && this.room.sceneManager.cameraComponent.changeToFirstPersonView(Zt($t({}, b), {
- rotation: b.angle
- }))
- }
- }
- );
- this.room = e
- }
- get actived() {
- return this._actived
- }
- bindListener(e) {
- this.room.networkController.rtcp.workers.registerFunction("panorama", o=>{
- var b;
- log$6.warn("receive panorama");
- const {metadata: s} = o
- , c = JSON.parse(String.fromCharCode.apply(null, s));
- o.parsedMetaData = c;
- const d = (b = o.parsedMetaData.newUserStates) == null ? void 0 : b.find(k=>k.userId === this.room.userId)
- , _ = d == null ? void 0 : d.playerState.camera;
- o.camera = _,
- eventsManager.remove(o.parsedMetaData.traceIds[0], Codes$1.Success, o, !0),
- this.room.isFirstDataUsed || (this.room.isFirstDataUsed = !0,
- this.handleReceivePanorama(o).then(e))
- }
- )
- }
- access(e, i, o) {
- this.isLoading = !0;
- const {camera: s, player: c, attitude: d, areaName: _, pathName: b, tag: k} = e;
- return this.room.actionsHandler.requestPanorama({
- camera: s,
- player: c,
- attitude: d,
- areaName: _,
- pathName: b,
- tag: k
- }, i, o).then(j=>(this.isLoading = !1,
- this.handleReceivePanorama(j))).catch(j=>(this.isLoading = !1,
- Promise.reject(j)))
- }
- exit(e) {
- const {camera: i, player: o, attitude: s, areaName: c, pathName: d} = e;
- return this.room.networkController.rtcp.workers.changePanoMode(!1),
- this.room.actionsHandler.changeRotationRenderType({
- renderType: RenderType.RotationVideo,
- player: o,
- camera: i,
- attitude: s,
- areaName: c,
- pathName: d
- }).then(()=>this.handleExitPanorama()).catch(_=>(this.room.networkController.rtcp.workers.changePanoMode(!0),
- Promise.reject(_)))
- }
- handleExitPanorama() {
- var e, i, o, s, c, d;
- this.room.isPano = !1,
- this._actived = !1,
- (s = (e = this.room.sceneManager) == null ? void 0 : e.cameraComponent) == null || s.forceChangeSavedCameraPose({
- position: (i = this.room._currentClickingState) == null ? void 0 : i.camera.position,
- rotation: (o = this.room._currentClickingState) == null ? void 0 : o.camera.angle
- }),
- this.room.sceneManager.changeVideoShaderForLowModel(),
- (d = (c = this.room.sceneManager) == null ? void 0 : c.cameraComponent) == null || d.changeToThirdPersonView()
- }
- }
- class PathManager {
- constructor() {
- Tt(this, "currentArea", "");
- Tt(this, "currentPathName", "");
- Tt(this, "currentAttitude", "");
- Tt(this, "speed", 0)
- }
- getSpeed(e) {
- const i = {
- guangchang: {
- [MotionType.Walk]: 17,
- [MotionType.Run]: 51
- },
- tower: {
- [MotionType.Walk]: 12.5,
- [MotionType.Run]: 25
- },
- zhiboting: {
- [MotionType.Walk]: 12.5,
- [MotionType.Run]: 25
- },
- youxiting: {
- [MotionType.Walk]: 12.5,
- [MotionType.Run]: 25
- },
- diqing: {
- [MotionType.Walk]: 12.5,
- [MotionType.Run]: 25
- }
- }
- , o = i[this.currentArea] || i.guangchang;
- return this.speed = o[e] * 30,
- this.speed
- }
- }
- const log$5 = new Logger("http");
- class Http extends EventEmitter {
- constructor() {
- super(...arguments);
- Tt(this, "secondArray", new SecondArray)
- }
- async get({url: i, useIndexedDb: o=!1, timeout: s=15e3, key: c, isOutPutObjectURL: d=!0}) {
- if (Xverse$1.NO_CACHE !== void 0 && (o = !Xverse$1.NO_CACHE),
- o)
- if (isIndexedDbSupported()) {
- window.performance.now();
- let _ = null;
- try {
- _ = await modelTable.query("url", i)
- } catch (b) {
- return log$5.debug(b),
- log$5.warn("cache query error", i),
- Promise.resolve(i)
- }
- if (_ && _.model) {
- let b = null;
- const k = Date.now();
- if (_.model instanceof Blob ? b = _.model : b = dataURItoBlob(_.model),
- !b)
- return Promise.reject("blob is null");
- const j = Date.now();
- this.secondArray.add(j - k);
- const $ = Promise.resolve(d ? URL.createObjectURL(b) : b);
- return window.performance.now(),
- $
- } else
- return this.request({
- url: i,
- timeout: s,
- contentType: "blob",
- key: c
- }).then(async b=>{
- const k = await blobToDataURI(b.response);
- try {
- await modelTable.put({
- url: i,
- model: k
- })
- } catch (j) {
- log$5.warn("unable to add data to indexedDB", j)
- }
- return Promise.resolve(d ? URL.createObjectURL(b.response) : b.response)
- }
- )
- } else
- return this.request({
- url: i,
- timeout: s,
- contentType: "blob",
- key: c
- }).then(_=>{
- const b = _.response;
- return Promise.resolve(d ? URL.createObjectURL(b) : b)
- }
- ).catch(_=>Promise.reject(_));
- else
- return this.request({
- url: i,
- timeout: s,
- key: c
- }).then(_=>_.getResponseHeader("content-type") === "application/json" ? Promise.resolve(JSON.parse(_.responseText)) : Promise.resolve(_.responseText))
- }
- request(i) {
- const {timeout: o=3e4, contentType: s, key: c, onRequestStart: d} = i
- , {url: _} = i;
- return new Promise((b,k)=>{
- window.performance.now();
- const j = new XMLHttpRequest;
- s && (j.responseType = s),
- j.timeout = o,
- j.addEventListener("readystatechange", ()=>{
- if (j.readyState == 4) {
- if (j.status == 200)
- return window.performance.now(),
- this.emit("loadend", {
- message: `request ${_} load success`
- }),
- b(j);
- {
- const $ = `Unable to load the request ${_}`;
- return this.emit("error", {
- message: $
- }),
- log$5.error($),
- k($)
- }
- }
- }
- ),
- d && d(j),
- j.open("GET", _),
- j.send()
- }
- )
- }
- }
- const http = new Http
- , isIndexedDbSupported = ()=>(window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB) !== void 0
- , blobToDataURI = async a=>new Promise((e,i)=>{
- const o = new FileReader;
- o.readAsDataURL(a),
- o.onload = function(s) {
- var c;
- e((c = s.target) == null ? void 0 : c.result)
- }
- ,
- o.onerror = function(s) {
- i(s)
- }
- }
- )
- , dataURItoBlob = a=>{
- let e;
- a.split(",")[0].indexOf("base64") >= 0 ? e = atob(a.split(",")[1]) : e = unescape(a.split(",")[1]);
- const i = a.split(",")[0].split(":")[1].split(";")[0]
- , o = new Uint8Array(e.length);
- for (let c = 0; c < e.length; c++)
- o[c] = e.charCodeAt(c);
- return new Blob([o],{
- type: i
- })
- }
- , log$4 = new Logger("xverse-signal");
- class Signal {
- constructor(e) {
- Tt(this, "_room");
- Tt(this, "signalHandleActived", !0);
- Tt(this, "isUpdatedYUV", !0);
- Tt(this, "handleSignalSecondArray", new SecondArray);
- Tt(this, "handleSignalPartialArray2", new SecondArray);
- Tt(this, "handleSignalPartialArray3", new SecondArray);
- Tt(this, "handleSignalPartialArray4", new SecondArray);
- Tt(this, "handleSignalPartialArray5", new SecondArray);
- Tt(this, "handleSignalPartialArray6", new SecondArray);
- Tt(this, "handleSignalPartialArray7", new SecondArray);
- this._room = e
- }
- getSignalStat() {
- const e = this.handleSignalSecondArray.getStat()
- , i = this.handleSignalPartialArray2.getStat().max
- , o = this.handleSignalPartialArray3.getStat().max
- , s = this.handleSignalPartialArray4.getStat().max
- , c = this.handleSignalPartialArray5.getStat().max
- , d = this.handleSignalPartialArray6.getStat().max
- , _ = this.handleSignalPartialArray7.getStat().max
- , b = http.secondArray.getStat();
- return {
- sdkAvg: e.avg,
- sdkMax: e.max,
- blobSum: b.sum,
- blobMax: b.max,
- partialMax: [i, o, s, c, d, _]
- }
- }
- handleSignal(e, i) {
- var tt, rt, it;
- if (!this.signalHandleActived)
- return;
- const o = Date.now()
- , {signal: s, alreadyUpdateYUV: c} = e;
- this.handleActionResponses(s),
- this._room.handleSignalHook(s);
- const d = Date.now();
- if (this.handleSignalPartialArray2.add(d - o),
- !c) {
- const nt = (tt = s.newUserStates) == null ? void 0 : tt.find(ot=>ot.userId === this._room.userId);
- if ((nt == null ? void 0 : nt.renderInfo) && ((rt = this._room._userAvatar) == null ? void 0 : rt.isMoving)) {
- log$4.debug("stream stoped, make avatar to stop");
- const {isMoving: ot, isRotating: at} = nt.renderInfo;
- this._room.avatarManager._updateAvatarMovingStatus({
- id: nt.userId,
- isMoving: !!ot,
- isRotating: !!at
- })
- }
- return
- }
- this.isUpdatedYUV = c;
- const _ = s;
- if (!s) {
- log$4.warn("metadata signal is empty");
- return
- }
- if (_.actionType === Actions.GetNewUserState) {
- eventsManager.remove(_.traceId, _.code, _);
- return
- }
- if (_.code === Codes$1.RepeatLogin) {
- this._room.handleRepetLogin();
- return
- }
- if (_.code !== void 0 && _.code !== Codes$1.Success && _.code !== Codes$1.ActionMaybeDelay && _.code !== Codes$1.DoActionBlocked && _.code !== Codes$1.GetOnVehicle)
- if (_.code === Codes$1.UnReachable)
- log$4.debug("signal errcode: ", _.code),
- this._room.proxyEvents("unreachable");
- else {
- if (!this._room.joined) {
- const nt = getErrorByCode(_.code)
- , ot = new nt(_.msg);
- i(ot)
- }
- log$4.error("signal errcode: ", _),
- this._room.emit("error", _)
- }
- const b = Date.now();
- this.handleSignalPartialArray3.add(b - d);
- const k = (it = _.newUserStates) == null ? void 0 : it.find(nt=>nt.userId === this._room.userId);
- if (_.broadcastAction)
- try {
- const nt = JSON.parse(_.broadcastAction.data);
- Broadcast.handlers.forEach(ot=>ot(nt))
- } catch (nt) {
- log$4.error(nt)
- }
- const j = Date.now();
- this.handleSignalPartialArray4.add(j - b),
- _.newUserStates && _.newUserStates.length > 0 && this._room.avatarManager.handleAvatar(_);
- const $ = Date.now();
- if (this.handleSignalPartialArray5.add($ - j),
- k != null && k.playerState) {
- this._room._currentClickingState = k.playerState;
- const {pathName: nt, attitude: ot, areaName: at, skinId: st} = k.playerState;
- if (nt && (this._room.pathManager.currentPathName = nt,
- this._room.updateCurrentState({
- pathName: nt
- })),
- at && this._room.updateCurrentState({
- areaName: at
- }),
- ot) {
- const ut = this._room.skin.routeList.find(lt=>lt.areaName === this._room.currentState.areaName)
- , ct = ((ut == null ? void 0 : ut.step) || 7.5) * 30;
- this._room.updateCurrentState({
- speed: ct,
- attitude: ot
- }),
- this._room.pathManager.currentAttitude = ot,
- this._room._userAvatar && (this._room._userAvatar.motionType = ot)
- }
- this._room.sceneManager.getCurrentShaderMode() !== ECurrentShaderMode.pano && !this._room.isPano && k.playerState.camera && !this._room.panorama.isLoading && this._room.camera.setCameraPose(k.playerState.camera)
- }
- k != null && k.renderInfo && this._room.camera.handleRenderInfo(k);
- const _e = Date.now();
- if (this.handleSignalPartialArray6.add(_e - $),
- _.actionType !== void 0) {
- const {actionType: nt, code: ot, echoMsg: at, traceId: st} = _;
- nt === Actions.Echo && ot === Codes$1.Success && this._room.networkController.rtcp.heartbeat.pong(at, st),
- 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, _)
- }
- const et = Date.now();
- this.handleSignalSecondArray.add(et - o),
- this.handleSignalPartialArray7.add(et - _e)
- }
- handleActionResponses(e) {
- !(e != null && e.actionResponses) || e.actionResponses.length === 0 || e.actionResponses.forEach(i=>{
- if (i.actionType == null)
- return;
- const {pointType: o, extra: s, actionType: c, traceId: d, code: _, msg: b} = i;
- c === Actions.GetNeighborPoints ? eventsManager.remove(d, _, i.nps) : c === Actions.GetUserWithAvatar ? eventsManager.remove(d, _, i.userWithAvatarList) : eventsManager.remove(d, _, b),
- o === PointType.Path && c === Actions.Clicking && (this._room.moveToExtra = decodeURIComponent(s))
- }
- )
- }
- }
- const BREATH_POINT_TYPE = "debugBreathPoint"
- , TAP_BREATH_POINT_TYPE = "debugTapBreathPoint"
- , DEFAULT_SEARCH_RANGE = 1e3;
- class Debug {
- constructor(e) {
- Tt(this, "isShowNearbyBreathPoints", !1);
- Tt(this, "isShowTapBreathPoints", !1);
- Tt(this, "isSceneShading", !0);
- Tt(this, "searchRange", DEFAULT_SEARCH_RANGE);
- Tt(this, "nearbyBreathPointListening", !1);
- Tt(this, "tapBreathPointListening", !1);
- Tt(this, "dumpStreamTimer", 0);
- this.room = e
- }
- toggleStats() {
- return this.room.stats.isShow ? this.room.stats.hide() : this.room.stats.show()
- }
- toggleNearbyBreathPoint(e=DEFAULT_SEARCH_RANGE) {
- this.searchRange = e,
- this.isShowNearbyBreathPoints = !this.isShowNearbyBreathPoints,
- this.isShowNearbyBreathPoints ? (this.getPointsAndRender(),
- this.setupNearbyBreathPointListener()) : this.room.breathPointManager.clearBreathPoints(BREATH_POINT_TYPE)
- }
- toggleTapBreathPoint() {
- this.isShowTapBreathPoints = !this.isShowTapBreathPoints,
- this.isShowTapBreathPoints ? this.setupTapPointListener() : this.room.breathPointManager.clearBreathPoints(TAP_BREATH_POINT_TYPE)
- }
- dumpStream(e, i=10 * 1e3) {
- if (this.dumpStreamTimer)
- throw new Error("dumpStream running");
- this.room.networkController.rtcp.workers.saveframe = !0,
- this.dumpStreamTimer = window.setTimeout(()=>{
- this.room.networkController.rtcp.workers.SaveMediaStream = !0,
- this.dumpStreamTimer = 0,
- e && e()
- }
- , i)
- }
- toggleSceneshading() {
- this.isSceneShading = !this.isSceneShading,
- this.isSceneShading ? this.room.sceneManager.changeVideoShaderForLowModel() : this.room.sceneManager.changeDefaultShaderForLowModel()
- }
- setupTapPointListener() {
- this.tapBreathPointListening || (this.tapBreathPointListening = !0,
- this.room.on("_coreClick", ({point: e})=>{
- this.isShowTapBreathPoints && this.renderTapBreathPoint({
- id: "tapToint",
- position: e
- })
- }
- ))
- }
- renderTapBreathPoint({position: e, id: i}) {
- let o;
- if (o = this.room.breathPointManager.breathPoints.get(i)) {
- o.position = e;
- return
- }
- this.room.breathPointManager.addBreathPoint({
- id: i,
- position: e,
- type: TAP_BREATH_POINT_TYPE,
- size: .8,
- forceLeaveGround: !0,
- billboardMode: !0,
- rotation: Math.abs(e.z) < 20 ? {
- pitch: 90,
- yaw: 0,
- roll: 0
- } : {
- pitch: 0,
- yaw: 270,
- roll: 0
- }
- })
- }
- setupNearbyBreathPointListener() {
- var e;
- this.nearbyBreathPointListening || (this.nearbyBreathPointListening = !0,
- (e = this.room._userAvatar) == null || e.on("stopMoving", ()=>{
- this.isShowNearbyBreathPoints && this.getPointsAndRender()
- }
- ))
- }
- async getPointsAndRender() {
- var o, s;
- const e = this.searchRange
- , i = ((o = this.room._userAvatar) == null ? void 0 : o.position) && await this.getNeighborPoints({
- point: (s = this.room._userAvatar) == null ? void 0 : s.position,
- containSelf: !0,
- searchRange: e
- }) || [];
- this.room.breathPointManager.breathPoints.forEach(c=>{
- !!i.find(_=>JSON.stringify(_) === c._id) || this.room.breathPointManager.clearBreathPoints(c._id)
- }
- ),
- i.forEach(c=>{
- const d = JSON.stringify(c);
- this.room.breathPointManager.breathPoints.get(d) || this.room.breathPointManager.addBreathPoint({
- id: d,
- position: c,
- type: BREATH_POINT_TYPE,
- rotation: {
- pitch: 90,
- yaw: 0,
- roll: 0
- },
- forceLeaveGround: !0
- })
- }
- )
- }
- getNeighborPoints(e) {
- const {point: i, containSelf: o=!1, searchRange: s=500} = e;
- return this.room.actionsHandler.getNeighborPoints({
- point: i,
- containSelf: o,
- searchRange: s
- })
- }
- }
- const log$3 = new Logger("xverse-room");
- class XverseRoom$1 extends EventEmitter {
- constructor(i) {
- super();
- Tt(this, "disableAutoTurn", !1);
- Tt(this, "options");
- Tt(this, "_currentNetworkOptions");
- Tt(this, "lastSkinId");
- Tt(this, "debug");
- Tt(this, "isFirstDataUsed", !1);
- Tt(this, "userId", null);
- Tt(this, "pathManager", new PathManager);
- Tt(this, "networkController");
- Tt(this, "_startTime", Date.now());
- Tt(this, "canvas");
- Tt(this, "modelManager");
- Tt(this, "eventsController");
- Tt(this, "panorama");
- Tt(this, "engineProxy");
- Tt(this, "_id");
- Tt(this, "skinList", []);
- Tt(this, "isHost", !1);
- Tt(this, "avatarManager", new XverseAvatarManager(this));
- Tt(this, "effectManager", new XverseEffectManager(this));
- Tt(this, "sceneManager");
- Tt(this, "scene");
- Tt(this, "breathPointManager");
- Tt(this, "_currentState");
- Tt(this, "joined", !1);
- Tt(this, "disableRotate", !1);
- Tt(this, "isPano", !1);
- Tt(this, "movingByClick", !1);
- Tt(this, "camera", new Camera(this));
- Tt(this, "stats", new Stats(this));
- Tt(this, "isUpdatedRawYUVData", !1);
- Tt(this, "actionsHandler", new ActionsHandler(this));
- Tt(this, "_currentClickingState", null);
- Tt(this, "signal", new Signal(this));
- Tt(this, "allowRender", !0);
- Tt(this, "firstFrameTimestamp");
- Tt(this, "receiveRtcData", async()=>{
- log$3.info("Invoke receiveRtcData");
- let i = !1
- , o = !1
- , s = !1
- , c = !1;
- return this.viewMode === "serverless" ? (log$3.warn("set view mode to serverless"),
- this.setViewMode("observer").then(()=>this, ()=>this)) : new Promise((d,_)=>{
- const b = this.networkController.rtcp.workers;
- b.registerFunction("signal", k=>{
- this.signal.handleSignal(k, _)
- }
- ),
- b.registerFunction("stream", k=>{
- var j;
- if (this.emit("streamTimestamp", {
- timestamp: Date.now()
- }),
- o || (o = !0,
- log$3.info("Invoke stream event")),
- k.stream) {
- s || (s = !0,
- log$3.info("Invoke updateRawYUVData")),
- this.isUpdatedRawYUVData = !1;
- const $ = (j = this._currentState.skin) == null ? void 0 : j.fov;
- this.sceneManager.materialComponent.updateRawYUVData(k.stream, k.width, k.height, $),
- this.isUpdatedRawYUVData = !0
- }
- i || (log$3.info("Invoke isAfterRenderRegistered"),
- i = !0,
- this.scene.registerAfterRender(()=>{
- this.engineProxy.frameRenderNumber >= 2 && (c || (c = !0,
- log$3.info("Invoke registerAfterRender")),
- this.isFirstDataUsed || (log$3.info("Invoke isStreamAvailable"),
- this.isFirstDataUsed = !0,
- this.firstFrameTimestamp = Date.now(),
- d(this),
- this.afterJoinRoom()))
- }
- ))
- }
- ),
- this.panorama.bindListener(()=>{
- d(this),
- this.afterJoinRoom()
- }
- ),
- b.registerFunction("reconnectedFrame", ()=>{}
- ),
- log$3.info("Invoke decoderWorker.postMessage"),
- b.decoderWorker.postMessage({
- t: 5
- })
- }
- )
- }
- );
- Tt(this, "moveToExtra", "");
- this.options = i,
- this.options.wsServerUrl || (this.options.wsServerUrl = SERVER_URLS.DEV),
- this.modelManager = ModelManager.getInstance(i.appId, i.releaseId),
- this.updateReporter();
- const c = i
- , {canvas: o} = c
- , s = gr(c, ["canvas"]);
- log$3.infoAndReportMeasurement({
- metric: "startJoinRoomAt",
- startTime: Date.now(),
- group: "joinRoom",
- extra: s,
- value: 0
- })
- }
- get currentNetworkOptions() {
- return this._currentNetworkOptions
- }
- get viewMode() {
- var i;
- return ((i = this._currentState) == null ? void 0 : i.viewMode) || "full"
- }
- get id() {
- return this._id
- }
- get skinId() {
- return this._currentState.skinId
- }
- get skin() {
- return this._currentState.skin
- }
- get sessionId() {
- return this.currentNetworkOptions.sessionId
- }
- get pictureQualityLevel() {
- return this.currentState.pictureQualityLevel
- }
- get avatars() {
- return Array.from(this.avatarManager.avatars.values())
- }
- get currentState() {
- var i;
- return Zt($t({}, this._currentState), {
- state: (i = this.networkController) == null ? void 0 : i._state
- })
- }
- get _userAvatar() {
- return this.avatars.find(i=>i.userId === this.userId)
- }
- get tvs() {
- return this.engineProxy._tvs
- }
- get tv() {
- return this.tvs[0]
- }
- get currentClickingState() {
- return this._currentClickingState
- }
- afterJoinRoomHook() {}
- beforeJoinRoomResolveHook() {}
- afterReconnectedHook() {}
- handleSignalHook(i) {}
- skinChangedHook() {}
- async beforeStartGameHook(i) {}
- afterLoadAssetsHook() {}
- afterUserAvatarLoadedHook() {}
- audienceViewModeHook(i) {}
- setViewModeToObserver() {}
- handleVehicleHook(i) {}
- updateReporter() {
- const {avatarId: i, skinId: o, userId: s, roomId: c, role: d, appId: _, wsServerUrl: b} = this.options;
- reporter.updateHeader({
- userId: s
- }),
- reporter.updateBody({
- roomId: c,
- role: d,
- skinId: o,
- avatarId: i,
- appId: _,
- wsServerUrl: b
- })
- }
- async initRoom() {
- const {timeout: i=DEFAULT_JOINROOM_TIMEOUT} = this.options;
- return isSupported() ? this._initRoom()._timeout(i, new TimeoutError("initRoom timeout")) : Promise.reject(new UnsupportedError)
- }
- async _initRoom() {
- const i = this.validateOptions(this.options);
- if (i)
- return log$3.error("initRoom param error", i),
- Promise.reject(i);
- 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;
- this.setCurrentNetworkOptions({
- avatarId: s,
- skinId: c,
- roomId: pt,
- userId: d,
- wsServerUrl: _,
- role: b,
- token: k,
- pageSession: j,
- rotationRenderType: $,
- isAllSync: _e,
- appId: et,
- camera: tt,
- player: rt,
- avatarComponents: it,
- nickname: nt,
- avatarScale: ot,
- firends: at,
- syncByEvent: st,
- areaName: ut,
- attitude: ct,
- pathName: lt,
- person: ht,
- roomTypeId: dt,
- hasAvatar: _t,
- syncToOthers: mt,
- prioritySync: vt,
- extra: Et,
- removeWhenDisconnected: yt
- }),
- this.userId = d,
- this.canvas = o,
- ut && (this.pathManager.currentArea = ut),
- this.networkController = new NetworkController(this),
- this.setCurrentState({
- areaName: ut,
- pathName: lt,
- attitude: ct,
- speed: 0,
- viewMode: ft,
- state: this.networkController._state,
- skinId: c
- });
- try {
- await Promise.all([this.initNetwork(), this.initConfig(), this.initWasm()]),
- log$3.info("network config wasm all ready, start to create game");
- const At = await this.requestCreateRoom({
- skinId: c
- })
- , gt = At.routeList.find(xt=>xt.areaName === ut)
- , St = ((gt == null ? void 0 : gt.step) || 7.5) * 30;
- this.updateCurrentState({
- skin: At,
- skinId: At.id,
- versionId: At.versionId,
- speed: St
- }),
- await this.initEngine(At)
- } catch (At) {
- return Promise.reject(At)
- }
- return this.beforeJoinRoomResolve(),
- this.receiveRtcData()
- }
- beforeJoinRoomResolve() {
- this.setupStats(),
- this.eventsController = new EventsController(this),
- this.eventsController.bindEvents(),
- this.panorama = new Panorama(this),
- this.beforeJoinRoomResolveHook()
- }
- afterJoinRoom() {
- this.joined = !0,
- this.viewMode === "observer" && this.setViewModeToObserver(),
- log$3.infoAndReportMeasurement({
- tag: this.viewMode,
- value: this.firstFrameTimestamp || Date.now() - this._startTime,
- startTime: Date.now(),
- metric: "joinRoom",
- reportOptions: {
- immediate: !0
- }
- }),
- this.camera.initialFov = this.sceneManager.cameraComponent.getCameraFov(),
- this.stats.on("stats", ({stats: i})=>{
- reporter.report("stats", $t({}, i))
- }
- ),
- this.debug = new Debug(this),
- this.afterJoinRoomHook(),
- setInterval(()=>{
- this.actionsHandler.getNewUserState(NewUserStateType.NUST_Undefined).then(i=>{
- this.avatarManager.handleAvatar(i)
- }
- ).catch(()=>{}
- )
- }
- , 2e3)
- }
- afterReconnected() {
- this.avatarManager.clearOtherUsers(),
- this.afterReconnectedHook()
- }
- leave() {
- var i, o;
- return log$3.info("Invoke room.leave"),
- (i = this.eventsController) == null || i.clearEvents(),
- (o = this.networkController) == null || o.quit(),
- this
- }
- validateOptions(i) {
- const {canvas: o, avatarId: s, skinId: c, userId: d, role: _, roomId: b, token: k, appId: j, avatarComponents: $} = i || {}
- , _e = [];
- return o instanceof HTMLCanvasElement || _e.push(new ParamError("`canvas` must be instanceof of HTMLCanvasElement")),
- (!d || typeof d != "string") && _e.push(new ParamError("`userId` must be string")),
- (!k || typeof k != "string") && _e.push(new ParamError("`token` must be string")),
- (!j || typeof j != "string") && _e.push(new ParamError("`appId` must be string")),
- _ == "audience" || (!s || !c) && _e.push(new ParamError("`avatarId` and `skinId` is required when create room")),
- _e[0]
- }
- async initNetwork() {
- if (this.viewMode === "serverless")
- return Promise.resolve();
- const i = Date.now();
- try {
- await this.networkController.connect()._timeout(8e3, new InitNetworkTimeoutError),
- log$3.infoAndReportMeasurement({
- metric: "networkInitAt",
- startTime: this._startTime,
- group: "joinRoom"
- }),
- log$3.infoAndReportMeasurement({
- metric: "networkInitCost",
- startTime: i,
- group: "joinRoom"
- })
- } catch (o) {
- throw log$3.infoAndReportMeasurement({
- metric: "networkInitAt",
- startTime: i,
- group: "joinRoom",
- error: o
- }),
- o
- }
- }
- async initConfig() {
- const i = Date.now();
- try {
- await this.modelManager.getApplicationConfig()._timeout(8e3, new InitConfigTimeoutError),
- log$3.infoAndReportMeasurement({
- metric: "configInitAt",
- startTime: this._startTime,
- group: "joinRoom"
- }),
- log$3.infoAndReportMeasurement({
- metric: "configInitCost",
- startTime: i,
- group: "joinRoom"
- })
- } catch (o) {
- throw log$3.infoAndReportMeasurement({
- metric: "configInitAt",
- startTime: i,
- group: "joinRoom",
- error: o
- }),
- o
- }
- }
- async initEngine(i) {
- const o = Date.now();
- try {
- this.engineProxy = new EngineProxy(this),
- await this.engineProxy.initEngine(i)._timeout(8e3, new InitEngineError("init engine timeout in 8s")),
- log$3.infoAndReportMeasurement({
- metric: "webglInitAt",
- startTime: this._startTime,
- group: "joinRoom"
- }),
- log$3.infoAndReportMeasurement({
- metric: "webglInitCost",
- startTime: o,
- group: "joinRoom"
- });
- return
- } catch (s) {
- let c = s;
- return s.code !== Codes$1.InitEngineTimeout && (c = new InitEngineError(s)),
- log$3.error(s),
- log$3.infoAndReportMeasurement({
- metric: "webglInitAt",
- startTime: o,
- group: "joinRoom",
- error: c
- }),
- Promise.reject(c)
- }
- }
- async initWasm() {
- if (this.viewMode === "serverless")
- return Promise.resolve();
- const i = Date.now();
- try {
- await this.networkController.rtcp.workers.init({
- width: 1920,
- height: 1080,
- userID: this.userId,
- pageSession: this.options.pageSession,
- serverSession: ""
- })._timeout(8e3, new InitDecoderTimeoutError),
- this.networkController.rtcp.workers.registerFunction("error", o=>{
- log$3.error("decode error", o);
- const {code: s, message: c} = o;
- this.emit("error", {
- code: s,
- msg: c
- })
- }
- ),
- log$3.infoAndReportMeasurement({
- metric: "wasmInitAt",
- group: "joinRoom",
- startTime: this._startTime
- }),
- log$3.infoAndReportMeasurement({
- metric: "wasmInitCost",
- group: "joinRoom",
- startTime: i
- }),
- eventsManager.on("traceId", o=>{
- this.networkController.rtcp.workers.onTraceId(o)
- }
- )
- } catch (o) {
- throw log$3.infoAndReportMeasurement({
- metric: "wasmInitAt",
- group: "joinRoom",
- startTime: i,
- error: o
- }),
- o
- }
- }
- async requestCreateRoom({skinId: i}) {
- let o;
- if (i) {
- o = await this.getSkin(i),
- this.updateCurrentState({
- skin: o
- });
- const s = await this.modelManager.findRoute(i, this.options.pathName);
- this.updateCurrentNetworkOptions({
- areaName: s.areaName,
- attitude: s.attitude,
- versionId: o.versionId
- });
- const {camera: c, player: d} = getRandomItem(s.birthPointList) || this.options;
- this.options.camera || this.updateCurrentNetworkOptions({
- camera: c
- }),
- this.options.player || this.updateCurrentNetworkOptions({
- player: d
- })
- }
- if (this.viewMode === "serverless")
- return o;
- try {
- await this.beforeStartGameHook(this.options);
- const {room_id: s, data: c, session_id: d} = await this.networkController.startGame();
- this._id = s;
- const _ = JSON.parse(c);
- this.isHost = _.IsHost,
- i = _.SkinID || i;
- const b = await this.getSkin(i);
- return this.updateCurrentNetworkOptions({
- roomId: s,
- sessionId: d
- }),
- reporter.updateBody({
- roomId: s,
- skinId: i,
- serverSession: d
- }),
- b
- } catch (s) {
- return log$3.error("requestCreateRoom error:", s),
- Promise.reject(s)
- }
- }
- pause() {
- return this.engineProxy.pause()
- }
- resume() {
- return this.engineProxy.resume()
- }
- reconnect() {
- this.networkController.reconnect()
- }
- async setViewMode(i) {}
- handleRepetLogin() {
- log$3.warn("receive " + Codes$1.RepeatLogin + " for repeat login"),
- this.emit("repeatLogin"),
- reporter.disable(),
- this.networkController.quit()
- }
- setPictureQualityLevel(i) {
- const o = {
- high: EImageQuality.high,
- low: EImageQuality.low,
- average: EImageQuality.mid
- };
- return this.updateCurrentState({
- pictureQualityLevel: i
- }),
- this.sceneManager.setImageQuality(o[i])
- }
- async getSkin(i) {
- let o = null;
- if (o = (this.skinList = await this.modelManager.getSkinsList()).find(c=>c.id === i || c.id === i),
- o)
- return o;
- {
- const c = `skin is invalid: skinId: ${i}`;
- return Promise.reject(new ParamError(c))
- }
- }
- setupStats() {
- this.stats.assign({
- roomId: this.id,
- userId: this.userId
- }),
- setInterval(this.engineProxy.updateStats, 1e3)
- }
- proxyEvents(i, o) {
- this.emit(i, o)
- }
- setCurrentNetworkOptions(i) {
- this._currentNetworkOptions = i
- }
- updateCurrentNetworkOptions(i) {
- Object.assign(this._currentNetworkOptions, i),
- Object.assign(this.options, i)
- }
- setCurrentState(i) {
- this._currentState = i
- }
- updateCurrentState(i) {
- i.skinId && (this.lastSkinId = this.currentState.skinId,
- this.updateCurrentNetworkOptions({
- skinId: i.skinId
- })),
- i.versionId && this.updateCurrentNetworkOptions({
- versionId: i.versionId
- }),
- Object.assign(this._currentState, i)
- }
- afterSetUrlHook() {}
- afterTvStopedHook() {}
- afterTvPlayedHook() {}
- pageShowHandler() {
- this.engineProxy.setEnv(this.skin),
- this.allowRender = !0
- }
- pageHideHandler() {
- this.allowRender = !1
- }
- }
- var RenderType = (a=>(a[a.PathVideo = 0] = "PathVideo",
- a[a.RotationVideo = 1] = "RotationVideo",
- a[a.RotationImage = 2] = "RotationImage",
- a[a.PanoramaImage = 3] = "PanoramaImage",
- a[a.CGVideo = 4] = "CGVideo",
- a[a.ClientRotationPano = 5] = "ClientRotationPano",
- a[a.CloudRotationPano = 6] = "CloudRotationPano",
- a))(RenderType || {})
- , Person = (a=>(a[a.Third = 0] = "Third",
- a[a.First = 1] = "First",
- a))(Person || {})
- , LandingType = (a=>(a[a.Stay = 0] = "Stay",
- a[a.InitPoint = 1] = "InitPoint",
- a[a.NewPoint = 2] = "NewPoint",
- a))(LandingType || {})
- , ClickType = (a=>(a[a.Screen = 0] = "Screen",
- a[a.ThreeDimension = 1] = "ThreeDimension",
- a[a.ThreeDimensionQuick = 2] = "ThreeDimensionQuick",
- a[a.IgnoreView = 3] = "IgnoreView",
- a))(ClickType || {})
- , ChangeMode = (a=>(a[a.Preview = 0] = "Preview",
- a[a.Confirm = 1] = "Confirm",
- a[a.Cancel = 2] = "Cancel",
- a))(ChangeMode || {})
- , PointType = (a=>(a[a.Path = 0] = "Path",
- a[a.Item = 1] = "Item",
- a[a.Closeup = 2] = "Closeup",
- a[a.NoValidMatched = 3] = "NoValidMatched",
- a))(PointType || {});
- const log$2 = new Logger("xverse-avatar-tools")
- , isSuit = a=>a === "suit"
- , avatarComponentsParser = async(a=null,e,i=[])=>new Promise(async(o,s)=>{
- var k, j;
- if (e.find($=>isSuit($.type))) {
- const $ = (j = (k = a == null ? void 0 : a.components) == null ? void 0 : k.find(_e=>isSuit(_e.type))) == null ? void 0 : j.suitComb;
- e = e.filter(_e=>($ == null ? void 0 : $.indexOf(_e.type)) === -1)
- }
- const d = e.filter($=>!i.some(_e=>_e.id === $.id));
- d.length === 0 && o([]);
- const _ = [];
- d.forEach(async$=>{
- var tt;
- let _e = (tt = a == null ? void 0 : a.components) == null ? void 0 : tt.find(rt=>rt.type === $.type);
- if (!_e) {
- const rt = `changeComponents, no such component with type: ${$.type}`;
- log$2.error(rt),
- s(rt)
- }
- _e = JSON.parse(JSON.stringify(_e));
- let et = _e == null ? void 0 : _e.units.find(rt=>rt.id === $.id);
- et || (log$2.warn(`changeComponents, no unit with type: ${$.type}, id: ${$.id}`),
- et = _e == null ? void 0 : _e.units.find(rt=>rt.isDefault),
- !et && log$2.warn(`changeComponents, no default unit with type: ${$.type}`)),
- et && _.push({
- id: et.id,
- url: et.url,
- suitComb: (_e == null ? void 0 : _e.suitComb) || [],
- type: $.type
- })
- }
- );
- const b = [];
- Promise.all(b).then($=>{
- _.forEach((_e,et)=>{
- var tt, rt;
- if (!isSuit(_e.type)) {
- const it = ((rt = (tt = a == null ? void 0 : a.components) == null ? void 0 : tt.find(nt=>isSuit(nt.type))) == null ? void 0 : rt.suitComb) || [];
- it.length > 0 && (it == null ? void 0 : it.indexOf(_e.type)) !== -1 && (_e.suitComb = ["suit"])
- }
- _e.url = $[et]
- }
- ),
- o(_)
- }
- ).catch($=>{
- s($)
- }
- )
- }
- )
- , avatarComponentsModify = (a,e)=>new Promise((i,o)=>{
- var b;
- let s = [];
- const c = []
- , d = [];
- let _ = e.some(k=>isSuit(k.type));
- if ((b = a == null ? void 0 : a.components) == null || b.forEach(k=>{
- var _e;
- const j = e.find(et=>et.type === k.type)
- , $ = 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;
- if (j)
- if ($)
- s.push(j);
- else {
- const et = k.units.find(tt=>tt.isDefault) || k.units[0];
- et ? s.push({
- type: k.type,
- id: et.id
- }) : c.push(`component with type: ${k.type} without default and available unit`)
- }
- else if (isSuit(k.type)) {
- const et = k.units.find(tt=>tt.isDefault);
- et && s.push({
- type: k.type,
- id: et.id
- })
- } else {
- const et = k.units.find(tt=>tt.isDefault) || k.units[0];
- et ? s.push({
- type: k.type,
- id: et.id
- }) : c.push(`component with type: ${k.type} without default and available unit`)
- }
- }
- ),
- _ = s.some(k=>isSuit(k.type)),
- _) {
- const k = a == null ? void 0 : a.components.find(j=>isSuit(j.type));
- s = s.filter(j=>(k == null ? void 0 : k.suitComb.indexOf(j.type)) === -1)
- }
- c.length > 0 && (log$2.error(c.join(", ")),
- o(c.join(", "))),
- d.length > 0 && log$2.warn(d.join(", ")),
- i(s)
- }
- )
- , positionPrecisionProtect = a=>{
- const {x: e, y: i, z: o} = a;
- return {
- x: +e.toFixed(2),
- y: +i.toFixed(2),
- z: +o.toFixed(2)
- }
- }
- , rotationPrecisionProtect = a=>{
- const {pitch: e, yaw: i, roll: o} = a;
- return {
- pitch: +e.toFixed(2),
- yaw: +i.toFixed(2),
- roll: +o.toFixed(2)
- }
- }
- , avatarComponentsValidate = (a,e)=>{
- a = a.filter(s=>s.type !== "effect");
- const i = []
- , o = {};
- return Array.isArray(a) ? (a.forEach(s=>{
- o[s.type] ? o[s.type].num++ : o[s.type] = {
- num: 1,
- isSuit: isSuit(s.type)
- }
- }
- ),
- Object.keys(o).forEach(s=>{
- if (o[s].num > 1 && i.push(new ParamError(`avatarComponent with type: ${s} repeated`)),
- o[s].isSuit) {
- const c = e.components.find(d=>isSuit(d.type));
- c == null || c.suitComb.forEach(d=>{
- Object.keys(o).indexOf(d) > -1 && i.push(new ParamError(`suit already contains: ${d}, ${d} repeated`))
- }
- )
- }
- }
- ),
- i[0]) : (i.push(new ParamError("avatarComponents must be array")),
- i[0])
- }
- , safeParseComponents = a=>{
- let e = [];
- try {
- e = JSON.parse(a || "[]")
- } catch {
- e = [],
- log$2.error(`avatarComponents parse error: ${a}`)
- }
- return e
- }
- ;
- var QueueType = (a=>(a.Move = "Move",
- a.Rotate = "Rotate",
- a))(QueueType || {});
- class Queue {
- constructor() {
- Tt(this, "queue", []);
- Tt(this, "currentAction")
- }
- async append(e) {
- var i, o;
- this.queue.length === 0 || ((i = this.currentAction) == null ? void 0 : i.type) === e.type && this.queue.length === 1 ? (this.queue = [],
- this.queue.push(e),
- await this.go()) : (((o = this.queue[this.queue.length - 1]) == null ? void 0 : o.type) === e.type && this.queue.pop(),
- this.queue.push(e))
- }
- async go() {
- if (this.queue.length !== 0) {
- const e = this.queue[0];
- this.currentAction = e,
- await e.action(),
- this.currentAction = void 0,
- this.queue.splice(0, 1),
- await this.go()
- }
- }
- async reject() {
- this.queue = []
- }
- }
- const log$1 = new Logger("xverse-avatar");
- class XverseAvatar extends EventEmitter {
- constructor({userId: i, isHost: o, room: s, avatarId: c, isSelf: d, group: _=AvatarGroup.Npc}) {
- super();
- Tt(this, "xAvatar");
- Tt(this, "_isHost", !1);
- Tt(this, "_room");
- Tt(this, "_withModel", !1);
- Tt(this, "_userId");
- Tt(this, "group", AvatarGroup.User);
- Tt(this, "state", "idle");
- Tt(this, "isLoading", !0);
- Tt(this, "_isMoving", !1);
- Tt(this, "_isRotating", !1);
- Tt(this, "_failed", !1);
- Tt(this, "disconnected", !1);
- Tt(this, "_avatarId");
- Tt(this, "prioritySync", !1);
- Tt(this, "priority", EAvatarRelationRank.Stranger);
- Tt(this, "_avatarModel");
- Tt(this, "_motionType", MotionType.Walk);
- Tt(this, "isSelf", !1);
- Tt(this, "_lastAnimTraceId", "");
- Tt(this, "statusSyncQueue", new Queue);
- Tt(this, "extraInfo", {});
- Tt(this, "attachedEffects", new Set);
- Tt(this, "currentPathName", "");
- Tt(this, "setPosition", i=>{
- var o;
- !this._room.signal.isUpdatedYUV || (o = this.xAvatar) == null || o.setPosition(positionPrecisionProtect(i), !0)
- }
- );
- Tt(this, "setRotation", i=>{
- var o;
- !this._room.signal.isUpdatedYUV || (o = this.xAvatar) == null || o.setRotation(rotationPrecisionProtect(i))
- }
- );
- Tt(this, "stopAnimation", ()=>{
- var i, o;
- (o = (i = this.xAvatar) == null ? void 0 : i.controller) == null || o.stopAnimation()
- }
- );
- Tt(this, "_playAnimation", async(i,o=!0,s=!1)=>{
- var d;
- if (!this._room.signal.isUpdatedYUV)
- return;
- if (this.state !== "idle" && !s)
- return log$1.warn("_playAnimation", i, "state is not idle, play animation failed"),
- Promise.resolve("_playAnimation, state is not idle");
- const c = Date.now();
- try {
- if (!((d = this.xAvatar) != null && d.controller))
- return Promise.reject(new InternalError(`[avatar: ${this.userId}] Play animation failed: ${i}, no controller`));
- this.isSelf && setTimeout(()=>{
- log$1.infoAndReportMeasurement({
- tag: i,
- startTime: c,
- value: 0,
- metric: "playAnimationStart"
- })
- }
- );
- const _ = uuid$1();
- this._lastAnimTraceId = _,
- await this.xAvatar.controller.playAnimation(i, o),
- _ === this._lastAnimTraceId && !this.isMoving && !o && i !== "Idle" && this.xAvatar.controller.playAnimation("Idle", o).catch(b=>{
- log$1.error(`[avatar: ${this.userId}] Play animation failed [force idle]`, b)
- }
- ),
- this.isSelf && log$1.infoAndReportMeasurement({
- tag: i,
- startTime: c,
- extra: {
- loop: o
- },
- metric: "playAnimationEnd"
- })
- } catch (_) {
- return log$1.error(`[avatar: ${this.userId}] Play animation failed: ${i}`, _),
- this.isSelf && log$1.infoAndReportMeasurement({
- tag: i,
- startTime: c,
- metric: "playAnimationEnd",
- error: _,
- extra: {
- loop: o
- }
- }),
- Promise.reject(_)
- }
- }
- );
- Tt(this, "avatarComponentsSync", i=>{
- i = i.map(o=>({
- type: o.type,
- id: o.id
- })),
- this._room.actionsHandler.avatarComponentsSync(i)
- }
- );
- Tt(this, "hide", ()=>{
- var i;
- if ((i = this.xAvatar) != null && i.hide())
- return Promise.resolve(`avatar: ${this.userId} hide success`);
- {
- const o = `avatar: ${this.userId} hide failed ${!this.xAvatar && "without instance: xAvatar"}`;
- return log$1.warn(o),
- Promise.reject(o)
- }
- }
- );
- Tt(this, "show", ()=>{
- var i;
- if ((i = this.xAvatar) != null && i.show())
- return Promise.resolve(`avatar: ${this.userId} show success`);
- {
- const o = `avatar: ${this.userId} show failed ${!this.xAvatar && "without instance: xAvatar"}`;
- return log$1.warn(o),
- Promise.reject(o)
- }
- }
- );
- Tt(this, "sayTimer");
- this._userId = i,
- this._room = s,
- this.isSelf = d || !1,
- this._withModel = !!c,
- this._isHost = o || !1,
- this._avatarId = c,
- this.group = _,
- this._room.modelManager.getAvatarModelList().then(b=>{
- const k = b.find(j=>j.id === c);
- k && (this._avatarModel = k)
- }
- )
- }
- get avatarId() {
- return this._avatarId
- }
- get isRender() {
- var i;
- return !!((i = this.xAvatar) != null && i.isRender)
- }
- get isHidden() {
- var i;
- return !!((i = this.xAvatar) != null && i.isHide)
- }
- get motionType() {
- return this._motionType
- }
- set motionType(i) {
- this._motionType = i
- }
- get nickname() {
- var i;
- return (i = this.xAvatar) == null ? void 0 : i.nickName
- }
- get words() {
- var i;
- return (i = this.xAvatar) == null ? void 0 : i.words
- }
- get isHost() {
- return this._isHost
- }
- get failed() {
- return this._failed
- }
- get scale() {
- var i;
- return (i = this.xAvatar) == null ? void 0 : i.scale
- }
- get animations() {
- var i;
- return !this.xAvatar || !this.xAvatar.controller ? [] : ((i = this.xAvatar) == null ? void 0 : i.getAvaliableAnimations()) || []
- }
- get position() {
- var i;
- return (i = this.xAvatar) == null ? void 0 : i.position
- }
- get rotation() {
- var i;
- return (i = this.xAvatar) == null ? void 0 : i.rotation
- }
- get pose() {
- return {
- position: this.position,
- angle: this.rotation
- }
- }
- get id() {
- return this.userId
- }
- get isMoving() {
- return this._isMoving
- }
- set isMoving(i) {
- this._isMoving = i,
- this.state = i ? "moving" : "idle"
- }
- get isRotating() {
- return this._isRotating
- }
- set isRotating(i) {
- this._isRotating = i,
- this.state = i ? "rotating" : "idle"
- }
- get withModel() {
- return this._withModel
- }
- get avatarComponents() {
- var i;
- return JSON.parse(JSON.stringify(((i = this.xAvatar) == null ? void 0 : i.clothesList) || []))
- }
- get userId() {
- return this._userId
- }
- get removeWhenDisconnected() {
- return this.extraInfo && this.extraInfo.removeWhenDisconnected !== void 0 ? this.extraInfo.removeWhenDisconnected : !0
- }
- setConnectionStatus(i) {
- this.disconnected !== i && (this.disconnected = i,
- i ? this.emit("disconnected") : this.emit("reconnected"),
- log$1.warn(`avatar ${this.userId} status changed, disconnected:`, i))
- }
- setScale(i) {
- var o;
- this.scale !== i && ((o = this.xAvatar) == null || o.setScale(i > 0 ? i : 1))
- }
- async playAnimation(i) {
- const {animationName: o, loop: s, extra: c} = i || {};
- if (this.isSelf) {
- if (this.isMoving)
- try {
- await this.stopMoving()
- } catch (_) {
- return log$1.error(`stopMoving error before playAnimation ${o}`, _),
- Promise.reject(`stopMoving error before playAnimation ${o}`)
- }
- const d = {
- info: {
- userId: this.userId,
- animation: o,
- loop: s,
- extra: encodeURIComponent(c || "")
- },
- broadcastType: CoreBroadcastType.PlayAnimation
- };
- this._room.avatarManager.broadcast.broadcast({
- data: d
- })
- }
- return this.isSelf && (log$1.warn("animationStart emit", o),
- this.emit("animationStart", {
- animationName: o,
- extra: safeDecodeURIComponent(c || "")
- })),
- this._playAnimation(o, s).then(()=>{
- this.isSelf && (log$1.warn("animationEnd emit", o),
- this.emit("animationEnd", {
- animationName: o,
- extra: safeDecodeURIComponent(c || "")
- }))
- }
- )
- }
- async changeComponents(i) {
- const {mode: o, endAnimation: s=""} = i || {}
- , c = JSON.parse(JSON.stringify(i.avatarComponents));
- let d = avatarComponentsValidate(c, this._avatarModel);
- return !ChangeComponentsMode[o] && !d && (d = new ParamError(`changeComponents failed, mode: ${o} is invalid`)),
- d ? (log$1.error(d),
- Promise.reject(d)) : this._changeComponents({
- avatarComponents: c,
- mode: o,
- endAnimation: s
- }).then(()=>{
- this.isSelf && o !== ChangeComponentsMode.Preview && this.avatarComponentsSync(this.avatarComponents)
- }
- )
- }
- async _changeComponents(i) {
- var d;
- const {avatarComponents: o=[], mode: s} = i || {}
- , c = Date.now();
- try {
- if (!this.xAvatar)
- return Promise.reject(new InternalError("changeComponents failed, without instance: xAvatar"));
- const _ = await avatarComponentsModify(this._avatarModel, o)
- , b = []
- , k = await avatarComponentsParser(this._avatarModel, _, this.avatarComponents);
- if (k.length === 0)
- return this.avatarComponents;
- await this.beforeChangeComponentsHook(i);
- for (const j of k) {
- const {id: $, type: _e, url: et, suitComb: tt} = j;
- b.push((d = this.xAvatar) == null ? void 0 : d.addComponent($, _e, et, tt))
- }
- return await Promise.all(b),
- this.emit("componentsChanged", {
- components: this.avatarComponents,
- mode: s
- }),
- this.isSelf && log$1.infoAndReportMeasurement({
- tag: "changeComponents",
- startTime: c,
- metric: "changeComponents",
- extra: {
- inputComponents: o,
- finalComponents: this.avatarComponents,
- mode: ChangeComponentsMode[s]
- }
- }),
- this.avatarComponents
- } catch (_) {
- return this.isSelf && log$1.infoAndReportMeasurement({
- tag: "changeComponents",
- startTime: c,
- metric: "changeComponents",
- error: _,
- extra: {
- inputComponents: o,
- finalComponents: this.avatarComponents,
- mode: ChangeComponentsMode[s]
- }
- }),
- Promise.reject(_)
- }
- }
- async beforeChangeComponentsHook(i) {}
- turnTo(i) {
- if (this._room.viewMode === "observer") {
- this._room.sceneManager.cameraComponent.MainCamera.setTarget(ue4Position2Xverse(i.point));
- return
- }
- return this._room.actionsHandler.turnTo(i).then(()=>{
- this.emit("viewChanged", {
- extra: (i == null ? void 0 : i.extra) || ""
- })
- }
- )
- }
- async moveTo(i) {
- const {point: o, extra: s=""} = i || {};
- if (!this.position)
- return Promise.reject(new ParamError("avatar position is empty"));
- if (typeof s != "string" || typeof s == "string" && s.length > 64) {
- const _ = "extra shoud be string which length less than 64";
- return log$1.warn(_),
- Promise.reject(new ParamError(_))
- }
- const d = getDistance(this.position, o) / 100 > 100 ? MotionType.Run : MotionType.Walk;
- return this._room.actionsHandler.moveTo({
- point: o,
- motionType: d,
- extra: s
- })
- }
- async stopMoving() {
- if (!!this.isMoving)
- return this._room.actionsHandler.stopMoving()
- }
- rotateTo(i) {
- return this._room.actionsHandler.rotateTo(i)
- }
- setRayCast(i) {
- this.xAvatar && (this.xAvatar.isRayCastEnable = i)
- }
- say(i, o) {
- let s, c, d, _;
- if (typeof o == "object" ? (s = o.duration,
- c = o.background,
- d = o.fontSize,
- _ = o.fontColor) : typeof o == "number" && (s = o),
- this.sayTimer && window.clearTimeout(this.sayTimer),
- !this.xAvatar) {
- log$1.error("say failed, without instance: xAvatar");
- return
- }
- this.xAvatar.say(i, {
- scale: this.xAvatar.scale,
- isUser: this.group === AvatarGroup.User,
- background: c,
- fontsize: d,
- fontcolor: _
- }),
- !(s === void 0 || s <= 0) && (this.sayTimer = window.setTimeout(()=>{
- this.silent()
- }
- , s))
- }
- silent() {
- var i;
- if (!this.xAvatar) {
- log$1.error("silent failed, without instance: xAvatar");
- return
- }
- (i = this.xAvatar) == null || i.silent()
- }
- setMotionType({type: i=MotionType.Walk}) {
- return this.motionType === i ? Promise.resolve() : this._room.actionsHandler.setMotionType(i).then(()=>{
- this._motionType = i
- }
- )
- }
- setNickname(i) {
- return this._room.actionsHandler.setNickName(encodeURIComponent(i))
- }
- _setNickname(i) {
- var s, c;
- if (!i)
- return;
- const o = safeDecodeURIComponent(i);
- ((s = this.xAvatar) == null ? void 0 : s.nickName) !== o && (this.isSelf && (this._room.updateCurrentNetworkOptions({
- nickname: o
- }),
- this._room.options.nickname = o),
- (c = this.xAvatar) == null || c.setNickName(o, {
- scale: this.xAvatar.scale
- }))
- }
- _move(i) {
- var k;
- const {start: o, end: s, walkSpeed: c, moveAnimation: d="Walking", inter: _=[], enforceRaycast: b=!0} = i || {};
- return (k = this.xAvatar) == null ? void 0 : k.move(o, s, c, d, _, b)
- }
- moveHermite(i) {
- var k;
- const {start: o, end: s, moveAnimation: c="Walking", duration: d, tension: _, enforceRaycast: b=!1} = i || {};
- return (k = this.xAvatar) == null ? void 0 : k.moveHermite(o, s, d, _, c, b)
- }
- move(i) {
- return this._move(i)
- }
- setPickBoxScale(i=1) {
- return this.xAvatar ? (this.xAvatar.setPickBoxScale(i),
- !0) : (log$1.error("setPickBoxScale failed, without instance: xAvatar"),
- !1)
- }
- transfer(i) {
- const {player: o, camera: s, areaName: c, attitude: d, pathName: _} = i;
- return this._room.actionsHandler.transfer({
- renderType: RenderType.RotationVideo,
- player: o,
- camera: s,
- areaName: c,
- attitude: d,
- pathName: _,
- tag: "transfer"
- })
- }
- avatarLoadedHook() {}
- avatarStartMovingHook() {}
- avatarStopMovingHook() {}
- async statusSync(i) {
- var o, s, c;
- try {
- if ((o = i.event) != null && o.rotateEvent) {
- const {angle: d, speed: _} = i.event.rotateEvent
- , b = this.motionType === MotionType.Run ? "Running" : "Walking";
- this.rotation && (this.rotation.yaw = this.rotation.yaw % 360,
- d.yaw - this.rotation.yaw > 180 && (d.yaw = 180 - d.yaw),
- this.isRotating = !0,
- await this.xAvatar.rotateTo(d, this.rotation, b).then(()=>{
- this._playAnimation("Idle", !0),
- this.isRotating = !1
- }
- ))
- }
- if (i.event && (((s = i.event) == null ? void 0 : s.points.length) || 0) > 1 && !this.isSelf) {
- this.isMoving = !0,
- i.playerState.attitude && (this._motionType = i.playerState.attitude);
- const d = this.motionType === MotionType.Run ? "Running" : "Walking"
- , _ = this._room.skin.routeList.find(k=>k.areaName === this.currentPathName)
- , b = ((_ == null ? void 0 : _.step) || 7.5) * 30 * (25 / 30);
- this.position && await this._move({
- start: this.position,
- end: i.event.points[i.event.points.length - 1],
- walkSpeed: b,
- moveAnimation: d,
- inter: (c = i.event) == null ? void 0 : c.points.slice(0, -1)
- }).then(()=>{
- this.isMoving = !1
- }
- )
- }
- } catch {
- return
- }
- }
- removeAttachedEffects() {
- this.attachedEffects.forEach((i,o)=>{
- this._room.effectManager.removeEffect(o)
- }
- ),
- this.attachedEffects.clear()
- }
- removeAttachedEffect(i) {
- this.attachedEffects.delete(i),
- this._room.effectManager.removeEffect(i)
- }
- faceTo({point: i, rotateSpeed: o=.1}) {
- return this.xAvatar.faceTo(i, o)
- }
- }
- var SyncEventType = (a=>(a[a.Reset = 0] = "Reset",
- a[a.Appear = 1] = "Appear",
- a[a.Disappear = 2] = "Disappear",
- a[a.Move = 3] = "Move",
- a[a.ChangeRenderInfo = 4] = "ChangeRenderInfo",
- a[a.KeepAlive = 5] = "KeepAlive",
- a[a.Rotate = 6] = "Rotate",
- a[a.ET_RemoveVisitor = 7] = "ET_RemoveVisitor",
- a))(SyncEventType || {});
- const log = new Logger("xverse-avatar-manager")
- , pr = class {
- constructor(e) {
- Tt(this, "xAvatarManager");
- Tt(this, "_room");
- Tt(this, "avatars", new Map);
- Tt(this, "syncAvatarsLength", 0);
- Tt(this, "broadcast");
- this._room = e,
- this._usersStatistics(),
- this.broadcast = this.setupBroadcast(),
- e.on("skinChanged", ()=>{
- this.avatars.forEach(i=>{
- i.disconnected && this.removeAvatar(i.userId, !0)
- }
- )
- }
- )
- }
- setupBroadcast() {
- return new Broadcast(this._room,async e=>{
- const {broadcastType: i, info: o} = e;
- if (i !== CoreBroadcastType.PlayAnimation)
- return;
- const {userId: s, animation: c, extra: d, loop: _=!1} = o
- , b = this.avatars.get(s);
- b && !b.isSelf && (b.emit("animationStart", {
- animationName: c,
- extra: decodeURIComponent(d)
- }),
- await (b == null ? void 0 : b._playAnimation(c, _)),
- b.emit("animationEnd", {
- animationName: c,
- extra: decodeURIComponent(d)
- }))
- }
- )
- }
- hideAll(e=!0) {
- this.xAvatarManager.hideAll(e)
- }
- showAll(e=!0) {
- this.xAvatarManager.showAll(e)
- }
- async init() {
- this.xAvatarManager = this._room.sceneManager.avatarComponent;
- try {
- const e = await this._room.modelManager.getApplicationConfig()
- , {avatars: i} = e;
- if (i) {
- await avatarLoader.parse(this._room.sceneManager, i);
- return
- }
- return Promise.reject("cannot find avatar config list")
- } catch (e) {
- return log.error(e),
- Promise.reject("avatar mananger init error!" + e)
- }
- }
- async handleAvatar(e) {
- if (this._room.viewMode === "simple" || !this._room.joined || !e.newUserStates)
- return;
- const i = e.newUserStates;
- if (e.actionType === Actions.GetNewUserState) {
- this.syncAvatarsLength = (i || []).length;
- const o = this._room.avatars.filter(d=>d.group == AvatarGroup.User);
- o.filter(d=>!(i != null && i.find(_=>_.userId == d.userId))).forEach(d=>{
- this.removeAvatar(d.userId)
- }
- );
- const c = i.filter(d=>!o.find(_=>_.userId == d.userId));
- this._handleAvatar(c)
- } else
- this._handleAvatar(i)
- }
- async _handleAvatar(e) {
- e == null || e.forEach(i=>{
- var s, c, d, _, b, k, j, $, _e;
- const o = this._room.userId === i.userId;
- if (((s = i.event) == null ? void 0 : s.type) === SyncEventType.ET_RemoveVisitor) {
- const et = (d = (c = i.event) == null ? void 0 : c.removeVisitorEvent) == null ? void 0 : d.removeVisitorEvent
- , tt = JSON.parse(safeDecodeURIComponent(((b = (_ = i.event) == null ? void 0 : _.removeVisitorEvent) == null ? void 0 : b.extraInfo) || ""))
- , {code: rt, msg: it} = tt;
- et === RemoveVisitorType.RVT_ChangeToObserver ? this._room.audienceViewModeHook(tt) : et === RemoveVisitorType.RVT_MoveOutOfTheRoom && this._room.leave(),
- this._room.proxyEvents("kicked", {
- code: rt,
- msg: it
- }),
- log.warn("kicked emit: ", {
- code: rt,
- msg: it
- })
- }
- if (i.event && [SyncEventType.Appear, SyncEventType.Reset].includes(i.event.type)) {
- let et = this.avatars.get(i.userId);
- if (et && i.playerState.avatarId && (et == null ? void 0 : et.avatarId) !== i.playerState.avatarId && (et = void 0,
- this.removeAvatar(i.userId, !0)),
- et) {
- if (i.playerState.pathName && (et.currentPathName = i.playerState.pathName),
- et.disconnected && et.setConnectionStatus(!1),
- (k = i.event) != null && k.id && this._room.actionsHandler.confirmEvent(i.event.id),
- i.playerState.nickName && (et == null || et._setNickname(i.playerState.nickName)),
- i.playerState.avatarComponents && !et.isSelf && et.xAvatar) {
- const tt = safeParseComponents(i.playerState.avatarComponents);
- et._changeComponents({
- avatarComponents: tt,
- mode: ChangeComponentsMode.Preview
- })
- }
- if (!et.isSelf && et.position && (et.statusSyncQueue.queue.length === 0 || !et.statusSyncQueue.currentAction)) {
- const {x: tt, y: rt} = et.position
- , {x: it, y: nt} = i.playerState.player.position;
- (Math.abs(tt - it) > 50 || Math.abs(rt - nt) > 50) && (et.setPosition(i.playerState.player.position),
- et.setRotation(i.playerState.player.angle))
- }
- } else {
- if (!i.playerState.player)
- return;
- const {position: tt, angle: rt} = i.playerState.player
- , it = i.playerState.avatarId
- , nt = i.playerState.prioritySync
- , ot = safelyJsonParse(i.playerState.extra)
- , at = safeParseComponents(i.playerState.avatarComponents)
- , st = safeDecodeURIComponent(i.playerState.nickName)
- , ut = this.calculatePriority(i.userId, ot);
- this.addAvatar({
- userId: i.userId,
- isHost: i.playerState.isHost,
- nickname: st,
- avatarPosition: tt,
- avatarRotation: rt,
- avatarScale: i.playerState.avatarSize,
- avatarId: it,
- avatarComponents: i.playerState.person === Person.First ? [] : at,
- priority: ut,
- group: AvatarGroup.User,
- prioritySync: nt,
- extraInfo: ot
- }).then(ct=>{
- var lt;
- i.playerState.pathName && (ct.currentPathName = i.playerState.pathName),
- (lt = i.event) != null && lt.id && this._room.actionsHandler.confirmEvent(i.event.id),
- this.updateAvatarPositionAndRotation(i),
- o && (this.xAvatarManager.setMainAvatar(i.userId),
- this._room.emit("userAvatarLoaded"),
- log.info("userAvatarLoaded"))
- }
- ).catch(ct=>{
- o && (this.xAvatarManager.setMainAvatar(i.userId),
- this._room.emit("userAvatarFailed", {
- error: ct
- }),
- log.error("userAvatarFailed", ct))
- }
- )
- }
- }
- 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),
- this.removeAvatar(i.userId)),
- i.event && [SyncEventType.Move, SyncEventType.ChangeRenderInfo].includes(i.event.type) || !i.event) {
- ($ = i == null ? void 0 : i.event) != null && $.id && this._room.actionsHandler.confirmEvent(i.event.id);
- const et = this.avatars.get(i.userId);
- et && et.withModel && !et.isLoading && this.updateAvatarPositionAndRotation(i)
- }
- if (!o && ((_e = i.event) == null ? void 0 : _e.type) === SyncEventType.Rotate) {
- const et = this.avatars.get(i.userId);
- et.statusSyncQueue.append({
- type: QueueType.Rotate,
- action: ()=>et.statusSync(i)
- })
- }
- }
- )
- }
- calculatePriority(e, i) {
- var s;
- return e === this._room.userId ? EAvatarRelationRank.Self : (s = this._room.options.firends) != null && s.includes(e) ? EAvatarRelationRank.Friend : EAvatarRelationRank.Stranger
- }
- updateAvatarPositionAndRotation(e) {
- var i, o;
- if ((i = e == null ? void 0 : e.playerState) != null && i.player) {
- let {position: s, angle: c} = e.playerState.player;
- const d = this.avatars.get(e.userId);
- if (!d)
- return;
- if (s = positionPrecisionProtect(s),
- c = rotationPrecisionProtect(c),
- d.isSelf && !this._room.networkController.rtcp.workers.inPanoMode && (d.setPosition(s),
- d.setRotation(c)),
- e.event && (((o = e.event) == null ? void 0 : o.points.length) || 0) > 1 && !d.isSelf && d.statusSyncQueue.append({
- type: QueueType.Move,
- action: ()=>d.statusSync(e)
- }),
- e.renderInfo && d.isSelf) {
- const {isMoving: _, isRotating: b} = e.renderInfo;
- this._updateAvatarMovingStatus({
- id: e.userId,
- isMoving: !!_,
- isRotating: !!b
- })
- }
- }
- }
- async addAvatar(e) {
- 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
- , tt = i === this._room.userId;
- let rt = this.avatars.get(i);
- if (rt)
- return Promise.resolve(rt);
- if (rt = new pr.subAvatar({
- userId: i,
- isHost: o,
- isSelf: tt,
- room: this._room,
- avatarComponents: b,
- avatarId: c,
- nickname: _,
- group: j
- }),
- this.avatars.set(i, rt),
- !rt.withModel)
- return rt.isLoading = !1,
- rt.avatarLoadedHook(),
- this._room.emit("avatarChanged", {
- avatars: this._room.avatars
- }),
- rt;
- const nt = (await this._room.modelManager.getAvatarModelList()).find(at=>at.id === c)
- , ot = Date.now();
- if (!nt)
- return this._room.emit("avatarChanged", {
- avatars: this._room.avatars
- }),
- this.avatars.delete(i),
- Promise.reject(`no such avatar model with id: ${c}`);
- try {
- let at = await avatarComponentsModify(nt, b);
- at = at.filter(ct=>ct.type != "pendant");
- const st = await avatarComponentsParser(nt, at)
- , ut = await this.xAvatarManager.loadAvatar({
- id: i,
- avatarType: c,
- priority: k,
- avatarManager: this.xAvatarManager,
- assets: st,
- status: {
- avatarPosition: s,
- avatarRotation: d,
- avatarScale: $
- }
- })._timeout(8e3, new TimeoutError$1("loadAvatar timeout(8s)"));
- return ut.setPickBoxScale(i === this._room.userId ? 0 : 1),
- rt.xAvatar = ut,
- rt.setScale($),
- s && rt.setPosition(s),
- rt.extraInfo = _e,
- rt.priority = k,
- rt.isLoading = !1,
- rt.prioritySync = !!et,
- rt._playAnimation("Idle", !0, !0),
- rt.avatarLoadedHook(),
- this._room.emit("avatarChanged", {
- avatars: this._room.avatars
- }),
- _ && rt._setNickname(_),
- i === this._room.userId && (log.infoAndReportMeasurement({
- metric: "avatarLoadDuration",
- startTime: ot,
- group: "costs"
- }),
- log.infoAndReportMeasurement({
- metric: "avatarLoadAt",
- startTime: this._room._startTime,
- group: "costs"
- })),
- rt
- } catch (at) {
- return rt.isLoading = !1,
- this._room.emit("avatarChanged", {
- avatars: this._room.avatars
- }),
- log.error(at),
- Promise.reject(at)
- }
- }
- removeAvatar(e, i=!1) {
- const o = this.avatars.get(e);
- if (!!o) {
- if (o.removeWhenDisconnected || i) {
- o.removeAttachedEffects(),
- o.xAvatar && this.xAvatarManager.deleteAvatar(o.xAvatar),
- this.avatars.delete(e),
- this._room.emit("avatarChanged", {
- avatars: this._room.avatars
- });
- return
- }
- o.setConnectionStatus(!0)
- }
- }
- clearOtherUsers() {
- this.avatars.forEach(e=>{
- !e.isSelf && e.group === AvatarGroup.User && this.removeAvatar(e.userId)
- }
- )
- }
- async _updateAvatarMovingStatus(e) {
- var d, _;
- const {id: i, isMoving: o, isRotating: s} = e
- , c = this.avatars.get(i);
- if (!!c) {
- if (c.isRotating !== s) {
- c.isRotating = s;
- let b = "Idle";
- s && (b = "Walking",
- c.motionType === MotionType.Run && (b = "Running")),
- c._playAnimation(b, !0, !0),
- log.infoAndReportMeasurement({
- startTime: Date.now(),
- value: 0,
- metric: s ? "userAvatarStartRotating" : "userAvatarStopRotating",
- extra: {
- motionType: c.motionType,
- moveToExtra: this._room.moveToExtra
- }
- })
- }
- if (c.isMoving !== o) {
- c.isMoving = o;
- let b = "Idle";
- o && (b = "Walking",
- c.motionType === MotionType.Run && (b = "Running")),
- o ? (c.avatarStartMovingHook(),
- c.isSelf && (log.warn("startMoving emit", this._room.moveToExtra),
- c.emit("startMoving", {
- target: c,
- extra: this._room.moveToExtra
- }))) : (c.avatarStopMovingHook(),
- c.isSelf && (log.warn("stopMoving emit", this._room.moveToExtra),
- c.emit("stopMoving", {
- target: c,
- extra: this._room.moveToExtra
- }))),
- c._playAnimation(b, !0, !0),
- log.infoAndReportMeasurement({
- startTime: Date.now(),
- value: 0,
- metric: o ? "userAvatarStartMoving" : "userAvatarStopMoving",
- extra: {
- motionType: c.motionType,
- moveToExtra: this._room.moveToExtra
- }
- })
- }
- if (o && ((_ = (d = c.xAvatar) == null ? void 0 : d.controller) == null ? void 0 : _.onPlay) === "Idle") {
- let b = "Walking";
- c.motionType === MotionType.Run && (b = "Running"),
- log.error("force avoiding slide step"),
- c._playAnimation(b, !0, !0)
- }
- }
- }
- _usersStatistics() {
- this._room.on("userAvatarLoaded", ()=>{
- window.setInterval(()=>{
- const e = this._room.avatars.filter(o=>o.group === AvatarGroup.User).length || 0
- , i = this._room.avatars.filter(o=>o.group === AvatarGroup.User && o.isRender).length || 0;
- this._room.stats.assign({
- userNum: e,
- syncUserNum: this.syncAvatarsLength,
- renderedUserNum: i
- })
- }
- , 3e3)
- }
- )
- }
- }
- ;
- let XverseAvatarManager = pr;
- Tt(XverseAvatarManager, "subAvatar", XverseAvatar);
- new Logger("Wsutils");
- function downloadFileByBase64(a, e) {
- const i = dataURLtoBlob(a)
- , o = URL.createObjectURL(i);
- downloadFile(o, e)
- }
- function dataURLtoBlob(a) {
- var d;
- const e = a.split(",")
- , i = (d = e[0].match(/:(.*?);/)) == null ? void 0 : d[1]
- , o = atob(e[1]);
- let s = o.length;
- const c = new Uint8Array(s);
- for (; s--; )
- c[s] = o.charCodeAt(s);
- return new Blob([c],{
- type: i
- })
- }
- function downloadFile(a, e="screenShot.png") {
- const i = document.createElement("a");
- i.setAttribute("href", a),
- i.setAttribute("download", e),
- i.setAttribute("target", "_blank");
- const o = document.createEvent("MouseEvents");
- o.initEvent("click", !0, !0),
- i.dispatchEvent(o)
- }
- const distance = (a,e)=>{
- const i = e.x - a.x
- , o = e.y - a.y;
- return Math.sqrt(i * i + o * o)
- }
- , angle = (a,e)=>{
- const i = e.x - a.x
- , o = e.y - a.y;
- return degrees(Math.atan2(o, i))
- }
- , findCoord = (a,e,i)=>{
- const o = {
- x: 0,
- y: 0
- };
- return i = radians(i),
- o.x = a.x - e * Math.cos(i),
- o.y = a.y - e * Math.sin(i),
- o
- }
- , radians = a=>a * (Math.PI / 180)
- , degrees = a=>a * (180 / Math.PI)
- , isPressed = a=>isNaN(a.buttons) ? a.pressure !== 0 : a.buttons !== 0
- , timers = new Map
- , throttle = a=>{
- timers.has(a) && clearTimeout(timers.get(a)),
- timers.set(a, setTimeout(a, 100))
- }
- , bindEvt = (a,e,i)=>{
- const o = e.split(/[ ,]+/g);
- let s;
- for (let c = 0; c < o.length; c += 1)
- s = o[c],
- a.addEventListener ? a.addEventListener(s, i, !1) : a.attachEvent && a.attachEvent(s, i)
- }
- , unbindEvt = (a,e,i)=>{
- const o = e.split(/[ ,]+/g);
- let s;
- for (let c = 0; c < o.length; c += 1)
- s = o[c],
- a.removeEventListener ? a.removeEventListener(s, i) : a.detachEvent && a.detachEvent(s, i)
- }
- , prepareEvent = a=>(a.preventDefault(),
- a.type.match(/^touch/) ? a.changedTouches : a)
- , getScroll = ()=>{
- const a = window.pageXOffset !== void 0 ? window.pageXOffset : (document.documentElement || document.body.parentNode || document.body).scrollLeft
- , e = window.pageYOffset !== void 0 ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop;
- return {
- x: a,
- y: e
- }
- }
- , applyPosition = (a,e)=>{
- e.top || e.right || e.bottom || e.left ? (a.style.top = e.top,
- a.style.right = e.right,
- a.style.bottom = e.bottom,
- a.style.left = e.left) : (a.style.left = e.x + "px",
- a.style.top = e.y + "px")
- }
- , getTransitionStyle = (a,e,i)=>{
- const o = configStylePropertyObject(a);
- for (let s in o)
- if (o.hasOwnProperty(s))
- if (typeof e == "string")
- o[s] = e + " " + i;
- else {
- let c = "";
- for (let d = 0, _ = e.length; d < _; d += 1)
- c += e[d] + " " + i + ", ";
- o[s] = c.slice(0, -2)
- }
- return o
- }
- , getVendorStyle = (a,e)=>{
- const i = configStylePropertyObject(a);
- for (let o in i)
- i.hasOwnProperty(o) && (i[o] = e);
- return i
- }
- , configStylePropertyObject = a=>{
- const e = {};
- return e[a] = "",
- ["webkit", "Moz", "o"].forEach(function(o) {
- e[o + a.charAt(0).toUpperCase() + a.slice(1)] = ""
- }),
- e
- }
- , extend = (a,e)=>{
- for (let i in e)
- e.hasOwnProperty(i) && (a[i] = e[i]);
- return a
- }
- , safeExtend = (a,e)=>{
- const i = {};
- for (let o in a)
- a.hasOwnProperty(o) && e.hasOwnProperty(o) ? i[o] = e[o] : a.hasOwnProperty(o) && (i[o] = a[o]);
- return i
- }
- , map = (a,e)=>{
- if (a.length)
- for (let i = 0, o = a.length; i < o; i += 1)
- e(a[i]);
- else
- e(a)
- }
- , clamp = (a,e,i)=>({
- x: Math.min(Math.max(a.x, e.x - i), e.x + i),
- y: Math.min(Math.max(a.y, e.y - i), e.y + i)
- });
- var isTouch = "ontouchstart"in window, isPointer = !!window.PointerEvent, isMSPointer = !!window.MSPointerEvent, events = {
- touch: {
- start: "touchstart",
- move: "touchmove",
- end: "touchend, touchcancel"
- },
- mouse: {
- start: "mousedown",
- move: "mousemove",
- end: "mouseup"
- },
- pointer: {
- start: "pointerdown",
- move: "pointermove",
- end: "pointerup, pointercancel"
- },
- MSPointer: {
- start: "MSPointerDown",
- move: "MSPointerMove",
- end: "MSPointerUp"
- }
- }, toBind, secondBind = {};
- isPointer ? toBind = events.pointer : isMSPointer ? toBind = events.MSPointer : isTouch ? (toBind = events.touch,
- secondBind = events.mouse) : toBind = events.mouse;
- function Super() {}
- Super.prototype.on = function(a, e) {
- var i = this, o = a.split(/[ ,]+/g), s;
- i._handlers_ = i._handlers_ || {};
- for (var c = 0; c < o.length; c += 1)
- s = o[c],
- i._handlers_[s] = i._handlers_[s] || [],
- i._handlers_[s].push(e);
- return i
- }
- ;
- Super.prototype.off = function(a, e) {
- var i = this;
- return i._handlers_ = i._handlers_ || {},
- 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),
- i
- }
- ;
- Super.prototype.trigger = function(a, e) {
- var i = this, o = a.split(/[ ,]+/g), s;
- i._handlers_ = i._handlers_ || {};
- for (var c = 0; c < o.length; c += 1)
- s = o[c],
- i._handlers_[s] && i._handlers_[s].length && i._handlers_[s].forEach(function(d) {
- d.call(i, {
- type: s,
- target: i
- }, e)
- })
- }
- ;
- Super.prototype.config = function(a) {
- var e = this;
- e.options = e.defaults || {},
- a && (e.options = safeExtend(e.options, a))
- }
- ;
- Super.prototype.bindEvt = function(a, e) {
- var i = this;
- return i._domHandlers_ = i._domHandlers_ || {},
- i._domHandlers_[e] = function() {
- typeof i["on" + e] == "function" ? i["on" + e].apply(i, arguments) : console.warn('[WARNING] : Missing "on' + e + '" handler.')
- }
- ,
- bindEvt(a, toBind[e], i._domHandlers_[e]),
- secondBind[e] && bindEvt(a, secondBind[e], i._domHandlers_[e]),
- i
- }
- ;
- Super.prototype.unbindEvt = function(a, e) {
- var i = this;
- return i._domHandlers_ = i._domHandlers_ || {},
- unbindEvt(a, toBind[e], i._domHandlers_[e]),
- secondBind[e] && unbindEvt(a, secondBind[e], i._domHandlers_[e]),
- delete i._domHandlers_[e],
- this
- }
- ;
- function Nipple(a, e) {
- return this.identifier = e.identifier,
- this.position = e.position,
- this.frontPosition = e.frontPosition,
- this.collection = a,
- this.defaults = {
- size: 100,
- threshold: .1,
- color: "white",
- fadeTime: 250,
- dataOnly: !1,
- restJoystick: !0,
- restOpacity: .5,
- mode: "dynamic",
- zone: document.body,
- lockX: !1,
- lockY: !1,
- shape: "circle"
- },
- this.config(e),
- this.options.mode === "dynamic" && (this.options.restOpacity = 0),
- this.id = Nipple.id,
- Nipple.id += 1,
- this.buildEl().stylize(),
- this.instance = {
- el: this.ui.el,
- on: this.on.bind(this),
- off: this.off.bind(this),
- show: this.show.bind(this),
- hide: this.hide.bind(this),
- add: this.addToDom.bind(this),
- remove: this.removeFromDom.bind(this),
- destroy: this.destroy.bind(this),
- setPosition: this.setPosition.bind(this),
- resetDirection: this.resetDirection.bind(this),
- computeDirection: this.computeDirection.bind(this),
- trigger: this.trigger.bind(this),
- position: this.position,
- frontPosition: this.frontPosition,
- ui: this.ui,
- identifier: this.identifier,
- id: this.id,
- options: this.options
- },
- this.instance
- }
- Nipple.prototype = new Super;
- Nipple.constructor = Nipple;
- Nipple.id = 0;
- Nipple.prototype.buildEl = function(a) {
- return this.ui = {},
- this.options.dataOnly ? this : (this.ui.el = document.createElement("div"),
- this.ui.back = document.createElement("div"),
- this.ui.front = document.createElement("div"),
- this.ui.el.className = "nipple collection_" + this.collection.id,
- this.ui.back.className = "back",
- this.ui.front.className = "front",
- this.ui.el.setAttribute("id", "nipple_" + this.collection.id + "_" + this.id),
- this.ui.el.appendChild(this.ui.back),
- this.ui.el.appendChild(this.ui.front),
- this)
- }
- ;
- Nipple.prototype.stylize = function() {
- if (this.options.dataOnly)
- return this;
- var a = this.options.fadeTime + "ms"
- , e = getVendorStyle("borderRadius", "50%")
- , i = getTransitionStyle("transition", "opacity", a)
- , o = {};
- return o.el = {
- position: "absolute",
- opacity: this.options.restOpacity,
- display: "block",
- zIndex: 999
- },
- o.back = {
- position: "absolute",
- display: "block",
- width: this.options.size + "px",
- height: this.options.size + "px",
- marginLeft: -this.options.size / 2 + "px",
- marginTop: -this.options.size / 2 + "px",
- background: this.options.color,
- opacity: ".5"
- },
- o.front = {
- width: this.options.size / 2 + "px",
- height: this.options.size / 2 + "px",
- position: "absolute",
- display: "block",
- marginLeft: -this.options.size / 4 + "px",
- marginTop: -this.options.size / 4 + "px",
- background: this.options.color,
- opacity: ".5"
- },
- extend(o.el, i),
- this.options.shape === "circle" && extend(o.back, e),
- extend(o.front, e),
- this.applyStyles(o),
- this
- }
- ;
- Nipple.prototype.applyStyles = function(a) {
- for (var e in this.ui)
- if (this.ui.hasOwnProperty(e))
- for (var i in a[e])
- this.ui[e].style[i] = a[e][i];
- return this
- }
- ;
- Nipple.prototype.addToDom = function() {
- return this.options.dataOnly || document.body.contains(this.ui.el) ? this : (this.options.zone.appendChild(this.ui.el),
- this)
- }
- ;
- Nipple.prototype.removeFromDom = function() {
- return this.options.dataOnly || !document.body.contains(this.ui.el) ? this : (this.options.zone.removeChild(this.ui.el),
- this)
- }
- ;
- Nipple.prototype.destroy = function() {
- clearTimeout(this.removeTimeout),
- clearTimeout(this.showTimeout),
- clearTimeout(this.restTimeout),
- this.trigger("destroyed", this.instance),
- this.removeFromDom(),
- this.off()
- }
- ;
- Nipple.prototype.show = function(a) {
- var e = this;
- return e.options.dataOnly || (clearTimeout(e.removeTimeout),
- clearTimeout(e.showTimeout),
- clearTimeout(e.restTimeout),
- e.addToDom(),
- e.restCallback(),
- setTimeout(function() {
- e.ui.el.style.opacity = 1
- }, 0),
- e.showTimeout = setTimeout(function() {
- e.trigger("shown", e.instance),
- typeof a == "function" && a.call(this)
- }, e.options.fadeTime)),
- e
- }
- ;
- Nipple.prototype.hide = function(a) {
- var e = this;
- if (e.options.dataOnly)
- return e;
- if (e.ui.el.style.opacity = e.options.restOpacity,
- clearTimeout(e.removeTimeout),
- clearTimeout(e.showTimeout),
- clearTimeout(e.restTimeout),
- e.removeTimeout = setTimeout(function() {
- var i = e.options.mode === "dynamic" ? "none" : "block";
- e.ui.el.style.display = i,
- typeof a == "function" && a.call(e),
- e.trigger("hidden", e.instance)
- }, e.options.fadeTime),
- e.options.restJoystick) {
- const i = e.options.restJoystick
- , o = {};
- o.x = i === !0 || i.x !== !1 ? 0 : e.instance.frontPosition.x,
- o.y = i === !0 || i.y !== !1 ? 0 : e.instance.frontPosition.y,
- e.setPosition(a, o)
- }
- return e
- }
- ;
- Nipple.prototype.setPosition = function(a, e) {
- var i = this;
- i.frontPosition = {
- x: e.x,
- y: e.y
- };
- var o = i.options.fadeTime + "ms"
- , s = {};
- s.front = getTransitionStyle("transition", ["top", "left"], o);
- var c = {
- front: {}
- };
- c.front = {
- left: i.frontPosition.x + "px",
- top: i.frontPosition.y + "px"
- },
- i.applyStyles(s),
- i.applyStyles(c),
- i.restTimeout = setTimeout(function() {
- typeof a == "function" && a.call(i),
- i.restCallback()
- }, i.options.fadeTime)
- }
- ;
- Nipple.prototype.restCallback = function() {
- var a = this
- , e = {};
- e.front = getTransitionStyle("transition", "none", ""),
- a.applyStyles(e),
- a.trigger("rested", a.instance)
- }
- ;
- Nipple.prototype.resetDirection = function() {
- this.direction = {
- x: !1,
- y: !1,
- angle: !1
- }
- }
- ;
- Nipple.prototype.computeDirection = function(a) {
- var e = a.angle.radian, i = Math.PI / 4, o = Math.PI / 2, s, c, d;
- 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"),
- a.lockY || (e > -o && e < o ? c = "left" : c = "right"),
- a.lockX || (e > 0 ? d = "up" : d = "down"),
- a.force > this.options.threshold) {
- var _ = {}, b;
- for (b in this.direction)
- this.direction.hasOwnProperty(b) && (_[b] = this.direction[b]);
- var k = {};
- this.direction = {
- x: c,
- y: d,
- angle: s
- },
- a.direction = this.direction;
- for (b in _)
- _[b] === this.direction[b] && (k[b] = !0);
- if (k.x && k.y && k.angle)
- return a;
- (!k.x || !k.y) && this.trigger("plain", a),
- k.x || this.trigger("plain:" + c, a),
- k.y || this.trigger("plain:" + d, a),
- k.angle || this.trigger("dir dir:" + s, a)
- } else
- this.resetDirection();
- return a
- }
- ;
- function Collection(a, e) {
- var i = this;
- i.nipples = [],
- i.idles = [],
- i.actives = [],
- i.ids = [],
- i.pressureIntervals = {},
- i.manager = a,
- i.id = Collection.id,
- Collection.id += 1,
- i.defaults = {
- zone: document.body,
- multitouch: !1,
- maxNumberOfNipples: 10,
- mode: "dynamic",
- position: {
- top: 0,
- left: 0
- },
- catchDistance: 200,
- size: 100,
- threshold: .1,
- color: "white",
- fadeTime: 250,
- dataOnly: !1,
- restJoystick: !0,
- restOpacity: .5,
- lockX: !1,
- lockY: !1,
- shape: "circle",
- dynamicPage: !1,
- follow: !1
- },
- i.config(e),
- (i.options.mode === "static" || i.options.mode === "semi") && (i.options.multitouch = !1),
- i.options.multitouch || (i.options.maxNumberOfNipples = 1);
- const o = getComputedStyle(i.options.zone.parentElement);
- return o && o.display === "flex" && (i.parentIsFlex = !0),
- i.updateBox(),
- i.prepareNipples(),
- i.bindings(),
- i.begin(),
- i.nipples
- }
- Collection.prototype = new Super;
- Collection.constructor = Collection;
- Collection.id = 0;
- Collection.prototype.prepareNipples = function() {
- var a = this
- , e = a.nipples;
- e.on = a.on.bind(a),
- e.off = a.off.bind(a),
- e.options = a.options,
- e.destroy = a.destroy.bind(a),
- e.ids = a.ids,
- e.id = a.id,
- e.processOnMove = a.processOnMove.bind(a),
- e.processOnEnd = a.processOnEnd.bind(a),
- e.get = function(i) {
- if (i === void 0)
- return e[0];
- for (var o = 0, s = e.length; o < s; o += 1)
- if (e[o].identifier === i)
- return e[o];
- return !1
- }
- }
- ;
- Collection.prototype.bindings = function() {
- var a = this;
- a.bindEvt(a.options.zone, "start"),
- a.options.zone.style.touchAction = "none",
- a.options.zone.style.msTouchAction = "none"
- }
- ;
- Collection.prototype.begin = function() {
- var a = this
- , e = a.options;
- if (e.mode === "static") {
- var i = a.createNipple(e.position, a.manager.getIdentifier());
- i.add(),
- a.idles.push(i)
- }
- }
- ;
- Collection.prototype.createNipple = function(a, e) {
- var i = this
- , o = i.manager.scroll
- , s = {}
- , c = i.options
- , d = {
- x: i.parentIsFlex ? o.x : o.x + i.box.left,
- y: i.parentIsFlex ? o.y : o.y + i.box.top
- };
- if (a.x && a.y)
- s = {
- x: a.x - d.x,
- y: a.y - d.y
- };
- else if (a.top || a.right || a.bottom || a.left) {
- var _ = document.createElement("DIV");
- _.style.display = "hidden",
- _.style.top = a.top,
- _.style.right = a.right,
- _.style.bottom = a.bottom,
- _.style.left = a.left,
- _.style.position = "absolute",
- c.zone.appendChild(_);
- var b = _.getBoundingClientRect();
- c.zone.removeChild(_),
- s = a,
- a = {
- x: b.left + o.x,
- y: b.top + o.y
- }
- }
- var k = new Nipple(i,{
- color: c.color,
- size: c.size,
- threshold: c.threshold,
- fadeTime: c.fadeTime,
- dataOnly: c.dataOnly,
- restJoystick: c.restJoystick,
- restOpacity: c.restOpacity,
- mode: c.mode,
- identifier: e,
- position: a,
- zone: c.zone,
- frontPosition: {
- x: 0,
- y: 0
- },
- shape: c.shape
- });
- return c.dataOnly || (applyPosition(k.ui.el, s),
- applyPosition(k.ui.front, k.frontPosition)),
- i.nipples.push(k),
- i.trigger("added " + k.identifier + ":added", k),
- i.manager.trigger("added " + k.identifier + ":added", k),
- i.bindNipple(k),
- k
- }
- ;
- Collection.prototype.updateBox = function() {
- var a = this;
- a.box = a.options.zone.getBoundingClientRect()
- }
- ;
- Collection.prototype.bindNipple = function(a) {
- var e = this, i, o = function(s, c) {
- i = s.type + " " + c.id + ":" + s.type,
- e.trigger(i, c)
- };
- a.on("destroyed", e.onDestroyed.bind(e)),
- a.on("shown hidden rested dir plain", o),
- a.on("dir:up dir:right dir:down dir:left", o),
- a.on("plain:up plain:right plain:down plain:left", o)
- }
- ;
- Collection.prototype.pressureFn = function(a, e, i) {
- var o = this
- , s = 0;
- clearInterval(o.pressureIntervals[i]),
- o.pressureIntervals[i] = setInterval(function() {
- var c = a.force || a.pressure || a.webkitForce || 0;
- c !== s && (e.trigger("pressure", c),
- o.trigger("pressure " + e.identifier + ":pressure", c),
- s = c)
- }
- .bind(o), 100)
- }
- ;
- Collection.prototype.onstart = function(a) {
- var e = this
- , i = e.options
- , o = a;
- a = prepareEvent(a),
- e.updateBox();
- var s = function(c) {
- e.actives.length < i.maxNumberOfNipples ? e.processOnStart(c) : o.type.match(/^touch/) && (Object.keys(e.manager.ids).forEach(function(d) {
- if (Object.values(o.touches).findIndex(function(b) {
- return b.identifier === d
- }) < 0) {
- var _ = [a[0]];
- _.identifier = d,
- e.processOnEnd(_)
- }
- }),
- e.actives.length < i.maxNumberOfNipples && e.processOnStart(c))
- };
- return map(a, s),
- e.manager.bindDocument(),
- !1
- }
- ;
- Collection.prototype.processOnStart = function(a) {
- var e = this, i = e.options, o, s = e.manager.getIdentifier(a), c = a.force || a.pressure || a.webkitForce || 0, d = {
- x: a.pageX,
- y: a.pageY
- }, _ = e.getOrCreate(s, d);
- _.identifier !== s && e.manager.removeIdentifier(_.identifier),
- _.identifier = s;
- var b = function(j) {
- j.trigger("start", j),
- e.trigger("start " + j.id + ":start", j),
- j.show(),
- c > 0 && e.pressureFn(a, j, j.identifier),
- e.processOnMove(a)
- };
- if ((o = e.idles.indexOf(_)) >= 0 && e.idles.splice(o, 1),
- e.actives.push(_),
- e.ids.push(_.identifier),
- i.mode !== "semi")
- b(_);
- else {
- var k = distance(d, _.position);
- if (k <= i.catchDistance)
- b(_);
- else {
- _.destroy(),
- e.processOnStart(a);
- return
- }
- }
- return _
- }
- ;
- Collection.prototype.getOrCreate = function(a, e) {
- var i = this, o = i.options, s;
- return /(semi|static)/.test(o.mode) ? (s = i.idles[0],
- s ? (i.idles.splice(0, 1),
- s) : o.mode === "semi" ? i.createNipple(e, a) : (console.warn("Coudln't find the needed nipple."),
- !1)) : (s = i.createNipple(e, a),
- s)
- }
- ;
- Collection.prototype.processOnMove = function(a) {
- var e = this
- , i = e.options
- , o = e.manager.getIdentifier(a)
- , s = e.nipples.get(o)
- , c = e.manager.scroll;
- if (!isPressed(a)) {
- this.processOnEnd(a);
- return
- }
- if (!s) {
- console.error("Found zombie joystick with ID " + o),
- e.manager.removeIdentifier(o);
- return
- }
- if (i.dynamicPage) {
- var d = s.el.getBoundingClientRect();
- s.position = {
- x: c.x + d.left,
- y: c.y + d.top
- }
- }
- s.identifier = o;
- var _ = s.options.size / 2
- , b = {
- x: a.pageX,
- y: a.pageY
- };
- i.lockX && (b.y = s.position.y),
- i.lockY && (b.x = s.position.x);
- var k = distance(b, s.position), j = angle(b, s.position), $ = radians(j), _e = k / _, et = {
- distance: k,
- position: b
- }, tt, rt;
- if (s.options.shape === "circle" ? (tt = Math.min(k, _),
- rt = findCoord(s.position, tt, j)) : (rt = clamp(b, s.position, _),
- tt = distance(rt, s.position)),
- i.follow) {
- if (k > _) {
- let at = b.x - rt.x
- , st = b.y - rt.y;
- s.position.x += at,
- s.position.y += st,
- s.el.style.top = s.position.y - (e.box.top + c.y) + "px",
- s.el.style.left = s.position.x - (e.box.left + c.x) + "px",
- k = distance(b, s.position)
- }
- } else
- b = rt,
- k = tt;
- var it = b.x - s.position.x
- , nt = b.y - s.position.y;
- s.frontPosition = {
- x: it,
- y: nt
- },
- i.dataOnly || applyPosition(s.ui.front, s.frontPosition);
- var ot = {
- identifier: s.identifier,
- position: b,
- force: _e,
- pressure: a.force || a.pressure || a.webkitForce || 0,
- distance: k,
- angle: {
- radian: $,
- degree: j
- },
- vector: {
- x: it / _,
- y: -nt / _
- },
- raw: et,
- instance: s,
- lockX: i.lockX,
- lockY: i.lockY
- };
- ot = s.computeDirection(ot),
- ot.angle = {
- radian: radians(180 - j),
- degree: 180 - j
- },
- s.trigger("move", ot),
- e.trigger("move " + s.id + ":move", ot)
- }
- ;
- Collection.prototype.processOnEnd = function(a) {
- var e = this
- , i = e.options
- , o = e.manager.getIdentifier(a)
- , s = e.nipples.get(o)
- , c = e.manager.removeIdentifier(s.identifier);
- !s || (i.dataOnly || s.hide(function() {
- i.mode === "dynamic" && (s.trigger("removed", s),
- e.trigger("removed " + s.id + ":removed", s),
- e.manager.trigger("removed " + s.id + ":removed", s),
- s.destroy())
- }),
- clearInterval(e.pressureIntervals[s.identifier]),
- s.resetDirection(),
- s.trigger("end", s),
- e.trigger("end " + s.id + ":end", s),
- e.ids.indexOf(s.identifier) >= 0 && e.ids.splice(e.ids.indexOf(s.identifier), 1),
- e.actives.indexOf(s) >= 0 && e.actives.splice(e.actives.indexOf(s), 1),
- /(semi|static)/.test(i.mode) ? e.idles.push(s) : e.nipples.indexOf(s) >= 0 && e.nipples.splice(e.nipples.indexOf(s), 1),
- e.manager.unbindDocument(),
- /(semi|static)/.test(i.mode) && (e.manager.ids[c.id] = c.identifier))
- }
- ;
- Collection.prototype.onDestroyed = function(a, e) {
- var i = this;
- i.nipples.indexOf(e) >= 0 && i.nipples.splice(i.nipples.indexOf(e), 1),
- i.actives.indexOf(e) >= 0 && i.actives.splice(i.actives.indexOf(e), 1),
- i.idles.indexOf(e) >= 0 && i.idles.splice(i.idles.indexOf(e), 1),
- i.ids.indexOf(e.identifier) >= 0 && i.ids.splice(i.ids.indexOf(e.identifier), 1),
- i.manager.removeIdentifier(e.identifier),
- i.manager.unbindDocument()
- }
- ;
- Collection.prototype.destroy = function() {
- var a = this;
- a.unbindEvt(a.options.zone, "start"),
- a.nipples.forEach(function(i) {
- i.destroy()
- });
- for (var e in a.pressureIntervals)
- a.pressureIntervals.hasOwnProperty(e) && clearInterval(a.pressureIntervals[e]);
- a.trigger("destroyed", a.nipples),
- a.manager.unbindDocument(),
- a.off()
- }
- ;
- function Manager(a) {
- var e = this;
- e.ids = {},
- e.index = 0,
- e.collections = [],
- e.scroll = getScroll(),
- e.config(a),
- e.prepareCollections();
- var i = function() {
- var s;
- e.collections.forEach(function(c) {
- c.forEach(function(d) {
- s = d.el.getBoundingClientRect(),
- d.position = {
- x: e.scroll.x + s.left,
- y: e.scroll.y + s.top
- }
- })
- })
- };
- bindEvt(window, "resize", function() {
- throttle(i)
- });
- var o = function() {
- e.scroll = getScroll()
- };
- return bindEvt(window, "scroll", function() {
- throttle(o)
- }),
- e.collections
- }
- Manager.prototype = new Super;
- Manager.constructor = Manager;
- Manager.prototype.prepareCollections = function() {
- var a = this;
- a.collections.create = a.create.bind(a),
- a.collections.on = a.on.bind(a),
- a.collections.off = a.off.bind(a),
- a.collections.destroy = a.destroy.bind(a),
- a.collections.get = function(e) {
- var i;
- return a.collections.every(function(o) {
- return i = o.get(e),
- !i
- }),
- i
- }
- }
- ;
- Manager.prototype.create = function(a) {
- return this.createCollection(a)
- }
- ;
- Manager.prototype.createCollection = function(a) {
- var e = this
- , i = new Collection(e,a);
- return e.bindCollection(i),
- e.collections.push(i),
- i
- }
- ;
- Manager.prototype.bindCollection = function(a) {
- var e = this, i, o = function(s, c) {
- i = s.type + " " + c.id + ":" + s.type,
- e.trigger(i, c)
- };
- a.on("destroyed", e.onDestroyed.bind(e)),
- a.on("shown hidden rested dir plain", o),
- a.on("dir:up dir:right dir:down dir:left", o),
- a.on("plain:up plain:right plain:down plain:left", o)
- }
- ;
- Manager.prototype.bindDocument = function() {
- var a = this;
- a.binded || (a.bindEvt(document, "move").bindEvt(document, "end"),
- a.binded = !0)
- }
- ;
- Manager.prototype.unbindDocument = function(a) {
- var e = this;
- (!Object.keys(e.ids).length || a === !0) && (e.unbindEvt(document, "move").unbindEvt(document, "end"),
- e.binded = !1)
- }
- ;
- Manager.prototype.getIdentifier = function(a) {
- var e;
- return a ? (e = a.identifier === void 0 ? a.pointerId : a.identifier,
- e === void 0 && (e = this.latest || 0)) : e = this.index,
- this.ids[e] === void 0 && (this.ids[e] = this.index,
- this.index += 1),
- this.latest = e,
- this.ids[e]
- }
- ;
- Manager.prototype.removeIdentifier = function(a) {
- var e = {};
- for (var i in this.ids)
- if (this.ids[i] === a) {
- e.id = i,
- e.identifier = this.ids[i],
- delete this.ids[i];
- break
- }
- return e
- }
- ;
- Manager.prototype.onmove = function(a) {
- var e = this;
- return e.onAny("move", a),
- !1
- }
- ;
- Manager.prototype.onend = function(a) {
- var e = this;
- return e.onAny("end", a),
- !1
- }
- ;
- Manager.prototype.oncancel = function(a) {
- var e = this;
- return e.onAny("end", a),
- !1
- }
- ;
- Manager.prototype.onAny = function(a, e) {
- var i = this, o, s = "processOn" + a.charAt(0).toUpperCase() + a.slice(1);
- e = prepareEvent(e);
- var c = function(_, b, k) {
- k.ids.indexOf(b) >= 0 && (k[s](_),
- _._found_ = !0)
- }
- , d = function(_) {
- o = i.getIdentifier(_),
- map(i.collections, c.bind(null, _, o)),
- _._found_ || i.removeIdentifier(o)
- };
- return map(e, d),
- !1
- }
- ;
- Manager.prototype.destroy = function() {
- var a = this;
- a.unbindDocument(!0),
- a.ids = {},
- a.index = 0,
- a.collections.forEach(function(e) {
- e.destroy()
- }),
- a.off()
- }
- ;
- Manager.prototype.onDestroyed = function(a, e) {
- var i = this;
- if (i.collections.indexOf(e) < 0)
- return !1;
- i.collections.splice(i.collections.indexOf(e), 1)
- }
- ;
- const factory = new Manager;
- var nipplejs = {
- create: function(a) {
- return factory.create(a)
- },
- factory
- };
- class JoyStick {
- constructor(e) {
- Tt(this, "_zone");
- Tt(this, "_joystick", null);
- Tt(this, "_room");
- this._room = e
- }
- get zone() {
- return this._zone
- }
- init(e) {
- var _e, et;
- this.destroy();
- const i = {
- position: "absolute",
- width: "200px",
- height: "200px",
- left: "0px",
- bottom: "0px",
- zIndex: "999",
- userSelect: "none",
- webkitUserSelect: "none"
- }
- , {interval: o=33, triggerDistance: s=25, size: c=110, zoneClassName: d="xverse-joystick-zone"} = e || {};
- typeof ((_e = e == null ? void 0 : e.style) == null ? void 0 : _e.left) == "number" && (e.style.left = e.style.left + "px"),
- typeof ((et = e == null ? void 0 : e.style) == null ? void 0 : et.bottom) == "number" && (e.style.bottom = e.style.bottom + "px");
- const _ = Object.assign(i, e == null ? void 0 : e.style)
- , b = (tt,rt)=>{
- this._room.actionsHandler.joystick({
- degree: Math.floor(tt),
- level: Math.floor(rt / 5)
- })
- }
- , k = this._zone = document.createElement("div");
- document.body.appendChild(k),
- k.className = d,
- Object.keys(_).forEach(tt=>{
- const rt = _[tt];
- rt !== void 0 && (k.style[tt] = rt)
- }
- ),
- this._joystick = nipplejs.create({
- zone: k,
- mode: "static",
- position: {
- left: "50%",
- top: "50%"
- },
- color: "white",
- restOpacity: .3,
- size: c
- }),
- this.customizeStyle();
- let j, $;
- return this._joystick.on("move", (tt,rt)=>{
- j = rt
- }
- ),
- this._joystick.on("start", ()=>{
- $ = window.setInterval(()=>{
- j && j.distance > s && b && b(j.angle.degree, j.distance)
- }
- , o)
- }
- ),
- this._joystick.on("end", ()=>{
- $ && window.clearInterval($),
- $ = void 0
- }
- ),
- this._joystick
- }
- destroy() {
- if (!!this._joystick) {
- this._joystick.destroy();
- try {
- this._zone && document.body.removeChild(this._zone)
- } catch {}
- }
- }
- customizeStyle() {
- var c, d;
- const e = this._zone;
- if (!e)
- return;
- const i = e.querySelector(".front")
- , o = e.querySelector(".back")
- , s = 30;
- i.style.width = s + "px",
- i.style.height = s + "px",
- i.style.marginLeft = s / -2 + "px",
- i.style.marginTop = s / -2 + "px",
- o.style.boxSizing = "border-box",
- o.style.backgroundColor = "black",
- o.style.backgroundClip = "padding-box",
- o.style.border = "2px solid white",
- (c = this._joystick) == null || c.on("start", ()=>{
- o.style.border = "2px solid #FFEA95",
- o.style.boxShadow = "inset 0px 0px 8px rgba(255, 255, 255, 0.25)",
- i.style.opacity = "1"
- }
- ),
- (d = this._joystick) == null || d.on("end", ()=>{
- o.style.border = "2px solid white",
- o.style.boxShadow = "none"
- }
- )
- }
- show() {
- if (!this._joystick || !this._zone)
- throw new Error("joystick is not created");
- this._zone.style.display = "block"
- }
- hide() {
- this._zone && (this._zone.style.display = "none")
- }
- }
- var app = "";
- function toast(a, e) {
- const {onClick: i, duration: o} = e || {};
- return window.Toastify({
- text: a,
- duration: o || 3e3,
- position: "center",
- onClick: function() {
- i && i()
- }
- }).showToast()
- }
- class XverseRoom extends XverseRoom$1 {
- constructor() {
- super(...arguments);
- Tt(this, "joyStick", new JoyStick(this))
- }
- afterJoinRoomHook() {
- this.joyStick.init({
- style: {
- width: "150px",
- height: "150px"
- }
- })
- }
- }
- class Xverse extends Xverse$1 {
- async joinRoom(e) {
- const i = e.pathName || "thirdwalk"
- , o = e.rotationRenderType || RenderType.RotationVideo
- , s = e.person || Person.Third
- , c = new XverseRoom(Zt($t({}, e), {
- appId: e.appId || this.appId,
- releaseId: e.releaseId || this.releaseId,
- pageSession: this.pageSession,
- isAllSync: !0,
- rotationRenderType: o,
- syncByEvent: !0,
- pathName: i,
- person: s,
- role: e.role || "audience"
- }));
- return c.initRoom().then(()=>c)
- }
- }
- var loadingImage = "./assets/loading.f375926b.png"
- , jsxRuntime = {
- exports: {}
- }
- , reactJsxRuntime_production_min = {};
- /** @license React v17.0.2
- * react-jsx-runtime.production.min.js
- *
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
- var f = react.exports
- , g = 60103;
- reactJsxRuntime_production_min.Fragment = 60107;
- if (typeof Symbol == "function" && Symbol.for) {
- var h = Symbol.for;
- g = h("react.element"),
- reactJsxRuntime_production_min.Fragment = h("react.fragment")
- }
- var m = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner
- , n = Object.prototype.hasOwnProperty
- , p = {
- key: !0,
- ref: !0,
- __self: !0,
- __source: !0
- };
- function q(a, e, i) {
- var o, s = {}, c = null, d = null;
- i !== void 0 && (c = "" + i),
- e.key !== void 0 && (c = "" + e.key),
- e.ref !== void 0 && (d = e.ref);
- for (o in e)
- n.call(e, o) && !p.hasOwnProperty(o) && (s[o] = e[o]);
- if (a && a.defaultProps)
- for (o in e = a.defaultProps,
- e)
- s[o] === void 0 && (s[o] = e[o]);
- return {
- $$typeof: g,
- type: a,
- key: c,
- ref: d,
- props: s,
- _owner: m.current
- }
- }
- reactJsxRuntime_production_min.jsx = q;
- reactJsxRuntime_production_min.jsxs = q;
- jsxRuntime.exports = reactJsxRuntime_production_min;
- const jsx = jsxRuntime.exports.jsx
- , jsxs = jsxRuntime.exports.jsxs
- , urlParam = new window.URLSearchParams(location.search)
- , appId = urlParam.get("appId") || void 0
- , releaseId = urlParam.get("releaseId") || void 0
- , scale = Number(urlParam.get("scale") || 1)
- , isDebug = !!urlParam.get("debug");
- appId || alert("AppId \u4E0D\u80FD\u4E3A\u7A7A");
- const xverse = new Xverse({
- env: "DEV",
- appId,
- releaseId
- });
- let room;
- function App() {
- const [a,e] = react.exports.useState(!0)
- , [i,o] = react.exports.useState(!0)
- , [s,c] = react.exports.useState("high")
- , [d,_] = react.exports.useState("");
- react.exports.useEffect(()=>{
- b()
- }
- , []);
- const b = async()=>{
- var ft;
- const _e = document.querySelector("#canvas")
- , et = urlParam.get("roomId") || "e629ef3e-022d-4e64-8654-703bb96410eb"
- , tt = urlParam.get("userId") || Math.random().toString(16).slice(2)
- , rt = urlParam.get("avatarId") || void 0
- , it = urlParam.get("appId") || void 0
- , nt = urlParam.get("skinId") || void 0
- , ot = urlParam.get("pathName") || void 0
- , at = urlParam.get("objectFit") || void 0
- , st = {
- width: parseInt(urlParam.get("width") || "1920"),
- height: parseInt(urlParam.get("height") || "1080")
- }
- , ut = urlParam.get("ws") ? decodeURIComponent(urlParam.get("ws")) : "wss://uat-eks.xverse.cn/ws"
- , ct = !!urlParam.get("preload")
- , lt = "full";
- if (Logger.setLevel(isDebug ? LoggerLevels.Debug : LoggerLevels.Warn),
- ct)
- try {
- await ((ft = xverse.preload) == null ? void 0 : ft.start(lt, (ht,pt)=>{
- const dt = `(${ht}/${pt})`;
- _(dt)
- }
- ))
- } catch (ht) {
- if (console.error(ht),
- ht.code === Codes.PreloadCanceled) {
- toast("\u9884\u52A0\u8F7D\u88AB\u53D6\u6D88");
- return
- }
- toast("\u8FDB\u5165\u5931\u8D25, \u8BF7\u91CD\u8BD5");
- return
- }
- try {
- room = await xverse.joinRoom({
- canvas: _e,
- skinId: nt,
- avatarId: rt,
- roomId: et,
- userId: tt,
- wsServerUrl: ut,
- appId: it,
- token: " ",
- nickname: tt,
- firends: ["user1"],
- viewMode: "full",
- resolution: st,
- pathName: ot,
- objectFit: at,
- hasAvatar: !0,
- syncToOthers: !0,
- avatarScale: scale
- }),
- k(),
- j(),
- window.room = room,
- e(!1)
- } catch (ht) {
- console.error(ht),
- alert(ht);
- return
- }
- }
- , k = ()=>{
- room.on("_coreClick", ({point: _e})=>{
- room._userAvatar.moveTo({
- point: _e
- })
- }
- )
- }
- , j = ()=>{
- room.on("repeatLogin", function() {
- toast("\u8BE5\u7528\u6237\u5DF2\u7ECF\u5728\u5176\u4ED6\u5730\u70B9\u767B\u5F55", {
- duration: 1e4
- })
- }),
- room.on("reconnecting", function({count: _e}) {
- toast(`\u5C1D\u8BD5\u7B2C${_e}\u6B21\u91CD\u8FDE`)
- }),
- room.on("reconnected", function() {
- toast("\u91CD\u8FDE\u6210\u529F")
- }),
- room.on("disconnected", function() {
- const _e = toast("\u8FDE\u63A5\u5931\u8D25\uFF0C\u624B\u52A8\u70B9\u51FB\u91CD\u8BD5", {
- duration: 1e5,
- onClick() {
- _e.hideToast(),
- room.reconnect()
- }
- })
- })
- }
- ;
- return jsxs("div", {
- className: "App",
- children: [jsx("canvas", {
- id: "canvas",
- className: "stream unselect"
- }), !a && isDebug && (()=>jsxs("div", {
- className: "debug_control_btns",
- children: [jsx("button", {
- onClick: ()=>{
- var at, st;
- (at = room.stats) != null && at.isShow ? room.stats.hide() : (st = room.stats) == null || st.show()
- }
- ,
- children: "Toggle Stats"
- }), jsx("button", {
- onClick: ()=>{
- room.debug.toggleSceneshading(),
- o(room.debug.isSceneShading)
- }
- ,
- children: i ? "\u53D6\u6D88\u4F4E\u6A21\u7740\u8272" : "\u4F4E\u6A21\u7740\u8272"
- }), jsxs("button", {
- onClick: ()=>{
- let at = "average";
- s === "high" ? at = "average" : s === "average" ? at = "low" : s === "low" ? at = "high" : at = "average",
- c(at),
- room.setPictureQualityLevel(at)
- }
- ,
- children: ["\u753B\u8D28\uFF1A", s === "high" ? "\u9AD8" : s === "low" ? "\u4F4E" : "\u4E2D"]
- }), jsx("button", {
- onClick: ()=>{
- room.debug.toggleNearbyBreathPoint()
- }
- ,
- className: "font-size-small",
- children: "Toggle\u5468\u8FB9\u547C\u5438\u70B9"
- }), jsx("button", {
- onClick: ()=>{
- room.debug.toggleTapBreathPoint()
- }
- ,
- className: "font-size-small",
- children: "Toggle\u70B9\u51FB\u547C\u5438\u70B9"
- }), jsx("button", {
- onClick: ()=>{
- try {
- room.debug.dumpStream(()=>{
- toast("\u5F55\u5236\u5B8C\u6210")
- }
- ),
- toast("\u5F00\u59CB\u5F55\u5236")
- } catch {
- toast("\u7801\u6D41\u5F55\u5236\u4E2D\uFF0C\u8BF7\u7A0D\u7B49")
- }
- }
- ,
- className: "font-size-small",
- children: "\u5F55\u5236\u7801\u6D41\uFF0810s\uFF09"
- }), jsx("input", {
- onBlur: at=>{
- at.preventDefault();
- const st = at.target.value
- , ut = Number(st);
- if (ut > 0) {
- urlParam.set("scale", String(ut));
- const ct = urlParam.toString();
- location.href = location.origin + location.pathname + "?" + ct
- }
- }
- ,
- placeholder: "\u81EA\u5B9A\u4E49Avatar\u7F29\u653E",
- defaultValue: scale || ""
- })]
- }))(), a && jsxs("div", {
- className: "loading",
- id: "loading",
- children: [jsx("img", {
- src: loadingImage,
- alt: ""
- }), jsxs("div", {
- children: ["\u5373\u5C06\u8FDB\u5165\u573A\u666F ", d]
- })]
- })]
- })
- }
- ReactDOM.render(jsx(React.StrictMode, {
- children: jsx(App, {})
- }), document.getElementById("root"));
|